Boost logo

Boost Users :

From: eg (egoots_at_[hidden])
Date: 2006-12-05 12:07:03


Hi all,

I've written a multichar_dual_use_filter for to handle a custom file
encryption.

Ideally, the encrypted file format consists of 3 distinct types of data:
1) initialization vector IV (only used by encry/decryp)
2) Main file data
3) Checksum (only used to validate file decryp is correct)

The output filter can easily write the above 3 items.

I have the input filter reading in and handling items 1 and 2 above...

But I need some advice on how to strip off the checksum (or any fixed
size chunk of data) at the end of the file to validate but not pass this
  into the output buffer.

I have thought of passing in the input file size to the filters
constructor and keep track of how many bytes are being processed... then
handling the final bytes separately. Does this sound like a feasible
approach? It makes using the filter harder as it imposes unusual
constraints on calling it.

Any other ideas?

My current filters Read function is of the following form:

template<typename Source>
std::streamsize read(Source& src, char* s, std::streamsize n)
{
   if (!bInit) {
     // Handle reading IV bytes and initialization
   }

   // Read in buffer to "s" and then decrypt it
   count = boost::iostreams::read(src, s, n);
   if (count <= 0)
     return -1; //EOF or Error

   // Decrypt s in place
   DecryptBuf(s, count);
   return count;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net