Crypto++  5.6.5
Free C++ class library of cryptographic schemes
eccrypto.h
Go to the documentation of this file.
1 // eccrypto.h - written and placed in the public domain by Wei Dai
2 
3 //! \file eccrypto.h
4 //! \brief Classes and functions for Elliptic Curves over prime and binary fields
5 
6 #ifndef CRYPTOPP_ECCRYPTO_H
7 #define CRYPTOPP_ECCRYPTO_H
8 
9 #include "config.h"
10 #include "cryptlib.h"
11 #include "pubkey.h"
12 #include "integer.h"
13 #include "asn.h"
14 #include "hmac.h"
15 #include "sha.h"
16 #include "gfpcrypt.h"
17 #include "dh.h"
18 #include "mqv.h"
19 #include "hmqv.h"
20 #include "fhmqv.h"
21 #include "ecp.h"
22 #include "ec2n.h"
23 
24 NAMESPACE_BEGIN(CryptoPP)
25 
26 //! \brief Elliptic Curve Parameters
27 //! \tparam EC elliptic curve field
28 //! \details This class corresponds to the ASN.1 sequence of the same name
29 //! in ANSI X9.62 and SEC 1. EC is currently defined for ECP and EC2N.
30 template <class EC>
32 {
34 
35 public:
36  typedef EC EllipticCurve;
37  typedef typename EllipticCurve::Point Point;
38  typedef Point Element;
40 
41 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
42  virtual ~DL_GroupParameters_EC() {}
43 #endif
44 
45  DL_GroupParameters_EC() : m_compress(false), m_encodeAsOID(true) {}
46  DL_GroupParameters_EC(const OID &oid)
47  : m_compress(false), m_encodeAsOID(true) {Initialize(oid);}
48  DL_GroupParameters_EC(const EllipticCurve &ec, const Point &G, const Integer &n, const Integer &k = Integer::Zero())
49  : m_compress(false), m_encodeAsOID(true) {Initialize(ec, G, n, k);}
51  : m_compress(false), m_encodeAsOID(true) {BERDecode(bt);}
52 
53  void Initialize(const EllipticCurve &ec, const Point &G, const Integer &n, const Integer &k = Integer::Zero())
54  {
55  this->m_groupPrecomputation.SetCurve(ec);
56  this->SetSubgroupGenerator(G);
57  m_n = n;
58  m_k = k;
59  }
60  void Initialize(const OID &oid);
61 
62  // NameValuePairs
63  bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
64  void AssignFrom(const NameValuePairs &source);
65 
66  // GeneratibleCryptoMaterial interface
67  //! this implementation doesn't actually generate a curve, it just initializes the parameters with existing values
68  /*! parameters: (Curve, SubgroupGenerator, SubgroupOrder, Cofactor (optional)), or (GroupOID) */
69  void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &alg);
70 
71  // DL_GroupParameters
72  const DL_FixedBasePrecomputation<Element> & GetBasePrecomputation() const {return this->m_gpc;}
74  const Integer & GetSubgroupOrder() const {return m_n;}
75  Integer GetCofactor() const;
76  bool ValidateGroup(RandomNumberGenerator &rng, unsigned int level) const;
77  bool ValidateElement(unsigned int level, const Element &element, const DL_FixedBasePrecomputation<Element> *precomp) const;
78  bool FastSubgroupCheckAvailable() const {return false;}
79  void EncodeElement(bool reversible, const Element &element, byte *encoded) const
80  {
81  if (reversible)
82  GetCurve().EncodePoint(encoded, element, m_compress);
83  else
84  element.x.Encode(encoded, GetEncodedElementSize(false));
85  }
86  virtual unsigned int GetEncodedElementSize(bool reversible) const
87  {
88  if (reversible)
89  return GetCurve().EncodedPointSize(m_compress);
90  else
91  return GetCurve().GetField().MaxElementByteLength();
92  }
93  Element DecodeElement(const byte *encoded, bool checkForGroupMembership) const
94  {
95  Point result;
96  if (!GetCurve().DecodePoint(result, encoded, GetEncodedElementSize(true)))
97  throw DL_BadElement();
98  if (checkForGroupMembership && !ValidateElement(1, result, NULL))
99  throw DL_BadElement();
100  return result;
101  }
102  Integer ConvertElementToInteger(const Element &element) const;
103  Integer GetMaxExponent() const {return GetSubgroupOrder()-1;}
104  bool IsIdentity(const Element &element) const {return element.identity;}
105  void SimultaneousExponentiate(Element *results, const Element &base, const Integer *exponents, unsigned int exponentsCount) const;
106  static std::string CRYPTOPP_API StaticAlgorithmNamePrefix() {return "EC";}
107 
108  // ASN1Key
109  OID GetAlgorithmID() const;
110 
111  // used by MQV
112  Element MultiplyElements(const Element &a, const Element &b) const;
113  Element CascadeExponentiate(const Element &element1, const Integer &exponent1, const Element &element2, const Integer &exponent2) const;
114 
115  // non-inherited
116 
117  // enumerate OIDs for recommended parameters, use OID() to get first one
118  static OID CRYPTOPP_API GetNextRecommendedParametersOID(const OID &oid);
119 
120  void BERDecode(BufferedTransformation &bt);
121  void DEREncode(BufferedTransformation &bt) const;
122 
123  void SetPointCompression(bool compress) {m_compress = compress;}
124  bool GetPointCompression() const {return m_compress;}
125 
126  void SetEncodeAsOID(bool encodeAsOID) {m_encodeAsOID = encodeAsOID;}
127  bool GetEncodeAsOID() const {return m_encodeAsOID;}
128 
129  const EllipticCurve& GetCurve() const {return this->m_groupPrecomputation.GetCurve();}
130 
131  bool operator==(const ThisClass &rhs) const
132  {return this->m_groupPrecomputation.GetCurve() == rhs.m_groupPrecomputation.GetCurve() && this->m_gpc.GetBase(this->m_groupPrecomputation) == rhs.m_gpc.GetBase(rhs.m_groupPrecomputation);}
133 
134 #ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
135  const Point& GetBasePoint() const {return this->GetSubgroupGenerator();}
136  const Integer& GetBasePointOrder() const {return this->GetSubgroupOrder();}
137  void LoadRecommendedParameters(const OID &oid) {Initialize(oid);}
138 #endif
139 
140 protected:
141  unsigned int FieldElementLength() const {return GetCurve().GetField().MaxElementByteLength();}
142  unsigned int ExponentLength() const {return m_n.ByteCount();}
143 
144  OID m_oid; // set if parameters loaded from a recommended curve
145  Integer m_n; // order of base point
146  mutable Integer m_k; // cofactor
147  mutable bool m_compress, m_encodeAsOID; // presentation details
148 };
149 
150 //! \class DL_PublicKey_EC
151 //! \brief Elliptic Curve Discrete Log (DL) public key
152 //! \tparam EC elliptic curve field
153 template <class EC>
154 class DL_PublicKey_EC : public DL_PublicKeyImpl<DL_GroupParameters_EC<EC> >
155 {
156 public:
157  typedef typename EC::Point Element;
158 
159 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
160  virtual ~DL_PublicKey_EC() {}
161 #endif
162 
163  void Initialize(const DL_GroupParameters_EC<EC> &params, const Element &Q)
164  {this->AccessGroupParameters() = params; this->SetPublicElement(Q);}
165  void Initialize(const EC &ec, const Element &G, const Integer &n, const Element &Q)
166  {this->AccessGroupParameters().Initialize(ec, G, n); this->SetPublicElement(Q);}
167 
168  // X509PublicKey
169  void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size);
171 };
172 
173 //! \class DL_PrivateKey_EC
174 //! \brief Elliptic Curve Discrete Log (DL) private key
175 //! \tparam EC elliptic curve field
176 template <class EC>
177 class DL_PrivateKey_EC : public DL_PrivateKeyImpl<DL_GroupParameters_EC<EC> >
178 {
179 public:
180  typedef typename EC::Point Element;
181 
182 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
183  virtual ~DL_PrivateKey_EC() {}
184 #endif
185 
186  void Initialize(const DL_GroupParameters_EC<EC> &params, const Integer &x)
187  {this->AccessGroupParameters() = params; this->SetPrivateExponent(x);}
188  void Initialize(const EC &ec, const Element &G, const Integer &n, const Integer &x)
189  {this->AccessGroupParameters().Initialize(ec, G, n); this->SetPrivateExponent(x);}
190  void Initialize(RandomNumberGenerator &rng, const DL_GroupParameters_EC<EC> &params)
191  {this->GenerateRandom(rng, params);}
192  void Initialize(RandomNumberGenerator &rng, const EC &ec, const Element &G, const Integer &n)
193  {this->GenerateRandom(rng, DL_GroupParameters_EC<EC>(ec, G, n));}
194 
195  // PKCS8PrivateKey
196  void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size);
198 };
199 
200 //! \class ECDH
201 //! \brief Elliptic Curve Diffie-Hellman
202 //! \tparam EC elliptic curve field
203 //! \tparam COFACTOR_OPTION \ref CofactorMultiplicationOption "cofactor multiplication option"
204 //! \sa <a href="http://www.weidai.com/scan-mirror/ka.html#ECDH">Elliptic Curve Diffie-Hellman, AKA ECDH</a>
205 template <class EC, class COFACTOR_OPTION = CPP_TYPENAME DL_GroupParameters_EC<EC>::DefaultCofactorOption>
206 struct ECDH
207 {
208  typedef DH_Domain<DL_GroupParameters_EC<EC>, COFACTOR_OPTION> Domain;
209 
210 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
211  virtual ~ECDH() {}
212 #endif
213 };
214 
215 //! \class ECMQV
216 //! \brief Elliptic Curve Menezes-Qu-Vanstone
217 //! \tparam EC elliptic curve field
218 //! \tparam COFACTOR_OPTION \ref CofactorMultiplicationOption "cofactor multiplication option"
219 /// \sa <a href="http://www.weidai.com/scan-mirror/ka.html#ECMQV">Elliptic Curve Menezes-Qu-Vanstone, AKA ECMQV</a>
220 template <class EC, class COFACTOR_OPTION = CPP_TYPENAME DL_GroupParameters_EC<EC>::DefaultCofactorOption>
221 struct ECMQV
222 {
223  typedef MQV_Domain<DL_GroupParameters_EC<EC>, COFACTOR_OPTION> Domain;
224 
225 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
226  virtual ~ECMQV() {}
227 #endif
228 };
229 
230 //! \class ECHMQV
231 //! \brief Hashed Elliptic Curve Menezes-Qu-Vanstone
232 //! \tparam EC elliptic curve field
233 //! \tparam COFACTOR_OPTION \ref CofactorMultiplicationOption "cofactor multiplication option"
234 //! \details This implementation follows Hugo Krawczyk's <a href="http://eprint.iacr.org/2005/176">HMQV: A High-Performance
235 //! Secure Diffie-Hellman Protocol</a>. Note: this implements HMQV only. HMQV-C with Key Confirmation is not provided.
236 template <class EC, class COFACTOR_OPTION = CPP_TYPENAME DL_GroupParameters_EC<EC>::DefaultCofactorOption, class HASH = SHA256>
237 struct ECHMQV
238 {
239  typedef HMQV_Domain<DL_GroupParameters_EC<EC>, COFACTOR_OPTION, HASH> Domain;
240 
241 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
242  virtual ~ECHMQV() {}
243 #endif
244 };
245 
247 typedef ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA256 >::Domain ECHMQV256;
248 typedef ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA384 >::Domain ECHMQV384;
249 typedef ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA512 >::Domain ECHMQV512;
250 
251 //! \class ECFHMQV
252 //! \brief Fully Hashed Elliptic Curve Menezes-Qu-Vanstone
253 //! \tparam EC elliptic curve field
254 //! \tparam COFACTOR_OPTION \ref CofactorMultiplicationOption "cofactor multiplication option"
255 //! \details This implementation follows Augustin P. Sarr and Philippe Elbaz–Vincent, and Jean–Claude Bajard's
256 //! <a href="http://eprint.iacr.org/2009/408">A Secure and Efficient Authenticated Diffie-Hellman Protocol</a>.
257 //! Note: this is FHMQV, Protocol 5, from page 11; and not FHMQV-C.
258 template <class EC, class COFACTOR_OPTION = CPP_TYPENAME DL_GroupParameters_EC<EC>::DefaultCofactorOption, class HASH = SHA256>
259 struct ECFHMQV
260 {
261  typedef FHMQV_Domain<DL_GroupParameters_EC<EC>, COFACTOR_OPTION, HASH> Domain;
262 
263 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
264  virtual ~ECFHMQV() {}
265 #endif
266 };
267 
269 typedef ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA256 >::Domain ECFHMQV256;
270 typedef ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA384 >::Domain ECFHMQV384;
271 typedef ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA512 >::Domain ECFHMQV512;
272 
273 //! \class DL_Keys_EC
274 //! \brief Elliptic Curve Discrete Log (DL) keys
275 //! \tparam EC elliptic curve field
276 template <class EC>
278 {
281 
282 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
283  virtual ~DL_Keys_EC() {}
284 #endif
285 };
286 
287 // Forward declaration; documented below
288 template <class EC, class H>
289 struct ECDSA;
290 
291 //! \class DL_Keys_ECDSA
292 //! \brief Elliptic Curve DSA keys
293 //! \tparam EC elliptic curve field
294 template <class EC>
296 {
299 
300 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
301  virtual ~DL_Keys_ECDSA() {}
302 #endif
303 };
304 
305 //! \class DL_Algorithm_ECDSA
306 //! \brief Elliptic Curve DSA (ECDSA) signature algorithm
307 //! \tparam EC elliptic curve field
308 template <class EC>
309 class DL_Algorithm_ECDSA : public DL_Algorithm_GDSA<typename EC::Point>
310 {
311 public:
312  CRYPTOPP_STATIC_CONSTEXPR char* const CRYPTOPP_API StaticAlgorithmName() {return "ECDSA";}
313 
314 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
315  virtual ~DL_Algorithm_ECDSA() {}
316 #endif
317 };
318 
319 //! \class DL_Algorithm_ECNR
320 //! \brief Elliptic Curve NR (ECNR) signature algorithm
321 //! \tparam EC elliptic curve field
322 template <class EC>
323 class DL_Algorithm_ECNR : public DL_Algorithm_NR<typename EC::Point>
324 {
325 public:
326  CRYPTOPP_STATIC_CONSTEXPR char* const CRYPTOPP_API StaticAlgorithmName() {return "ECNR";}
327 
328 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
329  virtual ~DL_Algorithm_ECNR() {}
330 #endif
331 };
332 
333 //! \class ECDSA
334 //! \brief Elliptic Curve DSA (ECDSA) signature scheme
335 //! \tparam EC elliptic curve field
336 //! \tparam H HashTransformation derived class
337 //! \sa <a href="http://www.weidai.com/scan-mirror/sig.html#ECDSA">ECDSA</a>
338 template <class EC, class H>
339 struct ECDSA : public DL_SS<DL_Keys_ECDSA<EC>, DL_Algorithm_ECDSA<EC>, DL_SignatureMessageEncodingMethod_DSA, H>
340 {
341 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
342  virtual ~ECDSA() {}
343 #endif
344 };
345 
346 //! \class ECNR
347 //! \brief Elliptic Curve NR (ECNR) signature scheme
348 //! \tparam EC elliptic curve field
349 //! \tparam H HashTransformation derived class
350 template <class EC, class H = SHA>
351 struct ECNR : public DL_SS<DL_Keys_EC<EC>, DL_Algorithm_ECNR<EC>, DL_SignatureMessageEncodingMethod_NR, H>
352 {
353 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
354  virtual ~ECNR() {}
355 #endif
356 };
357 
358 
359 //! \class ECIES
360 //! \brief Elliptic Curve Integrated Encryption Scheme
361 //! \tparam COFACTOR_OPTION \ref CofactorMultiplicationOption "cofactor multiplication option"
362 //! \tparam HASH HashTransformation derived class used for key drivation and MAC computation
363 //! \tparam DHAES_MODE flag indicating if the MAC includes additional context parameters such as <em>u·V</em>, <em>v·U</em> and label
364 //! \tparam LABEL_OCTETS flag indicating if the label size is specified in octets or bits
365 //! \details ECIES is an Elliptic Curve based Integrated Encryption Scheme (IES). The scheme combines a Key Encapsulation
366 //! Method (KEM) with a Data Encapsulation Method (DEM) and a MAC tag. The scheme is
367 //! <A HREF="http://en.wikipedia.org/wiki/ciphertext_indistinguishability">IND-CCA2</A>, which is a strong notion of security.
368 //! You should prefer an Integrated Encryption Scheme over homegrown schemes.
369 //! \details The library's original implementation is based on an early P1363 draft, which itself appears to be based on an early Certicom
370 //! SEC-1 draft (or an early SEC-1 draft was based on a P1363 draft). Crypto++ 4.2 used the early draft in its Integrated Ecryption
371 //! Schemes with <tt>NoCofactorMultiplication</tt>, <tt>DHAES_MODE=false</tt> and <tt>LABEL_OCTETS=true</tt>.
372 //! \details If you desire an Integrated Encryption Scheme with Crypto++ 4.2 compatibility, then use the ECIES template class with
373 //! <tt>NoCofactorMultiplication</tt>, <tt>DHAES_MODE=false</tt> and <tt>LABEL_OCTETS=true</tt>.
374 //! \details If you desire an Integrated Encryption Scheme with Bouncy Castle 1.54 and Botan 1.11 compatibility, then use the ECIES
375 //! template class with <tt>NoCofactorMultiplication</tt>, <tt>DHAES_MODE=true</tt> and <tt>LABEL_OCTETS=false</tt>.
376 //! \details The default template parameters ensure compatibility with Bouncy Castle 1.54 and Botan 1.11. The combination of
377 //! <tt>IncompatibleCofactorMultiplication</tt> and <tt>DHAES_MODE=true</tt> is recommended for best efficiency and security.
378 //! SHA1 is used for compatibility reasons, but it can be changed if desired. SHA-256 or another hash will likely improve the
379 //! security provided by the MAC. The hash is also used in the key derivation function as a PRF.
380 //! \details Below is an example of constructing a Crypto++ 4.2 compatible ECIES encryptor and decryptor.
381 //! <pre>
382 //! AutoSeededRandomPool prng;
383 //! DL_PrivateKey_EC<ECP> key;
384 //! key.Initialize(prng, ASN1::secp160r1());
385 //!
386 //! ECIES<ECP,SHA1,NoCofactorMultiplication,true,true>::Decryptor decryptor(key);
387 //! ECIES<ECP,SHA1,NoCofactorMultiplication,true,true>::Encryptor encryptor(decryptor);
388 //! </pre>
389 //! \sa DLIES, <a href="http://www.weidai.com/scan-mirror/ca.html#ECIES">Elliptic Curve Integrated Encryption Scheme (ECIES)</a>,
390 //! Martínez, Encinas, and Ávila's <A HREF="http://digital.csic.es/bitstream/10261/32671/1/V2-I2-P7-13.pdf">A Survey of the Elliptic
391 //! Curve Integrated Encryption Schemes</A>
392 //! \since Crypto++ 4.0, Crypto++ 5.6.6 for Bouncy Castle and Botan compatibility
393 template <class EC, class HASH = SHA1, class COFACTOR_OPTION = NoCofactorMultiplication, bool DHAES_MODE = true, bool LABEL_OCTETS = false>
394 struct ECIES
395  : public DL_ES<
396  DL_Keys_EC<EC>,
397  DL_KeyAgreementAlgorithm_DH<typename EC::Point, COFACTOR_OPTION>,
398  DL_KeyDerivationAlgorithm_P1363<typename EC::Point, DHAES_MODE, P1363_KDF2<HASH> >,
399  DL_EncryptionAlgorithm_Xor<HMAC<HASH>, DHAES_MODE, LABEL_OCTETS>,
400  ECIES<EC> >
401 {
402  static std::string CRYPTOPP_API StaticAlgorithmName() {return "ECIES";} // TODO: fix this after name is standardized
403 
404 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
405  virtual ~ECIES() {}
406 #endif
407 };
408 
409 NAMESPACE_END
410 
411 #ifdef CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES
412 #include "eccrypto.cpp"
413 #endif
414 
415 NAMESPACE_BEGIN(CryptoPP)
416 
417 CRYPTOPP_DLL_TEMPLATE_CLASS DL_GroupParameters_EC<ECP>;
418 CRYPTOPP_DLL_TEMPLATE_CLASS DL_GroupParameters_EC<EC2N>;
419 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PublicKeyImpl<DL_GroupParameters_EC<ECP> >;
420 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PublicKeyImpl<DL_GroupParameters_EC<EC2N> >;
421 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PublicKey_EC<ECP>;
422 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PublicKey_EC<EC2N>;
423 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKeyImpl<DL_GroupParameters_EC<ECP> >;
424 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKeyImpl<DL_GroupParameters_EC<EC2N> >;
425 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_EC<ECP>;
426 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_EC<EC2N>;
427 CRYPTOPP_DLL_TEMPLATE_CLASS DL_Algorithm_GDSA<ECP::Point>;
428 CRYPTOPP_DLL_TEMPLATE_CLASS DL_Algorithm_GDSA<EC2N::Point>;
429 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_WithSignaturePairwiseConsistencyTest<DL_PrivateKey_EC<ECP>, ECDSA<ECP, SHA256> >;
430 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_WithSignaturePairwiseConsistencyTest<DL_PrivateKey_EC<EC2N>, ECDSA<EC2N, SHA256> >;
431 
432 NAMESPACE_END
433 
434 #endif
SHA-384 message digest.
Definition: sha.h:81
Classes for Fully Hashed Menezes-Qu-Vanstone key agreement in GF(p)
SHA-256 message digest.
Definition: sha.h:39
This file contains helper classes/functions for implementing public key algorithms.
Elliptic Curve DSA keys.
Definition: eccrypto.h:295
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:259
Elliptic Curve DSA (ECDSA) signature scheme.
Definition: eccrypto.h:289
Converts a typename to an enumerated value.
Definition: cryptlib.h:116
Abstract base classes that provide a uniform interface to this library.
Hashed Menezes-Qu-Vanstone in GF(p)
Definition: hmqv.h:23
Elliptic Curve Discrete Log (DL) keys.
Definition: eccrypto.h:277
Elliptic Curve Discrete Log (DL) public key.
Definition: eccrypto.h:154
DL_FixedBasePrecomputation< Element > & AccessBasePrecomputation()
Retrieves the group precomputation.
Definition: eccrypto.h:73
Library configuration file.
Interface for random number generators.
Definition: cryptlib.h:1197
Elliptic Curve Discrete Log (DL) private key.
Definition: eccrypto.h:177
Discrete Log (DL) encryption scheme.
Definition: pubkey.h:2238
Interface for buffered transformations.
Definition: cryptlib.h:1363
bool operator==(const OID &lhs, const OID &rhs)
Compare two OIDs for equality.
void DEREncodePrivateKey(BufferedTransformation &bt) const
encode privateKey part of privateKeyInfo, without the OCTET STRING header
Definition: eccrypto.cpp:707
Classes for Hashed Menezes-Qu-Vanstone key agreement in GF(p)
Discrete Log (DL) signature scheme.
Definition: pubkey.h:2215
Classes for Elliptic Curves over binary fields.
Classes for HMAC message authentication codes.
MQV domain for performing authenticated key agreement.
Definition: mqv.h:27
Hashed Elliptic Curve Menezes-Qu-Vanstone.
Definition: eccrypto.h:237
Classes for Diffie-Hellman key exchange.
SHA-512 message digest.
Definition: sha.h:69
Integer GetMaxExponent() const
Retrieves the maximum exponent for the group.
Definition: eccrypto.h:103
Elliptic Curve Menezes-Qu-Vanstone.
Definition: eccrypto.h:221
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:394
SHA-1 message digest.
Definition: sha.h:25
Elliptic Curve NR (ECNR) signature algorithm.
Definition: eccrypto.h:323
void DEREncodePublicKey(BufferedTransformation &bt) const
encode subjectPublicKey part of subjectPublicKeyInfo, without the BIT STRING header ...
Definition: eccrypto.cpp:660
Elliptic Curve DSA (ECDSA) signature algorithm.
Definition: eccrypto.h:309
Exception thrown when an invalid group element is encountered.
Definition: pubkey.h:749
Diffie-Hellman domain.
Definition: dh.h:25
Elliptic Curve Diffie-Hellman.
Definition: eccrypto.h:206
Classes and functions for working with ANS.1 objects.
Classes for SHA-1 and SHA-2 family of message digests.
Elliptic Curve Parameters.
Definition: eccrypto.h:31
const DL_FixedBasePrecomputation< Element > & GetBasePrecomputation() const
Retrieves the group precomputation.
Definition: eccrypto.h:72
GDSA algorithm.
Definition: gfpcrypt.h:196
Elliptic Curve precomputation.
Definition: ec2n.h:100
virtual unsigned int GetEncodedElementSize(bool reversible) const
Retrieves the encoded element's size.
Definition: eccrypto.h:86
Element DecodeElement(const byte *encoded, bool checkForGroupMembership) const
Decodes the element.
Definition: eccrypto.h:93
NR algorithm.
Definition: gfpcrypt.h:234
Multiple precision integer with arithmetic operations.
static const Integer & Zero()
Integer representing 0.
Definition: integer.cpp:3032
Crypto++ library namespace.
Base implmentation of Discrete Log (DL) group parameters.
Definition: pubkey.h:972
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs &params)
Definition: pubkey.h:1176
Classes for Menezes–Qu–Vanstone (MQV) key agreement.
Object Identifier.
Definition: asn.h:158
const Integer & GetSubgroupOrder() const
Retrieves the subgroup order.
Definition: eccrypto.h:74
void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size)
decode subjectPublicKey part of subjectPublicKeyInfo, without the BIT STRING header ...
Definition: eccrypto.cpp:649
void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size)
decode privateKey part of privateKeyInfo, without the OCTET STRING header
Definition: eccrypto.cpp:668
Elliptic Curve NR (ECNR) signature scheme.
Definition: eccrypto.h:351
Interface for retrieving values given their names.
Definition: cryptlib.h:278