/src/botan/build/include/botan/internal/tls_client_impl_12.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * TLS Client - implementation for TLS 1.2 |
3 | | * (C) 2004-2011 Jack Lloyd |
4 | | * 2016 Matthias Gierlings |
5 | | * |
6 | | * Botan is released under the Simplified BSD License (see license.txt) |
7 | | */ |
8 | | |
9 | | #ifndef BOTAN_TLS_CLIENT_IMPL_12_H_ |
10 | | #define BOTAN_TLS_CLIENT_IMPL_12_H_ |
11 | | |
12 | | #include <botan/tls_channel.h> |
13 | | #include <botan/tls_policy.h> |
14 | | #include <botan/credentials_manager.h> |
15 | | #include <botan/internal/tls_channel_impl_12.h> |
16 | | #include <vector> |
17 | | #include <memory> |
18 | | |
19 | | namespace Botan { |
20 | | |
21 | | namespace TLS { |
22 | | |
23 | | /** |
24 | | * SSL/TLS Client 1.2 implementation |
25 | | */ |
26 | | class Client_Impl_12 : public Channel_Impl_12 |
27 | | { |
28 | | public: |
29 | | |
30 | | /** |
31 | | * Set up a new TLS client session |
32 | | * |
33 | | * @param callbacks contains a set of callback function references |
34 | | * required by the TLS client. |
35 | | * |
36 | | * @param session_manager manages session state |
37 | | * |
38 | | * @param creds manages application/user credentials |
39 | | * |
40 | | * @param policy specifies other connection policy information |
41 | | * |
42 | | * @param rng a random number generator |
43 | | * |
44 | | * @param server_info is identifying information about the TLS server |
45 | | * |
46 | | * @param datagram specifies whether to use TLS 1.2 or DTLS 1.2 |
47 | | * |
48 | | * @param next_protocols specifies protocols to advertise with ALPN |
49 | | * |
50 | | * @param reserved_io_buffer_size This many bytes of memory will |
51 | | * be preallocated for the read and write buffers. Smaller |
52 | | * values just mean reallocations and copies are more likely. |
53 | | */ |
54 | | explicit Client_Impl_12(Callbacks& callbacks, |
55 | | Session_Manager& session_manager, |
56 | | Credentials_Manager& creds, |
57 | | const Policy& policy, |
58 | | RandomNumberGenerator& rng, |
59 | | const Server_Information& server_info = Server_Information(), |
60 | | bool datagram = false, |
61 | | const std::vector<std::string>& next_protocols = {}, |
62 | | size_t reserved_io_buffer_size = TLS::Channel::IO_BUF_DEFAULT_SIZE |
63 | | ); |
64 | | |
65 | | explicit Client_Impl_12(const Channel_Impl::Downgrade_Information& downgrade_info); |
66 | | |
67 | | /** |
68 | | * @return network protocol as advertised by the TLS server, if server sent the ALPN extension |
69 | | */ |
70 | 0 | std::string application_protocol() const override { return m_application_protocol; } |
71 | | private: |
72 | | std::vector<X509_Certificate> |
73 | | get_peer_cert_chain(const Handshake_State& state) const override; |
74 | | |
75 | | void initiate_handshake(Handshake_State& state, |
76 | | bool force_full_renegotiation) override; |
77 | | |
78 | | void send_client_hello(Handshake_State& state, |
79 | | bool force_full_renegotiation, |
80 | | Protocol_Version version, |
81 | | std::optional<Session> session = std::nullopt, |
82 | | const std::vector<std::string>& next_protocols = {}); |
83 | | |
84 | | void process_handshake_msg(const Handshake_State* active_state, |
85 | | Handshake_State& pending_state, |
86 | | Handshake_Type type, |
87 | | const std::vector<uint8_t>& contents, |
88 | | bool epoch0_restart) override; |
89 | | |
90 | | std::unique_ptr<Handshake_State> new_handshake_state(std::unique_ptr<Handshake_IO> io) override; |
91 | | |
92 | | Credentials_Manager& m_creds; |
93 | | const Server_Information m_info; |
94 | | std::string m_application_protocol; |
95 | | }; |
96 | | |
97 | | } |
98 | | |
99 | | } |
100 | | |
101 | | #endif |