Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Software crypto methods (atcac_)

These methods provide a software implementation of various crypto algorithms.

Data Structures

struct  atcac_sha1_ctx
 
struct  atcac_sha2_256_ctx
 

Macros

#define ATCA_ECC_P256_FIELD_SIZE   (256 / 8)
 
#define ATCA_ECC_P256_PRIVATE_KEY_SIZE   (ATCA_ECC_P256_FIELD_SIZE)
 
#define ATCA_ECC_P256_PUBLIC_KEY_SIZE   (ATCA_ECC_P256_FIELD_SIZE * 2)
 
#define ATCA_ECC_P256_SIGNATURE_SIZE   (ATCA_ECC_P256_FIELD_SIZE * 2)
 
#define ATCA_SHA1_DIGEST_SIZE   (20)
 
#define ATCA_SHA2_256_DIGEST_SIZE   (32)
 

Functions

int atcac_sw_ecdsa_verify_p256 (const uint8_t msg[ATCA_ECC_P256_FIELD_SIZE], const uint8_t signature[ATCA_ECC_P256_SIGNATURE_SIZE], const uint8_t public_key[ATCA_ECC_P256_PUBLIC_KEY_SIZE])
 return software generated ECDSA verification result and the function is currently not implemented More...
 
int atcac_sw_random (uint8_t *data, size_t data_size)
 return software generated random number and the function is currently not implemented More...
 
int atcac_sw_sha1 (const uint8_t *data, size_t data_size, uint8_t digest[ATCA_SHA1_DIGEST_SIZE])
 Perform SHA1 hash of data in software. More...
 
int atcac_sw_sha1_finish (atcac_sha1_ctx *ctx, uint8_t digest[ATCA_SHA1_DIGEST_SIZE])
 Complete the SHA1 hash in software and return the digest. More...
 
int atcac_sw_sha1_init (atcac_sha1_ctx *ctx)
 Initialize context for performing SHA1 hash in software. More...
 
int atcac_sw_sha1_update (atcac_sha1_ctx *ctx, const uint8_t *data, size_t data_size)
 Add arbitrary data to a SHA1 hash. More...
 
int atcac_sw_sha2_256 (const uint8_t *data, size_t data_size, uint8_t digest[ATCA_SHA2_256_DIGEST_SIZE])
 single call convenience function which computes Hash of given data using SHA256 software More...
 
int atcac_sw_sha2_256_finish (atcac_sha2_256_ctx *ctx, uint8_t digest[ATCA_SHA2_256_DIGEST_SIZE])
 completes the final SHA256 calculation and returns the final digest/hash More...
 
int atcac_sw_sha2_256_init (atcac_sha2_256_ctx *ctx)
 initializes the SHA256 software More...
 
int atcac_sw_sha2_256_update (atcac_sha2_256_ctx *ctx, const uint8_t *data, size_t data_size)
 updates the running hash with the next block of data, called iteratively for the entire stream of data to be hashed using the SHA256 software More...
 

#define ATCA_ECC_P256_FIELD_SIZE   (256 / 8)
#define ATCA_ECC_P256_PRIVATE_KEY_SIZE   (ATCA_ECC_P256_FIELD_SIZE)
#define ATCA_ECC_P256_PUBLIC_KEY_SIZE   (ATCA_ECC_P256_FIELD_SIZE * 2)
#define ATCA_ECC_P256_SIGNATURE_SIZE   (ATCA_ECC_P256_FIELD_SIZE * 2)
#define ATCA_SHA1_DIGEST_SIZE   (20)
#define ATCA_SHA2_256_DIGEST_SIZE   (32)

int atcac_sw_ecdsa_verify_p256 ( const uint8_t  msg[ATCA_ECC_P256_FIELD_SIZE],
const uint8_t  signature[ATCA_ECC_P256_SIGNATURE_SIZE],
const uint8_t  public_key[ATCA_ECC_P256_PUBLIC_KEY_SIZE] 
)

return software generated ECDSA verification result and the function is currently not implemented

Parameters
[in]msgptr to message or challenge
[in]signatureptr to the signature to verify
[in]public_keyptr to public key of device which signed the challenge return ATCA_UNIMPLEMENTED , as the function is currently not implemented
int atcac_sw_random ( uint8_t *  data,
size_t  data_size 
)

return software generated random number and the function is currently not implemented

Parameters
[out]dataptr to space to receive the random number
[in]data_sizesize of data buffer return ATCA_UNIMPLEMENTED , as the function is not implemented
int atcac_sw_sha1 ( const uint8_t *  data,
size_t  data_size,
uint8_t  digest[ATCA_SHA1_DIGEST_SIZE] 
)

Perform SHA1 hash of data in software.

Parameters
[in]dataData to be hashed
[in]data_sizeData size in bytes
[out]digestDigest is returned here (20 bytes)
Returns
ATCA_SUCCESS on success, otherwise an error code.

References atcac_sw_sha1_finish(), atcac_sw_sha1_init(), and atcac_sw_sha1_update().

int atcac_sw_sha1_finish ( atcac_sha1_ctx ctx,
uint8_t  digest[ATCA_SHA1_DIGEST_SIZE] 
)

Complete the SHA1 hash in software and return the digest.

Parameters
[in]ctxHash context
[out]digestDigest is returned here (20 bytes)
Returns
ATCA_SUCCESS

References CL_hashFinal().

Referenced by atcac_sw_sha1().

int atcac_sw_sha1_init ( atcac_sha1_ctx ctx)

Initialize context for performing SHA1 hash in software.

Parameters
[in]ctxHash context
Returns
ATCA_SUCCESS on success, otherwise an error code.

References CL_hashInit().

Referenced by atcac_sw_sha1().

int atcac_sw_sha1_update ( atcac_sha1_ctx ctx,
const uint8_t *  data,
size_t  data_size 
)

Add arbitrary data to a SHA1 hash.

Parameters
[in]ctxHash context
[in]dataData to be added to the hash
[in]data_sizeData size in bytes
Returns
ATCA_SUCCESS

References CL_hashUpdate().

Referenced by atcac_sw_sha1().

int atcac_sw_sha2_256 ( const uint8_t *  data,
size_t  data_size,
uint8_t  digest[ATCA_SHA2_256_DIGEST_SIZE] 
)

single call convenience function which computes Hash of given data using SHA256 software

Parameters
[in]datapointer to stream of data to hash
[in]data_sizesize of data stream to hash
[out]digestresult
Returns
ATCA_SUCCESS on success, otherwise an error code.

References atcac_sw_sha2_256_finish(), atcac_sw_sha2_256_init(), and atcac_sw_sha2_256_update().

Referenced by atcah_check_mac(), atcah_derive_key(), atcah_derive_key_mac(), atcah_gen_dig(), atcah_gen_key_msg(), atcah_gen_mac(), atcah_hmac(), atcah_mac(), atcah_nonce(), atcah_privwrite_auth_mac(), atcah_sha256(), atcah_sign_internal_msg(), and atcah_write_auth_mac().

int atcac_sw_sha2_256_finish ( atcac_sha2_256_ctx ctx,
uint8_t  digest[ATCA_SHA2_256_DIGEST_SIZE] 
)

completes the final SHA256 calculation and returns the final digest/hash

Parameters
[in]ctxptr to context data structure
[out]digestreceives the computed digest of the SHA 256
Returns
ATCA_SUCCESS

References sw_sha256_final().

Referenced by atcac_sw_sha2_256(), atcah_io_decrypt(), atcah_secureboot_enc(), atcah_secureboot_mac(), and atcah_verify_mac().

int atcac_sw_sha2_256_init ( atcac_sha2_256_ctx ctx)

initializes the SHA256 software

Parameters
[in]ctxptr to context data structure
Returns
ATCA_SUCCESS on success, otherwise an error code.

References sw_sha256_init().

Referenced by atcac_sw_sha2_256(), atcah_io_decrypt(), atcah_secureboot_enc(), atcah_secureboot_mac(), and atcah_verify_mac().

int atcac_sw_sha2_256_update ( atcac_sha2_256_ctx ctx,
const uint8_t *  data,
size_t  data_size 
)

updates the running hash with the next block of data, called iteratively for the entire stream of data to be hashed using the SHA256 software

Parameters
[in]ctxptr to SHA context data structure
[in]dataptr to next block of data to hash
[in]data_sizesize amount of data to hash in the given block, in bytes
Returns
ATCA_SUCCESS

References sw_sha256_update().

Referenced by atcac_sw_sha2_256(), atcah_io_decrypt(), atcah_secureboot_enc(), atcah_secureboot_mac(), and atcah_verify_mac().