| 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 | |
| 44 | extern const int prime_tab_size; /* number of primes available */ |
| 45 | extern const mp_digit prime_tab[]; |
| 46 | |
| 47 | /* Tests for divisibility */ |
| 48 | mp_err mpp_divis(mp_int *a, mp_int *b); |
| 49 | mp_err mpp_divis_d(mp_int *a, mp_digit d); |
| 50 | |
| 51 | /* Random selection */ |
| 52 | mp_err mpp_random(mp_int *a); |
| 53 | mp_err mpp_random_size(mp_int *a, mp_size prec); |
| 54 | |
| 55 | /* Pseudo-primality testing */ |
| 56 | mp_err mpp_divis_vector(mp_int *a, const mp_digit *vec, int size, int *which); |
| 57 | mp_err mpp_divis_primes(mp_int *a, mp_digit *np); |
| 58 | mp_err mpp_fermat(mp_int *a, mp_digit w); |
| 59 | mp_err mpp_fermat_list(mp_int *a, const mp_digit *primes, mp_size nPrimes); |
| 60 | mp_err mpp_pprime(mp_int *a, int nt); |
| 61 | mp_err mpp_sieve(mp_int *trial, const mp_digit *primes, mp_size nPrimes, |
| 62 | unsigned char *sieve, mp_size nSieve); |
| 63 | mp_err mpp_make_prime(mp_int *start, mp_size nBits, mp_size strong, |
| 64 | unsigned long * nTries); |
| 65 | |
| 66 | #endif /* _MP_PRIME_H */ |
| 67 | |