|
BSL v1.1.1 - 39.g9f43410
AMMOS Bundle Protocol Security Library (BSL)
|
#include "bsl/front/TextUtil.h"#include "bsl/BPSecLib_Private.h"#include <inttypes.h>#include <math.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <strings.h>
Include dependency graph for TextUtil.c:Functions | |
| int | BSL_TextUtil_Base16_Encode (BSL_Data_t *out, const BSL_Data_t *in, bool uppercase) |
| Encode to base16 text form. | |
| static int | base16_decode_char (uint8_t chr) |
| Decode a single character. | |
| 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. | |
| static int | base64_decode_char (uint8_t chr) |
| Decode a single character. | |
| int | BSL_TextUtil_Base64_Decode (BSL_Data_t *out, const char *ptr, size_t len) |
| Decode base64 and base64url text forms. | |
Variables | |
| static const size_t | base16_decode_lim = 0x80 |
| Size of the base16_decode_table. | |
| static const int | base16_decode_table [0x80] |
| Decode table for base16. | |
| static const char * | base64_alphabet |
| static const char * | base64url_alphabet |
| static const size_t | base64_decode_lim = 0x80 |
| Size of the base16_decode_table. | |
| static const int | base64_decode_table [0x80] |
| Decode table for base64 and base64uri. | |
|
static |
Decode a single character.
| chr | The character to decode. |
References base16_decode_lim, and base16_decode_table.
Referenced by BSL_TextUtil_Base16_Decode().
|
static |
Decode a single character.
| chr | The character to decode. |
References base64_decode_lim, and base64_decode_table.
Referenced by BSL_TextUtil_Base64_Decode().
| 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().
|
static |
Size of the base16_decode_table.
Referenced by base16_decode_char().
|
static |
Decode table for base16.
Referenced by base16_decode_char().
|
static |
Referenced by BSL_TextUtil_Base64_Encode().
|
static |
Size of the base16_decode_table.
Referenced by base64_decode_char().
|
static |
Decode table for base64 and base64uri.
Referenced by base64_decode_char().
|
static |
Referenced by BSL_TextUtil_Base64_Encode().