CryptoAuthLib
Microchip CryptoAuthentication Library
atca_helpers.c File Reference

Helpers to support the CryptoAuthLib Basic API methods. More...

#include <stdlib.h>
#include <stdio.h>
#include "cryptoauthlib.h"
#include "atca_helpers.h"

Macros

#define B64_IS_EQUAL   (uint8_t)64
 
#define B64_IS_INVALID   (uint8_t)0xFF
 

Functions

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. More...
 
ATCA_STATUS atcab_bin2hex_ (const uint8_t *bin, size_t bin_size, char *hex, size_t *hex_size, bool is_pretty)
 Function that converts a binary buffer to a hex string suitable for easy reading. More...
 
ATCA_STATUS atcab_hex2bin (const char *hex, size_t hex_size, uint8_t *bin, size_t *bin_size)
 Function that converts a hex string to binary buffer. More...
 
bool isDigit (char c)
 Checks to see if a character is an ASCII representation of a digit ((c ge '0') and (c le '9')) More...
 
bool isWhiteSpace (char c)
 Checks to see if a character is whitespace. More...
 
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')) More...
 
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')) More...
 
bool isHex (char c)
 Returns true if this character is a valid hex character or if this is whitespace (The character can be included in a valid hexstring). More...
 
bool isHexDigit (char c)
 Returns true if this character is a valid hex character. More...
 
ATCA_STATUS packHex (const char *ascii_hex, size_t ascii_hex_len, char *packed_hex, size_t *packed_len)
 Remove white space from a ASCII hex string. More...
 
bool isBase64 (char c, const uint8_t *rules)
 Returns true if this character is a valid base 64 character or if this is whitespace (A character can be included in a valid base 64 string). More...
 
bool isBase64Digit (char c, const uint8_t *rules)
 Returns true if this character is a valid base 64 character. More...
 
uint8_t base64Index (char c, const uint8_t *rules)
 Returns the base 64 index of the given character. More...
 
char base64Char (uint8_t id, const uint8_t *rules)
 Returns the base 64 character of the given index. More...
 
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. More...
 
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. More...
 
ATCA_STATUS atcab_base64encode (const uint8_t *byte_array, size_t array_len, char *encoded, size_t *encoded_len)
 Encode data as base64 string. More...
 
ATCA_STATUS atcab_base64decode (const char *encoded, size_t encoded_len, uint8_t *byte_array, size_t *array_len)
 Decode base64 string to data. More...
 

Variables

uint8_t atcab_b64rules_default [4] = { '+', '/', '=', 64 }
 
uint8_t atcab_b64rules_mime [4] = { '+', '/', '=', 76 }
 
uint8_t atcab_b64rules_urlsafe [4] = { '-', '_', 0, 0 }
 

Detailed Description

Helpers to support the CryptoAuthLib Basic API methods.

Macro Definition Documentation

◆ B64_IS_EQUAL

#define B64_IS_EQUAL   (uint8_t)64

◆ B64_IS_INVALID

#define B64_IS_INVALID   (uint8_t)0xFF