Add EC prefix to classes which operate over elliptic curves

This commit is contained in:
Jeffrey Walton 2016-07-21 00:21:48 -04:00
parent 9529d19760
commit 060ba1a696
4 changed files with 254 additions and 254 deletions

View File

@ -325,15 +325,15 @@ void BenchmarkAll2(double t, double hertz)
BenchMarkKeyAgreement<MQV>(CRYPTOPP_DATA_DIR "TestData/mqv2048.dat", "MQV 2048", t);
#if 0
BenchMarkKeyAgreement<HMQV160>(CRYPTOPP_DATA_DIR "TestData/hmqv160.dat", "HMQV P-160", t);
BenchMarkKeyAgreement<HMQV256>(CRYPTOPP_DATA_DIR "TestData/hmqv256.dat", "HMQV P-256", t);
BenchMarkKeyAgreement<HMQV384>(CRYPTOPP_DATA_DIR "TestData/hmqv384.dat", "HMQV P-384", t);
BenchMarkKeyAgreement<HMQV512>(CRYPTOPP_DATA_DIR "TestData/hmqv512.dat", "HMQV P-512", t);
BenchMarkKeyAgreement<ECHMQV160>(CRYPTOPP_DATA_DIR "TestData/hmqv160.dat", "HMQV P-160", t);
BenchMarkKeyAgreement<ECHMQV256>(CRYPTOPP_DATA_DIR "TestData/hmqv256.dat", "HMQV P-256", t);
BenchMarkKeyAgreement<ECHMQV384>(CRYPTOPP_DATA_DIR "TestData/hmqv384.dat", "HMQV P-384", t);
BenchMarkKeyAgreement<ECHMQV512>(CRYPTOPP_DATA_DIR "TestData/hmqv512.dat", "HMQV P-512", t);
BenchMarkKeyAgreement<FHMQV160>(CRYPTOPP_DATA_DIR "TestData/fhmqv160.dat", "FHMQV P-160", t);
BenchMarkKeyAgreement<FHMQV256>(CRYPTOPP_DATA_DIR "TestData/fhmqv256.dat", "FHMQV P-256", t);
BenchMarkKeyAgreement<FHMQV384>(CRYPTOPP_DATA_DIR "TestData/fhmqv384.dat", "FHMQV P-384", t);
BenchMarkKeyAgreement<FHMQV512>(CRYPTOPP_DATA_DIR "TestData/fhmqv512.dat", "FHMQV P-512", t);
BenchMarkKeyAgreement<ECFHMQV160>(CRYPTOPP_DATA_DIR "TestData/fhmqv160.dat", "FHMQV P-160", t);
BenchMarkKeyAgreement<ECFHMQV256>(CRYPTOPP_DATA_DIR "TestData/fhmqv256.dat", "FHMQV P-256", t);
BenchMarkKeyAgreement<ECFHMQV384>(CRYPTOPP_DATA_DIR "TestData/fhmqv384.dat", "FHMQV P-384", t);
BenchMarkKeyAgreement<ECFHMQV512>(CRYPTOPP_DATA_DIR "TestData/fhmqv512.dat", "FHMQV P-512", t);
#endif
cout << "\n<TBODY style=\"background: white\">";

View File

@ -219,38 +219,38 @@ struct ECMQV
//! \details This implementation follows Hugo Krawczyk's <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 is not provided.
template <class EC, class COFACTOR_OPTION = CPP_TYPENAME DL_GroupParameters_EC<EC>::DefaultCofactorOption, class HASH = SHA256>
struct HMQV
struct ECHMQV
{
typedef HMQV_Domain<DL_GroupParameters_EC<EC>, COFACTOR_OPTION, HASH> Domain;
#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
virtual ~HMQV() {}
virtual ~ECHMQV() {}
#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;
typedef ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA1 >::Domain ECHMQV160;
typedef ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA256 >::Domain ECHMQV256;
typedef ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA384 >::Domain ECHMQV384;
typedef ECHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA512 >::Domain ECHMQV512;
//! \brief Fully Hashed Menezes-Qu-Vanstone in ECP or EC2N
//! \details This implementation follows Augustin P. Sarr and Philippe ElbazVincent, and JeanClaude Bajard's
//! <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
struct ECFHMQV
{
typedef FHMQV_Domain<DL_GroupParameters_EC<EC>, COFACTOR_OPTION, HASH> Domain;
#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
virtual ~FHMQV() {}
virtual ~ECFHMQV() {}
#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;
typedef ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA1 >::Domain ECFHMQV160;
typedef ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA256 >::Domain ECFHMQV256;
typedef ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA384 >::Domain ECFHMQV384;
typedef ECFHMQV< ECP, DL_GroupParameters_EC< ECP >::DefaultCofactorOption, SHA512 >::Domain ECFHMQV512;
//! EC keys
template <class EC>

2
hmqv.h
View File

@ -300,7 +300,7 @@ private:
//! \brief Hashed Menezes-Qu-Vanstone in GF(p)
//! \details This implementation follows Hugo Krawczyk's <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 is not provided.
typedef HMQV_Domain<DL_GroupParameters_GFP_DefaultSafePrime> HMQV_GFP;
typedef HMQV_Domain<DL_GroupParameters_GFP_DefaultSafePrime> HMQV;
NAMESPACE_END

View File

@ -390,8 +390,8 @@ bool ValidateHMQV()
{
std::cout << "\nHMQV validation suite running...\n\n";
//HMQV< ECP >::Domain hmqvB(false /*server*/);
HMQV256 hmqvB(false);
//ECHMQV< ECP >::Domain hmqvB(false /*server*/);
ECHMQV256 hmqvB(false);
FileSource f256("TestData/hmqv256.dat", true, new HexDecoder());
FileSource f384("TestData/hmqv384.dat", true, new HexDecoder());
FileSource f512("TestData/hmqv512.dat", true, new HexDecoder());
@ -408,7 +408,7 @@ bool ValidateHMQV()
}
const OID oid = ASN1::secp256r1();
HMQV< ECP >::Domain hmqvA(oid, true /*client*/);
ECHMQV< ECP >::Domain hmqvA(oid, true /*client*/);
if (hmqvA.GetCryptoParameters().Validate(GlobalRNG(), 3))
std::cout << "passed authenticated key agreement domain parameters validation (client)" << std::endl;
@ -450,7 +450,7 @@ bool ValidateHMQV()
std::cout << endl;
std::cout << "HMQV with NIST P-384 and SHA-384:" << std::endl;
HMQV384 hmqvB384(false);
ECHMQV384 hmqvB384(false);
hmqvB384.AccessGroupParameters().BERDecode(f384);
if (hmqvB384.GetCryptoParameters().Validate(GlobalRNG(), 3))
@ -462,7 +462,7 @@ bool ValidateHMQV()
}
const OID oid384 = ASN1::secp384r1();
HMQV384 hmqvA384(oid384, true /*client*/);
ECHMQV384 hmqvA384(oid384, true /*client*/);
if (hmqvA384.GetCryptoParameters().Validate(GlobalRNG(), 3))
std::cout << "passed authenticated key agreement domain parameters validation (client)" << std::endl;
@ -507,8 +507,8 @@ bool ValidateFHMQV()
{
std::cout << "\nFHMQV validation suite running...\n\n";
//FHMQV< ECP >::Domain fhmqvB(false /*server*/);
FHMQV256 fhmqvB(false);
//ECFHMQV< ECP >::Domain fhmqvB(false /*server*/);
ECFHMQV256 fhmqvB(false);
FileSource f256("TestData/fhmqv256.dat", true, new HexDecoder());
FileSource f384("TestData/fhmqv384.dat", true, new HexDecoder());
FileSource f512("TestData/fhmqv512.dat", true, new HexDecoder());
@ -525,7 +525,7 @@ bool ValidateFHMQV()
}
const OID oid = ASN1::secp256r1();
FHMQV< ECP >::Domain fhmqvA(oid, true /*client*/);
ECFHMQV< ECP >::Domain fhmqvA(oid, true /*client*/);
if (fhmqvA.GetCryptoParameters().Validate(GlobalRNG(), 3))
std::cout << "passed authenticated key agreement domain parameters validation (client)" << std::endl;
@ -567,7 +567,7 @@ bool ValidateFHMQV()
std::cout << endl;
std::cout << "FHMQV with NIST P-384 and SHA-384:" << std::endl;
FHMQV384 fhmqvB384(false);
ECHMQV384 fhmqvB384(false);
fhmqvB384.AccessGroupParameters().BERDecode(f384);
if (fhmqvB384.GetCryptoParameters().Validate(GlobalRNG(), 3))
@ -579,7 +579,7 @@ bool ValidateFHMQV()
}
const OID oid384 = ASN1::secp384r1();
FHMQV384 fhmqvA384(oid384, true /*client*/);
ECHMQV384 fhmqvA384(oid384, true /*client*/);
if (fhmqvA384.GetCryptoParameters().Validate(GlobalRNG(), 3))
std::cout << "passed authenticated key agreement domain parameters validation (client)" << std::endl;