Skip to content
Merged
Show file tree
Hide file tree
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
20 changes: 9 additions & 11 deletions src/pk_ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -4898,18 +4898,16 @@ WOLFSSL_ECDSA_SIG *wolfSSL_ECDSA_SIG_new(void)
DYNAMIC_TYPE_ECC);
if (sig == NULL) {
WOLFSSL_MSG("wolfSSL_ECDSA_SIG_new malloc ECDSA signature failure");
err = 1;
return NULL;
}

if (!err) {
/* Set s to NULL in case of error. */
sig->s = NULL;
/* Allocate BN into r. */
sig->r = wolfSSL_BN_new();
if (sig->r == NULL) {
WOLFSSL_MSG("wolfSSL_ECDSA_SIG_new malloc ECDSA r failure");
err = 1;
}
/* Set s to NULL in case of error. */
sig->s = NULL;
/* Allocate BN into r. */
sig->r = wolfSSL_BN_new();
if (sig->r == NULL) {
WOLFSSL_MSG("wolfSSL_ECDSA_SIG_new malloc ECDSA r failure");
err = 1;
}
if (!err) {
/* Allocate BN into s. */
Expand All @@ -4920,7 +4918,7 @@ WOLFSSL_ECDSA_SIG *wolfSSL_ECDSA_SIG_new(void)
}
}

if (err && (sig != NULL)) {
if (err) {
/* Dispose of allocated memory. */
wolfSSL_ECDSA_SIG_free(sig);
sig = NULL;
Expand Down
17 changes: 11 additions & 6 deletions wolfcrypt/src/evp_pk.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,19 @@ static int d2i_make_pkey(WOLFSSL_EVP_PKEY** out, const unsigned char* mem,

/* Set the size and allocate memory for key data to be copied into. */
pkey->pkey_sz = (int)memSz;
pkey->pkey.ptr = (char*)XMALLOC((size_t)memSz, NULL,
priv ? DYNAMIC_TYPE_PRIVATE_KEY : DYNAMIC_TYPE_PUBLIC_KEY);
if (pkey->pkey.ptr == NULL) {
ret = 0;
if (memSz > 0) {
pkey->pkey.ptr = (char*)XMALLOC((size_t)memSz, NULL,
priv ? DYNAMIC_TYPE_PRIVATE_KEY : DYNAMIC_TYPE_PUBLIC_KEY);
if (pkey->pkey.ptr == NULL) {
ret = 0;
}
if (ret == 1) {
/* Copy in key data. */
XMEMCPY(pkey->pkey.ptr, mem, memSz);
}
}
if (ret == 1) {
/* Copy in key data, set key type passed in and return object. */
XMEMCPY(pkey->pkey.ptr, mem, memSz);
/* Set key type passed in and return object. */
pkey->type = type;
*out = pkey;
}
Expand Down
Loading