Headers for the implementation of the AES cipher-algorithm.
More...
Headers for the implementation of the AES cipher-algorithm.
The default key size is 128 bits. To use a different key size add USEMODULE += crypto_aes_192 and/or USEMODULE += crypto_aes_256 to your Makefile.
If only one key size is needed and that key size is not 128 bits, the 128 bit USEMODULE += crypto_aes_192 and/or USEMODULE += crypto_aes_256 to your Makefile.
If only one key size is needed and that key size is not 128 bits, the 128 bit key size can be disabled with DISABLE_MODULE += crypto_aes_128 as an optimization.
- Author
- Nicolai Schmittberger nicol.nosp@m.ai.s.nosp@m.chmit.nosp@m.tber.nosp@m.ger@f.nosp@m.u-be.nosp@m.rlin..nosp@m.de
-
Fabrice Bellard
-
Zakaria Kasmi zkasm.nosp@m.i@in.nosp@m.f.fu-.nosp@m.berl.nosp@m.in.de
Definition in file aes.h.
#include <stdint.h>
#include "compiler_hints.h"
#include "crypto/ciphers.h"
Go to the source code of this file.
|
| int | aes_init (cipher_context_t *context, const uint8_t *key, uint8_t keySize) |
| | initializes the AES Cipher-algorithm with the passed parameters
|
| |
| int | aes_encrypt (const cipher_context_t *context, const uint8_t *plain_block, uint8_t *cipher_block) |
| | encrypts one plainBlock-block and saves the result in cipherblock.
|
| |
| int | aes_decrypt (const cipher_context_t *context, const uint8_t *cipher_block, uint8_t *plain_block) |
| | Decrypts one cipher-block and saves the plain-block in plain_block.
|
| |
| #define | GETU32(pt) |
| |
| #define | PUTU32(ct, st) |
| |
| #define | AES_MAXNR 14 |
| |
| #define | AES_BLOCK_SIZE 16 |
| |
| typedef uint32_t | u32 |
| |
| typedef uint16_t | u16 |
| |
| typedef uint8_t | u8 |
| |
◆ AES_BLOCK_SIZE
| #define AES_BLOCK_SIZE 16 |
Definition at line 53 of file aes.h.
◆ AES_KEY_SIZE_128
| #define AES_KEY_SIZE_128 16 |
Definition at line 59 of file aes.h.
◆ AES_KEY_SIZE_192
| #define AES_KEY_SIZE_192 24 |
Definition at line 60 of file aes.h.
◆ AES_KEY_SIZE_256
| #define AES_KEY_SIZE_256 32 |
Definition at line 61 of file aes.h.
◆ AES_MAXNR
Definition at line 52 of file aes.h.
◆ GETU32
Value: (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ \
((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
Definition at line 45 of file aes.h.
◆ PUTU32
| #define PUTU32 |
( |
| ct, |
|
|
| st ) |
Value: { (ct)[0] = (u8)((st) >> 24); \
(ct)[1] = (u8)((st) >> 16); \
(ct)[2] = (u8)((st) >> 8); \
(ct)[3] = (u8)(st); }
Definition at line 47 of file aes.h.
◆ u16
Definition at line 42 of file aes.h.
◆ u32
Definition at line 41 of file aes.h.
◆ u8
Definition at line 43 of file aes.h.
◆ aes_decrypt()
| int aes_decrypt |
( |
const cipher_context_t * | context, |
|
|
const uint8_t * | cipher_block, |
|
|
uint8_t * | plain_block ) |
Decrypts one cipher-block and saves the plain-block in plain_block.
Decrypts one blocksize long block of ciphertext pointed to by cipher_block to one blocksize long block of plaintext and stores the plaintext in the memory-area pointed to by plain_block.
- Parameters
-
| context | the cipher_context_t-struct to use for this decryption |
| cipher_block | a pointer to the ciphertext-block (of size blocksize) to be decrypted |
| plain_block | a pointer to the place where the decrypted plaintext will be stored |
- Return values
-
| 1 | success |
| -1 | context has not been initialized, see aes_init |
| -2 | key size in context invalid (memory safety bug?) |
| <0 | other error |
◆ aes_encrypt()
| int aes_encrypt |
( |
const cipher_context_t * | context, |
|
|
const uint8_t * | plain_block, |
|
|
uint8_t * | cipher_block ) |
encrypts one plainBlock-block and saves the result in cipherblock.
encrypts one blocksize long block of plaintext pointed to by plainBlock to one blocksize long block of ciphertext which will be written to the memory-area pointed to by cipherBlock
- Parameters
-
| context | the cipher_context_t-struct to use for this encryption |
| plain_block | a pointer to the plaintext-block (of size blocksize) |
| cipher_block | a pointer to the place where the ciphertext will be stored |
- Return values
-
| 1 | success |
| -1 | context has not been initialized, see aes_init |
| -2 | key size in context invalid (memory safety bug?) |
| <0 | other error |
◆ aes_init()
| int aes_init |
( |
cipher_context_t * | context, |
|
|
const uint8_t * | key, |
|
|
uint8_t | keySize ) |
initializes the AES Cipher-algorithm with the passed parameters
- Parameters
-
| context | the cipher_context_t-struct to save the initialization of the cipher in |
| keySize | the size of the key Must be 16, since this implementation does not support key lengths of 24 or 32 bytes |
| key | a pointer to the key |
- Return values
-
| CIPHER_INIT_SUCCESS | the initialization was successful |
| CIPHER_ERR_BAD_CONTEXT_SIZE | CIPHER_MAX_CONTEXT_SIZE undefined |
- Note
CIPHER_ERR_BAD_CONTEXT_SIZE error is typically when the cipher has not been included in the build