@@ -566,7 +566,7 @@ static const struct {
566566};
567567
568568/* find a hole and free as required, return -1 if no hole found */
569- static int _find_hole (void )
569+ static int s_find_hole (void )
570570{
571571 unsigned x ;
572572 int y , z ;
@@ -602,7 +602,7 @@ static int _find_hole(void)
602602}
603603
604604/* determine if a base is already in the cache and if so, where */
605- static int _find_base (ecc_point * g )
605+ static int s_find_base (ecc_point * g )
606606{
607607 int x ;
608608 for (x = 0 ; x < FP_ENTRIES ; x ++ ) {
@@ -620,7 +620,7 @@ static int _find_base(ecc_point *g)
620620}
621621
622622/* add a new base to the cache */
623- static int _add_entry (int idx , ecc_point * g )
623+ static int s_add_entry (int idx , ecc_point * g )
624624{
625625 unsigned x , y ;
626626
@@ -662,7 +662,7 @@ static int _add_entry(int idx, ecc_point *g)
662662 * The algorithm builds patterns in increasing bit order by first making all
663663 * single bit input patterns, then all two bit input patterns and so on
664664 */
665- static int _build_lut (int idx , void * a , void * modulus , void * mp , void * mu )
665+ static int s_build_lut (int idx , void * a , void * modulus , void * mp , void * mu )
666666{
667667 unsigned x , y , err , bitlen , lut_gap ;
668668 void * tmp ;
@@ -769,7 +769,7 @@ static int _build_lut(int idx, void *a, void *modulus, void *mp, void *mu)
769769}
770770
771771/* perform a fixed point ECC mulmod */
772- static int _accel_fp_mul (int idx , void * k , ecc_point * R , void * a , void * modulus , void * mp , int map )
772+ static int s_accel_fp_mul (int idx , void * k , ecc_point * R , void * a , void * modulus , void * mp , int map )
773773{
774774 unsigned char kb [128 ];
775775 int x ;
@@ -892,7 +892,7 @@ static int _accel_fp_mul(int idx, void *k, ecc_point *R, void *a, void *modulus,
892892
893893#ifdef LTC_ECC_SHAMIR
894894/* perform a fixed point ECC mulmod */
895- static int _accel_fp_mul2add (int idx1 , int idx2 ,
895+ static int ss_accel_fp_mul2add (int idx1 , int idx2 ,
896896 void * kA , void * kB ,
897897 ecc_point * R , void * a , void * modulus , void * mp )
898898{
@@ -1115,13 +1115,13 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11151115 mu = NULL ;
11161116 LTC_MUTEX_LOCK (& ltc_ecc_fp_lock );
11171117 /* find point */
1118- idx1 = _find_base (A );
1118+ idx1 = s_find_base (A );
11191119
11201120 /* no entry? */
11211121 if (idx1 == -1 ) {
11221122 /* find hole and add it */
1123- if ((idx1 = _find_hole ()) >= 0 ) {
1124- if ((err = _add_entry (idx1 , A )) != CRYPT_OK ) {
1123+ if ((idx1 = s_find_hole ()) >= 0 ) {
1124+ if ((err = s_add_entry (idx1 , A )) != CRYPT_OK ) {
11251125 goto LBL_ERR ;
11261126 }
11271127 }
@@ -1132,13 +1132,13 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11321132 }
11331133
11341134 /* find point */
1135- idx2 = _find_base (B );
1135+ idx2 = s_find_base (B );
11361136
11371137 /* no entry? */
11381138 if (idx2 == -1 ) {
11391139 /* find hole and add it */
1140- if ((idx2 = _find_hole ()) >= 0 ) {
1141- if ((err = _add_entry (idx2 , B )) != CRYPT_OK ) {
1140+ if ((idx2 = s_find_hole ()) >= 0 ) {
1141+ if ((err = s_add_entry (idx2 , B )) != CRYPT_OK ) {
11421142 goto LBL_ERR ;
11431143 }
11441144 }
@@ -1162,7 +1162,7 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11621162 }
11631163
11641164 /* build the LUT */
1165- if ((err = _build_lut (idx1 , a , modulus , mp , mu )) != CRYPT_OK ) {
1165+ if ((err = s_build_lut (idx1 , a , modulus , mp , mu )) != CRYPT_OK ) {
11661166 goto LBL_ERR ;;
11671167 }
11681168 }
@@ -1183,7 +1183,7 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11831183 }
11841184
11851185 /* build the LUT */
1186- if ((err = _build_lut (idx2 , a , modulus , mp , mu )) != CRYPT_OK ) {
1186+ if ((err = s_build_lut (idx2 , a , modulus , mp , mu )) != CRYPT_OK ) {
11871187 goto LBL_ERR ;;
11881188 }
11891189 }
@@ -1194,7 +1194,7 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
11941194 /* compute mp */
11951195 if ((err = mp_montgomery_setup (modulus , & mp )) != CRYPT_OK ) { goto LBL_ERR ; }
11961196 }
1197- err = _accel_fp_mul2add (idx1 , idx2 , kA , kB , C , a , modulus , mp );
1197+ err = ss_accel_fp_mul2add (idx1 , idx2 , kA , kB , C , a , modulus , mp );
11981198 } else {
11991199 err = ltc_ecc_mul2add (A , kA , B , kB , C , a , modulus );
12001200 }
@@ -1228,15 +1228,15 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *a, void *modulu
12281228 mu = NULL ;
12291229 LTC_MUTEX_LOCK (& ltc_ecc_fp_lock );
12301230 /* find point */
1231- idx = _find_base (G );
1231+ idx = s_find_base (G );
12321232
12331233 /* no entry? */
12341234 if (idx == -1 ) {
12351235 /* find hole and add it */
1236- idx = _find_hole ();
1236+ idx = s_find_hole ();
12371237
12381238 if (idx >= 0 ) {
1239- if ((err = _add_entry (idx , G )) != CRYPT_OK ) {
1239+ if ((err = s_add_entry (idx , G )) != CRYPT_OK ) {
12401240 goto LBL_ERR ;
12411241 }
12421242 }
@@ -1261,7 +1261,7 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *a, void *modulu
12611261 }
12621262
12631263 /* build the LUT */
1264- if ((err = _build_lut (idx , a , modulus , mp , mu )) != CRYPT_OK ) {
1264+ if ((err = s_build_lut (idx , a , modulus , mp , mu )) != CRYPT_OK ) {
12651265 goto LBL_ERR ;;
12661266 }
12671267 }
@@ -1271,7 +1271,7 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *a, void *modulu
12711271 /* compute mp */
12721272 if ((err = mp_montgomery_setup (modulus , & mp )) != CRYPT_OK ) { goto LBL_ERR ; }
12731273 }
1274- err = _accel_fp_mul (idx , k , R , a , modulus , mp , map );
1274+ err = s_accel_fp_mul (idx , k , R , a , modulus , mp , map );
12751275 } else {
12761276 err = ltc_ecc_mulmod (k , G , R , a , modulus , map );
12771277 }
@@ -1287,7 +1287,7 @@ int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *a, void *modulu
12871287}
12881288
12891289/* helper function for freeing the cache ... must be called with the cache mutex locked */
1290- static void _ltc_ecc_fp_free_cache (void )
1290+ static void s_ltc_ecc_fp_free_cache (void )
12911291{
12921292 unsigned x , y ;
12931293 for (x = 0 ; x < FP_ENTRIES ; x ++ ) {
@@ -1312,7 +1312,7 @@ static void _ltc_ecc_fp_free_cache(void)
13121312void ltc_ecc_fp_free (void )
13131313{
13141314 LTC_MUTEX_LOCK (& ltc_ecc_fp_lock );
1315- _ltc_ecc_fp_free_cache ();
1315+ s_ltc_ecc_fp_free_cache ();
13161316 LTC_MUTEX_UNLOCK (& ltc_ecc_fp_lock );
13171317}
13181318
@@ -1331,19 +1331,19 @@ ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock)
13311331 void * mu = NULL ;
13321332
13331333 LTC_MUTEX_LOCK (& ltc_ecc_fp_lock );
1334- if ((idx = _find_base (g )) >= 0 ) {
1334+ if ((idx = s_find_base (g )) >= 0 ) {
13351335 /* it is already in the cache ... just check that the LUT is initialized */
13361336 if (fp_cache [idx ].lru_count >= 2 ) {
13371337 LTC_MUTEX_UNLOCK (& ltc_ecc_fp_lock );
13381338 return CRYPT_OK ;
13391339 }
13401340 }
13411341
1342- if (idx == -1 && (idx = _find_hole ()) == -1 ) {
1342+ if (idx == -1 && (idx = s_find_hole ()) == -1 ) {
13431343 err = CRYPT_BUFFER_OVERFLOW ;
13441344 goto LBL_ERR ;
13451345 }
1346- if ((err = _add_entry (idx , g )) != CRYPT_OK ) {
1346+ if ((err = s_add_entry (idx , g )) != CRYPT_OK ) {
13471347 goto LBL_ERR ;
13481348 }
13491349 /* compute mp */
@@ -1360,7 +1360,7 @@ ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock)
13601360 }
13611361
13621362 /* build the LUT */
1363- if ((err = _build_lut (idx , a , modulus , mp , mu )) != CRYPT_OK ) {
1363+ if ((err = s_build_lut (idx , a , modulus , mp , mu )) != CRYPT_OK ) {
13641364 goto LBL_ERR ;
13651365 }
13661366 fp_cache [idx ].lru_count = 2 ;
@@ -1498,7 +1498,7 @@ int ltc_ecc_fp_restore_state(unsigned char *in, unsigned long inlen)
14981498 /*
14991499 * start with an empty cache
15001500 */
1501- _ltc_ecc_fp_free_cache ();
1501+ s_ltc_ecc_fp_free_cache ();
15021502
15031503 /*
15041504 * decode the input packet: It consists of a sequence with a few
@@ -1568,7 +1568,7 @@ int ltc_ecc_fp_restore_state(unsigned char *in, unsigned long inlen)
15681568ERR_OUT :
15691569 if (asn1_list )
15701570 XFREE (asn1_list );
1571- _ltc_ecc_fp_free_cache ();
1571+ s_ltc_ecc_fp_free_cache ();
15721572 LTC_MUTEX_UNLOCK (& ltc_ecc_fp_lock );
15731573 return err ;
15741574}
0 commit comments