Go to the documentation of this file.
22 #ifndef CRYPTO_CIPHERS_H
23 #define CRYPTO_CIPHERS_H
34 #define CIPHERS_MAX_KEY_SIZE 20
35 #define CIPHER_MAX_BLOCK_SIZE 16
44 #if defined(MODULE_CRYPTO_3DES)
45 #define CIPHER_MAX_CONTEXT_SIZE 24
46 #elif defined(MODULE_CRYPTO_AES)
47 #define CIPHER_MAX_CONTEXT_SIZE CIPHERS_MAX_KEY_SIZE
50 #define CIPHER_MAX_CONTEXT_SIZE 1
55 #define CIPHER_ERR_INVALID_KEY_SIZE -3
56 #define CIPHER_ERR_INVALID_LENGTH -4
57 #define CIPHER_ERR_ENC_FAILED -5
58 #define CIPHER_ERR_DEC_FAILED -6
60 #define CIPHER_ERR_BAD_CONTEXT_SIZE 0
62 #define CIPHER_INIT_SUCCESS 1
87 uint8_t *cipher_block);
91 uint8_t *plain_block);
97 extern const cipher_id_t CIPHER_AES_128;
basic struct for using block ciphers contains the cipher interface and the context
uint8_t block_size
Blocksize of this cipher.
int cipher_encrypt(const cipher_t *cipher, const uint8_t *input, uint8_t *output)
Encrypt data of BLOCK_SIZE length *.
#define CIPHER_MAX_CONTEXT_SIZE
Context sizes needed for the different ciphers.
cipher_context_t context
The encryption context (buffer) for the algorithm.
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.
const cipher_interface_t * interface
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
the context for cipher-operations
int cipher_decrypt(const cipher_t *cipher, const uint8_t *input, uint8_t *output)
Decrypt data of BLOCK_SIZE length *.
uint8_t max_key_size
Maximum key size for this cipher.
int(* encrypt)(const cipher_context_t *ctx, const uint8_t *plain_block, uint8_t *cipher_block)
the encrypt function
int cipher_get_block_size(const cipher_t *cipher)
Get block size of cipher *.
struct cipher_interface_st cipher_interface_t
BlockCipher-Interface for the Cipher-Algorithms.
int(* init)(cipher_context_t *ctx, const uint8_t *key, uint8_t key_size)
the init function