Class to perform AES encryption, decryption and CMAC.
More...
#include <Cryptography.h>
|
|
| RadioLibAES128 () |
| | Default constructor.
|
| |
| void | init (uint8_t *key) |
| | Initialize the AES.
|
| |
| size_t | encryptECB (const uint8_t *in, size_t len, uint8_t *out) |
| | Perform ECB-type AES encryption.
|
| |
| size_t | decryptECB (const uint8_t *in, size_t len, uint8_t *out) |
| | Perform ECB-type AES decryption.
|
| |
| void | generateCMAC (const uint8_t *in, size_t len, uint8_t *cmac) |
| | Calculate message authentication code according to RFC4493.
|
| |
| void | initCMAC (RadioLibCmacState *st) |
| | Initialize the CMAC state. This must be called before any updateCMAC calls.
|
| |
| void | updateCMAC (RadioLibCmacState *st, const uint8_t *data, size_t len) |
| | Update the CMAC state with a chunk of data. This can be called multiple times to process the data in chunks.
|
| |
| void | finishCMAC (RadioLibCmacState *st, uint8_t *out) |
| | Finalize the CMAC calculation and save the result. This must be called after all updateCMAC calls are done.
|
| |
| bool | verifyCMAC (const uint8_t *in, size_t len, const uint8_t *cmac) |
| | Verify the received CMAC. This just calculates the CMAC again and compares the results.
|
| |
Class to perform AES encryption, decryption and CMAC.
Most of the implementation here is adapted from https://github.com/kokke/tiny-AES-c Additional code and CMAC calculation is from https://github.com/megrxu/AES-CMAC
◆ decryptECB()
| size_t RadioLibAES128::decryptECB |
( |
const uint8_t * |
in, |
|
|
size_t |
len, |
|
|
uint8_t * |
out |
|
) |
| |
Perform ECB-type AES decryption.
- Parameters
-
| in | Input ciphertext data. |
| len | Length of the input data. |
| out | Buffer to save the output plaintext into. It is up to the caller to ensure the buffer is sufficiently large to save the data! |
- Returns
- The number of bytes saved into the output buffer.
◆ encryptECB()
| size_t RadioLibAES128::encryptECB |
( |
const uint8_t * |
in, |
|
|
size_t |
len, |
|
|
uint8_t * |
out |
|
) |
| |
Perform ECB-type AES encryption.
- Parameters
-
| in | Input plaintext data (unpadded). |
| len | Length of the input data. |
| out | Buffer to save the output ciphertext into. It is up to the caller to ensure the buffer is sufficiently large to save the data! |
- Returns
- The number of bytes saved into the output buffer.
◆ finishCMAC()
Finalize the CMAC calculation and save the result. This must be called after all updateCMAC calls are done.
- Parameters
-
| st | State to finalize. |
| out | Buffer to save the output MAC into. The buffer must be at least 16 bytes long! |
◆ generateCMAC()
| void RadioLibAES128::generateCMAC |
( |
const uint8_t * |
in, |
|
|
size_t |
len, |
|
|
uint8_t * |
cmac |
|
) |
| |
Calculate message authentication code according to RFC4493.
- Parameters
-
| in | Input data (unpadded). |
| len | Length of the input data. |
| cmac | Buffer to save the output MAC into. The buffer must be at least 16 bytes long! |
◆ init()
| void RadioLibAES128::init |
( |
uint8_t * |
key | ) |
|
Initialize the AES.
- Parameters
-
◆ initCMAC()
Initialize the CMAC state. This must be called before any updateCMAC calls.
- Parameters
-
◆ updateCMAC()
| void RadioLibAES128::updateCMAC |
( |
RadioLibCmacState * |
st, |
|
|
const uint8_t * |
data, |
|
|
size_t |
len |
|
) |
| |
Update the CMAC state with a chunk of data. This can be called multiple times to process the data in chunks.
- Parameters
-
| st | State to update. |
| data | Input data (unpadded). |
| len | Length of the input data. |
◆ verifyCMAC()
| bool RadioLibAES128::verifyCMAC |
( |
const uint8_t * |
in, |
|
|
size_t |
len, |
|
|
const uint8_t * |
cmac |
|
) |
| |
Verify the received CMAC. This just calculates the CMAC again and compares the results.
- Parameters
-
| in | Input data (unpadded). |
| len | Length of the input data. |
| cmac | CMAC to verify. |
- Returns
- True if valid, false otherwise.
The documentation for this class was generated from the following files: