Thank you much, Shawn!
 
I did not noticed the CFB_Mode_ExternalCipher defines :)
 
Thank for help,
Konstantin
 
----- Original Message -----
Sent: Friday, April 16, 2004 3:11 PM
Subject: RE: Design question

            When I have done this in the past (for an implementation of OpenPGP) I would create pointer to a common ancestor object for encryption.  Then once I knew what the encryption type was I would allocate the transform to the object and move onto the mode.  There was more then one way to do this, but this worked in our code and was simple enough to understand.

            With 5.X the preferred method changed some, but still should be easy to do.  There is a new set of class templates for external ciphers which you pass a reference to for the encryption transform.  To use it you would have a pre allocated encryptor or decryptor referenced by a BlockCipher type object and pass it into the constructor.  Only mode needs to be declared at compile time in this case, so you would have two sequential switch statements rather then nested.

 

            Hope that helps.

 

            73,

                        Shawn

 

 


From: Voronkov Konstantin [mailto:[EMAIL PROTECTED]
Sent: Friday, April 16, 2004 6:16 AM
To: [EMAIL PROTECTED]
Subject: Design question

 

Hello All!

 

I have design quesion about using cipher modes and block ciphers.

 

I need to enumerate cipher modes and block ciphers. E.g. Alice encrypts

 message, she uses CFB algoritghm and AES cipher. I want to save

some CFB id and AES id and append it to message. Then B wants

to decrypt message. I'm about to use something like this:

 

switch(mode) {

  case CBC: {

    case DES: {

       CFB_Mode<DES>::Decryption cfbE(key, DES::DEFAULT_KEYLENGTH, iv);

       ...
    }

    case AES: {

       CFB_Mode<AES>::Decryption cfbE(key, AES::DEFAULT_KEYLENGTH, iv);

       ...
    }

    ...

  }

  case CFB: {

    case DES: {

       CFB_Mode<DES>::Decryption cfbE(key, DES::DEFAULT_KEYLENGTH, iv);

       ...
    }

    case AES: {

       CFB_Mode<AES>::Decryption cfbE(key, AES::DEFAULT_KEYLENGTH, iv);

       ...
    }

    ...

  }

  ...

}

 

I feel there is some way to avoid this terrible swithes, but structure of CryptoPP

 is bit complicated for me, and I can not understand how to solve my task without

such switched.

 

Can you hint how to solve my task with CryptoPP library, please?

 

Best Regards,

Voronkov Konstantin

Reply via email to