Hi All, First off, I'm very new to CryptoPP and am just getting acquainted with it, so please bear with me. I would like to decrypt a file and before the FileSink, hash the stream. I would like to split the sinks up, so I have the original file in a FileSink and the hash in an ArraySink. It seems channels are of help here, notably:
HashFilter(HashTransformation &hm, BufferedTransformation *attachment = NULL, bool putMessage=false, int truncatedDigestSize=-1, const std::string &messagePutChannel=DEFAULT_CHANNEL, const std::string &hashPutChannel=DEFAULT_CHANNEL); seems to suggest that setting const std::string &hashPutChannel to something suitable (in the correct way and with the required support objects properly created) should make this possible. I apparently don't understand how to handle channels and AddRoute, as this code I have crashes, with exception "unknown: this object doesn't support multiple channels". I've got the following code-segment: ... // Hashing the stream SHA1 hash_function; bytes digest ( hash_function.DigestSize ( ) ); auto_ptr<ArraySink> digest_sink ( new ArraySink ( digest.data ( ), digest.size ( ) ) ); // Decrypting the stream MeterFilter* metered_out = new MeterFilter ( new FileSink ( *ofs.get ( ) ) ); auto_ptr<MeterFilter> metered_in ( new MeterFilter ( new StreamTransformationFilter ( Decryptor, new ZlibDecompressor ( new HashFilter ( hash_function, metered_out, true, -1, DEFAULT_CHANNEL, "HASH_SINK" ) ) ) ) ); // Channels auto_ptr<ChannelSwitch> channels ( new ChannelSwitch ); channels->AddDefaultRoute ( *metered_in ); channels->AddRoute ( "HASH_SINK", *digest_sink, Filter::NULL_CHANNEL ); // Doing it! FileSource source ( *ifs.get ( ), true, channels.release ( ) ); ... This code crashes, with exception "unknown: this object doesn't support multiple channels". I guess because the channels->AddRoute ( "HASH_SINK", *digest_sink, Filter::NULL_CHANNEL ); is wrong. When I use the HashFilter default values, i.e. with DEFAULT_CHANNEL in the last argument of HashFilter, the code works as expected, either outputting the hash or the file-contents followed by the hash, depending on on false/true in argument 3. Could someone please point me in the right direction of how to achieve the objective? What am I missing? Thanks in advance, Cheers, degski -- 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.
