@@ -760,7 +760,7 @@ static int test_mp_sqrt(void)
760760 printf ("\nmp_sqrt() error!" );
761761 goto LBL_ERR ;
762762 }
763- mp_n_root (& a , 2uL , & c );
763+ mp_root_u32 (& a , 2uL , & c );
764764 if (mp_cmp_mag (& b , & c ) != MP_EQ ) {
765765 printf ("mp_sqrt() bad result!\n" );
766766 goto LBL_ERR ;
@@ -1364,8 +1364,10 @@ static mp_err s_rs(const mp_int *a, int radix, int *size)
13641364static int test_mp_ilogb (void )
13651365{
13661366 mp_int a , lb ;
1367- mp_digit d , base ;
1367+ mp_digit d ;
1368+ uint32_t base ;
13681369 int size ;
1370+ const uint32_t max_base = MP_MIN (UINT32_MAX , MP_DIGIT_MAX );
13691371
13701372 if (mp_init_multi (& a , & lb , NULL ) != MP_OKAY ) {
13711373 goto LBL_ERR ;
@@ -1377,11 +1379,11 @@ static int test_mp_ilogb(void)
13771379 1 x MP_VAL
13781380 */
13791381 mp_set (& a , 42uL );
1380- base = 0uL ;
1382+ base = 0u ;
13811383 if (mp_ilogb (& a , base , & lb ) != MP_VAL ) {
13821384 goto LBL_ERR ;
13831385 }
1384- base = 1uL ;
1386+ base = 1u ;
13851387 if (mp_ilogb (& a , base , & lb ) != MP_VAL ) {
13861388 goto LBL_ERR ;
13871389 }
@@ -1392,7 +1394,7 @@ static int test_mp_ilogb(void)
13921394 2 2 1
13931395 2 3 1
13941396 */
1395- base = 2uL ;
1397+ base = 2u ;
13961398 mp_zero (& a );
13971399 if (mp_ilogb (& a , base , & lb ) != MP_VAL ) {
13981400 goto LBL_ERR ;
@@ -1414,7 +1416,7 @@ static int test_mp_ilogb(void)
14141416 3 2 0
14151417 3 3 1
14161418 */
1417- base = 3uL ;
1419+ base = 3u ;
14181420 mp_zero (& a );
14191421 if (mp_ilogb (& a , base , & lb ) != MP_VAL ) {
14201422 goto LBL_ERR ;
@@ -1437,7 +1439,7 @@ static int test_mp_ilogb(void)
14371439 if (mp_rand (& a , 10 ) != MP_OKAY ) {
14381440 goto LBL_ERR ;
14391441 }
1440- for (base = 2uL ; base < 65uL ; base ++ ) {
1442+ for (base = 2u ; base < 65u ; base ++ ) {
14411443 if (mp_ilogb (& a , base , & lb ) != MP_OKAY ) {
14421444 goto LBL_ERR ;
14431445 }
@@ -1458,7 +1460,7 @@ static int test_mp_ilogb(void)
14581460 if (mp_rand (& a , 1 ) != MP_OKAY ) {
14591461 goto LBL_ERR ;
14601462 }
1461- for (base = 2uL ; base < 65uL ; base ++ ) {
1463+ for (base = 2u ; base < 65u ; base ++ ) {
14621464 if (mp_ilogb (& a , base , & lb ) != MP_OKAY ) {
14631465 goto LBL_ERR ;
14641466 }
@@ -1471,15 +1473,15 @@ static int test_mp_ilogb(void)
14711473 }
14721474 }
14731475
1474- /*Test upper edgecase with base MP_MASK and number (MP_MASK /2)*MP_MASK ^10 */
1475- mp_set (& a , MP_MASK );
1476- if (mp_expt_d (& a , 10uL , & a ) != MP_OKAY ) {
1476+ /*Test upper edgecase with base UINT32_MAX and number (UINT32_MAX /2)*UINT32_MAX ^10 */
1477+ mp_set (& a , max_base );
1478+ if (mp_expt_u32 (& a , 10uL , & a ) != MP_OKAY ) {
14771479 goto LBL_ERR ;
14781480 }
1479- if (mp_add_d (& a , ( MP_MASK >> 1 ) , & a ) != MP_OKAY ) {
1481+ if (mp_add_d (& a , max_base / 2 , & a ) != MP_OKAY ) {
14801482 goto LBL_ERR ;
14811483 }
1482- if (mp_ilogb (& a , MP_MASK , & lb ) != MP_OKAY ) {
1484+ if (mp_ilogb (& a , max_base , & lb ) != MP_OKAY ) {
14831485 goto LBL_ERR ;
14841486 }
14851487 if (mp_cmp_d (& lb , 10uL ) != MP_EQ ) {
@@ -1626,7 +1628,7 @@ static int test_mp_decr(void)
16261628}
16271629
16281630/*
1629- Cannot test mp_exp(_d) without mp_n_root and vice versa.
1631+ Cannot test mp_exp(_d) without mp_root and vice versa.
16301632 So one of the two has to be tested from scratch.
16311633
16321634 Numbers generated by
@@ -1647,7 +1649,7 @@ static int test_mp_decr(void)
16471649 All numbers as strings to simplifiy things, especially for the
16481650 low-mp branch.
16491651*/
1650- static int test_mp_n_root (void )
1652+ static int test_mp_root_u32 (void )
16511653{
16521654 mp_int a , c , r ;
16531655 mp_err e ;
@@ -1850,10 +1852,10 @@ static int test_mp_n_root(void)
18501852#else
18511853 for (j = 3 ; j < 100 ; j ++ ) {
18521854#endif
1853- mp_n_root (& a , (mp_digit ) j , & c );
1855+ mp_root_u32 (& a , (uint32_t ) j , & c );
18541856 mp_read_radix (& r , root [i ][j - 3 ], 10 );
18551857 if (mp_cmp (& r , & c ) != MP_EQ ) {
1856- fprintf (stderr , "mp_n_root failed at input #%d, root #%d\n" , i , j );
1858+ fprintf (stderr , "mp_root_u32 failed at input #%d, root #%d\n" , i , j );
18571859 goto LTM_ERR ;
18581860 }
18591861 }
@@ -2063,7 +2065,7 @@ int unit_tests(int argc, char **argv)
20632065 T (mp_is_square ),
20642066 T (mp_kronecker ),
20652067 T (mp_montgomery_reduce ),
2066- T (mp_n_root ),
2068+ T (mp_root_u32 ),
20672069 T (mp_or ),
20682070 T (mp_prime_is_prime ),
20692071 T (mp_prime_rand ),
0 commit comments