[Boost-users] [asio] AES encryption/decryption

589 views
Skip to first unread message

Igor R

unread,
Aug 2, 2009, 2:59:02 PM8/2/09
to boost...@lists.boost.org
Hello all,

Does someone have an experience with the subj?
In my application I need an AES-encrypted socket. I try to accomplish
this by building a custom asio socket that performs all the needed
encryption (with openssl) and delegates the i/o to its service.
However, I encountered an issue that seems to be unsolvable with the
current approach: from one hand, every read opeartion has to return
the number of *decrypted* bytes, but from the other hand,
bytes_readable command returns the size of the available *encrypted*
data. Sometimes this causes severe problems:


void connection::read()
{
asio::socket_base::bytes_readable command(true);
socket_.lowest_layer().io_control(command);
size_t canRead = command.get();
if (canRead)
// this line creates completion condition that might never be met,
because read_some() would return less than canRead
asio::read(socket_, input_, asio::transfer_at_least(canRead), err);
}


I'd appreciate any idea - probably I'm going the wrong way, and
there's some more appropriate design that would give better results?

Thanks.
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Adrien Panay

unread,
Aug 3, 2009, 5:26:19 AM8/3/09
to boost...@lists.boost.org
Hello,

> Does someone have an experience with the subj?
> In my application I need an AES-encrypted socket. I try to accomplish
> this by building a custom asio socket that performs all the needed
> encryption (with openssl) and delegates the i/o to its service.

I never built an encrypted socket, but here is an example describing
this kind of situation :
http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/example/ssl/client.cpp
http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/example/ssl/server.cpp
It refers to an asio ssl::stream
http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/reference/ssl__stream.html
Did you use this documentation to write your connection class ?

Adrien

Reply all
Reply to author
Forward
0 new messages