[Botan-devel] clearing pipe messages

Jack Lloyd lloyd at randombit.net
Wed Dec 14 17:26:12 EST 2005


Oh, I should add that if you pass Pipe::LAST_MESSAGE as the message number to
any of the read()/peek() variants, it will keep track of the message number for
you. A minor convenience, but it's a little easier to read.

On Wed, Dec 14, 2005 at 04:22:43PM +0500, Muzaffar Mahkamov wrote:
> Hi Jack,
> 
> I think I've found the problem. read() operation increments the
> message number and the next time i was attempting to read the default
> message (which is empty) and the new message remained in the pipe. If
> I increment the message number and pass it to read() operation
> everything works fine. On the other hand, message number may reach
> Botan::Pipe::MAX_MESSAGES in my case. Is there a function to reset the
> message number or how could I do that without side effects by tweaking
> the Botan code? 
> 
> Muzaffar
> 
> 
> Wednesday, December 14, 2005, 2:20:31 AM, you wrote:
> 
> > Hi Muzaffar,
> 
> > Reading the previous message out removes it from memory (reading is
> > destructive; Pipe doesn't keep a copy), so this shouldn't be a problem. There
> > is still a small overhead, the empty SecureQueue* object, but that should be on
> > the order of three pointers per message.
> 
> > My first inclination would be that the right way to go about dealing with this
> > overhead, if it's actually a problem, is to delete/NULL out empty SecureQueue
> > objects stored in this->messages and then (re-)initialize them lazily. This
> > would be a lot cleaner, and would not require any explicit actions on the part
> > of the user.
> 
> > Are you seeing substantially more overhead in your application than the above
> > would suggest? If so, could you please post a testcase for me to poke at?
> 
> > Thanks,
> >   Jack
> 
> > On Tue, Dec 13, 2005 at 03:50:22PM +0500, Muzaffar Mahkamov wrote:
> >> Hi,
> >> 
> >> Is it possible to clear all the messages of Pipe and reuse it several
> >> times? I need to encrypt/decrypt large amounts of data in small chunks
> >> and constructing Pipe with calling get_cipher with lookups each time
> >> is a pretty expensive operation.
> >> 
> >> set_default_msg() is inacceptable for this case since it does not
> >> remove the previous messages and doesn't free the memory.
> >> 
> >> I want to modify the Pipe class by adding the following function:
> >> 
> >> void Pipe::clear_messages()
> >>    {
> >>    if(locked)
> >>       throw Invalid_State("Pipe cannot be modified while it is locked");
> >> 
> >>    for(u32bit j = 0; j != messages.size(); j++)
> >>       delete messages[j];
> >>    }
> >> 
> >>    locked = false;
> >>    }
> >> 
> >> Would it be sufficient for reusing the pipe or there are some internal
> >> states/flags that also must be cleared?
> >> 
> >> Thanks in advance,
> >> Muzaffar
> >> 
> >> _______________________________________________
> >> botan-devel mailing list
> >> botan-devel at randombit.net
> >> http://www.randombit.net/mailman/listinfo/botan-devel
> > _______________________________________________
> > botan-devel mailing list
> > botan-devel at randombit.net
> > http://www.randombit.net/mailman/listinfo/botan-devel
> 
> 
> -- 
> Best regards,
>  Muzaffar                            mailto:mahkamov at gmail.com
> 
> _______________________________________________
> botan-devel mailing list
> botan-devel at randombit.net
> http://www.randombit.net/mailman/listinfo/botan-devel



More information about the botan-devel mailing list