mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-07 06:42:56 +03:00
cipher_wrap: remove *setkey_dec_func in CIPHER_ENCRYPT_ONLY
There is no need to set decrypt key under CIPHER_ENCRYPT_ONLY, so we can remove *setkey_dec_func from ctx to save extra code size. Signed-off-by: Yanray Wang <yanray.wang@arm.com>
This commit is contained in:
@@ -396,6 +396,7 @@ int mbedtls_cipher_setkey(mbedtls_cipher_context_t *ctx,
|
||||
ctx->key_bitlen = key_bitlen;
|
||||
ctx->operation = operation;
|
||||
|
||||
#if !defined(MBEDTLS_CIPHER_ENCRYPT_ONLY)
|
||||
/*
|
||||
* For OFB, CFB and CTR mode always use the encryption key schedule
|
||||
*/
|
||||
@@ -413,6 +414,10 @@ int mbedtls_cipher_setkey(mbedtls_cipher_context_t *ctx,
|
||||
}
|
||||
|
||||
return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA;
|
||||
#else
|
||||
return mbedtls_cipher_get_base(ctx->cipher_info)->setkey_enc_func(ctx->cipher_ctx, key,
|
||||
ctx->key_bitlen);
|
||||
#endif
|
||||
}
|
||||
|
||||
int mbedtls_cipher_set_iv(mbedtls_cipher_context_t *ctx,
|
||||
|
Reference in New Issue
Block a user