XML Security Library

LibXML2
LibXSLT
OpenSSL

base64

Name

base64 -- Base64 encoding/decoding functions.

Synopsis

#define             XMLSEC_BASE64_LINESIZE
xmlSecBase64CtxPtrxmlSecBase64CtxCreate               (int encode,
                                                         int columns);
voidxmlSecBase64CtxDestroy              (xmlSecBase64CtxPtr ctx);
intxmlSecBase64CtxFinal                (xmlSecBase64CtxPtr ctx,
                                                         xmlSecByte *out,
                                                         xmlSecSize outSize);
voidxmlSecBase64CtxFinalize             (xmlSecBase64CtxPtr ctx);
intxmlSecBase64CtxInitialize           (xmlSecBase64CtxPtr ctx,
                                                         int encode,
                                                         int columns);
intxmlSecBase64CtxUpdate               (xmlSecBase64CtxPtr ctx,
                                                         const xmlSecByte *in,
                                                         xmlSecSize inSize,
                                                         xmlSecByte *out,
                                                         xmlSecSize outSize);
intxmlSecBase64Decode                  (const xmlChar *str,
                                                         xmlSecByte *buf,
                                                         xmlSecSize len);
xmlChar *           xmlSecBase64Encode                  (const xmlSecByte *buf,
                                                         xmlSecSize len,
                                                         int columns);
intxmlSecBase64GetDefaultLineSize      (void);
voidxmlSecBase64SetDefaultLineSize      (int columns);

Description

Base64 encoding/decoding functions.

Details

XMLSEC_BASE64_LINESIZE

#define XMLSEC_BASE64_LINESIZE                          64

The default maximum base64 encoded line size.


xmlSecBase64CtxCreate ()

xmlSecBase64CtxPtr  xmlSecBase64CtxCreate               (int encode,
                                                         int columns);

Allocates and initializes new base64 context.

encode :

the encode/decode flag (1 - encode, 0 - decode)

columns :

the max line length.

Returns :

a pointer to newly created xmlSecBase64Ctx structure or NULL if an error occurs.


xmlSecBase64CtxDestroy ()

void                xmlSecBase64CtxDestroy              (xmlSecBase64CtxPtr ctx);

Destroys base64 context.

ctx :

the pointer to xmlSecBase64Ctx structure.


xmlSecBase64CtxFinal ()

int                 xmlSecBase64CtxFinal                (xmlSecBase64CtxPtr ctx,
                                                         xmlSecByte *out,
                                                         xmlSecSize outSize);

Encodes or decodes the last piece of data stored in the context and finalizes the result.

ctx :

the pointer to xmlSecBase64Ctx structure

out :

the output buffer

outSize :

the output buffer size

Returns :

the number of bytes written to output buffer or -1 if an error occurs.


xmlSecBase64CtxFinalize ()

void                xmlSecBase64CtxFinalize             (xmlSecBase64CtxPtr ctx);

Frees all the resources allocated by ctx.

ctx :

the pointer to xmlSecBase64Ctx structure,


xmlSecBase64CtxInitialize ()

int                 xmlSecBase64CtxInitialize           (xmlSecBase64CtxPtr ctx,
                                                         int encode,
                                                         int columns);

Initializes new base64 context.

ctx :

the pointer to xmlSecBase64Ctx structure,

encode :

the encode/decode flag (1 - encode, 0 - decode)

columns :

the max line length.

Returns :

0 on success and a negative value otherwise.


xmlSecBase64CtxUpdate ()

int                 xmlSecBase64CtxUpdate               (xmlSecBase64CtxPtr ctx,
                                                         const xmlSecByte *in,
                                                         xmlSecSize inSize,
                                                         xmlSecByte *out,
                                                         xmlSecSize outSize);

Encodes or decodes the next piece of data from input buffer.

ctx :

the pointer to xmlSecBase64Ctx structure

in :

the input buffer

inSize :

the input buffer size

out :

the output buffer

outSize :

the output buffer size

Returns :

the number of bytes written to output buffer or -1 if an error occurs.


xmlSecBase64Decode ()

int                 xmlSecBase64Decode                  (const xmlChar *str,
                                                         xmlSecByte *buf,
                                                         xmlSecSize len);

Decodes input base64 encoded string and puts result into the output buffer.

str :

the input buffer with base64 encoded string

buf :

the output buffer

len :

the output buffer size

Returns :

the number of bytes written to the output buffer or a negative value if an error occurs


xmlSecBase64Encode ()

xmlChar *           xmlSecBase64Encode                  (const xmlSecByte *buf,
                                                         xmlSecSize len,
                                                         int columns);

Encodes the data from input buffer and allocates the string for the result. The caller is responsible for freeing returned buffer using xmlFree() function.

buf :

the input buffer.

len :

the input buffer size.

columns :

the output max line length (if 0 then no line breaks would be inserted)

Returns :

newly allocated string with base64 encoded data or NULL if an error occurs.


xmlSecBase64GetDefaultLineSize ()

int                 xmlSecBase64GetDefaultLineSize      (void);

Gets the current default line size.

Returns :

the current default line size.


xmlSecBase64SetDefaultLineSize ()

void                xmlSecBase64SetDefaultLineSize      (int columns);

Sets the current default line size.

columns :

number of columns