Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vinilox
biboumi
Commits
395297e4
Commit
395297e4
authored
Dec 02, 2016
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the new botan 1.11.32 Tls::Client API (but stay compatible with older ones)
ref #3245
parent
27940ecd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
12 deletions
+38
-12
louloulibs/network/tcp_socket_handler.cpp
louloulibs/network/tcp_socket_handler.cpp
+12
-8
louloulibs/network/tcp_socket_handler.hpp
louloulibs/network/tcp_socket_handler.hpp
+26
-4
No files found.
louloulibs/network/tcp_socket_handler.cpp
View file @
395297e4
...
...
@@ -419,10 +419,14 @@ void TCPSocketHandler::start_tls()
{
Botan
::
TLS
::
Server_Information
server_info
(
this
->
address
,
"irc"
,
std
::
stoul
(
this
->
port
));
this
->
tls
=
std
::
make_unique
<
Botan
::
TLS
::
Client
>
(
std
::
bind
(
&
TCPSocketHandler
::
tls_output_fn
,
this
,
ph
::
_1
,
ph
::
_2
),
std
::
bind
(
&
TCPSocketHandler
::
tls_data_cb
,
this
,
ph
::
_1
,
ph
::
_2
),
std
::
bind
(
&
TCPSocketHandler
::
tls_alert_cb
,
this
,
ph
::
_1
,
ph
::
_2
,
ph
::
_3
),
std
::
bind
(
&
TCPSocketHandler
::
tls_handshake_cb
,
this
,
ph
::
_1
),
# if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,11,32)
*
this
,
# else
[
this
](
const
Botan
::
byte
*
data
,
size_t
size
)
{
this
->
tls_emit_data
(
data
,
size
);
},
[
this
](
const
Botan
::
byte
*
data
,
size_t
size
)
{
this
->
tls_record_received
(
0
,
data
,
size
);
},
[
this
](
Botan
::
TLS
::
Alert
alert
,
const
Botan
::
byte
*
,
size_t
)
{
this
->
tls_alert
(
alert
);
},
[
this
](
const
Botan
::
TLS
::
Session
&
session
)
{
return
this
->
tls_session_established
(
session
);
},
# endif
session_manager
,
this
->
credential_manager
,
policy
,
rng
,
server_info
,
Botan
::
TLS
::
Protocol_Version
::
latest_tls_version
());
}
...
...
@@ -475,7 +479,7 @@ void TCPSocketHandler::tls_send(std::string&& data)
std
::
make_move_iterator
(
data
.
end
()));
}
void
TCPSocketHandler
::
tls_
data_cb
(
const
Botan
::
byte
*
data
,
size_t
size
)
void
TCPSocketHandler
::
tls_
record_received
(
uint64_t
,
const
Botan
::
byte
*
data
,
size_t
size
)
{
this
->
in_buf
+=
std
::
string
(
reinterpret_cast
<
const
char
*>
(
data
),
size
);
...
...
@@ -483,17 +487,17 @@ void TCPSocketHandler::tls_data_cb(const Botan::byte* data, size_t size)
this
->
parse_in_buffer
(
size
);
}
void
TCPSocketHandler
::
tls_
output_fn
(
const
Botan
::
byte
*
data
,
size_t
size
)
void
TCPSocketHandler
::
tls_
emit_data
(
const
Botan
::
byte
*
data
,
size_t
size
)
{
this
->
raw_send
(
std
::
string
(
reinterpret_cast
<
const
char
*>
(
data
),
size
));
}
void
TCPSocketHandler
::
tls_alert
_cb
(
Botan
::
TLS
::
Alert
alert
,
const
Botan
::
byte
*
,
size_
t
)
void
TCPSocketHandler
::
tls_alert
(
Botan
::
TLS
::
Alert
aler
t
)
{
log_debug
(
"tls_alert: "
,
alert
.
type_string
());
}
bool
TCPSocketHandler
::
tls_
handshake_cb
(
const
Botan
::
TLS
::
Session
&
session
)
bool
TCPSocketHandler
::
tls_
session_established
(
const
Botan
::
TLS
::
Session
&
session
)
{
log_debug
(
"Handshake with "
,
session
.
server_info
().
hostname
(),
" complete."
,
" Version: "
,
session
.
version
().
to_string
(),
...
...
louloulibs/network/tcp_socket_handler.hpp
View file @
395297e4
...
...
@@ -19,6 +19,25 @@
#include <string>
#include <list>
#ifdef BOTAN_FOUND
class
BiboumiTLSPolicy
:
public
Botan
::
TLS
::
Policy
{
public:
# if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,11,33)
bool
use_ecc_point_compression
()
const
override
{
return
true
;
}
# endif
};
# if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,11,32)
# define BOTAN_TLS_CALLBACKS_OVERRIDE override final
# else
# define BOTAN_TLS_CALLBACKS_OVERRIDE
# endif
#endif
/**
* An interface, with a series of callbacks that should be implemented in
* subclasses that deal with a socket. These callbacks are called on various events
...
...
@@ -26,6 +45,9 @@
* (select/poll/epoll etc)
*/
class
TCPSocketHandler
:
public
SocketHandler
#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,11,32)
,
public
Botan
::
TLS
::
Callbacks
#endif
{
protected:
~
TCPSocketHandler
();
...
...
@@ -158,22 +180,22 @@ private:
* Called by the tls object that some data has been decrypt. We call
* parse_in_buffer() to handle that unencrypted data.
*/
void
tls_
data_cb
(
const
Botan
::
byte
*
data
,
size_t
size
)
;
void
tls_
record_received
(
uint64_t
rec_no
,
const
Botan
::
byte
*
data
,
size_t
size
)
BOTAN_TLS_CALLBACKS_OVERRIDE
;
/**
* Called by the tls object to indicate that some data has been encrypted
* and is now ready to be sent on the socket as is.
*/
void
tls_
output_fn
(
const
Botan
::
byte
*
data
,
size_t
size
)
;
void
tls_
emit_data
(
const
Botan
::
byte
*
data
,
size_t
size
)
BOTAN_TLS_CALLBACKS_OVERRIDE
;
/**
* Called by the tls object to indicate that a TLS alert has been
* received. We don’t use it, we just log some message, at the moment.
*/
void
tls_alert
_cb
(
Botan
::
TLS
::
Alert
alert
,
const
Botan
::
byte
*
,
size_t
)
;
void
tls_alert
(
Botan
::
TLS
::
Alert
alert
)
BOTAN_TLS_CALLBACKS_OVERRIDE
;
/**
* Called by the tls object at the end of the TLS handshake. We don't do
* anything here appart from logging the TLS session information.
*/
bool
tls_
handshake_cb
(
const
Botan
::
TLS
::
Session
&
session
)
;
bool
tls_
session_established
(
const
Botan
::
TLS
::
Session
&
session
)
BOTAN_TLS_CALLBACKS_OVERRIDE
;
/**
* Called whenever the tls session goes from inactive to active. This
* means that the handshake has just been successfully done, and we can
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment