7 #if CRYPTOPP_MSC_VERSION 8 # pragma warning(disable: 4589) 21 #if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) 22 void ESIGN_TestInstantiations()
56 return STDMIN(a_exp_b_mod_c(x, m_e, m_n) >> (2*GetK()+2),
MaxImage());
61 CRYPTOPP_UNUSED(rng), CRYPTOPP_UNUSED(level);
64 pass = pass && m_e >= 8 && m_e < m_n;
70 return GetValueHelper(
this, name, valueType, pValue).Assignable()
71 CRYPTOPP_GET_FUNCTION_ENTRY(
Modulus)
78 AssignFromHelper(
this, source)
79 CRYPTOPP_SET_FUNCTION_ENTRY(
Modulus)
88 int modulusSize = 1023*2;
92 throw InvalidArgument(
"InvertibleESIGNFunction: specified modulus size is too small");
94 if (modulusSize % 3 != 0)
95 throw InvalidArgument(
"InvertibleESIGNFunction: modulus size must be divisible by 3");
100 throw InvalidArgument(
"InvertibleESIGNFunction: public exponents less than 8 may not be secure");
110 if (param.
GetValue(
"Seed", seedParam))
112 seed.
resize(seedParam.size() + 4);
113 memcpy(seed + 4, seedParam.begin(), seedParam.size());
115 PutWord(
false, BIG_ENDIAN_ORDER, seed, (word32)0);
117 PutWord(
false, BIG_ENDIAN_ORDER, seed, (word32)1);
122 m_p.GenerateRandom(rng, primeParam);
123 m_q.GenerateRandom(rng, primeParam);
126 m_n = m_p * m_p * m_q;
128 assert(m_n.
BitCount() == (
unsigned int)modulusSize);
136 m_p.BERDecode(privateKey);
137 m_q.BERDecode(privateKey);
138 privateKey.MessageEnd();
146 m_p.DEREncode(privateKey);
147 m_q.DEREncode(privateKey);
148 privateKey.MessageEnd();
153 DoQuickSanityCheck();
162 z = x << (2*GetK()+2);
163 re = a_exp_b_mod_c(r, m_e, m_n);
172 while ((w1 >> (2*GetK()+1)).IsPositive());
175 Integer t = modp.Divide(w0 * r % m_p, m_e * re % m_p);
180 cout <<
"f = " << x << endl;
181 cout <<
"r = " << r << endl;
182 cout <<
"z = " << z << endl;
183 cout <<
"a = " << a << endl;
184 cout <<
"w0 = " << w0 << endl;
185 cout <<
"w1 = " << w1 << endl;
186 cout <<
"t = " << t << endl;
187 cout <<
"s = " << s << endl;
195 pass = pass && m_p >
Integer::One() && m_p.IsOdd() && m_p < m_n;
196 pass = pass && m_q >
Integer::One() && m_q.IsOdd() && m_q < m_n;
197 pass = pass && m_p.BitCount() == m_q.BitCount();
199 pass = pass && m_p * m_p * m_q == m_n;
207 return GetValueHelper<ESIGNFunction>(
this, name, valueType, pValue).Assignable()
208 CRYPTOPP_GET_FUNCTION_ENTRY(
Prime1)
209 CRYPTOPP_GET_FUNCTION_ENTRY(
Prime2)
215 AssignFromHelper<ESIGNFunction>(
this, source)
216 CRYPTOPP_SET_FUNCTION_ENTRY(
Prime1)
217 CRYPTOPP_SET_FUNCTION_ENTRY(
Prime2)
used to pass byte array input as part of a NameValuePairs object
Integer CalculateRandomizedInverse(RandomNumberGenerator &rng, const Integer &x) const
Applies the inverse of the trapdoor function, using random data if required.
An invalid argument was detected.
Classes for working with NameValuePairs.
a number which is probabilistically prime
const char * Prime2()
Integer.
T GetValueWithDefault(const char *name, T defaultValue) const
Get a named value.
void resize(size_type newSize)
Change size and preserve contents.
Library configuration file.
Ring of congruence classes modulo n.
void DEREncode(BufferedTransformation &bt) const
Encode this object into a BufferedTransformation.
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.
SecByteBlock is a SecBlock<byte> typedef.
static const Integer & One()
Integer representing 1.
This file contains classes that implement the ESIGN signature schemes as defined in IEEE P1363a...
bool GetIntValue(const char *name, int &value) const
Get a named value with type int.
PK_FinalTemplate< TF_VerifierImpl< SchemeOptions > > Verifier
implements PK_Verifier interface
const char * Prime1()
Integer.
unsigned int BitCount() const
number of significant bits = floor(log2(abs(*this))) + 1
void BERDecode(BufferedTransformation &bt)
Decode this object from a BufferedTransformation.
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
bool GetValue(const char *name, T &value) const
Get a named value.
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
const char * PublicExponent()
Integer.
bool VerifyPrime(RandomNumberGenerator &rng, const Integer &p, unsigned int level=1)
Verifies a prime number.
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
static Integer Power2(size_t e)
Exponentiates to a power of 2.
Multiple precision integer with arithmetic operations.
virtual Integer MaxImage() const
Returns the maximum size of a message after the trapdoor function is applied bound to a public key...
void BERDecode(BufferedTransformation &bt)
Decode this object from a BufferedTransformation.
RandomNumberGenerator & NullRNG()
Random Number Generator that does not produce random numbers.
const T & STDMIN(const T &a, const T &b)
Replacement function for std::min.
static void Divide(Integer &r, Integer &q, const Integer &a, const Integer &d)
calculate r and q such that (a == d*q + r) && (0 <= r < abs(d))
Classes and functions for working with ANS.1 objects.
Classes for SHA-1 and SHA-2 family of message digests.
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
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.
static const Integer & Zero()
Integer representing 0.
void BERDecode(const byte *input, size_t inputLen)
Decode from BER format.
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
Class file for performing modular arithmetic.
Crypto++ library namespace.
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg)
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
void DEREncode(BufferedTransformation &bt) const
Encode this object into a BufferedTransformation.
Integer ApplyFunction(const Integer &x) const
Applies the trapdoor.
Interface for retrieving values given their names.
A template implementing constructors for public key algorithm classes.