Helpers to support the CryptoAuthLib Basic API methods. More...
#include <stdlib.h>#include <stdio.h>#include <ctype.h>#include <string.h>#include "cryptoauthlib.h"#include "atca_helpers.h"Macros | |
| #define | B64_IS_EQUAL (64u) |
| #define | B64_IS_INVALID (-1) |
Functions | |
| const uint8_t * | atcab_b64rules_default (void) |
| const uint8_t * | atcab_b64rules_mime (void) |
| const uint8_t * | atcab_b64rules_urlsafe (void) |
| ATCA_STATUS | atcab_bin2hex (const uint8_t *bin, size_t bin_size, char *hex, size_t *hex_size) |
| Convert a binary buffer to a hex string for easy reading. | |
| ATCA_STATUS | atcab_reversal (const uint8_t *bin, size_t bin_size, uint8_t *dest, size_t *dest_size) |
| To reverse the input data. | |
| ATCA_STATUS | atcab_bin2hex_ (const uint8_t *bin, size_t bin_size, char *hex, size_t *hex_size, bool is_pretty, bool is_space, bool is_upper) |
| Function that converts a binary buffer to a hex string suitable for easy reading. | |
| ATCA_STATUS | atcab_hex2bin_ (const char *hex, size_t hex_size, uint8_t *bin, size_t *bin_size, bool is_space) |
| ATCA_STATUS | atcab_hex2bin (const char *ascii_hex, size_t ascii_hex_len, uint8_t *binary, size_t *bin_len) |
| Function that converts a hex string to binary buffer. | |
| bool | isDigit (char c) |
| Checks to see if a character is an ASCII representation of a digit ((c ge '0') and (c le '9')) | |
| bool | isBlankSpace (char c) |
| Checks to see if a character is blank space. | |
| bool | isAlpha (char c) |
| Checks to see if a character is an ASCII representation of hex ((c >= 'A') and (c <= 'F')) || ((c >= 'a') and (c <= 'f')) | |
| bool | isHexAlpha (char c) |
| Checks to see if a character is an ASCII representation of hex ((c >= 'A') and (c <= 'F')) || ((c >= 'a') and (c <= 'f')) | |
| bool | isHex (char c) |
| Returns true if this character is a valid hex character or if this is blankspace (The character can be included in a valid hexstring). | |
| bool | isHexDigit (char c) |
| Returns true if this character is a valid hex character. | |
| ATCA_STATUS | packHex (const char *ascii_hex, size_t ascii_hex_len, char *packed_hex, size_t *packed_len) |
| Remove spaces from a ASCII hex string. | |
| bool | isBase64 (char c, const uint8_t *rules) |
| Returns true if this character is a valid base 64 character or if this is space (A character can be included in a valid base 64 string). | |
| bool | isBase64Digit (char c, const uint8_t *rules) |
| Returns true if this character is a valid base 64 character. | |
| ATCA_STATUS | atcab_base64decode_ (const char *encoded, size_t encoded_size, uint8_t *data, size_t *data_size, const uint8_t *rules) |
| Decode base64 string to data with ruleset option. | |
| ATCA_STATUS | atcab_base64encode_ (const uint8_t *data, size_t data_size, char *encoded, size_t *encoded_size, const uint8_t *rules) |
| Encode data as base64 string with ruleset option. | |
| ATCA_STATUS | atcab_base64encode (const uint8_t *byte_array, size_t array_len, char *encoded, size_t *encoded_len) |
| Encode data as base64 string. | |
| ATCA_STATUS | atcab_base64decode (const char *encoded, size_t encoded_len, uint8_t *byte_array, size_t *array_len) |
| Decode base64 string to data. | |
| size_t | atcab_pointer_delta (const void *start, const void *end) |
| Helper function to calculate the number of bytes between two pointers. | |
| int | atcab_memset_s (void *dest, size_t destsz, int ch, size_t count) |
| Guaranteed to perform memory writes regardless of optimization level. Matches memset_s signature. | |
| char | lib_toupper (char c) |
| Converts a character to uppercase. | |
| char | lib_tolower (char c) |
| Converts a character to lowercase. | |
| const char * | lib_strcasestr (const char *haystack, const char *needle) |
| Search for a substring in a case insenstive format. | |
Helpers to support the CryptoAuthLib Basic API methods.
| ATCA_STATUS atcab_base64decode | ( | const char * | encoded, |
| size_t | encoded_len, | ||
| uint8_t * | byte_array, | ||
| size_t * | array_len | ||
| ) |
Decode base64 string to data.
| [in] | encoded | Base64 string to be decoded. |
| [in] | encoded_len | Size of the base64 string in bytes. |
| [out] | byte_array | Decoded data will be returned here. |
| [in,out] | array_len | As input, the size of the byte_array buffer. As output, the length of the decoded data. |
| ATCA_STATUS atcab_base64decode_ | ( | const char * | encoded, |
| size_t | encoded_size, | ||
| uint8_t * | data, | ||
| size_t * | data_size, | ||
| const uint8_t * | rules | ||
| ) |
Decode base64 string to data with ruleset option.
| [in] | encoded | Base64 string to be decoded. |
| [in] | encoded_size | Size of the base64 string in bytes. |
| [out] | data | Decoded data will be returned here. |
| [in,out] | data_size | As input, the size of the byte_array buffer. As output, the length of the decoded data. |
| [in] | rules | base64 ruleset to use |
| ATCA_STATUS atcab_base64encode | ( | const uint8_t * | byte_array, |
| size_t | array_len, | ||
| char * | encoded, | ||
| size_t * | encoded_len | ||
| ) |
Encode data as base64 string.
| [in] | byte_array | Data to be encode in base64. |
| [in] | array_len | Size of byte_array in bytes. |
| [in] | encoded | Base64 output is returned here. |
| [in,out] | encoded_len | As input, the size of the encoded buffer. As output, the length of the encoded base64 character string. |
| ATCA_STATUS atcab_base64encode_ | ( | const uint8_t * | data, |
| size_t | data_size, | ||
| char * | encoded, | ||
| size_t * | encoded_size, | ||
| const uint8_t * | rules | ||
| ) |
Encode data as base64 string with ruleset option.
| [in] | data | The input byte array that will be converted to base 64 encoded characters |
| [in] | data_size | The length of the byte array |
| [in] | encoded | The output converted to base 64 encoded characters. |
| [in,out] | encoded_size | Input: The size of the encoded buffer, Output: The length of the encoded base 64 character string |
| [in] | rules | ruleset to use during encoding |
| ATCA_STATUS atcab_bin2hex | ( | const uint8_t * | bin, |
| size_t | bin_size, | ||
| char * | hex, | ||
| size_t * | hex_size | ||
| ) |
Convert a binary buffer to a hex string for easy reading.
| [in] | bin | Input data to convert. |
| [in] | bin_size | Size of data to convert. |
| [out] | hex | Buffer that receives hex string. |
| [in,out] | hex_size | As input, the size of the hex buffer. As output, the size of the output hex. |
| ATCA_STATUS atcab_bin2hex_ | ( | const uint8_t * | bin, |
| size_t | bin_size, | ||
| char * | hex, | ||
| size_t * | hex_size, | ||
| bool | is_pretty, | ||
| bool | is_space, | ||
| bool | is_upper | ||
| ) |
Function that converts a binary buffer to a hex string suitable for easy reading.
| [in] | bin | Input data to convert. |
| [in] | bin_size | Size of data to convert. |
| [out] | hex | Buffer that receives hex string. |
| [in,out] | hex_size | As input, the size of the hex buffer. As output, the size of the output hex. |
| [in] | is_pretty | Indicates whether new lines should be added for pretty printing. |
| [in] | is_space | Convert the output hex with space between it. |
| [in] | is_upper | Convert the output hex to upper case. |
| ATCA_STATUS atcab_hex2bin | ( | const char * | ascii_hex, |
| size_t | ascii_hex_len, | ||
| uint8_t * | binary, | ||
| size_t * | bin_len | ||
| ) |
Function that converts a hex string to binary buffer.
| [in] | ascii_hex | Input buffer to convert |
| [in] | ascii_hex_len | Length of buffer to convert |
| [out] | binary | Buffer that receives binary |
| [in,out] | bin_len | As input, the size of the bin buffer. As output, the size of the bin data. |
| ATCA_STATUS atcab_reversal | ( | const uint8_t * | bin, |
| size_t | bin_size, | ||
| uint8_t * | dest, | ||
| size_t * | dest_size | ||
| ) |
To reverse the input data.
| [in] | bin | Input data to reverse. |
| [in] | bin_size | Size of data to reverse. |
| [out] | dest | Buffer to store reversed binary data. |
| [in] | dest_size | The size of the dest buffer. |
| bool isAlpha | ( | char | c | ) |
Checks to see if a character is an ASCII representation of hex ((c >= 'A') and (c <= 'F')) || ((c >= 'a') and (c <= 'f'))
| [in] | c | character to check |
| bool isBase64 | ( | char | c, |
| const uint8_t * | rules | ||
| ) |
Returns true if this character is a valid base 64 character or if this is space (A character can be included in a valid base 64 string).
| [in] | c | character to check |
| [in] | rules | base64 ruleset to use |
| bool isBase64Digit | ( | char | c, |
| const uint8_t * | rules | ||
| ) |
Returns true if this character is a valid base 64 character.
| [in] | c | character to check |
| [in] | rules | base64 ruleset to use |
| bool isBlankSpace | ( | char | c | ) |
Checks to see if a character is blank space.
| [in] | c | character to check |
| bool isDigit | ( | char | c | ) |
Checks to see if a character is an ASCII representation of a digit ((c ge '0') and (c le '9'))
| [in] | c | character to check |
| bool isHex | ( | char | c | ) |
Returns true if this character is a valid hex character or if this is blankspace (The character can be included in a valid hexstring).
| [in] | c | character to check |
| bool isHexAlpha | ( | char | c | ) |
Checks to see if a character is an ASCII representation of hex ((c >= 'A') and (c <= 'F')) || ((c >= 'a') and (c <= 'f'))
| [in] | c | character to check |
| bool isHexDigit | ( | char | c | ) |
Returns true if this character is a valid hex character.
| [in] | c | character to check |
| ATCA_STATUS packHex | ( | const char * | ascii_hex, |
| size_t | ascii_hex_len, | ||
| char * | packed_hex, | ||
| size_t * | packed_len | ||
| ) |
Remove spaces from a ASCII hex string.
| [in] | ascii_hex | Initial hex string to remove blankspace from |
| [in] | ascii_hex_len | Length of the initial hex string |
| [in] | packed_hex | Resulting hex string without blankspace |
| [in,out] | packed_len | In: Size to packed_hex buffer Out: Number of bytes in the packed hex string |