| OLD | NEW |
| 1 /* | 1 /* |
| 2 * mpprime.c | 2 * mpprime.c |
| 3 * | 3 * |
| 4 * Utilities for finding and working with prime and pseudo-prime | 4 * Utilities for finding and working with prime and pseudo-prime |
| 5 * integers | 5 * integers |
| 6 * | 6 * |
| 7 * This Source Code Form is subject to the terms of the Mozilla Public | 7 * This Source Code Form is subject to the terms of the Mozilla Public |
| 8 * License, v. 2.0. If a copy of the MPL was not distributed with this | 8 * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 9 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 9 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 10 | 10 |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 | 290 |
| 291 MP_CHECKOK( mp_init_size(&x, MP_USED(a)) ); | 291 MP_CHECKOK( mp_init_size(&x, MP_USED(a)) ); |
| 292 MP_CHECKOK( mp_init(&z) ); | 292 MP_CHECKOK( mp_init(&z) ); |
| 293 MP_CHECKOK( mp_init(&m) ); | 293 MP_CHECKOK( mp_init(&m) ); |
| 294 MP_CHECKOK( mp_div_2d(&amo, b, &m, 0) ); | 294 MP_CHECKOK( mp_div_2d(&amo, b, &m, 0) ); |
| 295 | 295 |
| 296 /* Do the test nt times... */ | 296 /* Do the test nt times... */ |
| 297 for(iter = 0; iter < nt; iter++) { | 297 for(iter = 0; iter < nt; iter++) { |
| 298 | 298 |
| 299 /* Choose a random value for 1 < x < a */ | 299 /* Choose a random value for 1 < x < a */ |
| 300 s_mp_pad(&x, USED(a)); | 300 MP_CHECKOK( s_mp_pad(&x, USED(a)) ); |
| 301 mpp_random(&x); | 301 mpp_random(&x); |
| 302 MP_CHECKOK( mp_mod(&x, a, &x) ); | 302 MP_CHECKOK( mp_mod(&x, a, &x) ); |
| 303 if(mp_cmp_d(&x, 1) <= 0) { | 303 if(mp_cmp_d(&x, 1) <= 0) { |
| 304 iter--; /* don't count this iteration */ | 304 iter--; /* don't count this iteration */ |
| 305 continue; /* choose a new x */ | 305 continue; /* choose a new x */ |
| 306 } | 306 } |
| 307 | 307 |
| 308 /* Compute z = (x ** m) mod a */ | 308 /* Compute z = (x ** m) mod a */ |
| 309 MP_CHECKOK( mp_exptmod(&x, &m, a, &z) ); | 309 MP_CHECKOK( mp_exptmod(&x, &m, a, &z) ); |
| 310 | 310 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 } | 575 } |
| 576 | 576 |
| 577 return MP_NO; | 577 return MP_NO; |
| 578 | 578 |
| 579 } /* end s_mpp_divp() */ | 579 } /* end s_mpp_divp() */ |
| 580 | 580 |
| 581 /* }}} */ | 581 /* }}} */ |
| 582 | 582 |
| 583 /*------------------------------------------------------------------------*/ | 583 /*------------------------------------------------------------------------*/ |
| 584 /* HERE THERE BE DRAGONS */ | 584 /* HERE THERE BE DRAGONS */ |
| OLD | NEW |