Base64 module implementation file. More...
Go to the source code of this file.
Macros | |
#define | PADDING_CHAR '=' |
#define | QUANTUM_SIZE 4 |
#define | INPUT_GROUP_SIZE 3 |
#define | UPPER_COUNT_PADDING 3 |
Functions | |
static E_MCL_ERROR_CODE | _encode_with_table (const char *table, const mcl_uint8_t *data, mcl_size_t data_size, string_t **encoded_data) |
static E_MCL_ERROR_CODE | _decode_with_table (const mcl_uint8_t *table, const string_t *encoded_data, mcl_uint8_t **decoded_data, mcl_size_t *decoded_data_size) |
static E_MCL_ERROR_CODE | _decode_quantum (const mcl_uint8_t *table, const char *source, mcl_uint8_t *destination, mcl_size_t *padding) |
E_MCL_ERROR_CODE | base64_decode (const string_t *encoded_data, mcl_uint8_t **decoded_data, mcl_size_t *decoded_data_size) |
E_MCL_ERROR_CODE | base64_url_decode (const string_t *encoded_data, mcl_uint8_t **decoded_data, mcl_size_t *decoded_data_size) |
E_MCL_ERROR_CODE | base64_encode (const mcl_uint8_t *data, mcl_size_t data_size, string_t **encoded_data) |
E_MCL_ERROR_CODE | base64_url_encode (const mcl_uint8_t *data, mcl_size_t data_size, string_t **encoded_data) |
Variables | |
static const char | base64_encode_table [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" |
static const mcl_uint8_t | base64_decode_table [] |
static const char | base64_url_encode_table [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" |
static const mcl_uint8_t | base64_url_decode_table [] |
Base64 module implementation file.
Definition in file base64.c.
#define INPUT_GROUP_SIZE 3 |
Definition at line 24 of file base64.c.
Referenced by _decode_with_table(), and _encode_with_table().
#define PADDING_CHAR '=' |
Definition at line 20 of file base64.c.
Referenced by _decode_quantum(), _decode_with_table(), and _encode_with_table().
#define QUANTUM_SIZE 4 |
Definition at line 23 of file base64.c.
Referenced by _decode_quantum(), _decode_with_table(), and _encode_with_table().
#define UPPER_COUNT_PADDING 3 |
Definition at line 27 of file base64.c.
Referenced by _decode_quantum().
|
static |
Definition at line 203 of file base64.c.
References ASSERT_CODE_MESSAGE, DEBUG_ENTRY, DEBUG_LEAVE, MCL_BAD_CONTENT_ENCODING, MCL_DEBUG, MCL_OK, PADDING_CHAR, QUANTUM_SIZE, and UPPER_COUNT_PADDING.
Referenced by _decode_with_table().
|
static |
Definition at line 122 of file base64.c.
References _decode_quantum(), ASSERT_CODE_MESSAGE, ASSERT_STATEMENT_CODE_MESSAGE, string_t::buffer, DEBUG_ENTRY, DEBUG_LEAVE, INPUT_GROUP_SIZE, string_t::length, MCL_BAD_CONTENT_ENCODING, MCL_DEBUG, MCL_FREE, MCL_MALLOC, MCL_NULL, MCL_NULL_CHAR, MCL_OK, MCL_OUT_OF_MEMORY, PADDING_CHAR, and QUANTUM_SIZE.
Referenced by base64_decode(), and base64_url_decode().
|
static |
Definition at line 253 of file base64.c.
References ASSERT_CODE_MESSAGE, DEBUG_ENTRY, DEBUG_LEAVE, INPUT_GROUP_SIZE, MCL_DEBUG, MCL_MALLOC, MCL_NULL, MCL_NULL_CHAR, MCL_OK, MCL_OUT_OF_MEMORY, PADDING_CHAR, QUANTUM_SIZE, and string_initialize_dynamic().
Referenced by base64_encode(), and base64_url_encode().
E_MCL_ERROR_CODE base64_decode | ( | const string_t * | encoded_data, |
mcl_uint8_t ** | decoded_data, | ||
mcl_size_t * | decoded_data_size | ||
) |
Given a base64 zero-terminated string at encoded_data
, decode it and return a pointer in decoded_data
to a newly allocated memory area holding decoded data. Size of decoded data is returned in variable pointed by decoded_data_size
.
When decoded data length is 0, returns MCL_NULL in decoded_data
.
encoded_data | [in] Zero-terminated string which is base64 encoded and has to be decoded. |
decoded_data | [out] Newly allocated memory holding decoded data. |
decoded_data_size | [out] Size of decoded data. |
encoded_data
has invalid length (0 or not multiples of 4) or if the given encoded_data
is invalidly encoded. Definition at line 82 of file base64.c.
References _decode_with_table(), base64_decode_table, DEBUG_ENTRY, and DEBUG_LEAVE.
Referenced by security_handler_base64_decode().
E_MCL_ERROR_CODE base64_encode | ( | const mcl_uint8_t * | data, |
mcl_size_t | data_size, | ||
string_t ** | encoded_data | ||
) |
Given a pointer to an input data and an input size, encode it with base64 and return a pointer in encoded_data
to a newly allocated string area holding encoded data. Length of encoded data is also returned.
When encoded data length is 0, returns MCL_NULL in encoded_data
.
data | [in] Input data that has to be base64 encoded. |
data_size | [in] Size of given input data . |
encoded_data | [out] Newly allocated string holding encoded data and its length. |
Definition at line 102 of file base64.c.
References _encode_with_table(), base64_encode_table, DEBUG_ENTRY, and DEBUG_LEAVE.
Referenced by security_handler_base64_encode().
E_MCL_ERROR_CODE base64_url_decode | ( | const string_t * | encoded_data, |
mcl_uint8_t ** | decoded_data, | ||
mcl_size_t * | decoded_data_size | ||
) |
Given a base64 URL zero-terminated string at encoded_data
, decode it and return a pointer in decoded_data
to a newly allocated memory area holding decoded data. Size of decoded data is returned in variable pointed by decoded_data_size
.
When decoded data length is 0, returns MCL_NULL in decoded_data
.
encoded_data | [in] Zero-terminated string which is base64 URL encoded and has to be decoded. |
decoded_data | [out] Newly allocated memory holding decoded data. |
decoded_data_size | [out] Size of decoded_data . |
encoded_data
has invalid length (0 or not multiples of 4) or if the given encoded_data
is invalidly encoded. Definition at line 92 of file base64.c.
References _decode_with_table(), base64_url_decode_table, DEBUG_ENTRY, and DEBUG_LEAVE.
E_MCL_ERROR_CODE base64_url_encode | ( | const mcl_uint8_t * | data, |
mcl_size_t | data_size, | ||
string_t ** | encoded_data | ||
) |
Given a pointer to an input data and an input size, encode it with base64 URL and return a pointer in encoded_data
to a newly allocated string area holding encoded data. Length of encoded data is also returned.
When encoded data length is 0, returns MCL_NULL in encoded_data
.
data | [in] Input data that has to be base64 URL encoded. |
data_size | [in] Size of given input data . |
encoded_data | [out] Newly allocated string holding encoded data and its length. |
Definition at line 112 of file base64.c.
References _encode_with_table(), base64_url_encode_table, DEBUG_ENTRY, and DEBUG_LEAVE.
Referenced by _base64_encode_big_number(), and security_handler_base64_url_encode().
|
static |
Definition at line 32 of file base64.c.
Referenced by base64_decode().
|
static |
Definition at line 30 of file base64.c.
Referenced by base64_encode().
|
static |
Definition at line 56 of file base64.c.
Referenced by base64_url_decode().
|
static |
Definition at line 54 of file base64.c.
Referenced by base64_url_encode().