[asio] AES encryption/decryption
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.
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.... http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/example/ssl/server.... It refers to an asio ssl::stream http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/reference/ssl__stre... Did you use this documentation to write your connection class ? Adrien
participants (2)
-
Adrien Panay
-
Igor R