54 pass = pass &&
Jacobi(m_r, m_n) == -1 &&
Jacobi(m_s, m_n) == -1;
62 return GetValueHelper(
this, name, valueType, pValue).Assignable()
63 CRYPTOPP_GET_FUNCTION_ENTRY(
Modulus)
71 AssignFromHelper(
this, source)
72 CRYPTOPP_SET_FUNCTION_ENTRY(
Modulus)
84 int modulusSize = 2048;
88 throw InvalidArgument(
"InvertibleRabinFunction: specified modulus size is too small");
91 bool rFound=
false, sFound=
false;
95 (
"EquivalentTo", 3)(
"Mod", 4);
99 while (!(rFound && sFound))
104 if (!rFound && jp==1 && jq==-1)
110 if (!sFound && jp==-1 && jq==1)
182 out = modn.
Divide(out, r);
184 if ((jq==-1 && out.
IsEven()) || (jq==1 && out.
IsOdd()))
194 pass = pass && m_p >
Integer::One() && m_p%4 == 3 && m_p < m_n;
196 pass = pass && m_q >
Integer::One() && m_q%4 == 3 && m_q < m_n;
202 pass = pass && m_p * m_q == m_n;
204 pass = pass && m_u * m_q % m_p == 1;
206 pass = pass &&
Jacobi(m_r, m_p) == 1;
208 pass = pass &&
Jacobi(m_r, m_q) == -1;
210 pass = pass &&
Jacobi(m_s, m_p) == -1;
212 pass = pass &&
Jacobi(m_s, m_q) == 1;
225 return GetValueHelper<RabinFunction>(
this, name, valueType, pValue).Assignable()
226 CRYPTOPP_GET_FUNCTION_ENTRY(
Prime1)
227 CRYPTOPP_GET_FUNCTION_ENTRY(
Prime2)
234 AssignFromHelper<RabinFunction>(
this, source)
235 CRYPTOPP_SET_FUNCTION_ENTRY(
Prime1)
236 CRYPTOPP_SET_FUNCTION_ENTRY(
Prime2)
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.
const char * MultiplicativeInverseOfPrime2ModPrime1()
Integer.
const char * Prime2()
Integer.
const char * Modulus()
Integer.
const char * QuadraticResidueModPrime2()
Integer.
const char * QuadraticResidueModPrime1()
Integer.
const char * Prime1()
Integer.
Classes and functions for number theoretic operations.
CRYPTOPP_DLL int Jacobi(const Integer &a, const Integer &b)
Calculate the Jacobi symbol.
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.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.