7 #ifndef CRYPTOPP_ECCRYPTO_H 8 #define CRYPTOPP_ECCRYPTO_H 38 typedef typename EllipticCurve::Point
Point;
50 : m_compress(false), m_encodeAsOID(true) {Initialize(oid);}
58 : m_compress(false), m_encodeAsOID(true) {Initialize(ec, G, n, k);}
63 : m_compress(false), m_encodeAsOID(true) {BERDecode(bt);}
73 this->m_groupPrecomputation.SetCurve(ec);
74 this->SetSubgroupGenerator(G);
82 void Initialize(
const OID &oid);
85 bool GetVoidValue(
const char *
name,
const std::type_info &valueType,
void *pValue)
const;
104 GetCurve().EncodePoint(encoded, element, m_compress);
106 element.x.Encode(encoded, GetEncodedElementSize(
false));
111 return GetCurve().EncodedPointSize(m_compress);
113 return GetCurve().GetField().MaxElementByteLength();
118 if (!GetCurve().DecodePoint(result, encoded, GetEncodedElementSize(
true)))
120 if (checkForGroupMembership && !ValidateElement(1, result, NULL))
124 Integer ConvertElementToInteger(
const Element &element)
const;
126 bool IsIdentity(
const Element &element)
const {
return element.identity;}
127 void SimultaneousExponentiate(Element *results,
const Element &base,
const Integer *exponents,
unsigned int exponentsCount)
const;
131 OID GetAlgorithmID()
const;
134 Element MultiplyElements(
const Element &
a,
const Element &
b)
const;
135 Element CascadeExponentiate(
const Element &element1,
const Integer &exponent1,
const Element &element2,
const Integer &exponent2)
const;
151 const EllipticCurve&
GetCurve()
const {
return this->m_groupPrecomputation.GetCurve();}
238 {this->GenerateRandom(rng, params);}
261 template <class EC, class COFACTOR_OPTION = typename DL_GroupParameters_EC<EC>::DefaultCofactorOption>
272 template <class EC, class COFACTOR_OPTION = typename DL_GroupParameters_EC<EC>::DefaultCofactorOption>
284 template <class EC, class COFACTOR_OPTION = typename DL_GroupParameters_EC<EC>::DefaultCofactorOption,
class HASH =
SHA256>
291 typedef ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption,
SHA256 >::Domain
ECHMQV256;
292 typedef ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption,
SHA384 >::Domain
ECHMQV384;
293 typedef ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption,
SHA512 >::Domain
ECHMQV512;
302 template <class EC, class COFACTOR_OPTION = typename DL_GroupParameters_EC<EC>::DefaultCofactorOption,
class HASH =
SHA256>
309 typedef ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption,
SHA256 >::Domain
ECFHMQV256;
310 typedef ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption,
SHA384 >::Domain
ECFHMQV384;
311 typedef ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption,
SHA512 >::Domain
ECFHMQV512;
324 template <
class EC,
class H>
353 template <
class EC,
class H>
375 template <
class EC,
class H>
376 struct ECDSA :
public DL_SS<DL_Keys_ECDSA<EC>, DL_Algorithm_ECDSA<EC>, DL_SignatureMessageEncodingMethod_DSA, H>
386 template <
class EC,
class H>
389 DL_Algorithm_ECDSA_RFC6979<EC, H>,
390 DL_SignatureMessageEncodingMethod_DSA,
392 ECDSA_RFC6979<EC,H> >
401 template <
class EC,
class H = SHA>
402 struct ECNR :
public DL_SS<DL_Keys_EC<EC>, DL_Algorithm_ECNR<EC>, DL_SignatureMessageEncodingMethod_NR, H>
449 {this->GenerateRandom(rng, params);}
470 virtual bool GetVoidValue(
const char *
name,
const std::type_info &valueType,
void *pValue)
const 472 return GetValueHelper<DL_PrivateKey_ECGDSA_ISO15946<EC>,
478 AssignFromHelper<DL_PrivateKey_ECGDSA_ISO15946<EC>,
571 template <
class EC,
class H>
573 DL_Keys_ECGDSA_ISO15946<EC>,
574 DL_Algorithm_ECGDSA_ISO15946<EC>,
575 DL_SignatureMessageEncodingMethod_DSA,
617 template <
class EC,
class HASH = SHA1,
class COFACTOR_OPTION = NoCofactorMultiplication,
bool DHAES_MODE = true,
bool LABEL_OCTETS = false>
621 DL_KeyAgreementAlgorithm_DH<typename EC::Point, COFACTOR_OPTION>,
622 DL_KeyDerivationAlgorithm_P1363<typename EC::Point, DHAES_MODE, P1363_KDF2<HASH> >,
623 DL_EncryptionAlgorithm_Xor<HMAC<HASH>, DHAES_MODE, LABEL_OCTETS>,
632 #ifdef CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES
Classes for Fully Hashed Menezes-Qu-Vanstone key agreement in GF(p)
DL_PublicKey_EC< EC > PublicKey
virtual void AssignFrom(const NameValuePairs &source)
Assign values to this object.
DL_GroupParameters_EC()
Construct an EC GroupParameters.
void SetPointCompression(bool compress)
virtual ~DL_GroupParameters_EC()
#define CRYPTOPP_STATIC_CONSTEXPR
void Initialize(RandomNumberGenerator &rng, const EC &ec, const Element &G, const Integer &n)
Create an EC private key.
virtual ~DL_PrivateKey_ECGDSA_ISO15946()
static std::string CRYPTOPP_API StaticAlgorithmName()
HMQV_Domain< DL_GroupParameters_EC< EC >, COFACTOR_OPTION, HASH > Domain
Classes for Elliptic Curves over prime fields.
Fully Hashed Menezes-Qu-Vanstone in GF(p)
Elliptic Curve over GF(p), where p is prime.
Fully Hashed Elliptic Curve Menezes-Qu-Vanstone.
#define NAMESPACE_BEGIN(x)
void SetEncodeAsOID(bool encodeAsOID)
Interface for Discrete Log (DL) group parameters.
Elliptic Curve DSA (ECDSA) signature scheme.
#define CRYPTOPP_DLL_TEMPLATE_CLASS
Converts an enumeration to a type suitable for use as a template parameter.
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
Abstract base classes that provide a uniform interface to this library.
void Initialize(const DL_GroupParameters_EC< EC > ¶ms, const Element &Q)
Initialize an EC Public Key using {GP,Q}.
Hashed Menezes-Qu-Vanstone in GF(p)
bool GetPointCompression() const
Elliptic Curve Discrete Log (DL) keys.
Elliptic Curve Discrete Log (DL) public key.
DL_FixedBasePrecomputation< Element > & AccessBasePrecomputation()
Retrieves the group precomputation.
void Initialize(const EC &ec, const Element &G, const Integer &n, const Integer &x)
Initialize an EC Private Key using {EC,G,n,x}.
Library configuration file.
const Element & GetBase(const DL_GroupPrecomputation< Element > &group) const
Interface for random number generators.
ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA384 >::Domain ECFHMQV384
const DL_GroupParameters< Element > & GetAbstractGroupParameters() const
Elliptic Curve Discrete Log (DL) private key.
Discrete Log (DL) encryption scheme.
EllipticCurve::Point Point
ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA1 >::Domain ECHMQV160
Classes for Hashed Menezes-Qu-Vanstone key agreement in GF(p)
Elliptic Curve German Digital Signature Algorithm signature scheme.
virtual void SetPublicElement(const Element &y)
Discrete Log (DL) signature scheme.
Classes for Elliptic Curves over binary fields.
DL_PrivateKey_ECGDSA_ISO15946< EC > PrivateKey
Elliptic Curve German DSA keys for ISO/IEC 15946.
void Initialize(const EC &ec, const Element &G, const Integer &n, const Element &Q)
Initialize an EC Public Key using {EC,G,n,Q}.
ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA384 >::Domain ECHMQV384
Classes for HMAC message authentication codes.
DL_GroupParameters_EC(const EllipticCurve &ec, const Point &G, const Integer &n, const Integer &k=Integer::Zero())
Construct an EC GroupParameters.
bool GetThisPointer(T *&ptr) const
Get a pointer to this object.
MQV domain for performing authenticated key agreement.
Hashed Elliptic Curve Menezes-Qu-Vanstone.
ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA512 >::Domain ECHMQV512
const EllipticCurve & GetCurve() const
ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA256 >::Domain ECHMQV256
Elliptic Curve German DSA signature algorithm.
static std::string CRYPTOPP_API StaticAlgorithmNamePrefix()
bool IsIdentity(const Element &element) const
Classes for Diffie-Hellman key exchange.
void Initialize(const DL_GroupParameters_EC< EC > ¶ms, const Element &Q)
Initialize an EC Public Key using {GP,Q}.
FHMQV_Domain< DL_GroupParameters_EC< EC >, COFACTOR_OPTION, HASH > Domain
void Initialize(const EC &ec, const Element &G, const Integer &n, const Integer &x)
Initialize an EC Private Key using {EC,G,n,x}.
Integer GetMaxExponent() const
Retrieves the maximum exponent for the group.
Elliptic Curve Menezes-Qu-Vanstone.
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
Multiple precision integer with arithmetic operations.
Elliptic Curve over GF(2^n)
Elliptic Curve Integrated Encryption Scheme.
Elliptic Curve NR (ECNR) signature algorithm.
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
Classes and functions for schemes based on Discrete Logs (DL) over GF(p)
AssignFromHelperClass< T, BASE > AssignFromHelper(T *pObject, const NameValuePairs &source)
void DEREncodePublicKey(BufferedTransformation &bt) const
encode subjectPublicKey part of subjectPublicKeyInfo, without the BIT STRING header ...
Elliptic Curve DSA (ECDSA) signature algorithm.
Exception thrown when an invalid group element is encountered.
void Initialize(RandomNumberGenerator &rng, const EC &ec, const Element &G, const Integer &n)
Create an EC private key.
Elliptic Curve Diffie-Hellman.
void EncodeElement(bool reversible, const Element &element, byte *encoded) const
DL_GroupParameters_EC(const OID &oid)
Construct an EC GroupParameters.
Elliptic Curve DSA (ECDSA) signature algorithm based on RFC 6979.
DL_PublicKey_EC< EC > PublicKey
virtual void SetPublicElement(const Element &y)
Classes and functions for working with ANS.1 objects.
virtual void MakePublicKey(DL_PublicKey_ECGDSA_ISO15946< EC > &pub) const
Classes for SHA-1 and SHA-2 family of message digests.
Elliptic Curve Parameters.
void Initialize(RandomNumberGenerator &rng, const DL_GroupParameters_EC< EC > ¶ms)
Create an EC private key.
DL_GroupParameters< Element > & AccessAbstractGroupParameters()
#define CRYPTOPP_SET_FUNCTION_ENTRY(name)
DL_FixedBasePrecomputation< Element > & AccessPublicPrecomputation()
DSA signature algorithm based on RFC 6979.
DH_Domain< DL_GroupParameters_EC< EC >, COFACTOR_OPTION > Domain
void Initialize(const EC &ec, const Element &G, const Integer &n, const Element &Q)
Initialize an EC Public Key using {EC,G,n,Q}.
DL_PublicKey_ECGDSA_ISO15946< EC > PublicKey
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
uint8_t const size_t const size
bool GetEncodeAsOID() const
const DL_FixedBasePrecomputation< Element > & GetBasePrecomputation() const
Retrieves the group precomputation.
GROUP_PRECOMP m_groupPrecomputation
Elliptic Curve precomputation.
DL_GroupParameters_EC< EC > & AccessGroupParameters()
virtual unsigned int GetEncodedElementSize(bool reversible) const
Retrieves the encoded element's size.
Elliptic Curve German DSA key for ISO/IEC 15946.
DL_GroupParameters_EC(BufferedTransformation &bt)
Construct an EC GroupParameters.
bool FastSubgroupCheckAvailable() const
Integer InverseMod(const Integer &n) const
calculate multiplicative inverse of *this mod n
Element DecodeElement(const byte *encoded, bool checkForGroupMembership) const
Decodes the element.
Multiple precision integer with arithmetic operations.
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
virtual void AssignFrom(const NameValuePairs &source)
Assign values to this object.
ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA512 >::Domain ECFHMQV512
static const Integer &CRYPTOPP_API Zero()
Integer representing 0.
bool operator==(const ThisClass &rhs) const
Elliptic Curve German DSA key for ISO/IEC 15946.
Elliptic Curve DSA (ECDSA) deterministic signature scheme.
void Initialize(const EllipticCurve &ec, const Point &G, const Integer &n, const Integer &k=Integer::Zero())
Initialize an EC GroupParameters using {EC,G,n,k}.
virtual ~DL_PublicKey_EC()
ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA256 >::Domain ECFHMQV256
DL_PrivateKey_WithSignaturePairwiseConsistencyTest< DL_PrivateKey_EC< EC >, ECDSA< EC, SHA256 > > PrivateKey
DL_GroupParameters_EC< EC > ThisClass
IncompatibleCofactorMultiplication DefaultCofactorOption
static std::string CRYPTOPP_API StaticAlgorithmName()
Base implementation of Discrete Log (DL) group parameters.
MQV_Domain< DL_GroupParameters_EC< EC >, COFACTOR_OPTION > Domain
void Initialize(RandomNumberGenerator &rng, const DL_GroupParameters_EC< EC > ¶ms)
Create an EC private key.
virtual ~DL_PrivateKey_EC()
ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA1 >::Domain ECFHMQV160
DL_PublicKey_ECGDSA_ISO15946< EC > ThisClass
Classes for Menezes–Qu–Vanstone (MQV) key agreement.
virtual Element ExponentiateBase(const Integer &exponent) const
Retrieves the subgroup generator.
German Digital Signature Algorithm.
const Integer & GetSubgroupOrder() const
Retrieves the subgroup order.
void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size)
decode subjectPublicKey part of subjectPublicKeyInfo, without the BIT STRING header ...
unsigned int ExponentLength() const
void Initialize(const DL_GroupParameters_EC< EC > ¶ms, const Integer &x)
Initialize an EC Private Key using {GP,x}.
DL_PrivateKey_EC< EC > PrivateKey
virtual ~DL_PublicKey_ECGDSA_ISO15946()
virtual bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
void Initialize(const DL_GroupParameters_EC< EC > ¶ms, const Integer &x)
Initialize an EC Private Key using {GP,x}.
Elliptic Curve NR (ECNR) signature scheme.
unsigned int FieldElementLength() const
virtual Integer GetGroupOrder() const
Retrieves the order of the group.
Interface for retrieving values given their names.