Skip to content
Snippets Groups Projects
Commit ea8cd283 authored by Matt Johnston's avatar Matt Johnston
Browse files

Update to LibTomMath 0.40

--HG--
branch : libtommath-orig
extra : convert_revision : 1c2b7d389d0682caf980235dad97493e3206389c
parent 1c5fda51
No related branches found
No related tags found
No related merge requests found
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.
\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}
No preview for this file type
\documentclass[b5paper]{book}
\documentclass[synpaper]{book}
\usepackage{hyperref}
\usepackage{makeidx}
\usepackage{amssymb}
Loading
Loading
@@ -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.
Loading
Loading
Loading
Loading
@@ -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 {
Loading
Loading
@@ -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 $ */
Loading
Loading
@@ -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,
Loading
Loading
@@ -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 $ */
Loading
Loading
@@ -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
Loading
Loading
@@ -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 $ */
Loading
Loading
@@ -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
Loading
Loading
@@ -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 */
Loading
Loading
@@ -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;
Loading
Loading
@@ -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 $ */
Loading
Loading
@@ -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
Loading
Loading
@@ -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;
Loading
Loading
@@ -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];
}
Loading
Loading
@@ -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 $ */
Loading
Loading
@@ -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...
Loading
Loading
@@ -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 $ */
Loading
Loading
@@ -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
Loading
Loading
@@ -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 $ */
Loading
Loading
@@ -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|
Loading
Loading
@@ -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 $ */
Loading
Loading
@@ -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) */
Loading
Loading
@@ -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 $ */
Loading
Loading
@@ -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 */
Loading
Loading
@@ -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;
}
 
Loading
Loading
@@ -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 $ */
Loading
Loading
@@ -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) */
Loading
Loading
@@ -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 $ */
Loading
Loading
@@ -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 */
Loading
Loading
@@ -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 $ */
Loading
Loading
@@ -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
Loading
Loading
@@ -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 $ */
Loading
Loading
@@ -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) */
Loading
Loading
@@ -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 $ */
Loading
Loading
@@ -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>
 
Loading
Loading
@@ -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 $ */
Loading
Loading
@@ -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)*/
Loading
Loading
@@ -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 $ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment