Botan 3.11.0
Crypto and TLS for C&
tls_client_impl_12.h
Go to the documentation of this file.
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/credentials_manager.h>
13#include <botan/tls_channel.h>
14#include <botan/internal/tls_channel_impl_12.h>
15#include <memory>
16#include <vector>
17
18namespace Botan::TLS {
19
20/**
21* SSL/TLS Client 1.2 implementation
22*/
24 public:
25 /**
26 * Set up a new TLS client session
27 *
28 * @param callbacks contains a set of callback function references
29 * required by the TLS client.
30 *
31 * @param session_manager manages session state
32 *
33 * @param creds manages application/user credentials
34 *
35 * @param policy specifies other connection policy information
36 *
37 * @param rng a random number generator
38 *
39 * @param server_info is identifying information about the TLS server
40 *
41 * @param datagram specifies whether to use TLS 1.2 or DTLS 1.2
42 *
43 * @param next_protocols specifies protocols to advertise with ALPN
44 *
45 * @param reserved_io_buffer_size This many bytes of memory will
46 * be preallocated for the read and write buffers. Smaller
47 * values just mean reallocations and copies are more likely.
48 */
49 explicit Client_Impl_12(const std::shared_ptr<Callbacks>& callbacks,
50 const std::shared_ptr<Session_Manager>& session_manager,
51 const std::shared_ptr<Credentials_Manager>& creds,
52 const std::shared_ptr<const Policy>& policy,
53 const std::shared_ptr<RandomNumberGenerator>& rng,
55 bool datagram = false,
56 const std::vector<std::string>& next_protocols = {},
57 size_t reserved_io_buffer_size = TLS::Channel::IO_BUF_DEFAULT_SIZE);
58
59 explicit Client_Impl_12(const Channel_Impl::Downgrade_Information& downgrade_info);
60
61 /**
62 * @return network protocol as advertised by the TLS server, if server sent the ALPN extension
63 */
64 std::string application_protocol() const override { return m_application_protocol; }
65
66 private:
67 std::vector<X509_Certificate> get_peer_cert_chain(const Handshake_State& state) const override;
68
69 void initiate_handshake(Handshake_State& state, bool force_full_renegotiation) override;
70
71 void send_client_hello(Handshake_State& state,
72 bool force_full_renegotiation,
73 Protocol_Version version,
74 std::optional<Session_with_Handle> session_and_handle = std::nullopt,
75 const std::vector<std::string>& next_protocols = {});
76
77 void process_handshake_msg(const Handshake_State* active_state,
78 Handshake_State& pending_state,
79 Handshake_Type type,
80 const std::vector<uint8_t>& contents,
81 bool epoch0_restart) override;
82
83 std::unique_ptr<Handshake_State> new_handshake_state(std::unique_ptr<Handshake_IO> io) override;
84
85 std::shared_ptr<Credentials_Manager> m_creds;
86 const Server_Information m_info;
87 std::string m_application_protocol;
88};
89
90} // namespace Botan::TLS
91
92#endif
RandomNumberGenerator & rng()
Session_Manager & session_manager()
const Policy & policy() const
Channel_Impl_12(const std::shared_ptr< Callbacks > &callbacks, const std::shared_ptr< Session_Manager > &session_manager, const std::shared_ptr< RandomNumberGenerator > &rng, const std::shared_ptr< const Policy > &policy, bool is_server, bool is_datagram, size_t io_buf_sz=TLS::Channel::IO_BUF_DEFAULT_SIZE)
static constexpr size_t IO_BUF_DEFAULT_SIZE
Definition tls_channel.h:37
Client_Impl_12(const std::shared_ptr< Callbacks > &callbacks, const std::shared_ptr< Session_Manager > &session_manager, const std::shared_ptr< Credentials_Manager > &creds, const std::shared_ptr< const Policy > &policy, const std::shared_ptr< RandomNumberGenerator > &rng, Server_Information server_info=Server_Information(), bool datagram=false, const std::vector< std::string > &next_protocols={}, size_t reserved_io_buffer_size=TLS::Channel::IO_BUF_DEFAULT_SIZE)
std::string application_protocol() const override