@@ -147,7 +147,9 @@ class DL_GroupParameters_EC : public DL_GroupParametersImpl<EcPrecomputation<EC>
147
147
mutable bool m_compress, m_encodeAsOID; // presentation details
148
148
};
149
149
150
- // ! EC public key
150
+ // ! \class DL_PublicKey_EC
151
+ // ! \brief Elliptic Curve Discrete Log (DL) public key
152
+ // ! \tparam EC elliptic curve field
151
153
template <class EC >
152
154
class DL_PublicKey_EC : public DL_PublicKeyImpl <DL_GroupParameters_EC<EC> >
153
155
{
@@ -168,7 +170,9 @@ class DL_PublicKey_EC : public DL_PublicKeyImpl<DL_GroupParameters_EC<EC> >
168
170
void DEREncodePublicKey (BufferedTransformation &bt) const ;
169
171
};
170
172
171
- // ! EC private key
173
+ // ! \class DL_PrivateKey_EC
174
+ // ! \brief Elliptic Curve Discrete Log (DL) private key
175
+ // ! \tparam EC elliptic curve field
172
176
template <class EC >
173
177
class DL_PrivateKey_EC : public DL_PrivateKeyImpl <DL_GroupParameters_EC<EC> >
174
178
{
@@ -193,7 +197,11 @@ class DL_PrivateKey_EC : public DL_PrivateKeyImpl<DL_GroupParameters_EC<EC> >
193
197
void DEREncodePrivateKey (BufferedTransformation &bt) const ;
194
198
};
195
199
196
- // ! Elliptic Curve Diffie-Hellman, AKA <a href="http://www.weidai.com/scan-mirror/ka.html#ECDH">ECDH</a>
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>
197
205
template <class EC , class COFACTOR_OPTION = CPP_TYPENAME DL_GroupParameters_EC<EC>::DefaultCofactorOption>
198
206
struct ECDH
199
207
{
@@ -204,7 +212,11 @@ struct ECDH
204
212
#endif
205
213
};
206
214
207
- // / Elliptic Curve Menezes-Qu-Vanstone, AKA <a href="http://www.weidai.com/scan-mirror/ka.html#ECMQV">ECMQV</a>
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>
208
220
template <class EC , class COFACTOR_OPTION = CPP_TYPENAME DL_GroupParameters_EC<EC>::DefaultCofactorOption>
209
221
struct ECMQV
210
222
{
@@ -215,7 +227,10 @@ struct ECMQV
215
227
#endif
216
228
};
217
229
218
- // ! \brief Hashed Menezes-Qu-Vanstone in ECP or EC2N
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"
219
234
// ! \details This implementation follows Hugo Krawczyk's <a href="http://eprint.iacr.org/2005/176">HMQV: A High-Performance
220
235
// ! Secure Diffie-Hellman Protocol</a>. Note: this implements HMQV only. HMQV-C with Key Confirmation is not provided.
221
236
template <class EC , class COFACTOR_OPTION = CPP_TYPENAME DL_GroupParameters_EC<EC>::DefaultCofactorOption, class HASH = SHA256>
@@ -233,7 +248,10 @@ typedef ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA256
233
248
typedef ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA384 >::Domain ECHMQV384;
234
249
typedef ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA512 >::Domain ECHMQV512;
235
250
236
- // ! \brief Fully Hashed Menezes-Qu-Vanstone in ECP or EC2N
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"
237
255
// ! \details This implementation follows Augustin P. Sarr and Philippe Elbaz–Vincent, and Jean–Claude Bajard's
238
256
// ! <a href="http://eprint.iacr.org/2009/408">A Secure and Efficient Authenticated Diffie-Hellman Protocol</a>.
239
257
// ! Note: this is FHMQV, Protocol 5, from page 11; and not FHMQV-C.
@@ -252,7 +270,9 @@ typedef ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA25
252
270
typedef ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA384 >::Domain ECFHMQV384;
253
271
typedef ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA512 >::Domain ECFHMQV512;
254
272
255
- // ! EC keys
273
+ // ! \class DL_Keys_EC
274
+ // ! \brief Elliptic Curve Discrete Log (DL) keys
275
+ // ! \tparam EC elliptic curve field
256
276
template <class EC >
257
277
struct DL_Keys_EC
258
278
{
@@ -264,10 +284,16 @@ struct DL_Keys_EC
264
284
#endif
265
285
};
266
286
287
+ // ! \class ECDSA
288
+ // ! \brief Elliptic Curve DSA
289
+ // ! \tparam EC elliptic curve field
290
+ // ! \tparam H HashTransformation derived class
267
291
template <class EC , class H >
268
292
struct ECDSA ;
269
293
270
- // ! ECDSA keys
294
+ // ! \class DL_Keys_ECDSA
295
+ // ! \brief Elliptic Curve DSA keys
296
+ // ! \tparam EC elliptic curve field
271
297
template <class EC >
272
298
struct DL_Keys_ECDSA
273
299
{
@@ -279,7 +305,9 @@ struct DL_Keys_ECDSA
279
305
#endif
280
306
};
281
307
282
- // ! ECDSA algorithm
308
+ // ! \class DL_Algorithm_ECDSA
309
+ // ! \brief Elliptic Curve DSA (ECDSA) signature algorithm
310
+ // ! \tparam EC elliptic curve field
283
311
template <class EC >
284
312
class DL_Algorithm_ECDSA : public DL_Algorithm_GDSA <typename EC::Point>
285
313
{
@@ -291,7 +319,9 @@ class DL_Algorithm_ECDSA : public DL_Algorithm_GDSA<typename EC::Point>
291
319
#endif
292
320
};
293
321
294
- // ! ECNR algorithm
322
+ // ! \class DL_Algorithm_ECNR
323
+ // ! \brief Elliptic Curve NR (ECNR) signature algorithm
324
+ // ! \tparam EC elliptic curve field
295
325
template <class EC >
296
326
class DL_Algorithm_ECNR : public DL_Algorithm_NR <typename EC::Point>
297
327
{
@@ -303,7 +333,11 @@ class DL_Algorithm_ECNR : public DL_Algorithm_NR<typename EC::Point>
303
333
#endif
304
334
};
305
335
306
- // ! <a href="http://www.weidai.com/scan-mirror/sig.html#ECDSA">ECDSA</a>
336
+ // ! \class ECDSA
337
+ // ! \brief Elliptic Curve DSA (ECDSA) signature scheme
338
+ // ! \tparam EC elliptic curve field
339
+ // ! \tparam H HashTransformation derived class
340
+ // ! \sa <a href="http://www.weidai.com/scan-mirror/sig.html#ECDSA">ECDSA</a>
307
341
template <class EC , class H >
308
342
struct ECDSA : public DL_SS <DL_Keys_ECDSA<EC>, DL_Algorithm_ECDSA<EC>, DL_SignatureMessageEncodingMethod_DSA, H>
309
343
{
@@ -312,7 +346,10 @@ struct ECDSA : public DL_SS<DL_Keys_ECDSA<EC>, DL_Algorithm_ECDSA<EC>, DL_Signat
312
346
#endif
313
347
};
314
348
315
- // ! ECNR
349
+ // ! \class ECNR
350
+ // ! \brief Elliptic Curve NR (ECNR) signature scheme
351
+ // ! \tparam EC elliptic curve field
352
+ // ! \tparam H HashTransformation derived class
316
353
template <class EC , class H = SHA>
317
354
struct ECNR : public DL_SS <DL_Keys_EC<EC>, DL_Algorithm_ECNR<EC>, DL_SignatureMessageEncodingMethod_NR, H>
318
355
{
@@ -321,26 +358,56 @@ struct ECNR : public DL_SS<DL_Keys_EC<EC>, DL_Algorithm_ECNR<EC>, DL_SignatureMe
321
358
#endif
322
359
};
323
360
324
- // ! Elliptic Curve Integrated Encryption Scheme, AKA <a href="http://www.weidai.com/scan-mirror/ca.html#ECIES">ECIES</a>
325
- /* ! Default to (NoCofactorMultiplication and DHAES_MODE = false) for compatibilty with SEC1 and Crypto++ 4.2.
326
- The combination of (IncompatibleCofactorMultiplication and DHAES_MODE = true) is recommended for best
327
- efficiency and security. */
328
- template <class EC , class COFACTOR_OPTION = NoCofactorMultiplication, bool DHAES_MODE = false >
361
+
362
+ // ! \class ECIES
363
+ // ! \brief Elliptic Curve Integrated Encryption Scheme
364
+ // ! \tparam COFACTOR_OPTION \ref CofactorMultiplicationOption "cofactor multiplication option"
365
+ // ! \tparam HASH HashTransformation derived class used for key drivation and MAC computation
366
+ // ! \tparam DHAES_MODE flag indicating if the MAC includes additional context parameters such as <em>u·V</em>, <em>v·U</em> and label
367
+ // ! \tparam LABEL_OCTETS flag indicating if the label size is specified in octets or bits
368
+ // ! \details ECIES is an Elliptic Curve based Integrated Encryption Scheme (IES). The scheme combines a Key Encapsulation
369
+ // ! Method (KEM) with a Data Encapsulation Method (DEM) and a MAC tag. The scheme is
370
+ // ! <A HREF="http://en.wikipedia.org/wiki/ciphertext_indistinguishability">IND-CCA2</A>, which is a strong notion of security.
371
+ // ! You should prefer an Integrated Encryption Scheme over homegrown schemes.
372
+ // ! \details The library's original implementation is based on an early P1363 draft, which itself appears to be based on an early Certicom
373
+ // ! 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
374
+ // ! Schemes with <tt>NoCofactorMultiplication</tt>, <tt>DHAES_MODE=false</tt> and <tt>LABEL_OCTETS=true</tt>.
375
+ // ! \details If you desire an Integrated Encryption Scheme with Crypto++ 4.2 compatibility, then use the ECIES template class with
376
+ // ! <tt>NoCofactorMultiplication</tt>, <tt>DHAES_MODE=false</tt> and <tt>LABEL_OCTETS=true</tt>.
377
+ // ! \details If you desire an Integrated Encryption Scheme with Bouncy Castle 1.55 and Botan 1.11 compatibility, then use the ECIES
378
+ // ! template class with <tt>NoCofactorMultiplication</tt>, <tt>DHAES_MODE=true</tt> and <tt>LABEL_OCTETS=false</tt>.
379
+ // ! \details Bouncy Castle 1.55 and Botan 1.11 compatibility are the default template parameters. The combination of
380
+ // ! <tt>IncompatibleCofactorMultiplication</tt> and <tt>DHAES_MODE=true</tt> is recommended for best efficiency and security.
381
+ // ! SHA1 is used for compatibility reasons, but it can be changed of if desired. SHA-256 or another hash will likely improve the
382
+ // ! security provided by the MAC. The hash is also used in the key derivation function as a PRF.
383
+ // ! \details Below is an example of constructing a Crypto++ 4.2 compatible ECIES encryptor and decryptor.
384
+ // ! <pre>
385
+ // ! AutoSeededRandomPool prng;
386
+ // ! DL_PrivateKey_EC<ECP> key;
387
+ // ! key.Initialize(prng, ASN1::secp160r1());
388
+ // !
389
+ // ! ECIES<ECP,SHA1,NoCofactorMultiplication,true,true>::Decryptor decryptor(key);
390
+ // ! ECIES<ECP,SHA1,NoCofactorMultiplication,true,true>::Encryptor encryptor(decryptor);
391
+ // ! </pre>
392
+ // ! \sa DLIES, <a href="http://www.weidai.com/scan-mirror/ca.html#ECIES">Elliptic Curve Integrated Encryption Scheme (ECIES)</a>,
393
+ // ! 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
394
+ // ! Curve Integrated Encryption Schemes</A>
395
+ // ! \since Crypto++ 4.0
396
+ template <class EC , class HASH = SHA1, class COFACTOR_OPTION = NoCofactorMultiplication, bool DHAES_MODE = true , bool LABEL_OCTETS = false >
329
397
struct ECIES
330
398
: public DL_ES<
331
399
DL_Keys_EC<EC>,
332
400
DL_KeyAgreementAlgorithm_DH<typename EC::Point, COFACTOR_OPTION>,
333
- DL_KeyDerivationAlgorithm_P1363<typename EC::Point, DHAES_MODE, P1363_KDF2<SHA1 > >,
334
- DL_EncryptionAlgorithm_Xor<HMAC<SHA1 >, DHAES_MODE>,
401
+ DL_KeyDerivationAlgorithm_P1363<typename EC::Point, DHAES_MODE, P1363_KDF2<HASH > >,
402
+ DL_EncryptionAlgorithm_Xor<HMAC<HASH >, DHAES_MODE, LABEL_OCTETS >,
335
403
ECIES<EC> >
336
404
{
337
405
static std::string CRYPTOPP_API StaticAlgorithmName () {return " ECIES" ;} // TODO: fix this after name is standardized
338
406
339
407
#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
340
408
virtual ~ECIES () {}
341
409
#endif
342
-
343
- } CRYPTOPP_DEPRECATED (" ECIES will be changing in the near future due to an interop issue" );
410
+ };
344
411
345
412
NAMESPACE_END
346
413
0 commit comments