mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-03 20:54:41 +02:00
update tests and benchmark for HAVE_AES_DECRYPT
This commit is contained in:
@@ -1694,6 +1694,7 @@ exit_aes_dec:
|
|||||||
|
|
||||||
#endif /* HAVE_AES_DECRYPT */
|
#endif /* HAVE_AES_DECRYPT */
|
||||||
|
|
||||||
|
(void)decLabel;
|
||||||
exit:
|
exit:
|
||||||
|
|
||||||
for (i = 0; i < BENCH_MAX_PENDING; i++) {
|
for (i = 0; i < BENCH_MAX_PENDING; i++) {
|
||||||
@@ -1781,6 +1782,7 @@ static void bench_aesgcm_internal(int doAsync, const byte* key, word32 keySz,
|
|||||||
exit_aes_gcm:
|
exit_aes_gcm:
|
||||||
bench_stats_sym_finish(encLabel, doAsync, count, bench_size, start, ret);
|
bench_stats_sym_finish(encLabel, doAsync, count, bench_size, start, ret);
|
||||||
|
|
||||||
|
#ifdef HAVE_AES_DECRYPT
|
||||||
/* GCM uses same routine in backend for both encrypt and decrypt */
|
/* GCM uses same routine in backend for both encrypt and decrypt */
|
||||||
bench_stats_start(&count, &start);
|
bench_stats_start(&count, &start);
|
||||||
do {
|
do {
|
||||||
@@ -1804,6 +1806,9 @@ exit_aes_gcm:
|
|||||||
} while (bench_stats_sym_check(start));
|
} while (bench_stats_sym_check(start));
|
||||||
exit_aes_gcm_dec:
|
exit_aes_gcm_dec:
|
||||||
bench_stats_sym_finish(decLabel, doAsync, count, bench_size, start, ret);
|
bench_stats_sym_finish(decLabel, doAsync, count, bench_size, start, ret);
|
||||||
|
#endif /* HAVE_AES_DECRYPT */
|
||||||
|
|
||||||
|
(void)decLabel;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
||||||
|
@@ -5312,22 +5312,26 @@ static int aes_cbc_test(void)
|
|||||||
ret = wc_AesCbcEncryptWithKey(cipher, msg, AES_BLOCK_SIZE, key, 17, NULL);
|
ret = wc_AesCbcEncryptWithKey(cipher, msg, AES_BLOCK_SIZE, key, 17, NULL);
|
||||||
if (ret != BAD_FUNC_ARG)
|
if (ret != BAD_FUNC_ARG)
|
||||||
return -4100;
|
return -4100;
|
||||||
|
#ifdef HAVE_AES_DECRYPT
|
||||||
ret = wc_AesCbcDecryptWithKey(plain, cipher, AES_BLOCK_SIZE, key, 17, NULL);
|
ret = wc_AesCbcDecryptWithKey(plain, cipher, AES_BLOCK_SIZE, key, 17, NULL);
|
||||||
if (ret != BAD_FUNC_ARG)
|
if (ret != BAD_FUNC_ARG)
|
||||||
return -4101;
|
return -4101;
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = wc_AesCbcEncryptWithKey(cipher, msg, AES_BLOCK_SIZE, key,
|
ret = wc_AesCbcEncryptWithKey(cipher, msg, AES_BLOCK_SIZE, key,
|
||||||
AES_BLOCK_SIZE, iv);
|
AES_BLOCK_SIZE, iv);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return -4102;
|
return -4102;
|
||||||
|
#ifdef HAVE_AES_DECRYPT
|
||||||
ret = wc_AesCbcDecryptWithKey(plain, cipher, AES_BLOCK_SIZE, key,
|
ret = wc_AesCbcDecryptWithKey(plain, cipher, AES_BLOCK_SIZE, key,
|
||||||
AES_BLOCK_SIZE, iv);
|
AES_BLOCK_SIZE, iv);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return -4103;
|
return -4103;
|
||||||
|
|
||||||
if (XMEMCMP(plain, msg, AES_BLOCK_SIZE) != 0)
|
if (XMEMCMP(plain, msg, AES_BLOCK_SIZE) != 0)
|
||||||
return -4104;
|
return -4104;
|
||||||
|
#endif /* HAVE_AES_DECRYPT */
|
||||||
|
|
||||||
|
(void)plain;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -5781,9 +5785,9 @@ int aes_test(void)
|
|||||||
wc_AesFree(&enc);
|
wc_AesFree(&enc);
|
||||||
#ifdef HAVE_AES_DECRYPT
|
#ifdef HAVE_AES_DECRYPT
|
||||||
wc_AesFree(&dec);
|
wc_AesFree(&dec);
|
||||||
|
(void)plain;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
(void)plain;
|
|
||||||
(void)cipher;
|
(void)cipher;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -6162,6 +6166,7 @@ int aesgcm_test(void)
|
|||||||
if (XMEMCMP(t1, resultT, sizeof(resultT)))
|
if (XMEMCMP(t1, resultT, sizeof(resultT)))
|
||||||
return -4304;
|
return -4304;
|
||||||
|
|
||||||
|
#ifdef HAVE_AES_DECRYPT
|
||||||
result = wc_AesGcmDecrypt(&enc, resultP, resultC, sizeof(resultC),
|
result = wc_AesGcmDecrypt(&enc, resultP, resultC, sizeof(resultC),
|
||||||
iv1, sizeof(iv1), resultT, sizeof(resultT), a, sizeof(a));
|
iv1, sizeof(iv1), resultT, sizeof(resultT), a, sizeof(a));
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||||
@@ -6171,6 +6176,7 @@ int aesgcm_test(void)
|
|||||||
return -4305;
|
return -4305;
|
||||||
if (XMEMCMP(p, resultP, sizeof(resultP)))
|
if (XMEMCMP(p, resultP, sizeof(resultP)))
|
||||||
return -4306;
|
return -4306;
|
||||||
|
#endif /* HAVE_AES_DECRYPT */
|
||||||
|
|
||||||
/* Large buffer test */
|
/* Large buffer test */
|
||||||
#ifdef BENCH_AESGCM_LARGE
|
#ifdef BENCH_AESGCM_LARGE
|
||||||
@@ -6188,6 +6194,7 @@ int aesgcm_test(void)
|
|||||||
if (result != 0)
|
if (result != 0)
|
||||||
return -4307;
|
return -4307;
|
||||||
|
|
||||||
|
#ifdef HAVE_AES_DECRYPT
|
||||||
result = wc_AesGcmDecrypt(&enc, large_outdec, large_output,
|
result = wc_AesGcmDecrypt(&enc, large_outdec, large_output,
|
||||||
BENCH_AESGCM_LARGE, iv1, sizeof(iv1), resultT,
|
BENCH_AESGCM_LARGE, iv1, sizeof(iv1), resultT,
|
||||||
sizeof(resultT), a, sizeof(a));
|
sizeof(resultT), a, sizeof(a));
|
||||||
@@ -6198,6 +6205,7 @@ int aesgcm_test(void)
|
|||||||
return -4308;
|
return -4308;
|
||||||
if (XMEMCMP(large_input, large_outdec, BENCH_AESGCM_LARGE))
|
if (XMEMCMP(large_input, large_outdec, BENCH_AESGCM_LARGE))
|
||||||
return -4309;
|
return -4309;
|
||||||
|
#endif /* HAVE_AES_DECRYPT */
|
||||||
#endif /* BENCH_AESGCM_LARGE */
|
#endif /* BENCH_AESGCM_LARGE */
|
||||||
#ifdef ENABLE_NON_12BYTE_IV_TEST
|
#ifdef ENABLE_NON_12BYTE_IV_TEST
|
||||||
/* Variable IV length test */
|
/* Variable IV length test */
|
||||||
@@ -6210,6 +6218,7 @@ int aesgcm_test(void)
|
|||||||
#endif
|
#endif
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
return -4310;
|
return -4310;
|
||||||
|
#ifdef HAVE_AES_DECRYPT
|
||||||
result = wc_AesGcmDecrypt(&enc, resultP, resultC, sizeof(resultC), k1,
|
result = wc_AesGcmDecrypt(&enc, resultP, resultC, sizeof(resultC), k1,
|
||||||
(word32)ivlen, resultT, sizeof(resultT), a, sizeof(a));
|
(word32)ivlen, resultT, sizeof(resultT), a, sizeof(a));
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||||
@@ -6217,6 +6226,7 @@ int aesgcm_test(void)
|
|||||||
#endif
|
#endif
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
return -4311;
|
return -4311;
|
||||||
|
#endif /* HAVE_AES_DECRYPT */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -6230,6 +6240,7 @@ int aesgcm_test(void)
|
|||||||
#endif
|
#endif
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
return -4312;
|
return -4312;
|
||||||
|
#ifdef HAVE_AES_DECRYPT
|
||||||
result = wc_AesGcmDecrypt(&enc, resultP, resultC, sizeof(resultC), iv1,
|
result = wc_AesGcmDecrypt(&enc, resultP, resultC, sizeof(resultC), iv1,
|
||||||
sizeof(iv1), resultT, sizeof(resultT), p, (word32)alen);
|
sizeof(iv1), resultT, sizeof(resultT), p, (word32)alen);
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||||
@@ -6237,6 +6248,7 @@ int aesgcm_test(void)
|
|||||||
#endif
|
#endif
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
return -4313;
|
return -4313;
|
||||||
|
#endif /* HAVE_AES_DECRYPT */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BENCH_AESGCM_LARGE
|
#ifdef BENCH_AESGCM_LARGE
|
||||||
@@ -6252,6 +6264,7 @@ int aesgcm_test(void)
|
|||||||
if (result != 0)
|
if (result != 0)
|
||||||
return -4314;
|
return -4314;
|
||||||
|
|
||||||
|
#ifdef HAVE_AES_DECRYPT
|
||||||
result = wc_AesGcmDecrypt(&enc, large_outdec, large_output,
|
result = wc_AesGcmDecrypt(&enc, large_outdec, large_output,
|
||||||
plen, iv1, sizeof(iv1), resultT,
|
plen, iv1, sizeof(iv1), resultT,
|
||||||
sizeof(resultT), a, sizeof(a));
|
sizeof(resultT), a, sizeof(a));
|
||||||
@@ -6260,6 +6273,7 @@ int aesgcm_test(void)
|
|||||||
#endif
|
#endif
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
return -4315;
|
return -4315;
|
||||||
|
#endif /* HAVE_AES_DECRYPT */
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* Variable plain text length test */
|
/* Variable plain text length test */
|
||||||
@@ -6272,6 +6286,7 @@ int aesgcm_test(void)
|
|||||||
#endif
|
#endif
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
return -4314;
|
return -4314;
|
||||||
|
#ifdef HAVE_AES_DECRYPT
|
||||||
result = wc_AesGcmDecrypt(&enc, resultP, resultC, (word32)plen, iv1,
|
result = wc_AesGcmDecrypt(&enc, resultP, resultC, (word32)plen, iv1,
|
||||||
sizeof(iv1), resultT, sizeof(resultT), a, sizeof(a));
|
sizeof(iv1), resultT, sizeof(resultT), a, sizeof(a));
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||||
@@ -6279,6 +6294,7 @@ int aesgcm_test(void)
|
|||||||
#endif
|
#endif
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
return -4315;
|
return -4315;
|
||||||
|
#endif /* HAVE_AES_DECRYPT */
|
||||||
}
|
}
|
||||||
#endif /* BENCH_AESGCM_LARGE */
|
#endif /* BENCH_AESGCM_LARGE */
|
||||||
#endif /* WOLFSSL_AES_256 */
|
#endif /* WOLFSSL_AES_256 */
|
||||||
@@ -6304,6 +6320,7 @@ int aesgcm_test(void)
|
|||||||
if (XMEMCMP(t2, resultT, sizeof(resultT)))
|
if (XMEMCMP(t2, resultT, sizeof(resultT)))
|
||||||
return -4318;
|
return -4318;
|
||||||
|
|
||||||
|
#ifdef HAVE_AES_DECRYPT
|
||||||
result = wc_AesGcmDecrypt(&enc, resultP, resultC, sizeof(resultC),
|
result = wc_AesGcmDecrypt(&enc, resultP, resultC, sizeof(resultC),
|
||||||
iv2, sizeof(iv2), resultT, sizeof(resultT), a, sizeof(a));
|
iv2, sizeof(iv2), resultT, sizeof(resultT), a, sizeof(a));
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||||
@@ -6313,6 +6330,7 @@ int aesgcm_test(void)
|
|||||||
return -4319;
|
return -4319;
|
||||||
if (XMEMCMP(p, resultP, sizeof(resultP)))
|
if (XMEMCMP(p, resultP, sizeof(resultP)))
|
||||||
return -4320;
|
return -4320;
|
||||||
|
#endif /* HAVE_AES_DECRYPT */
|
||||||
|
|
||||||
XMEMSET(resultT, 0, sizeof(resultT));
|
XMEMSET(resultT, 0, sizeof(resultT));
|
||||||
XMEMSET(resultC, 0, sizeof(resultC));
|
XMEMSET(resultC, 0, sizeof(resultC));
|
||||||
@@ -6333,6 +6351,7 @@ int aesgcm_test(void)
|
|||||||
if (XMEMCMP(t3, resultT, sizeof(t3)))
|
if (XMEMCMP(t3, resultT, sizeof(t3)))
|
||||||
return -8211;
|
return -8211;
|
||||||
|
|
||||||
|
#ifdef HAVE_AES_DECRYPT
|
||||||
result = wc_AesGcmDecrypt(&enc, resultP, resultC, sizeof(c3),
|
result = wc_AesGcmDecrypt(&enc, resultP, resultC, sizeof(c3),
|
||||||
iv3, sizeof(iv3), resultT, sizeof(t3), a3, sizeof(a3));
|
iv3, sizeof(iv3), resultT, sizeof(t3), a3, sizeof(a3));
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||||
@@ -6342,6 +6361,7 @@ int aesgcm_test(void)
|
|||||||
return -8212;
|
return -8212;
|
||||||
if (XMEMCMP(p3, resultP, sizeof(p3)))
|
if (XMEMCMP(p3, resultP, sizeof(p3)))
|
||||||
return -8213;
|
return -8213;
|
||||||
|
#endif /* HAVE_AES_DECRYPT */
|
||||||
#endif /* WOLFSSL_AES_128 */
|
#endif /* WOLFSSL_AES_128 */
|
||||||
#endif /* ENABLE_NON_12BYTE_IV_TEST */
|
#endif /* ENABLE_NON_12BYTE_IV_TEST */
|
||||||
|
|
||||||
@@ -6364,6 +6384,7 @@ int aesgcm_test(void)
|
|||||||
if (XMEMCMP(t1, resultT + 1, sizeof(resultT) - 1))
|
if (XMEMCMP(t1, resultT + 1, sizeof(resultT) - 1))
|
||||||
return -4323;
|
return -4323;
|
||||||
|
|
||||||
|
#ifdef HAVE_AES_DECRYPT
|
||||||
result = wc_AesGcmDecrypt(&enc, resultP, resultC, sizeof(resultC),
|
result = wc_AesGcmDecrypt(&enc, resultP, resultC, sizeof(resultC),
|
||||||
iv1, sizeof(iv1), resultT + 1, sizeof(resultT) - 1, a, sizeof(a));
|
iv1, sizeof(iv1), resultT + 1, sizeof(resultT) - 1, a, sizeof(a));
|
||||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||||
@@ -6373,6 +6394,7 @@ int aesgcm_test(void)
|
|||||||
return -4324;
|
return -4324;
|
||||||
if (XMEMCMP(p, resultP, sizeof(resultP)))
|
if (XMEMCMP(p, resultP, sizeof(resultP)))
|
||||||
return -4325;
|
return -4325;
|
||||||
|
#endif /* HAVE_AES_DECRYPT */
|
||||||
#endif /* WOLFSSL_AES_256 */
|
#endif /* WOLFSSL_AES_256 */
|
||||||
wc_AesFree(&enc);
|
wc_AesFree(&enc);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user