Fix issue with wc_ecc_import_x963_ex() and wc_ecc_import_raw_private() loosing heap pointer. Fixes issue #750.
This commit is contained in:
parent
db1f205522
commit
7125d16f3e
@ -3009,7 +3009,6 @@ int wc_ecc_init_ex(ecc_key* key, void* heap, int devId)
|
||||
#endif
|
||||
|
||||
XMEMSET(key, 0, sizeof(ecc_key));
|
||||
key->state = ECC_STATE_NONE;
|
||||
|
||||
#ifdef WOLFSSL_ATECC508A
|
||||
key->slot = atmel_ecc_alloc();
|
||||
@ -4469,6 +4468,7 @@ int wc_ecc_import_x963_ex(const byte* in, word32 inLen, ecc_key* key,
|
||||
#ifndef WOLFSSL_ATECC508A
|
||||
int compressed = 0;
|
||||
#endif /* !WOLFSSL_ATECC508A */
|
||||
void* heap;
|
||||
|
||||
if (in == NULL || key == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
@ -4478,8 +4478,9 @@ int wc_ecc_import_x963_ex(const byte* in, word32 inLen, ecc_key* key,
|
||||
return ECC_BAD_ARG_E;
|
||||
}
|
||||
|
||||
heap = key->heap; /* save heap */
|
||||
XMEMSET(key, 0, sizeof(ecc_key));
|
||||
key->state = ECC_STATE_NONE;
|
||||
key->heap = heap; /* restore heap */
|
||||
|
||||
#ifdef WOLFSSL_ATECC508A
|
||||
/* TODO: Implement equiv call to ATECC508A */
|
||||
@ -4894,13 +4895,17 @@ static int wc_ecc_import_raw_private(ecc_key* key, const char* qx,
|
||||
const char* qy, const char* d, int curve_id)
|
||||
{
|
||||
int err = MP_OKAY;
|
||||
void* heap;
|
||||
|
||||
/* if d is NULL, only import as public key using Qx,Qy */
|
||||
if (key == NULL || qx == NULL || qy == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
heap = key->heap; /* save heap */
|
||||
XMEMSET(key, 0, sizeof(ecc_key));
|
||||
key->heap = heap; /* restore heap */
|
||||
|
||||
/* set curve type and index */
|
||||
err = wc_ecc_set_curve(key, 0, curve_id);
|
||||
if (err != 0) {
|
||||
|
@ -262,7 +262,7 @@ typedef struct ecc_key {
|
||||
int idx; /* Index into the ecc_sets[] for the parameters of
|
||||
this curve if -1, this key is using user supplied
|
||||
curve in dp */
|
||||
int state;
|
||||
int state;
|
||||
word32 flags;
|
||||
const ecc_set_type* dp; /* domain parameters, either points to NIST
|
||||
curves (idx >= 0) or user supplied */
|
||||
|
Loading…
x
Reference in New Issue
Block a user