From f08260c3e2c1b2631f2297af0c57b7a43911379f Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Wed, 29 Mar 2017 11:54:45 -0400 Subject: Fix RSA blinding test Failed if OpenSSL was used since OpenSSL does (whatever it does). GH #879 --- src/tests/test_rsa.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/tests/test_rsa.cpp') diff --git a/src/tests/test_rsa.cpp b/src/tests/test_rsa.cpp index b22b8d044..2078a399e 100644 --- a/src/tests/test_rsa.cpp +++ b/src/tests/test_rsa.cpp @@ -141,6 +141,7 @@ class RSA_Blinding_Tests : public Test #if defined(BOTAN_HAS_EMSA_RAW) || defined(BOTAN_HAS_EME_RAW) Botan::RSA_PrivateKey rsa(Test::rng(), 1024); + Botan::Null_RNG null_rng; #endif #if defined(BOTAN_HAS_EMSA_RAW) @@ -153,10 +154,9 @@ class RSA_Blinding_Tests : public Test * are used as an additional test on the blinders. */ - Botan::PK_Signer signer(rsa, Test::rng(), "Raw"); // don't try this at home + Botan::PK_Signer signer(rsa, Test::rng(), "Raw", Botan::IEEE_1363, "base"); // don't try this at home Botan::PK_Verifier verifier(rsa, "Raw"); - Botan::Null_RNG null_rng; for(size_t i = 1; i <= BOTAN_BLINDING_REINIT_INTERVAL * 6; ++i) { std::vector input(16); @@ -187,14 +187,14 @@ class RSA_Blinding_Tests : public Test // test blinding reinit interval // Seed Fixed_Output_RNG only with enough bytes for the initial blinder initialization Botan_Tests::Fixed_Output_RNG fixed_rng(Botan::unlock(Test::rng().random_vec(rsa.get_n().bytes()))); - Botan::PK_Decryptor_EME decryptor(rsa, fixed_rng, "Raw"); + Botan::PK_Decryptor_EME decryptor(rsa, fixed_rng, "Raw", "base"); for(size_t i = 1; i <= BOTAN_BLINDING_REINIT_INTERVAL ; ++i) { std::vector input(16); input[ input.size() - 1 ] = static_cast(i); - std::vector ciphertext = encryptor.encrypt(input, Test::rng()); + std::vector ciphertext = encryptor.encrypt(input, null_rng); std::vector plaintext = Botan::unlock(decryptor.decrypt(ciphertext)); plaintext.insert(plaintext.begin(), input.size() - 1, 0); @@ -202,12 +202,14 @@ class RSA_Blinding_Tests : public Test result.test_eq("Successful decryption", plaintext, input); } + result.test_eq("RNG is no longer seeded", fixed_rng.is_seeded(), false); + // one more decryption should trigger a blinder reinitialization result.test_throws("RSA blinding reinit", "Test error Fixed output RNG ran out of bytes, test bug?", [&decryptor,&encryptor]() { - std::vector ciphertext = encryptor.encrypt(std::vector(16, 5), Test::rng()); + std::vector ciphertext = encryptor.encrypt(std::vector(16, 5), null_rng); decryptor.decrypt(ciphertext); }); -- cgit v1.2.3