18 template <class GROUP_PARAMETERS, class COFACTOR_OPTION = typename GROUP_PARAMETERS::DefaultCofactorOption>
31 typedef typename GroupParameters::Element
Element;
40 : m_groupParameters(params) {}
45 {m_groupParameters.BERDecode(bt);}
53 template <
class T1,
class T2>
55 {m_groupParameters.Initialize(v1, v2);}
65 template <
class T1,
class T2,
class T3>
67 {m_groupParameters.Initialize(v1, v2, v3);}
79 template <
class T1,
class T2,
class T3,
class T4>
81 {m_groupParameters.Initialize(v1, v2, v3, v4);}
100 unsigned int AgreedValueLength()
const {
return GetAbstractGroupParameters().GetEncodedElementSize(
false);}
122 x.
Encode(privateKey, StaticPrivateKeyLength());
136 Integer x(privateKey, StaticPrivateKeyLength());
148 x.Encode(privateKey, StaticPrivateKeyLength());
150 params.
EncodeElement(
true, y, privateKey+StaticPrivateKeyLength());
156 memcpy(publicKey, privateKey+StaticPrivateKeyLength(), EphemeralPublicKeyLength());
160 const byte *staticPrivateKey,
const byte *ephemeralPrivateKey,
161 const byte *staticOtherPublicKey,
const byte *ephemeralOtherPublicKey,
162 bool validateStaticOtherPublicKey=
true)
const 167 Element WW = params.
DecodeElement(staticOtherPublicKey, validateStaticOtherPublicKey);
168 Element VV = params.
DecodeElement(ephemeralOtherPublicKey,
true);
170 Integer s(staticPrivateKey, StaticPrivateKeyLength());
171 Integer u(ephemeralPrivateKey, StaticPrivateKeyLength());
172 Element V = params.
DecodeElement(ephemeralPrivateKey+StaticPrivateKeyLength(),
false);
182 P = m_groupParameters.MultiplyElements(P, VV);
195 Element
P = m_groupParameters.CascadeExponentiate(VV, k*e, WW, k*(e*tt%r));
MQV_Domain(T1 v1, T2 v2)
Construct a MQV domain.
Utility functions for the Crypto++ library.
GroupParameters m_groupParameters
void Encode(byte *output, size_t outputLen, Signedness sign=UNSIGNED) const
Encode in big-endian format.
void GenerateStaticPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
Generate a static public key from a private key in this domain.
#define NAMESPACE_BEGIN(x)
Interface for Discrete Log (DL) group parameters.
MQV_Domain(T1 v1, T2 v2, T3 v3, T4 v4)
Construct a MQV domain.
const DL_GroupParameters< Element > & GetAbstractGroupParameters() const
unsigned int EphemeralPublicKeyLength() const
Provides the size of ephemeral public key.
Abstract base classes that provide a uniform interface to this library.
virtual Integer ConvertElementToInteger(const Element &element) const =0
Converts an element to an Integer.
Ring of congruence classes modulo n.
Interface for random number generators.
MQV_Domain(BufferedTransformation &bt)
Construct a MQV domain.
Classes for performing mathematics over different fields.
static const Integer &CRYPTOPP_API One()
Integer representing 1.
MQV_Domain< DL_GroupParameters_GFP_DefaultSafePrime > MQV
Menezes-Qu-Vanstone in GF(p) with key validation, AKA MQV
unsigned int BitCount() const
Determines the number of bits required to represent the Integer.
MQV domain for performing authenticated key agreement.
No cofactor multiplication applied.
GROUP_PARAMETERS GroupParameters
virtual void SimultaneousExponentiate(Element *results, const Element &base, const Integer *exponents, unsigned int exponentsCount) const =0
Exponentiates a base to multiple exponents.
static Integer CRYPTOPP_API Power2(size_t e)
Exponentiates to a power of 2.
unsigned int EphemeralPrivateKeyLength() const
Provides the size of ephemeral private key.
unsigned int StaticPrivateKeyLength() const
Provides the size of the static private key.
Multiple precision integer with arithmetic operations.
unsigned int AgreedValueLength() const
Provides the size of the agreed value.
void GenerateStaticPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
Generate static private key in this domain.
GroupParameters::Element Element
MQV_Domain< GROUP_PARAMETERS, COFACTOR_OPTION > Domain
Classes and functions for schemes based on Discrete Logs (DL) over GF(p)
virtual Element DecodeElement(const byte *encoded, bool checkForGroupMembership) const =0
Decodes the element.
Exception thrown when an invalid group element is encountered.
virtual Integer GetCofactor() const
Retrieves the cofactor.
void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
Generate ephemeral public key.
const Integer & Divide(const Integer &a, const Integer &b) const
Divides elements in the ring.
DL_GroupParameters< Element > & AccessAbstractGroupParameters()
MQV_Domain(const GroupParameters ¶ms)
Construct a MQV domain.
void * memcpy(void *a, const void *b, size_t c)
#define CRYPTOPP_UNUSED(x)
virtual void EncodeElement(bool reversible, const Element &element, byte *encoded) const =0
Encodes the element.
Multiple precision integer with arithmetic operations.
MQV_Domain(T1 v1, T2 v2, T3 v3)
Construct a MQV domain.
MQV_Domain()
Construct a MQV domain.
Interface for crypto prameters.
virtual Integer GetMaxExponent() const =0
Retrieves the maximum exponent for the group.
CryptoParameters & AccessCryptoParameters()
Retrieves the crypto parameters for this domain.
Class file for performing modular arithmetic.
const GroupParameters & GetGroupParameters() const
Retrieves the group parameters for this domain.
Interface for domains of authenticated key agreement protocols.
GroupParameters & AccessGroupParameters()
Retrieves the group parameters for this domain.
void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
Generate ephemeral private key.
virtual Element ExponentiateBase(const Integer &exponent) const
Retrieves the subgroup generator.
bool Agree(byte *agreedValue, const byte *staticPrivateKey, const byte *ephemeralPrivateKey, const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey=true) const
Derive agreed value.
unsigned int StaticPublicKeyLength() const
Provides the size of the static public key.
Cofactor multiplication compatible with ordinary Diffie-Hellman.
virtual Element ExponentiateElement(const Element &base, const Integer &exponent) const
Exponentiates an element.
virtual bool IsIdentity(const Element &element) const =0
Determines if an element is an identity.
virtual const Integer & GetSubgroupOrder() const =0
Retrieves the subgroup order.