11 #ifndef CRYPTOPP_IMPORTS 38 const word r3a = (16 + 5 - r) % 16;
39 const word r3b = (16 + 13 - r) % 16;
40 const word r4 = (8 + 5 - r/2) % 8;
68 CRYPTOPP_UNUSED(rng), CRYPTOPP_UNUSED(level);
76 return GetValueHelper(
this, name, valueType, pValue).Assignable()
77 CRYPTOPP_GET_FUNCTION_ENTRY(
Modulus)
83 AssignFromHelper(
this, source)
84 CRYPTOPP_SET_FUNCTION_ENTRY(
Modulus)
94 int modulusSize = 2048;
98 throw InvalidArgument(
"InvertibleRWFunction: specified modulus length is too small");
130 DoQuickSanityCheck();
139 rInv = modn.MultiplicativeInverse(r);
140 }
while (rInv.IsZero());
142 re = modn.Multiply(re, x);
145 if (Jacobi(cp, m_p) * Jacobi(cq, m_q) != 1)
147 cp = cp.IsOdd() ? (cp+m_p) >> 1 : cp >> 1;
148 cq = cq.IsOdd() ? (cq+m_q) >> 1 : cq >> 1;
155 cp = ModularSquareRoot(cp, m_p);
157 cq = ModularSquareRoot(cq, m_q);
160 Integer y = CRT(cq, m_q, cp, m_p, m_u);
161 y = modn.Multiply(y, rInv);
171 pass = pass && m_p >
Integer::One() && m_p%8 == 3 && m_p < m_n;
172 pass = pass && m_q >
Integer::One() && m_q%8 == 7 && m_q < m_n;
173 pass = pass && m_u.IsPositive() && m_u < m_p;
176 pass = pass && m_p * m_q == m_n;
177 pass = pass && m_u * m_q % m_p == 1;
186 return GetValueHelper<RWFunction>(
this, name, valueType, pValue).Assignable()
187 CRYPTOPP_GET_FUNCTION_ENTRY(
Prime1)
188 CRYPTOPP_GET_FUNCTION_ENTRY(
Prime2)
195 AssignFromHelper<RWFunction>(
this, source)
196 CRYPTOPP_SET_FUNCTION_ENTRY(
Prime1)
197 CRYPTOPP_SET_FUNCTION_ENTRY(
Prime2)
Base class for all exceptions thrown by Crypto++.
const char * MultiplicativeInverseOfPrime2ModPrime1()
Integer.
An invalid argument was detected.
const char * Prime2()
Integer.
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
Some other error occurred not belong to any of the above categories.
Ring of congruence classes modulo n.
Interface for random number generators.
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
void Randomize(RandomNumberGenerator &rng, size_t bitCount)
Set this Integer to random integer.
static const Integer & One()
Integer representing 1.
Integer ApplyFunction(const Integer &x) const
Applies the trapdoor.
bool GetIntValue(const char *name, int &value) const
Get a named value with type int.
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg)
const char * Prime1()
Integer.
Classes for Rabin-Williams signature schemes.
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
bool VerifyPrime(RandomNumberGenerator &rng, const Integer &p, unsigned int level=1)
Verifies a prime number.
void Negate()
Reverse the Sign of the Integer.
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
Multiple precision integer with arithmetic operations.
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.
const T & STDMIN(const T &a, const T &b)
Replacement function for std::min.
Classes and functions for working with ANS.1 objects.
Classes and functions for number theoretic operations.
void DEREncode(BufferedTransformation &bt) const
Encode in DER format.
An object that implements NameValuePairs.
const char * Modulus()
Integer.
Integer InverseMod(const Integer &n) const
calculate multiplicative inverse of *this mod n
static const Integer & Zero()
Integer representing 0.
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.
Crypto++ library namespace.
Interface for retrieving values given their names.