tommath.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. /* LibTomMath, multiple-precision integer library -- Tom St Denis
  2. *
  3. * LibTomMath is a library that provides multiple-precision
  4. * integer arithmetic as well as number theoretic functionality.
  5. *
  6. * The library was designed directly after the MPI library by
  7. * Michael Fromberger but has been written from scratch with
  8. * additional optimizations in place.
  9. *
  10. * The library is free for all purposes without any express
  11. * guarantee it works.
  12. *
  13. * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
  14. */
  15. #ifndef BN_H_
  16. #define BN_H_
  17. #include <stdio.h>
  18. #include <string.h>
  19. #include <stdlib.h>
  20. #include <ctype.h>
  21. #include <limits.h>
  22. #include "tommath_class.h"
  23. #ifndef MIN
  24. #define MIN(x,y) ((x)<(y)?(x):(y))
  25. #endif
  26. #ifndef MAX
  27. #define MAX(x,y) ((x)>(y)?(x):(y))
  28. #endif
  29. #ifdef __cplusplus
  30. extern "C" {
  31. /* C++ compilers don't like assigning void * to mp_digit * */
  32. #define OPT_CAST(x) (x *)
  33. #else
  34. /* C on the other hand doesn't care */
  35. #define OPT_CAST(x)
  36. #endif
  37. /* detect 64-bit mode if possible */
  38. #if defined(__x86_64__)
  39. #if !(defined(MP_64BIT) && defined(MP_16BIT) && defined(MP_8BIT))
  40. #define MP_64BIT
  41. #endif
  42. #endif
  43. /* some default configurations.
  44. *
  45. * A "mp_digit" must be able to hold DIGIT_BIT + 1 bits
  46. * A "mp_word" must be able to hold 2*DIGIT_BIT + 1 bits
  47. *
  48. * At the very least a mp_digit must be able to hold 7 bits
  49. * [any size beyond that is ok provided it doesn't overflow the data type]
  50. */
  51. #ifdef MP_8BIT
  52. typedef unsigned char mp_digit;
  53. typedef unsigned short mp_word;
  54. #elif defined(MP_16BIT)
  55. typedef unsigned short mp_digit;
  56. typedef unsigned long mp_word;
  57. #elif defined(MP_64BIT)
  58. /* for GCC only on supported platforms */
  59. #ifndef CRYPT
  60. typedef unsigned long long ulong64;
  61. typedef signed long long long64;
  62. #endif
  63. typedef unsigned long mp_digit;
  64. typedef unsigned long mp_word __attribute__ ((mode(TI)));
  65. #define DIGIT_BIT 60
  66. #else
  67. /* this is the default case, 28-bit digits */
  68. /* this is to make porting into LibTomCrypt easier :-) */
  69. #ifndef CRYPT
  70. #if defined(_MSC_VER) || defined(__BORLANDC__)
  71. typedef unsigned __int64 ulong64;
  72. typedef signed __int64 long64;
  73. #else
  74. typedef unsigned long long ulong64;
  75. typedef signed long long long64;
  76. #endif
  77. #endif
  78. typedef unsigned long mp_digit;
  79. typedef ulong64 mp_word;
  80. #ifdef MP_31BIT
  81. /* this is an extension that uses 31-bit digits */
  82. #define DIGIT_BIT 31
  83. #else
  84. /* default case is 28-bit digits, defines MP_28BIT as a handy macro to test */
  85. #define DIGIT_BIT 28
  86. #define MP_28BIT
  87. #endif
  88. #endif
  89. /* define heap macros */
  90. #ifndef CRYPT
  91. /* default to libc stuff */
  92. #ifndef XMALLOC
  93. #define XMALLOC malloc
  94. #define XFREE free
  95. #define XREALLOC realloc
  96. #define XCALLOC calloc
  97. #else
  98. /* prototypes for our heap functions */
  99. extern void *XMALLOC(size_t n);
  100. extern void *XREALLOC(void *p, size_t n);
  101. extern void *XCALLOC(size_t n, size_t s);
  102. extern void XFREE(void *p);
  103. #endif
  104. #endif
  105. /* otherwise the bits per digit is calculated automatically from the size of a mp_digit */
  106. #ifndef DIGIT_BIT
  107. #define DIGIT_BIT ((int)((CHAR_BIT * sizeof(mp_digit) - 1))) /* bits per digit */
  108. #endif
  109. #define MP_DIGIT_BIT DIGIT_BIT
  110. #define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1))
  111. #define MP_DIGIT_MAX MP_MASK
  112. /* equalities */
  113. #define MP_LT -1 /* less than */
  114. #define MP_EQ 0 /* equal to */
  115. #define MP_GT 1 /* greater than */
  116. #define MP_ZPOS 0 /* positive integer */
  117. #define MP_NEG 1 /* negative */
  118. #define MP_OKAY 0 /* ok result */
  119. #define MP_MEM -2 /* out of mem */
  120. #define MP_VAL -3 /* invalid input */
  121. #define MP_RANGE MP_VAL
  122. #define MP_YES 1 /* yes response */
  123. #define MP_NO 0 /* no response */
  124. /* Primality generation flags */
  125. #define LTM_PRIME_BBS 0x0001 /* BBS style prime */
  126. #define LTM_PRIME_SAFE 0x0002 /* Safe prime (p-1)/2 == prime */
  127. #define LTM_PRIME_2MSB_ON 0x0008 /* force 2nd MSB to 1 */
  128. typedef int mp_err;
  129. /* you'll have to tune these... */
  130. extern int KARATSUBA_MUL_CUTOFF,
  131. KARATSUBA_SQR_CUTOFF,
  132. TOOM_MUL_CUTOFF,
  133. TOOM_SQR_CUTOFF;
  134. /* define this to use lower memory usage routines (exptmods mostly) */
  135. /* #define MP_LOW_MEM */
  136. /* default precision */
  137. #ifndef MP_PREC
  138. #ifndef MP_LOW_MEM
  139. #define MP_PREC 32 /* default digits of precision */
  140. #else
  141. #define MP_PREC 8 /* default digits of precision */
  142. #endif
  143. #endif
  144. /* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */
  145. #define MP_WARRAY (1 << (sizeof(mp_word) * CHAR_BIT - 2 * DIGIT_BIT + 1))
  146. /* the infamous mp_int structure */
  147. typedef struct {
  148. int used, alloc, sign;
  149. mp_digit *dp;
  150. } mp_int;
  151. /* callback for mp_prime_random, should fill dst with random bytes and return how many read [upto len] */
  152. typedef int ltm_prime_callback(unsigned char *dst, int len, void *dat);
  153. #define USED(m) ((m)->used)
  154. #define DIGIT(m,k) ((m)->dp[(k)])
  155. #define SIGN(m) ((m)->sign)
  156. /* error code to char* string */
  157. char *mp_error_to_string(int code);
  158. /* ---> init and deinit bignum functions <--- */
  159. /* init a bignum */
  160. int mp_init(mp_int *a);
  161. /* free a bignum */
  162. void mp_clear(mp_int *a);
  163. /* init a null terminated series of arguments */
  164. int mp_init_multi(mp_int *mp, ...);
  165. /* clear a null terminated series of arguments */
  166. void mp_clear_multi(mp_int *mp, ...);
  167. /* exchange two ints */
  168. void mp_exch(mp_int *a, mp_int *b);
  169. /* shrink ram required for a bignum */
  170. int mp_shrink(mp_int *a);
  171. /* grow an int to a given size */
  172. int mp_grow(mp_int *a, int size);
  173. /* init to a given number of digits */
  174. int mp_init_size(mp_int *a, int size);
  175. /* ---> Basic Manipulations <--- */
  176. #define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO)
  177. #define mp_iseven(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO)
  178. #define mp_isodd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO)
  179. /* set to zero */
  180. void mp_zero(mp_int *a);
  181. /* set to a digit */
  182. void mp_set(mp_int *a, mp_digit b);
  183. /* set a 32-bit const */
  184. int mp_set_int(mp_int *a, unsigned long b);
  185. /* get a 32-bit value */
  186. unsigned long mp_get_int(mp_int * a);
  187. /* initialize and set a digit */
  188. int mp_init_set (mp_int * a, mp_digit b);
  189. /* initialize and set 32-bit value */
  190. int mp_init_set_int (mp_int * a, unsigned long b);
  191. /* copy, b = a */
  192. int mp_copy(mp_int *a, mp_int *b);
  193. /* inits and copies, a = b */
  194. int mp_init_copy(mp_int *a, mp_int *b);
  195. /* trim unused digits */
  196. void mp_clamp(mp_int *a);
  197. /* ---> digit manipulation <--- */
  198. /* right shift by "b" digits */
  199. void mp_rshd(mp_int *a, int b);
  200. /* left shift by "b" digits */
  201. int mp_lshd(mp_int *a, int b);
  202. /* c = a / 2**b */
  203. int mp_div_2d(mp_int *a, int b, mp_int *c, mp_int *d);
  204. /* b = a/2 */
  205. int mp_div_2(mp_int *a, mp_int *b);
  206. /* c = a * 2**b */
  207. int mp_mul_2d(mp_int *a, int b, mp_int *c);
  208. /* b = a*2 */
  209. int mp_mul_2(mp_int *a, mp_int *b);
  210. /* c = a mod 2**d */
  211. int mp_mod_2d(mp_int *a, int b, mp_int *c);
  212. /* computes a = 2**b */
  213. int mp_2expt(mp_int *a, int b);
  214. /* Counts the number of lsbs which are zero before the first zero bit */
  215. int mp_cnt_lsb(mp_int *a);
  216. /* I Love Earth! */
  217. /* makes a pseudo-random int of a given size */
  218. int mp_rand(mp_int *a, int digits);
  219. /* ---> binary operations <--- */
  220. /* c = a XOR b */
  221. int mp_xor(mp_int *a, mp_int *b, mp_int *c);
  222. /* c = a OR b */
  223. int mp_or(mp_int *a, mp_int *b, mp_int *c);
  224. /* c = a AND b */
  225. int mp_and(mp_int *a, mp_int *b, mp_int *c);
  226. /* ---> Basic arithmetic <--- */
  227. /* b = -a */
  228. int mp_neg(mp_int *a, mp_int *b);
  229. /* b = |a| */
  230. int mp_abs(mp_int *a, mp_int *b);
  231. /* compare a to b */
  232. int mp_cmp(mp_int *a, mp_int *b);
  233. /* compare |a| to |b| */
  234. int mp_cmp_mag(mp_int *a, mp_int *b);
  235. /* c = a + b */
  236. int mp_add(mp_int *a, mp_int *b, mp_int *c);
  237. /* c = a - b */
  238. int mp_sub(mp_int *a, mp_int *b, mp_int *c);
  239. /* c = a * b */
  240. int mp_mul(mp_int *a, mp_int *b, mp_int *c);
  241. /* b = a*a */
  242. int mp_sqr(mp_int *a, mp_int *b);
  243. /* a/b => cb + d == a */
  244. int mp_div(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
  245. /* c = a mod b, 0 <= c < b */
  246. int mp_mod(mp_int *a, mp_int *b, mp_int *c);
  247. /* ---> single digit functions <--- */
  248. /* compare against a single digit */
  249. int mp_cmp_d(mp_int *a, mp_digit b);
  250. /* c = a + b */
  251. int mp_add_d(mp_int *a, mp_digit b, mp_int *c);
  252. /* c = a - b */
  253. int mp_sub_d(mp_int *a, mp_digit b, mp_int *c);
  254. /* c = a * b */
  255. int mp_mul_d(mp_int *a, mp_digit b, mp_int *c);
  256. /* a/b => cb + d == a */
  257. int mp_div_d(mp_int *a, mp_digit b, mp_int *c, mp_digit *d);
  258. /* a/3 => 3c + d == a */
  259. int mp_div_3(mp_int *a, mp_int *c, mp_digit *d);
  260. /* c = a**b */
  261. int mp_expt_d(mp_int *a, mp_digit b, mp_int *c);
  262. /* c = a mod b, 0 <= c < b */
  263. int mp_mod_d(mp_int *a, mp_digit b, mp_digit *c);
  264. /* ---> number theory <--- */
  265. /* d = a + b (mod c) */
  266. int mp_addmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
  267. /* d = a - b (mod c) */
  268. int mp_submod(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
  269. /* d = a * b (mod c) */
  270. int mp_mulmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
  271. /* c = a * a (mod b) */
  272. int mp_sqrmod(mp_int *a, mp_int *b, mp_int *c);
  273. /* c = 1/a (mod b) */
  274. int mp_invmod(mp_int *a, mp_int *b, mp_int *c);
  275. /* c = (a, b) */
  276. int mp_gcd(mp_int *a, mp_int *b, mp_int *c);
  277. /* produces value such that U1*a + U2*b = U3 */
  278. int mp_exteuclid(mp_int *a, mp_int *b, mp_int *U1, mp_int *U2, mp_int *U3);
  279. /* c = [a, b] or (a*b)/(a, b) */
  280. int mp_lcm(mp_int *a, mp_int *b, mp_int *c);
  281. /* finds one of the b'th root of a, such that |c|**b <= |a|
  282. *
  283. * returns error if a < 0 and b is even
  284. */
  285. int mp_n_root(mp_int *a, mp_digit b, mp_int *c);
  286. /* special sqrt algo */
  287. int mp_sqrt(mp_int *arg, mp_int *ret);
  288. /* is number a square? */
  289. int mp_is_square(mp_int *arg, int *ret);
  290. /* computes the jacobi c = (a | n) (or Legendre if b is prime) */
  291. int mp_jacobi(mp_int *a, mp_int *n, int *c);
  292. /* used to setup the Barrett reduction for a given modulus b */
  293. int mp_reduce_setup(mp_int *a, mp_int *b);
  294. /* Barrett Reduction, computes a (mod b) with a precomputed value c
  295. *
  296. * Assumes that 0 < a <= b*b, note if 0 > a > -(b*b) then you can merely
  297. * compute the reduction as -1 * mp_reduce(mp_abs(a)) [pseudo code].
  298. */
  299. int mp_reduce(mp_int *a, mp_int *b, mp_int *c);
  300. /* setups the montgomery reduction */
  301. int mp_montgomery_setup(mp_int *a, mp_digit *mp);
  302. /* computes a = B**n mod b without division or multiplication useful for
  303. * normalizing numbers in a Montgomery system.
  304. */
  305. int mp_montgomery_calc_normalization(mp_int *a, mp_int *b);
  306. /* computes x/R == x (mod N) via Montgomery Reduction */
  307. int mp_montgomery_reduce(mp_int *a, mp_int *m, mp_digit mp);
  308. /* returns 1 if a is a valid DR modulus */
  309. int mp_dr_is_modulus(mp_int *a);
  310. /* sets the value of "d" required for mp_dr_reduce */
  311. void mp_dr_setup(mp_int *a, mp_digit *d);
  312. /* reduces a modulo b using the Diminished Radix method */
  313. int mp_dr_reduce(mp_int *a, mp_int *b, mp_digit mp);
  314. /* returns true if a can be reduced with mp_reduce_2k */
  315. int mp_reduce_is_2k(mp_int *a);
  316. /* determines k value for 2k reduction */
  317. int mp_reduce_2k_setup(mp_int *a, mp_digit *d);
  318. /* reduces a modulo b where b is of the form 2**p - k [0 <= a] */
  319. int mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d);
  320. /* returns true if a can be reduced with mp_reduce_2k_l */
  321. int mp_reduce_is_2k_l(mp_int *a);
  322. /* determines k value for 2k reduction */
  323. int mp_reduce_2k_setup_l(mp_int *a, mp_int *d);
  324. /* reduces a modulo b where b is of the form 2**p - k [0 <= a] */
  325. int mp_reduce_2k_l(mp_int *a, mp_int *n, mp_int *d);
  326. /* d = a**b (mod c) */
  327. int mp_exptmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
  328. /* ---> Primes <--- */
  329. /* number of primes */
  330. #ifdef MP_8BIT
  331. #define PRIME_SIZE 31
  332. #else
  333. #define PRIME_SIZE 256
  334. #endif
  335. /* table of first PRIME_SIZE primes */
  336. extern const mp_digit ltm_prime_tab[];
  337. /* result=1 if a is divisible by one of the first PRIME_SIZE primes */
  338. int mp_prime_is_divisible(mp_int *a, int *result);
  339. /* performs one Fermat test of "a" using base "b".
  340. * Sets result to 0 if composite or 1 if probable prime
  341. */
  342. int mp_prime_fermat(mp_int *a, mp_int *b, int *result);
  343. /* performs one Miller-Rabin test of "a" using base "b".
  344. * Sets result to 0 if composite or 1 if probable prime
  345. */
  346. int mp_prime_miller_rabin(mp_int *a, mp_int *b, int *result);
  347. /* This gives [for a given bit size] the number of trials required
  348. * such that Miller-Rabin gives a prob of failure lower than 2^-96
  349. */
  350. int mp_prime_rabin_miller_trials(int size);
  351. /* performs t rounds of Miller-Rabin on "a" using the first
  352. * t prime bases. Also performs an initial sieve of trial
  353. * division. Determines if "a" is prime with probability
  354. * of error no more than (1/4)**t.
  355. *
  356. * Sets result to 1 if probably prime, 0 otherwise
  357. */
  358. int mp_prime_is_prime(mp_int *a, int t, int *result);
  359. /* finds the next prime after the number "a" using "t" trials
  360. * of Miller-Rabin.
  361. *
  362. * bbs_style = 1 means the prime must be congruent to 3 mod 4
  363. */
  364. int mp_prime_next_prime(mp_int *a, int t, int bbs_style);
  365. /* makes a truly random prime of a given size (bytes),
  366. * call with bbs = 1 if you want it to be congruent to 3 mod 4
  367. *
  368. * You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can
  369. * have passed to the callback (e.g. a state or something). This function doesn't use "dat" itself
  370. * so it can be NULL
  371. *
  372. * The prime generated will be larger than 2^(8*size).
  373. */
  374. #define mp_prime_random(a, t, size, bbs, cb, dat) mp_prime_random_ex(a, t, ((size) * 8) + 1, (bbs==1)?LTM_PRIME_BBS:0, cb, dat)
  375. /* makes a truly random prime of a given size (bits),
  376. *
  377. * Flags are as follows:
  378. *
  379. * LTM_PRIME_BBS - make prime congruent to 3 mod 4
  380. * LTM_PRIME_SAFE - make sure (p-1)/2 is prime as well (implies LTM_PRIME_BBS)
  381. * LTM_PRIME_2MSB_OFF - make the 2nd highest bit zero
  382. * LTM_PRIME_2MSB_ON - make the 2nd highest bit one
  383. *
  384. * You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can
  385. * have passed to the callback (e.g. a state or something). This function doesn't use "dat" itself
  386. * so it can be NULL
  387. *
  388. */
  389. int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback cb, void *dat);
  390. /* ---> radix conversion <--- */
  391. int mp_count_bits(mp_int *a);
  392. int mp_unsigned_bin_size(mp_int *a);
  393. int mp_read_unsigned_bin(mp_int *a, const unsigned char *b, int c);
  394. int mp_to_unsigned_bin(mp_int *a, unsigned char *b);
  395. int mp_to_unsigned_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen);
  396. int mp_signed_bin_size(mp_int *a);
  397. int mp_read_signed_bin(mp_int *a, const unsigned char *b, int c);
  398. int mp_to_signed_bin(mp_int *a, unsigned char *b);
  399. int mp_to_signed_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen);
  400. int mp_read_radix(mp_int *a, const char *str, int radix);
  401. int mp_toradix(mp_int *a, char *str, int radix);
  402. int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen);
  403. int mp_radix_size(mp_int *a, int radix, int *size);
  404. int mp_fread(mp_int *a, int radix, FILE *stream);
  405. int mp_fwrite(mp_int *a, int radix, FILE *stream);
  406. #define mp_read_raw(mp, str, len) mp_read_signed_bin((mp), (str), (len))
  407. #define mp_raw_size(mp) mp_signed_bin_size(mp)
  408. #define mp_toraw(mp, str) mp_to_signed_bin((mp), (str))
  409. #define mp_read_mag(mp, str, len) mp_read_unsigned_bin((mp), (str), (len))
  410. #define mp_mag_size(mp) mp_unsigned_bin_size(mp)
  411. #define mp_tomag(mp, str) mp_to_unsigned_bin((mp), (str))
  412. #define mp_tobinary(M, S) mp_toradix((M), (S), 2)
  413. #define mp_tooctal(M, S) mp_toradix((M), (S), 8)
  414. #define mp_todecimal(M, S) mp_toradix((M), (S), 10)
  415. #define mp_tohex(M, S) mp_toradix((M), (S), 16)
  416. /* lowlevel functions, do not call! */
  417. int s_mp_add(mp_int *a, mp_int *b, mp_int *c);
  418. int s_mp_sub(mp_int *a, mp_int *b, mp_int *c);
  419. #define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1)
  420. int fast_s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
  421. int s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
  422. int fast_s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
  423. int s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs);
  424. int fast_s_mp_sqr(mp_int *a, mp_int *b);
  425. int s_mp_sqr(mp_int *a, mp_int *b);
  426. int mp_karatsuba_mul(mp_int *a, mp_int *b, mp_int *c);
  427. int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c);
  428. int mp_karatsuba_sqr(mp_int *a, mp_int *b);
  429. int mp_toom_sqr(mp_int *a, mp_int *b);
  430. int fast_mp_invmod(mp_int *a, mp_int *b, mp_int *c);
  431. int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c);
  432. int fast_mp_montgomery_reduce(mp_int *a, mp_int *m, mp_digit mp);
  433. int mp_exptmod_fast(mp_int *G, mp_int *X, mp_int *P, mp_int *Y, int mode);
  434. int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int mode);
  435. void bn_reverse(unsigned char *s, int len);
  436. extern const char *mp_s_rmap;
  437. #ifdef __cplusplus
  438. }
  439. #endif
  440. #endif
  441. /* $Source: /cvs/libtom/libtommath/tommath.h,v $ */
  442. /* $Revision: 1.8 $ */
  443. /* $Date: 2006/03/31 14:18:44 $ */