Merge pull request #16253 from Ollrogge/ciphers_PR
crypto/ciphers: remove unneeded max_key_size in cipher_interface_st
This commit is contained in:
commit
c8cb79c3cf
@ -45,7 +45,6 @@
|
|||||||
*/
|
*/
|
||||||
static const cipher_interface_t aes_interface = {
|
static const cipher_interface_t aes_interface = {
|
||||||
AES_BLOCK_SIZE,
|
AES_BLOCK_SIZE,
|
||||||
AES_KEY_SIZE,
|
|
||||||
aes_init,
|
aes_init,
|
||||||
aes_encrypt,
|
aes_encrypt,
|
||||||
aes_decrypt
|
aes_decrypt
|
||||||
|
|||||||
@ -22,13 +22,8 @@
|
|||||||
int cipher_init(cipher_t *cipher, cipher_id_t cipher_id, const uint8_t *key,
|
int cipher_init(cipher_t *cipher, cipher_id_t cipher_id, const uint8_t *key,
|
||||||
uint8_t key_size)
|
uint8_t key_size)
|
||||||
{
|
{
|
||||||
if (key_size > cipher_id->max_key_size) {
|
|
||||||
return CIPHER_ERR_INVALID_KEY_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
cipher->interface = cipher_id;
|
cipher->interface = cipher_id;
|
||||||
return cipher->interface->init(&cipher->context, key, key_size);
|
return cipher->interface->init(&cipher->context, key, key_size);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -73,20 +73,22 @@ typedef struct {
|
|||||||
* @brief BlockCipher-Interface for the Cipher-Algorithms
|
* @brief BlockCipher-Interface for the Cipher-Algorithms
|
||||||
*/
|
*/
|
||||||
typedef struct cipher_interface_st {
|
typedef struct cipher_interface_st {
|
||||||
/** Blocksize of this cipher */
|
/** @brief Blocksize of this cipher */
|
||||||
uint8_t block_size;
|
uint8_t block_size;
|
||||||
|
|
||||||
/** Maximum key size for this cipher */
|
/**
|
||||||
uint8_t max_key_size;
|
* @brief the init function.
|
||||||
|
*
|
||||||
/** 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);
|
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,
|
int (*encrypt)(const cipher_context_t *ctx, const uint8_t *plain_block,
|
||||||
uint8_t *cipher_block);
|
uint8_t *cipher_block);
|
||||||
|
|
||||||
/** the decrypt function */
|
/** @brief the decrypt function */
|
||||||
int (*decrypt)(const cipher_context_t *ctx, const uint8_t *cipher_block,
|
int (*decrypt)(const cipher_context_t *ctx, const uint8_t *cipher_block,
|
||||||
uint8_t *plain_block);
|
uint8_t *plain_block);
|
||||||
} cipher_interface_t;
|
} cipher_interface_t;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user