|
BSL v1.1.1 - 39.g9f43410
AMMOS Bundle Protocol Security Library (BSL)
|
This file contains definitions for text CODEC functions. More...
Include dependency graph for TextUtil.h:
This graph shows which files directly or indirectly include this file:Macros | |
| #define | BSL_LOG_PLAINTEXT_PTR(title, ctx, in_ptr, in_len) |
| Log plaintext as hex for debugging only when enabled by compile option BSL_LOG_PLAINTEXT_ENABLE is non-zero. | |
Functions | |
| int | BSL_TextUtil_Base16_Encode (BSL_Data_t *out, const BSL_Data_t *in, bool uppercase) |
| Encode to base16 text form. | |
| int | BSL_TextUtil_Base16_Decode (BSL_Data_t *out, const char *ptr, size_t len) |
| Decode base16 text form. | |
| int | BSL_TextUtil_Base64_Encode (BSL_Data_t *out, const BSL_Data_t *in, bool useurl, bool usepad) |
| Encode base64 and base64url text forms. | |
| int | BSL_TextUtil_Base64_Decode (BSL_Data_t *out, const char *ptr, size_t len) |
| Decode base64 and base64url text forms. | |
This file contains definitions for text CODEC functions.
| #define BSL_LOG_PLAINTEXT_PTR | ( | title, | |
| ctx, | |||
| in_ptr, | |||
| in_len | |||
| ) |
Log plaintext as hex for debugging only when enabled by compile option BSL_LOG_PLAINTEXT_ENABLE is non-zero.
| title | The static C string title. |
| ctc | A correlating context pointer to log. |
| in_ptr | The data start pointer. |
| in_len | The data length. |
| int BSL_TextUtil_Base16_Decode | ( | BSL_Data_t * | out, |
| const char * | ptr, | ||
| size_t | len | ||
| ) |
Decode base16 text form.
This is defined in Section 8 of RFC 4648 [12].
| [out] | out | The output buffer, which will be sized to its data. |
| [in] | ptr | The input buffer to read, which may be null terminated. Whitespace in the input must have already been removed. |
| len | The length from ptr to read, not including null terminator. |
References ASSERT_ARG_NONNULL, base16_decode_char(), BSL_Data_Resize(), and BSL_Data_t::ptr.
Referenced by BSL_TestUtils_DecodeBase16_cstr(), BSLP_GetBytesHex(), test_BSL_TextUtil_Base16_Decode_invalid(), and test_BSL_TextUtil_Base16_Decode_valid().
| int BSL_TextUtil_Base16_Encode | ( | BSL_Data_t * | out, |
| const BSL_Data_t * | in, | ||
| bool | uppercase | ||
| ) |
Encode to base16 text form.
This is defined in Section 8 of RFC 4648 [12].
| [out] | out | The output buffer, which will be resized appropriately and null-terminated. |
| [in] | in | The input buffer to read. |
| uppercase | True to use upper-case letters, false to use lower-case. |
References ASSERT_ARG_NONNULL, BSL_Data_Resize(), BSL_Data_t::len, and BSL_Data_t::ptr.
Referenced by BSL_IdValPair_Print(), BSL_TestUtils_PrintHexToBuffer(), and test_BSL_TextUtil_Base16_Encode().
| int BSL_TextUtil_Base64_Decode | ( | BSL_Data_t * | out, |
| const char * | ptr, | ||
| size_t | len | ||
| ) |
Decode base64 and base64url text forms.
These is defined in Section 4 and 5 of RFC 4648 [12].
| [out] | out | The output buffer, which will be sized to its data. |
| [in] | ptr | The input buffer to read, which may be null terminated. Whitespace in the input must have already been removed. |
| len | The length from ptr to read, not including null terminator. |
References ASSERT_ARG_NONNULL, base64_decode_char(), BSL_Data_Resize(), BSL_Data_t::len, and BSL_Data_t::ptr.
Referenced by mock_bpa_key_registry_init_jwk(), test_BSL_TextUtil_Base64_Decode_invalid(), and test_BSL_TextUtil_Base64_Decode_valid().
| int BSL_TextUtil_Base64_Encode | ( | BSL_Data_t * | out, |
| const BSL_Data_t * | in, | ||
| bool | useurl, | ||
| bool | usepad | ||
| ) |
Encode base64 and base64url text forms.
These is defined in Section 4 and 5 of RFC 4648 [12].
| [out] | out | The output buffer, which will be resized appropriately and null-terminated. |
| [in] | in | The input buffer to read. |
| useurl | True to use the base64url alphabet, false to use the base64 alphabet. | |
| usepad | True to include padding characters (=), false to not use padding. |
References ASSERT_ARG_NONNULL, base64_alphabet, base64url_alphabet, BSL_Data_Resize(), BSL_Data_t::len, and BSL_Data_t::ptr.
Referenced by TEST_CASE().