Hi guys,

I'm just starting out with the crypto++ examples, trying to work through 
some examples to understand how everything goes together. All the 
complete projects I can find seem to be built for Visual C++ or other 
Windows environments, but my coding environment uses the CodeBlocks IDE. 
I've set up a build environment (with the crypto++ libraries) on both a 
Mac OSX system and a Linux system and seem to be running into the same 
snag in both cases. I'm sure my error has something to do with my 
includes, or possibly the placement of files, etc. but I can't find a 
complete example to compare against so I thought you guys might be able 
to help.

I've linked the compiled libcryptopp.a file into the project and added 
the /usr/include/cryptopp/ directory to the project so it can find the 
included files.

The project I'm compiling is a very slightly modified version of the 
Sample 2 project from this page:
http://www.codeproject.com/KB/security/BlockCiphers.aspx

When compiling the code I get a linking error which produces:

Undefined symbols:
   "CryptoPP::Rijndael::Enc::AdvancedProcessBlocks(unsigned char const*, 
unsigned char const*, unsigned char*, unsigned long, unsigned int) 
const", referenced from:
       vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, 
CryptoPP::Rijndael::Enc>in displayclient.o
       vtable for 
CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, 
CryptoPP::Rijndael::Enc>, 
CryptoPP::Rijndael::Enc>in displayclient.o
   "non-virtual thunk to 
CryptoPP::Rijndael::Enc::AdvancedProcessBlocks(unsigned char const*, 
unsigned char const*, unsigned char*, unsigned long, unsigned int) 
const", referenced from:
       vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, 
CryptoPP::Rijndael::Enc>in displayclient.o
       vtable for 
CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, 
CryptoPP::Rijndael::Enc>, 
CryptoPP::Rijndael::Enc>in displayclient.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

The code that produces this error is:

// Crypto++ Includes
#include <aes.h>
#include "modes.h"      // xxx_Mode< >
#include "filters.h"    // StringSource and StreamTransformation

// Standard Includes
#include <iostream>
#include <string>

using namespace CryptoPP;
using namespace std;

int main(int argc, char *argv[])
{
     // Key and IV setup
     byte key[ CryptoPP::AES::DEFAULT_KEYLENGTH ];
     byte iv[ CryptoPP::AES::BLOCKSIZE ];

     ::memset( key, 0x01, CryptoPP::AES::DEFAULT_KEYLENGTH );
     ::memset( iv, 0x01, CryptoPP::AES::BLOCKSIZE );

     // Message M
     std::string PlainText = "Voltaire said, Prejudices are what fools 
use for reason";

     // Cipher Text Sink
     std::string CipherText;

     // Encryptor
     CryptoPP::ECB_Mode< CryptoPP::AES >::Encryption
     //Encryptor( key, sizeof(key), iv );
     Encryptor( key, sizeof(key));

     // Encryption
     CryptoPP::StringSource( PlainText, true,
         new CryptoPP::StreamTransformationFilter( Encryptor,
             new CryptoPP::StringSink( CipherText )
         ) // StreamTransformationFilter
     ); // StringSource

     ///////////////////////////////////////
     // DMZ                               //
     ///////////////////////////////////////

     // Recovered Text Sink
     std::string RecoveredText;

     // Decryptor
     CryptoPP::ECB_Mode< CryptoPP::AES >::Decryption
       // Decryptor( key, sizeof(key), iv );
       Decryptor( key, sizeof(key) );

     // Decryption
     CryptoPP::StringSource( CipherText, true,
         new CryptoPP::StreamTransformationFilter( Decryptor,
             new CryptoPP::StringSink( RecoveredText )
         ) // StreamTransformationFilter
     ); // StringSource

     //////////////////////////////////////////
     // Output //
     //////////////////////////////////////////

     std::cout << "Algorithm:" << std::endl;
     std::cout << " " << Encryptor.AlgorithmName() << std::endl;
     std::cout << "Minimum Key Size:" << std::endl;
     std::cout << " " << Encryptor.MinKeyLength() << " bytes" << std::endl;
     std::cout << std::endl;

     std::cout << "Plain Text (" << PlainText.length() << " bytes)" << 
std::endl;
     std::cout << " '" << PlainText << "'" << std::endl;
     std::cout << std::endl;

     std::cout << "Cipher Text (" << CipherText.length() << " bytes)" << 
std::endl;
     std::cout << std::endl;

     std::cout << "Recovered Text:" << std::endl;
     std::cout << " '" << RecoveredText << "'" << std::endl;
     std::cout << std::endl;

     return 0;
}

Any help would be appreciated. Thanks.

--~--~---------~--~----~------------~-------~--~----~
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.
-~----------~----~----~----~------~----~------~--~---

Reply via email to