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

randombit / botan / 5079590438

25 May 2023 12:28PM UTC coverage: 92.228% (+0.5%) from 91.723%
5079590438

Pull #3502

github

Pull Request #3502: Apply clang-format to the codebase

75589 of 81959 relevant lines covered (92.23%)

12139530.51 hits per line

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

88.0
/src/tests/test_siv.cpp
1
/*
2
* (C) 2017 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_AEAD_SIV)
10
   #include <botan/aead.h>
11
   #include <botan/internal/parsing.h>
12
#endif
13

14
namespace Botan_Tests {
15

16
namespace {
17

18
#if defined(BOTAN_HAS_AEAD_SIV)
19

20
class SIV_Tests final : public Text_Based_Test {
×
21
   public:
22
      SIV_Tests() : Text_Based_Test("siv_ad.vec", "Key,In,ADs,Out", "Nonce") {}
2✔
23

24
      Test::Result run_one_test(const std::string& algo, const VarMap& vars) override {
5✔
25
         const std::vector<uint8_t> key = vars.get_req_bin("Key");
5✔
26
         const std::vector<uint8_t> nonce = vars.get_opt_bin("Nonce");
5✔
27
         const std::vector<uint8_t> input = vars.get_req_bin("In");
5✔
28
         const std::vector<uint8_t> expected = vars.get_req_bin("Out");
5✔
29
         const std::vector<std::string> ad_list = Botan::split_on(vars.get_req_str("ADs"), ',');
10✔
30

31
         const std::string siv_name = algo + "/SIV";
5✔
32

33
         Test::Result result(siv_name);
10✔
34

35
         auto siv = Botan::AEAD_Mode::create(siv_name, Botan::Cipher_Dir::Encryption);
5✔
36

37
         if(!siv) {
5✔
38
            result.test_note("Skipping test due to missing cipher");
×
39
            return result;
×
40
         }
41

42
         siv->set_key(key);
5✔
43

44
         for(size_t i = 0; i != ad_list.size(); ++i) {
21✔
45
            std::vector<uint8_t> ad = Botan::hex_decode(ad_list[i]);
16✔
46
            siv->set_associated_data_n(i, ad);
16✔
47
         }
16✔
48

49
         Botan::secure_vector<uint8_t> buf(input.begin(), input.end());
5✔
50
         siv->start(nonce);
5✔
51
         siv->finish(buf, 0);
5✔
52

53
         result.test_eq("SIV ciphertext", buf, expected);
5✔
54

55
         return result;
5✔
56
      }
25✔
57
};
58

59
BOTAN_REGISTER_TEST("modes", "siv_ad", SIV_Tests);
60

61
#endif
62

63
}
64

65
}
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