Merge pull request #16253 from Ollrogge/ciphers_PR

crypto/ciphers: remove unneeded max_key_size in cipher_interface_st
This commit is contained in:
Peter Kietzmann 2021-04-06 11:18:30 +02:00 committed by GitHub
commit c8cb79c3cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;