[Botan-devel] Network I/O

Jack Lloyd lloyd at randombit.net
Sat May 26 22:01:32 EDT 2007

On Sat, May 26, 2007 at 05:10:57PM -0700, Barath Raghavan wrote:

> 1. It treats the input stream as a single contiguous message, but the
> input stream of data really might be a bunch of messages (in the sense
> of multiple start_msg()/end_msg() calls that were made at the remote
> host).
> 2. It blocks to read all data until EOF, which won't happen until the
> socket is closed.
> I'd like use the << operator on the pipe to read messages and have
> that pull data from the input stream (which happens to be a socket in
> this context).  Or, similarly, make calls that feed data into the
> pipe, but have that call terminate as soon as one message's worth of
> data (as readable from the other end of the pipe) has been read from
> the input stream.
> Any thoughts on how I can achieve this?

Hi Barath,

You don't state how you are framing the messages. EAX itself does
nothing with that, so you need to combine the messages coming out of
the encrypting pipe in such a way that they can be broken up later.

A few ideas come to mind. You could write an explicit loop, as in:

   a_buffer = socket.read();

You could also put this into a new DataSource subclass. This will only
work if message boundaries are visible in the ciphertext. It would
detect where the end of data marker is and then set end_of_data to
return true (so process_msg returns). Then you can write something

DataSource_Mine in(stream);
while(!in.eof_on_socket()) {
   SecureVector<byte> this_msg = pipe.read_all(Pipe::LAST_MESSAGE);

[with in.next_message() moving the read pointer forward to the next
message in the stream]

Hope this helps,

More information about the botan-devel mailing list