aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/tls/tls_channel.h
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-08-12 12:36:36 -0400
committerJack Lloyd <[email protected]>2016-08-16 15:46:10 -0400
commita22a54fd962f4aafa7ea3d6a888d8d4ab779f1ba (patch)
tree4a0f2088b6bb7a14d54cdfffe6d7a1cc12b6095c /src/lib/tls/tls_channel.h
parent589000efb270f8226745b7f32f52c42f4a0f0bdf (diff)
Changes to TLS::Callbacks for GH PR #457
Make TLS::Channel::m_callbacks a reference, so deriving from TLS::Callbacks works Split out the compat (std::function) based interface to Compat_Callbacks. This avoids the overhead of empty std::functions when using the virtual interface, and ensures the virtual interface works since there is no callback path that does not involve a vtable lookup. Rename the TLS::Callback functions. Since the idea is that often an owning class will pass *this as the callbacks argument, it is good to namespace the virtual functions so as not to conflict with other names chosen by the class. Specifically, prefixes all cb functions with tls_ Revert changes to use the old style alert callback (with no longer used data/len params) so no API changes are required for old code. The new Callbacks interface continues to just receive the alert code itself. Switch to virtual function interface in CLI tls_client for testing. Inline tls_server_handshake_state.h - only used in tls_server.cpp Fix tests - test looked like it was creating a new client object but it was not actually being used. And when enabled, it failed because the queues were not being emptied in between. So, fix that.
Diffstat (limited to 'src/lib/tls/tls_channel.h')
-rw-r--r--src/lib/tls/tls_channel.h23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/lib/tls/tls_channel.h b/src/lib/tls/tls_channel.h
index 7c59e1d6f..073af760f 100644
--- a/src/lib/tls/tls_channel.h
+++ b/src/lib/tls/tls_channel.h
@@ -36,12 +36,12 @@ class BOTAN_DLL Channel
public:
typedef std::function<void (const byte[], size_t)> output_fn;
typedef std::function<void (const byte[], size_t)> data_cb;
- typedef std::function<void (Alert)> alert_cb;
+ typedef std::function<void (Alert, const byte[], size_t)> alert_cb;
typedef std::function<bool (const Session&)> handshake_cb;
typedef std::function<void (const Handshake_Message&)> handshake_msg_cb;
static size_t IO_BUF_DEFAULT_SIZE;
- Channel(const Callbacks& callbacks,
+ Channel(Callbacks& callbacks,
Session_Manager& session_manager,
RandomNumberGenerator& rng,
const Policy& policy,
@@ -215,9 +215,9 @@ class BOTAN_DLL Channel
const Policy& policy() const { return m_policy; }
- bool save_session(const Session& session) const { return m_callbacks.handshake(session); }
+ bool save_session(const Session& session) const { return callbacks().tls_session_established(session); }
- Callbacks get_callbacks() const { return m_callbacks; }
+ Callbacks& callbacks() const { return m_callbacks; }
private:
void init(size_t io_buf_sze);
@@ -245,19 +245,20 @@ class BOTAN_DLL Channel
const Handshake_State* pending_state() const { return m_pending_state.get(); }
/* methods to handle incoming traffic through Channel::receive_data. */
- void process_handshake_ccs(secure_vector<byte>& record,
- u64bit& record_sequence,
- Record_Type& record_type,
- Protocol_Version& record_version);
+ void process_handshake_ccs(const secure_vector<byte>& record,
+ u64bit record_sequence,
+ Record_Type record_type,
+ Protocol_Version record_version);
- void process_application_data(secure_vector<byte>& record);
+ void process_application_data(u64bit req_no, const secure_vector<byte>& record);
- void process_alert(secure_vector<byte>& record);
+ void process_alert(const secure_vector<byte>& record);
bool m_is_datagram;
/* callbacks */
- Callbacks m_callbacks;
+ std::unique_ptr<Compat_Callbacks> m_compat_callbacks;
+ Callbacks& m_callbacks;
/* external state */
Session_Manager& m_session_manager;