22#ifndef CRYPTO_CIPHERS_H
23#define CRYPTO_CIPHERS_H
40#if IS_USED(MODULE_CRYPTO_AES_256)
41 #define CIPHERS_MAX_KEY_SIZE 32
42#elif IS_USED(MODULE_CRYPTO_AES_192)
43 #define CIPHERS_MAX_KEY_SIZE 24
45 #define CIPHERS_MAX_KEY_SIZE 16
47#define CIPHER_MAX_BLOCK_SIZE 16
55#if IS_USED(MODULE_CRYPTO_AES_256) || IS_USED(MODULE_CRYPTO_AES_192) || \
56 IS_USED(MODULE_CRYPTO_AES_128)
57 #define CIPHER_MAX_CONTEXT_SIZE CIPHERS_MAX_KEY_SIZE
60 #define CIPHER_MAX_CONTEXT_SIZE 1
65#define CIPHER_ERR_INVALID_KEY_SIZE -3
66#define CIPHER_ERR_INVALID_LENGTH -4
67#define CIPHER_ERR_ENC_FAILED -5
68#define CIPHER_ERR_DEC_FAILED -6
71#define CIPHER_ERR_BAD_CONTEXT_SIZE 0
73#define CIPHER_INIT_SUCCESS 1
100 uint8_t *cipher_block);
104 uint8_t *plain_block);
struct cipher_interface_st cipher_interface_t
BlockCipher-Interface for the Cipher-Algorithms.
int cipher_init(cipher_t *cipher, cipher_id_t cipher_id, const uint8_t *key, uint8_t key_size)
Initialize new cipher state.
#define CIPHER_MAX_CONTEXT_SIZE
Context sizes needed for the different ciphers.
int cipher_decrypt(const cipher_t *cipher, const uint8_t *input, uint8_t *output)
Decrypt data of BLOCK_SIZE length *.
int cipher_encrypt(const cipher_t *cipher, const uint8_t *input, uint8_t *output)
Encrypt data of BLOCK_SIZE length *.
int cipher_get_block_size(const cipher_t *cipher)
Get block size of cipher *.
const cipher_interface_t * cipher_id_t
Pointer type to BlockCipher-Interface for the Cipher-Algorithms.
const cipher_id_t CIPHER_AES
AES cipher id.
Common macros and compiler attributes/pragmas configuration.
the context for cipher-operations
uint8_t key_size
key size used
BlockCipher-Interface for the Cipher-Algorithms.
int(* decrypt)(const cipher_context_t *ctx, const uint8_t *cipher_block, uint8_t *plain_block)
the decrypt function
uint8_t block_size
Blocksize of this cipher.
int(* init)(cipher_context_t *ctx, const uint8_t *key, uint8_t key_size)
the init function.
int(* encrypt)(const cipher_context_t *ctx, const uint8_t *plain_block, uint8_t *cipher_block)
the encrypt function
basic struct for using block ciphers contains the cipher interface and the context
cipher_context_t context
The encryption context (buffer) for the algorithm.
const cipher_interface_t * interface
BlockCipher-Interface for the Cipher-Algorithms.