2
* (C) 2014,2015 Jack Lloyd
4
* Botan is released under the Simplified BSD License (see license.txt)
9
#if defined(BOTAN_HAS_RFC6979_GENERATOR)
10
#include <botan/rfc6979.h>
13
#include <botan/hash.h>
15
namespace Botan_Tests {
19
#if defined(BOTAN_HAS_RFC6979_GENERATOR)
21
class RFC6979_KAT_Tests final : public Text_Based_Test
24
RFC6979_KAT_Tests() : Text_Based_Test("rfc6979.vec", "Q,X,H,K") {}
26
Test::Result run_one_test(const std::string& hash, const VarMap& vars) override
28
const BigInt Q = get_req_bn(vars, "Q");
29
const BigInt X = get_req_bn(vars, "X");
30
const BigInt H = get_req_bn(vars, "H");
31
const BigInt K = get_req_bn(vars, "K");
33
Test::Result result("RFC 6979 nonce generation");
35
auto hash_func = Botan::HashFunction::create(hash);
39
result.test_note("Skipping due to missing: " + hash);
43
result.test_eq("vector matches", Botan::generate_rfc6979_nonce(X, Q, H, hash), K);
45
Botan::RFC6979_Nonce_Generator gen(hash, Q, X);
47
result.test_eq("vector matches", gen.nonce_for(H), K);
48
result.test_ne("different output for H+1", gen.nonce_for(H + 1), K);
49
result.test_eq("vector matches when run again", gen.nonce_for(H), K);
55
BOTAN_REGISTER_TEST("rfc6979", RFC6979_KAT_Tests);