8 #ifndef CRYPTOPP_IMPORTS
10 NAMESPACE_BEGIN(CryptoPP)
35 const word r3a = (16 + 5 - r) % 16;
36 const word r3b = (16 + 13 - r) % 16;
37 const word r4 = (8 + 5 - r/2) % 8;
72 return GetValueHelper(
this, name, valueType, pValue).Assignable()
73 CRYPTOPP_GET_FUNCTION_ENTRY(Modulus)
79 AssignFromHelper(
this, source)
80 CRYPTOPP_SET_FUNCTION_ENTRY(Modulus)
90 int modulusSize = 2048;
94 throw InvalidArgument(
"InvertibleRWFunction: specified modulus length is too small");
126 DoQuickSanityCheck();
137 }
while (rInv.IsZero());
140 re = modn.Multiply(re, x);
143 if (Jacobi(cp, m_p) * Jacobi(cq, m_q) != 1)
145 cp = cp.IsOdd() ? (cp+m_p) >> 1 : cp >> 1;
146 cq = cq.IsOdd() ? (cq+m_q) >> 1 : cq >> 1;
153 cp = ModularSquareRoot(cp, m_p);
155 cq = ModularSquareRoot(cq, m_q);
158 Integer y = CRT(cq, m_q, cp, m_p, m_u);
159 y = modn.Multiply(y, rInv);
160 y = STDMIN(y, m_n-y);
161 if (ApplyFunction(y) != x)
169 pass = pass && m_p >
Integer::One() && m_p%8 == 3 && m_p < m_n;
170 pass = pass && m_q >
Integer::One() && m_q%8 == 7 && m_q < m_n;
171 pass = pass && m_u.IsPositive() && m_u < m_p;
174 pass = pass && m_p * m_q == m_n;
175 pass = pass && m_u * m_q % m_p == 1;
178 pass = pass && VerifyPrime(rng, m_p, level-2) && VerifyPrime(rng, m_q, level-2);
184 return GetValueHelper<RWFunction>(
this, name, valueType, pValue).Assignable()
185 CRYPTOPP_GET_FUNCTION_ENTRY(Prime1)
186 CRYPTOPP_GET_FUNCTION_ENTRY(Prime2)
187 CRYPTOPP_GET_FUNCTION_ENTRY(MultiplicativeInverseOfPrime2ModPrime1)
193 AssignFromHelper<RWFunction>(
this, source)
194 CRYPTOPP_SET_FUNCTION_ENTRY(Prime1)
195 CRYPTOPP_SET_FUNCTION_ENTRY(Prime2)
196 CRYPTOPP_SET_FUNCTION_ENTRY(MultiplicativeInverseOfPrime2ModPrime1)
base class for all exceptions thrown by Crypto++
exception thrown when an invalid argument is detected
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
to be implemented by derived classes, users should use one of the above functions instead ...
some error 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
Integer MultiplicativeInverse() const
return inverse if 1 or -1, otherwise return 0
static const Integer & One()
avoid calling constructors for these frequently used integers
bool GetIntValue(const char *name, int &value) const
get a named value with type int
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg)
This file contains classes that implement the Rabin-Williams signature schemes as defined in IEEE P13...
void AssignFrom(const NameValuePairs &source)
assign values from source to this object
multiple precision integer and basic arithmetics
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
to be implemented by derived classes, users should use one of the above functions instead ...
void DEREncode(BufferedTransformation &bt) const
encode using Distinguished Encoding Rules, put result into a BufferedTransformation object ...
Integer InverseMod(const Integer &n) const
calculate multiplicative inverse of *this mod n
static const Integer & Zero()
avoid calling constructors for these frequently used integers
void AssignFrom(const NameValuePairs &source)
assign values from source to this object
interface for retrieving values given their names