manual merge pull request #83, ALT_ECC_SIZE fix

This commit is contained in:
toddouska
2015-08-27 10:18:00 -07:00
parent e8c17ed2bb
commit 3c614b5ba7

View File

@@ -1057,7 +1057,8 @@ static int _fp_exptmod(fp_int * G, fp_int * X, fp_int * P, fp_int * Y)
}
/* 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 */
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 */
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 */
if ((b && a->used == 0) || a->sign == FP_NEG) {
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
void fp_copy(fp_int *a, fp_int* b)
{
if (a != b) {
if (a != b && b->size >= a->used) {
b->used = a->used;
b->sign = a->sign;
XMEMCPY(b->dp, a->dp, a->used * sizeof(fp_digit));
}
}