4
* Utilities for finding and working with prime and pseudo-prime
7
* The contents of this file are subject to the Mozilla Public
8
* License Version 1.1 (the "License"); you may not use this file
9
* except in compliance with the License. You may obtain a copy of
10
* the License at http://www.mozilla.org/MPL/
12
* Software distributed under the License is distributed on an "AS
13
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14
* implied. See the License for the specific language governing
15
* rights and limitations under the License.
17
* The Original Code is the MPI Arbitrary Precision Integer Arithmetic
20
* The Initial Developer of the Original Code is Michael J. Fromberger.
21
* Portions created by Michael J. Fromberger are
22
* Copyright (C) 1997, 1998, 1999, 2000 Michael J. Fromberger.
23
* All Rights Reserved.
27
* Alternatively, the contents of this file may be used under the
28
* terms of the GNU General Public License Version 2 or later (the
29
* "GPL"), in which case the provisions of the GPL are applicable
30
* instead of those above. If you wish to allow use of your
31
* version of this file only under the terms of the GPL and not to
32
* allow others to use your version of this file under the MPL,
33
* indicate your decision by deleting the provisions above and
34
* replace them with the notice and other provisions required by
35
* the GPL. If you do not delete the provisions above, a recipient
36
* may use your version of this file under either the MPL or the
45
extern const int prime_tab_size; /* number of primes available */
46
extern const mp_digit prime_tab[];
48
/* Tests for divisibility */
49
mp_err mpp_divis(mp_int *a, mp_int *b);
50
mp_err mpp_divis_d(mp_int *a, mp_digit d);
52
/* Random selection */
53
mp_err mpp_random(mp_int *a);
54
mp_err mpp_random_size(mp_int *a, mp_size prec);
56
/* Pseudo-primality testing */
57
mp_err mpp_divis_vector(mp_int *a, const mp_digit *vec, int size, int *which);
58
mp_err mpp_divis_primes(mp_int *a, mp_digit *np);
59
mp_err mpp_fermat(mp_int *a, mp_digit w);
60
mp_err mpp_fermat_list(mp_int *a, const mp_digit *primes, mp_size nPrimes);
61
mp_err mpp_pprime(mp_int *a, int nt);
62
mp_err mpp_sieve(mp_int *trial, const mp_digit *primes, mp_size nPrimes,
63
unsigned char *sieve, mp_size nSieve);
64
mp_err mpp_make_prime(mp_int *start, mp_size nBits, mp_size strong,
65
unsigned long * nTries);
67
#endif /* end _H_MP_PRIME_ */