diff --git a/validat6.cpp b/validat6.cpp index 06d26276..16df05ab 100644 --- a/validat6.cpp +++ b/validat6.cpp @@ -254,7 +254,7 @@ bool ValidateECP() } std::cout << "\nECP validation suite running...\n\n"; - return ValidateECP_Agreement() && ValidateECP_Encrypt() && ValidateECP_Sign() && pass; + return ValidateECP_Agreement() && ValidateECP_Encrypt() && ValidateECP_NULLDigest_Encrypt() && ValidateECP_Sign() && pass; } bool ValidateEC2N() diff --git a/validat8.cpp b/validat8.cpp index c168a406..16d2daba 100644 --- a/validat8.cpp +++ b/validat8.cpp @@ -139,6 +139,49 @@ bool ValidateECP_Encrypt() return pass; } +class NULLHash : public CryptoPP::IteratedHashWithStaticTransform + +{ +public: + static void InitState(HashWordType *state) {} + static void Transform(CryptoPP::word32 *digest, const CryptoPP::word32 *data) {} + static const char *StaticAlgorithmName() {return "NULL HASH";} +}; + +template +struct ECIES_NULLDigest + : public DL_ES< + DL_Keys_EC, + DL_KeyAgreementAlgorithm_DH, + DL_KeyDerivationAlgorithm_P1363 >, + DL_EncryptionAlgorithm_Xor, DHAES_MODE, LABEL_OCTETS>, + ECIES > +{ + // TODO: fix this after name is standardized + CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "ECIES NULLDigest";} +}; + +bool ValidateECP_NULLDigest_Encrypt() +{ + ECIES_NULLDigest::Decryptor cpriv(GlobalRNG(), ASN1::secp256k1()); + ECIES_NULLDigest::Encryptor cpub(cpriv); + ByteQueue bq; + cpriv.GetKey().DEREncode(bq); + cpub.AccessKey().AccessGroupParameters().SetEncodeAsOID(true); + cpub.GetKey().DEREncode(bq); + + cpub.AccessKey().Precompute(); + cpriv.AccessKey().Precompute(); + bool pass = CryptoSystemValidate(cpriv, cpub); + + std::cout << "Turning on point compression..." << std::endl; + cpriv.AccessKey().AccessGroupParameters().SetPointCompression(true); + cpub.AccessKey().AccessGroupParameters().SetPointCompression(true); + pass = CryptoSystemValidate(cpriv, cpub) && pass; + + return pass; +} + bool ValidateEC2N_Encrypt() { // DEREncode() changed to Save() at Issue 569. diff --git a/validate.h b/validate.h index e95b2985..6c3ec6ac 100644 --- a/validate.h +++ b/validate.h @@ -372,6 +372,8 @@ bool ValidateECP_Agreement(); bool ValidateECP_Encrypt(); bool ValidateECP_Sign(); +bool ValidateECP_NULLDigest_Encrypt(); + bool ValidateEC2N(); bool ValidateEC2N_Agreement(); bool ValidateEC2N_Encrypt();