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

randombit / botan / 5123321399

30 May 2023 04:06PM UTC coverage: 92.213% (+0.004%) from 92.209%
5123321399

Pull #3558

github

web-flow
Merge dd72f7389 into 057bcbc35
Pull Request #3558: Add braces around all if/else statements

75602 of 81986 relevant lines covered (92.21%)

11859779.3 hits per line

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

96.67
/src/lib/tls/tls12/msg_hello_verify.cpp
1
/*
2
* DTLS Hello Verify Request
3
* (C) 2012 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#include <botan/tls_messages.h>
9

10
#include <botan/mac.h>
11

12
namespace Botan::TLS {
13

14
Hello_Verify_Request::Hello_Verify_Request(const std::vector<uint8_t>& buf) {
428✔
15
   if(buf.size() < 3) {
428✔
16
      throw Decoding_Error("Hello verify request too small");
1✔
17
   }
18

19
   Protocol_Version version(buf[0], buf[1]);
427✔
20

21
   if(!version.is_datagram_protocol()) {
427✔
22
      throw Decoding_Error("Unknown version from server in hello verify request");
1✔
23
   }
24

25
   if(static_cast<size_t>(buf[2]) + 3 != buf.size()) {
426✔
26
      throw Decoding_Error("Bad length in hello verify request");
3✔
27
   }
28

29
   m_cookie.assign(buf.begin() + 3, buf.end());
423✔
30
}
428✔
31

32
Hello_Verify_Request::Hello_Verify_Request(const std::vector<uint8_t>& client_hello_bits,
736✔
33
                                           std::string_view client_identity,
34
                                           const SymmetricKey& secret_key) {
736✔
35
   auto hmac = MessageAuthenticationCode::create_or_throw("HMAC(SHA-256)");
736✔
36
   hmac->set_key(secret_key);
736✔
37

38
   hmac->update_be(static_cast<uint64_t>(client_hello_bits.size()));
736✔
39
   hmac->update(client_hello_bits);
736✔
40
   hmac->update_be(static_cast<uint64_t>(client_identity.size()));
736✔
41
   hmac->update(client_identity);
736✔
42

43
   m_cookie.resize(hmac->output_length());
736✔
44
   hmac->final(m_cookie.data());
736✔
45
}
736✔
46

47
std::vector<uint8_t> Hello_Verify_Request::serialize() const {
367✔
48
   /* DTLS 1.2 server implementations SHOULD use DTLS version 1.0
49
      regardless of the version of TLS that is expected to be
50
      negotiated (RFC 6347, section 4.2.1)
51
   */
52

53
   Protocol_Version format_version(254, 255);  // DTLS 1.0
367✔
54

55
   std::vector<uint8_t> bits;
367✔
56
   bits.push_back(format_version.major_version());
367✔
57
   bits.push_back(format_version.minor_version());
367✔
58
   bits.push_back(static_cast<uint8_t>(m_cookie.size()));
367✔
59
   bits += m_cookie;
367✔
60
   return bits;
367✔
61
}
×
62

63
}  // namespace Botan::TLS
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