diff --git a/tests/cryptotester.cpp b/tests/cryptotester.cpp index 81b2c5c54..c33a038ff 100644 --- a/tests/cryptotester.cpp +++ b/tests/cryptotester.cpp @@ -208,6 +208,12 @@ void CryptoTester::testAesEncryption() { CPPUNIT_ASSERT(salt1 != salt2); + auto encrypted11 = dht::crypto::aesBuildEncrypted(encrypted1_data, salt1); + auto encrypted22 = dht::crypto::aesBuildEncrypted(encrypted2_data, salt2); + + CPPUNIT_ASSERT(encrypted11 == encrypted1); + CPPUNIT_ASSERT(encrypted22 == encrypted2); + auto key12 = dht::crypto::stretchKey(password, salt1, 256/8); auto key22 = dht::crypto::stretchKey(password, salt2, 256/8); @@ -219,6 +225,18 @@ void CryptoTester::testAesEncryption() { CPPUNIT_ASSERT(data1 == decrypted1); CPPUNIT_ASSERT(data2 == decrypted2); + + auto encrypted12_data = dht::crypto::aesEncrypt(data1, key12); + auto encrypted22_data = dht::crypto::aesEncrypt(data2, key22); + + encrypted11 = dht::crypto::aesBuildEncrypted(encrypted12_data, salt1); + encrypted22 = dht::crypto::aesBuildEncrypted(encrypted22_data, salt2); + + decrypted1 = dht::crypto::aesDecrypt(encrypted11, password); + decrypted2 = dht::crypto::aesDecrypt(encrypted22, password); + + CPPUNIT_ASSERT(data1 == decrypted1); + CPPUNIT_ASSERT(data2 == decrypted2); } void