Skip to content

Commit 1a779b3

Browse files
fix for passing devId from WOLFSSL_CTX down to hash operation
1 parent 7524552 commit 1a779b3

1 file changed

Lines changed: 27 additions & 15 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17914,7 +17914,8 @@ void FreeSignatureCtx(SignatureCtx* sigCtx)
1791417914

1791517915
#if !defined(NO_ASN_CRYPT) && !defined(NO_HASH_WRAPPER)
1791617916
static int HashForSignature(const byte* buf, word32 bufSz, word32 sigOID,
17917-
byte* digest, int* typeH, int* digestSz, int verify)
17917+
byte* digest, int* typeH, int* digestSz, int verify,
17918+
void* heap, int devId)
1791817919
{
1791917920
int ret = 0;
1792017921

@@ -17933,7 +17934,7 @@ static int HashForSignature(const byte* buf, word32 bufSz, word32 sigOID,
1793317934
#endif
1793417935
#ifndef NO_MD5
1793517936
case CTC_MD5wRSA:
17936-
if ((ret = wc_Md5Hash(buf, bufSz, digest)) == 0) {
17937+
if ((ret = wc_Md5Hash_ex(buf, bufSz, digest, heap, devId)) == 0) {
1793717938
*typeH = MD5h;
1793817939
*digestSz = WC_MD5_DIGEST_SIZE;
1793917940
}
@@ -17943,7 +17944,7 @@ static int HashForSignature(const byte* buf, word32 bufSz, word32 sigOID,
1794317944
case CTC_SHAwRSA:
1794417945
case CTC_SHAwDSA:
1794517946
case CTC_SHAwECDSA:
17946-
if ((ret = wc_ShaHash(buf, bufSz, digest)) == 0) {
17947+
if ((ret = wc_ShaHash_ex(buf, bufSz, digest, heap, devId)) == 0) {
1794717948
*typeH = SHAh;
1794817949
*digestSz = WC_SHA_DIGEST_SIZE;
1794917950
}
@@ -17952,7 +17953,8 @@ static int HashForSignature(const byte* buf, word32 bufSz, word32 sigOID,
1795217953
#ifdef WOLFSSL_SHA224
1795317954
case CTC_SHA224wRSA:
1795417955
case CTC_SHA224wECDSA:
17955-
if ((ret = wc_Sha224Hash(buf, bufSz, digest)) == 0) {
17956+
if ((ret = wc_Sha224Hash_ex(buf, bufSz, digest, heap, devId)) == 0)
17957+
{
1795617958
*typeH = SHA224h;
1795717959
*digestSz = WC_SHA224_DIGEST_SIZE;
1795817960
}
@@ -17962,7 +17964,8 @@ static int HashForSignature(const byte* buf, word32 bufSz, word32 sigOID,
1796217964
case CTC_SHA256wRSA:
1796317965
case CTC_SHA256wECDSA:
1796417966
case CTC_SHA256wDSA:
17965-
if ((ret = wc_Sha256Hash(buf, bufSz, digest)) == 0) {
17967+
if ((ret = wc_Sha256Hash_ex(buf, bufSz, digest, heap, devId)) == 0)
17968+
{
1796617969
*typeH = SHA256h;
1796717970
*digestSz = WC_SHA256_DIGEST_SIZE;
1796817971
}
@@ -17971,7 +17974,8 @@ static int HashForSignature(const byte* buf, word32 bufSz, word32 sigOID,
1797117974
#ifdef WOLFSSL_SHA384
1797217975
case CTC_SHA384wRSA:
1797317976
case CTC_SHA384wECDSA:
17974-
if ((ret = wc_Sha384Hash(buf, bufSz, digest)) == 0) {
17977+
if ((ret = wc_Sha384Hash_ex(buf, bufSz, digest, heap, devId)) == 0)
17978+
{
1797517979
*typeH = SHA384h;
1797617980
*digestSz = WC_SHA384_DIGEST_SIZE;
1797717981
}
@@ -17980,7 +17984,8 @@ static int HashForSignature(const byte* buf, word32 bufSz, word32 sigOID,
1798017984
#ifdef WOLFSSL_SHA512
1798117985
case CTC_SHA512wRSA:
1798217986
case CTC_SHA512wECDSA:
17983-
if ((ret = wc_Sha512Hash(buf, bufSz, digest)) == 0) {
17987+
if ((ret = wc_Sha512Hash_ex(buf, bufSz, digest, heap, devId)) == 0)
17988+
{
1798417989
*typeH = SHA512h;
1798517990
*digestSz = WC_SHA512_DIGEST_SIZE;
1798617991
}
@@ -17990,7 +17995,8 @@ static int HashForSignature(const byte* buf, word32 bufSz, word32 sigOID,
1799017995
#ifndef WOLFSSL_NOSHA3_224
1799117996
case CTC_SHA3_224wRSA:
1799217997
case CTC_SHA3_224wECDSA:
17993-
if ((ret = wc_Sha3_224Hash(buf, bufSz, digest)) == 0) {
17998+
if ((ret = wc_Sha3_224Hash_ex(buf, bufSz, digest, heap, devId))
17999+
== 0) {
1799418000
*typeH = SHA3_224h;
1799518001
*digestSz = WC_SHA3_224_DIGEST_SIZE;
1799618002
}
@@ -17999,7 +18005,8 @@ static int HashForSignature(const byte* buf, word32 bufSz, word32 sigOID,
1799918005
#ifndef WOLFSSL_NOSHA3_256
1800018006
case CTC_SHA3_256wRSA:
1800118007
case CTC_SHA3_256wECDSA:
18002-
if ((ret = wc_Sha3_256Hash(buf, bufSz, digest)) == 0) {
18008+
if ((ret = wc_Sha3_256Hash_ex(buf, bufSz, digest, heap, devId))
18009+
== 0) {
1800318010
*typeH = SHA3_256h;
1800418011
*digestSz = WC_SHA3_256_DIGEST_SIZE;
1800518012
}
@@ -18008,7 +18015,8 @@ static int HashForSignature(const byte* buf, word32 bufSz, word32 sigOID,
1800818015
#ifndef WOLFSSL_NOSHA3_384
1800918016
case CTC_SHA3_384wRSA:
1801018017
case CTC_SHA3_384wECDSA:
18011-
if ((ret = wc_Sha3_384Hash(buf, bufSz, digest)) == 0) {
18018+
if ((ret = wc_Sha3_384Hash_ex(buf, bufSz, digest, heap, devId))
18019+
== 0) {
1801218020
*typeH = SHA3_384h;
1801318021
*digestSz = WC_SHA3_384_DIGEST_SIZE;
1801418022
}
@@ -18017,7 +18025,8 @@ static int HashForSignature(const byte* buf, word32 bufSz, word32 sigOID,
1801718025
#ifndef WOLFSSL_NOSHA3_512
1801818026
case CTC_SHA3_512wRSA:
1801918027
case CTC_SHA3_512wECDSA:
18020-
if ((ret = wc_Sha3_512Hash(buf, bufSz, digest)) == 0) {
18028+
if ((ret = wc_Sha3_512Hash_ex(buf, bufSz, digest, heap, devId))
18029+
== 0) {
1802118030
*typeH = SHA3_512h;
1802218031
*digestSz = WC_SHA3_512_DIGEST_SIZE;
1802318032
}
@@ -18026,7 +18035,7 @@ static int HashForSignature(const byte* buf, word32 bufSz, word32 sigOID,
1802618035
#endif
1802718036
#if defined(WOLFSSL_SM2) & defined(WOLFSSL_SM3)
1802818037
case CTC_SM3wSM2:
18029-
if ((ret = wc_Sm3Hash(buf, bufSz, digest)) == 0) {
18038+
if ((ret = wc_Sm3Hash_ex(buf, bufSz, digest, heap, devId)) == 0) {
1803018039
*typeH = SM3h;
1803118040
*digestSz = WC_SM3_DIGEST_SIZE;
1803218041
}
@@ -18236,7 +18245,8 @@ int ConfirmSignature(SignatureCtx* sigCtx,
1823618245
}
1823718246
/* Decode parameters. */
1823818247
ret = HashForSignature(buf, bufSz, fakeSigOID, sigCtx->digest,
18239-
&sigCtx->typeH, &sigCtx->digestSz, 1);
18248+
&sigCtx->typeH, &sigCtx->digestSz, 1, sigCtx->heap,
18249+
sigCtx->devId);
1824018250
if (ret != 0) {
1824118251
goto exit_cs;
1824218252
}
@@ -18251,7 +18261,8 @@ int ConfirmSignature(SignatureCtx* sigCtx,
1825118261
#endif
1825218262
{
1825318263
ret = HashForSignature(buf, bufSz, sigOID, sigCtx->digest,
18254-
&sigCtx->typeH, &sigCtx->digestSz, 1);
18264+
&sigCtx->typeH, &sigCtx->digestSz, 1,
18265+
sigCtx->heap, sigCtx->devId);
1825518266
if (ret != 0) {
1825618267
goto exit_cs;
1825718268
}
@@ -31931,7 +31942,8 @@ static int MakeSignature(CertSignCtx* certSignCtx, const byte* buf, word32 sz,
3193131942
#endif
3193231943

3193331944
ret = HashForSignature(buf, sz, sigAlgoType, certSignCtx->digest,
31934-
&typeH, &digestSz, 0);
31945+
&typeH, &digestSz, 0, NULL,
31946+
INVALID_DEVID);
3193531947
/* set next state, since WC_PENDING_E rentry for these are not "call again" */
3193631948
certSignCtx->state = CERTSIGN_STATE_ENCODE;
3193731949
if (ret != 0) {

0 commit comments

Comments
 (0)