comparison bn_mp_prime_is_prime.c @ 190:d8254fc979e9 libtommath-orig LTM_0.35

Initial import of libtommath 0.35
author Matt Johnston <matt@ucc.asn.au>
date Fri, 06 May 2005 08:59:30 +0000
parents d29b64170cf0
children
comparison
equal deleted inserted replaced
142:d29b64170cf0 190:d8254fc979e9
35 return MP_VAL; 35 return MP_VAL;
36 } 36 }
37 37
38 /* is the input equal to one of the primes in the table? */ 38 /* is the input equal to one of the primes in the table? */
39 for (ix = 0; ix < PRIME_SIZE; ix++) { 39 for (ix = 0; ix < PRIME_SIZE; ix++) {
40 if (mp_cmp_d(a, __prime_tab[ix]) == MP_EQ) { 40 if (mp_cmp_d(a, ltm_prime_tab[ix]) == MP_EQ) {
41 *result = 1; 41 *result = 1;
42 return MP_OKAY; 42 return MP_OKAY;
43 } 43 }
44 } 44 }
45 45
58 return err; 58 return err;
59 } 59 }
60 60
61 for (ix = 0; ix < t; ix++) { 61 for (ix = 0; ix < t; ix++) {
62 /* set the prime */ 62 /* set the prime */
63 mp_set (&b, __prime_tab[ix]); 63 mp_set (&b, ltm_prime_tab[ix]);
64 64
65 if ((err = mp_prime_miller_rabin (a, &b, &res)) != MP_OKAY) { 65 if ((err = mp_prime_miller_rabin (a, &b, &res)) != MP_OKAY) {
66 goto __B; 66 goto LBL_B;
67 } 67 }
68 68
69 if (res == MP_NO) { 69 if (res == MP_NO) {
70 goto __B; 70 goto LBL_B;
71 } 71 }
72 } 72 }
73 73
74 /* passed the test */ 74 /* passed the test */
75 *result = MP_YES; 75 *result = MP_YES;
76 __B:mp_clear (&b); 76 LBL_B:mp_clear (&b);
77 return err; 77 return err;
78 } 78 }
79 #endif 79 #endif