Stephen,

That's where it gets more tricky.  I have always used the
DefaultEncryptorWithMAC for most of my encryption needs, and it is already
setup to just plop it in the same way I did with Gzip and Base64Encoder. So
most of your questions are over my head.  The class DefaultEncryptorWithMAC
uses DES-EDE2 and HMAC/SHA-1 to do its thing, but it uses Password-Based
encryption, instead of real keys, so I am not exactly sure how that would
affect things.

However, if you just copy the code for DefaultEncryptorWithMAC, and change
its algorithm from DESede to AES, and pass in a real key and IV instead of a
passphrase, you should be able to put something together.

I do sympathize with what you are going thru - everytime I try to do
anything other then what has already been coded in test.cpp by Wei, I end up
killing myself for days to figure it out.

Scott Barnhart

-----Original Message-----
From: Stephen torri [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 18, 2003 5:33 PM
To: [EMAIL PROTECTED]
Cc: cryptopp
Subject: RE: Gzip & Gunzip code: Correct or rubbish

On Tue, 2003-11-18 at 19:14, Scott Barnhart wrote:
> Stephen,
> 
> Based on the code in test.cpp for GzipFile and GunzipFile, I have always
> used the following, and it should work for you:
> 
> // Gzip contents of plaintext into gzip_text;
> StringSource(plaintext, true, new Gzip(new StringSink(gzip_text))); 
> 
> // Ungzip contents of gzip_text into unzip_text;
> StringSource(gzip_text, true, new Gunzip(new StringSink(unzip_text))); 
> 
> Maybe I am missing something in your requirements?  (I have been pretty
much
> following your whole thread.)
> 
> You can also string these together, so if you want to gzip then B64
encode,
> you could:
> 
> StringSource(plaintext, true, new Gzip(new Base64Encoder(new
> StringSink(b64_text)))); 
> 
> And then to undo it back to plaintext, you do:
> 
> StringSource(b64_text, true, new Base64Decoder(new Gunzip(new
> StringSink(unb64_text)))); 

A couple more steps here.

I want to take the plain text and produce an encrypted text using AES.
I want to create a MAC of the encrypted text.
I want to create a single string containing the encrypted text and MAC.

So I can use what you gave to produce a compressed string. So

<encrypt>
plain text -> compress text (Use what you gave me above)

code: StringSource(plaintext, true, new Gzip(new
StringSink(gzip_text))); 

compress text -> encrypted text (base64 encoded)
        Q: What do you use for encrypting a std::string? 
          - A StringTransformationFilter?

mac text = mac of encrypted text
        Q: What do you use for generating a MAC?
        Q: Is a MAC a fixed size for all types? (e.g. SHA512 and SHA256)

cipher text = encrypted text + mac text

code: stringstream str;
      str << encrypted text << mac text;
      return str.str();

Stephen
-- 
Stephen Torri
GPG Key: http://www.cs.wustl.edu/~storri/storri.asc

Reply via email to