From ec350995893b8388631c023d8884f22c94c212ad Mon Sep 17 00:00:00 2001 From: Uri Blumenthal Date: Fri, 1 Jul 2016 14:19:41 -0400 Subject: Add HMQV implementation (and merge the old FHMQV into the new codebase) --- eccrypto.h | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'eccrypto.h') 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, +/*! HMQV: A High-Performance Secure Diffie-Hellman Protocol + Note: this implements HMQV only. HMQV-C (with Key Confirmation) will be provided separately. +*/ +template ::DefaultCofactorOption, class HASH = SHA256> +struct HMQV +{ + typedef HMQV_Domain, 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 Secure and Efficient Authenticated Diffie–Hellman Protocol + Note: this is FHMQV, Protocol 5, from page 11; and not FHMQV-C. +*/ +template ::DefaultCofactorOption, class HASH = SHA256> +struct FHMQV +{ + typedef FHMQV_Domain, 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 struct DL_Keys_EC @@ -283,10 +323,10 @@ struct ECNR : public DL_SS, DL_Algorithm_ECNR, DL_SignatureMe }; //! Elliptic Curve Integrated Encryption Scheme, AKA ECIES -/*! 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 +template struct ECIES : public DL_ES< DL_Keys_EC, -- cgit v1.2.1 From fb72dbc8cb750be749a4ec3e2f27d164fe89d431 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 5 Jul 2016 02:48:27 -0400 Subject: Add MacPorts GCC compiler and Clang integrated assembler support. This is a merge of the development branch 'clang-ia' --- eccrypto.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'eccrypto.h') diff --git a/eccrypto.h b/eccrypto.h index a3d15e95..cba037fb 100644 --- a/eccrypto.h +++ b/eccrypto.h @@ -130,7 +130,7 @@ public: const Integer& GetBasePointOrder() const {return this->GetSubgroupOrder();} void LoadRecommendedParameters(const OID &oid) {Initialize(oid);} #endif - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_GroupParameters_EC() {} #endif @@ -160,7 +160,7 @@ public: // X509PublicKey void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size); void DEREncodePublicKey(BufferedTransformation &bt) const; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_PublicKey_EC() {} #endif @@ -185,7 +185,7 @@ public: // PKCS8PrivateKey void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size); void DEREncodePrivateKey(BufferedTransformation &bt) const; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_PrivateKey_EC() {} #endif @@ -196,7 +196,7 @@ template , COFACTOR_OPTION> Domain; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~ECDH() {} #endif @@ -207,7 +207,7 @@ template , COFACTOR_OPTION> Domain; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~ECMQV() {} #endif @@ -219,7 +219,7 @@ struct DL_Keys_EC { typedef DL_PublicKey_EC PublicKey; typedef DL_PrivateKey_EC PrivateKey; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_Keys_EC() {} #endif @@ -234,7 +234,7 @@ struct DL_Keys_ECDSA { typedef DL_PublicKey_EC PublicKey; typedef DL_PrivateKey_WithSignaturePairwiseConsistencyTest, ECDSA > PrivateKey; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_Keys_ECDSA() {} #endif @@ -246,7 +246,7 @@ class DL_Algorithm_ECDSA : public DL_Algorithm_GDSA { public: static const char * CRYPTOPP_API StaticAlgorithmName() {return "ECDSA";} - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_Algorithm_ECDSA() {} #endif @@ -258,7 +258,7 @@ class DL_Algorithm_ECNR : public DL_Algorithm_NR { public: static const char * CRYPTOPP_API StaticAlgorithmName() {return "ECNR";} - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_Algorithm_ECNR() {} #endif @@ -296,12 +296,12 @@ struct ECIES ECIES > { static std::string CRYPTOPP_API StaticAlgorithmName() {return "ECIES";} // TODO: fix this after name is standardized - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~ECIES() {} #endif - -#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_CLANG_VERSION >= 20800) + +#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800) } __attribute__((deprecated ("ECIES will be changing in the near future due to (1) an implementation bug and (2) an interop issue"))); #elif (CRYPTOPP_GCC_VERSION) } __attribute__((deprecated)); -- cgit v1.2.1 From 87be783cd1b6f13d8501497dbffa0c8c7502997e Mon Sep 17 00:00:00 2001 From: Mouse Date: Wed, 6 Jul 2016 12:01:28 -0400 Subject: Revert "Merge remote-tracking branch 'upstream/master'" - not intended to be merged by me This reverts commit 762c315566bce681e380641d1894251f984eac10, reversing changes made to b48866631a5587e9348245fedd6f1e0871df35db. --- eccrypto.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'eccrypto.h') diff --git a/eccrypto.h b/eccrypto.h index a809f661..6642dec5 100644 --- a/eccrypto.h +++ b/eccrypto.h @@ -132,7 +132,7 @@ public: const Integer& GetBasePointOrder() const {return this->GetSubgroupOrder();} void LoadRecommendedParameters(const OID &oid) {Initialize(oid);} #endif - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_GroupParameters_EC() {} #endif @@ -162,7 +162,7 @@ public: // X509PublicKey void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size); void DEREncodePublicKey(BufferedTransformation &bt) const; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_PublicKey_EC() {} #endif @@ -187,7 +187,7 @@ public: // PKCS8PrivateKey void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size); void DEREncodePrivateKey(BufferedTransformation &bt) const; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_PrivateKey_EC() {} #endif @@ -198,7 +198,7 @@ template , COFACTOR_OPTION> Domain; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~ECDH() {} #endif @@ -209,7 +209,7 @@ template , COFACTOR_OPTION> Domain; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~ECMQV() {} #endif @@ -259,7 +259,7 @@ struct DL_Keys_EC { typedef DL_PublicKey_EC PublicKey; typedef DL_PrivateKey_EC PrivateKey; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_Keys_EC() {} #endif @@ -274,7 +274,7 @@ struct DL_Keys_ECDSA { typedef DL_PublicKey_EC PublicKey; typedef DL_PrivateKey_WithSignaturePairwiseConsistencyTest, ECDSA > PrivateKey; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_Keys_ECDSA() {} #endif @@ -286,7 +286,7 @@ class DL_Algorithm_ECDSA : public DL_Algorithm_GDSA { public: static const char * CRYPTOPP_API StaticAlgorithmName() {return "ECDSA";} - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_Algorithm_ECDSA() {} #endif @@ -298,7 +298,7 @@ class DL_Algorithm_ECNR : public DL_Algorithm_NR { public: static const char * CRYPTOPP_API StaticAlgorithmName() {return "ECNR";} - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_Algorithm_ECNR() {} #endif @@ -336,12 +336,12 @@ struct ECIES ECIES > { static std::string CRYPTOPP_API StaticAlgorithmName() {return "ECIES";} // TODO: fix this after name is standardized - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~ECIES() {} #endif - -#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800) + +#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_CLANG_VERSION >= 20800) } __attribute__((deprecated ("ECIES will be changing in the near future due to (1) an implementation bug and (2) an interop issue"))); #elif (CRYPTOPP_GCC_VERSION) } __attribute__((deprecated)); -- cgit v1.2.1 From c6c0bdeebe7ae5399045ef2360d8ae54d76d209b Mon Sep 17 00:00:00 2001 From: Mouse Date: Wed, 6 Jul 2016 12:15:47 -0400 Subject: Revert "Add HMQV implementation (and merge the old FHMQV into the new codebase)" This reverts commit ec350995893b8388631c023d8884f22c94c212ad. --- eccrypto.h | 44 ++------------------------------------------ 1 file changed, 2 insertions(+), 42 deletions(-) (limited to 'eccrypto.h') diff --git a/eccrypto.h b/eccrypto.h index 6642dec5..a3d15e95 100644 --- a/eccrypto.h +++ b/eccrypto.h @@ -16,8 +16,6 @@ #include "gfpcrypt.h" #include "dh.h" #include "mqv.h" -#include "hmqv.h" -#include "fhmqv.h" #include "ecp.h" #include "ec2n.h" @@ -215,44 +213,6 @@ struct ECMQV #endif }; -//! Hashed Menezes-Qu-Vanstone in GF(p) with key validation, -/*! HMQV: A High-Performance Secure Diffie-Hellman Protocol - Note: this implements HMQV only. HMQV-C (with Key Confirmation) will be provided separately. -*/ -template ::DefaultCofactorOption, class HASH = SHA256> -struct HMQV -{ - typedef HMQV_Domain, 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 Secure and Efficient Authenticated Diffie–Hellman Protocol - Note: this is FHMQV, Protocol 5, from page 11; and not FHMQV-C. -*/ -template ::DefaultCofactorOption, class HASH = SHA256> -struct FHMQV -{ - typedef FHMQV_Domain, 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 struct DL_Keys_EC @@ -323,10 +283,10 @@ struct ECNR : public DL_SS, DL_Algorithm_ECNR, DL_SignatureMe }; //! Elliptic Curve Integrated Encryption Scheme, AKA ECIES -/*! Choose NoCofactorMultiplication and DHAES_MODE = false for compatibilty with SEC1 and Crypto++ 4.2. +/*! Default to (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 +template struct ECIES : public DL_ES< DL_Keys_EC, -- cgit v1.2.1 From 6c0b120072563ca77c6a3aec4c6c6f143cb984f9 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Wed, 6 Jul 2016 14:39:18 -0400 Subject: Go back to Commit 66ada4cc61d62afc --- eccrypto.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'eccrypto.h') diff --git a/eccrypto.h b/eccrypto.h index a3d15e95..cba037fb 100644 --- a/eccrypto.h +++ b/eccrypto.h @@ -130,7 +130,7 @@ public: const Integer& GetBasePointOrder() const {return this->GetSubgroupOrder();} void LoadRecommendedParameters(const OID &oid) {Initialize(oid);} #endif - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_GroupParameters_EC() {} #endif @@ -160,7 +160,7 @@ public: // X509PublicKey void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size); void DEREncodePublicKey(BufferedTransformation &bt) const; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_PublicKey_EC() {} #endif @@ -185,7 +185,7 @@ public: // PKCS8PrivateKey void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size); void DEREncodePrivateKey(BufferedTransformation &bt) const; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_PrivateKey_EC() {} #endif @@ -196,7 +196,7 @@ template , COFACTOR_OPTION> Domain; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~ECDH() {} #endif @@ -207,7 +207,7 @@ template , COFACTOR_OPTION> Domain; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~ECMQV() {} #endif @@ -219,7 +219,7 @@ struct DL_Keys_EC { typedef DL_PublicKey_EC PublicKey; typedef DL_PrivateKey_EC PrivateKey; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_Keys_EC() {} #endif @@ -234,7 +234,7 @@ struct DL_Keys_ECDSA { typedef DL_PublicKey_EC PublicKey; typedef DL_PrivateKey_WithSignaturePairwiseConsistencyTest, ECDSA > PrivateKey; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_Keys_ECDSA() {} #endif @@ -246,7 +246,7 @@ class DL_Algorithm_ECDSA : public DL_Algorithm_GDSA { public: static const char * CRYPTOPP_API StaticAlgorithmName() {return "ECDSA";} - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_Algorithm_ECDSA() {} #endif @@ -258,7 +258,7 @@ class DL_Algorithm_ECNR : public DL_Algorithm_NR { public: static const char * CRYPTOPP_API StaticAlgorithmName() {return "ECNR";} - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_Algorithm_ECNR() {} #endif @@ -296,12 +296,12 @@ struct ECIES ECIES > { static std::string CRYPTOPP_API StaticAlgorithmName() {return "ECIES";} // TODO: fix this after name is standardized - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~ECIES() {} #endif - -#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_CLANG_VERSION >= 20800) + +#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800) } __attribute__((deprecated ("ECIES will be changing in the near future due to (1) an implementation bug and (2) an interop issue"))); #elif (CRYPTOPP_GCC_VERSION) } __attribute__((deprecated)); -- cgit v1.2.1