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
|
* If either of those don't allocate correctly, none of
|
||||||
* the rest of this function will execute, and everything
|
* the rest of this function will execute, and everything
|
||||||
* gets cleaned up at the end. */
|
* gets cleaned up at the end. */
|
||||||
XMEMSET(&r, 0, sizeof(r));
|
mp_init(&r);
|
||||||
XMEMSET(&s, 0, sizeof(s));
|
mp_init(&s);
|
||||||
if (err == MP_OKAY)
|
if (err == MP_OKAY)
|
||||||
err = DecodeECC_DSA_Sig(sig, siglen, &r, &s);
|
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)
|
void fp_sub_d(fp_int *a, fp_digit b, fp_int *c)
|
||||||
{
|
{
|
||||||
fp_int tmp;
|
fp_int tmp;
|
||||||
|
fp_init(&tmp);
|
||||||
fp_set(&tmp, b);
|
fp_set(&tmp, b);
|
||||||
fp_sub(a, &tmp, c);
|
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));
|
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
|
#endif
|
||||||
|
|
||||||
/* fast math conversion */
|
/* fast math conversion */
|
||||||
|
@@ -375,10 +375,11 @@ void fp_set(fp_int *a, fp_digit b);
|
|||||||
/* copy from a to b */
|
/* copy from a to b */
|
||||||
#ifndef ALT_ECC_SIZE
|
#ifndef ALT_ECC_SIZE
|
||||||
#define fp_copy(a, b) (void)(((a) != (b)) ? ((void)XMEMCPY((b), (a), sizeof(fp_int))) : (void)0)
|
#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
|
#else
|
||||||
void fp_copy(fp_int *a, fp_int *b);
|
void fp_copy(fp_int *a, fp_int *b);
|
||||||
|
void fp_init_copy(fp_int *a, fp_int *b);
|
||||||
#endif
|
#endif
|
||||||
#define fp_init_copy(a, b) fp_copy(b, a)
|
|
||||||
|
|
||||||
/* clamp digits */
|
/* 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; }
|
#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