-----Original Message----- From: Jeffrey Walton [mailto:[EMAIL PROTECTED] Sent: den 6 november 2005 18:11 To: [email protected] Subject: Re: Newbie help tips please
Hi, Sorry for the top post... Glad to hear you are through the issues. It has been a long time since I worked in *nix - sorry I could not be of more help. I absolutely love Wei's library. I hope you'll find it so also. Jeff ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <[email protected]> Sent: Sunday, November 06, 2005 11:38 AM Subject: RE: Newbie help tips please > -----Original Message----- > From: Manik Taneja [mailto:[EMAIL PROTECTED] > Sent: den 5 november 2005 23:50 > To: [email protected] > Subject: RE: Newbie help tips please > > I think there should be a sligt difference in the order of arguments... > > g++ crypt_test.cpp -lcryptopp.a -static -L$<path> -o test_app > where $<path> is the location for lcryptopp.a you could figure this out by > typing locate libcryptopp.a > > --- > hope is the quintessential human illusion... simultaneously the source of > your greatest strength and your greatest weakness > > Quoting [EMAIL PROTECTED]: > > > Hi tried that as well. Still get the same errors. I will later today > > install a linux machine and see if I can get it working there. Thanks > > for the tips. > > > > // JPB > > > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > > Sent: den 4 november 2005 01:03 > > To: [email protected]; [EMAIL PROTECTED] > > Cc: 'Jeffrey Walton' > > Subject: RE: Newbie help tips please > > > > Hi, > > > > Should it not be (see Wei's gnumakefile): > > g++ libcryptopp.a -L... -lcryptopp -o test_app crypt_test.cpp > > > > Jeff > > > > Quoting [EMAIL PROTECTED]: > > > > > Hello, > > > Unfortunatly I have not made any progress, I did some more > > > tests but decided to leave it for a while and learn some more basic > > > > > c++ thinking maybe I was missing some basic knowledge. What I did > > do is: > > > > > > I have tried installing the freebsd port and using the library that > > > > > way, but that doesn't work either. I then tried to update the whole > > > > > system to FreeBSD 6RC2. That helped a bit regarding the compilation > > > > > errors encountered when compiling integer.cpp but still I get > > linking > > > erros. Just a quick recap to see if I am correct in my > > methodology: > > > 1. Download and extract the source for cryptopp > > > /root/code/gsm_control/trunk/cryptopp > > > 2. cp GNUMakefile to Makefile and run gmake 3. Compilation goes > > fine > > > but cryptotest fails all 16 "Panama validation suite running..." > > tests > > > 4. Use small test program from Faq to test > > > (/root/code/gsm_control/trunk/crypto_test.cpp): > > > ********************************** > > > #include <iostream> > > > #include <iomanip> > > > > > > #include "cryptopp/modes.h" > > > #include "cryptopp/aes.h" > > > #include "cryptopp/filters.h" > > > > > > int main(int argc, char* argv[]) { > > > > > > // > > > // Key and IV setup > > > // > > > byte key[ CryptoPP::AES::DEFAULT_KEYLENGTH ], iv[ > > > CryptoPP::AES::BLOCKSIZE ]; > > > memset( key, 0x00, CryptoPP::AES::DEFAULT_KEYLENGTH ); > > > memset( iv, 0x00, CryptoPP::AES::BLOCKSIZE ); > > > > > > // > > > // String and Sink setup > > > // > > > std::string plaintext = "Now is the time for all good men to > > come > > > to the aide..."; > > > std::string ciphertext; > > > std::string decryptedtext; > > > > > > // > > > // Dump Plain Text > > > // > > > std::cout << "Plain Text (" << plaintext.size() << " bytes)" << > > > > > std::endl; > > > std::cout << plaintext; > > > std::cout << std::endl << std::endl; > > > > > > // > > > // Create Cipher Text > > > // > > > CryptoPP::AES::Encryption aesEncryption(key, > > > CryptoPP::AES::DEFAULT_KEYLENGTH); > > > CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption( > > > aesEncryption, iv ); > > > > > > CryptoPP::StreamTransformationFilter > > stfEncryptor(cbcEncryption, > > > new CryptoPP::StringSink( ciphertext ) ); > > > stfEncryptor.Put( reinterpret_cast<const unsigned char*>( > > > plaintext.c_str() ), plaintext.length() + 1 ); > > > stfEncryptor.MessageEnd(); > > > > > > // > > > // Dump Cipher Text > > > // > > > std::cout << "Cipher Text (" << ciphertext.size() << " bytes)" > > << > > > std::endl; > > > > > > for( int i = 0; i < ciphertext.size(); i++ ) { > > > > > > std::cout << "0x" << std::hex << (0xFF & > > > static_cast<byte>(ciphertext[i])) << " "; > > > } > > > > > > std::cout << std::endl << std::endl; > > > > > > // > > > // Decrypt > > > // > > > CryptoPP::AES::Decryption aesDecryption(key, > > > CryptoPP::AES::DEFAULT_KEYLENGTH); > > > CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption( > > > aesDecryption, iv ); > > > > > > CryptoPP::StreamTransformationFilter > > stfDecryptor(cbcDecryption, > > > new CryptoPP::StringSink( decryptedtext ) ); > > > stfDecryptor.Put( reinterpret_cast<const unsigned char*>( > > > ciphertext.c_str() ), ciphertext.size() ); > > > stfDecryptor.MessageEnd(); > > > > > > // > > > // Dump Decrypted Text > > > // > > > std::cout << "Decrypted Text: " << std::endl; > > > std::cout << decryptedtext; > > > std::cout << std::endl << std::endl; > > > > > > return 0; > > > } > > > ********************************** > > > 5. Compile using > > > gandalf# pwd > > > /root/code/gsm_control/trunk > > > gandalf# g++ -L/root/code/gsm_control/trunk/cryptopp/ -lcryptopp -o > > > > > test_app crypt_test.cpp 6. Get lots and lots of errors (here are > > > some): > > > /var/tmp//ccAX78nC.o(.text+0x27b): In function `main': > > > : undefined reference to > > > > > > `CryptoPP::CipherModeFinalTemplate_ExternalCipher<CryptoPP::CBC_Encryption>: > > > > > :CipherModeFinalTemplate_ExternalCipher(CryptoPP::SimpleKeyedTransform > > > ation< CryptoPP::BlockTransformation>&, unsigned char const*, > > int)' > > > /var/tmp//ccAX78nC.o(.text+0x2a5): In function `main': > > > : undefined reference to > > > > > `CryptoPP::StringSinkTemplate<std::string>::StringSinkTemplate(std::st > > > ring&) > > > ' > > > /var/tmp//ccAX78nC.o(.text+0x2ec): In function `main': > > > : undefined reference to > > > > > > `CryptoPP::StreamTransformationFilter::StreamTransformationFilter(CryptoPP:: > > > StreamTransformation&, CryptoPP::BufferedTransformation*, > > > CryptoPP::StreamTransformationFilter::BlockPaddingScheme)' > > > /var/tmp//ccAX78nC.o(.text+0x465): In function `main': > > > : undefined reference to > > > > > > `CryptoPP::CipherModeFinalTemplate_ExternalCipher<CryptoPP::CBC_Decryption>: > > > > > :CipherModeFinalTemplate_ExternalCipher(CryptoPP::SimpleKeyedTransform > > > ation< CryptoPP::BlockTransformation>&, unsigned char const*, > > int)' > > > /var/tmp//ccAX78nC.o(.text+0x48f): In function `main': > > > : undefined reference to > > > > > `CryptoPP::StringSinkTemplate<std::string>::StringSinkTemplate(std::st > > > ring&) > > > ' > > > /var/tmp//ccAX78nC.o(.text+0x4d6): In function `main': > > > > > > Am I doing anything obviously wrong here?! Do I have to pass any > > > object files or the like with the compiler statement? Any help > > greatly > > appreciated. > > > Thanks. > > > > > > // Jorgen > > > > > > -----Original Message----- > > > From: Jeffrey Walton [mailto:[EMAIL PROTECTED] > > > Sent: den 3 november 2005 22:28 > > > To: [email protected]; [EMAIL PROTECTED] > > > Subject: Re: Newbie help tips please > > > > > > Hi, > > > > > > Have you made any progress? > > > > > > Jeff > > > > > > >>> [EMAIL PROTECTED] 10/30/2005 8:39 PM >>> > > > Hello, > > > I am a complete C++ newbie but I think the best way to learn > > is > > > to get stuck into it. Anyhow what I want to do is simply try to use > > > > > the CryptoPP library in a small learning program. For example > > starting > > > out using SHA hashes or the like. So I downloaded the source, > > > extracted it into cryptopp directory in my source root. I then > > copied > > > the GNUmakefile to Makefile, ran gmake. One thing I had to do > > thoguh > > > was compile integer.cpp by hand as it did not compile with -O2 (-O1 > > > > > worked fine). After this I ran tried compiling the program from the > > > > > FAQ entitled "How do I use a block cipher in > > > Crypto++ > > > 5.0?" by 2005-Oct-21 7:38am jeffrey. I only changed the include > > paths > > > as below. > > > > > > #include "cryptopp/modes.h" > > > #include "cryptopp/aes.h" > > > #include "cryptopp/filters.h" > > > > > > > > > However I get lots of errors and the compilation fails. I am > > running > > > FreeBSD: > > > > > > FreeBSD xxx.xxx.xxx 5.4-RELEASE FreeBSD 5.4-RELEASE #0: Sun May 8 > > > 10:21:06 > > > UTC 2005 i386 > > > > > > Here are some of the erorrors, as far as I can understand these are > > > > > linker errors and not compilation erros right?: > > > > > > > > /var/tmp//ccb6QI7E.o(.gnu.linkonce.t._ZN8CryptoPP8Rijndael3EncC2ERKS1_ > > > +0x28) > > > : In function > > `CryptoPP::Rijndael::Enc::Enc(CryptoPP::Rijndael::Enc > > > const&)': > > > : undefined reference to `vtable for CryptoPP::Rijndael::Enc' > > > > > /var/tmp//ccb6QI7E.o(.gnu.linkonce.t._ZN8CryptoPP8SecBlockIjNS_20Alloc > > > atorWi > > > thCleanupIjEEEC1ERKS3_+0x25): In function > > `CryptoPP::SecBlock<unsigned > > > int, CryptoPP::AllocatorWithCleanup<unsigned int> > > > >::SecBlock(CryptoPP::SecBlock<unsigned int, > > > CryptoPP::AllocatorWithCleanup<unsigned int> > const&)': > > > : undefined reference to `CryptoPP::AllocatorWithCleanup<unsigned > > > int>::allocate(unsigned int, void const*)' > > > > > > > > > This is the command I used to compile: > > > > > > # g++ crypt_test.cpp -o cptest.out > > > > > > I also tried using for SHA in my own really simple program but get > > the > > > same errors. > > > > > > Am I missing something. Like I said I am VERY new to C++ so maybe I > > > > > haven't yet grasped how the libraries are supposed to be used (I > > have > > > compiled other OOP programs I've written myself though without > > > problems). I have searched for code examples on the net but almost > > all > > > are Windows code. I have tried the -lcryptopp and -L path switches > > but > > > still get the same error. Also the cryptotest v fails on many > > tests. > > > > > > Tests complete. Total tests = 16. Failed tests = 16. > > > SOME TESTS FAILED! > > > > > > Whirlpool Hash Function validation suite running... > > > AlgorithmType: MessageDigest > > > Comment: Message digests of strings of 0-bits and lengths 0-127 > > bytes > > > Digest: > > > 470F0409ABAA446E49667D4EBE12A14387CEDBD10DD17B8243CAD550A089DC0F\ > > > Message: r0 0x00 > > > Name: Whirlpool > > > Source: Tweaked NESSIE submission > > > > > > CryptoPP::Exception caught: Unexpected error during validation > > test > > > > > > Thankful for any tips or nudges in the right direction. > > > > > > // bobey > > > > > > > > > > > > > > > > > > > > > > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > Manik Taneja > University at Buffalo > mtaneja [at] buffalo [dot] edu > > ************************************************************ > Ah thank you very much. That worked... Well almost... A small change to your > line: > > g++ crypt_test.cpp -lcryptopp -static -L./cryptopp -o test_app (Removed the > .a in -l) > > Now I can continue and see if I can write an application using the library. > Thanks a million!!! > > // jpb > > ***************************************************************** Hello, I appreciate thee help you gave. Like I said I am just learning c++ but that is always easier if one has something interesting to work with. Now that I have gotten the compilation and linking issues sorted I can concentrate on learning to use the library which is where the real fun starts! My first task is a simple OTP generating routine. I have however already run into one minor problem, although a quick search through the archives suggests that the question has already been answered (huge executable program even thought the code is < 25 lines) so I will read through all the answers and fix that problem. Otherwise I forsee relatively smooth sailing ahead :). Thanks again everyone for the help. No doubt I'll be back soon again with more problems. Also I'll see if I can contribute some myself by helping others (although at the moment I think I'm maybe to much of a newbie). Best Regards, jpb
