@@ -670,7 +670,7 @@ static int add_entry(int idx, ecc_point *g)
670670 * The algorithm builds patterns in increasing bit order by first making all
671671 * single bit input patterns, then all two bit input patterns and so on
672672 */
673- static int build_lut (int idx , void * modulus , void * mp , void * mu )
673+ static int build_lut (int idx , void * a , void * modulus , void * mp , void * mu )
674674{
675675 unsigned x , y , err , bitlen , lut_gap ;
676676 void * tmp ;
@@ -709,7 +709,7 @@ static int build_lut(int idx, void *modulus, void *mp, void *mu)
709709
710710 /* now double it bitlen/FP_LUT times */
711711 for (y = 0 ; y < lut_gap ; y ++ ) {
712- if ((err = ltc_mp .ecc_ptdbl (fp_cache [idx ].LUT [1 <<x ], fp_cache [idx ].LUT [1 <<x ], modulus , mp )) != CRYPT_OK ) {
712+ if ((err = ltc_mp .ecc_ptdbl (fp_cache [idx ].LUT [1 <<x ], fp_cache [idx ].LUT [1 <<x ], a , modulus , mp )) != CRYPT_OK ) {
713713 goto ERR ;
714714 }
715715 }
@@ -722,7 +722,7 @@ static int build_lut(int idx, void *modulus, void *mp, void *mu)
722722
723723 /* perform the add */
724724 if ((err = ltc_mp .ecc_ptadd (fp_cache [idx ].LUT [lut_orders [y ].terma ], fp_cache [idx ].LUT [lut_orders [y ].termb ],
725- fp_cache [idx ].LUT [y ], modulus , mp )) != CRYPT_OK ) {
725+ fp_cache [idx ].LUT [y ], a , modulus , mp )) != CRYPT_OK ) {
726726 goto ERR ;
727727 }
728728 }
@@ -777,7 +777,7 @@ static int build_lut(int idx, void *modulus, void *mp, void *mu)
777777}
778778
779779/* perform a fixed point ECC mulmod */
780- static int accel_fp_mul (int idx , void * k , ecc_point * R , void * modulus , void * mp , int map )
780+ static int accel_fp_mul (int idx , void * k , ecc_point * R , void * a , void * modulus , void * mp , int map )
781781{
782782 unsigned char kb [128 ];
783783 int x ;
@@ -870,14 +870,14 @@ static int accel_fp_mul(int idx, void *k, ecc_point *R, void *modulus, void *mp,
870870
871871 /* double if not first */
872872 if (!first ) {
873- if ((err = ltc_mp .ecc_ptdbl (R , R , modulus , mp )) != CRYPT_OK ) {
873+ if ((err = ltc_mp .ecc_ptdbl (R , R , a , modulus , mp )) != CRYPT_OK ) {
874874 return err ;
875875 }
876876 }
877877
878878 /* add if not first, otherwise copy */
879879 if (!first && z ) {
880- if ((err = ltc_mp .ecc_ptadd (R , fp_cache [idx ].LUT [z ], R , modulus , mp )) != CRYPT_OK ) {
880+ if ((err = ltc_mp .ecc_ptadd (R , fp_cache [idx ].LUT [z ], R , a , modulus , mp )) != CRYPT_OK ) {
881881 return err ;
882882 }
883883 } else if (z ) {
@@ -902,7 +902,7 @@ static int accel_fp_mul(int idx, void *k, ecc_point *R, void *modulus, void *mp,
902902/* perform a fixed point ECC mulmod */
903903static int accel_fp_mul2add (int idx1 , int idx2 ,
904904 void * kA , void * kB ,
905- ecc_point * R , void * modulus , void * mp )
905+ ecc_point * R , void * a , void * modulus , void * mp )
906906{
907907 unsigned char kb [2 ][128 ];
908908 int x ;
@@ -1058,20 +1058,20 @@ static int accel_fp_mul2add(int idx1, int idx2,
10581058
10591059 /* double if not first */
10601060 if (!first ) {
1061- if ((err = ltc_mp .ecc_ptdbl (R , R , modulus , mp )) != CRYPT_OK ) {
1061+ if ((err = ltc_mp .ecc_ptdbl (R , R , a , modulus , mp )) != CRYPT_OK ) {
10621062 return err ;
10631063 }
10641064 }
10651065
10661066 /* add if not first, otherwise copy */
10671067 if (!first ) {
10681068 if (zA ) {
1069- if ((err = ltc_mp .ecc_ptadd (R , fp_cache [idx1 ].LUT [zA ], R , modulus , mp )) != CRYPT_OK ) {
1069+ if ((err = ltc_mp .ecc_ptadd (R , fp_cache [idx1 ].LUT [zA ], R , a , modulus , mp )) != CRYPT_OK ) {
10701070 return err ;
10711071 }
10721072 }
10731073 if (zB ) {
1074- if ((err = ltc_mp .ecc_ptadd (R , fp_cache [idx2 ].LUT [zB ], R , modulus , mp )) != CRYPT_OK ) {
1074+ if ((err = ltc_mp .ecc_ptadd (R , fp_cache [idx2 ].LUT [zB ], R , a , modulus , mp )) != CRYPT_OK ) {
10751075 return err ;
10761076 }
10771077 }
@@ -1084,7 +1084,7 @@ static int accel_fp_mul2add(int idx1, int idx2,
10841084 }
10851085 if (zB && first == 0 ) {
10861086 if (zB ) {
1087- if ((err = ltc_mp .ecc_ptadd (R , fp_cache [idx2 ].LUT [zB ], R , modulus , mp )) != CRYPT_OK ) {
1087+ if ((err = ltc_mp .ecc_ptadd (R , fp_cache [idx2 ].LUT [zB ], R , a , modulus , mp )) != CRYPT_OK ) {
10881088 return err ;
10891089 }
10901090 }
@@ -1112,7 +1112,9 @@ static int accel_fp_mul2add(int idx1, int idx2,
11121112*/
11131113int ltc_ecc_fp_mul2add (ecc_point * A , void * kA ,
11141114 ecc_point * B , void * kB ,
1115- ecc_point * C , void * modulus )
1115+ ecc_point * C ,
1116+ void * a ,
1117+ void * modulus )
11161118{
11171119 int idx1 , idx2 , err ;
11181120 void * mp , * mu ;
@@ -1168,7 +1170,7 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11681170 }
11691171
11701172 /* build the LUT */
1171- if ((err = build_lut (idx1 , modulus , mp , mu )) != CRYPT_OK ) {
1173+ if ((err = build_lut (idx1 , a , modulus , mp , mu )) != CRYPT_OK ) {
11721174 goto LBL_ERR ;;
11731175 }
11741176 }
@@ -1189,7 +1191,7 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11891191 }
11901192
11911193 /* build the LUT */
1192- if ((err = build_lut (idx2 , modulus , mp , mu )) != CRYPT_OK ) {
1194+ if ((err = build_lut (idx2 , a , modulus , mp , mu )) != CRYPT_OK ) {
11931195 goto LBL_ERR ;;
11941196 }
11951197 }
@@ -1200,9 +1202,9 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
12001202 /* compute mp */
12011203 if ((err = mp_montgomery_setup (modulus , & mp )) != CRYPT_OK ) { goto LBL_ERR ; }
12021204 }
1203- err = accel_fp_mul2add (idx1 , idx2 , kA , kB , C , modulus , mp );
1205+ err = accel_fp_mul2add (idx1 , idx2 , kA , kB , C , a , modulus , mp );
12041206 } else {
1205- err = ltc_ecc_mul2add (A , kA , B , kB , C , modulus );
1207+ err = ltc_ecc_mul2add (A , kA , B , kB , C , a , modulus );
12061208 }
12071209LBL_ERR :
12081210 LTC_MUTEX_UNLOCK (& ltc_ecc_fp_lock );
@@ -1220,11 +1222,12 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
12201222 @param k The multiplicand
12211223 @param G Base point to multiply
12221224 @param R [out] Destination of product
1225+ @param a ECC curve parameter a
12231226 @param modulus The modulus for the curve
12241227 @param map [boolean] If non-zero maps the point back to affine co-ordinates, otherwise it's left in jacobian-montgomery form
12251228 @return CRYPT_OK if successful
12261229*/
1227- int ltc_ecc_fp_mulmod (void * k , ecc_point * G , ecc_point * R , void * modulus , int map )
1230+ int ltc_ecc_fp_mulmod (void * k , ecc_point * G , ecc_point * R , void * a , void * modulus , int map )
12281231{
12291232 int idx , err ;
12301233 void * mp , * mu ;
@@ -1266,7 +1269,7 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int ma
12661269 }
12671270
12681271 /* build the LUT */
1269- if ((err = build_lut (idx , modulus , mp , mu )) != CRYPT_OK ) {
1272+ if ((err = build_lut (idx , a , modulus , mp , mu )) != CRYPT_OK ) {
12701273 goto LBL_ERR ;;
12711274 }
12721275 }
@@ -1276,9 +1279,9 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int ma
12761279 /* compute mp */
12771280 if ((err = mp_montgomery_setup (modulus , & mp )) != CRYPT_OK ) { goto LBL_ERR ; }
12781281 }
1279- err = accel_fp_mul (idx , k , R , modulus , mp , map );
1282+ err = accel_fp_mul (idx , k , R , a , modulus , mp , map );
12801283 } else {
1281- err = ltc_ecc_mulmod (k , G , R , modulus , map );
1284+ err = ltc_ecc_mulmod (k , G , R , a , modulus , map );
12821285 }
12831286LBL_ERR :
12841287 LTC_MUTEX_UNLOCK (& ltc_ecc_fp_lock );
@@ -1365,7 +1368,7 @@ ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock)
13651368 }
13661369
13671370 /* build the LUT */
1368- if ((err = build_lut (idx , modulus , mp , mu )) != CRYPT_OK ) {
1371+ if ((err = build_lut (idx , a , modulus , mp , mu )) != CRYPT_OK ) {
13691372 goto LBL_ERR ;
13701373 }
13711374 fp_cache [idx ].lru_count = 2 ;
0 commit comments