Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 42 lines (37 sloc) 0.93 kb
e549ccf added libtommath-0.32
Tom St Denis authored
1 #include <tommath.h>
2 #ifdef BN_MP_ADDMOD_C
57354e1 added libtommath-0.12
Tom St Denis authored
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis
4 *
c1da6aa added libtommath-0.25
Tom St Denis authored
5 * LibTomMath is a library that provides multiple-precision
57354e1 added libtommath-0.12
Tom St Denis authored
6 * integer arithmetic as well as number theoretic functionality.
7 *
c1da6aa added libtommath-0.25
Tom St Denis authored
8 * The library was designed directly after the MPI library by
57354e1 added libtommath-0.12
Tom St Denis authored
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 *
333aebc added libtommath-0.41
Tom St Denis authored
15 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
57354e1 added libtommath-0.12
Tom St Denis authored
16 */
17
18 /* d = a + b (mod c) */
19 int
20 mp_addmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
21 {
b66471f added libtommath-0.13
Tom St Denis authored
22 int res;
23 mp_int t;
57354e1 added libtommath-0.12
Tom St Denis authored
24
25 if ((res = mp_init (&t)) != MP_OKAY) {
26 return res;
27 }
28
29 if ((res = mp_add (a, b, &t)) != MP_OKAY) {
30 mp_clear (&t);
31 return res;
32 }
33 res = mp_mod (&t, c, d);
34 mp_clear (&t);
35 return res;
36 }
e549ccf added libtommath-0.32
Tom St Denis authored
37 #endif
9294e79 added libtommath-0.36
Tom St Denis authored
38
39 /* $Source$ */
40 /* $Revision$ */
41 /* $Date$ */
Something went wrong with that request. Please try again.