MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Hashcrypt_driver_aes

Data Structures

struct  hashcrypt_handle_t
 Specify HASHCRYPT's key resource. More...
 

Macros

#define HASHCRYPT_AES_BLOCK_SIZE   16U
 AES block size in bytes.
 

Enumerations

enum  hashcrypt_aes_mode_t {
  kHASHCRYPT_AesEcb = 0U,
  kHASHCRYPT_AesCbc = 1U,
  kHASHCRYPT_AesCtr = 2U
}
 AES mode. More...
 
enum  hashcrypt_aes_keysize_t {
  kHASHCRYPT_Aes128 = 0U,
  kHASHCRYPT_Aes192 = 1U,
  kHASHCRYPT_Aes256 = 2U,
  kHASHCRYPT_InvalidKey = 3U
}
 Size of AES key. More...
 
enum  hashcrypt_key_t {
  kHASHCRYPT_UserKey = 0xc3c3U,
  kHASHCRYPT_SecretKey = 0x3c3cU
}
 HASHCRYPT key source selection. More...
 

Functions

status_t HASHCRYPT_AES_SetKey (HASHCRYPT_Type *base, hashcrypt_handle_t *handle, const uint8_t *key, size_t keySize)
 Set AES key to hashcrypt_handle_t struct and optionally to HASHCRYPT. More...
 
status_t HASHCRYPT_AES_EncryptEcb (HASHCRYPT_Type *base, hashcrypt_handle_t *handle, const uint8_t *plaintext, uint8_t *ciphertext, size_t size)
 Encrypts AES on one or multiple 128-bit block(s). More...
 
status_t HASHCRYPT_AES_DecryptEcb (HASHCRYPT_Type *base, hashcrypt_handle_t *handle, const uint8_t *ciphertext, uint8_t *plaintext, size_t size)
 Decrypts AES on one or multiple 128-bit block(s). More...
 
status_t HASHCRYPT_AES_EncryptCbc (HASHCRYPT_Type *base, hashcrypt_handle_t *handle, const uint8_t *plaintext, uint8_t *ciphertext, size_t size, const uint8_t iv[16])
 Encrypts AES using CBC block mode. More...
 
status_t HASHCRYPT_AES_DecryptCbc (HASHCRYPT_Type *base, hashcrypt_handle_t *handle, const uint8_t *ciphertext, uint8_t *plaintext, size_t size, const uint8_t iv[16])
 Decrypts AES using CBC block mode. More...
 
status_t HASHCRYPT_AES_CryptCtr (HASHCRYPT_Type *base, hashcrypt_handle_t *handle, const uint8_t *input, uint8_t *output, size_t size, uint8_t counter[HASHCRYPT_AES_BLOCK_SIZE], uint8_t counterlast[HASHCRYPT_AES_BLOCK_SIZE], size_t *szLeft)
 Encrypts or decrypts AES using CTR block mode. More...
 

Detailed Description


Data Structure Documentation

struct _hashcrypt_handle

Data Fields

uint32_t keyWord [8]
 Copy of user key (set by HASHCRYPT_AES_SetKey(). More...
 
hashcrypt_key_t keyType
 For operations with key (such as AES encryption/decryption), specify key type. More...
 

Field Documentation

uint32_t hashcrypt_handle_t::keyWord[8]
hashcrypt_key_t hashcrypt_handle_t::keyType

Enumeration Type Documentation

Enumerator
kHASHCRYPT_AesEcb 

AES ECB mode.

kHASHCRYPT_AesCbc 

AES CBC mode.

kHASHCRYPT_AesCtr 

AES CTR mode.

Enumerator
kHASHCRYPT_Aes128 

AES 128 bit key.

kHASHCRYPT_Aes192 

AES 192 bit key.

kHASHCRYPT_Aes256 

AES 256 bit key.

kHASHCRYPT_InvalidKey 

AES invalid key.

Enumerator
kHASHCRYPT_UserKey 

HASHCRYPT user key.

kHASHCRYPT_SecretKey 

HASHCRYPT secret key (dedicated hw bus from PUF)

Function Documentation

status_t HASHCRYPT_AES_SetKey ( HASHCRYPT_Type *  base,
hashcrypt_handle_t *  handle,
const uint8_t *  key,
size_t  keySize 
)

Sets the AES key for encryption/decryption with the hashcrypt_handle_t structure. The hashcrypt_handle_t input argument specifies key source.

Parameters
baseHASHCRYPT peripheral base address.
handleHandle used for the request.
key0-mod-4 aligned pointer to AES key.
keySizeAES key size in bytes. Shall equal 16, 24 or 32.
Returns
status from set key operation
status_t HASHCRYPT_AES_EncryptEcb ( HASHCRYPT_Type *  base,
hashcrypt_handle_t *  handle,
const uint8_t *  plaintext,
uint8_t *  ciphertext,
size_t  size 
)

Encrypts AES. The source plaintext and destination ciphertext can overlap in system memory.

Parameters
baseHASHCRYPT peripheral base address
handleHandle used for this request.
plaintextInput plain text to encrypt
[out]ciphertextOutput cipher text
sizeSize of input and output data in bytes. Must be multiple of 16 bytes.
Returns
Status from encrypt operation
status_t HASHCRYPT_AES_DecryptEcb ( HASHCRYPT_Type *  base,
hashcrypt_handle_t *  handle,
const uint8_t *  ciphertext,
uint8_t *  plaintext,
size_t  size 
)

Decrypts AES. The source ciphertext and destination plaintext can overlap in system memory.

Parameters
baseHASHCRYPT peripheral base address
handleHandle used for this request.
ciphertextInput plain text to encrypt
[out]plaintextOutput cipher text
sizeSize of input and output data in bytes. Must be multiple of 16 bytes.
Returns
Status from decrypt operation
status_t HASHCRYPT_AES_EncryptCbc ( HASHCRYPT_Type *  base,
hashcrypt_handle_t *  handle,
const uint8_t *  plaintext,
uint8_t *  ciphertext,
size_t  size,
const uint8_t  iv[16] 
)
Parameters
baseHASHCRYPT peripheral base address
handleHandle used for this request.
plaintextInput plain text to encrypt
[out]ciphertextOutput cipher text
sizeSize of input and output data in bytes. Must be multiple of 16 bytes.
ivInput initial vector to combine with the first input block.
Returns
Status from encrypt operation
status_t HASHCRYPT_AES_DecryptCbc ( HASHCRYPT_Type *  base,
hashcrypt_handle_t *  handle,
const uint8_t *  ciphertext,
uint8_t *  plaintext,
size_t  size,
const uint8_t  iv[16] 
)
Parameters
baseHASHCRYPT peripheral base address
handleHandle used for this request.
ciphertextInput cipher text to decrypt
[out]plaintextOutput plain text
sizeSize of input and output data in bytes. Must be multiple of 16 bytes.
ivInput initial vector to combine with the first input block.
Returns
Status from decrypt operation
status_t HASHCRYPT_AES_CryptCtr ( HASHCRYPT_Type *  base,
hashcrypt_handle_t *  handle,
const uint8_t *  input,
uint8_t *  output,
size_t  size,
uint8_t  counter[HASHCRYPT_AES_BLOCK_SIZE],
uint8_t  counterlast[HASHCRYPT_AES_BLOCK_SIZE],
size_t *  szLeft 
)

Encrypts or decrypts AES using CTR block mode. AES CTR mode uses only forward AES cipher and same algorithm for encryption and decryption. The only difference between encryption and decryption is that, for encryption, the input argument is plain text and the output argument is cipher text. For decryption, the input argument is cipher text and the output argument is plain text.

Parameters
baseHASHCRYPT peripheral base address
handleHandle used for this request.
inputInput data for CTR block mode
[out]outputOutput data for CTR block mode
sizeSize of input and output data in bytes
[in,out]counterInput counter (updates on return)
[out]counterlastOutput cipher of last counter, for chained CTR calls (statefull encryption). NULL can be passed if chained calls are not used.
[out]szLeftOutput number of bytes in left unused in counterlast block. NULL can be passed if chained calls are not used.
Returns
Status from encrypt operation