13 #if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) 14 void LUC_TestInstantiations()
26 s = (k + x*(r+
e)) % q;
36 return (Vsg*Vsg + Vry*Vry + r*r) % p == (Vsg * Vry * r + 4) % p;
41 return Lucas(exponent, m_g, static_cast<const DL_GroupPrecomputation_LUC &>(group).GetModulus());
46 for (
unsigned int i=0; i<exponentsCount; i++)
47 results[i] =
Lucas(exponents[i], base, GetModulus());
69 return Lucas(m_e, x, m_n);
113 int modulusSize = 2048;
116 if (modulusSize < 16)
117 throw InvalidArgument(
"InvertibleLUCFunction: specified modulus size is too small");
121 if (m_e < 5 || m_e.IsEven())
122 throw InvalidArgument(
"InvertibleLUCFunction: invalid public exponent");
127 m_p.GenerateRandom(rng, primeParam);
128 m_q.GenerateRandom(rng, primeParam);
131 m_u = m_q.InverseMod(m_p);
136 GenerateRandom(rng,
MakeParameters(
"ModulusSize", (
int)keybits)(
"PublicExponent", e));
160 seq.
Put(version,
sizeof(version));
173 DoQuickSanityCheck();
182 pass = pass && m_u.IsPositive() && m_u < m_p;
185 pass = pass && m_p * m_q == m_n;
190 pass = pass && m_u * m_q % m_p == 1;
199 return GetValueHelper<LUCFunction>(
this,
name, valueType, pValue).Assignable()
208 AssignFromHelper<LUCFunction>(
this,
source)
void Initialize(RandomNumberGenerator &rng, unsigned int modulusBits, const Integer &eStart=17)
Create a LUC private key.
An invalid argument was detected.
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg)
Classes for working with NameValuePairs.
AlgorithmParameters MakeParametersForTwoPrimesOfEqualSize(unsigned int productBitLength)
bool IsOdd() const
Determines if the Integer is odd parity.
T GetValueWithDefault(const char *name, T defaultValue) const
Get a named value.
LUCPrimeSelector(const Integer &e)
bool Verify(const DL_GroupParameters< Integer > ¶ms, const DL_PublicKey< Integer > &publicKey, const Integer &e, const Integer &r, const Integer &s) const
#define NAMESPACE_BEGIN(x)
void BERDecode(BufferedTransformation &bt)
CRYPTOPP_DLL bool GetIntValue(const char *name, int &value) const
Get a named value with type int.
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
virtual Element ExponentiatePublicElement(const Integer &exponent) const
Interface for random number generators.
Integer InverseLucas(const Integer &e, const Integer &m, const Integer &p, const Integer &q, const Integer &u)
Integer Exponentiate(const DL_GroupPrecomputation< Element > &group, const Integer &exponent) const
Integer ApplyFunction(const Integer &x) const
Applies the trapdoor.
static const Integer &CRYPTOPP_API One()
Integer representing 1.
bool VerifyPrime(RandomNumberGenerator &rng, const Integer &p, unsigned int level)
Verifies a prime number.
Interface for Discrete Log (DL) public keys.
Classes for the LUC cryptosystem.
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
Integer CalculateInverse(RandomNumberGenerator &rng, const Integer &x) const
Calculates the inverse of an element.
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
Application callback to signal suitability of a cabdidate prime.
Multiple precision integer with arithmetic operations.
Integer Lucas(const Integer &e, const Integer &pIn, const Integer &n)
AssignFromHelperClass< T, BASE > AssignFromHelper(T *pObject, const NameValuePairs &source)
void BERDecodeError()
Raises a BERDecodeErr.
Classes and functions for working with ANS.1 objects.
The LUC inverse function.
Classes for SHA-1 and SHA-2 family of message digests.
#define CRYPTOPP_SET_FUNCTION_ENTRY(name)
void Sign(const DL_GroupParameters< Integer > ¶ms, const Integer &x, const Integer &k, const Integer &e, Integer &r, Integer &s) const
Classes and functions for number theoretic operations.
void DEREncode(BufferedTransformation &bt) const
#define pass(a, b, c, mul, X)
#define CRYPTOPP_GET_FUNCTION_ENTRY(name)
#define CRYPTOPP_UNUSED(x)
void SimultaneousExponentiate(Element *results, const Element &base, const Integer *exponents, unsigned int exponentsCount) const
Exponentiates a base to multiple exponents.
bool RelativelyPrime(const Integer &a, const Integer &b)
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
An object that implements NameValuePairs.
Multiple precision integer with arithmetic operations.
void BERDecode(BufferedTransformation &bt)
bool IsAcceptable(const Integer &candidate) const
const PrimeSelector * GetSelectorPointer() const
virtual Element ExponentiateBase(const Integer &exponent) const
Retrieves the subgroup generator.
void DEREncode(BufferedTransformation &bt) const
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
virtual Integer GetGroupOrder() const
Retrieves the order of the group.
Interface for retrieving values given their names.
Template implementing constructors for public key algorithm classes.
GetValueHelperClass< T, BASE > GetValueHelper(const T *pObject, const char *name, const std::type_info &valueType, void *pValue, const NameValuePairs *searchFirst=NULL)
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
virtual const Integer & GetSubgroupOrder() const =0
Retrieves the subgroup order.