andre@0: /* andre@0: * mpprime.h andre@0: * andre@0: * Utilities for finding and working with prime and pseudo-prime andre@0: * integers andre@0: * andre@0: * This Source Code Form is subject to the terms of the Mozilla Public andre@0: * License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ andre@0: andre@0: #ifndef _H_MP_PRIME_ andre@0: #define _H_MP_PRIME_ andre@0: andre@0: #include "mpi.h" andre@0: andre@0: extern const int prime_tab_size; /* number of primes available */ andre@0: extern const mp_digit prime_tab[]; andre@0: andre@0: /* Tests for divisibility */ andre@0: mp_err mpp_divis(mp_int *a, mp_int *b); andre@0: mp_err mpp_divis_d(mp_int *a, mp_digit d); andre@0: andre@0: /* Random selection */ andre@0: mp_err mpp_random(mp_int *a); andre@0: mp_err mpp_random_size(mp_int *a, mp_size prec); andre@0: andre@0: /* Pseudo-primality testing */ andre@0: mp_err mpp_divis_vector(mp_int *a, const mp_digit *vec, int size, int *which); andre@0: mp_err mpp_divis_primes(mp_int *a, mp_digit *np); andre@0: mp_err mpp_fermat(mp_int *a, mp_digit w); andre@0: mp_err mpp_fermat_list(mp_int *a, const mp_digit *primes, mp_size nPrimes); andre@0: mp_err mpp_pprime(mp_int *a, int nt); andre@0: mp_err mpp_sieve(mp_int *trial, const mp_digit *primes, mp_size nPrimes, andre@0: unsigned char *sieve, mp_size nSieve); andre@0: mp_err mpp_make_prime(mp_int *start, mp_size nBits, mp_size strong, andre@0: unsigned long * nTries); andre@0: andre@0: #endif /* end _H_MP_PRIME_ */