Firmware SDK
twr_aes

Driver for AES. More...

Macros

#define TWR_AES_KEYLEN   128
 
#define TWR_AES_IVLEN   128
 

Typedefs

typedef uint32_t twr_aes_key_t[TWR_AES_KEYLEN/8/4]
 AES 128-bit Key.
 
typedef uint32_t twr_aes_iv_t[TWR_AES_IVLEN/8/4]
 AES 128-bit Initialization vector.
 

Functions

void twr_aes_init (void)
 Initialize AES.
 
bool twr_aes_key_derivation (twr_aes_key_t decryption_key, const twr_aes_key_t key)
 AES derivation decryption key from encryption key. More...
 
bool twr_aes_ecb_encrypt (void *buffer_out, const void *buffer_in, const size_t length, const twr_aes_key_t key)
 AES encryption Electronic CodeBook (ECB) More...
 
bool twr_aes_ecb_decrypt (void *buffer_out, const void *buffer_in, size_t length, twr_aes_key_t key)
 AES decryption Electronic CodeBook (ECB) More...
 
bool twr_aes_ctwr_encrypt (void *buffer_out, const void *buffer_in, size_t length, twr_aes_key_t key, twr_aes_iv_t iv)
 AES Cipher block chaining (CBC) More...
 
bool twr_aes_ctwr_decrypt (void *buffer_out, const void *buffer_in, size_t length, twr_aes_key_t key, twr_aes_iv_t iv)
 AES Cipher block chaining (CBC) More...
 
void twr_aes_key_from_uint8 (twr_aes_key_t key, const uint8_t *buffer)
 Create key from uint8 array. More...
 
void twr_aes_iv_from_uint8 (twr_aes_iv_t iv, const uint8_t *buffer)
 Create Initialization vector from uint8 array. More...
 

Detailed Description

Driver for AES.

Function Documentation

◆ twr_aes_ctwr_decrypt()

bool twr_aes_ctwr_decrypt ( void *  buffer_out,
const void *  buffer_in,
size_t  length,
twr_aes_key_t  key,
twr_aes_iv_t  iv 
)

AES Cipher block chaining (CBC)

Parameters
[out]buffer_outPointer to destination buffer
[in]buffer_inPointer to source buffer
[in]lengthNumber of bytes
[in]key128-bit decryption key
[in]iv128-bit Initialization vector
Returns
true On success
false On failure

Definition at line 96 of file twr_aes.c.

◆ twr_aes_ctwr_encrypt()

bool twr_aes_ctwr_encrypt ( void *  buffer_out,
const void *  buffer_in,
size_t  length,
twr_aes_key_t  key,
twr_aes_iv_t  iv 
)

AES Cipher block chaining (CBC)

Parameters
[out]buffer_outPointer to destination buffer
[in]buffer_inPointer to source buffer
[in]lengthNumber of bytes
[in]key128-bit encryption key
[in]iv128-bit Initialization vector
Returns
true On success
false On failure

Definition at line 80 of file twr_aes.c.

◆ twr_aes_ecb_decrypt()

bool twr_aes_ecb_decrypt ( void *  buffer_out,
const void *  buffer_in,
size_t  length,
twr_aes_key_t  key 
)

AES decryption Electronic CodeBook (ECB)

Parameters
[out]buffer_outPointer to destination buffer
[in]buffer_inPointer to source buffer
[in]lengthNumber of bytes
[in]key128-bit decryption key
Returns
true On success
false On failure

Definition at line 66 of file twr_aes.c.

◆ twr_aes_ecb_encrypt()

bool twr_aes_ecb_encrypt ( void *  buffer_out,
const void *  buffer_in,
const size_t  length,
const twr_aes_key_t  key 
)

AES encryption Electronic CodeBook (ECB)

Parameters
[out]buffer_outPointer to destination buffer
[in]buffer_inPointer to source buffer
[in]lengthNumber of bytes
[in]key128-bit encryption key
Returns
true On success
false On failure

Definition at line 52 of file twr_aes.c.

◆ twr_aes_iv_from_uint8()

void twr_aes_iv_from_uint8 ( twr_aes_iv_t  iv,
const uint8_t *  buffer 
)

Create Initialization vector from uint8 array.

Parameters
[out]iv128-bit Initialization vector
[in]bufferPointer to source buffer

Definition at line 122 of file twr_aes.c.

◆ twr_aes_key_derivation()

bool twr_aes_key_derivation ( twr_aes_key_t  decryption_key,
const twr_aes_key_t  key 
)

AES derivation decryption key from encryption key.

Parameters
[out]key128-bit decryption key
[in]key128-bit encryption key
Returns
true On success
false On failure

Definition at line 19 of file twr_aes.c.

Here is the call graph for this function:

◆ twr_aes_key_from_uint8()

void twr_aes_key_from_uint8 ( twr_aes_key_t  key,
const uint8_t *  buffer 
)

Create key from uint8 array.

Parameters
[out]keykey 128-bit encryption key
[in]bufferPointer to source buffer

Definition at line 112 of file twr_aes.c.