summaryrefslogtreecommitdiff
path: root/eccrypto.h
diff options
context:
space:
mode:
authorUri Blumenthal <uri@ll.mit.edu>2016-07-01 14:19:41 -0400
committerUri Blumenthal <uri@ll.mit.edu>2016-07-01 14:30:43 -0400
commitec350995893b8388631c023d8884f22c94c212ad (patch)
treeae3356d69a8903e3b5745c3a69a9ffcc962f97e1 /eccrypto.h
parent20c3e1a5ef708f7a0b8f28b67053f5b8587b2bfb (diff)
downloadcryptopp-git-ec350995893b8388631c023d8884f22c94c212ad.tar.gz
Add HMQV implementation (and merge the old FHMQV into the new codebase)
Diffstat (limited to 'eccrypto.h')
-rw-r--r--eccrypto.h44
1 files changed, 42 insertions, 2 deletions
diff --git a/eccrypto.h b/eccrypto.h
index a3d15e95..6642dec5 100644
--- a/eccrypto.h
+++ b/eccrypto.h
@@ -16,6 +16,8 @@
#include "gfpcrypt.h"
#include "dh.h"
#include "mqv.h"
+#include "hmqv.h"
+#include "fhmqv.h"
#include "ecp.h"
#include "ec2n.h"
@@ -213,6 +215,44 @@ struct ECMQV
#endif
};
+//! Hashed Menezes-Qu-Vanstone in GF(p) with key validation,
+/*! <a href="http://eprint.iacr.org/2005/176">HMQV: A High-Performance Secure Diffie-Hellman Protocol</a>
+ Note: this implements HMQV only. HMQV-C (with Key Confirmation) will be provided separately.
+*/
+template <class EC, class COFACTOR_OPTION = CPP_TYPENAME DL_GroupParameters_EC<EC>::DefaultCofactorOption, class HASH = SHA256>
+struct HMQV
+{
+ typedef HMQV_Domain<DL_GroupParameters_EC<EC>, COFACTOR_OPTION, HASH> Domain;
+
+#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
+ virtual ~HMQV() {}
+#endif
+};
+
+typedef HMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA1 >::Domain HMQV160;
+typedef HMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA256 >::Domain HMQV256;
+typedef HMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA384 >::Domain HMQV384;
+typedef HMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA512 >::Domain HMQV512;
+
+//! Fully Hashed Menezes-Qu-Vanstone in GF(p) with key validation,
+/*! <a href="http://eprint.iacr.org/2009/408">A Secure and Efficient Authenticated Diffie–Hellman Protocol</a>
+ Note: this is FHMQV, Protocol 5, from page 11; and not FHMQV-C.
+*/
+template <class EC, class COFACTOR_OPTION = CPP_TYPENAME DL_GroupParameters_EC<EC>::DefaultCofactorOption, class HASH = SHA256>
+struct FHMQV
+{
+ typedef FHMQV_Domain<DL_GroupParameters_EC<EC>, COFACTOR_OPTION, HASH> Domain;
+
+#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
+ virtual ~FHMQV() {}
+#endif
+};
+
+typedef FHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA1 >::Domain FHMQV160;
+typedef FHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA256 >::Domain FHMQV256;
+typedef FHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA384 >::Domain FHMQV384;
+typedef FHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA512 >::Domain FHMQV512;
+
//! EC keys
template <class EC>
struct DL_Keys_EC
@@ -283,10 +323,10 @@ struct ECNR : public DL_SS<DL_Keys_EC<EC>, DL_Algorithm_ECNR<EC>, DL_SignatureMe
};
//! Elliptic Curve Integrated Encryption Scheme, AKA <a href="http://www.weidai.com/scan-mirror/ca.html#ECIES">ECIES</a>
-/*! Default to (NoCofactorMultiplication and DHAES_MODE = false) for compatibilty with SEC1 and Crypto++ 4.2.
+/*! Choose NoCofactorMultiplication and DHAES_MODE = false for compatibilty with SEC1 and Crypto++ 4.2.
The combination of (IncompatibleCofactorMultiplication and DHAES_MODE = true) is recommended for best
efficiency and security. */
-template <class EC, class COFACTOR_OPTION = NoCofactorMultiplication, bool DHAES_MODE = false>
+template <class EC, class COFACTOR_OPTION = NoCofactorMultiplication, bool DHAES_MODE = true>
struct ECIES
: public DL_ES<
DL_Keys_EC<EC>,