diff --git a/Filelist.txt b/Filelist.txt index af30fe81..581fcee0 100644 --- a/Filelist.txt +++ b/Filelist.txt @@ -388,7 +388,8 @@ TestData/aria.dat TestData/camellia.dat TestData/cast128v.dat TestData/cast256v.dat -TestData/defdmac.bin +TestData/defdmac1.bin +TestData/defdmac2.bin TestData/descert.dat TestData/dh1024.dat TestData/dh2048.dat diff --git a/TestData/defdmac1.bin b/TestData/defdmac1.bin new file mode 100644 index 00000000..b02ac428 --- /dev/null +++ b/TestData/defdmac1.bin @@ -0,0 +1 @@ +nCB pIb__|+"w#Anmȇ%kXRw`Z^s.+ڵ`Bf]z}R`}\dibftt^ \ No newline at end of file diff --git a/TestData/defdmac.bin b/TestData/defdmac2.bin similarity index 100% rename from TestData/defdmac.bin rename to TestData/defdmac2.bin diff --git a/default.cpp b/default.cpp index eda6cb14..ab1890b5 100644 --- a/default.cpp +++ b/default.cpp @@ -299,8 +299,8 @@ template class DataEncryptor; template class DataEncryptor; template class DataDecryptor; -template class DataEncryptorWithMAC; -template class DataDecryptorWithMAC; +template class DataEncryptorWithMAC; +template class DataDecryptorWithMAC; template class DataEncryptorWithMAC; template class DataDecryptorWithMAC; diff --git a/default.h b/default.h index 2fb7982f..12360018 100644 --- a/default.h +++ b/default.h @@ -275,12 +275,12 @@ struct DefaultDecryptor : public DataDecryptorDefault* classes, and the old algorithms are available with the Legacy* classes. -struct LegacyEncryptorWithMAC : public DataEncryptorWithMAC {}; +struct LegacyEncryptorWithMAC : public DataEncryptorWithMAC {}; /// \brief Password-based decryptor with MAC (deprecated) /// \details Crypto++ 5.6.5 and earlier used the legacy algorithms, including DES_EDE2 and SHA1. /// Crypto++ 5.7 switched to AES and SHA256. The updated algorithms are available with the /// Default* classes, and the old algorithms are available with the Legacy* classes. -struct LegacyDecryptorWithMAC : public DataDecryptorWithMAC {}; +struct LegacyDecryptorWithMAC : public DataDecryptorWithMAC {}; /// \brief Password-based encryptor with MAC /// \details Crypto++ 5.6.5 and earlier used the legacy algorithms, including DES_EDE2 and SHA1. /// Crypto++ 5.7 switched to AES and SHA256. The updated algorithms are available with the @@ -298,8 +298,8 @@ typedef DataDecryptor L typedef DataEncryptor DefaultEncryptor; typedef DataDecryptor DefaultDecryptor; -typedef DataEncryptorWithMAC LegacyEncryptorWithMAC; -typedef DataDecryptorWithMAC LegacyDecryptorWithMAC; +typedef DataEncryptorWithMAC LegacyEncryptorWithMAC; +typedef DataDecryptorWithMAC LegacyDecryptorWithMAC; typedef DataEncryptorWithMAC DefaultEncryptorWithMAC; typedef DataDecryptorWithMAC DefaultDecryptorWithMAC; diff --git a/validat0.cpp b/validat0.cpp index 62e5ec30..d9c445f1 100644 --- a/validat0.cpp +++ b/validat0.cpp @@ -434,10 +434,22 @@ bool TestEncryptors() try { + // Common password and message. std::string password = "super secret password"; std::string recovered, message = "Now is the time for all good men to come to the aide of their country."; - //StringSource(message, true, new DefaultEncryptorWithMAC(password.c_str(), new FileSink("TestData/defdmac.bin"))); - FileSource("TestData/defdmac.bin", true, new DefaultDecryptorWithMAC(password.c_str(), new StringSink(recovered))); + + // This data was generated with Crypto++ 5.6.2 + //StringSource(message, true, new LegacyEncryptorWithMAC(password.c_str(), new FileSink("TestData/defdmac1.bin"))); + FileSource("TestData/defdmac1.bin", true, new LegacyDecryptorWithMAC(password.c_str(), new StringSink(recovered))); + if (message != recovered) + throw Exception(Exception::OTHER_ERROR, "LegacyDecryptorWithMAC failed a self test"); + + // Reset sink + recovered.clear(); + + // This data was generated with Crypto++ 6.0 + //StringSource(message, true, new DefaultEncryptorWithMAC(password.c_str(), new FileSink("TestData/defdmac2.bin"))); + FileSource("TestData/defdmac2.bin", true, new DefaultDecryptorWithMAC(password.c_str(), new StringSink(recovered))); if (message != recovered) throw Exception(Exception::OTHER_ERROR, "DefaultDecryptorWithMAC failed a self test"); } @@ -1491,22 +1503,22 @@ bool TestASN1Parse() #if defined(CRYPTOPP_EXTENDED_VALIDATION) bool TestStringSink() { - try - { - std::string in = "The quick brown fox jumps over the lazy dog"; + try + { + std::string in = "The quick brown fox jumps over the lazy dog"; - std::string str; - StringSource s1(in, true, new StringSink(str)); + std::string str; + StringSource s1(in, true, new StringSink(str)); - std::vector vec; - StringSource s2(in, true, new VectorSink(vec)); + std::vector vec; + StringSource s2(in, true, new VectorSink(vec)); - return str.size() == vec.size() && std::equal(str.begin(), str.end(), vec.begin()); - } - catch(const std::exception&) - { - } - return false; + return str.size() == vec.size() && std::equal(str.begin(), str.end(), vec.begin()); + } + catch(const std::exception&) + { + } + return false; } #endif