at86rf2xx_aes.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Otto-von-Guericke-Universität Magdeburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for more
6  * details.
7  */
8 
23 #ifndef AT86RF2XX_AES_H
24 #define AT86RF2XX_AES_H
25 
26 #include "at86rf2xx.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
35 #define AT86RF2XX_AES_KEY_BITS (128U)
36 
39 #define AT86RF2XX_AES_KEY_LENGTH ((AT86RF2XX_AES_KEY_BITS) / 8)
40 
43 #define AT86RF2XX_AES_BLOCK_SIZE ((AT86RF2XX_AES_KEY_BITS) / 8)
44 
47 #define AT86RF2XX_AES_DELAY_US (24)
48 
53 #define AT86RF2XX_REG__AES_STATUS (0x82)
54 #define AT86RF2XX_REG__AES_CTRL (0x83)
55 #define AT86RF2XX_REG__AES_KEY_START (0x84)
56 #define AT86RF2XX_REG__AES_KEY_END (0x93)
57 #define AT86RF2XX_REG__AES_DATA_START (0x84)
58 #define AT86RF2XX_REG__AES_DATA_END (0x93)
59 #define AT86RF2XX_REG__AES_CTRL_MIRROR (0x94)
60 
66 #define AT86RF2XX_AES_STATUS_MASK__AES_ER (0x80)
67 #define AT86RF2XX_AES_STATUS_MASK__AES_DONE (0x01)
68 
69 #define AT86RF2XX_AES_STATUS_AES_ER__NO_ERROR (0x00)
70 #define AT86RF2XX_AES_STATUS_AES_ER__ERROR (0x80)
71 
72 #define AT86RF2XX_AES_STATUS_AES_DONE__NOT_DONE (0x00)
73 #define AT86RF2XX_AES_STATUS_AES_DONE__DONE (0x01)
74 
80 #define AT86RF2XX_AES_CTRL_MASK__AES_REQUEST (0x80)
81 #define AT86RF2XX_AES_CTRL_MASK__AES_MODE (0x70)
82 #define AT86RF2XX_AES_CTRL_MASK__AES_DIR (0x08)
83 
84 #define AT86RF2XX_AES_CTRL_AES_REQUEST__IDLE (0x00)
85 #define AT86RF2XX_AES_CTRL_AES_REQUEST__START (0x80)
86 
87 #define AT86RF2XX_AES_CTRL_AES_MODE__ECB (0x00)
88 #define AT86RF2XX_AES_CTRL_AES_MODE__KEY (0x10)
89 #define AT86RF2XX_AES_CTRL_AES_MODE__CBC (0x20)
90 
91 #define AT86RF2XX_AES_CTRL_AES_DIR__ENC (0x00)
92 #define AT86RF2XX_AES_CTRL_AES_DIR__DEC (0x08)
93 
99 #define AT86RF2XX_AES_CTRL_MIRROR_MASK__AES_REQUEST (0x80)
100 #define AT86RF2XX_AES_CTRL_MIRROR_MASK__AES_MODE (0x70)
101 #define AT86RF2XX_AES_CTRL_MIRROR_MASK__AES_DIR (0x08)
102 
103 #define AT86RF2XX_AES_CTRL_MIRROR_AES_REQUEST__IDLE (0x00)
104 #define AT86RF2XX_AES_CTRL_MIRROR_AES_REQUEST__START (0x80)
105 
106 #define AT86RF2XX_AES_CTRL_MIRROR_AES_MODE__ECB (0x00)
107 #define AT86RF2XX_AES_CTRL_MIRROR_AES_MODE__KEY (0x10)
108 #define AT86RF2XX_AES_CTRL_MIRROR_AES_MODE__CBC (0x20)
109 
110 #define AT86RF2XX_AES_CTRL_MIRROR_AES_DIR__ENC (0x00)
111 #define AT86RF2XX_AES_CTRL_MIRROR_AES_DIR__DEC (0x08)
112 
120 
128  uint8_t key[AT86RF2XX_AES_KEY_LENGTH]);
129 
139  const uint8_t key[AT86RF2XX_AES_KEY_LENGTH]);
140 
148  uint8_t key[AT86RF2XX_AES_KEY_LENGTH]);
149 
159  const uint8_t key[AT86RF2XX_AES_KEY_LENGTH]);
160 
174  aes_block_t *cipher,
175  uint8_t key[AT86RF2XX_AES_BLOCK_SIZE],
176  const aes_block_t *plain,
177  uint8_t nblocks);
178 
192  aes_block_t *plain,
193  uint8_t key[AT86RF2XX_AES_BLOCK_SIZE],
194  const aes_block_t *cipher,
195  uint8_t nblocks);
196 
211  aes_block_t *cipher,
212  uint8_t key[AT86RF2XX_AES_BLOCK_SIZE],
213  uint8_t iv[AT86RF2XX_AES_BLOCK_SIZE],
214  const aes_block_t *plain,
215  uint8_t nblocks);
216 
231  aes_block_t *plain,
232  uint8_t key[AT86RF2XX_AES_BLOCK_SIZE],
233  uint8_t iv[AT86RF2XX_AES_BLOCK_SIZE],
234  const aes_block_t *cipher,
235  uint8_t nblocks);
236 
237 #ifdef __cplusplus
238 }
239 #endif
240 
241 #endif /* AT86RF2XX_AES_H */
242 
at86rf2xx_aes_key_write_decrypt
void at86rf2xx_aes_key_write_decrypt(at86rf2xx_t *dev, const uint8_t key[AT86RF2XX_AES_KEY_LENGTH])
Write the AES key used for decryption.
AT86RF2XX_AES_KEY_LENGTH
#define AT86RF2XX_AES_KEY_LENGTH
AES key length in bytes.
Definition: at86rf2xx_aes.h:39
at86rf2xx_aes_ecb_encrypt
void at86rf2xx_aes_ecb_encrypt(at86rf2xx_t *dev, aes_block_t *cipher, uint8_t key[AT86RF2XX_AES_BLOCK_SIZE], const aes_block_t *plain, uint8_t nblocks)
Perform AES algorithm and encrypt data blocks in plain to cipher data blocks, using ECB mode.
at86rf2xx_aes_cbc_encrypt
void at86rf2xx_aes_cbc_encrypt(at86rf2xx_t *dev, aes_block_t *cipher, uint8_t key[AT86RF2XX_AES_BLOCK_SIZE], uint8_t iv[AT86RF2XX_AES_BLOCK_SIZE], const aes_block_t *plain, uint8_t nblocks)
Perform AES algorithm and encrypt data blocks in plain to cipher data blocks, using CBC mode.
AT86RF2XX_AES_BLOCK_SIZE
#define AT86RF2XX_AES_BLOCK_SIZE
AES block size in bytes.
Definition: at86rf2xx_aes.h:43
at86rf2xx_aes_key_read_decrypt
void at86rf2xx_aes_key_read_decrypt(at86rf2xx_t *dev, uint8_t key[AT86RF2XX_AES_KEY_LENGTH])
Read the AES key used for decryption.
at86rf2xx_aes_ecb_decrypt
void at86rf2xx_aes_ecb_decrypt(at86rf2xx_t *dev, aes_block_t *plain, uint8_t key[AT86RF2XX_AES_BLOCK_SIZE], const aes_block_t *cipher, uint8_t nblocks)
Perform AES algorithm and decrypt data blocks in cipher to plain data blocks, using ECB mode.
at86rf2xx.h
Interface definition for AT86RF2xx based drivers.
at86rf2xx_aes_cbc_decrypt
void at86rf2xx_aes_cbc_decrypt(at86rf2xx_t *dev, aes_block_t *plain, uint8_t key[AT86RF2XX_AES_BLOCK_SIZE], uint8_t iv[AT86RF2XX_AES_BLOCK_SIZE], const aes_block_t *cipher, uint8_t nblocks)
Perform AES algorithm and decrypt data blocks in cipher to plain data blocks, using CBC mode.
at86rf2xx_aes_key_read_encrypt
void at86rf2xx_aes_key_read_encrypt(at86rf2xx_t *dev, uint8_t key[AT86RF2XX_AES_KEY_LENGTH])
Read the AES key used for encryption.
aes_block_t
uint8_t aes_block_t[AT86RF2XX_AES_BLOCK_SIZE]
An AES block.
Definition: at86rf2xx_aes.h:119
at86rf2xx_t
Device descriptor for AT86RF2XX radio devices.
Definition: at86rf2xx.h:246
at86rf2xx_aes_key_write_encrypt
void at86rf2xx_aes_key_write_encrypt(at86rf2xx_t *dev, const uint8_t key[AT86RF2XX_AES_KEY_LENGTH])
Write the AES key used for encryption.