diff --git a/sys/crypto/aes.c b/sys/crypto/aes.c index 0e7fd6a75d..a6a229df83 100644 --- a/sys/crypto/aes.c +++ b/sys/crypto/aes.c @@ -45,7 +45,6 @@ */ static const cipher_interface_t aes_interface = { AES_BLOCK_SIZE, - AES_KEY_SIZE, aes_init, aes_encrypt, aes_decrypt diff --git a/sys/crypto/ciphers.c b/sys/crypto/ciphers.c index e51fa72fad..1b8afa60de 100644 --- a/sys/crypto/ciphers.c +++ b/sys/crypto/ciphers.c @@ -22,13 +22,8 @@ int cipher_init(cipher_t *cipher, cipher_id_t cipher_id, const uint8_t *key, uint8_t key_size) { - if (key_size > cipher_id->max_key_size) { - return CIPHER_ERR_INVALID_KEY_SIZE; - } - cipher->interface = cipher_id; return cipher->interface->init(&cipher->context, key, key_size); - } diff --git a/sys/include/crypto/ciphers.h b/sys/include/crypto/ciphers.h index 5c7b24b8e8..d66e7a54e4 100644 --- a/sys/include/crypto/ciphers.h +++ b/sys/include/crypto/ciphers.h @@ -73,20 +73,22 @@ typedef struct { * @brief BlockCipher-Interface for the Cipher-Algorithms */ typedef struct cipher_interface_st { - /** Blocksize of this cipher */ + /** @brief Blocksize of this cipher */ uint8_t block_size; - /** Maximum key size for this cipher */ - uint8_t max_key_size; - - /** the init function */ + /** + * @brief the init function. + * + * This function is responsible for checking that the given key_size is + * valid for the chosen cipher. + */ int (*init)(cipher_context_t *ctx, const uint8_t *key, uint8_t key_size); - /** the encrypt function */ + /** @brief the encrypt function */ int (*encrypt)(const cipher_context_t *ctx, const uint8_t *plain_block, uint8_t *cipher_block); - /** the decrypt function */ + /** @brief the decrypt function */ int (*decrypt)(const cipher_context_t *ctx, const uint8_t *cipher_block, uint8_t *plain_block); } cipher_interface_t;