1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

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>
This commit is contained in:
Yanray Wang
2023-08-24 14:53:16 +08:00
parent a8ac23a758
commit 9141ad1223
6 changed files with 54 additions and 1 deletions

View File

@ -425,6 +425,7 @@ int mbedtls_aria_setkey_enc(mbedtls_aria_context *ctx,
/*
* 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 @@ int mbedtls_aria_setkey_dec(mbedtls_aria_context *ctx,
return 0;
}
#endif /* !MBEDTLS_CIPHER_ENCRYPT_ONLY */
/*
* Encrypt a block
@ -884,12 +886,18 @@ int mbedtls_aria_self_test(int verbose)
/* 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");