Skip to content

Commit ab09d0c

Browse files
committed
misc_fixes: cleanup for skoll review.
1 parent 7926d9d commit ab09d0c

6 files changed

Lines changed: 16 additions & 11 deletions

File tree

tests/api/test_dsa.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,8 @@ int test_wc_DsaExportKeyRaw(void)
547547
WC_RNG rng;
548548
byte xOut[MAX_DSA_PARAM_SIZE];
549549
byte yOut[MAX_DSA_PARAM_SIZE];
550-
word32 xOutSz, yOutSz;
550+
word32 xOutSz = sizeof(xOut);
551+
word32 yOutSz = sizeof(yOut);
551552

552553
XMEMSET(&key, 0, sizeof(key));
553554
XMEMSET(&rng, 0, sizeof(rng));
@@ -563,8 +564,6 @@ int test_wc_DsaExportKeyRaw(void)
563564
ExpectIntEQ(wc_MakeDsaKey(&rng, &key), 0);
564565

565566
/* try successful export */
566-
xOutSz = sizeof(xOut);
567-
yOutSz = sizeof(yOut);
568567
ExpectIntEQ(wc_DsaExportKeyRaw(&key, xOut, &xOutSz, yOut, &yOutSz), 0);
569568

570569
/* test bad args */

tests/api/test_hmac.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,13 @@ int test_wc_Md5HmacUpdate(void)
305305
b.inLen = XSTRLEN(b.input);
306306

307307
ExpectIntEQ(wc_HmacInit(&hmac, NULL, INVALID_DEVID), 0);
308-
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0))
308+
#if !defined(WOLFSSL_KCAPI_HMAC) && !defined(HAVE_SELFTEST) && \
309+
(!defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0))
309310
/* update before setkey results in err. */
310311
ExpectIntEQ(wc_HmacUpdate(&hmac, (byte*)b.input, (word32)b.inLen),
311312
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
312-
#endif /* !HAVE_SELFTEST && (!HAVE_FIPS || FIPS_VERSION3_GE(7,0,0)) */
313+
#endif /* !WOLFSSL_KCAPI_HMAC && !HAVE_SELFTEST && \
314+
(!HAVE_FIPS || FIPS_VERSION3_GE(7,0,0)) */
313315
ExpectIntEQ(wc_HmacSetKey(&hmac, WC_MD5, (byte*)keys,
314316
(word32)XSTRLEN(keys)), 0);
315317
ExpectIntEQ(wc_HmacUpdate(&hmac, (byte*)b.input, (word32)b.inLen), 0);

wolfcrypt/src/dsa.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -709,11 +709,6 @@ int wc_DsaExportKeyRaw(DsaKey* dsa, byte* x, word32* xSz, byte* y, word32* ySz)
709709
if (dsa == NULL || xSz == NULL || ySz == NULL)
710710
return BAD_FUNC_ARG;
711711

712-
/* check we have a key to export */
713-
if (mp_iszero(&dsa->x) || mp_iszero(&dsa->y)) {
714-
return BAD_FUNC_ARG;
715-
}
716-
717712
/* get required output buffer sizes */
718713
xLen = (word32)mp_unsigned_bin_size(&dsa->x);
719714
yLen = (word32)mp_unsigned_bin_size(&dsa->y);
@@ -728,6 +723,11 @@ int wc_DsaExportKeyRaw(DsaKey* dsa, byte* x, word32* xSz, byte* y, word32* ySz)
728723
if (x == NULL || y == NULL)
729724
return BAD_FUNC_ARG;
730725

726+
/* check we have a key to export */
727+
if (mp_iszero(&dsa->x) && mp_iszero(&dsa->y)) {
728+
return BAD_FUNC_ARG;
729+
}
730+
731731
/* export x */
732732
if (*xSz < xLen) {
733733
WOLFSSL_MSG("Output buffer for DSA private key (x) too small, "

wolfcrypt/src/evp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9848,9 +9848,10 @@ static int ECC_populate_EVP_PKEY(WOLFSSL_EVP_PKEY* pkey, WOLFSSL_EC_KEY *key)
98489848
pkey->pkey.ptr = (char*)derBuf;
98499849
if ((derSz = wc_EccPublicKeyToDer(ecc, derBuf, (word32)derSz,
98509850
1)) < 0) {
9851-
XFREE(derBuf, NULL, DYNAMIC_TYPE_OPENSSL);
9851+
XFREE(derBuf, pkey->heap, DYNAMIC_TYPE_OPENSSL);
98529852
derBuf = NULL;
98539853
pkey->pkey.ptr = NULL;
9854+
pkey->pkey_sz = 0;
98549855
}
98559856
}
98569857
}

wolfcrypt/src/hmac.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ static int HmacKeyCopyHash(byte macType, wc_HmacHash* src, wc_HmacHash* dst)
368368
#endif
369369

370370
default:
371+
ret = BAD_FUNC_ARG;
371372
break;
372373
}
373374

@@ -475,6 +476,7 @@ static int HmacKeyHashUpdate(byte macType, wc_HmacHash* hash, byte* pad)
475476
#endif
476477

477478
default:
479+
ret = BAD_FUNC_ARG;
478480
break;
479481
}
480482

wolfcrypt/src/pwdbased.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ int wc_PKCS12_PBKDF_ex(byte* output, const byte* passwd, int passLen,
777777
#endif
778778
}
779779

780+
ForceZero(B, WC_MAX_BLOCK_SIZE);
780781
WC_FREE_VAR_EX(B, heap, DYNAMIC_TYPE_TMP_BUFFER);
781782
ForceZero(buffer, totalLen);
782783
if (buffer != staticBuffer) {

0 commit comments

Comments
 (0)