1/*
2 * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
3 * Use is subject to license terms.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24/* *********************************************************************
25 *
26 * The Original Code is the MPI Arbitrary Precision Integer Arithmetic library.
27 *
28 * The Initial Developer of the Original Code is
29 * Michael J. Fromberger.
30 * Portions created by the Initial Developer are Copyright (C) 1997
31 * the Initial Developer. All Rights Reserved.
32 *
33 * Contributor(s):
34 *
35 *********************************************************************** */
36
37/* Utilities for finding and working with prime and pseudo-prime integers */
38
39#ifndef _MP_PRIME_H
40#define _MP_PRIME_H
41
42#include "mpi.h"
43
44extern const int prime_tab_size; /* number of primes available */
45extern const mp_digit prime_tab[];
46
47/* Tests for divisibility */
48mp_err mpp_divis(mp_int *a, mp_int *b);
49mp_err mpp_divis_d(mp_int *a, mp_digit d);
50
51/* Random selection */
52mp_err mpp_random(mp_int *a);
53mp_err mpp_random_size(mp_int *a, mp_size prec);
54
55/* Pseudo-primality testing */
56mp_err mpp_divis_vector(mp_int *a, const mp_digit *vec, int size, int *which);
57mp_err mpp_divis_primes(mp_int *a, mp_digit *np);
58mp_err mpp_fermat(mp_int *a, mp_digit w);
59mp_err mpp_fermat_list(mp_int *a, const mp_digit *primes, mp_size nPrimes);
60mp_err mpp_pprime(mp_int *a, int nt);
61mp_err mpp_sieve(mp_int *trial, const mp_digit *primes, mp_size nPrimes,
62 unsigned char *sieve, mp_size nSieve);
63mp_err mpp_make_prime(mp_int *start, mp_size nBits, mp_size strong,
64 unsigned long * nTries);
65
66#endif /* _MP_PRIME_H */
67