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

randombit / botan / 21755637170

06 Feb 2026 03:17PM UTC coverage: 90.077% (+0.004%) from 90.073%
21755637170

Pull #5291

github

web-flow
Merge 649b01982 into 8ea0ca252
Pull Request #5291: Refactor: Extract TLS 1.2 specific Certificate_Status constructor

102238 of 113501 relevant lines covered (90.08%)

11475082.3 hits per line

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

87.5
/src/lib/tls/msg_cert_status.cpp
1
/*
2
* Certificate Status
3
* (C) 2016 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/internal/loadstor.h>
11

12
namespace Botan::TLS {
13

14
Certificate_Status::Certificate_Status(const std::vector<uint8_t>& buf, const Connection_Side /*side*/) {
102✔
15
   if(buf.size() < 5) {
102✔
16
      throw Decoding_Error("Invalid Certificate_Status message: too small");
3✔
17
   }
18

19
   if(buf[0] != 1) {  // not OCSP
99✔
20
      throw Decoding_Error("Unexpected Certificate_Status message: unexpected response type");
×
21
   }
22

23
   const size_t len = make_uint32(0, buf[1], buf[2], buf[3]);
99✔
24

25
   // Verify the redundant length field...
26
   if(buf.size() != len + 4) {
99✔
27
      throw Decoding_Error("Invalid Certificate_Status: invalid length field");
4✔
28
   }
29

30
   m_response.assign(buf.begin() + 4, buf.end());
95✔
31
}
102✔
32

33
Certificate_Status::Certificate_Status(std::vector<uint8_t> raw_response_bytes) :
48✔
34
      m_response(std::move(raw_response_bytes)) {}
48✔
35

36
std::vector<uint8_t> Certificate_Status::serialize() const {
48✔
37
   if(m_response.size() > 0xFFFFFF) {  // unlikely
48✔
38
      throw Encoding_Error("OCSP response too long to encode in TLS");
×
39
   }
40

41
   const uint32_t response_len = static_cast<uint32_t>(m_response.size());
48✔
42

43
   std::vector<uint8_t> buf;
48✔
44
   buf.reserve(1 + 3 + m_response.size());
48✔
45
   buf.push_back(1);  // type OCSP
48✔
46
   for(size_t i = 1; i < 4; ++i) {
192✔
47
      buf.push_back(get_byte_var(i, response_len));
144✔
48
   }
49

50
   buf += m_response;
48✔
51
   return buf;
48✔
52
}
×
53

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

© 2026 Coveralls, Inc