Skip to content

Commit

Permalink
added libtommath-0.39
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom St Denis authored and sjaeckel committed Jul 15, 2010
1 parent 21adca0 commit f0b91a5
Show file tree
Hide file tree
Showing 133 changed files with 474 additions and 4,674 deletions.
Binary file modified bn.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion bn.tex
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
\begin{document}
\frontmatter
\pagestyle{empty}
\title{LibTomMath User Manual \\ v0.38}
\title{LibTomMath User Manual \\ v0.39}
\author{Tom St Denis \\ [email protected]}
\maketitle
This text, the library and the accompanying textbook are all hereby placed in the public domain. This book has been
Expand Down
2 changes: 1 addition & 1 deletion bn_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion bn_fast_mp_invmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion bn_fast_mp_montgomery_reduce.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bn_fast_s_mp_mul_digs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bn_fast_s_mp_mul_high_digs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bn_fast_s_mp_sqr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_2expt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_abs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_add.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_add_d.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_addmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_and.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_clamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_clear.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_clear_multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion bn_mp_cmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)*/
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_cmp_d.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_cmp_mag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_cnt_lsb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_count_bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_div.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_div_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_div_2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_div_3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_div_d.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_dr_is_modulus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_dr_reduce.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_dr_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_exch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_expt_d.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_exptmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/


Expand Down
2 changes: 1 addition & 1 deletion bn_mp_exptmod_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_exteuclid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_fread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_fwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 3 additions & 11 deletions bn_mp_gcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_get_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_grow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
Loading

0 comments on commit f0b91a5

Please sign in to comment.