• 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

78.79
/src/lib/tls/tls12/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/ber_dec.h>
11
#include <botan/der_enc.h>
12
#include <botan/ocsp.h>
13
#include <botan/tls_extensions.h>
14
#include <botan/internal/tls_handshake_hash.h>
15
#include <botan/internal/tls_handshake_io.h>
16
#include <botan/internal/tls_reader.h>
17

18
namespace Botan::TLS {
19

20
Certificate_Status::Certificate_Status(const std::vector<uint8_t>& buf, const Connection_Side) {
83✔
21
   if(buf.size() < 5)
83✔
22
      throw Decoding_Error("Invalid Certificate_Status message: too small");
3✔
23

24
   if(buf[0] != 1)  // not OCSP
80✔
25
      throw Decoding_Error("Unexpected Certificate_Status message: unexpected response type");
×
26

27
   size_t len = make_uint32(0, buf[1], buf[2], buf[3]);
80✔
28

29
   // Verify the redundant length field...
30
   if(buf.size() != len + 4)
80✔
31
      throw Decoding_Error("Invalid Certificate_Status: invalid length field");
3✔
32

33
   m_response.assign(buf.begin() + 4, buf.end());
77✔
34
}
83✔
35

36
Certificate_Status::Certificate_Status(Handshake_IO& io, Handshake_Hash& hash, const OCSP::Response& ocsp) :
×
37
      m_response(ocsp.raw_bits()) {
×
38
   hash.update(io.send(*this));
×
39
}
×
40

41
Certificate_Status::Certificate_Status(Handshake_IO& io,
32✔
42
                                       Handshake_Hash& hash,
43
                                       std::vector<uint8_t> raw_response_bytes) :
32✔
44
      Certificate_Status(std::move(raw_response_bytes)) {
32✔
45
   hash.update(io.send(*this));
64✔
46
}
32✔
47

48
Certificate_Status::Certificate_Status(std::vector<uint8_t> raw_response_bytes) :
48✔
49
      m_response(std::move(raw_response_bytes)) {}
48✔
50

51
std::vector<uint8_t> Certificate_Status::serialize() const {
48✔
52
   if(m_response.size() > 0xFFFFFF)  // unlikely
48✔
53
      throw Encoding_Error("OCSP response too long to encode in TLS");
×
54

55
   const uint32_t response_len = static_cast<uint32_t>(m_response.size());
48✔
56

57
   std::vector<uint8_t> buf;
48✔
58
   buf.reserve(1 + 3 + m_response.size());
48✔
59
   buf.push_back(1);  // type OCSP
48✔
60
   for(size_t i = 1; i < 4; ++i)
192✔
61
      buf.push_back(get_byte_var(i, response_len));
144✔
62

63
   buf += m_response;
48✔
64
   return buf;
48✔
65
}
×
66

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