CryptoAuthLib
Microchip CryptoAuthentication Library
atca_basic_sha.c File Reference

CryptoAuthLib Basic API methods for SHA command. More...

#include "atca_basic.h"
#include "atca_execution.h"

Data Structures

struct  hw_sha256_ctx
 

Functions

ATCA_STATUS atcab_sha_base (uint8_t mode, uint16_t length, const uint8_t *message, uint8_t *data_out, uint16_t *data_out_size)
 Executes SHA command, which computes a SHA-256 or HMAC/SHA-256 digest for general purpose use by the host system. More...
 
ATCA_STATUS atcab_sha_start (void)
 Executes SHA command to initialize SHA-256 calculation engine. More...
 
ATCA_STATUS atcab_sha_update (const uint8_t *message)
 Executes SHA command to add 64 bytes of message data to the current context. More...
 
ATCA_STATUS atcab_sha_end (uint8_t *digest, uint16_t length, const uint8_t *message)
 Executes SHA command to complete SHA-256 or HMAC/SHA-256 operation. More...
 
ATCA_STATUS atcab_sha_read_context (uint8_t *context, uint16_t *context_size)
 Executes SHA command to read the SHA-256 context back. Only for ATECC608A with SHA-256 contexts. HMAC not supported. More...
 
ATCA_STATUS atcab_sha_write_context (const uint8_t *context, uint16_t context_size)
 Executes SHA command to write (restore) a SHA-256 context into the the device. Only supported for ATECC608A with SHA-256 contexts. More...
 
ATCA_STATUS atcab_sha (uint16_t length, const uint8_t *message, uint8_t *digest)
 Use the SHA command to compute a SHA-256 digest. More...
 
ATCA_STATUS atcab_hw_sha2_256_init (atca_sha256_ctx_t *ctx)
 Initialize a SHA context for performing a hardware SHA-256 operation on a device. Note that only one SHA operation can be run at a time. More...
 
ATCA_STATUS atcab_hw_sha2_256_update (atca_sha256_ctx_t *ctx, const uint8_t *data, size_t data_size)
 Add message data to a SHA context for performing a hardware SHA-256 operation on a device. More...
 
ATCA_STATUS atcab_hw_sha2_256_finish (atca_sha256_ctx_t *ctx, uint8_t *digest)
 Finish SHA-256 digest for a SHA context for performing a hardware SHA-256 operation on a device. More...
 
ATCA_STATUS atcab_hw_sha2_256 (const uint8_t *data, size_t data_size, uint8_t *digest)
 Use the SHA command to compute a SHA-256 digest. More...
 
ATCA_STATUS atcab_sha_hmac_init (atca_hmac_sha256_ctx_t *ctx, uint16_t key_slot)
 Executes SHA command to start an HMAC/SHA-256 operation. More...
 
ATCA_STATUS atcab_sha_hmac_update (atca_hmac_sha256_ctx_t *ctx, const uint8_t *data, size_t data_size)
 Executes SHA command to add an arbitrary amount of message data to a HMAC/SHA-256 operation. More...
 
ATCA_STATUS atcab_sha_hmac_finish (atca_hmac_sha256_ctx_t *ctx, uint8_t *digest, uint8_t target)
 Executes SHA command to complete a HMAC/SHA-256 operation. More...
 
ATCA_STATUS atcab_sha_hmac (const uint8_t *data, size_t data_size, uint16_t key_slot, uint8_t *digest, uint8_t target)
 Use the SHA command to compute an HMAC/SHA-256 operation. More...
 

Detailed Description

CryptoAuthLib Basic API methods for SHA command.

The SHA command Computes a SHA-256 or HMAC/SHA digest for general purpose use by the host system.

Note
List of devices that support this command - ATSHA204A, ATECC108A, ATECC508A, and ATECC608A. There are differences in the modes that they support. Refer to device datasheets for full details.