aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_newhope.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-10-18 12:27:37 -0400
committerJack Lloyd <[email protected]>2016-10-19 14:41:10 -0400
commit3324f00a8b094c86cee1f5a59ec6fc746663bd7e (patch)
treebc3dfb670237c9b7ebaac3539cdf91a02414a712 /src/tests/test_newhope.cpp
parentd1817c9960f619b130388a570ed09ccbed568e2e (diff)
Add proper SHA-3
Kind of a copy and paste of Keccak, but only a single copy of the permutation at least. Keccak depends on SHA-3 instead of the reverse, so that SHA-3 can be enabled without also bringing in an unapproved hash function. Updates newhope code and removes API function newhope_hash which was an unofficial SHA-3-256.
Diffstat (limited to 'src/tests/test_newhope.cpp')
-rw-r--r--src/tests/test_newhope.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/tests/test_newhope.cpp b/src/tests/test_newhope.cpp
index ed3690f55..894896777 100644
--- a/src/tests/test_newhope.cpp
+++ b/src/tests/test_newhope.cpp
@@ -8,6 +8,7 @@
#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>
#endif
@@ -101,13 +102,15 @@ class NEWHOPE_Tests : public Text_Based_Test
NEWHOPE_RNG drbg_a(get_req_bin(vars, "DRBG_SeedA"));
NEWHOPE_RNG drbg_b(get_req_bin(vars, "DRBG_SeedB"));
+ Botan::SHA_3_256 sha3;
+
std::vector<uint8_t> send_a(NEWHOPE_SENDABYTES);
Botan::newhope_poly a_sk;
Botan::newhope_keygen(send_a.data(), &a_sk, drbg_a);
- std::vector<uint8_t> h_send_a(32);
- Botan::newhope_hash(h_send_a.data(), send_a.data(), send_a.size());
-
+ std::vector<uint8_t> h_send_a(sha3.output_length());
+ sha3.update(send_a);
+ sha3.final(h_send_a.data());
result.test_eq("Hash Output A", h_send_a, h_output_a);
std::vector<uint8_t> sharedkey_b(32);
@@ -115,8 +118,9 @@ class NEWHOPE_Tests : public Text_Based_Test
Botan::newhope_sharedb(sharedkey_b.data(), send_b.data(), send_a.data(), drbg_b);
result.test_eq("Key B", sharedkey_b, shared_key);
- std::vector<uint8_t> h_send_b(32);
- Botan::newhope_hash(h_send_b.data(), send_b.data(), send_b.size());
+ std::vector<uint8_t> h_send_b(sha3.output_length());
+ sha3.update(send_b);
+ sha3.final(h_send_b.data());
result.test_eq("Hash Output B", h_send_b, h_output_b);
std::vector<uint8_t> sharedkey_a(32);