diff options
Diffstat (limited to 'src/tests/test_newhope.cpp')
-rw-r--r-- | src/tests/test_newhope.cpp | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/src/tests/test_newhope.cpp b/src/tests/test_newhope.cpp index ddd5a8101..112b1f4a7 100644 --- a/src/tests/test_newhope.cpp +++ b/src/tests/test_newhope.cpp @@ -7,10 +7,10 @@ #include "tests.h" #if defined(BOTAN_HAS_NEWHOPE) && defined(BOTAN_HAS_CHACHA) - #include <botan/newhope.h> - #include <botan/sha3.h> - #include <botan/chacha.h> - #include <botan/rng.h> + #include <botan/newhope.h> + #include <botan/sha3.h> + #include <botan/chacha.h> + #include <botan/rng.h> #endif namespace Botan_Tests { @@ -20,15 +20,23 @@ namespace Botan_Tests { class NEWHOPE_RNG : public Botan::RandomNumberGenerator { public: - std::string name() const override { return "NEWHOPE_RNG"; } - void clear() override { /* ignored */ } + std::string name() const override + { + return "NEWHOPE_RNG"; + } + void clear() override + { + /* ignored */ + } void randomize(uint8_t out[], size_t len) override { if(m_first.size() == len) { if(len != 32) + { throw Test_Error("NEWHOPE_RNG called in unexpected way, bad test?"); + } Botan::copy_mem(out, m_first.data(), m_first.size()); return; @@ -58,9 +66,15 @@ class NEWHOPE_RNG : public Botan::RandomNumberGenerator m_chacha.set_iv(nonce, 8); } - bool is_seeded() const override { return true; } + bool is_seeded() const override + { + return true; + } - void add_entropy(const uint8_t[], size_t) override { /* ignored */ } + void add_entropy(const uint8_t[], size_t) override + { + /* ignored */ + } NEWHOPE_RNG(const std::vector<uint8_t>& seed) { @@ -89,10 +103,10 @@ class NEWHOPE_RNG : public Botan::RandomNumberGenerator class NEWHOPE_Tests : public Text_Based_Test { public: - NEWHOPE_Tests() : Text_Based_Test( - "pubkey/newhope.vec", - "DRBG_SeedA,H_OutputA,DRBG_SeedB,H_OutputB,SharedKey") - {} + NEWHOPE_Tests() + : Text_Based_Test( + "pubkey/newhope.vec", + "DRBG_SeedA,H_OutputA,DRBG_SeedB,H_OutputB,SharedKey") {} Test::Result run_one_test(const std::string&, const VarMap& vars) override { |