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>
diff --git a/library/cipher.c b/library/cipher.c
index de7f837..cefd9e1 100644
--- a/library/cipher.c
+++ b/library/cipher.c
@@ -396,6 +396,7 @@
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 @@
}
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,