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

randombit / botan / 21768358452

06 Feb 2026 10:35PM UTC coverage: 90.064% (-0.003%) from 90.067%
21768358452

Pull #5289

github

web-flow
Merge f589db195 into 8ea0ca252
Pull Request #5289: Further misc header reductions, forward declarations, etc

102238 of 113517 relevant lines covered (90.06%)

11357432.36 hits per line

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

97.87
/src/tests/test_tls_handshake_state_13.cpp
1
/*
2
* (C) 2022 Jack Lloyd
3
* (C) 2022 Hannes Rantzsch, René Meusel - neXenio
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#include "tests.h"
9

10
#if defined(BOTAN_HAS_TLS_13)
11
   #include <botan/hex.h>
12
   #include <botan/tls_exceptn.h>
13
   #include <botan/internal/tls_handshake_state_13.h>
14
#endif
15

16
namespace Botan_Tests {
17

18
namespace {
19

20
#if defined(BOTAN_HAS_TLS_13)
21

22
// From RFC 8448
23
const auto client_hello_message_hex =
24
   "03 03 cb"
25
   "34 ec b1 e7 81 63 ba 1c 38 c6 da cb 19 6a 6d ff a2 1a 8d 99 12"
26
   "ec 18 a2 ef 62 83 02 4d ec e7 00 00 06 13 01 13 03 13 02 01 00"
27
   "00 91 00 00 00 0b 00 09 00 00 06 73 65 72 76 65 72 ff 01 00 01"
28
   "00 00 0a 00 14 00 12 00 1d 00 17 00 18 00 19 01 00 01 01 01 02"
29
   "01 03 01 04 00 23 00 00 00 33 00 26 00 24 00 1d 00 20 99 38 1d"
30
   "e5 60 e4 bd 43 d2 3d 8e 43 5a 7d ba fe b3 c0 6e 51 c1 3c ae 4d"
31
   "54 13 69 1e 52 9a af 2c 00 2b 00 03 02 03 04 00 0d 00 20 00 1e"
32
   "04 03 05 03 06 03 02 03 08 04 08 05 08 06 04 01 05 01 06 01 02"
33
   "01 04 02 05 02 06 02 02 02 00 2d 00 02 01 01 00 1c 00 02 40 01";
34

35
const auto server_hello_message_hex =
36
   "03 03 a6"
37
   "af 06 a4 12 18 60 dc 5e 6e 60 24 9c d3 4c 95 93 0c 8a c5 cb 14"
38
   "34 da c1 55 77 2e d3 e2 69 28 00 13 01 00 00 2e 00 33 00 24 00"
39
   "1d 00 20 c9 82 88 76 11 20 95 fe 66 76 2b db f7 c6 72 e1 56 d6"
40
   "cc 25 3b 83 3d f1 dd 69 b1 b0 4e 75 1f 0f 00 2b 00 02 03 04";
41

42
const auto server_finished_message_hex =
43
   "9b 9b 14 1d 90 63 37 fb"
44
   "d2 cb dc e7 1d f4 de da 4a b4 2c 30"
45
   "95 72 cb 7f ff ee 54 54 b7 8f 07 18";
46

47
const auto client_finished_message_hex =
48
   "a8 ec 43 6d 67 76 34 ae 52 5a c1"
49
   "fc eb e1 1a 03 9e c1 76 94 fa c6 e9 85 27 b6 42 f2 ed d5 ce 61";
50

51
std::vector<Test::Result> finished_message_handling() {
1✔
52
   return {
1✔
53
      CHECK("Client sends and receives Finished messages",
54
            [&](auto& result) {
1✔
55
               Botan::TLS::Client_Handshake_State_13 state;
1✔
56

57
               const auto client_finished_message = Botan::hex_decode(client_finished_message_hex);
1✔
58
               const auto server_finished_message = Botan::hex_decode(server_finished_message_hex);
1✔
59

60
               Botan::TLS::Finished_13 client_finished(client_finished_message);
1✔
61

62
               [[maybe_unused]]  // just making sure that the return type of .sending is correct
63
               const std::reference_wrapper<Botan::TLS::Finished_13>
64
                  client_fin = state.sending(std::move(client_finished));
1✔
65
               result.test_throws("not stored as server Finished", [&] { state.server_finished(); });
4✔
66
               result.test_eq(
4✔
67
                  "correct client Finished stored", state.client_finished().serialize(), client_finished_message);
1✔
68

69
               Botan::TLS::Finished_13 server_finished(server_finished_message);
1✔
70

71
               auto server_fin = state.received(std::move(server_finished));
2✔
72
               result.require("client can receive server finished",
2✔
73
                              std::holds_alternative<std::reference_wrapper<Botan::TLS::Finished_13>>(server_fin));
1✔
74
               result.test_eq(
4✔
75
                  "correct client Finished stored", state.client_finished().serialize(), client_finished_message);
1✔
76
               result.test_eq(
4✔
77
                  "correct server Finished stored", state.server_finished().serialize(), server_finished_message);
1✔
78
            }),
3✔
79
   };
2✔
80
}
1✔
81

82
std::vector<Test::Result> handshake_message_filtering() {
1✔
83
   return {
1✔
84
      CHECK("Client with client hello",
85
            [&](auto& result) {
1✔
86
               Botan::TLS::Client_Handshake_State_13 state;
1✔
87

88
               const auto client_hello_message = Botan::hex_decode(client_hello_message_hex);
1✔
89

90
               auto client_hello =
3✔
91
                  std::get<Botan::TLS::Client_Hello_13>(Botan::TLS::Client_Hello_13::parse(client_hello_message));
92

93
               [[maybe_unused]]  // just making sure that the return type of .sending is correct
94
               const std::reference_wrapper<Botan::TLS::Client_Hello_13>
95
                  filtered = state.sending(std::move(client_hello));
2✔
96
               result.test_eq("correct client hello stored", state.client_hello().serialize(), client_hello_message);
2✔
97

98
               result.template test_throws<Botan::TLS::TLS_Exception>(
3✔
99
                  "client cannot receive client hello", "received an illegal handshake message", [&] {
1✔
100
                     auto ch =
2✔
101
                        std::get<Botan::TLS::Client_Hello_13>(Botan::TLS::Client_Hello_13::parse(client_hello_message));
102
                     state.received(std::move(ch));
2✔
103
                  });
×
104
            }),
2✔
105
      CHECK("Client with server hello",
106
            [&](auto& result) {
1✔
107
               Botan::TLS::Client_Handshake_State_13 state;
1✔
108

109
               const auto server_hello_message = Botan::hex_decode(server_hello_message_hex);
1✔
110

111
               auto server_hello =
3✔
112
                  std::get<Botan::TLS::Server_Hello_13>(Botan::TLS::Server_Hello_13::parse(server_hello_message));
113

114
               auto filtered = state.received(std::move(server_hello));
2✔
115
               result.confirm("client can receive server hello",
1✔
116
                              std::holds_alternative<std::reference_wrapper<Botan::TLS::Server_Hello_13>>(filtered));
1✔
117

118
               result.test_eq("correct server hello stored", state.server_hello().serialize(), server_hello_message);
3✔
119
            }),
2✔
120
   };
3✔
121
}
1✔
122

123
BOTAN_REGISTER_TEST_FN("tls", "tls_handshake_state_13", finished_message_handling, handshake_message_filtering);
124

125
#endif
126

127
}  // namespace
128

129
}  // 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

© 2026 Coveralls, Inc