Hi All/Wei,

I built a few prototypes trying to work out a design. Here's what I
found.

1) A Source can be modified so that it presents data on a channel
other than DEFAULT_CHANNEL. In my case, I simply built a ChannelSource
(...) modeled after StringSource:

ChannelSource(const char *string, ..., const std::string& channel="")
        : SourceTemplate<StringStore>(attachment)
{
    SourceInitialize(pumpAll, MakeParameters("InputBuffer",
        ConstByteArrayParameter(string)));
    TransferAllTo2( *AttachedTransformation(), channel );
};

2) Filters are problematic. A filter assumes that data is meant for
the default channel, unless PutChannel(...) or other non-default
channel methods are called. What we need is a filter with 'forwarding'
behavior where appropriate. That is, if a filter's PutChannel is
called and the filter does not have the channel, it should perform its
transformation and on the data in the specified channel. Two examples
would be a HexEncoder and Redirector - transform the data (as
required) and pass the data down.

3) Some filters, such as AuthenticatedDecryptionFilter, should not be
a forwarder. If a channel does not exist, a non-forwarding filter
should return the appropriate error.

Wei: Is this correct or did I miss something in the big picture?

Jeff

On Mar 12, 8:57 pm, Jeffrey Walton <[email protected]> wrote:
> Hi All/Wei,
>
> What I want to achieve is similar to below. StringSource does not have
> it, and neither does Redirector. Both would be good candidates, but I
> think Redirector would probably trump due to its behavior. Or should I
> look at rolling ChannelSource(...)?
>
> Using a ChannelSwitch is like using a Filter's PutChannel - it's not
> quite as elegant as Crypto++.
>
> Jeff
>
> AuthenticatedDecryptionFilter df( d, ... );
>
> ArraySource( (const byte*)adata.data(),
>     adata.size(), true,
>     new Redirector( df ),
>     "AAD"
> ); // ArraySource
>
> ArraySource( (const byte*)enc.data(),
>     enc.size(), true,
>     new Redirector( df ),
>     DEFAULT_CHANNEL
> ); // ArraySource
>
> ArraySource( (const byte*)tag.data(),
>     tag.size(), true,
>     new Redirector( df ),
>     "MAC"
> ); // ArraySource
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

Reply via email to