BufferedTransormation and CreatePutSpace

48 views
Skip to first unread message

Jeffrey Walton

unread,
Mar 11, 2009, 1:04:19 AM3/11/09
to Crypto++ Users
Hi All/Wei,

I have a filter which is last in the chain _before_ the sink. The
filter needs a single buffer to perform some work on the message. The
buffer will then be an argument to Put().

// cryptlib.h
virtual byte * CreatePutSpace(size_t &size) {size=0; return NULL;}

Any ideas on what I should be using?

Jeff

Jeffrey Walton

unread,
Mar 11, 2009, 3:29:41 AM3/11/09
to Crypto++ Users
Hi All,

> Any ideas on what I should be using?
Cancel. I punted and used a SecByteBlock in the object (neither
CreatePutSpace or CreateChannelPutSpace appears to be implemented).
SecByteBlock also seemed more appropriate since it scrubs memory on
destruction.

If anyone is interested in reading about Crypto++ filters, see
http://www.cryptopp.com/wiki/Filter and http://www.cryptopp.com/wiki/Filter_(Intermediate).

There are a few samples of custom filters: "UselessFilter can be
enhanced to provide bufferless uselessness by deriving from ..."

Wei: any corrections or omissions would be appreciated.

Jeff

Wei Dai

unread,
Mar 11, 2009, 4:21:07 AM3/11/09
to Jeffrey Walton, Crypto++ Users
Jeffrey Walton wrote:
>> Any ideas on what I should be using?
> Cancel. I punted and used a SecByteBlock in the object (neither
> CreatePutSpace or CreateChannelPutSpace appears to be implemented).
> SecByteBlock also seemed more appropriate since it scrubs memory on
> destruction.

CreatePutSpace() is implemented by Filters that happen to have an existing
allocated buffer that can be reused. The caller has to be prepared for the
possibility that it will return NULL and fall back to using its own
SecByteBlock in that case. There's a helper class FilterPutSpaceHelper that
does this for you. Or you can not worry about saving the memory allocations
and copies and just use a SecByteBlock directly, like you've done.

> Wei: any corrections or omissions would be appreciated.

In IsolatedFlush(), you're not supposed to call IsolatedFlush() on the
AttachedTransformation(). This will be done by Filter's implementation of
Flush().

You should probably warn the Wiki reader that the interfaces used to
implement a Filter may not be as stable as the interfaces that are meant to
be used by applications. The basic Put() and Get() for example are backwards
compatible to early versions of Crypto++, while Put2() and IsolatedFlush()
were introduced in version 5.0, I think.

Jeffrey Walton

unread,
Mar 11, 2009, 5:04:19 AM3/11/09
to Wei Dai, Crypto++ Users
Hi Wei,

Thanks. The topics have been revised.

Jeff

Reply all
Reply to author
Forward
0 new messages