summaryrefslogtreecommitdiff
path: root/nbtheory.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2015-11-22 19:11:31 -0500
committerJeffrey Walton <noloader@gmail.com>2015-11-22 19:11:31 -0500
commit62618fda97bbde6d4cc4752101e69839fc4f3b6f (patch)
treebcdacdfed312bb5ac9e4c504ff2a3c293214fe40 /nbtheory.h
parentc45435812225aa68d122c7de246e5f60b509766c (diff)
downloadcryptopp-git-62618fda97bbde6d4cc4752101e69839fc4f3b6f.tar.gz
Revert botched "Crypto++ 5.6.3 check-in". Corruption due to VMware adding garbage to the end of some source files during drag and drop from guest to host.
This reverts commit c45435812225aa68d122c7de246e5f60b509766c.
Diffstat (limited to 'nbtheory.h')
-rw-r--r--nbtheory.h55
1 files changed, 7 insertions, 48 deletions
diff --git a/nbtheory.h b/nbtheory.h
index 3620d8e2..779d6dea 100644
--- a/nbtheory.h
+++ b/nbtheory.h
@@ -1,8 +1,5 @@
// nbtheory.h - written and placed in the public domain by Wei Dai
-//! \file nbtheory.h
-//! \brief Classes and functions for number theoretic operations
-
#ifndef CRYPTOPP_NBTHEORY_H
#define CRYPTOPP_NBTHEORY_H
@@ -17,31 +14,14 @@ CRYPTOPP_DLL const word16 * CRYPTOPP_API GetPrimeTable(unsigned int &size);
// ************ primality testing ****************
-//! \brief Generates a provable prime
-//! \param rng a RandomNumberGenerator to produce keying material
-//! \param bits the number of bits in the prime number
-//! \returns Integer() meeting Maurer's tests for primality
+// generate a provable prime
CRYPTOPP_DLL Integer CRYPTOPP_API MaurerProvablePrime(RandomNumberGenerator &rng, unsigned int bits);
-
-//! \brief Generates a provable prime
-//! \param rng a RandomNumberGenerator to produce keying material
-//! \param bits the number of bits in the prime number
-//! \returns Integer() meeting Mihailescu's tests for primality
-//! \details Mihailescu's methods performs a search using algorithmic progressions.
CRYPTOPP_DLL Integer CRYPTOPP_API MihailescuProvablePrime(RandomNumberGenerator &rng, unsigned int bits);
-//! \brief Tests whether a number is a small prime
-//! \param p a candidate prime to test
-//! \returns true if p is a small prime, false otherwise
-//! \details Internally, the library maintains a table fo the first 32719 prime numbers
-//! in sorted order. IsSmallPrime() searches the table and returns true if p is
-//! in the table.
CRYPTOPP_DLL bool CRYPTOPP_API IsSmallPrime(const Integer &p);
-//!
-//! \returns true if p is divisible by some prime less than bound.
-//! \details TrialDivision() true if p is divisible by some prime less than bound. bound not be
-//! greater than the largest entry in the prime table, which is 32719.
+// returns true if p is divisible by some prime less than bound
+// bound not be greater than the largest entry in the prime table
CRYPTOPP_DLL bool CRYPTOPP_API TrialDivision(const Integer &p, unsigned bound);
// returns true if p is NOT divisible by small primes
@@ -58,25 +38,12 @@ CRYPTOPP_DLL bool CRYPTOPP_API IsStrongLucasProbablePrime(const Integer &n);
// for several rounds with random bases
CRYPTOPP_DLL bool CRYPTOPP_API RabinMillerTest(RandomNumberGenerator &rng, const Integer &w, unsigned int rounds);
-//! \brief Verifies a prime number
-//! \param p a candidate prime to test
-//! \returns true if p is a probable prime, false otherwise
-//! \details IsPrime() is suitable for testing candidate primes when creating them. Internally,
-//! IsPrime() utilizes SmallDivisorsTest(), IsStrongProbablePrime() and IsStrongLucasProbablePrime().
+// primality test, used to generate primes
CRYPTOPP_DLL bool CRYPTOPP_API IsPrime(const Integer &p);
-//! \brief Verifies a prime number
-//! \param rng a RandomNumberGenerator for randomized testing
-//! \param p a candidate prime to test
-//! \param level the level of thoroughness of testing
-//! \returns true if p is a strong probable prime, false otherwise
-//! \details VerifyPrime() is suitable for testing candidate primes created by others. Internally,
-//! VerifyPrime() utilizes IsPrime() and one-round RabinMillerTest(). If the candiate passes and
-//! level is greater than 1, then 10 round RabinMillerTest() primality testing is performed.
+// more reliable than IsPrime(), used to verify primes generated by others
CRYPTOPP_DLL bool CRYPTOPP_API VerifyPrime(RandomNumberGenerator &rng, const Integer &p, unsigned int level = 1);
-//! \class PrimeSelector
-//! \brief Application callback to signal suitability of a cabdidate prime
class CRYPTOPP_DLL PrimeSelector
{
public:
@@ -84,16 +51,8 @@ public:
virtual bool IsAcceptable(const Integer &candidate) const =0;
};
-//! \brief Finds a random prime of special form
-//! \param p an Integer reference to receive the prime
-//! \param max the maximum value
-//! \param equiv the equivalence class based on the parameter mod
-//! \param mod the modulus used to reduce the equivalence class
-//! \param pSelector pointer to a PrimeSelector function for the application to signal suitability
-//! \returns true if and only if FirstPrime() finds a prime and returns the prime through p. If FirstPrime()
-//! returns false, then no such prime exists and the value of p is undefined
-//! \details FirstPrime() uses a fast sieve to find the first probable prime
-//! in <tt>{x | p<=x<=max and x%mod==equiv}</tt>
+// use a fast sieve to find the first probable prime in {x | p<=x<=max and x%mod==equiv}
+// returns true iff successful, value of p is undefined if no such prime exists
CRYPTOPP_DLL bool CRYPTOPP_API FirstPrime(Integer &p, const Integer &max, const Integer &equiv, const Integer &mod, const PrimeSelector *pSelector);
CRYPTOPP_DLL unsigned int CRYPTOPP_API PrimeSearchInterval(const Integer &max);