Debian Codegraph @

lib/hcrypto/libtommath/bn_mp_prime_fermat.c

raw symbols SCIP
1 #cxx . . $ `<file>/lib/hcrypto/libtommath/bn_mp_prime_fermat.c`/include <tommath.h>cxx . . $ `<file>/lib/hcrypto/libtommath/tommath.h`/
2 #ifdef BN_MP_PRIME_FERMAT_Ccxx . . $ `lib/hcrypto/libtommath/tommath_class.h:80:9`!
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis
4 *
5 * LibTomMath is a library that provides multiple-precision
6 * integer arithmetic as well as number theoretic functionality.
7 *
8 * The library was designed directly after the MPI library by
9 * Michael Fromberger but has been written from scratch with
10 * additional optimizations in place.
11 *
12 * The library is free for all purposes without any express
13 * guarantee it works.
14 *
15 * Tom St Denis, [email protected], http://libtom.org
16 */
17
18 /* performs one Fermat test.
19 *
20 * If "a" were prime then b**a == b (mod a) since the order of
21 * the multiplicative sub-group would be phi(a) = a-1. That means
22 * it would be the same as b**(a mod (a-1)) == b**1 == b (mod a).
23 *
24 * Sets result to 1 if the congruence holds, or zero otherwise.
25 */
26 int mp_prime_fermatcxx . . $ mp_prime_fermat(36a3a65a859a5b82). (mp_intcxx . . $ mp_int# * a, mp_intcxx . . $ mp_int# * b, int *result)
27 {
28 mp_intcxx . . $ mp_int# t;
29 int err;
30
31 /* default to composite */
32 *result = MP_NOcxx . . $ `lib/hcrypto/libtommath/tommath.h:148:9`!;
33
34 /* ensure b > 1 */
35 if (mp_cmp_dcxx . . $ mp_cmp_d(b5b2c7102e233a3f).(b, 1) != MP_GTcxx . . $ `lib/hcrypto/libtommath/tommath.h:137:9`!) {
36 return MP_VALcxx . . $ `lib/hcrypto/libtommath/tommath.h:144:9`!;
37 }
38
39 /* init t */
40 if ((err = mp_initcxx . . $ mp_init(c11792386c92c0f8). (&t)) != MP_OKAYcxx . . $ `lib/hcrypto/libtommath/tommath.h:142:9`!) {
41 return err;
42 }
43
44 /* compute t = b**a mod a */
45 if ((err = mp_exptmodcxx . . $ mp_exptmod(fd4ad6881c769929). (b, a, a, &t)) != MP_OKAYcxx . . $ `lib/hcrypto/libtommath/tommath.h:142:9`!) {
46 goto LBL_T;
47 }
48
49 /* is it equal to b? */
50 if (mp_cmpcxx . . $ mp_cmp(90c7f7e4c7870e62). (&t, b) == MP_EQcxx . . $ `lib/hcrypto/libtommath/tommath.h:136:9`!) {
51 *result = MP_YEScxx . . $ `lib/hcrypto/libtommath/tommath.h:147:9`!;
52 }
53
54 err = MP_OKAYcxx . . $ `lib/hcrypto/libtommath/tommath.h:142:9`!;
55 LBL_T:mp_clearcxx . . $ mp_clear(31834e326202325c). (&t);
56 return err;
57 }
58 #endif
59
60 /* $Source: /cvs/libtom/libtommath/bn_mp_prime_fermat.c,v $ */
61 /* $Revision: 1.4 $ */
62 /* $Date: 2006/12/28 01:25:13 $ */