CryptoAuthLib
Microchip CryptoAuthentication Library
|
Unity tests for the cryptoauthlib AES GCM functions. More...
#include "cryptoauthlib.h"
Go to the source code of this file.
Data Structures | |
struct | atca_aes_gcm_ctx |
Typedefs | |
typedef struct atca_aes_gcm_ctx | atca_aes_gcm_ctx_t |
Functions | |
ATCA_STATUS | atcab_aes_gcm_init (atca_aes_gcm_ctx_t *ctx, uint16_t key_id, uint8_t key_block, const uint8_t *iv, size_t iv_size) |
Initialize context for AES GCM operation with an existing IV, which is common when starting a decrypt operation. More... | |
ATCA_STATUS | atcab_aes_gcm_init_rand (atca_aes_gcm_ctx_t *ctx, uint16_t key_id, uint8_t key_block, size_t rand_size, const uint8_t *free_field, size_t free_field_size, uint8_t *iv) |
Initialize context for AES GCM operation with a IV composed of a random and optional fixed(free) field, which is common when starting an encrypt operation. More... | |
ATCA_STATUS | atcab_aes_gcm_aad_update (atca_aes_gcm_ctx_t *ctx, const uint8_t *aad, uint32_t aad_size) |
Process Additional Authenticated Data (AAD) using GCM mode and a key within the ATECC608A device. More... | |
ATCA_STATUS | atcab_aes_gcm_encrypt_update (atca_aes_gcm_ctx_t *ctx, const uint8_t *plaintext, uint32_t plaintext_size, uint8_t *ciphertext) |
Encrypt data using GCM mode and a key within the ATECC608A device. atcab_aes_gcm_init() or atcab_aes_gcm_init_rand() should be called before the first use of this function. More... | |
ATCA_STATUS | atcab_aes_gcm_encrypt_finish (atca_aes_gcm_ctx_t *ctx, uint8_t *tag, size_t tag_size) |
Complete a GCM encrypt operation returning the authentication tag. More... | |
ATCA_STATUS | atcab_aes_gcm_decrypt_update (atca_aes_gcm_ctx_t *ctx, const uint8_t *ciphertext, uint32_t ciphertext_size, uint8_t *plaintext) |
Decrypt data using GCM mode and a key within the ATECC608A device. atcab_aes_gcm_init() or atcab_aes_gcm_init_rand() should be called before the first use of this function. More... | |
ATCA_STATUS | atcab_aes_gcm_decrypt_finish (atca_aes_gcm_ctx_t *ctx, const uint8_t *tag, size_t tag_size, bool *is_verified) |
Complete a GCM decrypt operation verifying the authentication tag. More... | |
Variables | |
const char * | atca_basic_aes_gcm_version |
Unity tests for the cryptoauthlib AES GCM functions.
typedef struct atca_aes_gcm_ctx atca_aes_gcm_ctx_t |
Context structure for AES GCM operations.
ATCA_STATUS atcab_aes_gcm_aad_update | ( | atca_aes_gcm_ctx_t * | ctx, |
const uint8_t * | aad, | ||
uint32_t | aad_size | ||
) |
Process Additional Authenticated Data (AAD) using GCM mode and a key within the ATECC608A device.
This can be called multiple times. atcab_aes_gcm_init() or atcab_aes_gcm_init_rand() should be called before the first use of this function. When there is AAD to include, this should be called before atcab_aes_gcm_encrypt_update() or atcab_aes_gcm_decrypt_update().
[in] | ctx | AES GCM context |
[in] | aad | Additional authenticated data to be added |
[in] | aad_size | Size of aad in bytes |
ATCA_STATUS atcab_aes_gcm_decrypt_finish | ( | atca_aes_gcm_ctx_t * | ctx, |
const uint8_t * | tag, | ||
size_t | tag_size, | ||
bool * | is_verified | ||
) |
Complete a GCM decrypt operation verifying the authentication tag.
[in] | ctx | AES GCM context structure. |
[in] | tag | Expected authentication tag. |
[in] | tag_size | Size of tag in bytes (12 to 16 bytes). |
[out] | is_verified | Returns whether or not the tag verified. |
ATCA_STATUS atcab_aes_gcm_decrypt_update | ( | atca_aes_gcm_ctx_t * | ctx, |
const uint8_t * | ciphertext, | ||
uint32_t | ciphertext_size, | ||
uint8_t * | plaintext | ||
) |
Decrypt data using GCM mode and a key within the ATECC608A device. atcab_aes_gcm_init() or atcab_aes_gcm_init_rand() should be called before the first use of this function.
[in] | ctx | AES GCM context structure. |
[in] | ciphertext | Ciphertext to be decrypted. |
[in] | ciphertext_size | Size of ciphertext in bytes. |
[out] | plaintext | Decrypted data is returned here. |
ATCA_STATUS atcab_aes_gcm_encrypt_finish | ( | atca_aes_gcm_ctx_t * | ctx, |
uint8_t * | tag, | ||
size_t | tag_size | ||
) |
Complete a GCM encrypt operation returning the authentication tag.
[in] | ctx | AES GCM context structure. |
[out] | tag | Authentication tag is returned here. |
[in] | tag_size | Tag size in bytes (12 to 16 bytes). |
ATCA_STATUS atcab_aes_gcm_encrypt_update | ( | atca_aes_gcm_ctx_t * | ctx, |
const uint8_t * | plaintext, | ||
uint32_t | plaintext_size, | ||
uint8_t * | ciphertext | ||
) |
Encrypt data using GCM mode and a key within the ATECC608A device. atcab_aes_gcm_init() or atcab_aes_gcm_init_rand() should be called before the first use of this function.
[in] | ctx | AES GCM context structure. |
[in] | plaintext | Plaintext to be encrypted (16 bytes). |
[in] | plaintext_size | Size of plaintext in bytes. |
[out] | ciphertext | Encrypted data is returned here. |
ATCA_STATUS atcab_aes_gcm_init | ( | atca_aes_gcm_ctx_t * | ctx, |
uint16_t | key_id, | ||
uint8_t | key_block, | ||
const uint8_t * | iv, | ||
size_t | iv_size | ||
) |
Initialize context for AES GCM operation with an existing IV, which is common when starting a decrypt operation.
[in] | ctx | AES GCM context to be initialized. |
[in] | key_id | Key location. Can either be a slot number or ATCA_TEMPKEY_KEYID for TempKey. |
[in] | key_block | Index of the 16-byte block to use within the key location for the actual key. |
[in] | iv | Initialization vector. |
[in] | iv_size | Size of IV in bytes. Standard is 12 bytes. |
ATCA_STATUS atcab_aes_gcm_init_rand | ( | atca_aes_gcm_ctx_t * | ctx, |
uint16_t | key_id, | ||
uint8_t | key_block, | ||
size_t | rand_size, | ||
const uint8_t * | free_field, | ||
size_t | free_field_size, | ||
uint8_t * | iv | ||
) |
Initialize context for AES GCM operation with a IV composed of a random and optional fixed(free) field, which is common when starting an encrypt operation.
[in] | ctx | AES CTR context to be initialized. |
[in] | key_id | Key location. Can either be a slot number or ATCA_TEMPKEY_KEYID for TempKey. |
[in] | key_block | Index of the 16-byte block to use within the key location for the actual key. |
[in] | rand_size | Size of the random field in bytes. Minimum and recommended size is 12 bytes. Max is 32 bytes. |
[in] | free_field | Fixed data to include in the IV after the random field. Can be NULL if not used. |
[in] | free_field_size | Size of the free field in bytes. |
[out] | iv | Initialization vector is returned here. Its size will be rand_size and free_field_size combined. |
const char* atca_basic_aes_gcm_version |