RSA Security logo

RSA BSAFE Cert-C
API Reference

base64.h File Reference

This file encodes and decodes the buffer.

Go to the source code of this file.

Functions

int C_EncodeBase64 (unsigned char *pOutBuf, unsigned int *pOutLen, unsigned char *pInBuf, unsigned int inLen)
 Encodes the contents of the buffer pointed to by pInBuf of length inLen into the pre-allocated buffer pointed to by pOutBuf. More...

int C_DecodeBase64 (unsigned char *pOutBuf, unsigned int *pOutLen, unsigned char *pInBuf, unsigned int inLen)
 Decodes a Base64-encoded string in pInBuf, with the length as InBuf. More...


Function Documentation

int C_DecodeBase64 unsigned char *    pOutBuf,
unsigned int *    pOutLen,
unsigned char *    pInBuf,
unsigned int    inLen
;
 

Decodes a Base64-encoded string in pInBuf, with the length as InBuf. The function then copies the decoded string into the memory buffer pointed by pOutBuf, and returns the length of the decoded string in pOutBuf. The memory buffer pointed by pOutBuf must be allocated and managed by the application that called C_DecodeBase64(). The application must allocate enough memory to hold the output. To determine how much memory is needed, the application calls this function with the input to decode. It sets the pOutBuf as NULL_PTR. In this case, the only return value is pOutBuf, which indicates the necessary buffer length. This return value is then used to allocate an output buffer to be used in a subsequent call to this function. The specification for the decoding is in RFC 1421.

The contents pointed to by pInBuf can contain line-broken or continuous base64 text, that is, carriage-returns and line-feeds are ignored in the input buffer. The end of the buffer can additionally contain NUL characters that will also be ignored. Otherwise, the entire input buffer, up to inLen will be expected to contain only valid base64-encoded text.

Parameters:
pOutBuf This input and output parameter is a pointer to the buffer into which the decoded data is written. It can be NULL_PTR if you only want to determine the length of the output decoding.
pOutLen This output parameter is a pointer to the length of the decoding.
pInBuf This input parameter is a pointer to the data to decode. It cannot be NULL_PTR.
inLen This input parameter is the length of the data to decode.
Returns:
If successful, returns 0. If not, returns a Cert-C error code.

int C_EncodeBase64 unsigned char *    pOutBuf,
unsigned int *    pOutLen,
unsigned char *    pInBuf,
unsigned int    inLen
;
 

Encodes the contents of the buffer pointed to by pInBuf of length inLen into the pre-allocated buffer pointed to by pOutBuf. The length of the output data is stored into the location pointed to by pOutLen. In order to determine the minimum length of the output buffer you need to allocate before you call this function to perform the actual encoding, you can call this function with a NULL_PTR pOutBuf, in which case only the output length will be returned in pOutLen. This length value can be used to allocate an output buffer to be used in a subsequent call to this function. The specification for the encoding is in RFC 1421.

Parameters:
pOutBuf This input and output parameter is a pointer to the buffer into which the encoded data is written. It can be NULL_PTR if the caller only wants to determine the size of the output encoding.
pOutLen This output parameter is a pointer to the length of the encoding.
pInBuf This input parameter is a pointer to the data to encode. It cannot be NULL_PTR.
inLen This input parameter is the length of the data to encode.
Returns:
If successful, returns 0. If not, returns a Cert-C error code.



RSA BSAFE® Cert-C 2.7 API Reference