Skip to content

Commit 7f158da

Browse files
miyazakhjackctj117
authored andcommitted
Support sha2-224, 384 and 512 (wolfSSL#144)
* add sha2-224, 384 and 512 * addressed code review add missing Dma handling * fix Sha512 tests enable sha224, sha384 and sh512 as default enable sha224, sha384 and sha512 at tcp server * addressed code review comments * unify Sha2 Dma Request/Response addressed review comment * run clang-format
1 parent f738840 commit 7f158da

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

src/wh_server_crypto.c

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,29 +1746,16 @@ static int _HandleSha256(whServerContext* ctx, uint16_t magic,
17461746
int ret = 0;
17471747
wc_Sha256 sha256[1];
17481748
whMessageCrypto_Sha256Request req;
1749-
whMessageCrypto_Sha256Response res = {0};
1750-
1751-
/* THe server SHA256 struct doesn't persist state (it is a union), meaning
1752-
* the devId may get blown away between calls. We must restore the server
1753-
* devId each time */
1754-
sha256->devId = ctx->crypto->devId;
1755-
1749+
whMessageCrypto_Sha2Response res;
17561750
/* Translate the request */
17571751
ret = wh_MessageCrypto_TranslateSha256Request(magic, cryptoDataIn, &req);
17581752
if (ret != 0) {
17591753
return ret;
17601754
}
1761-
1762-
/* Init the SHA256 context if this is the first time, otherwise restore the
1763-
* hash state from the client */
1764-
if (req.resumeState.hiLen == 0 && req.resumeState.loLen == 0) {
1765-
ret = wc_InitSha256_ex(sha256, NULL, ctx->crypto->devId);
1766-
}
1767-
else {
1768-
/* HAVE_DILITHIUM */
1769-
memcpy(sha256->digest, req.resumeState.hash, WC_SHA256_DIGEST_SIZE);
1770-
sha256->loLen = req.resumeState.loLen;
1771-
sha256->hiLen = req.resumeState.hiLen;
1755+
/* always init sha2 struct with the devid */
1756+
ret = wc_InitSha256_ex(sha256, NULL, ctx->crypto->devId);
1757+
if (ret != 0) {
1758+
return ret;
17721759
}
17731760
/* restore the hash state from the client */
17741761
memcpy(sha256->digest, req.resumeState.hash, WC_SHA256_DIGEST_SIZE);

0 commit comments

Comments
 (0)