CryptoAuthLib
Atmel CryptoAuthentication Library
Software crypto methods (atcac_)

These methods provide a software implementation of various crypto algorithms. More...

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 More...
 
int atcac_sw_random (uint8_t *data, size_t data_size)
 return software generated random number More...
 
int atcac_sw_sha1_init (atcac_sha1_ctx *ctx)
 
int atcac_sw_sha1_update (atcac_sha1_ctx *ctx, const uint8_t *data, size_t data_size)
 
int atcac_sw_sha1_finish (atcac_sha1_ctx *ctx, uint8_t digest[ATCA_SHA1_DIGEST_SIZE])
 
int atcac_sw_sha1 (const uint8_t *data, size_t data_size, uint8_t digest[ATCA_SHA1_DIGEST_SIZE])
 
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 More...
 
int atcac_sw_sha2_256_finish (atcac_sha2_256_ctx *ctx, uint8_t digest[ATCA_SHA2_256_DIGEST_SIZE])
 completes the final SHA calculation and returns the final digest/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 to comput SHA256 of given data More...
 

Detailed Description

These methods provide a software implementation of various crypto algorithms.

Macro Definition Documentation

#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)

Function Documentation

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

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_STATUS
int atcac_sw_random ( uint8_t *  data,
size_t  data_size 
)

return software generated random number

Parameters
[out]dataptr to space to receive the random number
[in]data_sizesize of data buffer return ATCA_STATUS
int atcac_sw_sha1 ( const uint8_t *  data,
size_t  data_size,
uint8_t  digest[ATCA_SHA1_DIGEST_SIZE] 
)
int atcac_sw_sha1_finish ( atcac_sha1_ctx ctx,
uint8_t  digest[ATCA_SHA1_DIGEST_SIZE] 
)
int atcac_sw_sha1_init ( atcac_sha1_ctx ctx)
int atcac_sw_sha1_update ( atcac_sha1_ctx ctx,
const uint8_t *  data,
size_t  data_size 
)
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 to comput SHA256 of given data

Parameters
[in]datapointer to stream of data to hash
[in]data_sizesize of data stream to hash
[out]digestresult
Returns
ATCA_STATUS
int atcac_sw_sha2_256_finish ( atcac_sha2_256_ctx ctx,
uint8_t  digest[ATCA_SHA2_256_DIGEST_SIZE] 
)

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

Parameters
[in]ctxptr to context data structure
[out]digestreceives the computed digest of the SHA 256 has
Returns
ATCA_STATUS
int atcac_sw_sha2_256_init ( atcac_sha2_256_ctx ctx)

initializes the SHA256 software

Parameters
[in]ctxptr to context data structure
Returns
ATCA_STATUS value
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

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_STATUS