7#if CRYPTOPP_MSC_VERSION
8# pragma warning(disable: 4589)
21#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
22void 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);
65 pass = pass && m_e >= 8 && m_e < m_n;
72 return GetValueHelper(
this, name, valueType, pValue).Assignable()
73 CRYPTOPP_GET_FUNCTION_ENTRY(Modulus)
74 CRYPTOPP_GET_FUNCTION_ENTRY(PublicExponent)
80 AssignFromHelper(
this, source)
81 CRYPTOPP_SET_FUNCTION_ENTRY(Modulus)
82 CRYPTOPP_SET_FUNCTION_ENTRY(PublicExponent)
90 int modulusSize = 1023*2;
94 throw InvalidArgument(
"InvertibleESIGNFunction: specified modulus size is too small");
96 if (modulusSize % 3 != 0)
97 throw InvalidArgument(
"InvertibleESIGNFunction: modulus size must be divisible by 3");
102 throw InvalidArgument(
"InvertibleESIGNFunction: public exponents less than 8 may not be secure");
112 if (param.
GetValue(
"Seed", seedParam))
115 throw InvalidArgument(
"InvertibleESIGNFunction::GenerateRandom: buffer overflow");
118 std::memcpy(seed + 4, seedParam.
begin(), seedParam.
size());
131 m_n = m_p * m_p * m_q;
139 m_n.BERDecode(privateKey);
140 m_e.BERDecode(privateKey);
149 m_n.DEREncode(privateKey);
150 m_e.DEREncode(privateKey);
167 z = x << (2*GetK()+2);
168 re = a_exp_b_mod_c(r, m_e, m_n);
177 while ((w1 >> (2*GetK()+1)).IsPositive());
199 pass = pass && m_p * m_p * m_q == m_n;
212 return GetValueHelper<ESIGNFunction>(
this, name, valueType, pValue).Assignable()
213 CRYPTOPP_GET_FUNCTION_ENTRY(Prime1)
214 CRYPTOPP_GET_FUNCTION_ENTRY(Prime2)
220 AssignFromHelper<ESIGNFunction>(
this, source)
221 CRYPTOPP_SET_FUNCTION_ENTRY(Prime1)
222 CRYPTOPP_SET_FUNCTION_ENTRY(Prime2)
Classes for working with NameValuePairs.
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
Classes and functions for working with ANS.1 objects.
An object that implements NameValuePairs.
void MessageEnd()
Signals the end of messages to the object.
Combines two sets of NameValuePairs.
Used to pass byte array input as part of a NameValuePairs object.
const byte * begin() const
Pointer to the first byte in the memory block.
size_t size() const
Length of the memory block.
void DoQuickSanityCheck() const
Perform a quick sanity check.
void MessageEnd()
Signals the end of messages to the object.
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
void DEREncode(BufferedTransformation &bt) const
Encode this object into a BufferedTransformation.
void BERDecode(BufferedTransformation &bt)
Decode this object from a BufferedTransformation.
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
Integer ApplyFunction(const Integer &x) const
Applies the trapdoor.
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
Multiple precision integer with arithmetic operations.
static void Divide(Integer &r, Integer &q, const Integer &a, const Integer &d)
Extended Division.
void DEREncode(BufferedTransformation &bt) const
Encode in DER format.
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs ¶ms=g_nullNameValuePairs)
Generate a random number.
bool NotZero() const
Determines if the Integer is non-0.
static const Integer & Zero()
Integer representing 0.
void Randomize(RandomNumberGenerator &rng, size_t bitCount)
Set this Integer to random integer.
static Integer Power2(size_t e)
Exponentiates to a power of 2.
void BERDecode(const byte *input, size_t inputLen)
Decode from BER format.
unsigned int BitCount() const
Determines the number of bits required to represent the Integer.
@ PRIME
a number which is probabilistically prime
bool IsOdd() const
Determines if the Integer is odd parity.
static const Integer & One()
Integer representing 1.
An invalid argument was detected.
Integer CalculateRandomizedInverse(RandomNumberGenerator &rng, const Integer &x) const
Applies the inverse of the trapdoor function, using random data if required.
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
Check this object for errors.
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg)
void DEREncode(BufferedTransformation &bt) const
Encode this object into a BufferedTransformation.
void BERDecode(BufferedTransformation &bt)
Decode this object from a BufferedTransformation.
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
Ring of congruence classes modulo n.
const Integer & Divide(const Integer &a, const Integer &b) const
Divides elements in the ring.
Interface for retrieving values given their names.
T GetValueWithDefault(const char *name, T defaultValue) const
Get a named value.
bool GetValue(const char *name, T &value) const
Get a named value.
CRYPTOPP_DLL bool GetIntValue(const char *name, int &value) const
Get a named value with type int.
Template implementing constructors for public key algorithm classes.
Interface for random number generators.
static const size_type ELEMS_MAX
Returns the maximum number of elements the block can hold.
void resize(size_type newSize)
Change size and preserve contents.
PK_FinalTemplate< TF_VerifierImpl< SchemeOptions > > Verifier
implements PK_Verifier interface
virtual Integer MaxImage() const
Returns the maximum size of a representation after the trapdoor function is applied bound to a public...
Library configuration file.
unsigned int word32
32-bit unsigned datatype
CRYPTOPP_DLL RandomNumberGenerator & NullRNG()
Random Number Generator that does not produce random numbers.
@ BIG_ENDIAN_ORDER
byte order is big-endian
Classes providing ESIGN signature schemes as defined in IEEE P1363a.
Multiple precision integer with arithmetic operations.
const T & STDMIN(const T &a, const T &b)
Replacement function for std::min.
void PutWord(bool assumeAligned, ByteOrder order, byte *block, T value, const byte *xorBlock=NULL)
Access a block of memory.
Class file for performing modular arithmetic.
Crypto++ library namespace.
Classes and functions for number theoretic operations.
CRYPTOPP_DLL bool VerifyPrime(RandomNumberGenerator &rng, const Integer &p, unsigned int level=1)
Verifies a number is probably prime.
Classes for SHA-1 and SHA-2 family of message digests.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.