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