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