forked from wolfSSL/wolfssl
manual merge pull request #83, ALT_ECC_SIZE fix
This commit is contained in:
@@ -1057,7 +1057,8 @@ static int _fp_exptmod(fp_int * G, fp_int * X, fp_int * P, fp_int * Y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* init M array */
|
/* init M array */
|
||||||
XMEMSET(M, 0, sizeof(M));
|
for(x = 0; x < (int)(sizeof(M)/sizeof(fp_int)); x++)
|
||||||
|
fp_init(&M[x]);
|
||||||
|
|
||||||
/* now setup montgomery */
|
/* now setup montgomery */
|
||||||
if ((err = fp_montgomery_setup (P, &mp)) != FP_OKAY) {
|
if ((err = fp_montgomery_setup (P, &mp)) != FP_OKAY) {
|
||||||
@@ -1456,6 +1457,10 @@ int fp_cmp(fp_int *a, fp_int *b)
|
|||||||
/* compare against a single digit */
|
/* compare against a single digit */
|
||||||
int fp_cmp_d(fp_int *a, fp_digit b)
|
int fp_cmp_d(fp_int *a, fp_digit b)
|
||||||
{
|
{
|
||||||
|
/* special case for zero*/
|
||||||
|
if (a->used == 0 && b == 0)
|
||||||
|
return FP_EQ;
|
||||||
|
|
||||||
/* compare based on sign */
|
/* compare based on sign */
|
||||||
if ((b && a->used == 0) || a->sign == FP_NEG) {
|
if ((b && a->used == 0) || a->sign == FP_NEG) {
|
||||||
return FP_LT;
|
return FP_LT;
|
||||||
@@ -2156,9 +2161,10 @@ int mp_div_2d(fp_int* a, int b, fp_int* c, fp_int* d)
|
|||||||
#ifdef ALT_ECC_SIZE
|
#ifdef ALT_ECC_SIZE
|
||||||
void fp_copy(fp_int *a, fp_int* b)
|
void fp_copy(fp_int *a, fp_int* b)
|
||||||
{
|
{
|
||||||
if (a != b) {
|
if (a != b && b->size >= a->used) {
|
||||||
b->used = a->used;
|
b->used = a->used;
|
||||||
b->sign = a->sign;
|
b->sign = a->sign;
|
||||||
|
|
||||||
XMEMCPY(b->dp, a->dp, a->used * sizeof(fp_digit));
|
XMEMCPY(b->dp, a->dp, a->used * sizeof(fp_digit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user