1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

crypto/ciphers: remove unneeded max_key_size in cipher_interface_st

This commit is contained in:
Ollrogge 2021-03-30 11:30:11 +02:00
parent 85eebf9e79
commit 650e69038c
3 changed files with 9 additions and 13 deletions

View File

@ -45,7 +45,6 @@
*/
static const cipher_interface_t aes_interface = {
AES_BLOCK_SIZE,
AES_KEY_SIZE,
aes_init,
aes_encrypt,
aes_decrypt

View File

@ -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);
}

View File

@ -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;