AES: skip 192bit and 256bit key in selftest if 128bit_only enabled
This includes:
- aes.c
- cmac.c
- gcm.c
- nist_kw.c
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
diff --git a/library/cmac.c b/library/cmac.c
index 7d90ad2..e62db8b 100644
--- a/library/cmac.c
+++ b/library/cmac.c
@@ -760,6 +760,13 @@
mbedtls_printf(" %s CMAC subkey #%d: ", testname, i + 1);
}
+#if defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH)
+ if (keybits > 128) {
+ mbedtls_printf("skipped\n");
+ continue;
+ }
+#endif /* MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH */
+
mbedtls_cipher_init(&ctx);
if ((ret = mbedtls_cipher_setup(&ctx, cipher_info)) != 0) {
@@ -855,6 +862,13 @@
mbedtls_printf(" %s CMAC #%d: ", testname, i + 1);
}
+#if defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH)
+ if (keybits > 128) {
+ mbedtls_printf("skipped\n");
+ continue;
+ }
+#endif /* MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH */
+
if ((ret = mbedtls_cipher_cmac(cipher_info, key, keybits, messages,
message_lengths[i], output)) != 0) {
/* When CMAC is implemented by an alternative implementation, or