diff options
Diffstat (limited to 'src/tests/test_c25519.cpp')
-rw-r--r-- | src/tests/test_c25519.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/tests/test_c25519.cpp b/src/tests/test_c25519.cpp index ccc84a4b0..2c7003e1d 100644 --- a/src/tests/test_c25519.cpp +++ b/src/tests/test_c25519.cpp @@ -38,6 +38,7 @@ class Curve25519_Sclarmult_Tests final : public Text_Based_Test return result; } }; +BOTAN_REGISTER_TEST("curve25519_scalar", Curve25519_Sclarmult_Tests); class Curve25519_Roundtrip_Test final : public Test { @@ -57,6 +58,7 @@ class Curve25519_Roundtrip_Test final : public Test const std::string b_pass = "bob pass"; // Then serialize to encrypted storage +#if defined(BOTAN_HAS_AES) && defined(BOTAN_HAS_GCM) const auto pbe_time = std::chrono::milliseconds(10); const std::string a_priv_pem = Botan::PKCS8::PEM_encode(a_priv_gen, Test::rng(), a_pass, pbe_time); const std::string b_priv_pem = Botan::PKCS8::PEM_encode(b_priv_gen, Test::rng(), b_pass, pbe_time); @@ -67,6 +69,17 @@ class Curve25519_Roundtrip_Test final : public Test std::unique_ptr<Botan::Private_Key> a_priv(Botan::PKCS8::load_key(a_priv_ds, Test::rng(), [a_pass]() { return a_pass; })); std::unique_ptr<Botan::Private_Key> b_priv(Botan::PKCS8::load_key(b_priv_ds, Test::rng(), b_pass)); +#else + const std::string a_priv_pem = Botan::PKCS8::PEM_encode(a_priv_gen); + const std::string b_priv_pem = Botan::PKCS8::PEM_encode(b_priv_gen); + + // Reload back into memory + Botan::DataSource_Memory a_priv_ds(a_priv_pem); + Botan::DataSource_Memory b_priv_ds(b_priv_pem); + + std::unique_ptr<Botan::Private_Key> a_priv(Botan::PKCS8::load_key(a_priv_ds, Test::rng())); + std::unique_ptr<Botan::Private_Key> b_priv(Botan::PKCS8::load_key(b_priv_ds, Test::rng())); +#endif // Export public keys as PEM const std::string a_pub_pem = Botan::X509::PEM_encode(*a_priv); @@ -83,8 +96,8 @@ class Curve25519_Roundtrip_Test final : public Test if(a_pub_key && b_pub_key) { - Botan::PK_Key_Agreement a_ka(*a_priv, Test::rng(), "KDF2(SHA-256)"); - Botan::PK_Key_Agreement b_ka(*b_priv, Test::rng(), "KDF2(SHA-256)"); + Botan::PK_Key_Agreement a_ka(*a_priv, Test::rng(), "Raw"); + Botan::PK_Key_Agreement b_ka(*b_priv, Test::rng(), "Raw"); const std::string context = "shared context value"; Botan::SymmetricKey a_key = a_ka.derive_key(32, b_pub_key->public_value(), context); @@ -108,6 +121,8 @@ class Curve25519_Roundtrip_Test final : public Test } }; +BOTAN_REGISTER_TEST("curve25519_rt", Curve25519_Roundtrip_Test); + class Curve25519_Keygen_Tests final : public PK_Key_Generation_Test { public: @@ -121,8 +136,6 @@ class Curve25519_Keygen_Tests final : public PK_Key_Generation_Test } }; -BOTAN_REGISTER_TEST("curve25519_scalar", Curve25519_Sclarmult_Tests); -BOTAN_REGISTER_TEST("curve25519_rt", Curve25519_Roundtrip_Test); BOTAN_REGISTER_TEST("curve25519_keygen", Curve25519_Keygen_Tests); #endif |