tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

mpprime.h (1644B)


      1 /*
      2 *  mpprime.h
      3 *
      4 *  Utilities for finding and working with prime and pseudo-prime
      5 *  integers
      6 *
      7 * This Source Code Form is subject to the terms of the Mozilla Public
      8 * License, v. 2.0. If a copy of the MPL was not distributed with this
      9 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     10 
     11 #ifndef _H_MP_PRIME_
     12 #define _H_MP_PRIME_
     13 
     14 #include "mpi.h"
     15 
     16 SEC_BEGIN_PROTOS
     17 
     18 extern const int prime_tab_size; /* number of primes available */
     19 extern const mp_digit prime_tab[];
     20 
     21 /* Tests for divisibility    */
     22 mp_err mpp_divis(mp_int *a, mp_int *b);
     23 mp_err mpp_divis_d(mp_int *a, mp_digit d);
     24 
     25 /* Random selection          */
     26 mp_err mpp_random(mp_int *a);
     27 mp_err mpp_random_size(mp_int *a, mp_size prec);
     28 
     29 /* Type for a pointer to a user-provided mpp_random implementation */
     30 typedef mp_err (*mpp_random_fn)(mp_int *);
     31 
     32 /* Pseudo-primality testing  */
     33 mp_err mpp_divis_vector(mp_int *a, const mp_digit *vec, int size, int *which);
     34 mp_err mpp_divis_primes(mp_int *a, mp_digit *np);
     35 mp_err mpp_fermat(mp_int *a, mp_digit w);
     36 mp_err mpp_fermat_list(mp_int *a, const mp_digit *primes, mp_size nPrimes);
     37 mp_err mpp_pprime(mp_int *a, int nt);
     38 mp_err mpp_sieve(mp_int *trial, const mp_digit *primes, mp_size nPrimes,
     39                 unsigned char *sieve, mp_size nSieve);
     40 mp_err mpp_make_prime(mp_int *start, mp_size nBits, mp_size strong);
     41 
     42 /* Pseudo-primality tests using a user-provided mpp_random implementation */
     43 mp_err mpp_pprime_ext_random(mp_int *a, int nt, mpp_random_fn random);
     44 mp_err mpp_make_prime_ext_random(mp_int *start, mp_size nBits, mp_size strong, mpp_random_fn random);
     45 
     46 SEC_END_PROTOS
     47 
     48 #endif /* end _H_MP_PRIME_ */