mirror of
https://github.com/clearml/dropbear
synced 2025-04-15 21:11:19 +00:00
Update to LibTomMath 0.40
--HG-- branch : libtommath-orig extra : convert_revision : 1c2b7d389d0682caf980235dad97493e3206389c
This commit is contained in:
parent
1c5fda515f
commit
ea8cd283eb
16
TODO
16
TODO
@ -1,16 +0,0 @@
|
||||
things for book in order of importance...
|
||||
|
||||
- Fix up pseudo-code [only] for combas that are not consistent with source
|
||||
- Start in chapter 3 [basics] and work up...
|
||||
- re-write to prose [less abrupt]
|
||||
- clean up pseudo code [spacing]
|
||||
- more examples where appropriate and figures
|
||||
|
||||
Goal:
|
||||
- Get sync done by mid January [roughly 8-12 hours work]
|
||||
- Finish ch3-6 by end of January [roughly 12-16 hours of work]
|
||||
- Finish ch7-end by mid Feb [roughly 20-24 hours of work].
|
||||
|
||||
Goal isn't "first edition" but merely cleaner to read.
|
||||
|
||||
|
130
bn.ind
130
bn.ind
@ -1,82 +1,82 @@
|
||||
\begin{theindex}
|
||||
|
||||
\item mp\_add, \hyperpage{29}
|
||||
\item mp\_add\_d, \hyperpage{52}
|
||||
\item mp\_and, \hyperpage{29}
|
||||
\item mp\_clear, \hyperpage{11}
|
||||
\item mp\_clear\_multi, \hyperpage{12}
|
||||
\item mp\_cmp, \hyperpage{24}
|
||||
\item mp\_cmp\_d, \hyperpage{25}
|
||||
\item mp\_add, \hyperpage{31}
|
||||
\item mp\_add\_d, \hyperpage{56}
|
||||
\item mp\_and, \hyperpage{31}
|
||||
\item mp\_clear, \hyperpage{12}
|
||||
\item mp\_clear\_multi, \hyperpage{13}
|
||||
\item mp\_cmp, \hyperpage{25}
|
||||
\item mp\_cmp\_d, \hyperpage{26}
|
||||
\item mp\_cmp\_mag, \hyperpage{23}
|
||||
\item mp\_div, \hyperpage{30}
|
||||
\item mp\_div\_2, \hyperpage{26}
|
||||
\item mp\_div\_2d, \hyperpage{28}
|
||||
\item mp\_div\_d, \hyperpage{52}
|
||||
\item mp\_dr\_reduce, \hyperpage{40}
|
||||
\item mp\_dr\_setup, \hyperpage{40}
|
||||
\item MP\_EQ, \hyperpage{22}
|
||||
\item mp\_error\_to\_string, \hyperpage{10}
|
||||
\item mp\_expt\_d, \hyperpage{43}
|
||||
\item mp\_exptmod, \hyperpage{43}
|
||||
\item mp\_exteuclid, \hyperpage{51}
|
||||
\item mp\_gcd, \hyperpage{51}
|
||||
\item mp\_div, \hyperpage{32}
|
||||
\item mp\_div\_2, \hyperpage{28}
|
||||
\item mp\_div\_2d, \hyperpage{30}
|
||||
\item mp\_div\_d, \hyperpage{56}
|
||||
\item mp\_dr\_reduce, \hyperpage{45}
|
||||
\item mp\_dr\_setup, \hyperpage{45}
|
||||
\item MP\_EQ, \hyperpage{23}
|
||||
\item mp\_error\_to\_string, \hyperpage{9}
|
||||
\item mp\_expt\_d, \hyperpage{47}
|
||||
\item mp\_exptmod, \hyperpage{47}
|
||||
\item mp\_exteuclid, \hyperpage{55}
|
||||
\item mp\_gcd, \hyperpage{55}
|
||||
\item mp\_get\_int, \hyperpage{20}
|
||||
\item mp\_grow, \hyperpage{16}
|
||||
\item MP\_GT, \hyperpage{22}
|
||||
\item mp\_grow, \hyperpage{17}
|
||||
\item MP\_GT, \hyperpage{23}
|
||||
\item mp\_init, \hyperpage{11}
|
||||
\item mp\_init\_copy, \hyperpage{13}
|
||||
\item mp\_init\_multi, \hyperpage{12}
|
||||
\item mp\_init\_copy, \hyperpage{14}
|
||||
\item mp\_init\_multi, \hyperpage{13}
|
||||
\item mp\_init\_set, \hyperpage{21}
|
||||
\item mp\_init\_set\_int, \hyperpage{21}
|
||||
\item mp\_init\_size, \hyperpage{14}
|
||||
\item mp\_init\_size, \hyperpage{15}
|
||||
\item mp\_int, \hyperpage{10}
|
||||
\item mp\_invmod, \hyperpage{52}
|
||||
\item mp\_jacobi, \hyperpage{52}
|
||||
\item mp\_lcm, \hyperpage{51}
|
||||
\item mp\_lshd, \hyperpage{28}
|
||||
\item MP\_LT, \hyperpage{22}
|
||||
\item mp\_invmod, \hyperpage{56}
|
||||
\item mp\_jacobi, \hyperpage{56}
|
||||
\item mp\_lcm, \hyperpage{56}
|
||||
\item mp\_lshd, \hyperpage{30}
|
||||
\item MP\_LT, \hyperpage{23}
|
||||
\item MP\_MEM, \hyperpage{9}
|
||||
\item mp\_mod, \hyperpage{35}
|
||||
\item mp\_mod\_d, \hyperpage{52}
|
||||
\item mp\_montgomery\_calc\_normalization, \hyperpage{38}
|
||||
\item mp\_montgomery\_reduce, \hyperpage{37}
|
||||
\item mp\_montgomery\_setup, \hyperpage{37}
|
||||
\item mp\_mul, \hyperpage{31}
|
||||
\item mp\_mul\_2, \hyperpage{26}
|
||||
\item mp\_mul\_2d, \hyperpage{28}
|
||||
\item mp\_mul\_d, \hyperpage{52}
|
||||
\item mp\_n\_root, \hyperpage{44}
|
||||
\item mp\_neg, \hyperpage{29}
|
||||
\item mp\_mod, \hyperpage{39}
|
||||
\item mp\_mod\_d, \hyperpage{56}
|
||||
\item mp\_montgomery\_calc\_normalization, \hyperpage{42}
|
||||
\item mp\_montgomery\_reduce, \hyperpage{42}
|
||||
\item mp\_montgomery\_setup, \hyperpage{42}
|
||||
\item mp\_mul, \hyperpage{33}
|
||||
\item mp\_mul\_2, \hyperpage{28}
|
||||
\item mp\_mul\_2d, \hyperpage{29}
|
||||
\item mp\_mul\_d, \hyperpage{56}
|
||||
\item mp\_n\_root, \hyperpage{48}
|
||||
\item mp\_neg, \hyperpage{31, 32}
|
||||
\item MP\_NO, \hyperpage{9}
|
||||
\item MP\_OKAY, \hyperpage{9}
|
||||
\item mp\_or, \hyperpage{29}
|
||||
\item mp\_prime\_fermat, \hyperpage{45}
|
||||
\item mp\_prime\_is\_divisible, \hyperpage{45}
|
||||
\item mp\_prime\_is\_prime, \hyperpage{46}
|
||||
\item mp\_prime\_miller\_rabin, \hyperpage{45}
|
||||
\item mp\_prime\_next\_prime, \hyperpage{46}
|
||||
\item mp\_prime\_rabin\_miller\_trials, \hyperpage{46}
|
||||
\item mp\_prime\_random, \hyperpage{47}
|
||||
\item mp\_prime\_random\_ex, \hyperpage{47}
|
||||
\item mp\_radix\_size, \hyperpage{49}
|
||||
\item mp\_read\_radix, \hyperpage{49}
|
||||
\item mp\_read\_unsigned\_bin, \hyperpage{50}
|
||||
\item mp\_reduce, \hyperpage{36}
|
||||
\item mp\_reduce\_2k, \hyperpage{41}
|
||||
\item mp\_reduce\_2k\_setup, \hyperpage{41}
|
||||
\item mp\_reduce\_setup, \hyperpage{36}
|
||||
\item mp\_rshd, \hyperpage{28}
|
||||
\item mp\_or, \hyperpage{31}
|
||||
\item mp\_prime\_fermat, \hyperpage{49}
|
||||
\item mp\_prime\_is\_divisible, \hyperpage{49}
|
||||
\item mp\_prime\_is\_prime, \hyperpage{51}
|
||||
\item mp\_prime\_miller\_rabin, \hyperpage{50}
|
||||
\item mp\_prime\_next\_prime, \hyperpage{51}
|
||||
\item mp\_prime\_rabin\_miller\_trials, \hyperpage{50}
|
||||
\item mp\_prime\_random, \hyperpage{51}
|
||||
\item mp\_prime\_random\_ex, \hyperpage{52}
|
||||
\item mp\_radix\_size, \hyperpage{53}
|
||||
\item mp\_read\_radix, \hyperpage{53}
|
||||
\item mp\_read\_unsigned\_bin, \hyperpage{54}
|
||||
\item mp\_reduce, \hyperpage{40}
|
||||
\item mp\_reduce\_2k, \hyperpage{46}
|
||||
\item mp\_reduce\_2k\_setup, \hyperpage{46}
|
||||
\item mp\_reduce\_setup, \hyperpage{40}
|
||||
\item mp\_rshd, \hyperpage{30}
|
||||
\item mp\_set, \hyperpage{19}
|
||||
\item mp\_set\_int, \hyperpage{20}
|
||||
\item mp\_shrink, \hyperpage{15}
|
||||
\item mp\_sqr, \hyperpage{33}
|
||||
\item mp\_sub, \hyperpage{29}
|
||||
\item mp\_sub\_d, \hyperpage{52}
|
||||
\item mp\_to\_unsigned\_bin, \hyperpage{50}
|
||||
\item mp\_toradix, \hyperpage{49}
|
||||
\item mp\_unsigned\_bin\_size, \hyperpage{50}
|
||||
\item mp\_shrink, \hyperpage{16}
|
||||
\item mp\_sqr, \hyperpage{35}
|
||||
\item mp\_sub, \hyperpage{31}
|
||||
\item mp\_sub\_d, \hyperpage{56}
|
||||
\item mp\_to\_unsigned\_bin, \hyperpage{54}
|
||||
\item mp\_toradix, \hyperpage{53}
|
||||
\item mp\_unsigned\_bin\_size, \hyperpage{54}
|
||||
\item MP\_VAL, \hyperpage{9}
|
||||
\item mp\_xor, \hyperpage{29}
|
||||
\item mp\_xor, \hyperpage{31}
|
||||
\item MP\_YES, \hyperpage{9}
|
||||
|
||||
\end{theindex}
|
||||
|
6
bn.tex
6
bn.tex
@ -1,4 +1,4 @@
|
||||
\documentclass[b5paper]{book}
|
||||
\documentclass[synpaper]{book}
|
||||
\usepackage{hyperref}
|
||||
\usepackage{makeidx}
|
||||
\usepackage{amssymb}
|
||||
@ -49,8 +49,8 @@
|
||||
\begin{document}
|
||||
\frontmatter
|
||||
\pagestyle{empty}
|
||||
\title{LibTomMath User Manual \\ v0.35}
|
||||
\author{Tom St Denis \\ tomstdenis@iahu.ca}
|
||||
\title{LibTomMath User Manual \\ v0.40}
|
||||
\author{Tom St Denis \\ tomstdenis@gmail.com}
|
||||
\maketitle
|
||||
This text, the library and the accompanying textbook are all hereby placed in the public domain. This book has been
|
||||
formatted for B5 [176x250] paper using the \LaTeX{} {\em book} macro package.
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
static const struct {
|
||||
@ -41,3 +41,7 @@ char *mp_error_to_string(int code)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_error.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* computes the modular inverse via binary extended euclidean algorithm,
|
||||
@ -142,3 +142,7 @@ LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &B, &D, NULL);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_fast_mp_invmod.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* computes xR**-1 == x (mod N) via Montgomery Reduction
|
||||
@ -166,3 +166,7 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_fast_mp_montgomery_reduce.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* Fast (comba) multiplier
|
||||
@ -70,6 +70,7 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
||||
/* execute loop */
|
||||
for (iz = 0; iz < iy; ++iz) {
|
||||
_W += ((mp_word)*tmpx++)*((mp_word)*tmpy--);
|
||||
|
||||
}
|
||||
|
||||
/* store term */
|
||||
@ -77,10 +78,7 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
||||
|
||||
/* make next carry */
|
||||
_W = _W >> ((mp_word)DIGIT_BIT);
|
||||
}
|
||||
|
||||
/* store final carry */
|
||||
W[ix] = (mp_digit)(_W & MP_MASK);
|
||||
}
|
||||
|
||||
/* setup dest */
|
||||
olduse = c->used;
|
||||
@ -103,3 +101,7 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_mul_digs.c,v $ */
|
||||
/* $Revision: 1.7 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* this is a modified version of fast_s_mul_digs that only produces
|
||||
@ -70,9 +70,6 @@ int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
||||
_W = _W >> ((mp_word)DIGIT_BIT);
|
||||
}
|
||||
|
||||
/* store final carry */
|
||||
W[ix] = (mp_digit)(_W & MP_MASK);
|
||||
|
||||
/* setup dest */
|
||||
olduse = c->used;
|
||||
c->used = pa;
|
||||
@ -81,7 +78,7 @@ int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
||||
register mp_digit *tmpc;
|
||||
|
||||
tmpc = c->dp + digs;
|
||||
for (ix = digs; ix <= pa; ix++) {
|
||||
for (ix = digs; ix < pa; ix++) {
|
||||
/* now extract the previous digit [below the carry] */
|
||||
*tmpc++ = W[ix];
|
||||
}
|
||||
@ -95,3 +92,7 @@ int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_mul_high_digs.c,v $ */
|
||||
/* $Revision: 1.5 $ */
|
||||
/* $Date: 2006/11/14 03:46:25 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* the jist of squaring...
|
||||
@ -108,3 +108,7 @@ int fast_s_mp_sqr (mp_int * a, mp_int * b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_sqr.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* computes a = 2**b
|
||||
@ -42,3 +42,7 @@ mp_2expt (mp_int * a, int b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_2expt.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* b = |a|
|
||||
@ -37,3 +37,7 @@ mp_abs (mp_int * a, mp_int * b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_abs.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* high level addition (handles signs) */
|
||||
@ -47,3 +47,7 @@ int mp_add (mp_int * a, mp_int * b, mp_int * c)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_add.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* single digit addition */
|
||||
@ -40,6 +40,9 @@ mp_add_d (mp_int * a, mp_digit b, mp_int * c)
|
||||
/* fix sign */
|
||||
a->sign = c->sign = MP_NEG;
|
||||
|
||||
/* clamp */
|
||||
mp_clamp(c);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -103,3 +106,7 @@ mp_add_d (mp_int * a, mp_digit b, mp_int * c)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_add_d.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* d = a + b (mod c) */
|
||||
@ -35,3 +35,7 @@ mp_addmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_addmod.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* AND two ints together */
|
||||
@ -51,3 +51,7 @@ mp_and (mp_int * a, mp_int * b, mp_int * c)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_and.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* trim unused digits
|
||||
@ -38,3 +38,7 @@ mp_clamp (mp_int * a)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_clamp.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* clear one (frees) */
|
||||
@ -38,3 +38,7 @@ mp_clear (mp_int * a)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_clear.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
|
||||
@ -28,3 +28,7 @@ void mp_clear_multi(mp_int *mp, ...)
|
||||
va_end(args);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_clear_multi.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* compare two ints (signed)*/
|
||||
@ -37,3 +37,7 @@ mp_cmp (mp_int * a, mp_int * b)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_cmp.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* compare a digit */
|
||||
@ -38,3 +38,7 @@ int mp_cmp_d(mp_int * a, mp_digit b)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_cmp_d.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* compare maginitude of two ints (unsigned) */
|
||||
@ -49,3 +49,7 @@ int mp_cmp_mag (mp_int * a, mp_int * b)
|
||||
return MP_EQ;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_cmp_mag.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
static const int lnz[16] = {
|
||||
@ -47,3 +47,7 @@ int mp_cnt_lsb(mp_int *a)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_cnt_lsb.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* copy, b = a */
|
||||
@ -62,3 +62,7 @@ mp_copy (mp_int * a, mp_int * b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_copy.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* returns the number of bits in an int */
|
||||
@ -39,3 +39,7 @@ mp_count_bits (mp_int * a)
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_count_bits.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
#ifdef BN_MP_DIV_SMALL
|
||||
@ -286,3 +286,7 @@ LBL_Q:mp_clear (&q);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_div.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* b = a/2 */
|
||||
@ -62,3 +62,7 @@ int mp_div_2(mp_int * a, mp_int * b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_div_2.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* shift right by a certain bit count (store quotient in c, optional remainder in d) */
|
||||
@ -91,3 +91,7 @@ int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_div_2d.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* divide by three (based on routine from MPI and the GMP manual) */
|
||||
@ -73,3 +73,7 @@ mp_div_3 (mp_int * a, mp_int *c, mp_digit * d)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_div_3.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
static int s_is_power_of_two(mp_digit b, int *p)
|
||||
@ -104,3 +104,7 @@ int mp_div_d (mp_int * a, mp_digit b, mp_int * c, mp_digit * d)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_div_d.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* determines if a number is a valid DR modulus */
|
||||
@ -37,3 +37,7 @@ int mp_dr_is_modulus(mp_int *a)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_dr_is_modulus.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* reduce "x" in place modulo "n" using the Diminished Radix algorithm.
|
||||
@ -88,3 +88,7 @@ top:
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_dr_reduce.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* determines the setup value */
|
||||
@ -26,3 +26,7 @@ void mp_dr_setup(mp_int *a, mp_digit *d)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_dr_setup.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* swap the elements of two integers, for cases where you can't simply swap the
|
||||
@ -28,3 +28,7 @@ mp_exch (mp_int * a, mp_int * b)
|
||||
*b = t;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_exch.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* calculate c = a**b using a square-multiply algorithm */
|
||||
@ -51,3 +51,7 @@ int mp_expt_d (mp_int * a, mp_digit b, mp_int * c)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_expt_d.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
|
||||
@ -66,7 +66,7 @@ int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y)
|
||||
}
|
||||
|
||||
/* modified diminished radix reduction */
|
||||
#if defined(BN_MP_REDUCE_IS_2K_L_C) && defined(BN_MP_REDUCE_2K_L_C)
|
||||
#if defined(BN_MP_REDUCE_IS_2K_L_C) && defined(BN_MP_REDUCE_2K_L_C) && defined(BN_S_MP_EXPTMOD_C)
|
||||
if (mp_reduce_is_2k_l(P) == MP_YES) {
|
||||
return s_mp_exptmod(G, X, P, Y, 1);
|
||||
}
|
||||
@ -106,3 +106,7 @@ int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_exptmod.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* computes Y == G**X mod P, HAC pp.616, Algorithm 14.85
|
||||
@ -315,3 +315,7 @@ LBL_M:
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_exptmod_fast.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* Extended euclidean algorithm of (a, b) produces
|
||||
@ -76,3 +76,7 @@ _ERR: mp_clear_multi(&u1, &u2, &u3, &v1, &v2, &v3, &t1, &t2, &t3, &q, &tmp, NULL
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_exteuclid.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* read a bigint from a file stream in ASCII */
|
||||
@ -61,3 +61,7 @@ int mp_fread(mp_int *a, int radix, FILE *stream)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_fread.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
int mp_fwrite(mp_int *a, int radix, FILE *stream)
|
||||
@ -46,3 +46,7 @@ int mp_fwrite(mp_int *a, int radix, FILE *stream)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_fwrite.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
18
bn_mp_gcd.c
18
bn_mp_gcd.c
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* Greatest Common Divisor using the binary method */
|
||||
@ -22,21 +22,13 @@ int mp_gcd (mp_int * a, mp_int * b, mp_int * c)
|
||||
int k, u_lsb, v_lsb, res;
|
||||
|
||||
/* either zero than gcd is the largest */
|
||||
if (mp_iszero (a) == 1 && mp_iszero (b) == 0) {
|
||||
if (mp_iszero (a) == MP_YES) {
|
||||
return mp_abs (b, c);
|
||||
}
|
||||
if (mp_iszero (a) == 0 && mp_iszero (b) == 1) {
|
||||
if (mp_iszero (b) == MP_YES) {
|
||||
return mp_abs (a, c);
|
||||
}
|
||||
|
||||
/* optimized. At this point if a == 0 then
|
||||
* b must equal zero too
|
||||
*/
|
||||
if (mp_iszero (a) == 1) {
|
||||
mp_zero(c);
|
||||
return MP_OKAY;
|
||||
}
|
||||
|
||||
/* get copies of a and b we can modify */
|
||||
if ((res = mp_init_copy (&u, a)) != MP_OKAY) {
|
||||
return res;
|
||||
@ -107,3 +99,7 @@ LBL_U:mp_clear (&v);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_gcd.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* get the lower 32-bits of an mp_int */
|
||||
@ -39,3 +39,7 @@ unsigned long mp_get_int(mp_int * a)
|
||||
return res & 0xFFFFFFFFUL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_get_int.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* grow as required */
|
||||
@ -51,3 +51,7 @@ int mp_grow (mp_int * a, int size)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_grow.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* init a new mp_int */
|
||||
@ -40,3 +40,7 @@ int mp_init (mp_int * a)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_init.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* creates "a" then copies b into it */
|
||||
@ -26,3 +26,7 @@ int mp_init_copy (mp_int * a, mp_int * b)
|
||||
return mp_copy (b, a);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_init_copy.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
|
||||
@ -53,3 +53,7 @@ int mp_init_multi(mp_int *mp, ...)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_init_multi.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* initialize and set a digit */
|
||||
@ -26,3 +26,7 @@ int mp_init_set (mp_int * a, mp_digit b)
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_init_set.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* initialize and set a digit */
|
||||
@ -25,3 +25,7 @@ int mp_init_set_int (mp_int * a, unsigned long b)
|
||||
return mp_set_int(a, b);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_init_set_int.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* init an mp_init for a given size */
|
||||
@ -42,3 +42,7 @@ int mp_init_size (mp_int * a, int size)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_init_size.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* hac 14.61, pp608 */
|
||||
@ -37,3 +37,7 @@ int mp_invmod (mp_int * a, mp_int * b, mp_int * c)
|
||||
return MP_VAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_invmod.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* hac 14.61, pp608 */
|
||||
@ -169,3 +169,7 @@ LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &A, &B, &C, &D, NULL);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_invmod_slow.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* Check if remainders are possible squares - fast exclude non-squares */
|
||||
@ -103,3 +103,7 @@ ERR:mp_clear(&t);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_is_square.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* computes the jacobi c = (a | n) (or Legendre if n is prime)
|
||||
@ -99,3 +99,7 @@ LBL_A1:mp_clear (&a1);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_jacobi.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* c = |a| * |b| using Karatsuba Multiplication using
|
||||
@ -26,12 +26,12 @@
|
||||
* b = b1 * B**n + b0
|
||||
*
|
||||
* Then, a * b =>
|
||||
a1b1 * B**2n + ((a1 - a0)(b1 - b0) + a0b0 + a1b1) * B + a0b0
|
||||
a1b1 * B**2n + ((a1 + a0)(b1 + b0) - (a0b0 + a1b1)) * B + a0b0
|
||||
*
|
||||
* Note that a1b1 and a0b0 are used twice and only need to be
|
||||
* computed once. So in total three half size (half # of
|
||||
* digit) multiplications are performed, a0b0, a1b1 and
|
||||
* (a1-b1)(a0-b0)
|
||||
* (a1+b1)(a0+b0)
|
||||
*
|
||||
* Note that a multiplication of half the digits requires
|
||||
* 1/4th the number of single precision multiplications so in
|
||||
@ -122,19 +122,19 @@ int mp_karatsuba_mul (mp_int * a, mp_int * b, mp_int * c)
|
||||
if (mp_mul (&x1, &y1, &x1y1) != MP_OKAY)
|
||||
goto X1Y1; /* x1y1 = x1*y1 */
|
||||
|
||||
/* now calc x1-x0 and y1-y0 */
|
||||
if (mp_sub (&x1, &x0, &t1) != MP_OKAY)
|
||||
/* now calc x1+x0 and y1+y0 */
|
||||
if (s_mp_add (&x1, &x0, &t1) != MP_OKAY)
|
||||
goto X1Y1; /* t1 = x1 - x0 */
|
||||
if (mp_sub (&y1, &y0, &x0) != MP_OKAY)
|
||||
if (s_mp_add (&y1, &y0, &x0) != MP_OKAY)
|
||||
goto X1Y1; /* t2 = y1 - y0 */
|
||||
if (mp_mul (&t1, &x0, &t1) != MP_OKAY)
|
||||
goto X1Y1; /* t1 = (x1 - x0) * (y1 - y0) */
|
||||
goto X1Y1; /* t1 = (x1 + x0) * (y1 + y0) */
|
||||
|
||||
/* add x0y0 */
|
||||
if (mp_add (&x0y0, &x1y1, &x0) != MP_OKAY)
|
||||
goto X1Y1; /* t2 = x0y0 + x1y1 */
|
||||
if (mp_sub (&x0, &t1, &t1) != MP_OKAY)
|
||||
goto X1Y1; /* t1 = x0y0 + x1y1 - (x1-x0)*(y1-y0) */
|
||||
if (s_mp_sub (&t1, &x0, &t1) != MP_OKAY)
|
||||
goto X1Y1; /* t1 = (x1+x0)*(y1+y0) - (x1y1 + x0y0) */
|
||||
|
||||
/* shift by B */
|
||||
if (mp_lshd (&t1, B) != MP_OKAY)
|
||||
@ -161,3 +161,7 @@ ERR:
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_karatsuba_mul.c,v $ */
|
||||
/* $Revision: 1.5 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* Karatsuba squaring, computes b = a*a using three
|
||||
@ -80,8 +80,8 @@ int mp_karatsuba_sqr (mp_int * a, mp_int * b)
|
||||
if (mp_sqr (&x1, &x1x1) != MP_OKAY)
|
||||
goto X1X1; /* x1x1 = x1*x1 */
|
||||
|
||||
/* now calc (x1-x0)**2 */
|
||||
if (mp_sub (&x1, &x0, &t1) != MP_OKAY)
|
||||
/* now calc (x1+x0)**2 */
|
||||
if (s_mp_add (&x1, &x0, &t1) != MP_OKAY)
|
||||
goto X1X1; /* t1 = x1 - x0 */
|
||||
if (mp_sqr (&t1, &t1) != MP_OKAY)
|
||||
goto X1X1; /* t1 = (x1 - x0) * (x1 - x0) */
|
||||
@ -89,8 +89,8 @@ int mp_karatsuba_sqr (mp_int * a, mp_int * b)
|
||||
/* add x0y0 */
|
||||
if (s_mp_add (&x0x0, &x1x1, &t2) != MP_OKAY)
|
||||
goto X1X1; /* t2 = x0x0 + x1x1 */
|
||||
if (mp_sub (&t2, &t1, &t1) != MP_OKAY)
|
||||
goto X1X1; /* t1 = x0x0 + x1x1 - (x1-x0)*(x1-x0) */
|
||||
if (s_mp_sub (&t1, &t2, &t1) != MP_OKAY)
|
||||
goto X1X1; /* t1 = (x1+x0)**2 - (x0x0 + x1x1) */
|
||||
|
||||
/* shift by B */
|
||||
if (mp_lshd (&t1, B) != MP_OKAY)
|
||||
@ -115,3 +115,7 @@ ERR:
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_karatsuba_sqr.c,v $ */
|
||||
/* $Revision: 1.5 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* computes least common multiple as |a*b|/(a, b) */
|
||||
@ -54,3 +54,7 @@ LBL_T:
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_lcm.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* shift left a certain amount of digits */
|
||||
@ -61,3 +61,7 @@ int mp_lshd (mp_int * a, int b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_lshd.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* c = a mod b, 0 <= c < b */
|
||||
@ -42,3 +42,7 @@ mp_mod (mp_int * a, mp_int * b, mp_int * c)
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_mod.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* calc a value mod 2**b */
|
||||
@ -49,3 +49,7 @@ mp_mod_2d (mp_int * a, int b, mp_int * c)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_mod_2d.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
int
|
||||
@ -21,3 +21,7 @@ mp_mod_d (mp_int * a, mp_digit b, mp_digit * c)
|
||||
return mp_div_d(a, b, NULL, c);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_mod_d.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -53,3 +53,7 @@ int mp_montgomery_calc_normalization (mp_int * a, mp_int * b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_montgomery_calc_normalization.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* computes xR**-1 == x (mod N) via Montgomery Reduction */
|
||||
@ -112,3 +112,7 @@ mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_montgomery_reduce.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* setups the montgomery reduction stuff */
|
||||
@ -48,8 +48,12 @@ mp_montgomery_setup (mp_int * n, mp_digit * rho)
|
||||
#endif
|
||||
|
||||
/* rho = -1/m mod b */
|
||||
*rho = (((mp_word)1 << ((mp_word) DIGIT_BIT)) - x) & MP_MASK;
|
||||
*rho = (unsigned long)(((mp_word)1 << ((mp_word) DIGIT_BIT)) - x) & MP_MASK;
|
||||
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_montgomery_setup.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/12/04 21:34:03 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* high level multiplication (handles sign) */
|
||||
@ -60,3 +60,7 @@ int mp_mul (mp_int * a, mp_int * b, mp_int * c)
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_mul.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* b = a*2 */
|
||||
@ -76,3 +76,7 @@ int mp_mul_2(mp_int * a, mp_int * b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_mul_2.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* shift left by a certain bit count */
|
||||
@ -79,3 +79,7 @@ int mp_mul_2d (mp_int * a, int b, mp_int * c)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_mul_2d.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* multiply by a digit */
|
||||
@ -73,3 +73,7 @@ mp_mul_d (mp_int * a, mp_digit b, mp_int * c)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_mul_d.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,12 +12,11 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* d = a * b (mod c) */
|
||||
int
|
||||
mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
|
||||
int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
|
||||
{
|
||||
int res;
|
||||
mp_int t;
|
||||
@ -35,3 +34,7 @@ mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_mulmod.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* find the n'th root of an integer
|
||||
@ -126,3 +126,7 @@ LBL_T1:mp_clear (&t1);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_n_root.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* b = -a */
|
||||
@ -34,3 +34,7 @@ int mp_neg (mp_int * a, mp_int * b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_neg.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* OR two ints together */
|
||||
@ -44,3 +44,7 @@ int mp_or (mp_int * a, mp_int * b, mp_int * c)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_or.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* performs one Fermat test.
|
||||
@ -56,3 +56,7 @@ LBL_T:mp_clear (&t);
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_prime_fermat.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* determines if an integers is divisible by one
|
||||
@ -44,3 +44,7 @@ int mp_prime_is_divisible (mp_int * a, int *result)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_prime_is_divisible.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* performs a variable number of rounds of Miller-Rabin
|
||||
@ -77,3 +77,7 @@ LBL_B:mp_clear (&b);
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_prime_is_prime.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* Miller-Rabin test of "a" to the base of "b" as described in
|
||||
@ -97,3 +97,7 @@ LBL_N1:mp_clear (&n1);
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_prime_miller_rabin.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* finds the next prime after the number "a" using "t" trials
|
||||
@ -164,3 +164,7 @@ LBL_ERR:
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_prime_next_prime.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
|
||||
@ -46,3 +46,7 @@ int mp_prime_rabin_miller_trials(int size)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_prime_rabin_miller_trials.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* makes a truly random prime of a given size (bits),
|
||||
@ -62,10 +62,8 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
|
||||
maskOR_msb = 0;
|
||||
maskOR_msb_offset = ((size & 7) == 1) ? 1 : 0;
|
||||
if (flags & LTM_PRIME_2MSB_ON) {
|
||||
maskOR_msb |= 1 << ((size - 2) & 7);
|
||||
} else if (flags & LTM_PRIME_2MSB_OFF) {
|
||||
maskAND &= ~(1 << ((size - 2) & 7));
|
||||
}
|
||||
maskOR_msb |= 0x80 >> ((9 - size) & 7);
|
||||
}
|
||||
|
||||
/* get the maskOR_lsb */
|
||||
maskOR_lsb = 1;
|
||||
@ -121,3 +119,7 @@ error:
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_prime_random_ex.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* returns size of ASCII reprensentation */
|
||||
@ -36,7 +36,7 @@ int mp_radix_size (mp_int * a, int radix, int *size)
|
||||
}
|
||||
|
||||
if (mp_iszero(a) == MP_YES) {
|
||||
*size = 2;
|
||||
*size = 2;
|
||||
return MP_OKAY;
|
||||
}
|
||||
|
||||
@ -72,3 +72,7 @@ int mp_radix_size (mp_int * a, int radix, int *size)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_radix_size.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,9 +12,13 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* chars used in radix conversions */
|
||||
const char *mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_radix_smap.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* makes a pseudo-random int of a given size */
|
||||
@ -49,3 +49,7 @@ mp_rand (mp_int * a, int digits)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_rand.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* read a string [ASCII] in a given radix */
|
||||
@ -21,6 +21,9 @@ int mp_read_radix (mp_int * a, const char *str, int radix)
|
||||
int y, res, neg;
|
||||
char ch;
|
||||
|
||||
/* zero the digit bignum */
|
||||
mp_zero(a);
|
||||
|
||||
/* make sure the radix is ok */
|
||||
if (radix < 2 || radix > 64) {
|
||||
return MP_VAL;
|
||||
@ -76,3 +79,7 @@ int mp_read_radix (mp_int * a, const char *str, int radix)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_read_radix.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,12 +12,11 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* read signed bin, big endian, first byte is 0==positive or 1==negative */
|
||||
int
|
||||
mp_read_signed_bin (mp_int * a, unsigned char *b, int c)
|
||||
int mp_read_signed_bin (mp_int * a, const unsigned char *b, int c)
|
||||
{
|
||||
int res;
|
||||
|
||||
@ -36,3 +35,7 @@ mp_read_signed_bin (mp_int * a, unsigned char *b, int c)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_read_signed_bin.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,12 +12,11 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* reads a unsigned char array, assumes the msb is stored first [big endian] */
|
||||
int
|
||||
mp_read_unsigned_bin (mp_int * a, unsigned char *b, int c)
|
||||
int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c)
|
||||
{
|
||||
int res;
|
||||
|
||||
@ -50,3 +49,7 @@ mp_read_unsigned_bin (mp_int * a, unsigned char *b, int c)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_read_unsigned_bin.c,v $ */
|
||||
/* $Revision: 1.4 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* reduces x mod m, assumes 0 < x < m**2, mu is
|
||||
@ -94,3 +94,7 @@ CLEANUP:
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_reduce.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* reduces a modulo n where n is of the form 2**p - d */
|
||||
@ -55,3 +55,7 @@ ERR:
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* reduces a modulo n where n is of the form 2**p - d
|
||||
@ -56,3 +56,7 @@ ERR:
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k_l.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* determines the setup value */
|
||||
@ -41,3 +41,7 @@ int mp_reduce_2k_setup(mp_int *a, mp_digit *d)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k_setup.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* determines the setup value */
|
||||
@ -38,3 +38,7 @@ ERR:
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k_setup_l.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* determines if mp_reduce_2k can be used */
|
||||
@ -46,3 +46,7 @@ int mp_reduce_is_2k(mp_int *a)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_is_2k.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* determines if reduce_2k_l can be used */
|
||||
@ -38,3 +38,7 @@ int mp_reduce_is_2k_l(mp_int *a)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_is_2k_l.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* pre-calculate the value required for Barrett reduction
|
||||
@ -28,3 +28,7 @@ int mp_reduce_setup (mp_int * a, mp_int * b)
|
||||
return mp_div (a, b, a, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_setup.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* shift right a certain amount of digits */
|
||||
@ -66,3 +66,7 @@ void mp_rshd (mp_int * a, int b)
|
||||
a->used -= b;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_rshd.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* set to a digit */
|
||||
@ -23,3 +23,7 @@ void mp_set (mp_int * a, mp_digit b)
|
||||
a->used = (a->dp[0] != 0) ? 1 : 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_set.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* set a 32-bit const */
|
||||
@ -42,3 +42,7 @@ int mp_set_int (mp_int * a, unsigned long b)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_set_int.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* shrink a bignum */
|
||||
@ -29,3 +29,7 @@ int mp_shrink (mp_int * a)
|
||||
return MP_OKAY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_shrink.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* get the size for an signed equivalent */
|
||||
@ -21,3 +21,7 @@ int mp_signed_bin_size (mp_int * a)
|
||||
return 1 + mp_unsigned_bin_size (a);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_signed_bin_size.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* computes b = a*a */
|
||||
@ -52,3 +52,7 @@ if (a->used >= KARATSUBA_SQR_CUTOFF) {
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_sqr.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* c = a * a (mod b) */
|
||||
@ -35,3 +35,7 @@ mp_sqrmod (mp_int * a, mp_int * b, mp_int * c)
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_sqrmod.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
* Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
/* this function is less generic than mp_n_root, simpler and faster */
|
||||
@ -75,3 +75,7 @@ E2: mp_clear(&t1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source: /cvs/libtom/libtommath/bn_mp_sqrt.c,v $ */
|
||||
/* $Revision: 1.3 $ */
|
||||
/* $Date: 2006/03/31 14:18:44 $ */
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user