55 pass = pass &&
Jacobi(m_r, m_n) == -1 &&
Jacobi(m_s, m_n) == -1;
63 return GetValueHelper(
this, name, valueType, pValue).Assignable()
64 CRYPTOPP_GET_FUNCTION_ENTRY(Modulus)
65 CRYPTOPP_GET_FUNCTION_ENTRY(QuadraticResidueModPrime1)
66 CRYPTOPP_GET_FUNCTION_ENTRY(QuadraticResidueModPrime2)
72 AssignFromHelper(
this, source)
73 CRYPTOPP_SET_FUNCTION_ENTRY(Modulus)
74 CRYPTOPP_SET_FUNCTION_ENTRY(QuadraticResidueModPrime1)
75 CRYPTOPP_SET_FUNCTION_ENTRY(QuadraticResidueModPrime2)
85 int modulusSize = 2048;
89 throw InvalidArgument(
"InvertibleRabinFunction: specified modulus size is too small");
92 bool rFound=
false, sFound=
false;
96 (
"EquivalentTo", 3)(
"Mod", 4);
100 while (!(rFound && sFound))
105 if (!rFound && jp==1 && jq==-1)
111 if (!sFound && jp==-1 && jq==1)
189 out = modn.
Divide(out, r);
191 if ((jq==-1 && out.
IsEven()) || (jq==1 && out.
IsOdd()))
201 pass = pass && m_p >
Integer::One() && m_p%4 == 3 && m_p < m_n;
203 pass = pass && m_q >
Integer::One() && m_q%4 == 3 && m_q < m_n;
209 pass = pass && m_p * m_q == m_n;
211 pass = pass && m_u * m_q % m_p == 1;
213 pass = pass &&
Jacobi(m_r, m_p) == 1;
215 pass = pass &&
Jacobi(m_r, m_q) == -1;
217 pass = pass &&
Jacobi(m_s, m_p) == -1;
219 pass = pass &&
Jacobi(m_s, m_q) == 1;
232 return GetValueHelper<RabinFunction>(
this, name, valueType, pValue).Assignable()
233 CRYPTOPP_GET_FUNCTION_ENTRY(Prime1)
234 CRYPTOPP_GET_FUNCTION_ENTRY(Prime2)
235 CRYPTOPP_GET_FUNCTION_ENTRY(MultiplicativeInverseOfPrime2ModPrime1)
241 AssignFromHelper<RabinFunction>(
this, source)
242 CRYPTOPP_SET_FUNCTION_ENTRY(Prime1)
243 CRYPTOPP_SET_FUNCTION_ENTRY(Prime2)
244 CRYPTOPP_SET_FUNCTION_ENTRY(MultiplicativeInverseOfPrime2ModPrime1)
Classes and functions for working with ANS.1 objects.
An object that implements NameValuePairs.
void DoQuickSanityCheck() const
Perform a quick sanity check.
Multiple precision integer with arithmetic operations.
void DEREncode(BufferedTransformation &bt) const
Encode in DER format.
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs ¶ms=g_nullNameValuePairs)
Generate a random number.
bool IsPositive() const
Determines if the Integer is positive.
Integer Squared() const
Multiply this integer by itself.
void BERDecode(const byte *input, size_t inputLen)
Decode from BER format.
bool IsOdd() const
Determines if the Integer is odd parity.
Integer InverseMod(const Integer &n) const
Calculate multiplicative inverse.
static const Integer & One()
Integer representing 1.
bool IsEven() const
Determines if the Integer is even parity.
An invalid argument was detected.
Integer CalculateInverse(RandomNumberGenerator &rng, const Integer &x) const
Calculates the inverse of an element.
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg)
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
Ring of congruence classes modulo n.
const Integer & Square(const Integer &a) const
Square an element in the ring.
const Integer & Multiply(const Integer &a, const Integer &b) const
Multiplies elements in the ring.
const Integer & Divide(const Integer &a, const Integer &b) const
Divides elements in the ring.
Interface for retrieving values given their names.
CRYPTOPP_DLL bool GetIntValue(const char *name, int &value) const
Get a named value with type int.
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
Integer ApplyFunction(const Integer &x) const
Applies the trapdoor.
Interface for random number generators.
Multiple precision integer with arithmetic operations.
Class file for performing modular arithmetic.
Crypto++ library namespace.
Classes and functions for number theoretic operations.
CRYPTOPP_DLL int Jacobi(const Integer &a, const Integer &b)
Calculate the Jacobi symbol.
CRYPTOPP_DLL bool IsPrime(const Integer &p)
Verifies a number is probably prime.
CRYPTOPP_DLL Integer ModularSquareRoot(const Integer &a, const Integer &p)
Extract a modular square root.
CRYPTOPP_DLL bool VerifyPrime(RandomNumberGenerator &rng, const Integer &p, unsigned int level=1)
Verifies a number is probably prime.
Integer EuclideanMultiplicativeInverse(const Integer &a, const Integer &b)
Calculate multiplicative inverse.
CRYPTOPP_DLL Integer CRT(const Integer &xp, const Integer &p, const Integer &xq, const Integer &q, const Integer &u)
Chinese Remainder Theorem.
Classes for Rabin encryption and signature schemes.
Classes for SHA-1 and SHA-2 family of message digests.
Debugging and diagnostic assertions.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.