|
1 /* ********************************************************************* |
|
2 * |
|
3 * Sun elects to have this file available under and governed by the |
|
4 * Mozilla Public License Version 1.1 ("MPL") (see |
|
5 * http://www.mozilla.org/MPL/ for full license text). For the avoidance |
|
6 * of doubt and subject to the following, Sun also elects to allow |
|
7 * licensees to use this file under the MPL, the GNU General Public |
|
8 * License version 2 only or the Lesser General Public License version |
|
9 * 2.1 only. Any references to the "GNU General Public License version 2 |
|
10 * or later" or "GPL" in the following shall be construed to mean the |
|
11 * GNU General Public License version 2 only. Any references to the "GNU |
|
12 * Lesser General Public License version 2.1 or later" or "LGPL" in the |
|
13 * following shall be construed to mean the GNU Lesser General Public |
|
14 * License version 2.1 only. However, the following notice accompanied |
|
15 * the original version of this file: |
|
16 * |
|
17 * |
|
18 * Utilities for finding and working with prime and pseudo-prime |
|
19 * integers |
|
20 * |
|
21 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
|
22 * |
|
23 * The contents of this file are subject to the Mozilla Public License Version |
|
24 * 1.1 (the "License"); you may not use this file except in compliance with |
|
25 * the License. You may obtain a copy of the License at |
|
26 * http://www.mozilla.org/MPL/ |
|
27 * |
|
28 * Software distributed under the License is distributed on an "AS IS" basis, |
|
29 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
|
30 * for the specific language governing rights and limitations under the |
|
31 * License. |
|
32 * |
|
33 * The Original Code is the MPI Arbitrary Precision Integer Arithmetic library. |
|
34 * |
|
35 * The Initial Developer of the Original Code is |
|
36 * Michael J. Fromberger. |
|
37 * Portions created by the Initial Developer are Copyright (C) 1997 |
|
38 * the Initial Developer. All Rights Reserved. |
|
39 * |
|
40 * Contributor(s): |
|
41 * |
|
42 * Alternatively, the contents of this file may be used under the terms of |
|
43 * either the GNU General Public License Version 2 or later (the "GPL"), or |
|
44 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
|
45 * in which case the provisions of the GPL or the LGPL are applicable instead |
|
46 * of those above. If you wish to allow use of your version of this file only |
|
47 * under the terms of either the GPL or the LGPL, and not to allow others to |
|
48 * use your version of this file under the terms of the MPL, indicate your |
|
49 * decision by deleting the provisions above and replace them with the notice |
|
50 * and other provisions required by the GPL or the LGPL. If you do not delete |
|
51 * the provisions above, a recipient may use your version of this file under |
|
52 * the terms of any one of the MPL, the GPL or the LGPL. |
|
53 * |
|
54 *********************************************************************** */ |
|
55 /* |
|
56 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. |
|
57 * Use is subject to license terms. |
|
58 */ |
|
59 |
|
60 #ifndef _MP_PRIME_H |
|
61 #define _MP_PRIME_H |
|
62 |
|
63 #pragma ident "%Z%%M% %I% %E% SMI" |
|
64 |
|
65 #include "mpi.h" |
|
66 |
|
67 extern const int prime_tab_size; /* number of primes available */ |
|
68 extern const mp_digit prime_tab[]; |
|
69 |
|
70 /* Tests for divisibility */ |
|
71 mp_err mpp_divis(mp_int *a, mp_int *b); |
|
72 mp_err mpp_divis_d(mp_int *a, mp_digit d); |
|
73 |
|
74 /* Random selection */ |
|
75 mp_err mpp_random(mp_int *a); |
|
76 mp_err mpp_random_size(mp_int *a, mp_size prec); |
|
77 |
|
78 /* Pseudo-primality testing */ |
|
79 mp_err mpp_divis_vector(mp_int *a, const mp_digit *vec, int size, int *which); |
|
80 mp_err mpp_divis_primes(mp_int *a, mp_digit *np); |
|
81 mp_err mpp_fermat(mp_int *a, mp_digit w); |
|
82 mp_err mpp_fermat_list(mp_int *a, const mp_digit *primes, mp_size nPrimes); |
|
83 mp_err mpp_pprime(mp_int *a, int nt); |
|
84 mp_err mpp_sieve(mp_int *trial, const mp_digit *primes, mp_size nPrimes, |
|
85 unsigned char *sieve, mp_size nSieve); |
|
86 mp_err mpp_make_prime(mp_int *start, mp_size nBits, mp_size strong, |
|
87 unsigned long * nTries); |
|
88 |
|
89 #endif /* _MP_PRIME_H */ |