mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 20:24:39 +02:00
Fix unit test coverity defect in test_wc_PKCS7_SetAESKeyWrapUnwrapCb()
This commit is contained in:
77
tests/api.c
77
tests/api.c
@@ -18229,41 +18229,46 @@ static int test_wc_PKCS7_SetAESKeyWrapUnwrapCb(void)
|
|||||||
WC_RNG rng;
|
WC_RNG rng;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Load test certs */
|
#ifdef ECC_TIMING_RESISTANT
|
||||||
#ifdef USE_CERT_BUFFERS_256
|
XMEMSET(&rng, 0, sizeof(WC_RNG));
|
||||||
ExpectNotNull(eccCert = (byte*)XMALLOC(TWOK_BUF, HEAP_HINT,
|
ExpectIntEQ(wc_InitRng(&rng), 0);
|
||||||
DYNAMIC_TYPE_TMP_BUFFER));
|
#endif
|
||||||
/* Init buffer. */
|
|
||||||
eccCertSz = (word32)sizeof_cliecc_cert_der_256;
|
/* Load test certs */
|
||||||
if (eccCert != NULL) {
|
#ifdef USE_CERT_BUFFERS_256
|
||||||
XMEMCPY(eccCert, cliecc_cert_der_256, eccCertSz);
|
ExpectNotNull(eccCert = (byte*)XMALLOC(TWOK_BUF, HEAP_HINT,
|
||||||
}
|
DYNAMIC_TYPE_TMP_BUFFER));
|
||||||
ExpectNotNull(eccPrivKey = (byte*)XMALLOC(TWOK_BUF, HEAP_HINT,
|
/* Init buffer. */
|
||||||
DYNAMIC_TYPE_TMP_BUFFER));
|
eccCertSz = (word32)sizeof_cliecc_cert_der_256;
|
||||||
eccPrivKeySz = (word32)sizeof_ecc_clikey_der_256;
|
if (eccCert != NULL) {
|
||||||
if (eccPrivKey != NULL) {
|
XMEMCPY(eccCert, cliecc_cert_der_256, eccCertSz);
|
||||||
XMEMCPY(eccPrivKey, ecc_clikey_der_256, eccPrivKeySz);
|
}
|
||||||
}
|
ExpectNotNull(eccPrivKey = (byte*)XMALLOC(TWOK_BUF, HEAP_HINT,
|
||||||
#else /* File system. */
|
DYNAMIC_TYPE_TMP_BUFFER));
|
||||||
ExpectTrue((certFile = XFOPEN(eccClientCert, "rb")) != XBADFILE);
|
eccPrivKeySz = (word32)sizeof_ecc_clikey_der_256;
|
||||||
eccCertSz = (word32)FOURK_BUF;
|
if (eccPrivKey != NULL) {
|
||||||
ExpectNotNull(eccCert = (byte*)XMALLOC(FOURK_BUF, HEAP_HINT,
|
XMEMCPY(eccPrivKey, ecc_clikey_der_256, eccPrivKeySz);
|
||||||
DYNAMIC_TYPE_TMP_BUFFER));
|
}
|
||||||
ExpectTrue((eccCertSz = (word32)XFREAD(eccCert, 1, eccCertSz,
|
#else /* File system. */
|
||||||
certFile)) > 0);
|
ExpectTrue((certFile = XFOPEN(eccClientCert, "rb")) != XBADFILE);
|
||||||
if (certFile != XBADFILE) {
|
eccCertSz = (word32)FOURK_BUF;
|
||||||
XFCLOSE(certFile);
|
ExpectNotNull(eccCert = (byte*)XMALLOC(FOURK_BUF, HEAP_HINT,
|
||||||
}
|
DYNAMIC_TYPE_TMP_BUFFER));
|
||||||
ExpectTrue((keyFile = XFOPEN(eccClientKey, "rb")) != XBADFILE);
|
ExpectTrue((eccCertSz = (word32)XFREAD(eccCert, 1, eccCertSz,
|
||||||
eccPrivKeySz = (word32)FOURK_BUF;
|
certFile)) > 0);
|
||||||
ExpectNotNull(eccPrivKey = (byte*)XMALLOC(FOURK_BUF, HEAP_HINT,
|
if (certFile != XBADFILE) {
|
||||||
DYNAMIC_TYPE_TMP_BUFFER));
|
XFCLOSE(certFile);
|
||||||
ExpectTrue((eccPrivKeySz = (word32)XFREAD(eccPrivKey, 1, eccPrivKeySz,
|
}
|
||||||
keyFile)) > 0);
|
ExpectTrue((keyFile = XFOPEN(eccClientKey, "rb")) != XBADFILE);
|
||||||
if (keyFile != XBADFILE) {
|
eccPrivKeySz = (word32)FOURK_BUF;
|
||||||
XFCLOSE(keyFile);
|
ExpectNotNull(eccPrivKey = (byte*)XMALLOC(FOURK_BUF, HEAP_HINT,
|
||||||
}
|
DYNAMIC_TYPE_TMP_BUFFER));
|
||||||
#endif /* USE_CERT_BUFFERS_256 */
|
ExpectTrue((eccPrivKeySz = (word32)XFREAD(eccPrivKey, 1, eccPrivKeySz,
|
||||||
|
keyFile)) > 0);
|
||||||
|
if (keyFile != XBADFILE) {
|
||||||
|
XFCLOSE(keyFile);
|
||||||
|
}
|
||||||
|
#endif /* USE_CERT_BUFFERS_256 */
|
||||||
|
|
||||||
ExpectNotNull(pkcs7 = wc_PKCS7_New(HEAP_HINT, testDevId));
|
ExpectNotNull(pkcs7 = wc_PKCS7_New(HEAP_HINT, testDevId));
|
||||||
ExpectIntEQ(wc_PKCS7_InitWithCert(pkcs7, eccCert, eccCertSz), 0);
|
ExpectIntEQ(wc_PKCS7_InitWithCert(pkcs7, eccCert, eccCertSz), 0);
|
||||||
@@ -18279,8 +18284,6 @@ static int test_wc_PKCS7_SetAESKeyWrapUnwrapCb(void)
|
|||||||
pkcs7->singleCert = eccCert;
|
pkcs7->singleCert = eccCert;
|
||||||
pkcs7->singleCertSz = (word32)eccCertSz;
|
pkcs7->singleCertSz = (word32)eccCertSz;
|
||||||
#ifdef ECC_TIMING_RESISTANT
|
#ifdef ECC_TIMING_RESISTANT
|
||||||
XMEMSET(&rng, 0, sizeof(WC_RNG));
|
|
||||||
ExpectIntEQ(wc_InitRng(&rng), 0);
|
|
||||||
pkcs7->rng = &rng;
|
pkcs7->rng = &rng;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -16513,7 +16513,7 @@ static int ValidateGmtime(struct tm* inTime)
|
|||||||
#if !defined(NO_ASN_TIME) && !defined(USER_TIME) && \
|
#if !defined(NO_ASN_TIME) && !defined(USER_TIME) && \
|
||||||
!defined(TIME_OVERRIDES) && (defined(OPENSSL_EXTRA) || defined(HAVE_PKCS7))
|
!defined(TIME_OVERRIDES) && (defined(OPENSSL_EXTRA) || defined(HAVE_PKCS7))
|
||||||
/* Set current time string, either UTC or GeneralizedTime.
|
/* Set current time string, either UTC or GeneralizedTime.
|
||||||
* (void*) tm should be a pointer to time_t, output is placed in buf.
|
* (void*) currTime should be a pointer to time_t, output is placed in buf.
|
||||||
*
|
*
|
||||||
* Return time string length placed in buf on success, negative on error */
|
* Return time string length placed in buf on success, negative on error */
|
||||||
int GetAsnTimeString(void* currTime, byte* buf, word32 len)
|
int GetAsnTimeString(void* currTime, byte* buf, word32 len)
|
||||||
|
Reference in New Issue
Block a user