Merge remote-tracking branch 'upstream/master' into gh7197

This commit is contained in:
Kareem
2025-12-23 14:43:57 -07:00
34 changed files with 7727 additions and 542 deletions
+24
View File
@@ -13402,10 +13402,34 @@ int wc_AesInit_Label(Aes* aes, const char* label, void* heap, int devId)
/* Free Aes resources */
void wc_AesFree(Aes* aes)
{
#if defined(WOLF_CRYPTO_CB) && defined(WOLF_CRYPTO_CB_FREE)
int ret = 0;
#endif
if (aes == NULL) {
return;
}
#if defined(WOLF_CRYPTO_CB) && defined(WOLF_CRYPTO_CB_FREE)
#ifndef WOLF_CRYPTO_CB_FIND
if (aes->devId != INVALID_DEVID)
#endif
{
ret = wc_CryptoCb_Free(aes->devId, WC_ALGO_TYPE_CIPHER,
WC_CIPHER_AES, (void*)aes);
/* If they want the standard free, they can call it themselves */
/* via their callback setting devId to INVALID_DEVID */
/* otherwise assume the callback handled it */
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
return;
/* fall-through when unavailable */
}
/* silence compiler warning */
(void)ret;
#endif /* WOLF_CRYPTO_CB && WOLF_CRYPTO_CB_FREE */
#ifdef WC_DEBUG_CIPHER_LIFECYCLE
(void)wc_debug_CipherLifecycleFree(&aes->CipherLifecycleTag, aes->heap, 1);
#endif
+31 -30
View File
@@ -104,6 +104,9 @@ ASN Options:
* DO NOT enable this unless required for interoperability.
* WOLFSSL_ASN_EXTRA: Make more ASN.1 APIs available regardless of internal
* usage.
* WOLFSSL_ALLOW_AKID_SKID_MATCH: By default cert issuer is found using hash
* of cert subject hash with signers subject hash. This option allows fallback
* to using AKID and SKID matching.
*/
#ifndef NO_RSA
@@ -21339,42 +21342,25 @@ static int DecodeAuthKeyIdInternal(const byte* input, word32 sz,
ret = DecodeAuthKeyId(input, sz, &extAuthKeyId, &extAuthKeyIdSz,
&extAuthKeyIdIssuer, &extAuthKeyIdIssuerSz, &extAuthKeyIdIssuerSN,
&extAuthKeyIdIssuerSNSz);
if (ret != 0)
return ret;
#ifndef WOLFSSL_ASN_TEMPLATE
if (extAuthKeyIdSz == 0)
{
if (ret != 0) {
cert->extAuthKeyIdSet = 0;
return 0;
return ret;
}
cert->extAuthKeyIdSz = extAuthKeyIdSz;
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
#ifdef WOLFSSL_AKID_NAME
cert->extRawAuthKeyIdSrc = input;
cert->extRawAuthKeyIdSz = sz;
#endif
cert->extAuthKeyIdSrc = extAuthKeyId;
#endif /* OPENSSL_EXTRA */
return GetHashId(extAuthKeyId, extAuthKeyIdSz, cert->extAuthKeyId,
HashIdAlg(cert->signatureOID));
#else
/* Each field is optional */
if (extAuthKeyIdSz > 0) {
#ifdef OPENSSL_EXTRA
cert->extAuthKeyIdSrc = extAuthKeyId;
cert->extAuthKeyIdSet = 1;
cert->extAuthKeyIdSz = extAuthKeyIdSz;
#endif /* OPENSSL_EXTRA */
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
cert->extAuthKeyIdSrc = extAuthKeyId;
#endif
/* Get the hash or hash of the hash if wrong size. */
ret = GetHashId(extAuthKeyId, (int)extAuthKeyIdSz, cert->extAuthKeyId,
HashIdAlg(cert->signatureOID));
}
#ifdef WOLFSSL_AKID_NAME
if (ret == 0 && extAuthKeyIdIssuerSz > 0) {
cert->extAuthKeyIdIssuer = extAuthKeyIdIssuer;
@@ -21386,15 +21372,15 @@ static int DecodeAuthKeyIdInternal(const byte* input, word32 sz,
}
#endif /* WOLFSSL_AKID_NAME */
if (ret == 0) {
#if defined(OPENSSL_EXTRA) && defined(WOLFSSL_AKID_NAME)
#if (defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)) && \
defined(WOLFSSL_AKID_NAME)
/* Store the raw authority key id. */
cert->extRawAuthKeyIdSrc = input;
cert->extRawAuthKeyIdSz = sz;
#endif /* OPENSSL_EXTRA */
#endif
}
return ret;
#endif /* WOLFSSL_ASN_TEMPLATE */
}
/* Decode subject key id extension.
@@ -25723,7 +25709,22 @@ int ParseCertRelative(DecodedCert* cert, int type, int verify, void* cm,
}
if (cert->ca != NULL && XMEMCMP(cert->issuerHash,
cert->ca->subjectNameHash, KEYID_SIZE) != 0) {
cert->ca = NULL;
#ifdef WOLFSSL_ALLOW_AKID_SKID_MATCH
/* if hash of cert subject does not match hash of issuer
* then try with AKID/SKID if available */
if (cert->extAuthKeyIdSet && cert->extAuthKeyIdSz > 0 &&
cert->extAuthKeyIdSz ==
(word32)sizeof(cert->ca->subjectKeyIdHash) &&
XMEMCMP(cert->extAuthKeyId, cert->ca->subjectKeyIdHash,
cert->extAuthKeyIdSz) == 0) {
WOLFSSL_MSG("Cert AKID matches CA SKID");
}
else
#endif
{
WOLFSSL_MSG("Cert subject hash does not match issuer hash");
cert->ca = NULL;
}
}
if (cert->ca == NULL) {
cert->ca = GetCAByName(cm, cert->issuerHash);
+14 -5
View File
@@ -202,6 +202,15 @@ int wc_curve25519_make_pub(int public_size, byte* pub, int private_size,
#endif /* !WOLFSSL_CURVE25519_BLINDING */
#endif /* FREESCALE_LTC_ECC */
/* If WOLFSSL_CURVE25519_BLINDING is defined, this check is run in
* wc_curve25519_make_pub_blind since it could be called directly. */
#if !defined(WOLFSSL_CURVE25519_BLINDING) || defined(FREESCALE_LTC_ECC)
if (ret == 0) {
ret = wc_curve25519_check_public(pub, (word32)public_size,
EC25519_LITTLE_ENDIAN);
}
#endif
return ret;
}
@@ -297,6 +306,11 @@ int wc_curve25519_make_pub_blind(int public_size, byte* pub, int private_size,
ret = curve25519_smul_blind(pub, priv, (byte*)kCurve25519BasePoint, rng);
#endif
if (ret == 0) {
ret = wc_curve25519_check_public(pub, (word32)public_size,
EC25519_LITTLE_ENDIAN);
}
return ret;
}
#endif
@@ -463,11 +477,6 @@ int wc_curve25519_make_key(WC_RNG* rng, int keysize, curve25519_key* key)
ret = wc_curve25519_make_pub((int)sizeof(key->p.point), key->p.point,
(int)sizeof(key->k), key->k);
#endif
if (ret == 0) {
ret = wc_curve25519_check_public(key->p.point,
(word32)sizeof(key->p.point),
EC25519_LITTLE_ENDIAN);
}
key->pubSet = (ret == 0);
}
#endif
+6 -1
View File
@@ -1127,6 +1127,9 @@ int wc_ed25519_export_public(const ed25519_key* key, byte* out, word32* outLen)
return BUFFER_E;
}
if (!key->pubKeySet)
return PUBLIC_KEY_E;
*outLen = ED25519_PUB_KEY_SIZE;
XMEMCPY(out, key->p, ED25519_PUB_KEY_SIZE);
@@ -1368,7 +1371,7 @@ int wc_ed25519_export_private_only(const ed25519_key* key, byte* out, word32* ou
int wc_ed25519_export_private(const ed25519_key* key, byte* out, word32* outLen)
{
/* sanity checks on arguments */
if (key == NULL || out == NULL || outLen == NULL)
if (key == NULL || !key->privKeySet || out == NULL || outLen == NULL)
return BAD_FUNC_ARG;
if (*outLen < ED25519_PRV_KEY_SIZE) {
@@ -1398,6 +1401,8 @@ int wc_ed25519_export_key(const ed25519_key* key,
/* export public part */
ret = wc_ed25519_export_public(key, pub, pubSz);
if (ret == WC_NO_ERR_TRACE(PUBLIC_KEY_E))
ret = 0; /* ignore no public key */
return ret;
}
+21 -3
View File
@@ -5455,7 +5455,6 @@ static int PKCS7_VerifySignedData(wc_PKCS7* pkcs7, const byte* hashBuf,
if (ret == 0 && GetMyVersion(pkiMsg, &idx, &version, pkiMsgSz) < 0)
ret = ASN_PARSE_E;
/* version 1 follows RFC 2315 */
/* version 3 follows RFC 4108 */
if (ret == 0 && (version != 1 && version != 3)) {
@@ -5673,6 +5672,15 @@ static int PKCS7_VerifySignedData(wc_PKCS7* pkcs7, const byte* hashBuf,
* this as start of content. */
localIdx = start;
pkcs7->contentIsPkcs7Type = 1;
#ifndef NO_PKCS7_STREAM
/* Set streaming variables for PKCS#7 type content.
* length contains the size from [0] EXPLICIT wrapper */
pkcs7->stream->multi = 0;
pkcs7->stream->currContIdx = localIdx;
pkcs7->stream->currContSz = (word32)length;
pkcs7->stream->currContRmnSz = (word32)length;
#endif
}
else {
/* CMS eContent OCTET_STRING */
@@ -5762,7 +5770,6 @@ static int PKCS7_VerifySignedData(wc_PKCS7* pkcs7, const byte* hashBuf,
idx = localIdx;
}
else {
/* If either pkcs7->content and pkcs7->contentSz are set
* (detached signature where user has set content explicitly
* into pkcs7->content/contentSz) OR pkcs7->hashBuf and
@@ -5862,7 +5869,7 @@ static int PKCS7_VerifySignedData(wc_PKCS7* pkcs7, const byte* hashBuf,
/* copy content to pkcs7->contentDynamic */
if (keepContent && pkcs7->stream->content &&
pkcs7->stream->contentSz >0) {
pkcs7->stream->contentSz > 0) {
pkcs7->contentDynamic = (byte*)XMALLOC(pkcs7->stream->contentSz,
pkcs7->heap, DYNAMIC_TYPE_PKCS7);
if (pkcs7->contentDynamic == NULL) {
@@ -6412,6 +6419,17 @@ static int PKCS7_VerifySignedData(wc_PKCS7* pkcs7, const byte* hashBuf,
NO_USER_CHECK) < 0)
ret = ASN_PARSE_E;
/* Update degenerate flag based on if signerInfos SET is empty.
* The earlier degenerate check at digestAlgorithms is an early
* optimization, but depending on degenerate case may not be
* detected until here. */
if (ret == 0) {
degenerate = (length == 0) ? 1 : 0;
#ifndef NO_PKCS7_STREAM
pkcs7->stream->degenerate = (degenerate != 0);
#endif
}
if (ret != 0)
break;
#ifndef NO_PKCS7_STREAM
+6
View File
@@ -759,6 +759,9 @@ static Error caamAes(struct DescStruct* desc)
ctx[ctxIdx] = buf;
sz += buf->dataSz;
if (ctx[ctxIdx]->dataSz + offset > (MAX_CTX * sizeof(UINT4))) {
return SizeIsTooLarge;
}
memcpy((unsigned char*)&local[offset],
(unsigned char*)ctx[ctxIdx]->data, ctx[ctxIdx]->dataSz);
offset += ctx[ctxIdx]->dataSz;
@@ -958,6 +961,9 @@ static Error caamAead(struct DescStruct* desc)
ctx[ctxIdx] = buf;
sz += buf->dataSz;
if (ctx[ctxIdx]->dataSz + offset > (MAX_CTX * sizeof(UINT4))) {
return SizeIsTooLarge;
}
memcpy((unsigned char*)&local[offset],
(unsigned char*)ctx[ctxIdx]->data, ctx[ctxIdx]->dataSz);
offset += ctx[ctxIdx]->dataSz;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-5
View File
@@ -813,7 +813,6 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz,
#ifdef HAVE_HASHDRBG
word32 seedSz = SEED_SZ + SEED_BLOCK_SZ;
WC_DECLARE_VAR(seed, byte, MAX_SEED_SZ, rng->heap);
int drbg_instantiated = 0;
#ifdef WOLFSSL_SMALL_STACK_CACHE
int drbg_scratch_instantiated = 0;
#endif
@@ -1025,8 +1024,6 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz,
ret = Hash_DRBG_Instantiate((DRBG_internal *)rng->drbg,
seed + SEED_BLOCK_SZ, seedSz - SEED_BLOCK_SZ,
nonce, nonceSz, rng->heap, devId);
if (ret == 0)
drbg_instantiated = 1;
} /* ret == 0 */
#ifdef WOLFSSL_SMALL_STACK
@@ -1038,8 +1035,6 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz,
WC_FREE_VAR_EX(seed, rng->heap, DYNAMIC_TYPE_SEED);
if (ret != DRBG_SUCCESS) {
if (drbg_instantiated)
(void)Hash_DRBG_Uninstantiate((DRBG_internal *)rng->drbg);
#if !defined(WOLFSSL_NO_MALLOC) || defined(WOLFSSL_STATIC_MEMORY)
XFREE(rng->drbg, rng->heap, DYNAMIC_TYPE_RNG);
#endif
+1
View File
@@ -913,6 +913,7 @@ int wc_LmsKey_Reload(LmsKey* key)
/* Reload the key ready for signing. */
ret = wc_hss_reload_key(state, key->priv_raw, &key->priv,
key->priv_data, NULL);
wc_lmskey_state_free(state);
}
ForceZero(state, sizeof(LmsState));
WC_FREE_VAR_EX(state, NULL, DYNAMIC_TYPE_TMP_BUFFER);
+2 -1
View File
@@ -2764,7 +2764,8 @@ static int Pkcs11ECDH(Pkcs11Session* session, wc_CryptoInfo* info)
if (ret == 0) {
secSz = *info->pk.ecdh.outlen;
if (secSz > (CK_ULONG)info->pk.ecdh.private_key->dp->size)
if (info->pk.ecdh.private_key->dp != NULL &&
secSz > (CK_ULONG)info->pk.ecdh.private_key->dp->size)
secSz = info->pk.ecdh.private_key->dp->size;
params.kdf = CKD_NULL;
+33 -1
View File
@@ -58,7 +58,7 @@ data, use this implementation to seed and re-seed the DRBG.
#define MAX_NOISE_CNT (MAX_ENTROPY_BITS * 8 + ENTROPY_EXTRA)
/* MemUse entropy global state initialized. */
static int entropy_memuse_initialized = 0;
static volatile int entropy_memuse_initialized = 0;
/* Global SHA-3 object used for conditioning entropy and creating noise. */
static wc_Sha3 entropyHash;
/* Reset the health tests. */
@@ -740,6 +740,21 @@ int wc_Entropy_Get(int bits, unsigned char* entropy, word32 len)
int noise_len = (bits + ENTROPY_EXTRA) / ENTROPY_MIN;
static byte noise[MAX_NOISE_CNT];
#ifdef HAVE_FIPS
/* FIPS KATs, e.g. EccPrimitiveZ_KnownAnswerTest(), call wc_Entropy_Get()
* incidental to wc_InitRng(), without first calling Entropy_Init(), neither
* directly, nor indirectly via wolfCrypt_Init(). This matters, because
* KATs must be usable before wolfCrypt_Init() (indeed, in the library
* embodiment, the HMAC KAT always runs before wolfCrypt_Init(), incidental
* to fipsEntry()). Without the InitSha3() under Entropy_Init(), the
* SHA3_BLOCK function pointer is null when Sha3Update() is called by
* Entropy_MemUse(), which ends badly.
*/
if (!entropy_memuse_initialized) {
ret = Entropy_Init();
}
#endif
/* Lock the mutex as collection uses globals. */
if ((ret == 0) && (wc_LockMutex(&entropy_mutex) != 0)) {
ret = BAD_MUTEX_E;
@@ -851,6 +866,19 @@ int Entropy_Init(void)
#if !defined(SINGLE_THREADED) && !defined(WOLFSSL_MUTEX_INITIALIZER)
ret = wc_InitMutex(&entropy_mutex);
#endif
if (ret == 0)
ret = wc_LockMutex(&entropy_mutex);
if (entropy_memuse_initialized) {
/* Short circuit return -- a competing thread initialized the state
* while we were waiting. Note, this is only threadsafe when
* WOLFSSL_MUTEX_INITIALIZER is defined.
*/
if (ret == 0)
wc_UnLockMutex(&entropy_mutex);
return 0;
}
if (ret == 0) {
/* Initialize a SHA3-256 object for use in entropy operations. */
ret = wc_InitSha3_256(&entropyHash, NULL, INVALID_DEVID);
@@ -872,6 +900,10 @@ int Entropy_Init(void)
Entropy_StopThread();
#endif
}
if (ret != WC_NO_ERR_TRACE(BAD_MUTEX_E)) {
wc_UnLockMutex(&entropy_mutex);
}
}
return ret;
+174 -98
View File
@@ -7402,7 +7402,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_md5_test(void)
testVector a, b, c, d;
testVector test_hmac[4];
wc_test_ret_t ret;
wc_test_ret_t ret = WC_TEST_RET_ENC_NC;
int times = sizeof(test_hmac) / sizeof(testVector), i;
WOLFSSL_ENTER("hmac_md5_test");
@@ -7440,6 +7440,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_md5_test(void)
test_hmac[2] = c;
test_hmac[3] = d;
XMEMSET(&hmac, 0, sizeof(hmac));
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
WC_ALLOC_VAR_EX(hmac_copy, Hmac, 1, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER,
return WC_TEST_RET_ENC_EC(MEMORY_E));
@@ -7454,29 +7455,29 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_md5_test(void)
ret = wc_HmacInit(&hmac, HEAP_HINT, devId);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
ret = wc_HmacSetKey(&hmac, WC_MD5, (byte*)keys[i],
(word32)XSTRLEN(keys[i]));
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
ret = wc_HmacCopy(&hmac, hmac_copy);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#endif
ret = wc_HmacUpdate(&hmac, (byte*)test_hmac[i].input,
(word32)test_hmac[i].inLen);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
ret = wc_HmacFinal(&hmac, hash);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
if (XMEMCMP(hash, test_hmac[i].output, WC_MD5_DIGEST_SIZE) != 0)
return WC_TEST_RET_ENC_I(i);
ERROR_OUT(WC_TEST_RET_ENC_I(i), out);
wc_HmacFree(&hmac);
@@ -7484,28 +7485,35 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_md5_test(void)
ret = wc_HmacUpdate(hmac_copy, (byte*)test_hmac[i].input,
(word32)test_hmac[i].inLen);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
ret = wc_HmacFinal(hmac_copy, hash);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
if (XMEMCMP(hash, test_hmac[i].output, WC_MD5_DIGEST_SIZE) != 0)
return WC_TEST_RET_ENC_I(i);
ERROR_OUT(WC_TEST_RET_ENC_I(i), out);
wc_HmacFree(hmac_copy);
#endif
}
out:
wc_HmacFree(&hmac);
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
wc_HmacFree(hmac_copy);
WC_FREE_VAR_EX(hmac_copy, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
#endif
#if !defined(HAVE_FIPS) || FIPS_VERSION3_GE(6,0,0)
if ((ret = wc_HmacSizeByType(WC_MD5)) != WC_MD5_DIGEST_SIZE)
return WC_TEST_RET_ENC_EC(ret);
if (ret == 0) {
if ((ret = wc_HmacSizeByType(WC_MD5)) != WC_MD5_DIGEST_SIZE)
return WC_TEST_RET_ENC_EC(ret);
ret = 0;
}
#endif
return 0;
return ret;
}
#endif /* !NO_HMAC && !NO_MD5 && (!HAVE_FIPS || (HAVE_FIPS_VERSION < 5)) */
@@ -7535,7 +7543,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha_test(void)
testVector a, b, c, d;
testVector test_hmac[4];
wc_test_ret_t ret;
wc_test_ret_t ret = WC_TEST_RET_ENC_NC;
int times = sizeof(test_hmac) / sizeof(testVector), i;
#if FIPS_VERSION3_GE(6,0,0)
@@ -7577,6 +7585,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha_test(void)
test_hmac[2] = c;
test_hmac[3] = d;
XMEMSET(&hmac, 0, sizeof(hmac));
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
WC_ALLOC_VAR_EX(hmac_copy, Hmac, 1, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER,
return WC_TEST_RET_ENC_EC(MEMORY_E));
@@ -7589,38 +7598,38 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha_test(void)
#endif
if ((ret = wc_HmacInit(&hmac, HEAP_HINT, devId)) != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
ret = wc_HmacSetKey(&hmac, WC_SHA, (byte*)keys[i],
(word32)XSTRLEN(keys[i]));
#if FIPS_VERSION3_GE(6,0,0)
if (i == 1) {
if (ret != WC_NO_ERR_TRACE(HMAC_MIN_KEYLEN_E))
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
/* Now use the ex and allow short keys with FIPS option */
ret = wc_HmacSetKey_ex(&hmac, WC_SHA, (byte*) keys[i],
(word32)XSTRLEN(keys[i]), allowShortKeyWithFips);
}
#endif
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
ret = wc_HmacCopy(&hmac, hmac_copy);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#endif
ret = wc_HmacUpdate(&hmac, (byte*)test_hmac[i].input,
(word32)test_hmac[i].inLen);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
ret = wc_HmacFinal(&hmac, hash);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
if (XMEMCMP(hash, test_hmac[i].output, WC_SHA_DIGEST_SIZE) != 0)
return WC_TEST_RET_ENC_I(i);
ERROR_OUT(WC_TEST_RET_ENC_I(i), out);
wc_HmacFree(&hmac);
@@ -7628,28 +7637,35 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha_test(void)
ret = wc_HmacUpdate(hmac_copy, (byte*)test_hmac[i].input,
(word32)test_hmac[i].inLen);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
ret = wc_HmacFinal(hmac_copy, hash);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
if (XMEMCMP(hash, test_hmac[i].output, WC_SHA_DIGEST_SIZE) != 0)
return WC_TEST_RET_ENC_I(i);
ERROR_OUT(WC_TEST_RET_ENC_I(i), out);
wc_HmacFree(hmac_copy);
#endif
}
out:
wc_HmacFree(&hmac);
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
wc_HmacFree(hmac_copy);
WC_FREE_VAR_EX(hmac_copy, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
#endif
#if !defined(HAVE_FIPS) || FIPS_VERSION3_GE(6,0,0)
if ((ret = wc_HmacSizeByType(WC_SHA)) != WC_SHA_DIGEST_SIZE)
return WC_TEST_RET_ENC_EC(ret);
if (ret == 0) {
if ((ret = wc_HmacSizeByType(WC_SHA)) != WC_SHA_DIGEST_SIZE)
return WC_TEST_RET_ENC_EC(ret);
ret = 0;
}
#endif
return 0;
return ret;
}
#endif
@@ -7684,7 +7700,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha224_test(void)
testVector a, b, c, d;
testVector test_hmac[4];
wc_test_ret_t ret;
wc_test_ret_t ret = WC_TEST_RET_ENC_NC;
int times = sizeof(test_hmac) / sizeof(testVector), i;
WOLFSSL_ENTER("hmac_sha224_test");
@@ -7720,6 +7736,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha224_test(void)
test_hmac[2] = c;
test_hmac[3] = d;
XMEMSET(&hmac, 0, sizeof(hmac));
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
WC_ALLOC_VAR_EX(hmac_copy, Hmac, 1, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER,
return WC_TEST_RET_ENC_EC(MEMORY_E));
@@ -7732,29 +7749,29 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha224_test(void)
#endif
if ((ret = wc_HmacInit(&hmac, HEAP_HINT, devId)) != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
ret = wc_HmacSetKey(&hmac, WC_SHA224, (byte*)keys[i],
(word32)XSTRLEN(keys[i]));
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
ret = wc_HmacCopy(&hmac, hmac_copy);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#endif
ret = wc_HmacUpdate(&hmac, (byte*)test_hmac[i].input,
(word32)test_hmac[i].inLen);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
ret = wc_HmacFinal(&hmac, hash);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
if (XMEMCMP(hash, test_hmac[i].output, WC_SHA224_DIGEST_SIZE) != 0)
return WC_TEST_RET_ENC_I(i);
ERROR_OUT(WC_TEST_RET_ENC_I(i), out);
wc_HmacFree(&hmac);
@@ -7762,28 +7779,35 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha224_test(void)
ret = wc_HmacUpdate(hmac_copy, (byte*)test_hmac[i].input,
(word32)test_hmac[i].inLen);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
ret = wc_HmacFinal(hmac_copy, hash);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
if (XMEMCMP(hash, test_hmac[i].output, WC_SHA224_DIGEST_SIZE) != 0)
return WC_TEST_RET_ENC_I(i);
ERROR_OUT(WC_TEST_RET_ENC_I(i), out);
wc_HmacFree(hmac_copy);
#endif
}
out:
wc_HmacFree(&hmac);
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
wc_HmacFree(hmac_copy);
WC_FREE_VAR_EX(hmac_copy, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
#endif
#if !defined(HAVE_FIPS) || FIPS_VERSION3_GE(6,0,0)
if ((ret = wc_HmacSizeByType(WC_SHA224)) != WC_SHA224_DIGEST_SIZE)
return WC_TEST_RET_ENC_EC(ret);
if (ret == 0) {
if ((ret = wc_HmacSizeByType(WC_SHA224)) != WC_SHA224_DIGEST_SIZE)
return WC_TEST_RET_ENC_EC(ret);
ret = 0;
}
#endif
return 0;
return ret;
}
#endif
@@ -7820,7 +7844,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha256_test(void)
testVector a, b, c, d, e;
testVector test_hmac[5];
wc_test_ret_t ret;
wc_test_ret_t ret = WC_TEST_RET_ENC_NC;
int times = sizeof(test_hmac) / sizeof(testVector), i;
WOLFSSL_ENTER("hmac_sha256_test");
@@ -7869,6 +7893,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha256_test(void)
test_hmac[3] = d;
test_hmac[4] = e;
XMEMSET(&hmac, 0, sizeof(hmac));
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
WC_ALLOC_VAR_EX(hmac_copy, Hmac, 1, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER,
return WC_TEST_RET_ENC_EC(MEMORY_E));
@@ -7885,31 +7910,31 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha256_test(void)
#endif
if (wc_HmacInit(&hmac, HEAP_HINT, devId) != 0)
return WC_TEST_RET_ENC_I(i);
ERROR_OUT(WC_TEST_RET_ENC_I(i), out);
ret = wc_HmacSetKey(&hmac, WC_SHA256, (byte*)keys[i],
(word32)XSTRLEN(keys[i]));
if (ret != 0)
return WC_TEST_RET_ENC_I(i);
ERROR_OUT(WC_TEST_RET_ENC_I(i), out);
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
ret = wc_HmacCopy(&hmac, hmac_copy);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#endif
if (test_hmac[i].input != NULL) {
ret = wc_HmacUpdate(&hmac, (byte*)test_hmac[i].input,
(word32)test_hmac[i].inLen);
if (ret != 0)
return WC_TEST_RET_ENC_I(i);
ERROR_OUT(WC_TEST_RET_ENC_I(i), out);
}
ret = wc_HmacFinal(&hmac, hash);
if (ret != 0)
return WC_TEST_RET_ENC_I(i);
ERROR_OUT(WC_TEST_RET_ENC_I(i), out);
if (XMEMCMP(hash, test_hmac[i].output, WC_SHA256_DIGEST_SIZE) != 0)
return WC_TEST_RET_ENC_I(i);
ERROR_OUT(WC_TEST_RET_ENC_I(i), out);
wc_HmacFree(&hmac);
@@ -7918,20 +7943,24 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha256_test(void)
ret = wc_HmacUpdate(hmac_copy, (byte*)test_hmac[i].input,
(word32)test_hmac[i].inLen);
if (ret != 0)
return WC_TEST_RET_ENC_I(i);
ERROR_OUT(WC_TEST_RET_ENC_I(i), out);
}
ret = wc_HmacFinal(hmac_copy, hash);
if (ret != 0)
return WC_TEST_RET_ENC_I(i);
ERROR_OUT(WC_TEST_RET_ENC_I(i), out);
if (XMEMCMP(hash, test_hmac[i].output, WC_SHA256_DIGEST_SIZE) != 0)
return WC_TEST_RET_ENC_I(i);
ERROR_OUT(WC_TEST_RET_ENC_I(i), out);
wc_HmacFree(hmac_copy);
#endif
}
out:
wc_HmacFree(&hmac);
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
wc_HmacFree(hmac_copy);
WC_FREE_VAR_EX(hmac_copy, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
#endif
@@ -7985,7 +8014,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha384_test(void)
testVector a, b, c, d;
testVector test_hmac[4];
wc_test_ret_t ret;
wc_test_ret_t ret = WC_TEST_RET_ENC_NC;
int times = sizeof(test_hmac) / sizeof(testVector), i;
WOLFSSL_ENTER("hmac_sha384_test");
@@ -8030,6 +8059,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha384_test(void)
test_hmac[2] = c;
test_hmac[3] = d;
XMEMSET(&hmac, 0, sizeof(hmac));
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
WC_ALLOC_VAR_EX(hmac_copy, Hmac, 1, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER,
return WC_TEST_RET_ENC_EC(MEMORY_E));
@@ -8042,29 +8072,29 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha384_test(void)
#endif
if ((ret = wc_HmacInit(&hmac, HEAP_HINT, devId)) != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
ret = wc_HmacSetKey(&hmac, WC_SHA384, (byte*)keys[i],
(word32)XSTRLEN(keys[i]));
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
ret = wc_HmacCopy(&hmac, hmac_copy);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#endif
ret = wc_HmacUpdate(&hmac, (byte*)test_hmac[i].input,
(word32)test_hmac[i].inLen);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
ret = wc_HmacFinal(&hmac, hash);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
if (XMEMCMP(hash, test_hmac[i].output, WC_SHA384_DIGEST_SIZE) != 0)
return WC_TEST_RET_ENC_I(i);
ERROR_OUT(WC_TEST_RET_ENC_I(i), out);
wc_HmacFree(&hmac);
@@ -8072,28 +8102,35 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha384_test(void)
ret = wc_HmacUpdate(hmac_copy, (byte*)test_hmac[i].input,
(word32)test_hmac[i].inLen);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
ret = wc_HmacFinal(hmac_copy, hash);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
if (XMEMCMP(hash, test_hmac[i].output, WC_SHA384_DIGEST_SIZE) != 0)
return WC_TEST_RET_ENC_I(i);
ERROR_OUT(WC_TEST_RET_ENC_I(i), out);
wc_HmacFree(hmac_copy);
#endif
}
out:
wc_HmacFree(&hmac);
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
wc_HmacFree(hmac_copy);
WC_FREE_VAR_EX(hmac_copy, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
#endif
#if !defined(HAVE_FIPS) || FIPS_VERSION3_GE(6,0,0)
if ((ret = wc_HmacSizeByType(WC_SHA384)) != WC_SHA384_DIGEST_SIZE)
return WC_TEST_RET_ENC_EC(ret);
if (ret == 0) {
if ((ret = wc_HmacSizeByType(WC_SHA384)) != WC_SHA384_DIGEST_SIZE)
return WC_TEST_RET_ENC_EC(ret);
ret = 0;
}
#endif
return 0;
return ret;
}
#endif
@@ -8128,7 +8165,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha512_test(void)
testVector a, b, c, d;
testVector test_hmac[4];
wc_test_ret_t ret;
wc_test_ret_t ret = WC_TEST_RET_ENC_NC;
int times = sizeof(test_hmac) / sizeof(testVector), i;
WOLFSSL_ENTER("hmac_sha512_test");
@@ -8177,6 +8214,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha512_test(void)
test_hmac[2] = c;
test_hmac[3] = d;
XMEMSET(&hmac, 0, sizeof(hmac));
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
WC_ALLOC_VAR_EX(hmac_copy, Hmac, 1, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER,
return WC_TEST_RET_ENC_EC(MEMORY_E));
@@ -8189,29 +8227,29 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha512_test(void)
#endif
if ((ret = wc_HmacInit(&hmac, HEAP_HINT, devId)) != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
ret = wc_HmacSetKey(&hmac, WC_SHA512, (byte*)keys[i],
(word32)XSTRLEN(keys[i]));
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
ret = wc_HmacCopy(&hmac, hmac_copy);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#endif
ret = wc_HmacUpdate(&hmac, (byte*)test_hmac[i].input,
(word32)test_hmac[i].inLen);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
ret = wc_HmacFinal(&hmac, hash);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
if (XMEMCMP(hash, test_hmac[i].output, WC_SHA512_DIGEST_SIZE) != 0)
return WC_TEST_RET_ENC_I(i);
ERROR_OUT(WC_TEST_RET_ENC_I(i), out);
wc_HmacFree(&hmac);
@@ -8219,28 +8257,35 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha512_test(void)
ret = wc_HmacUpdate(hmac_copy, (byte*)test_hmac[i].input,
(word32)test_hmac[i].inLen);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
ret = wc_HmacFinal(hmac_copy, hash);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
if (XMEMCMP(hash, test_hmac[i].output, WC_SHA512_DIGEST_SIZE) != 0)
return WC_TEST_RET_ENC_I(i);
ERROR_OUT(WC_TEST_RET_ENC_I(i), out);
wc_HmacFree(hmac_copy);
#endif
}
out:
wc_HmacFree(&hmac);
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
wc_HmacFree(hmac_copy);
WC_FREE_VAR_EX(hmac_copy, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
#endif
#if !defined(HAVE_FIPS) || FIPS_VERSION3_GE(6,0,0)
if ((ret = wc_HmacSizeByType(WC_SHA512)) != WC_SHA512_DIGEST_SIZE)
return WC_TEST_RET_ENC_EC(ret);
if (ret == 0) {
if ((ret = wc_HmacSizeByType(WC_SHA512)) != WC_SHA512_DIGEST_SIZE)
return WC_TEST_RET_ENC_EC(ret);
ret = 0;
}
#endif
return 0;
return ret;
}
#endif
@@ -8378,9 +8423,10 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha3_test(void)
int i = 0, iMax = sizeof(input) / sizeof(input[0]),
j, jMax = sizeof(hashType) / sizeof(hashType[0]);
int ret;
wc_test_ret_t ret = WC_TEST_RET_ENC_NC;
WOLFSSL_ENTER("hmac_sha3_test");
XMEMSET(&hmac, 0, sizeof(hmac));
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
WC_ALLOC_VAR_EX(hmac_copy, Hmac, 1, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER,
return WC_TEST_RET_ENC_EC(MEMORY_E));
@@ -8394,28 +8440,28 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha3_test(void)
for (; i < iMax; i++) {
for (j = 0; j < jMax; j++) {
if ((ret = wc_HmacInit(&hmac, HEAP_HINT, devId)) != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
ret = wc_HmacSetKey(&hmac, hashType[j], (byte*)key[i],
(word32)XSTRLEN(key[i]));
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
ret = wc_HmacCopy(&hmac, hmac_copy);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#endif
ret = wc_HmacUpdate(&hmac, (byte*)input[i],
(word32)XSTRLEN(input[i]));
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
ret = wc_HmacFinal(&hmac, hash);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
if (XMEMCMP(hash, output[(i*jMax) + j], (size_t)hashSz[j]) != 0)
return WC_TEST_RET_ENC_NC;
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
wc_HmacFree(&hmac);
@@ -8423,12 +8469,12 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha3_test(void)
ret = wc_HmacUpdate(hmac_copy, (byte*)input[i],
(word32)XSTRLEN(input[i]));
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
ret = wc_HmacFinal(hmac_copy, hash);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
if (XMEMCMP(hash, output[(i*jMax) + j], (size_t)hashSz[j]) != 0)
return WC_TEST_RET_ENC_NC;
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
wc_HmacFree(hmac_copy);
#endif
@@ -8439,16 +8485,20 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hmac_sha3_test(void)
#if !defined(HAVE_FIPS) || FIPS_VERSION3_GE(6,0,0)
ret = wc_HmacSizeByType(hashType[j]);
if (ret != hashSz[j])
return WC_TEST_RET_ENC_EC(ret);
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
#endif
}
}
out:
wc_HmacFree(&hmac);
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GT(7,0,0))
wc_HmacFree(hmac_copy);
WC_FREE_VAR_EX(hmac_copy, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
#endif
return 0;
return ret;
}
#endif
@@ -19698,14 +19748,23 @@ static wc_test_ret_t _rng_test(WC_RNG* rng)
!defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GE(5,0,0))
/* Test periodic reseed dynamics. */
((struct DRBG_internal *)rng->drbg)->reseedCtr = WC_RESEED_INTERVAL;
#ifdef WOLF_CRYPTO_CB
if (wc_CryptoCb_RandomBlock(rng, block, sizeof(block)) ==
WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
{
#endif
((struct DRBG_internal *)rng->drbg)->reseedCtr = WC_RESEED_INTERVAL;
ret = wc_RNG_GenerateBlock(rng, block, sizeof(block));
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ret = wc_RNG_GenerateBlock(rng, block, sizeof(block));
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
if (((struct DRBG_internal *)rng->drbg)->reseedCtr == WC_RESEED_INTERVAL)
return WC_TEST_RET_ENC_NC;
#ifdef WOLF_CRYPTO_CB
}
#endif
if (((struct DRBG_internal *)rng->drbg)->reseedCtr == WC_RESEED_INTERVAL)
return WC_TEST_RET_ENC_NC;
#endif /* HAVE_HASHDRBG && !CUSTOM_RAND_GENERATE_BLOCK && !HAVE_SELFTEST */
#if defined(WOLFSSL_TRACK_MEMORY) && defined(WOLFSSL_SMALL_STACK_CACHE)
@@ -19820,7 +19879,7 @@ static wc_test_ret_t rng_seed_test(void)
* SEED_BLOCK_SZ, which depend on which seed back end is configured.
*/
#if defined(HAVE_ENTROPY_MEMUSE) && defined(HAVE_AMD_RDSEED) && \
!(defined(HAVE_FIPS) && FIPS_VERSION_LT(6,0))
!(defined(HAVE_FIPS) && FIPS_VERSION3_LT(6,0,0) && FIPS_VERSION3_NE(5,2,4))
#ifdef HAVE_FIPS
WOLFSSL_SMALL_STACK_STATIC const byte check[] =
{
@@ -19858,7 +19917,7 @@ static wc_test_ret_t rng_seed_test(void)
};
#endif
#elif defined(HAVE_AMD_RDSEED) && \
!(defined(HAVE_FIPS) && FIPS_VERSION_LT(6,0))
!(defined(HAVE_FIPS) && FIPS_VERSION3_LT(6,0,0) && FIPS_VERSION3_NE(5,2,4))
WOLFSSL_SMALL_STACK_STATIC const byte check[] =
{
0x2c, 0xd4, 0x9b, 0x1e, 0x1e, 0xe7, 0xb0, 0xb0,
@@ -19867,7 +19926,7 @@ static wc_test_ret_t rng_seed_test(void)
0xa2, 0xe7, 0xe5, 0x90, 0x6d, 0x1f, 0x88, 0x98
};
#elif (defined(HAVE_INTEL_RDSEED) || defined(HAVE_INTEL_RDRAND)) && \
!(defined(HAVE_FIPS) && FIPS_VERSION_LT(6,0))
!(defined(HAVE_FIPS) && FIPS_VERSION3_LT(6,0,0) && FIPS_VERSION3_NE(5,2,4))
#ifdef HAVE_FIPS
WOLFSSL_SMALL_STACK_STATIC const byte check[] =
{
@@ -19886,7 +19945,7 @@ static wc_test_ret_t rng_seed_test(void)
};
#endif
#elif defined(HAVE_INTEL_RDSEED) && \
defined(HAVE_FIPS) && FIPS_VERSION_LT(6,0)
defined(HAVE_FIPS) && FIPS_VERSION3_LT(6,0,0) && FIPS_VERSION3_NE(5,2,4)
WOLFSSL_SMALL_STACK_STATIC const byte check[] =
{
0x27, 0xdd, 0xff, 0x5b, 0x21, 0x26, 0x0a, 0x48,
@@ -62463,6 +62522,23 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
ret = 0;
break;
}
#endif
default:
ret = WC_NO_ERR_TRACE(NOT_COMPILED_IN);
break;
}
}
else if (info->free.algo == WC_ALGO_TYPE_CIPHER) {
switch (info->free.type) {
#ifndef NO_AES
case WC_CIPHER_AES:
{
Aes* aes = (Aes*)info->free.obj;
aes->devId = INVALID_DEVID;
wc_AesFree(aes);
ret = 0;
break;
}
#endif
default:
ret = WC_NO_ERR_TRACE(NOT_COMPILED_IN);