7 #if CRYPTOPP_MSC_VERSION 8 # pragma warning(disable: 4189 4589) 11 #ifndef CRYPTOPP_IMPORTS 23 #if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) 24 void TestInstantiations_gfpcrypt()
48 int modulusSize = 1024, defaultSubgroupOrderSize;
54 defaultSubgroupOrderSize = 160;
57 defaultSubgroupOrderSize = 224;
60 defaultSubgroupOrderSize = 256;
74 pass = pass && ((pSize==1024 && qSize==160) || (pSize==2048 && qSize==224) || (pSize==2048 && qSize==256) || (pSize==3072 && qSize==256));
79 const byte *recoverableMessage,
size_t recoverableMessageLength,
81 byte *representative,
size_t representativeBitLength)
const 88 const size_t representativeByteLength =
BitsToBytes(representativeBitLength);
92 memset(representative, 0, paddingLength);
95 if (digestSize*8 > representativeBitLength)
97 Integer h(representative, representativeByteLength);
98 h >>= representativeByteLength*8 - representativeBitLength;
99 h.
Encode(representative, representativeByteLength);
104 const byte *recoverableMessage,
size_t recoverableMessageLength,
106 byte *representative,
size_t representativeBitLength)
const 114 const size_t representativeByteLength =
BitsToBytes(representativeBitLength);
116 const size_t paddingLength =
SaturatingSubtract(representativeByteLength, digestSize);
118 memset(representative, 0, paddingLength);
119 hash.
TruncatedFinal(representative+paddingLength,
STDMIN(representativeByteLength, digestSize));
121 if (digestSize*8 >= representativeBitLength)
123 Integer h(representative, representativeByteLength);
124 h >>= representativeByteLength*8 - representativeBitLength + 1;
125 h.
Encode(representative, representativeByteLength);
161 pass = pass &&
Jacobi(g*g-4, p)==-1;
167 if (fullValidate && pass)
173 pass = pass &&
Jacobi(g, p) == 1;
189 int modulusSize, subgroupOrderSize;
194 if (!alg.
GetIntValue(
"SubgroupOrderSize", subgroupOrderSize))
258 return GetValueHelper<DL_GroupParameters<Element> >(
this,
name, valueType, pValue)
272 return ASN1::id_dsa();
void DEREncode(BufferedTransformation &bt) const
Encode this object into a BufferedTransformation.
bool IsIdentity(const Integer &element) const
Determines if an element is an identity.
void AssignFrom(const NameValuePairs &source)
Assign values to this object.
int Jacobi(const Integer &aIn, const Integer &bIn)
An invalid argument was detected.
bool ValidateElement(unsigned int level, const Integer &element, const DL_FixedBasePrecomputation< Integer > *precomp) const
Check the element for errors.
Integer CascadeExponentiate(const Integer &x, const Integer &e1, const Integer &y, const Integer &e2) const
TODO.
void BERDecode(BufferedTransformation &bt)
Decode this object from a BufferedTransformation.
virtual Element Exponentiate(const DL_GroupPrecomputation< Element > &group, const Integer &exponent) const =0
Utility functions for the Crypto++ library.
void SetModulusAndSubgroupGenerator(const Integer &p, const Integer &g)
void Encode(byte *output, size_t outputLen, Signedness sign=UNSIGNED) const
Encode in big-endian format.
bool IsOdd() const
Determines if the Integer is odd parity.
T GetValueWithDefault(const char *name, T defaultValue) const
Get a named value.
Integer GetGroupOrder() const
Retrieves the order of the group.
Integer a_times_b_mod_c(const Integer &x, const Integer &y, const Integer &m)
size_t BitsToBytes(size_t bitCount)
Returns the number of 8-bit bytes or octets required for the specified number of bits.
#define NAMESPACE_BEGIN(x)
CRYPTOPP_DLL bool GetIntValue(const char *name, int &value) const
Get a named value with type int.
const Integer & GetModulus() const
void SetSubgroupOrder(const Integer &q)
ASN.1 object identifiers for algorthms and schemes.
void EncodeElement(bool reversible, const Element &element, byte *encoded) const
Encodes the element.
void ComputeMessageRepresentative(RandomNumberGenerator &rng, const byte *recoverableMessage, size_t recoverableMessageLength, HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, byte *representative, size_t representativeBitLength) const
Library configuration file.
Ring of congruence classes modulo n.
bool FastSubgroupCheckAvailable() const
Interface for random number generators.
Combines two sets of NameValuePairs.
Generator of prime numbers of special forms.
Element CascadeExponentiate(const Element &element1, const Integer &exponent1, const Element &element2, const Integer &exponent2) const
unsigned int DiscreteLogWorkFactor(unsigned int n)
static const Integer &CRYPTOPP_API One()
Integer representing 1.
bool VerifyPrime(RandomNumberGenerator &rng, const Integer &p, unsigned int level)
Verifies a prime number.
OID GetAlgorithmID() const
virtual const Element & GetSubgroupGenerator() const
Retrieves the subgroup generator.
Integer GetMaxExponent() const
Retrieves the maximum exponent for the group.
unsigned int BitCount() const
Determines the number of bits required to represent the Integer.
bool IsPositive() const
Determines if the Integer is positive.
bool ValidateGroup(RandomNumberGenerator &rng, unsigned int level) const
bool GetValue(const char *name, T &value) const
Get a named value.
void SimultaneousExponentiate(Element *results, const Element &base, const Integer *exponents, unsigned int exponentsCount) const
Exponentiates a base to multiple exponents.
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
const Integer & Generator() const
Retrieve the generator.
CRYPTOPP_DLL int GetIntValueWithDefault(const char *name, int defaultValue) const
Get a named value with type int, with default.
static Integer CRYPTOPP_API Power2(size_t e)
Exponentiates to a power of 2.
const Integer & GetSubgroupOrder() const
Retrieves the subgroup order.
Multiple precision integer with arithmetic operations.
T1 SaturatingSubtract(const T1 &a, const T2 &b)
Performs a saturating subtract clamped at 0.
Classes and functions for schemes based on Discrete Logs (DL) over GF(p)
const DL_GroupPrecomputation< Element > & GetGroupPrecomputation() const
Retrieves the group precomputation.
AssignFromHelperClass< T, BASE > AssignFromHelper(T *pObject, const NameValuePairs &source)
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg)
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
Exception thrown when an invalid group element is encountered.
virtual Integer GetCofactor() const
Retrieves the cofactor.
const T & STDMIN(const T &a, const T &b)
Replacement function for std::min.
#define CRYPTOPP_ASSERT(exp)
unsigned int GetEncodedElementSize(bool reversible) const
Retrieves the encoded element's size.
Classes and functions for working with ANS.1 objects.
void Initialize(const DL_GroupParameters_IntegerBased ¶ms)
Initialize a group parameters over integers.
#define CRYPTOPP_SET_FUNCTION_ENTRY(name)
Classes and functions for number theoretic operations.
Integer ComputeGroupOrder(const Integer &modulus) const
void DEREncode(BufferedTransformation &bt) const
Encode in DER format.
#define pass(a, b, c, mul, X)
Integer DecodeElement(const byte *encoded, bool checkForGroupMembership) const
Decodes the element.
Element MultiplyElements(const Element &a, const Element &b) const
#define CRYPTOPP_GET_FUNCTION_ENTRY(name)
#define CRYPTOPP_UNUSED(x)
RandomNumberGenerator & NullRNG()
Random Number Generator that does not produce random numbers.
bool ValidateGroup(RandomNumberGenerator &rng, unsigned int level) const
Check the group for errors.
void Generate(signed int delta, RandomNumberGenerator &rng, unsigned int pbits, unsigned qbits)
Generate a Prime and Generator.
Multiple precision integer with arithmetic operations.
static const Integer &CRYPTOPP_API Zero()
Integer representing 0.
std::vector< char * > parameters
void BERDecode(const byte *input, size_t inputLen)
Decode from BER format.
Class file for performing modular arithmetic.
std::pair< const byte *, unsigned int > HashIdentifier
const Integer & Prime() const
Retrieve first prime.
void SimultaneousExponentiate(Element *results, const Element &base, const Integer *exponents, unsigned int exponentsCount) const
Exponentiates a base to multiple exponents in the ring.
void ComputeMessageRepresentative(RandomNumberGenerator &rng, const byte *recoverableMessage, size_t recoverableMessageLength, HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, byte *representative, size_t representativeBitLength) const
#define CRYPTOPP_SET_FUNCTION_ENTRY2(name1, name2)
virtual unsigned int GetDefaultSubgroupOrderSize(unsigned int modulusSize) const
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg)
virtual Element ExponentiateElement(const Element &base, const Integer &exponent) const
Exponentiates an element.
unsigned int ByteCount() const
Determines the number of bytes required to represent the Integer.
const Integer & SubPrime() const
Retrieve second prime.
bool NotNegative() const
Determines if the Integer is non-negative.
Interface for retrieving values given their names.
Template implementing constructors for public key algorithm classes.