78 int modulusSize = 2048;
82 throw InvalidArgument(
"InvertibleRabinFunction: specified modulus size is too small");
85 bool rFound=
false, sFound=
false;
89 (
"EquivalentTo", 3)(
"Mod", 4);
90 m_p.GenerateRandom(rng, primeParam);
91 m_q.GenerateRandom(rng, primeParam);
93 while (!(rFound && sFound))
98 if (!rFound && jp==1 && jq==-1)
104 if (!sFound && jp==-1 && jq==1)
176 out = modn.
Divide(out, r);
178 if ((jq==-1 && out.
IsEven()) || (jq==1 && out.
IsOdd()))
192 pass = pass && m_p * m_q ==
m_n;
193 pass = pass && m_u * m_q % m_p == 1;
206 return GetValueHelper<RabinFunction>(
this,
name, valueType, pValue).Assignable()
215 AssignFromHelper<RabinFunction>(
this,
source)
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
int Jacobi(const Integer &aIn, const Integer &bIn)
An invalid argument was detected.
Classes for Rabin encryption and signature schemes.
AlgorithmParameters MakeParametersForTwoPrimesOfEqualSize(unsigned int productBitLength)
Integer ApplyFunction(const Integer &x) const
Applies the trapdoor.
bool IsOdd() const
Determines if the Integer is odd parity.
Integer CalculateInverse(RandomNumberGenerator &rng, const Integer &x) const
Calculates the inverse of an element.
void DEREncode(BufferedTransformation &bt) const
#define NAMESPACE_BEGIN(x)
CRYPTOPP_DLL bool GetIntValue(const char *name, int &value) const
Get a named value with type int.
bool IsEven() const
Determines if the Integer is even parity.
const Integer & Square(const Integer &a) const
Square an element in the ring.
Ring of congruence classes modulo n.
Interface for random number generators.
Integer CRT(const Integer &xp, const Integer &p, const Integer &xq, const Integer &q, const Integer &u)
static const Integer &CRYPTOPP_API One()
Integer representing 1.
bool VerifyPrime(RandomNumberGenerator &rng, const Integer &p, unsigned int level)
Verifies a prime number.
Rabin trapdoor function using the public key.
const Integer & Multiply(const Integer &a, const Integer &b) const
Multiplies elements in the ring.
bool IsPositive() const
Determines if the Integer is positive.
Integer Squared() const
Multiply this integer by itself.
void DEREncode(BufferedTransformation &bt) const
Multiple precision integer with arithmetic operations.
void BERDecode(BufferedTransformation &bt)
AssignFromHelperClass< T, BASE > AssignFromHelper(T *pObject, const NameValuePairs &source)
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg)
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
const Integer & Divide(const Integer &a, const Integer &b) const
Divides elements in the ring.
Classes and functions for working with ANS.1 objects.
Classes for SHA-1 and SHA-2 family of message digests.
#define CRYPTOPP_SET_FUNCTION_ENTRY(name)
Classes and functions for number theoretic operations.
Integer ModularSquareRoot(const Integer &a, const Integer &p)
void DEREncode(BufferedTransformation &bt) const
Encode in DER format.
Integer EuclideanMultiplicativeInverse(const Integer &a, const Integer &b)
#define pass(a, b, c, mul, X)
#define CRYPTOPP_GET_FUNCTION_ENTRY(name)
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
An object that implements NameValuePairs.
Integer InverseMod(const Integer &n) const
calculate multiplicative inverse of *this mod n
Multiple precision integer with arithmetic operations.
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
void BERDecode(const byte *input, size_t inputLen)
Decode from BER format.
Class file for performing modular arithmetic.
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.
Interface for retrieving values given their names.
void DoQuickSanityCheck() const
Perform a quick sanity check.
GetValueHelperClass< T, BASE > GetValueHelper(const T *pObject, const char *name, const std::type_info &valueType, void *pValue, const NameValuePairs *searchFirst=NULL)