From f74c9196543bc16765b857232949028286a9396c Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Tue, 23 May 2023 18:32:50 -0700 Subject: [PATCH] Use different values for p and r in scrypt test settings to make sure we catch serialization errors that confuse the two --- src/cpp-utils/crypto/kdf/Scrypt.h | 2 +- test/cpp-utils/crypto/kdf/SCryptTest.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cpp-utils/crypto/kdf/Scrypt.h b/src/cpp-utils/crypto/kdf/Scrypt.h index 04b8269e..2824c7b4 100644 --- a/src/cpp-utils/crypto/kdf/Scrypt.h +++ b/src/cpp-utils/crypto/kdf/Scrypt.h @@ -23,7 +23,7 @@ namespace cpputils { public: static constexpr SCryptSettings ParanoidSettings = SCryptSettings {32, 1048576, 8, 16}; static constexpr SCryptSettings DefaultSettings = SCryptSettings {32, 1048576, 4, 8}; - static constexpr SCryptSettings TestSettings = SCryptSettings {32, 1024, 1, 1}; + static constexpr SCryptSettings TestSettings = SCryptSettings {32, 1024, 1, 2}; explicit SCrypt(const SCryptSettings& settingsForNewKeys); diff --git a/test/cpp-utils/crypto/kdf/SCryptTest.cpp b/test/cpp-utils/crypto/kdf/SCryptTest.cpp index 906d7235..15d64038 100644 --- a/test/cpp-utils/crypto/kdf/SCryptTest.cpp +++ b/test/cpp-utils/crypto/kdf/SCryptTest.cpp @@ -21,9 +21,9 @@ TEST_F(SCryptTest, GeneratedKeyIsReproductible_448) { TEST_F(SCryptTest, BackwardsCompatibility_448) { SCrypt scrypt(SCrypt::TestSettings); - auto kdfParameters = Data::FromString("000400000000000001000000010000006525D6D08CF88ADD10180F90322372A04F9E1C6D98264D94A7AC5CADF6286F23"); + auto kdfParameters = Data::FromString("00040000000000000100000002000000E429AFB0500BD5D172089598B76E6B9ED6D0DDAF3B08F99AA05357F96F4F7823"); auto rederivedKey = scrypt.deriveExistingKey(56, "mypassword", kdfParameters); - EXPECT_EQ("460C501CC3BD2A26C2C82ABF72DB07616793F6B0EBAE5AD4E00BE1813B154BC9F22E58D9B49B123CC0D354A7DBF7BEC7325F3838455E932B", rederivedKey.ToString()); + EXPECT_EQ("70416B4E1569E2335442F7FE740E6A8ADC149514B7B6D7838A996AE0E2125F743341E72FF9F44C91A9675EAE459C0C0126FDB6CE220436E0", rederivedKey.ToString()); } TEST_F(SCryptTest, GeneratedKeyIsReproductible_256) { @@ -35,9 +35,9 @@ TEST_F(SCryptTest, GeneratedKeyIsReproductible_256) { TEST_F(SCryptTest, BackwardsCompatibility_256) { SCrypt scrypt(SCrypt::TestSettings); - auto kdfParameters = Data::FromString("000400000000000001000000010000008E1E5C8BE2665897FCFA96E829CB3322824B174F295382673D43AF752AC51447"); + auto kdfParameters = Data::FromString("000400000000000001000000020000007D65C035E0C4250003A24ED11ABD41F6101DEEC104F6875EE1B808A6683535BD"); auto rederivedKey = scrypt.deriveExistingKey(32, "mypassword", kdfParameters); - EXPECT_EQ("00C193FB9028F1371590FB9309F254377FFC3B6E1DDBBD5E0AD2F56AE1900D91", rederivedKey.ToString()); + EXPECT_EQ("A423A0176F99A3197722D4B8686110FC2E2C04FF5E37AE43A7241097598F599D", rederivedKey.ToString()); } TEST_F(SCryptTest, GeneratedKeyIsReproductible_128) { @@ -49,9 +49,9 @@ TEST_F(SCryptTest, GeneratedKeyIsReproductible_128) { TEST_F(SCryptTest, BackwardsCompatibility_128) { SCrypt scrypt(SCrypt::TestSettings); - auto kdfParameters = Data::FromString("00040000000000000100000001000000C66B1F2B1175C23909488AB895A4E8BFCF59A4878AED5B299C37E445820EB415"); + auto kdfParameters = Data::FromString("000400000000000001000000020000008514339A7F583D80C9865C9EA01B698EE8AEAF99AE5F7AE79C8817D2E73D553D"); auto rederivedKey = scrypt.deriveExistingKey(16, "mypassword", kdfParameters); - EXPECT_EQ("24F0FB654ECB04827B1621CF4E00858F", rederivedKey.ToString()); + EXPECT_EQ("2EF2F0A4EC335C961D4BE58BFB722F75", rederivedKey.ToString()); } TEST_F(SCryptTest, GeneratedKeyIsReproductible_DefaultSettings) {