comparison tommath.h @ 190:d8254fc979e9 libtommath-orig LTM_0.35

Initial import of libtommath 0.35
author Matt Johnston <matt@ucc.asn.au>
date Fri, 06 May 2005 08:59:30 +0000
parents d29b64170cf0
children c5c969ed76f3
comparison
equal deleted inserted replaced
142:d29b64170cf0 190:d8254fc979e9
427 int mp_reduce_2k_setup(mp_int *a, mp_digit *d); 427 int mp_reduce_2k_setup(mp_int *a, mp_digit *d);
428 428
429 /* reduces a modulo b where b is of the form 2**p - k [0 <= a] */ 429 /* reduces a modulo b where b is of the form 2**p - k [0 <= a] */
430 int mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d); 430 int mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d);
431 431
432 /* returns true if a can be reduced with mp_reduce_2k_l */
433 int mp_reduce_is_2k_l(mp_int *a);
434
435 /* determines k value for 2k reduction */
436 int mp_reduce_2k_setup_l(mp_int *a, mp_int *d);
437
438 /* reduces a modulo b where b is of the form 2**p - k [0 <= a] */
439 int mp_reduce_2k_l(mp_int *a, mp_int *n, mp_int *d);
440
432 /* d = a**b (mod c) */ 441 /* d = a**b (mod c) */
433 int mp_exptmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d); 442 int mp_exptmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
434 443
435 /* ---> Primes <--- */ 444 /* ---> Primes <--- */
436 445
440 #else 449 #else
441 #define PRIME_SIZE 256 450 #define PRIME_SIZE 256
442 #endif 451 #endif
443 452
444 /* table of first PRIME_SIZE primes */ 453 /* table of first PRIME_SIZE primes */
445 extern const mp_digit __prime_tab[]; 454 extern const mp_digit ltm_prime_tab[];
446 455
447 /* result=1 if a is divisible by one of the first PRIME_SIZE primes */ 456 /* result=1 if a is divisible by one of the first PRIME_SIZE primes */
448 int mp_prime_is_divisible(mp_int *a, int *result); 457 int mp_prime_is_divisible(mp_int *a, int *result);
449 458
450 /* performs one Fermat test of "a" using base "b". 459 /* performs one Fermat test of "a" using base "b".
509 int mp_count_bits(mp_int *a); 518 int mp_count_bits(mp_int *a);
510 519
511 int mp_unsigned_bin_size(mp_int *a); 520 int mp_unsigned_bin_size(mp_int *a);
512 int mp_read_unsigned_bin(mp_int *a, unsigned char *b, int c); 521 int mp_read_unsigned_bin(mp_int *a, unsigned char *b, int c);
513 int mp_to_unsigned_bin(mp_int *a, unsigned char *b); 522 int mp_to_unsigned_bin(mp_int *a, unsigned char *b);
523 int mp_to_unsigned_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen);
514 524
515 int mp_signed_bin_size(mp_int *a); 525 int mp_signed_bin_size(mp_int *a);
516 int mp_read_signed_bin(mp_int *a, unsigned char *b, int c); 526 int mp_read_signed_bin(mp_int *a, unsigned char *b, int c);
517 int mp_to_signed_bin(mp_int *a, unsigned char *b); 527 int mp_to_signed_bin(mp_int *a, unsigned char *b);
518 528 int mp_to_signed_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen);
519 int mp_read_radix(mp_int *a, char *str, int radix); 529
530 int mp_read_radix(mp_int *a, const char *str, int radix);
520 int mp_toradix(mp_int *a, char *str, int radix); 531 int mp_toradix(mp_int *a, char *str, int radix);
521 int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen); 532 int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen);
522 int mp_radix_size(mp_int *a, int radix, int *size); 533 int mp_radix_size(mp_int *a, int radix, int *size);
523 534
524 int mp_fread(mp_int *a, int radix, FILE *stream); 535 int mp_fread(mp_int *a, int radix, FILE *stream);
552 int mp_toom_sqr(mp_int *a, mp_int *b); 563 int mp_toom_sqr(mp_int *a, mp_int *b);
553 int fast_mp_invmod(mp_int *a, mp_int *b, mp_int *c); 564 int fast_mp_invmod(mp_int *a, mp_int *b, mp_int *c);
554 int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c); 565 int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c);
555 int fast_mp_montgomery_reduce(mp_int *a, mp_int *m, mp_digit mp); 566 int fast_mp_montgomery_reduce(mp_int *a, mp_int *m, mp_digit mp);
556 int mp_exptmod_fast(mp_int *G, mp_int *X, mp_int *P, mp_int *Y, int mode); 567 int mp_exptmod_fast(mp_int *G, mp_int *X, mp_int *P, mp_int *Y, int mode);
557 int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y); 568 int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int mode);
558 void bn_reverse(unsigned char *s, int len); 569 void bn_reverse(unsigned char *s, int len);
559 570
560 extern const char *mp_s_rmap; 571 extern const char *mp_s_rmap;
561 572
562 #ifdef __cplusplus 573 #ifdef __cplusplus