/src/botan/src/lib/tls/tls_extensions_cert_status_req.cpp
Line | Count | Source |
1 | | /* |
2 | | * TLS Extension Certificate_Status_Request |
3 | | * (C) 2011,2012,2015,2016,2022 Jack Lloyd |
4 | | * 2016 Juraj Somorovsky |
5 | | * 2021 Elektrobit Automotive GmbH |
6 | | * 2022 Hannes Rantzsch, René Meusel, neXenio GmbH |
7 | | * |
8 | | * Botan is released under the Simplified BSD License (see license.txt) |
9 | | */ |
10 | | |
11 | | #include <botan/tls_extensions.h> |
12 | | #include <botan/tls_messages.h> |
13 | | #include <botan/internal/tls_reader.h> |
14 | | #include <botan/tls_exceptn.h> |
15 | | |
16 | | namespace Botan::TLS |
17 | | { |
18 | | |
19 | | std::vector<uint8_t> Certificate_Status_Request::serialize(Connection_Side whoami) const |
20 | 3.45k | { |
21 | 3.45k | std::vector<uint8_t> buf; |
22 | | |
23 | 3.45k | if(whoami == Connection_Side::SERVER) |
24 | 2.02k | return buf; // server reply is empty |
25 | | |
26 | | /* |
27 | | opaque ResponderID<1..2^16-1>; |
28 | | opaque Extensions<0..2^16-1>; |
29 | | |
30 | | CertificateStatusType status_type = ocsp(1) |
31 | | ResponderID responder_id_list<0..2^16-1> |
32 | | Extensions request_extensions; |
33 | | */ |
34 | | |
35 | 1.42k | buf.push_back(1); // CertificateStatusType ocsp |
36 | | |
37 | 1.42k | buf.push_back(0); |
38 | 1.42k | buf.push_back(0); |
39 | 1.42k | buf.push_back(0); |
40 | 1.42k | buf.push_back(0); |
41 | | |
42 | 1.42k | return buf; |
43 | 3.45k | } |
44 | | |
45 | | Certificate_Status_Request::Certificate_Status_Request(TLS_Data_Reader& reader, |
46 | | uint16_t extension_size, |
47 | | Connection_Side from, |
48 | | Handshake_Type) |
49 | 2.20k | { |
50 | 2.20k | if(from == Connection_Side::SERVER) |
51 | 40 | { |
52 | 40 | if(extension_size != 0) |
53 | 15 | throw Decoding_Error("Server sent non-empty Certificate_Status_Request extension in Server Hello"); |
54 | 40 | } |
55 | 2.16k | else if(extension_size > 0) |
56 | 1.09k | { |
57 | 1.09k | const uint8_t type = reader.get_byte(); |
58 | 1.09k | if(type == 1) |
59 | 41 | { |
60 | 41 | const size_t len_resp_id_list = reader.get_uint16_t(); |
61 | 41 | m_ocsp_names = reader.get_fixed<uint8_t>(len_resp_id_list); |
62 | 41 | const size_t len_requ_ext = reader.get_uint16_t(); |
63 | 41 | m_extension_bytes = reader.get_fixed<uint8_t>(len_requ_ext); |
64 | 41 | } |
65 | 1.05k | else |
66 | 1.05k | { |
67 | 1.05k | reader.discard_next(extension_size - 1); |
68 | 1.05k | } |
69 | 1.09k | } |
70 | 2.20k | } |
71 | | |
72 | | Certificate_Status_Request::Certificate_Status_Request(const std::vector<uint8_t>& ocsp_responder_ids, |
73 | | const std::vector<std::vector<uint8_t>>& ocsp_key_ids) : |
74 | | m_ocsp_names(ocsp_responder_ids), |
75 | | m_ocsp_keys(ocsp_key_ids) |
76 | 1.42k | { |
77 | 1.42k | } |
78 | | |
79 | | } |