Skip to content

Commit 9e6cc82

Browse files
authored
Merge pull request #345 from miyazakh/chunk
Set chunk in whTest_CryptoShaxxxAsync based on the defined DATA_LEN
2 parents 655e1c9 + 09a0fcf commit 9e6cc82

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

test/wh_test_crypto.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,7 +1824,9 @@ static int whTest_CryptoSha256Async(whClientContext* ctx, int devId,
18241824
(void)wc_Sha256Free(sha256);
18251825
ret = wc_InitSha256_ex(sha256, NULL, devId);
18261826
while (ret == 0 && consumed < BUFSZ) {
1827-
uint32_t chunk = 700; /* arbitrary, less than max inline */
1827+
/* arbitrary, 70% of max inline */
1828+
uint32_t chunk =
1829+
(WH_MESSAGE_CRYPTO_SHA256_MAX_INLINE_UPDATE_SZ * 7 / 10);
18281830
if (consumed + chunk > BUFSZ) {
18291831
chunk = BUFSZ - consumed;
18301832
}
@@ -2337,7 +2339,9 @@ static int whTest_CryptoSha224Async(whClientContext* ctx, int devId,
23372339
(void)wc_Sha224Free(sha224);
23382340
ret = wc_InitSha224_ex(sha224, NULL, devId);
23392341
while (ret == 0 && consumed < BUFSZ) {
2340-
uint32_t chunk = 700; /* arbitrary, less than max inline */
2342+
/* arbitrary, 70% of max inline */
2343+
uint32_t chunk =
2344+
(WH_MESSAGE_CRYPTO_SHA224_MAX_INLINE_UPDATE_SZ * 7 / 10);
23412345
if (consumed + chunk > BUFSZ) {
23422346
chunk = BUFSZ - consumed;
23432347
}
@@ -2857,7 +2861,9 @@ static int whTest_CryptoSha384Async(whClientContext* ctx, int devId,
28572861
(void)wc_Sha384Free(sha384);
28582862
ret = wc_InitSha384_ex(sha384, NULL, devId);
28592863
while (ret == 0 && consumed < BUFSZ) {
2860-
uint32_t chunk = 1400; /* arbitrary, less than max inline */
2864+
/* arbitrary, 70% of max inline */
2865+
uint32_t chunk =
2866+
(WH_MESSAGE_CRYPTO_SHA384_MAX_INLINE_UPDATE_SZ * 7 / 10);
28612867
if (consumed + chunk > BUFSZ) {
28622868
chunk = BUFSZ - consumed;
28632869
}
@@ -3381,7 +3387,9 @@ static int whTest_CryptoSha512Async(whClientContext* ctx, int devId,
33813387
(void)wc_Sha512Free(sha512);
33823388
ret = wc_InitSha512_ex(sha512, NULL, devId);
33833389
while (ret == 0 && consumed < BUFSZ) {
3384-
uint32_t chunk = 1400; /* arbitrary, less than max inline */
3390+
/* arbitrary, 70% of max inline */
3391+
uint32_t chunk =
3392+
(WH_MESSAGE_CRYPTO_SHA512_MAX_INLINE_UPDATE_SZ * 7 / 10);
33853393
if (consumed + chunk > BUFSZ) {
33863394
chunk = BUFSZ - consumed;
33873395
}
@@ -5904,14 +5912,14 @@ static int whTestCrypto_MlDsaClient(whClientContext* ctx, int devId,
59045912
word32 sigLen = sizeof(sig);
59055913
int verified = 0;
59065914

5907-
ret = wh_Client_MlDsaSign(ctx, msg, sizeof(msg), sig, &sigLen, key,
5915+
ret = wh_Client_MlDsaSign(ctx, msg, sizeof(msg), sig, &sigLen, key,
59085916
NULL, 0, WC_HASH_TYPE_NONE);
59095917
if (ret != 0) {
59105918
WH_ERROR_PRINT("Failed to sign using ML-DSA non-DMA: %d\n", ret);
59115919
}
59125920
else {
59135921
ret = wh_Client_MlDsaVerify(ctx, sig, sigLen, msg, sizeof(msg),
5914-
&verified, key, NULL, 0,
5922+
&verified, key, NULL, 0,
59155923
WC_HASH_TYPE_NONE);
59165924
if (ret != 0) {
59175925
WH_ERROR_PRINT("Failed to verify ML-DSA non-DMA: %d\n", ret);
@@ -6105,7 +6113,7 @@ static int whTestCrypto_MlDsaDmaClient(whClientContext* ctx, int devId,
61056113
else {
61066114
/* Verify the signature - should succeed */
61076115
ret = wh_Client_MlDsaVerifyDma(ctx, sig, sigLen, msg, sizeof(msg),
6108-
&verified, key, NULL, 0,
6116+
&verified, key, NULL, 0,
61096117
WC_HASH_TYPE_NONE);
61106118
if (ret != 0) {
61116119
WH_ERROR_PRINT("Failed to verify signature using ML-DSA: %d\n",

0 commit comments

Comments
 (0)