Fix for SP init and free with HAVE_WOLF_BIGINT. Fix for sp_free macro typo. Fix to expose mp_init_copy with ECC disabled because its used by mp_test.

This commit is contained in:
David Garske
2020-08-26 09:42:29 -07:00
parent 61545df606
commit 3878af96cd
4 changed files with 29 additions and 10 deletions

View File

@@ -104,7 +104,9 @@ int sp_init(sp_int* a)
{
a->used = 0;
a->size = SP_INT_DIGITS;
#ifdef HAVE_WOLF_BIGINT
wc_bigint_init(&a->raw);
#endif
return MP_OKAY;
}
@@ -125,26 +127,44 @@ int sp_init_multi(sp_int* a, sp_int* b, sp_int* c, sp_int* d, sp_int* e,
if (a != NULL) {
a->used = 0;
a->size = SP_INT_DIGITS;
#ifdef HAVE_WOLF_BIGINT
wc_bigint_init(&a->raw);
#endif
}
if (b != NULL) {
b->used = 0;
b->size = SP_INT_DIGITS;
#ifdef HAVE_WOLF_BIGINT
wc_bigint_init(&b->raw);
#endif
}
if (c != NULL) {
c->used = 0;
c->size = SP_INT_DIGITS;
#ifdef HAVE_WOLF_BIGINT
wc_bigint_init(&c->raw);
#endif
}
if (d != NULL) {
d->used = 0;
d->size = SP_INT_DIGITS;
#ifdef HAVE_WOLF_BIGINT
wc_bigint_init(&d->raw);
#endif
}
if (e != NULL) {
e->used = 0;
e->size = SP_INT_DIGITS;
#ifdef HAVE_WOLF_BIGINT
wc_bigint_init(&e->raw);
#endif
}
if (f != NULL) {
f->used = 0;
f->size = SP_INT_DIGITS;
#ifdef HAVE_WOLF_BIGINT
wc_bigint_init(&f->raw);
#endif
}
return MP_OKAY;

View File

@@ -4300,6 +4300,12 @@ void fp_copy(fp_int *a, fp_int *b)
}
}
int mp_init_copy(fp_int * a, fp_int * b)
{
fp_init_copy(a, b);
return MP_OKAY;
}
void fp_init_copy(fp_int *a, fp_int* b)
{
if (a != b) {
@@ -5392,13 +5398,6 @@ int mp_div_2_mod_ct(mp_int *a, mp_int *b, mp_int *c)
return fp_div_2_mod_ct(a, b, c);
}
int mp_init_copy(fp_int * a, fp_int * b)
{
fp_init_copy(a, b);
return MP_OKAY;
}
#ifdef HAVE_COMP_KEY
int mp_cnt_lsb(fp_int* a)