Implements a Base64 decoding routine. More...
Functions | |
static Base64Status_t | preprocessBase64Index (uint8_t base64Index, int64_t *pNumPadding, int64_t *pNumWhitespace) |
Validates the input Base64 index based on the context of what has been decoded so far and the value of the index. Updates the input counters that are used to keep track of the number of whitespace and padding symbols that have been parsed so far. | |
static void | updateBase64DecodingBuffer (const uint8_t base64Index, uint32_t *pBase64IndexBuffer, uint32_t *pNumDataInBuffer) |
Add a Base64 index to a Base64 index buffer. The buffer will only be updated if the index represents a Base64 digit. | |
static Base64Status_t | decodeBase64IndexBuffer (uint32_t *pBase64IndexBuffer, uint32_t *pNumDataInBuffer, uint8_t *pDest, const size_t destLen, size_t *pOutputLen) |
Decode a buffer containing two, three, or four Base64 indices. | |
Base64Status_t | base64Decode (uint8_t *pDest, const size_t destLen, size_t *pResultLen, const uint8_t *pEncodedData, const size_t encodedLen) |
Decode Base64 encoded data. | |
Variables | |
static const uint8_t | pBase64SymbolToIndexMap [] |
This table takes is indexed by an Ascii character and returns the respective Base64 index. The Ascii character used to index into this table is assumed to represent a symbol in a string of Base64 encoded data. There are three kinds of possible ascii characters: 1) Base64 Symbols. These are the digits of a Base 64 number system. 2) Formatting characters. These are newline, whitespace, and padding. 3) Symbols that are impossible to have inside of correctly Base64 encoded data. | |
Implements a Base64 decoding routine.
|
static |
Validates the input Base64 index based on the context of what has been decoded so far and the value of the index. Updates the input counters that are used to keep track of the number of whitespace and padding symbols that have been parsed so far.
[in] | base64Index | Base64 index that can have on of the values listed in pBase64SymbolToIndexMap. This index represents the value of a valid Base64 symbol, a number to identify it as a formatting symbol, or a number to identify it as an invalid symbol. |
[in,out] | pNumPadding | Pointer to the number of padding symbols that are present before the input Base64 index in the encoded data. This number is incremented if the input symbol is a padding symbol. |
[in,out] | pNumWhitespace | Pointer to the number of whitespace symbols that are present before the input Base64 index in the encoded data. This number is incremented if the input symbol is a whitespace symbol. |
|
static |
Add a Base64 index to a Base64 index buffer. The buffer will only be updated if the index represents a Base64 digit.
[in] | base64Index | Base64 index that can have one of the values listed in pBase64SymbolToIndexMap. |
[in,out] | pBase64IndexBuffer | Pointer to a 32 bit variable that contains Base64 indexes that will be decoded. |
[in,out] | pNumDataInBuffer | Pointer to the number of sextets that are stored in pBase64IndexBuffer. This will be incremented if base64Index is stored in pBase64IndexBuffer. |
|
static |
Decode a buffer containing two, three, or four Base64 indices.
[in,out] | pBase64IndexBuffer | Pointer to a 32 bit variable that contains Base64 indexes that will be decoded. Each index is represented by a sextet in the buffer. |
[in,out] | pNumDataInBuffer | Pointer to the number of sextets (indexes) that are concatenated and stored in pBase64IndexBuffer. This will be set to zero before this function returns. |
[out] | pDest | Pointer to a buffer used for storing the decoded data. |
[in] | destLen | Length of the pDest buffer. |
[in,out] | pOutputLen | Pointer to the index of pDest where the output should be written. |
Base64Status_t base64Decode | ( | uint8_t * | pDest, |
const size_t | destLen, | ||
size_t * | pResultLen, | ||
const uint8_t * | pEncodedData, | ||
const size_t | encodedLen | ||
) |
Decode Base64 encoded data.
[out] | pDest | Pointer to a buffer for storing the decoded result. |
[in] | destLen | Length of the pDest buffer. |
[out] | pResultLen | Pointer to the length of the decoded result. |
[in] | pEncodedData | Pointer to a buffer containing the Base64 encoded data that is intended to be decoded. |
[in] | encodedLen | Length of the pEncodedData buffer. |
|
static |
This table takes is indexed by an Ascii character and returns the respective Base64 index. The Ascii character used to index into this table is assumed to represent a symbol in a string of Base64 encoded data. There are three kinds of possible ascii characters: 1) Base64 Symbols. These are the digits of a Base 64 number system. 2) Formatting characters. These are newline, whitespace, and padding. 3) Symbols that are impossible to have inside of correctly Base64 encoded data.
This table assumes that the padding symbol is the Ascii character '='
Valid Base64 symbols will have an index ranging from 0-63. The Base64 digits being used are "ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxyz0123456789+/" where 'A' is the 0th index of the Base64 symbols and '/' is the 63rd index.
Outside of the numbers 0-63, there are magic numbers in this table: