Fabcoin Core  0.16.2
P2P Digital Currency
eccrypto.h
Go to the documentation of this file.
1 // eccrypto.h - written and placed in the public domain by Wei Dai
2 // deterministic signatures added by by Douglas Roark
3 
6 
7 #ifndef CRYPTOPP_ECCRYPTO_H
8 #define CRYPTOPP_ECCRYPTO_H
9 
10 #include "config.h"
11 #include "cryptlib.h"
12 #include "pubkey.h"
13 #include "integer.h"
14 #include "asn.h"
15 #include "hmac.h"
16 #include "sha.h"
17 #include "gfpcrypt.h"
18 #include "dh.h"
19 #include "mqv.h"
20 #include "hmqv.h"
21 #include "fhmqv.h"
22 #include "ecp.h"
23 #include "ec2n.h"
24 
26 
27 template <class EC>
33 {
35 
36 public:
37  typedef EC EllipticCurve;
38  typedef typename EllipticCurve::Point Point;
39  typedef Point Element;
41 
43 
45  DL_GroupParameters_EC() : m_compress(false), m_encodeAsOID(true) {}
46 
50  : m_compress(false), m_encodeAsOID(true) {Initialize(oid);}
51 
57  DL_GroupParameters_EC(const EllipticCurve &ec, const Point &G, const Integer &n, const Integer &k = Integer::Zero())
58  : m_compress(false), m_encodeAsOID(true) {Initialize(ec, G, n, k);}
59 
63  : m_compress(false), m_encodeAsOID(true) {BERDecode(bt);}
64 
71  void Initialize(const EllipticCurve &ec, const Point &G, const Integer &n, const Integer &k = Integer::Zero())
72  {
73  this->m_groupPrecomputation.SetCurve(ec);
74  this->SetSubgroupGenerator(G);
75  m_n = n;
76  m_k = k;
77  }
78 
82  void Initialize(const OID &oid);
83 
84  // NameValuePairs
85  bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
86  void AssignFrom(const NameValuePairs &source);
87 
88  // GeneratibleCryptoMaterial interface
90 
91  void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg);
92 
93  // DL_GroupParameters
94  const DL_FixedBasePrecomputation<Element> & GetBasePrecomputation() const {return this->m_gpc;}
96  const Integer & GetSubgroupOrder() const {return m_n;}
97  Integer GetCofactor() const;
98  bool ValidateGroup(RandomNumberGenerator &rng, unsigned int level) const;
99  bool ValidateElement(unsigned int level, const Element &element, const DL_FixedBasePrecomputation<Element> *precomp) const;
100  bool FastSubgroupCheckAvailable() const {return false;}
101  void EncodeElement(bool reversible, const Element &element, byte *encoded) const
102  {
103  if (reversible)
104  GetCurve().EncodePoint(encoded, element, m_compress);
105  else
106  element.x.Encode(encoded, GetEncodedElementSize(false));
107  }
108  virtual unsigned int GetEncodedElementSize(bool reversible) const
109  {
110  if (reversible)
111  return GetCurve().EncodedPointSize(m_compress);
112  else
113  return GetCurve().GetField().MaxElementByteLength();
114  }
115  Element DecodeElement(const byte *encoded, bool checkForGroupMembership) const
116  {
117  Point result;
118  if (!GetCurve().DecodePoint(result, encoded, GetEncodedElementSize(true)))
119  throw DL_BadElement();
120  if (checkForGroupMembership && !ValidateElement(1, result, NULL))
121  throw DL_BadElement();
122  return result;
123  }
124  Integer ConvertElementToInteger(const Element &element) const;
125  Integer GetMaxExponent() const {return GetSubgroupOrder()-1;}
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;
128  static std::string CRYPTOPP_API StaticAlgorithmNamePrefix() {return "EC";}
129 
130  // ASN1Key
131  OID GetAlgorithmID() const;
132 
133  // used by MQV
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;
136 
137  // non-inherited
138 
139  // enumerate OIDs for recommended parameters, use OID() to get first one
140  static OID CRYPTOPP_API GetNextRecommendedParametersOID(const OID &oid);
141 
142  void BERDecode(BufferedTransformation &bt);
143  void DEREncode(BufferedTransformation &bt) const;
144 
145  void SetPointCompression(bool compress) {m_compress = compress;}
146  bool GetPointCompression() const {return m_compress;}
147 
148  void SetEncodeAsOID(bool encodeAsOID) {m_encodeAsOID = encodeAsOID;}
149  bool GetEncodeAsOID() const {return m_encodeAsOID;}
150 
151  const EllipticCurve& GetCurve() const {return this->m_groupPrecomputation.GetCurve();}
152 
153  bool operator==(const ThisClass &rhs) const
154  {return this->m_groupPrecomputation.GetCurve() == rhs.m_groupPrecomputation.GetCurve() && this->m_gpc.GetBase(this->m_groupPrecomputation) == rhs.m_gpc.GetBase(rhs.m_groupPrecomputation);}
155 
156  //#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
157  //const Point& GetBasePoint() const {return this->GetSubgroupGenerator();}
158  //const Integer& GetBasePointOrder() const {return this->GetSubgroupOrder();}
159  //void LoadRecommendedParameters(const OID &oid) {Initialize(oid);}
160  //#endif
161 
162 protected:
163  unsigned int FieldElementLength() const {return GetCurve().GetField().MaxElementByteLength();}
164  unsigned int ExponentLength() const {return m_n.ByteCount();}
165 
166  OID m_oid; // set if parameters loaded from a recommended curve
167  Integer m_n; // order of base point
168  mutable Integer m_k; // cofactor
169  mutable bool m_compress, m_encodeAsOID; // presentation details
170 };
171 
175 template <class EC>
176 class DL_PublicKey_EC : public DL_PublicKeyImpl<DL_GroupParameters_EC<EC> >
177 {
178 public:
179  typedef typename EC::Point Element;
180 
181  virtual ~DL_PublicKey_EC() {}
182 
187  void Initialize(const DL_GroupParameters_EC<EC> &params, const Element &Q)
188  {this->AccessGroupParameters() = params; this->SetPublicElement(Q);}
189 
196  void Initialize(const EC &ec, const Element &G, const Integer &n, const Element &Q)
197  {this->AccessGroupParameters().Initialize(ec, G, n); this->SetPublicElement(Q);}
198 
199  // X509PublicKey
200  void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size);
202 };
203 
207 template <class EC>
208 class DL_PrivateKey_EC : public DL_PrivateKeyImpl<DL_GroupParameters_EC<EC> >
209 {
210 public:
211  typedef typename EC::Point Element;
212 
213  virtual ~DL_PrivateKey_EC() {}
214 
219  void Initialize(const DL_GroupParameters_EC<EC> &params, const Integer &x)
220  {this->AccessGroupParameters() = params; this->SetPrivateExponent(x);}
221 
228  void Initialize(const EC &ec, const Element &G, const Integer &n, const Integer &x)
229  {this->AccessGroupParameters().Initialize(ec, G, n); this->SetPrivateExponent(x);}
230 
238  {this->GenerateRandom(rng, params);}
239 
248  void Initialize(RandomNumberGenerator &rng, const EC &ec, const Element &G, const Integer &n)
249  {this->GenerateRandom(rng, DL_GroupParameters_EC<EC>(ec, G, n));}
250 
251  // PKCS8PrivateKey
252  void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size);
253  void DEREncodePrivateKey(BufferedTransformation &bt) const;
254 };
255 
261 template <class EC, class COFACTOR_OPTION = typename DL_GroupParameters_EC<EC>::DefaultCofactorOption>
262 struct ECDH
263 {
264  typedef DH_Domain<DL_GroupParameters_EC<EC>, COFACTOR_OPTION> Domain;
265 };
266 
272 template <class EC, class COFACTOR_OPTION = typename DL_GroupParameters_EC<EC>::DefaultCofactorOption>
273 struct ECMQV
274 {
275  typedef MQV_Domain<DL_GroupParameters_EC<EC>, COFACTOR_OPTION> Domain;
276 };
277 
284 template <class EC, class COFACTOR_OPTION = typename DL_GroupParameters_EC<EC>::DefaultCofactorOption, class HASH = SHA256>
285 struct ECHMQV
286 {
287  typedef HMQV_Domain<DL_GroupParameters_EC<EC>, COFACTOR_OPTION, HASH> Domain;
288 };
289 
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;
294 
302 template <class EC, class COFACTOR_OPTION = typename DL_GroupParameters_EC<EC>::DefaultCofactorOption, class HASH = SHA256>
303 struct ECFHMQV
304 {
305  typedef FHMQV_Domain<DL_GroupParameters_EC<EC>, COFACTOR_OPTION, HASH> Domain;
306 };
307 
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;
312 
316 template <class EC>
318 {
321 };
322 
323 // Forward declaration; documented below
324 template <class EC, class H>
325 struct ECDSA;
326 
330 template <class EC>
332 {
335 };
336 
340 template <class EC>
341 class DL_Algorithm_ECDSA : public DL_Algorithm_GDSA<typename EC::Point>
342 {
343 public:
345 };
346 
353 template <class EC, class H>
354 class DL_Algorithm_ECDSA_RFC6979 : public DL_Algorithm_DSA_RFC6979<typename EC::Point, H>
355 {
356 public:
357  CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "ECDSA-RFC6979";}
358 };
359 
363 template <class EC>
364 class DL_Algorithm_ECNR : public DL_Algorithm_NR<typename EC::Point>
365 {
366 public:
368 };
369 
375 template <class EC, class H>
376 struct ECDSA : public DL_SS<DL_Keys_ECDSA<EC>, DL_Algorithm_ECDSA<EC>, DL_SignatureMessageEncodingMethod_DSA, H>
377 {
378 };
379 
386 template <class EC, class H>
387 struct ECDSA_RFC6979 : public DL_SS<
388  DL_Keys_ECDSA<EC>,
389  DL_Algorithm_ECDSA_RFC6979<EC, H>,
390  DL_SignatureMessageEncodingMethod_DSA,
391  H,
392  ECDSA_RFC6979<EC,H> >
393 {
394  static std::string CRYPTOPP_API StaticAlgorithmName() {return std::string("ECDSA-RFC6979/") + H::StaticAlgorithmName();}
395 };
396 
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>
403 {
404 };
405 
406 // ******************************************
407 
408 template <class EC>
410 template <class EC>
412 
418 template <class EC>
419 class DL_PrivateKey_ECGDSA_ISO15946 : public DL_PrivateKeyImpl<DL_GroupParameters_EC<EC> >
420 {
421 public:
422  typedef typename EC::Point Element;
423 
425 
430  void Initialize(const DL_GroupParameters_EC<EC> &params, const Integer &x)
431  {this->AccessGroupParameters() = params; this->SetPrivateExponent(x);}
432 
439  void Initialize(const EC &ec, const Element &G, const Integer &n, const Integer &x)
440  {this->AccessGroupParameters().Initialize(ec, G, n); this->SetPrivateExponent(x);}
441 
449  {this->GenerateRandom(rng, params);}
450 
459  void Initialize(RandomNumberGenerator &rng, const EC &ec, const Element &G, const Integer &n)
460  {this->GenerateRandom(rng, DL_GroupParameters_EC<EC>(ec, G, n));}
461 
463  {
465  pub.AccessAbstractGroupParameters().AssignFrom(params);
466  const Integer &xInv = this->GetPrivateExponent().InverseMod(params.GetGroupOrder());
467  pub.SetPublicElement(params.ExponentiateBase(xInv));
468  }
469 
470  virtual bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
471  {
472  return GetValueHelper<DL_PrivateKey_ECGDSA_ISO15946<EC>,
473  DL_PrivateKey_ECGDSA_ISO15946<EC> >(this, name, valueType, pValue).Assignable();
474  }
475 
476  virtual void AssignFrom(const NameValuePairs &source)
477  {
478  AssignFromHelper<DL_PrivateKey_ECGDSA_ISO15946<EC>,
480  }
481 
482  // PKCS8PrivateKey
483  void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size);
484  void DEREncodePrivateKey(BufferedTransformation &bt) const;
485 };
486 
492 template <class EC>
493 class DL_PublicKey_ECGDSA_ISO15946 : public DL_PublicKeyImpl<DL_GroupParameters_EC<EC> >
494 {
496 
497 public:
498  typedef typename EC::Point Element;
499 
501 
506  void Initialize(const DL_GroupParameters_EC<EC> &params, const Element &Q)
507  {this->AccessGroupParameters() = params; this->SetPublicElement(Q);}
508 
515  void Initialize(const EC &ec, const Element &G, const Integer &n, const Element &Q)
516  {this->AccessGroupParameters().Initialize(ec, G, n); this->SetPublicElement(Q);}
517 
518  virtual void AssignFrom(const NameValuePairs &source)
519  {
520  DL_PrivateKey_ECGDSA_ISO15946<EC> *pPrivateKey = NULL;
521  if (source.GetThisPointer(pPrivateKey))
522  pPrivateKey->MakePublicKey(*this);
523  else
524  {
525  this->AccessAbstractGroupParameters().AssignFrom(source);
526  AssignFromHelper(this, source)
527  CRYPTOPP_SET_FUNCTION_ENTRY(PublicElement);
528  }
529  }
530 
531  // DL_PublicKey<T>
532  virtual void SetPublicElement(const Element &y)
533  {this->AccessPublicPrecomputation().SetBase(this->GetAbstractGroupParameters().GetGroupPrecomputation(), y);}
534 
535  // X509PublicKey
536  void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size);
538 };
539 
545 template <class EC>
547 {
550 };
551 
557 template <class EC>
559 {
560 public:
562 };
563 
571 template <class EC, class H>
572 struct ECGDSA : public DL_SS<
573  DL_Keys_ECGDSA_ISO15946<EC>,
574  DL_Algorithm_ECGDSA_ISO15946<EC>,
575  DL_SignatureMessageEncodingMethod_DSA,
576  H>
577 {
578  static std::string CRYPTOPP_API StaticAlgorithmName() {return std::string("ECGDSA-ISO15946/") + H::StaticAlgorithmName();}
579 };
580 
581 // ******************************************
582 
617 template <class EC, class HASH = SHA1, class COFACTOR_OPTION = NoCofactorMultiplication, bool DHAES_MODE = true, bool LABEL_OCTETS = false>
618 struct ECIES
619  : public DL_ES<
620  DL_Keys_EC<EC>,
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>,
624  ECIES<EC> >
625 {
626  // TODO: fix this after name is standardized
628 };
629 
631 
632 #ifdef CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES
633 #include "eccrypto.cpp"
634 #endif
635 
637 
656 
658 
659 #endif
SHA-384 message digest.
Definition: sha.h:81
Classes for Fully Hashed Menezes-Qu-Vanstone key agreement in GF(p)
DL_PublicKey_EC< EC > PublicKey
Definition: eccrypto.h:319
virtual void AssignFrom(const NameValuePairs &source)
Assign values to this object.
Definition: eccrypto.h:518
uint8_t byte
Definition: Common.h:57
DL_GroupParameters_EC()
Construct an EC GroupParameters.
Definition: eccrypto.h:45
EC::Point Element
Definition: eccrypto.h:211
void SetPointCompression(bool compress)
Definition: eccrypto.h:145
virtual ~DL_GroupParameters_EC()
Definition: eccrypto.h:42
#define CRYPTOPP_STATIC_CONSTEXPR
Definition: config.h:892
SHA-256 message digest.
Definition: sha.h:39
EC::Point Element
Definition: eccrypto.h:179
void Initialize(RandomNumberGenerator &rng, const EC &ec, const Element &G, const Integer &n)
Create an EC private key.
Definition: eccrypto.h:248
virtual ~DL_PrivateKey_ECGDSA_ISO15946()
Definition: eccrypto.h:424
static std::string CRYPTOPP_API StaticAlgorithmName()
Definition: eccrypto.h:394
Elliptic Curve DSA keys.
Definition: eccrypto.h:331
HMQV_Domain< DL_GroupParameters_EC< EC >, COFACTOR_OPTION, HASH > Domain
Definition: eccrypto.h:287
Classes for Elliptic Curves over prime fields.
Fully Hashed Menezes-Qu-Vanstone in GF(p)
Definition: fhmqv.h:24
Elliptic Curve over GF(p), where p is prime.
Definition: ecp.h:22
Fully Hashed Elliptic Curve Menezes-Qu-Vanstone.
Definition: eccrypto.h:303
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
void SetEncodeAsOID(bool encodeAsOID)
Definition: eccrypto.h:148
Interface for Discrete Log (DL) group parameters.
Definition: pubkey.h:736
Elliptic Curve DSA (ECDSA) signature scheme.
Definition: eccrypto.h:325
#define CRYPTOPP_DLL_TEMPLATE_CLASS
Definition: config.h:720
Converts an enumeration to a type suitable for use as a template parameter.
Definition: cryptlib.h:116
#define Q(i)
Definition: cast.cpp:199
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
Definition: eccrypto.h:357
Abstract base classes that provide a uniform interface to this library.
void Initialize(const DL_GroupParameters_EC< EC > &params, const Element &Q)
Initialize an EC Public Key using {GP,Q}.
Definition: eccrypto.h:506
Hashed Menezes-Qu-Vanstone in GF(p)
Definition: hmqv.h:23
bool GetPointCompression() const
Definition: eccrypto.h:146
Elliptic Curve Discrete Log (DL) keys.
Definition: eccrypto.h:317
Elliptic Curve Discrete Log (DL) public key.
Definition: eccrypto.h:176
DL_FixedBasePrecomputation< Element > & AccessBasePrecomputation()
Retrieves the group precomputation.
Definition: eccrypto.h:95
void Initialize(const EC &ec, const Element &G, const Integer &n, const Integer &x)
Initialize an EC Private Key using {EC,G,n,x}.
Definition: eccrypto.h:439
Library configuration file.
const Element & GetBase(const DL_GroupPrecomputation< Element > &group) const
Definition: eprecomp.h:64
Interface for random number generators.
Definition: cryptlib.h:1188
ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA384 >::Domain ECFHMQV384
Definition: eccrypto.h:310
const DL_GroupParameters< Element > & GetAbstractGroupParameters() const
Definition: pubkey.h:1240
Elliptic Curve Discrete Log (DL) private key.
Definition: eccrypto.h:208
Discrete Log (DL) encryption scheme.
Definition: pubkey.h:2155
Interface for buffered transformations.
Definition: cryptlib.h:1352
EllipticCurve::Point Point
Definition: eccrypto.h:38
ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA1 >::Domain ECHMQV160
Definition: eccrypto.h:290
Classes for Hashed Menezes-Qu-Vanstone key agreement in GF(p)
Elliptic Curve German Digital Signature Algorithm signature scheme.
Definition: eccrypto.h:572
virtual void SetPublicElement(const Element &y)
Definition: pubkey.h:1011
Discrete Log (DL) signature scheme.
Definition: pubkey.h:2132
Classes for Elliptic Curves over binary fields.
DL_PrivateKey_ECGDSA_ISO15946< EC > PrivateKey
Definition: eccrypto.h:549
Elliptic Curve German DSA keys for ISO/IEC 15946.
Definition: eccrypto.h:546
void Initialize(const EC &ec, const Element &G, const Integer &n, const Element &Q)
Initialize an EC Public Key using {EC,G,n,Q}.
Definition: eccrypto.h:515
#define a(i)
ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA384 >::Domain ECHMQV384
Definition: eccrypto.h:292
#define x(i)
Classes for HMAC message authentication codes.
const char * source
Definition: rpcconsole.cpp:60
DL_GroupParameters_EC(const EllipticCurve &ec, const Point &G, const Integer &n, const Integer &k=Integer::Zero())
Construct an EC GroupParameters.
Definition: eccrypto.h:57
bool GetThisPointer(T *&ptr) const
Get a pointer to this object.
Definition: cryptlib.h:324
MQV domain for performing authenticated key agreement.
Definition: mqv.h:27
Hashed Elliptic Curve Menezes-Qu-Vanstone.
Definition: eccrypto.h:285
ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA512 >::Domain ECHMQV512
Definition: eccrypto.h:293
const EllipticCurve & GetCurve() const
Definition: eccrypto.h:151
ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA256 >::Domain ECHMQV256
Definition: eccrypto.h:291
Elliptic Curve German DSA signature algorithm.
Definition: eccrypto.h:558
static std::string CRYPTOPP_API StaticAlgorithmNamePrefix()
Definition: eccrypto.h:128
bool IsIdentity(const Element &element) const
Definition: eccrypto.h:126
Classes for Diffie-Hellman key exchange.
void Initialize(const DL_GroupParameters_EC< EC > &params, const Element &Q)
Initialize an EC Public Key using {GP,Q}.
Definition: eccrypto.h:187
const char * name
Definition: rest.cpp:36
SHA-512 message digest.
Definition: sha.h:69
FHMQV_Domain< DL_GroupParameters_EC< EC >, COFACTOR_OPTION, HASH > Domain
Definition: eccrypto.h:305
void Initialize(const EC &ec, const Element &G, const Integer &n, const Integer &x)
Initialize an EC Private Key using {EC,G,n,x}.
Definition: eccrypto.h:228
Integer GetMaxExponent() const
Retrieves the maximum exponent for the group.
Definition: eccrypto.h:125
Elliptic Curve Menezes-Qu-Vanstone.
Definition: eccrypto.h:273
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
Definition: eccrypto.h:344
Multiple precision integer with arithmetic operations.
Definition: integer.h:43
Elliptic Curve over GF(2^n)
Definition: ec2n.h:24
Elliptic Curve Integrated Encryption Scheme.
Definition: eccrypto.h:618
SHA-1 message digest.
Definition: sha.h:25
Elliptic Curve NR (ECNR) signature algorithm.
Definition: eccrypto.h:364
#define CRYPTOPP_API
Definition: config.h:705
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
Definition: eccrypto.h:561
Classes and functions for schemes based on Discrete Logs (DL) over GF(p)
AssignFromHelperClass< T, BASE > AssignFromHelper(T *pObject, const NameValuePairs &source)
Definition: algparam.h:286
void DEREncodePublicKey(BufferedTransformation &bt) const
encode subjectPublicKey part of subjectPublicKeyInfo, without the BIT STRING header ...
Definition: eccrypto.cpp:661
Elliptic Curve DSA (ECDSA) signature algorithm.
Definition: eccrypto.h:341
Exception thrown when an invalid group element is encountered.
Definition: pubkey.h:726
void Initialize(RandomNumberGenerator &rng, const EC &ec, const Element &G, const Integer &n)
Create an EC private key.
Definition: eccrypto.h:459
#define b(i, j)
Diffie-Hellman domain.
Definition: dh.h:25
Elliptic Curve Diffie-Hellman.
Definition: eccrypto.h:262
void EncodeElement(bool reversible, const Element &element, byte *encoded) const
Definition: eccrypto.h:101
DL_GroupParameters_EC(const OID &oid)
Construct an EC GroupParameters.
Definition: eccrypto.h:49
Elliptic Curve DSA (ECDSA) signature algorithm based on RFC 6979.
Definition: eccrypto.h:354
DL_PublicKey_EC< EC > PublicKey
Definition: eccrypto.h:333
virtual void SetPublicElement(const Element &y)
Definition: eccrypto.h:532
Classes and functions for working with ANS.1 objects.
virtual void MakePublicKey(DL_PublicKey_ECGDSA_ISO15946< EC > &pub) const
Definition: eccrypto.h:462
Classes for SHA-1 and SHA-2 family of message digests.
Elliptic Curve Parameters.
Definition: eccrypto.h:32
void Initialize(RandomNumberGenerator &rng, const DL_GroupParameters_EC< EC > &params)
Create an EC private key.
Definition: eccrypto.h:237
DL_GroupParameters< Element > & AccessAbstractGroupParameters()
Definition: pubkey.h:1241
#define CRYPTOPP_SET_FUNCTION_ENTRY(name)
Definition: algparam.h:505
DL_FixedBasePrecomputation< Element > & AccessPublicPrecomputation()
Definition: pubkey.h:1245
DSA signature algorithm based on RFC 6979.
Definition: gfpcrypt.h:236
DH_Domain< DL_GroupParameters_EC< EC >, COFACTOR_OPTION > Domain
Definition: eccrypto.h:264
void Initialize(const EC &ec, const Element &G, const Integer &n, const Element &Q)
Initialize an EC Public Key using {EC,G,n,Q}.
Definition: eccrypto.h:196
DL_PublicKey_ECGDSA_ISO15946< EC > PublicKey
Definition: eccrypto.h:548
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
Definition: eccrypto.h:627
uint8_t const size_t const size
Definition: sha3.h:20
bool GetEncodeAsOID() const
Definition: eccrypto.h:149
const DL_FixedBasePrecomputation< Element > & GetBasePrecomputation() const
Retrieves the group precomputation.
Definition: eccrypto.h:94
GROUP_PRECOMP m_groupPrecomputation
Definition: pubkey.h:969
GDSA algorithm.
Definition: gfpcrypt.h:198
Elliptic Curve precomputation.
Definition: ec2n.h:98
DL_GroupParameters_EC< EC > & AccessGroupParameters()
Definition: pubkey.h:1093
virtual unsigned int GetEncodedElementSize(bool reversible) const
Retrieves the encoded element&#39;s size.
Definition: eccrypto.h:108
Elliptic Curve German DSA key for ISO/IEC 15946.
Definition: eccrypto.h:409
DL_GroupParameters_EC(BufferedTransformation &bt)
Construct an EC GroupParameters.
Definition: eccrypto.h:62
bool FastSubgroupCheckAvailable() const
Definition: eccrypto.h:100
Integer InverseMod(const Integer &n) const
calculate multiplicative inverse of *this mod n
Definition: integer.cpp:4370
Element DecodeElement(const byte *encoded, bool checkForGroupMembership) const
Decodes the element.
Definition: eccrypto.h:115
NR algorithm.
Definition: gfpcrypt.h:444
Multiple precision integer with arithmetic operations.
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
Definition: eccrypto.h:367
virtual void AssignFrom(const NameValuePairs &source)
Assign values to this object.
Definition: eccrypto.h:476
ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA512 >::Domain ECFHMQV512
Definition: eccrypto.h:311
static const Integer &CRYPTOPP_API Zero()
Integer representing 0.
Definition: integer.cpp:3027
bool operator==(const ThisClass &rhs) const
Definition: eccrypto.h:153
Elliptic Curve German DSA key for ISO/IEC 15946.
Definition: eccrypto.h:411
Elliptic Curve DSA (ECDSA) deterministic signature scheme.
Definition: eccrypto.h:387
#define NAMESPACE_END
Definition: config.h:201
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}.
Definition: eccrypto.h:71
virtual ~DL_PublicKey_EC()
Definition: eccrypto.h:181
ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA256 >::Domain ECFHMQV256
Definition: eccrypto.h:309
DL_PrivateKey_WithSignaturePairwiseConsistencyTest< DL_PrivateKey_EC< EC >, ECDSA< EC, SHA256 > > PrivateKey
Definition: eccrypto.h:334
DL_GroupParameters_EC< EC > ThisClass
Definition: eccrypto.h:34
IncompatibleCofactorMultiplication DefaultCofactorOption
Definition: eccrypto.h:40
static std::string CRYPTOPP_API StaticAlgorithmName()
Definition: eccrypto.h:578
Base implementation of Discrete Log (DL) group parameters.
Definition: pubkey.h:947
MQV_Domain< DL_GroupParameters_EC< EC >, COFACTOR_OPTION > Domain
Definition: eccrypto.h:275
void Initialize(RandomNumberGenerator &rng, const DL_GroupParameters_EC< EC > &params)
Create an EC private key.
Definition: eccrypto.h:448
virtual ~DL_PrivateKey_EC()
Definition: eccrypto.h:213
ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA1 >::Domain ECFHMQV160
Definition: eccrypto.h:308
DL_PublicKey_ECGDSA_ISO15946< EC > ThisClass
Definition: eccrypto.h:495
Classes for Menezes–Qu–Vanstone (MQV) key agreement.
virtual Element ExponentiateBase(const Integer &exponent) const
Retrieves the subgroup generator.
Definition: pubkey.h:803
German Digital Signature Algorithm.
Definition: gfpcrypt.h:402
#define G(x, y, z)
Definition: Hash.cpp:80
Object Identifier.
Definition: asn.h:166
const Integer & GetSubgroupOrder() const
Retrieves the subgroup order.
Definition: eccrypto.h:96
void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size)
decode subjectPublicKey part of subjectPublicKeyInfo, without the BIT STRING header ...
Definition: eccrypto.cpp:650
unsigned int ExponentLength() const
Definition: eccrypto.h:164
void Initialize(const DL_GroupParameters_EC< EC > &params, const Integer &x)
Initialize an EC Private Key using {GP,x}.
Definition: eccrypto.h:219
DL_PrivateKey_EC< EC > PrivateKey
Definition: eccrypto.h:320
virtual ~DL_PublicKey_ECGDSA_ISO15946()
Definition: eccrypto.h:500
virtual bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
Get a named value.
Definition: eccrypto.h:470
void Initialize(const DL_GroupParameters_EC< EC > &params, const Integer &x)
Initialize an EC Private Key using {GP,x}.
Definition: eccrypto.h:430
Elliptic Curve NR (ECNR) signature scheme.
Definition: eccrypto.h:402
unsigned int FieldElementLength() const
Definition: eccrypto.h:163
virtual Integer GetGroupOrder() const
Retrieves the order of the group.
Definition: pubkey.h:843
Interface for retrieving values given their names.
Definition: cryptlib.h:279
BASE_PRECOMP m_gpc
Definition: pubkey.h:970