aria/camellia/des: guard setkey_dec by CIPHER_ENCRYPT_ONLY
This is a pre-step to remove *setkey_dec_func in cipher_wrap ctx
when CIPHER_ENCRYPT_ONLY is enabled.
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
diff --git a/library/aria.c b/library/aria.c
index 0980362..0bd489e 100644
--- a/library/aria.c
+++ b/library/aria.c
@@ -425,6 +425,7 @@
/*
* Set decryption key
*/
+#if !defined(MBEDTLS_CIPHER_ENCRYPT_ONLY)
int mbedtls_aria_setkey_dec(mbedtls_aria_context *ctx,
const unsigned char *key, unsigned int keybits)
{
@@ -454,6 +455,7 @@
return 0;
}
+#endif /* !MBEDTLS_CIPHER_ENCRYPT_ONLY */
/*
* Encrypt a block
@@ -884,12 +886,18 @@
/* test ECB decryption */
if (verbose) {
mbedtls_printf(" ARIA-ECB-%d (dec): ", 128 + 64 * i);
+#if defined(MBEDTLS_CIPHER_ENCRYPT_ONLY)
+ mbedtls_printf("skipped\n");
+#endif
}
+
+#if !defined(MBEDTLS_CIPHER_ENCRYPT_ONLY)
mbedtls_aria_setkey_dec(&ctx, aria_test1_ecb_key, 128 + 64 * i);
mbedtls_aria_crypt_ecb(&ctx, aria_test1_ecb_ct[i], blk);
ARIA_SELF_TEST_ASSERT(
memcmp(blk, aria_test1_ecb_pt, MBEDTLS_ARIA_BLOCKSIZE)
!= 0);
+#endif
}
if (verbose) {
mbedtls_printf("\n");