Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to use WC_RNG and fix max data_size check. #394

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/wolfssl/atca_wolfssl_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
ATCA_STATUS atcac_sw_random(uint8_t* data, size_t data_size)
{
ATCA_STATUS status = ATCA_BAD_PARAM;
RNG rng;
WC_RNG rng;

if (0 == wc_InitRng(&rng))
{
if (UINT32_MAX <= data_size)
if (data_size <= UINT32_MAX)
{
if (0 == wc_RNG_GenerateBlock(&rng, data, (word32)data_size))
{
Expand Down Expand Up @@ -1100,7 +1100,7 @@ ATCA_STATUS atcac_get_subj_public_key(const struct atcac_x509_ctx* cert, cal_buf
if (0 == wc_RsaPublicKeyDecode((byte*)key->pkey.ptr, &idx, &rsaKey, (word32)key->pkey_sz))
{
int nlen = mp_unsigned_bin_size(&rsaKey.n);
// Check buffer size before storing public key
// Check buffer size before storing public key
if ((nlen > 0) && ((unsigned long)nlen <= subj_public_key->len))
{
if (0 == mp_to_unsigned_bin(&rsaKey.n, (byte*)subj_public_key->buf))
Expand Down