Firmware SDK
twr_aes.h
1 #ifndef _TWR_AES_H
2 #define _TWR_AES_H
3 
4 #include <twr_common.h>
5 
9 
10 #define TWR_AES_KEYLEN 128
11 #define TWR_AES_IVLEN 128
12 
14 
15 typedef uint32_t twr_aes_key_t[TWR_AES_KEYLEN/8/4];
16 
18 
19 typedef uint32_t twr_aes_iv_t[TWR_AES_IVLEN/8/4];
20 
22 
23 void twr_aes_init(void);
24 
30 
31 bool twr_aes_key_derivation(twr_aes_key_t decryption_key, const twr_aes_key_t key);
32 
40 
41 bool twr_aes_ecb_encrypt(void *buffer_out, const void *buffer_in, const size_t length, const twr_aes_key_t key);
42 
50 
51 bool twr_aes_ecb_decrypt(void *buffer_out, const void *buffer_in, size_t length, twr_aes_key_t key);
52 
61 
62 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);
63 
72 
73 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);
74 
78 
79 void twr_aes_key_from_uint8(twr_aes_key_t key, const uint8_t *buffer);
80 
84 
85 void twr_aes_iv_from_uint8(twr_aes_iv_t iv, const uint8_t *buffer);
86 
88 
89 #endif // _TWR_AES_H
uint32_t twr_aes_iv_t[TWR_AES_IVLEN/8/4]
AES 128-bit Initialization vector.
Definition: twr_aes.h:19
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)
Definition: twr_aes.c:96
void twr_aes_key_from_uint8(twr_aes_key_t key, const uint8_t *buffer)
Create key from uint8 array.
Definition: twr_aes.c:112
uint32_t twr_aes_key_t[TWR_AES_KEYLEN/8/4]
AES 128-bit Key.
Definition: twr_aes.h:15
void twr_aes_init(void)
Initialize AES.
Definition: twr_aes.c:12
void twr_aes_iv_from_uint8(twr_aes_iv_t iv, const uint8_t *buffer)
Create Initialization vector from uint8 array.
Definition: twr_aes.c:122
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)
Definition: twr_aes.c:66
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)
Definition: twr_aes.c:52
bool twr_aes_key_derivation(twr_aes_key_t decryption_key, const twr_aes_key_t key)
AES derivation decryption key from encryption key.
Definition: twr_aes.c:19
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)
Definition: twr_aes.c:80