forked from wolfSSL/wolfssl
1. Changed a memset to 0 of some mp_ints with mp_inits()
2. For alt-ecc, implemented the function fp_init_copy() 3. Added an fp_init() for the temp fp_int in fp_sub_d()
This commit is contained in:
@@ -2088,8 +2088,8 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
|
||||
* If either of those don't allocate correctly, none of
|
||||
* the rest of this function will execute, and everything
|
||||
* gets cleaned up at the end. */
|
||||
XMEMSET(&r, 0, sizeof(r));
|
||||
XMEMSET(&s, 0, sizeof(s));
|
||||
mp_init(&r);
|
||||
mp_init(&s);
|
||||
if (err == MP_OKAY)
|
||||
err = DecodeECC_DSA_Sig(sig, siglen, &r, &s);
|
||||
|
||||
|
@@ -1829,6 +1829,7 @@ void fp_reverse (unsigned char *s, int len)
|
||||
void fp_sub_d(fp_int *a, fp_digit b, fp_int *c)
|
||||
{
|
||||
fp_int tmp;
|
||||
fp_init(&tmp);
|
||||
fp_set(&tmp, b);
|
||||
fp_sub(a, &tmp, c);
|
||||
}
|
||||
@@ -1983,6 +1984,14 @@ void fp_copy(fp_int *a, fp_int* b)
|
||||
XMEMCPY(b->dp, a->dp, a->used * sizeof(fp_digit));
|
||||
}
|
||||
}
|
||||
|
||||
void fp_init_copy(fp_int *a, fp_int* b)
|
||||
{
|
||||
if (a != b) {
|
||||
fp_init(a);
|
||||
fp_copy(b, a);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* fast math conversion */
|
||||
|
@@ -375,10 +375,11 @@ void fp_set(fp_int *a, fp_digit b);
|
||||
/* copy from a to b */
|
||||
#ifndef ALT_ECC_SIZE
|
||||
#define fp_copy(a, b) (void)(((a) != (b)) ? ((void)XMEMCPY((b), (a), sizeof(fp_int))) : (void)0)
|
||||
#define fp_init_copy(a, b) fp_copy(b, a)
|
||||
#else
|
||||
void fp_copy(fp_int *a, fp_int *b);
|
||||
void fp_init_copy(fp_int *a, fp_int *b);
|
||||
#endif
|
||||
#define fp_init_copy(a, b) fp_copy(b, a)
|
||||
|
||||
/* clamp digits */
|
||||
#define fp_clamp(a) { while ((a)->used && (a)->dp[(a)->used-1] == 0) --((a)->used); (a)->sign = (a)->used ? (a)->sign : FP_ZPOS; }
|
||||
|
Reference in New Issue
Block a user