Using one Source Filter to feed two attachments

View: New views
2 Messages — Rating Filter:   Alert me  

Using one Source Filter to feed two attachments

by Rafael Vargas-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello All,

I'm using FileSource to make a signature of a file.  But I need to
read the file twice, since is a small file, thats OK, but what if was
a bigger file? Is there a way to use the filter to feed two (or maybe
possibly more) attachments? If there is such a way I can feed both the
SignerFilter and the FileSink simultaneously.

Here is my code (that is based on the examples located on the wiki):

    FileSource privFile( PrivateKeyFile.c_str(), true, new
Base64Decoder );

    RSASSA_PKCS1v15_SHA_Signer Signer( privFile );

    string signature;

    FileSource inFile( inFileName.c_str(), true,
        new SignerFilter( GlobalRNG(), Signer,
            new StringSink( signature )
        )
    );

    FileSink fsink( "signed.txt" );
    FileSource inFile2( inFileName.c_str(), true, new Redirector
(fsink ) );
    string endoffile = "\n\x1b\n"; //newline,ESC,newline. Just to
separate the signature from the file
    fsink.Put( (const byte*)endoffile.c_str(), endoffile.size(),
true );
    StringSource inSign( signature.c_str(), true, new Redirector
(fsink) );

Thanks in advance,
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---


Re: Using one Source Filter to feed two attachments

by Geoff Beier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Look at ChannelSwitch.

http://cryptopp.pastebin.com/f105b26b1

On Wed, Sep 9, 2009 at 08:36, Rafael Vargas<vargas.khomp@...> wrote:

>
> Hello All,
>
> I'm using FileSource to make a signature of a file.  But I need to
> read the file twice, since is a small file, thats OK, but what if was
> a bigger file? Is there a way to use the filter to feed two (or maybe
> possibly more) attachments? If there is such a way I can feed both the
> SignerFilter and the FileSink simultaneously.
>
> Here is my code (that is based on the examples located on the wiki):
>
>    FileSource privFile( PrivateKeyFile.c_str(), true, new
> Base64Decoder );
>
>    RSASSA_PKCS1v15_SHA_Signer Signer( privFile );
>
>    string signature;
>
>    FileSource inFile( inFileName.c_str(), true,
>        new SignerFilter( GlobalRNG(), Signer,
>            new StringSink( signature )
>        )
>    );
>
>    FileSink fsink( "signed.txt" );
>    FileSource inFile2( inFileName.c_str(), true, new Redirector
> (fsink ) );
>    string endoffile = "\n\x1b\n"; //newline,ESC,newline. Just to
> separate the signature from the file
>    fsink.Put( (const byte*)endoffile.c_str(), endoffile.size(),
> true );
>    StringSource inSign( signature.c_str(), true, new Redirector
> (fsink) );
>
> Thanks in advance,
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---