Bluenet
5.7.0
Bluenet, firmware for nRF52 smart home devices
|
Class that implements AES encryption. More...
#include <cs_AES.h>
Public Member Functions | |
void | init () |
Initialize the class, reads from State. More... | |
cs_ret_code_t | encryptEcb (cs_data_t key, cs_data_t prefix, cs_data_t input, cs_data_t output, cs_buffer_size_t &writtenSize) |
Encrypt data with given key in ECB mode. More... | |
cs_ret_code_t | encryptCtr (cs_data_t key, cs_data_t nonce, cs_data_t prefix, cs_data_t input, cs_data_t output, cs_buffer_size_t &writtenSize, uint8_t blockCtr=0) |
Encrypt data with given key in CTR mode. More... | |
cs_ret_code_t | decryptCtr (cs_data_t key, cs_data_t nonce, cs_data_t input, cs_data_t prefix, cs_data_t output, cs_buffer_size_t &writtenSize, uint8_t blockCtr=0) |
Decrypt data with given key in CTR mode. More... | |
Static Public Member Functions | |
static AES & | getInstance () |
Use static variant of singleton, no dynamic memory allocation. More... | |
Private Member Functions | |
AES () | |
AES (AES const &) | |
void | operator= (AES const &) |
cs_ret_code_t | ctr (cs_data_t key, cs_data_t nonce, cs_data_t inputPrefix, cs_data_t input, cs_data_t outputPrefix, cs_data_t output, cs_buffer_size_t &writtenSize, uint8_t blockCtr=0) |
Encrypt or decrypt data with given key in CTR mode. More... | |
Private Attributes | |
nrf_ecb_hal_data_t | _block |
Struct with key, and single block of encrypted and decypted data. More... | |
Class that implements AES encryption.
|
private |
|
private |
Encrypt or decrypt data with given key in CTR mode.
[in] | key | Key to encrypt with. |
[in] | nonce | Nonce to use for encryption. |
[in] | inputPrefix | Extra data to put before the input data. |
[in] | input | Input data to be encrypted. |
[in] | outputPrefix | Extra data to be written to before writing to the output buffer. |
[out] | output | Buffer to encrypt to. Can be the same as input, as long as: output pointer + output prefix size >= input pointer + input prefix size. |
[out] | writtenSize | How many bytes are written to output. |
[in] | blockCtr | Optional initial block counter. |
cs_ret_code_t AES::decryptCtr | ( | cs_data_t | key, |
cs_data_t | nonce, | ||
cs_data_t | input, | ||
cs_data_t | prefix, | ||
cs_data_t | output, | ||
cs_buffer_size_t & | writtenSize, | ||
uint8_t | blockCtr = 0 |
||
) |
Decrypt data with given key in CTR mode.
The decrypted data is a concatenation of prefix and output.
[in] | key | Key to encrypt with. |
[in] | nonce | Nonce to use for decryption. |
[in] | input | Input data to be encrypted. |
[out] | prefix | Buffer to encrypt to, before the output buffer. Can be the same as input. |
[out] | output | Buffer to encrypt to. Can be the same as input, as long as: output pointer <= input pointer + prefix size. |
[out] | writtenSize | How many bytes are written to output. |
[in] | blockCtr | Optional initial block counter. |
cs_ret_code_t AES::encryptCtr | ( | cs_data_t | key, |
cs_data_t | nonce, | ||
cs_data_t | prefix, | ||
cs_data_t | input, | ||
cs_data_t | output, | ||
cs_buffer_size_t & | writtenSize, | ||
uint8_t | blockCtr = 0 |
||
) |
Encrypt data with given key in CTR mode.
The data that's encrypted is a concatenation of prefix and input.
[in] | key | Key to encrypt with. |
[in] | nonce | Nonce to use for encryption. |
[in] | prefix | Extra data to put before the input data. |
[in] | input | Input data to be encrypted. |
[out] | output | Buffer to encrypt to. Can be the same as input, as long as: output pointer <= input pointer - prefix size. |
[out] | writtenSize | How many bytes are written to output. |
[in] | blockCtr | Optional initial block counter. |
cs_ret_code_t AES::encryptEcb | ( | cs_data_t | key, |
cs_data_t | prefix, | ||
cs_data_t | input, | ||
cs_data_t | output, | ||
cs_buffer_size_t & | writtenSize | ||
) |
Encrypt data with given key in ECB mode.
The data that's encrypted is a concatenation of prefix and input.
[in] | key | Key to encrypt with. |
[in] | prefix | Extra data to put before the input data. Can be skipped by passing a null pointer and data size 0. |
[in] | input | Input data to be encrypted. |
[out] | output | Buffer to encrypt to. Can be the same as input, as long as: output pointer >= input pointer + prefix size. |
[out] | writtenSize | How many bytes are written to output. |
|
inlinestatic |
Use static variant of singleton, no dynamic memory allocation.
void AES::init | ( | ) |
Initialize the class, reads from State.
|
private |
|
private |
Struct with key, and single block of encrypted and decypted data.