For those who might be interested, here is how I solved the problem.

I created a new project in the workspace : simple Win32 application, not
using MFC, Single-Threaded, with automatic use of precompiled headers (I
don't know if those parameters are important, but it works like that ;) ).
I compiled cryptopp as a multi-threaded lib, not using MFC, with automatic
use of precompiled headers.

My new project has 2 very simple files (this is just an example at the
moment, cipher and decipher using AES / CFB). Here they are :

****************************************************************************
**********
#include "../../cryptopp/modes.h"
#include "../../cryptopp/aes.h"
using namespace CryptoPP;

#include "Cipher.h"


unsigned char* Crypt(unsigned char* plaintext)
{
        byte key[AES::DEFAULT_KEYLENGTH], iv[AES::BLOCKSIZE];
    // initialize key and iv here
    CFB_Mode<AES >::Encryption cfbEncryption(key, AES::DEFAULT_KEYLENGTH,
iv);

        unsigned char *ciphertext = new unsigned char[100] ;

    // encrypt
    cfbEncryption.ProcessData(ciphertext, plaintext, 100);

        return ciphertext;
}


unsigned char* DeCrypt(unsigned char* ciphertext)
{
        byte key[AES::DEFAULT_KEYLENGTH], iv[AES::BLOCKSIZE];
    // initialize key and iv here
    CFB_Mode<AES >::Encryption cfbEncryption(key, AES::DEFAULT_KEYLENGTH,
iv);

        unsigned char *plaintext = new unsigned char[100] ;

    // now decrypt
   CFB_Mode<AES >::Decryption cfbDecryption(key, 16, iv);
    cfbDecryption.ProcessData(plaintext, ciphertext, 100);

        return plaintext;
}
****************************************************************************
***************

and the expectable Cipher.h :

****************************************************************************
***************
unsigned char* Crypt(unsigned char* plaintext);
unsigned char* DeCrypt(unsigned char* ciphertext);

****************************************************************************
***************

Then in my big application (using MFC, and stdafx.h as precompiled header),
I just included
Cipher.h, and the 2 functions work.

Hope this might help someone :)

C�dric

Reply via email to