CryptoAuthLib
Microchip CryptoAuthentication Library
atca_host.h File Reference

Definitions and Prototypes for ATCA Utility Functions. More...

#include <stdint.h>
#include "cryptoauthlib.h"

Go to the source code of this file.

Data Structures

struct  atca_temp_key
 Structure to hold TempKey fields. More...
 
struct  atca_include_data_in_out
 Input / output parameters for function atca_include_data(). More...
 
struct  atca_nonce_in_out
 Input/output parameters for function atca_nonce(). More...
 
struct  atca_io_decrypt_in_out
 
struct  atca_verify_mac
 
struct  atca_secureboot_enc_in_out
 
struct  atca_secureboot_mac_in_out
 
struct  atca_mac_in_out
 Input/output parameters for function atca_mac(). More...
 
struct  atca_hmac_in_out
 Input/output parameters for function atca_hmac(). More...
 
struct  atca_gen_dig_in_out
 Input/output parameters for function atcah_gen_dig(). More...
 
struct  atca_write_mac_in_out
 Input/output parameters for function atcah_write_auth_mac() and atcah_privwrite_auth_mac(). More...
 
struct  atca_derive_key_in_out
 Input/output parameters for function atcah_derive_key(). More...
 
struct  atca_derive_key_mac_in_out
 Input/output parameters for function atcah_derive_key_mac(). More...
 
struct  atca_decrypt_in_out
 Input/output parameters for function atca_decrypt(). More...
 
struct  atca_check_mac_in_out
 Input/output parameters for function atcah_check_mac(). More...
 
struct  atca_verify_in_out
 Input/output parameters for function atcah_verify(). More...
 
struct  atca_gen_key_in_out
 Input/output parameters for calculating the PubKey digest put into TempKey by the GenKey command with the atcah_gen_key_msg() function. More...
 
struct  atca_sign_internal_in_out
 Input/output parameters for calculating the message and digest used by the Sign(internal) command. Used with the atcah_sign_internal_msg() function. More...
 

Macros

Definitions for ATECC Message Sizes to Calculate a SHA256 Hash

"||" is the concatenation operator. The number in braces is the length of the hash input value in bytes.

#define ATCA_MSG_SIZE_NONCE   (55)
 RandOut{32} || NumIn{20} || OpCode{1} || Mode{1} || LSB of Param2{1}. More...
 
#define ATCA_MSG_SIZE_MAC   (88)
 (Key or TempKey){32} || (Challenge or TempKey){32} || OpCode{1} || Mode{1} || Param2{2} || (OTP0_7 or 0){8} || (OTP8_10 or 0){3} || SN8{1} || (SN4_7 or 0){4} || SN0_1{2} || (SN2_3 or 0){2} More...
 
#define ATCA_MSG_SIZE_HMAC   (88)
 
#define ATCA_MSG_SIZE_GEN_DIG   (96)
 KeyId{32} || OpCode{1} || Param1{1} || Param2{2} || SN8{1} || SN0_1{2} || 0{25} || TempKey{32}. More...
 
#define ATCA_MSG_SIZE_DERIVE_KEY   (96)
 KeyId{32} || OpCode{1} || Param1{1} || Param2{2} || SN8{1} || SN0_1{2} || 0{25} || TempKey{32}. More...
 
#define ATCA_MSG_SIZE_DERIVE_KEY_MAC   (39)
 KeyId{32} || OpCode{1} || Param1{1} || Param2{2} || SN8{1} || SN0_1{2}. More...
 
#define ATCA_MSG_SIZE_ENCRYPT_MAC   (96)
 KeyId{32} || OpCode{1} || Param1{1} || Param2{2}|| SN8{1} || SN0_1{2} || 0{25} || TempKey{32}. More...
 
#define ATCA_MSG_SIZE_PRIVWRITE_MAC   (96)
 KeyId{32} || OpCode{1} || Param1{1} || Param2{2}|| SN8{1} || SN0_1{2} || 0{21} || PlainText{36}. More...
 
#define ATCA_COMMAND_HEADER_SIZE   ( 4)
 
#define ATCA_GENDIG_ZEROS_SIZE   (25)
 
#define ATCA_WRITE_MAC_ZEROS_SIZE   (25)
 
#define ATCA_PRIVWRITE_MAC_ZEROS_SIZE   (21)
 
#define ATCA_PRIVWRITE_PLAIN_TEXT_SIZE   (36)
 
#define ATCA_DERIVE_KEY_ZEROS_SIZE   (25)
 
#define HMAC_BLOCK_SIZE   (64)
 
#define ENCRYPTION_KEY_SIZE   (64)
 
Default Fixed Byte Values of Serial Number (SN[0:1] and SN[8])
#define ATCA_SN_0_DEF   (0x01)
 
#define ATCA_SN_1_DEF   (0x23)
 
#define ATCA_SN_8_DEF   (0xEE)
 
Definition for TempKey Mode
#define MAC_MODE_USE_TEMPKEY_MASK   ((uint8_t)0x03)
 mode mask for MAC command when using TempKey More...
 

Typedefs

typedef struct atca_temp_key atca_temp_key_t
 Structure to hold TempKey fields. More...
 
typedef struct atca_nonce_in_out atca_nonce_in_out_t
 
typedef struct atca_io_decrypt_in_out atca_io_decrypt_in_out_t
 
typedef struct atca_verify_mac atca_verify_mac_in_out_t
 
typedef struct atca_secureboot_enc_in_out atca_secureboot_enc_in_out_t
 
typedef struct atca_secureboot_mac_in_out atca_secureboot_mac_in_out_t
 
typedef struct atca_mac_in_out atca_mac_in_out_t
 
typedef struct atca_gen_dig_in_out atca_gen_dig_in_out_t
 Input/output parameters for function atcah_gen_dig(). More...
 
typedef struct atca_write_mac_in_out atca_write_mac_in_out_t
 Input/output parameters for function atcah_write_auth_mac() and atcah_privwrite_auth_mac(). More...
 
typedef struct atca_check_mac_in_out atca_check_mac_in_out_t
 Input/output parameters for function atcah_check_mac(). More...
 
typedef struct atca_verify_in_out atca_verify_in_out_t
 
typedef struct atca_gen_key_in_out atca_gen_key_in_out_t
 Input/output parameters for calculating the PubKey digest put into TempKey by the GenKey command with the atcah_gen_key_msg() function. More...
 
typedef struct atca_sign_internal_in_out atca_sign_internal_in_out_t
 Input/output parameters for calculating the message and digest used by the Sign(internal) command. Used with the atcah_sign_internal_msg() function. More...
 

Functions

ATCA_STATUS atcah_nonce (struct atca_nonce_in_out *param)
 This function calculates host side nonce with the parameters passed. More...
 
ATCA_STATUS atcah_mac (struct atca_mac_in_out *param)
 This function generates an SHA-256 digest (MAC) of a key, challenge, and other information. More...
 
ATCA_STATUS atcah_check_mac (struct atca_check_mac_in_out *param)
 This function performs the checkmac operation to generate client response on the host side . More...
 
ATCA_STATUS atcah_hmac (struct atca_hmac_in_out *param)
 This function generates an HMAC / SHA-256 hash of a key and other information. More...
 
ATCA_STATUS atcah_gen_dig (struct atca_gen_dig_in_out *param)
 This function combines the current TempKey with a stored value. More...
 
ATCA_STATUS atcah_gen_mac (struct atca_gen_dig_in_out *param)
 This function generates mac with session key with a plain text. More...
 
ATCA_STATUS atcah_write_auth_mac (struct atca_write_mac_in_out *param)
 This function calculates the input MAC for the Write command. More...
 
ATCA_STATUS atcah_privwrite_auth_mac (struct atca_write_mac_in_out *param)
 This function calculates the input MAC for the PrivWrite command. More...
 
ATCA_STATUS atcah_derive_key (struct atca_derive_key_in_out *param)
 This function derives a key with a key and TempKey. More...
 
ATCA_STATUS atcah_derive_key_mac (struct atca_derive_key_mac_in_out *param)
 This function calculates the input MAC for a DeriveKey command. More...
 
ATCA_STATUS atcah_decrypt (struct atca_decrypt_in_out *param)
 This function decrypts 32-byte encrypted data received with the Read command. More...
 
ATCA_STATUS atcah_sha256 (int32_t len, const uint8_t *message, uint8_t *digest)
 This function creates a SHA256 digest on a little-endian system. More...
 
uint8_t * atcah_include_data (struct atca_include_data_in_out *param)
 This function copies otp and sn data into a command buffer. More...
 
ATCA_STATUS atcah_gen_key_msg (struct atca_gen_key_in_out *param)
 Calculate the PubKey digest created by GenKey and saved to TempKey. More...
 
ATCA_STATUS atcah_config_to_sign_internal (ATCADeviceType device_type, struct atca_sign_internal_in_out *param, const uint8_t *config)
 Populate the slot_config, key_config, and is_slot_locked fields in the atca_sign_internal_in_out structure from the provided config zone. More...
 
ATCA_STATUS atcah_sign_internal_msg (ATCADeviceType device_type, struct atca_sign_internal_in_out *param)
 Builds the full message that would be signed by the Sign(Internal) command. More...
 
ATCA_STATUS atcah_verify_mac (atca_verify_mac_in_out_t *param)
 Calculate the expected MAC on the host side for the Verify command. More...
 
ATCA_STATUS atcah_secureboot_enc (atca_secureboot_enc_in_out_t *param)
 Encrypts the digest for the SecureBoot command when using the encrypted digest / validating mac option. More...
 
ATCA_STATUS atcah_secureboot_mac (atca_secureboot_mac_in_out_t *param)
 Calculates the expected MAC returned from the SecureBoot command when verification is a success. More...
 
ATCA_STATUS atcah_encode_counter_match (uint32_t counter, uint8_t *counter_match)
 Builds the counter match value that needs to be stored in a slot. More...
 
ATCA_STATUS atcah_io_decrypt (struct atca_io_decrypt_in_out *param)
 Decrypt data that's been encrypted by the IO protection key. The ECDH and KDF commands on the ATECC608A are the only ones that support this operation. More...
 

Detailed Description

Definitions and Prototypes for ATCA Utility Functions.