Back to index

lightning-sunbird  0.9+nobinonly
mpprime.h
Go to the documentation of this file.
00001 /*
00002  *  mpprime.h
00003  *
00004  *  Utilities for finding and working with prime and pseudo-prime
00005  *  integers
00006  *
00007  * ***** BEGIN LICENSE BLOCK *****
00008  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00009  *
00010  * The contents of this file are subject to the Mozilla Public License Version
00011  * 1.1 (the "License"); you may not use this file except in compliance with
00012  * the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS" basis,
00016  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00017  * for the specific language governing rights and limitations under the
00018  * License.
00019  *
00020  * The Original Code is the MPI Arbitrary Precision Integer Arithmetic library.
00021  *
00022  * The Initial Developer of the Original Code is
00023  * Michael J. Fromberger.
00024  * Portions created by the Initial Developer are Copyright (C) 1997
00025  * the Initial Developer. All Rights Reserved.
00026  *
00027  * Contributor(s):
00028  *
00029  * Alternatively, the contents of this file may be used under the terms of
00030  * either the GNU General Public License Version 2 or later (the "GPL"), or
00031  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00032  * in which case the provisions of the GPL or the LGPL are applicable instead
00033  * of those above. If you wish to allow use of your version of this file only
00034  * under the terms of either the GPL or the LGPL, and not to allow others to
00035  * use your version of this file under the terms of the MPL, indicate your
00036  * decision by deleting the provisions above and replace them with the notice
00037  * and other provisions required by the GPL or the LGPL. If you do not delete
00038  * the provisions above, a recipient may use your version of this file under
00039  * the terms of any one of the MPL, the GPL or the LGPL.
00040  *
00041  * ***** END LICENSE BLOCK ***** */
00042 
00043 #ifndef _H_MP_PRIME_
00044 #define _H_MP_PRIME_
00045 
00046 #include "mpi.h"
00047 
00048 extern const int prime_tab_size;   /* number of primes available */
00049 extern const mp_digit prime_tab[];
00050 
00051 /* Tests for divisibility    */
00052 mp_err  mpp_divis(mp_int *a, mp_int *b);
00053 mp_err  mpp_divis_d(mp_int *a, mp_digit d);
00054 
00055 /* Random selection          */
00056 mp_err  mpp_random(mp_int *a);
00057 mp_err  mpp_random_size(mp_int *a, mp_size prec);
00058 
00059 /* Pseudo-primality testing  */
00060 mp_err  mpp_divis_vector(mp_int *a, const mp_digit *vec, int size, int *which);
00061 mp_err  mpp_divis_primes(mp_int *a, mp_digit *np);
00062 mp_err  mpp_fermat(mp_int *a, mp_digit w);
00063 mp_err mpp_fermat_list(mp_int *a, const mp_digit *primes, mp_size nPrimes);
00064 mp_err  mpp_pprime(mp_int *a, int nt);
00065 mp_err mpp_sieve(mp_int *trial, const mp_digit *primes, mp_size nPrimes, 
00066                unsigned char *sieve, mp_size nSieve);
00067 mp_err mpp_make_prime(mp_int *start, mp_size nBits, mp_size strong,
00068                     unsigned long * nTries);
00069 
00070 #endif /* end _H_MP_PRIME_ */