11 NAMESPACE_BEGIN(CryptoPP)
13 void ESIGN_TestInstantiations()
46 return STDMIN(a_exp_b_mod_c(x, m_e, m_n) >> (2*GetK()+2), MaxImage());
53 pass = pass && m_e >= 8 && m_e < m_n;
59 return GetValueHelper(
this, name, valueType, pValue).Assignable()
60 CRYPTOPP_GET_FUNCTION_ENTRY(Modulus)
61 CRYPTOPP_GET_FUNCTION_ENTRY(PublicExponent)
67 AssignFromHelper(
this, source)
68 CRYPTOPP_SET_FUNCTION_ENTRY(Modulus)
69 CRYPTOPP_SET_FUNCTION_ENTRY(PublicExponent)
77 int modulusSize = 1023*2;
81 throw InvalidArgument(
"InvertibleESIGNFunction: specified modulus size is too small");
83 if (modulusSize % 3 != 0)
84 throw InvalidArgument(
"InvertibleESIGNFunction: modulus size must be divisible by 3");
89 throw InvalidArgument(
"InvertibleESIGNFunction: public exponents less than 8 may not be secure");
97 AlgorithmParameters primeParam = MakeParameters(
"Min", minP)(
"Max", maxP)(
"RandomNumberType", Integer::PRIME);
99 if (param.
GetValue(
"Seed", seedParam))
101 seed.
resize(seedParam.size() + 4);
102 memcpy(seed + 4, seedParam.begin(), seedParam.size());
104 PutWord(
false, BIG_ENDIAN_ORDER, seed, (word32)0);
106 PutWord(
false, BIG_ENDIAN_ORDER, seed, (word32)1);
111 m_p.GenerateRandom(rng, primeParam);
112 m_q.GenerateRandom(rng, primeParam);
115 m_n = m_p * m_p * m_q;
117 assert(m_n.
BitCount() == modulusSize);
123 m_n.BERDecode(privateKey);
124 m_e.BERDecode(privateKey);
125 m_p.BERDecode(privateKey);
126 m_q.BERDecode(privateKey);
127 privateKey.MessageEnd();
137 privateKey.MessageEnd();
142 DoQuickSanityCheck();
151 z = x << (2*GetK()+2);
152 re = a_exp_b_mod_c(r, m_e, m_n);
161 while ((w1 >> 2*GetK()+1).IsPositive());
184 pass = pass && m_p >
Integer::One() && m_p.IsOdd() && m_p < m_n;
185 pass = pass && m_q >
Integer::One() && m_q.IsOdd() && m_q < m_n;
186 pass = pass && m_p.BitCount() == m_q.BitCount();
188 pass = pass && m_p * m_p * m_q == m_n;
190 pass = pass && VerifyPrime(rng, m_p, level-2) && VerifyPrime(rng, m_q, level-2);
196 return GetValueHelper<ESIGNFunction>(
this, name, valueType, pValue).Assignable()
197 CRYPTOPP_GET_FUNCTION_ENTRY(Prime1)
198 CRYPTOPP_GET_FUNCTION_ENTRY(Prime2)
204 AssignFromHelper<ESIGNFunction>(
this, source)
205 CRYPTOPP_SET_FUNCTION_ENTRY(Prime1)
206 CRYPTOPP_SET_FUNCTION_ENTRY(Prime2)
used to pass byte array input as part of a NameValuePairs object
exception thrown when an invalid argument is detected
T GetValueWithDefault(const char *name, T defaultValue) const
get a named value, returns the default if the name doesn't exist
void resize(size_type newSize)
change size and preserve contents
ring of congruence classes modulo n
void DEREncode(BufferedTransformation &bt) const
encode this object into a BufferedTransformation, using DER (Distinguished Encoding Rules) ...
interface for random number generators
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
check this object for errors
static const Integer & One()
avoid calling constructors for these frequently used integers
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
unsigned int BitCount() const
number of significant bits = floor(log2(abs(*this))) + 1
void BERDecode(BufferedTransformation &bt)
decode this object from a BufferedTransformation, using BER (Basic Encoding Rules) ...
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, returns true if the name exists
void AssignFrom(const NameValuePairs &source)
assign values from source to this object
static Integer Power2(size_t e)
return the integer 2**e
multiple precision integer and basic arithmetics
void BERDecode(BufferedTransformation &bt)
decode this object from a BufferedTransformation, using BER (Basic Encoding Rules) ...
RandomNumberGenerator & NullRNG()
returns a reference that can be passed to functions that ask for a RNG but doesn't actually use it ...
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))
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 ...
static const Integer & Zero()
avoid calling constructors for these frequently used integers
void AssignFrom(const NameValuePairs &source)
assign values from source to this object
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg)
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 this object into a BufferedTransformation, using DER (Distinguished Encoding Rules) ...
interface for retrieving values given their names
A template implementing constructors for public key algorithm classes.