Permalink
Browse files

added libtommath-0.39

  • Loading branch information...
1 parent 21adca0 commit f0b91a572efd34bc8c6fbcd864e6c777ac4e1ece Tom St Denis committed with sjaeckel Apr 6, 2006
Showing with 474 additions and 4,674 deletions.
  1. BIN bn.pdf
  2. +1 −1 bn.tex
  3. +1 −1 bn_error.c
  4. +1 −1 bn_fast_mp_invmod.c
  5. +1 −1 bn_fast_mp_montgomery_reduce.c
  6. +1 −1 bn_fast_s_mp_mul_digs.c
  7. +1 −1 bn_fast_s_mp_mul_high_digs.c
  8. +1 −1 bn_fast_s_mp_sqr.c
  9. +1 −1 bn_mp_2expt.c
  10. +1 −1 bn_mp_abs.c
  11. +1 −1 bn_mp_add.c
  12. +1 −1 bn_mp_add_d.c
  13. +1 −1 bn_mp_addmod.c
  14. +1 −1 bn_mp_and.c
  15. +1 −1 bn_mp_clamp.c
  16. +1 −1 bn_mp_clear.c
  17. +1 −1 bn_mp_clear_multi.c
  18. +1 −1 bn_mp_cmp.c
  19. +1 −1 bn_mp_cmp_d.c
  20. +1 −1 bn_mp_cmp_mag.c
  21. +1 −1 bn_mp_cnt_lsb.c
  22. +1 −1 bn_mp_copy.c
  23. +1 −1 bn_mp_count_bits.c
  24. +1 −1 bn_mp_div.c
  25. +1 −1 bn_mp_div_2.c
  26. +1 −1 bn_mp_div_2d.c
  27. +1 −1 bn_mp_div_3.c
  28. +1 −1 bn_mp_div_d.c
  29. +1 −1 bn_mp_dr_is_modulus.c
  30. +1 −1 bn_mp_dr_reduce.c
  31. +1 −1 bn_mp_dr_setup.c
  32. +1 −1 bn_mp_exch.c
  33. +1 −1 bn_mp_expt_d.c
  34. +1 −1 bn_mp_exptmod.c
  35. +1 −1 bn_mp_exptmod_fast.c
  36. +1 −1 bn_mp_exteuclid.c
  37. +1 −1 bn_mp_fread.c
  38. +1 −1 bn_mp_fwrite.c
  39. +3 −11 bn_mp_gcd.c
  40. +1 −1 bn_mp_get_int.c
  41. +1 −1 bn_mp_grow.c
  42. +1 −1 bn_mp_init.c
  43. +1 −1 bn_mp_init_copy.c
  44. +1 −1 bn_mp_init_multi.c
  45. +1 −1 bn_mp_init_set.c
  46. +1 −1 bn_mp_init_set_int.c
  47. +1 −1 bn_mp_init_size.c
  48. +1 −1 bn_mp_invmod.c
  49. +1 −1 bn_mp_invmod_slow.c
  50. +1 −1 bn_mp_is_square.c
  51. +1 −1 bn_mp_jacobi.c
  52. +1 −1 bn_mp_karatsuba_mul.c
  53. +1 −1 bn_mp_karatsuba_sqr.c
  54. +1 −1 bn_mp_lcm.c
  55. +1 −1 bn_mp_lshd.c
  56. +1 −1 bn_mp_mod.c
  57. +1 −1 bn_mp_mod_2d.c
  58. +1 −1 bn_mp_mod_d.c
  59. +1 −1 bn_mp_montgomery_calc_normalization.c
  60. +1 −1 bn_mp_montgomery_reduce.c
  61. +1 −1 bn_mp_montgomery_setup.c
  62. +1 −1 bn_mp_mul.c
  63. +1 −1 bn_mp_mul_2.c
  64. +1 −1 bn_mp_mul_2d.c
  65. +1 −1 bn_mp_mul_d.c
  66. +1 −1 bn_mp_mulmod.c
  67. +1 −1 bn_mp_n_root.c
  68. +1 −1 bn_mp_neg.c
  69. +1 −1 bn_mp_or.c
  70. +1 −1 bn_mp_prime_fermat.c
  71. +1 −1 bn_mp_prime_is_divisible.c
  72. +1 −1 bn_mp_prime_is_prime.c
  73. +1 −1 bn_mp_prime_miller_rabin.c
  74. +1 −1 bn_mp_prime_next_prime.c
  75. +1 −1 bn_mp_prime_rabin_miller_trials.c
  76. +1 −1 bn_mp_prime_random_ex.c
  77. +1 −1 bn_mp_radix_size.c
  78. +1 −1 bn_mp_radix_smap.c
  79. +1 −1 bn_mp_rand.c
  80. +1 −1 bn_mp_read_radix.c
  81. +1 −1 bn_mp_read_signed_bin.c
  82. +1 −1 bn_mp_read_unsigned_bin.c
  83. +1 −1 bn_mp_reduce.c
  84. +1 −1 bn_mp_reduce_2k.c
  85. +1 −1 bn_mp_reduce_2k_l.c
  86. +1 −1 bn_mp_reduce_2k_setup.c
  87. +1 −1 bn_mp_reduce_2k_setup_l.c
  88. +1 −1 bn_mp_reduce_is_2k.c
  89. +1 −1 bn_mp_reduce_is_2k_l.c
  90. +1 −1 bn_mp_reduce_setup.c
  91. +1 −1 bn_mp_rshd.c
  92. +1 −1 bn_mp_set.c
  93. +1 −1 bn_mp_set_int.c
  94. +1 −1 bn_mp_shrink.c
  95. +1 −1 bn_mp_signed_bin_size.c
  96. +1 −1 bn_mp_sqr.c
  97. +1 −1 bn_mp_sqrmod.c
  98. +1 −1 bn_mp_sqrt.c
  99. +1 −1 bn_mp_sub.c
  100. +1 −1 bn_mp_sub_d.c
  101. +1 −1 bn_mp_submod.c
  102. +1 −1 bn_mp_to_signed_bin.c
  103. +1 −1 bn_mp_to_signed_bin_n.c
  104. +1 −1 bn_mp_to_unsigned_bin.c
  105. +1 −1 bn_mp_to_unsigned_bin_n.c
  106. +1 −1 bn_mp_toom_mul.c
  107. +1 −1 bn_mp_toom_sqr.c
  108. +1 −1 bn_mp_toradix.c
  109. +1 −1 bn_mp_toradix_n.c
  110. +1 −1 bn_mp_unsigned_bin_size.c
  111. +1 −1 bn_mp_xor.c
  112. +1 −1 bn_mp_zero.c
  113. +1 −1 bn_prime_tab.c
  114. +1 −1 bn_reverse.c
  115. +1 −1 bn_s_mp_add.c
  116. +1 −1 bn_s_mp_exptmod.c
  117. +1 −1 bn_s_mp_mul_digs.c
  118. +1 −1 bn_s_mp_mul_high_digs.c
  119. +1 −1 bn_s_mp_sqr.c
  120. +1 −1 bn_s_mp_sub.c
  121. +1 −1 bncore.c
  122. +7 −0 changes.txt
  123. +1 −1 etc/mersenne.c
  124. +2 −2 etc/pprime.c
  125. +1 −1 etc/tune.c
  126. +1 −1 makefile
  127. +4 −3 makefile.shared
  128. BIN poster.pdf
  129. +121 −129 pre_gen/mpi.c
  130. +1 −1 tommath.h
  131. BIN tommath.pdf
  132. +58 −59 tommath.src
  133. +156 −4,347 tommath.tex
View
BIN bn.pdf
Binary file not shown.
View
2 bn.tex
@@ -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 \\ tomstdenis@iahu.ca}
\maketitle
This text, the library and the accompanying textbook are all hereby placed in the public domain. This book has been
View
@@ -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 {
View
@@ -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,
@@ -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
View
@@ -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
@@ -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
View
@@ -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...
View
@@ -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
View
@@ -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|
View
@@ -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) */
View
@@ -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 */
View
@@ -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) */
View
@@ -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 */
View
@@ -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
View
@@ -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) */
View
@@ -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>
View
@@ -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)*/
View
@@ -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 */
View
@@ -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) */
View
@@ -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] = {
View
@@ -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 */
View
@@ -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 */
View
@@ -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
View
@@ -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 */
View
@@ -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) */
View
@@ -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) */
View
@@ -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)
View
@@ -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 */
View
@@ -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.
View
@@ -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 */
View
@@ -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
View
@@ -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 */
View
@@ -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
*/
View
@@ -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
View
@@ -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
View
@@ -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 */
View
@@ -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)
View
@@ -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;
View
@@ -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 */
View
@@ -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 */
View
@@ -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 */
Oops, something went wrong.

0 comments on commit f0b91a5

Please sign in to comment.