Skip to content

Commit

Permalink
Merge pull request #7769 from douzzer/20240719-PQ-fixes
Browse files Browse the repository at this point in the history
20240719-PQ-fixes
  • Loading branch information
dgarske authored Jul 19, 2024
2 parents 0eeae4d + e13a8dd commit 16a2d2e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 4 additions & 3 deletions wolfcrypt/src/dilithium.c
Original file line number Diff line number Diff line change
Expand Up @@ -6952,10 +6952,9 @@ int wc_dilithium_init_ex(dilithium_key* key, void* heap, int devId)
key->idLen = 0;
key->labelLen = 0;
#endif
key->heap = heap;
}

key->heap = heap;

return ret;
}

Expand Down Expand Up @@ -7422,7 +7421,9 @@ int wc_dilithium_check_key(dilithium_key* key)
}

/* Dispose of allocated memory. */
XFREE(s1, key->heap, DYNAMIC_TYPE_DILITHIUM);
if (s1 != NULL) {
XFREE(s1, key->heap, DYNAMIC_TYPE_DILITHIUM);
}
#else
/* Validate parameter. */
if (key == NULL) {
Expand Down
8 changes: 6 additions & 2 deletions wolfcrypt/src/wc_kyber.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ int wc_KyberKey_MakeKeyWithRandom(KyberKey* key, const unsigned char* rand,
}

/* Free dynamic memory allocated in function. */
XFREE(a, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
if (a != NULL) {
XFREE(a, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
}

return ret;
}
Expand Down Expand Up @@ -890,7 +892,9 @@ int wc_KyberKey_Decapsulate(KyberKey* key, unsigned char* ss,

#ifndef USE_INTEL_SPEEDUP
/* Dispose of dynamic memory allocated in function. */
XFREE(cmp, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
if (cmp != NULL) {
XFREE(cmp, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
}
#endif

return ret;
Expand Down

0 comments on commit 16a2d2e

Please sign in to comment.