Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/security/ec/impl/mpprime.h
38918 views
/*1* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.2* Use is subject to license terms.3*4* This library is free software; you can redistribute it and/or5* modify it under the terms of the GNU Lesser General Public6* License as published by the Free Software Foundation; either7* version 2.1 of the License, or (at your option) any later version.8*9* This library is distributed in the hope that it will be useful,10* but WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU12* Lesser General Public License for more details.13*14* You should have received a copy of the GNU Lesser General Public License15* along with this library; if not, write to the Free Software Foundation,16* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/* *********************************************************************24*25* The Original Code is the MPI Arbitrary Precision Integer Arithmetic library.26*27* The Initial Developer of the Original Code is28* Michael J. Fromberger.29* Portions created by the Initial Developer are Copyright (C) 199730* the Initial Developer. All Rights Reserved.31*32* Contributor(s):33*34*********************************************************************** */3536/* Utilities for finding and working with prime and pseudo-prime integers */3738#ifndef _MP_PRIME_H39#define _MP_PRIME_H4041#include "mpi.h"4243extern const int prime_tab_size; /* number of primes available */44extern const mp_digit prime_tab[];4546/* Tests for divisibility */47mp_err mpp_divis(mp_int *a, mp_int *b);48mp_err mpp_divis_d(mp_int *a, mp_digit d);4950/* Random selection */51mp_err mpp_random(mp_int *a);52mp_err mpp_random_size(mp_int *a, mp_size prec);5354/* Pseudo-primality testing */55mp_err mpp_divis_vector(mp_int *a, const mp_digit *vec, int size, int *which);56mp_err mpp_divis_primes(mp_int *a, mp_digit *np);57mp_err mpp_fermat(mp_int *a, mp_digit w);58mp_err mpp_fermat_list(mp_int *a, const mp_digit *primes, mp_size nPrimes);59mp_err mpp_pprime(mp_int *a, int nt);60mp_err mpp_sieve(mp_int *trial, const mp_digit *primes, mp_size nPrimes,61unsigned char *sieve, mp_size nSieve);62mp_err mpp_make_prime(mp_int *start, mp_size nBits, mp_size strong,63unsigned long * nTries);6465#endif /* _MP_PRIME_H */666768