• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 5111374265

29 May 2023 11:19AM UTC coverage: 92.227% (+0.5%) from 91.723%
5111374265

push

github

randombit
Next release will be 3.1.0. Update release notes

75588 of 81959 relevant lines covered (92.23%)

11886470.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.21
/src/tests/test_rfc6979.cpp
1
/*
2
* (C) 2014,2015 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6

7
#include "tests.h"
8

9
#if defined(BOTAN_HAS_RFC6979_GENERATOR)
10
   #include <botan/hash.h>
11
   #include <botan/internal/rfc6979.h>
12
#endif
13

14
namespace Botan_Tests {
15

16
namespace {
17

18
#if defined(BOTAN_HAS_RFC6979_GENERATOR)
19

20
class RFC6979_KAT_Tests final : public Text_Based_Test {
×
21
   public:
22
      RFC6979_KAT_Tests() : Text_Based_Test("rfc6979.vec", "Q,X,H,K") {}
2✔
23

24
      Test::Result run_one_test(const std::string& hash, const VarMap& vars) override {
2✔
25
         const BigInt Q = vars.get_req_bn("Q");
2✔
26
         const BigInt X = vars.get_req_bn("X");
2✔
27
         const BigInt H = vars.get_req_bn("H");
2✔
28
         const BigInt K = vars.get_req_bn("K");
2✔
29

30
         Test::Result result("RFC 6979 nonce generation");
2✔
31

32
         auto hash_func = Botan::HashFunction::create(hash);
2✔
33

34
         if(!hash_func) {
2✔
35
            result.test_note("Skipping due to missing: " + hash);
×
36
            return result;
×
37
         }
38

39
         result.test_eq("vector matches", Botan::generate_rfc6979_nonce(X, Q, H, hash), K);
4✔
40

41
         Botan::RFC6979_Nonce_Generator gen(hash, Q, X);
2✔
42

43
         result.test_eq("vector matches", gen.nonce_for(H), K);
2✔
44
         result.test_ne("different output for H+1", gen.nonce_for(H + 1), K);
4✔
45
         result.test_eq("vector matches when run again", gen.nonce_for(H), K);
2✔
46

47
         return result;
2✔
48
      }
12✔
49
};
50

51
BOTAN_REGISTER_TEST("pubkey", "rfc6979", RFC6979_KAT_Tests);
52

53
#endif
54

55
}  // namespace
56

57
}  // namespace Botan_Tests
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc