1 /* 2 * XML Security Library (http://www.aleksey.com/xmlsec). 3 * 4 * Base64 encode/decode transform and utility functions. 5 * 6 * This is free software; see Copyright file in the source 7 * distribution for preciese wording. 8 * 9 * Copyright (C) 2002-2016 Aleksey Sanin <aleksey@aleksey.com>. All Rights Reserved. 10 */ 11 #ifndef __XMLSEC_BASE64_H__ 12 #define __XMLSEC_BASE64_H__ 13 14 #include <libxml/tree.h> 15 16 #include <xmlsec/xmlsec.h> 17 #include <xmlsec/transforms.h> 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif /* __cplusplus */ 22 23 /** 24 * XMLSEC_BASE64_LINESIZE: 25 * 26 * The default maximum base64 encoded line size. 27 */ 28 #define XMLSEC_BASE64_LINESIZE 64 29 30 XMLSEC_EXPORT int xmlSecBase64GetDefaultLineSize (void); 31 XMLSEC_EXPORT void xmlSecBase64SetDefaultLineSize (int columns); 32 33 34 /* Base64 Context */ 35 typedef struct _xmlSecBase64Ctx xmlSecBase64Ctx, 36 *xmlSecBase64CtxPtr; 37 38 XMLSEC_EXPORT xmlSecBase64CtxPtr xmlSecBase64CtxCreate (int encode, 39 int columns); 40 XMLSEC_EXPORT void xmlSecBase64CtxDestroy (xmlSecBase64CtxPtr ctx); 41 XMLSEC_EXPORT int xmlSecBase64CtxInitialize (xmlSecBase64CtxPtr ctx, 42 int encode, 43 int columns); 44 XMLSEC_EXPORT void xmlSecBase64CtxFinalize (xmlSecBase64CtxPtr ctx); 45 XMLSEC_EXPORT int xmlSecBase64CtxUpdate (xmlSecBase64CtxPtr ctx, 46 const xmlSecByte *in, 47 xmlSecSize inSize, 48 xmlSecByte *out, 49 xmlSecSize outSize); 50 XMLSEC_EXPORT int xmlSecBase64CtxFinal (xmlSecBase64CtxPtr ctx, 51 xmlSecByte *out, 52 xmlSecSize outSize); 53 54 /* Standalone routines to do base64 encode/decode "at once" */ 55 XMLSEC_EXPORT xmlChar* xmlSecBase64Encode (const xmlSecByte *buf, 56 xmlSecSize len, 57 int columns); 58 XMLSEC_EXPORT int xmlSecBase64Decode (const xmlChar* str, 59 xmlSecByte *buf, 60 xmlSecSize len); 61 62 #ifdef __cplusplus 63 } 64 #endif /* __cplusplus */ 65 66 #endif /* __XMLSEC_BASE64_H__ */ 67 68