Crypto++ Faq-O-Matic
Page 1 of 15
Crypto++ Faq-O-Matic Moderator: weidai This is the Crypto++ ( http://www.cryptopp.com ) Frequently Asked Questions document. If you have any questions not answered in this FAQ, please search the Crypto++ mailing list archive, and then post your question to the mailing list if you can't find the answer in the archive. 2006-Dec-22 11:45am alister, weidai, weidai General Where is the tutorial? Where is the reference manual? Is there anyone I could pay to help me with this? Knowledge of cryptography How am I going to use Crypto++ if I don't have a clue about cryptography? Recommended Algorithms Links to cryptographic resources - http://www.mobiuslinks.com/links.asp?sid=1 Using the library How much C++ experience do I need to use this library? How do I use the Filter class? How do I use hex encoding and decoding? How do I use a block cipher in Crypto++ 4.x? How do I use a block cipher in Crypto++ 5.x? How do I use a stream cipher? How do I use a hash function? How do I use a message authentication code? How do I use a random number generator? How do I use a public key cryptosystem or signature scheme? How do I encrypt a message using a *private* key? (example of using signature with recovery) How can I use an RSA key from Crypto++ in openssl? The sample code shows how to work with a file, but my data is in a string (or vice versa). Why is ElGamal key generation so slow? I'm trying to process multiple messages with a Filter, and MaxRetrievable() always returns 0 after the first one. Compiling, linking, and testing issues What are the supported compilers and platforms? I am getting compiler errors with GCC. I get an "error opening file" message when I run cryptest.exe. Why can't I read Crypto++ objects from files via FileStore with STLport streams? Microsoft tools I compiled cryptest.exe successfully, but am getting linker errors with my own application. I'm getting internal compiler errors on Windows 98. Administration How can I contribute to this FAQ? New Questions 2006-Dec-22 8:14am alister, e.b.w., weidai, faq-o-matic, ban.giap.poh, ldb277, mschatz, shimh_eric, diogenes, bb100, hyn_4, pred, opadmassana, afomitch, erikd, ping9919, bayu, soha_nabel, atam, janus_19, ozturkfa, yyxzz, mhunley, starsoft, fabrizio.lovison, zhbh144, dviz, cryan, nagual, weidai [New Answer in "Crypto++ Faq-O-Matic"]
2008-Sep-19 7:39pm Crypto++ Faq-O-Matic :
Where is the tutorial? Moderator: weidai (inherited from parent) denis bider has created a user guide, which is available here: http://www.bitvise.com/users-guide.html You can also learn a lot about how to use the library by examining the self-test and benchmark suites that are included in the distribution. 2002-May-04 6:39am alister See also Jeffery Walton's series of articles here: http://www.codeproject.com/script/Articles/list_articles.asp?userid=349853 2006-Dec-17 10:44pm weidai [Append to This Answer]
2006-Dec-17 10:44pm Crypto++ Faq-O-Matic :
Where is the reference manual? Moderator: weidai (inherited from parent) The shortcut bar at the top of the Crypto++ home at http://www.cryptopp.com will always contain a link to the the reference documentation for the most recent release. This documentation is generated from specially tagged comments in the source code by Doxygen (http://www.doxygen.org). 2006-Dec-22 8:18am alister, weidai, weidai [Append to This Answer]
2006-Dec-22 8:18am
http://www.cryptopp.com/cgi-bin/fom.cgi?_recurse=1&file=1
04/04/2010
Crypto++ Faq-O-Matic
Page 2 of 15
Crypto++ Faq-O-Matic :
Is there anyone I could pay to help me with this? Moderator: weidai (inherited from parent) These people below have experience with C++ and Crypto++. At least one of them is likely to be available and interested in your project, for the right price. 2000-Dec-09 3:03am alister, faq-o-matic http://www.denisbider.com With 3 years of solid experience with Crypto++ and 8 years with C++, I can provide quality consulting and integration services for any Crypto++ project, as well as for computer security projects in general. Due to my convenient geographic location, I am able to offer sufficient pricing flexibility to suit any client profile: my past and existing clients include government organizations, corporations, professionals, and even students. You are invited to visit http://www.bitvise.com/services.html for further information. 2001-Apr-22 7:52pm faq-o-matic, alister http://www.SecondMouse.com
[email protected] Second Mouse Publishing, LLC has extensive experience with Crypto++ and can be contacted for consulting to help your company get Crypto++ in place for your security needs. We do general IT consulting and Custom Programming. We have worked with clients worldwide and are very good at finishing what others have started and failed. Hence our name, Second Mouse Software, the Second Mouse gets the cheese. Feel free to contact me directly at
[email protected] for inquiries or visit http://www.SecondMouse.com to get our free Simple ActiveX Control that encapsulates the Rijndael algorithm in Crypto++. It can be found on our Free Code Page. 2003-Jul-15 7:41am gary Seekford Solutions, Inc.-http://www.seekfordsolutions.com Seekford Solutions, Inc. provides custom software development with expertise in Internet protocols, encryption and security. We are happy to help you implement the crypto++ api, or create a project based on the technology to meet your needs. 2007-Dec-05 7:41am brians, weidai Jeffrey Walton. 439-5915, Maryland Area Code Portfolio available upon request. Jeff 2006-Dec-26 8:02pm jeffrey Dave Modi, MCL, Mumbai, India. Email :
[email protected]; www.mcl.in 2007-Dec-05 5:04am dmodi [Append to This Answer]
2007-Dec-05 7:41am Crypto++ Faq-O-Matic :
How am I going to use Crypto++ if I don't have a clue about cryptography? Moderator: weidai (inherited from parent) The answer is: with difficulty. There is nothing the more experienced people that use this library like more than a challenging security question to mull over. However, you may find you don't get much help if you ask a basic question with an answer that is well-documented elsewhere. The library assumes you know in cryptographic terms what you want to achieve. Until you reach that point, perhaps you should do some background research? You should also know that building secure systems is difficult at the best of times. If you can afford it, you can get some professional help: Is there anyone I could pay to help me with this? The good news is that there is a decent body of literature to help you. A list of recommended cryptography books is available at http://books.cryptopp.com. A lot of good crypto information is also available on the web. See http://links.cryptopp.com for a list of recommended sites. (An excellent on-line glossary of cryptographic concepts and terms is at RSA Labs, which you can reach by going through the above link.) 2001-Jul-16 7:30pm alister, weidai [Append to This Answer]
2001-Jul-16 7:30pm Crypto++ Faq-O-Matic :
Recommended Algorithms Moderator: weidai (inherited from parent) Crypto++ contains a large number of algorithms, and it may not always be obvious which ones to use. The algorithms given below are recommended because they are widely used and generally considered to be secure and patent-free. block cipher: DES-EDE3, AES, Serpent (Serpent is slower than AES but has a larger security margin and is not vulnerable to timing attacks.) stream cipher: any of the above block ciphers in CTR mode fast stream cipher: Salsa20, Panama, Sosemanuk (available in version 5.5) hash function: SHA-256, SHA-512, Whirlpool message authentication code: HMAC/SHA1 or HMAC with one of the above hash functions public key encryption: RSA/OAEP/SHA1, ECIES
http://www.cryptopp.com/cgi-bin/fom.cgi?_recurse=1&file=1
04/04/2010
Crypto++ Faq-O-Matic
Page 3 of 15
signature: RSA/PSS/H, ECDSA/H, which H one of the above hash functions key agreement: DH, ECDH random number generator: RandomPool, AutoSeededRandomPool See http://www.cryptopp.com/benchmarks.html for how fast these algorithms are. 2007-Apr-16 4:48pm weidai, weidai [Append to This Answer]
2007-Apr-16 4:48pm Crypto++ Faq-O-Matic :
How much C++ experience do I need to use this library? Moderator: weidai (inherited from parent) The library is an powerful and elegant tool for performing complex cryptography. It uses advanced C++ features such as templates, multiple inheritance, and exceptions to achieve that power and elegance. For people who are familiar with C++, the library will appear intuitive and easy to use. Others may need to view it as a learning opportunity. If you are a C++ beginner and you are under a very tight schedule, or if you are "afraid" of the more advanced features of C++, this library may not be for you. Having said that, you are invited to see for yourself how easy or hard it is to use by looking at some of the other answers in this category. 2001-Jan-13 6:07am alister, weidai [Append to This Answer]
2001-Jan-13 5:20pm Crypto++ Faq-O-Matic :
How do I use the Filter class? Moderator: weidai (inherited from parent) I'll try to explain the filter/pipeline design in Crypto++. The (abstract) base class is BufferedTransformation, with main member functions: virtual void Put(const byte *inString, unsigned int length) =0; virtual unsigned int Get(byte *outString, unsigned int getMax) =0;
The idea is that you put some bytes into a BufferedTransformation object, it does some transformation on them and buffers them, and then you get them back later (possibly with the length changed). One example of a BufferedTransformation is the MessageQueue, which just stores whatever you put in and then gives them back to you when you ask. The Filter abstract class derives from BufferedTransformation. A Filter is a BufferedTransformation on which you can attach another BufferedTransformation object. Instead of buffering up the transformed bytes, it would Put() them into the attached object. When you call Get() on a Filter, it calls Get() on the attached object and returns what the attached object returns without change. By default the object attached is a MessageQueue, but you can specify another filter or link a series of filters into a pipeline. Other abstract classes derived from BufferedTransformation include Source, which adds the Pump() member function (it pumps a specified number of bytes from its resevoir into the attached object) and Sink, which always returns 0 on Get(). 2002-Oct-12 4:27pm alister, weidai There are two ways to use filters. The first is defining your own Source and Sink classes (or use ones already in the library), and then link your Source and Sink objects with a series of filters. Examples: 2000-Aug-23 7:25am alister void EncryptFile(const char *filein, const char *fileout, const char *passPhrase) { FileSource f(filein, true, new DefaultEncryptor(passPhrase, new FileSink(fileout))); } void GzipFile(const char *filein, const char *fileout) { FileSource f(filein, true, new Gzip(new FileSink(fileout))); }
2001-Jan-12 11:00pm alister, weidai The "true" argument tells FileSource to immediately pump everything from filein to the attached BufferedTransformation. 2001-Jan-12 11:01pm alister, weidai The second method is to link a series of filters into a pipeline, manually Put() some bytes into it and then Get() them back. For example: 2000-Aug-23 7:28am alister // encode a string using passPhrase and encode it in hex // returns the ciphertext, which should be deleted by caller char *EncryptString(const char *instr, const char *passPhrase) { unsigned int len=strlen(instr); char* outstr; DefaultEncryptor encryptor(passPhrase, new HexEncoder); encryptor.Put((byte *)instr, len); encryptor.MessageEnd(); unsigned int outputLength = encryptor.MaxRetrieveable(); outstr = new char[outputLength+1]; encryptor.Get((byte *)outstr, outputLength); outstr[outputLength] = 0; return outstr; }
2001-Jan-16 5:38pm alister, weidai The filter/pipeline design has some more advanced features, such multiple channels (useful for secret sharing), but these basic features are all you
http://www.cryptopp.com/cgi-bin/fom.cgi?_recurse=1&file=1
04/04/2010
Crypto++ Faq-O-Matic
Page 4 of 15
need for most purposes. 2001-Jan-12 11:05pm weidai, alister [Append to This Answer]
2002-Oct-12 4:27pm Crypto++ Faq-O-Matic :
How do I use hex encoding and decoding? Moderator: weidai (inherited from parent) Encoding Encoding is very simple, say we had some data 'pData' that was of length 'dwLen', that we wished to encode and store in 'pData2' which is of length 'dwLen'*2, then #include "hex.h" // from crypto++ library HexEncoder hexEncoder; hexEncoder.Put(pData,dwLen); hexEncoder.MessageEnd(); hexEncoder.Get(pData2,dwLen*2); And there we have it. It is also possible to add multiple blocks of data to the encoders stream i.e. HexEncoder hexEncoder; hexEncoder.Put(pDataA,dwLenA); hexEncoder.Put(pDataB,dwLenB); hexEncoder.Put(pDataC,dwLenC); hexEncoder.MessageEnd(); hexEncoder.Get(pData2,(dwLenA+dwLenB+dwLenC)*2);
Decoding Decoding is equally simple. HexDecoder hexDecoder; hexDecoder.Put(pData,dwLen); hexDecoder.MessageEnd(); hexDecoder.Get(pData2,dwLen/2);
2001-Jan-12 10:55pm shaun_wilde, weidai See http://www.cryptopp.com/cgi-bin/fom.cgi?file=29 for more information on using Filters, which applies to these hex encoding and decoding filters. 2006-Dec-11 10:52pm weidai [Append to This Answer]
2006-Dec-11 10:52pm Crypto++ Faq-O-Matic :
How do I use a block cipher in Crypto++ 4.x? Moderator: weidai (inherited from parent) First you need to decide which block cipher and which cipher mode to use: CBC, CFB, OFB, or Counter Mode. (Check a crypto book if you don't understand the difference between them.) Using CBC is slightly different from using the other modes. Here's an example to encrypt with AES in CBC mode: 2001-Jan-11 11:15pm weidai byte key[16], iv[16], plaintext[100]; std::string ciphertext; // initialize key, iv, and plaintext here AESEncryption aesEncryption(key, 16); CBCPaddedEncryptor cbcEncryptor(aesEncryption, iv, new StringSink(ciphertext)); cbcEncryptor.Put(plaintext, 100); // input more plaintext here if needed cbcEncryptor.MessageEnd(); return ciphertext;
2001-Jan-11 11:14pm weidai Here's an example to decrypt with AES in CBC mode, using a StringSource object as an alternative way to input the ciphertext instead of the Put() and MessageEnd() calls shown above: 2001-Apr-04 10:58am weidai std::string decrypted; AESDecryption aesDecryption(key, 16); StringSource source(ciphertext, true, new CBCPaddedDecryptor(aesDecryption, iv, new StringSink(decrypted))); return decrypted;
2001-Jul-22 9:02pm weidai CFB, OFB, and Counter Mode essentially turn a block cipher into a stream cipher. You create one of these mode objects like this: AESEncryption aesEncryption(key, 16); CFBEncryption cfbEncryption(aesEncryption, iv);
and then use the mode object (cfbEncryption) the same way as a stream cipher:
http://www.cryptopp.com/cgi-bin/fom.cgi?_recurse=1&file=1
04/04/2010
Crypto++ Faq-O-Matic
Page 5 of 15
cfbEncryption.ProcessString(plaintext, 100);
Please note that a CFB, OFB, or Counter Mode (but not CBC) object should always be initialized with a block cipher encryption object, even if you want to use the mode for decryption: AESEncryption aesEncryption(key, 16); CFBDecryption cfbDecryption(aesEncryption, iv);
// use the encryption object // but the decryption mode
cfbDecryption.ProcessString(plaintext, 100);
// back to plaintext
If you want to use the same Filter interface as shown above for CBC mode, there is a StreamCipherFilter class in filters.h that will create a Filter given a stream cipher object: StreamCipherFilter cfbEncryptor(cfbEncryption);
2001-Apr-04 10:55am weidai, alister You can also use block cyphers directly, i.e. ECB mode. Now, normally this is a bad idea, but as Bruce Schneier writes in _Applied_Cryptography_, "For encrypting random data, such as other keys, ECB is a good mode to use. Since the data is short and random, none of the shortcomings of ECB matter for this application."
Here is an example using AES encryption in ECB mode, presuming you have a 128-bit key that you wish to encrypt. Note that this example works because the block size of the AES algorithm (128 bits) is identical to the size of the data we wish to encrypt. If you wish to encrypt data whose size is different than the block size, you will need to either write a BufferedTransformation that pads/breaks up the input, or do it "in-line" and repeatedly invoke ProcessBlock. byte myKey[16], ecbKey[16], encryptedKey[16]; // Populate myKey and ecbKey kere AESEncryption aesEncryption(ecbKey,16); // 128-bit ECB key aesEncryption.ProcessBlock(myKey,encryptedKey); // AES block size is identical in size to myKey and encryptedKey.
2001-Jul-03 3:09pm koan he Crypto FAQ at http://www.math.umn.edu/~garrett/crypto/faq.html describes the differences between EBC, CBC, PCBC, CFB, and OFB in section 5. 2001-Dec-13 8:09pm alk [Append to This Answer]
2006-Dec-11 10:52pm Crypto++ Faq-O-Matic :
How do I use a block cipher in Crypto++ 5.x? Moderator: weidai (inherited from parent) First you need to decide which block cipher and which cipher mode to use: ECB, CBC, CFB, OFB, or CTR Mode. Crypto++ provides mode objects which essentially turn a block cipher into a stream cipher. Here is how to create a mode object: #include "cryptopp/modes.h" #include "cryptopp/aes.h" using namespace CryptoPP; // ... byte key[AES::DEFAULT_KEYLENGTH], iv[AES::BLOCKSIZE]; // initialize key and iv here CFB_Mode
::Encryption cfbEncryption(key, AES::DEFAULT_KEYLENGTH, iv);
You can also create a mode object that holds a reference to a block cipher object rather than an instance of it: AES::Encryption aesEncryption(key, AES::DEFAULT_KEYLENGTH); CFB_Mode_ExternalCipher::Encryption cfbEncryption(aesEncryption, iv);
Mode objects implement the SymmetricCipher interface, documented at http://www.cryptopp.com/docs/ref/struct_symmetric_cipher_documentation.html. You can use it directly, for example: byte plaintext[100], ciphertext[100]; // put data into plaintext here // encrypt cfbEncryption.ProcessData(ciphertext, plaintext, 100); // now decrypt CFB_Mode::Decryption cfbDecryption(key, 16, iv); cfbDecryption.ProcessData(plaintext, ciphertext, 100);
For ECB and CBC mode, you must process data in multiples of the block size. Alternatively, you can wrap StreamTransformationFilter around the mode object and use it as a Filter object. StreamTransformationFilter will take care of buffering data into blocks for you when needed. std::string ciphertext; StreamTransformationFilter cfbEncryptor(cfbEncryption, new StringSink(ciphertext)); cfbEncryptor.Put(plaintext, 100); // input more plaintext here if needed cfbEncryptor.MessageEnd(); return ciphertext;
2007-Aug-16 5:14pm weidai, weidai // To encrypt a string using a block cipher:
http://www.cryptopp.com/cgi-bin/fom.cgi?_recurse=1&file=1
04/04/2010
Crypto++ Faq-O-Matic
Page 6 of 15
byte key[Twofish::DEFAULT_KEYLENGTH], iv[Twofish::BLOCKSIZE]; string plainText; // ... populate key, iv, plainText here string cipher; StringSink* sink = new StringSink(cipher); Base64Encoder* base64_enc = new Base64Encoder(sink); CBC_Mode::Encryptor twofish(key, Twofish::DEFAULT_KEYLENGTH, iv); StreamTransformationFilter* twofish_enc = new StreamTransformationFilter(twofish, base64_enc); StringSource source(plainText, true, twofish_enc);
2003-Nov-05 6:21pm jonathanischoice #include #include #include "modes.h" #include "aes.h" #include "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( 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(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( 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; }
2005-Oct-21 10:38am jeffrey Descriptions of the modes given above can be found at the following wikipedia page: http://en.wikipedia.org/wiki/Cipher_block_chaining
2006-Jan-21 11:08am jason // Runtime Includes #include // Crypto++ Includes
http://www.cryptopp.com/cgi-bin/fom.cgi?_recurse=1&file=1
04/04/2010
Crypto++ Faq-O-Matic
#include "cryptlib.h" #include "modes.h" #include "filters.h"
Page 7 of 15
// xxx_Mode< > // StringSource and // StreamTransformation
// Cipher Modes // // #define CIPHER_MODE CBC_CTS_Mode // #define CIPHER_MODE CBC_Mode // #define CIPHER_MODE CFB_FIPS_Mode #define CIPHER_MODE CFB_Mode // #define CIPHER_MODE CTR_Mode // #define CIPHER_MODE ECB_Mode // #define CIPHER_MODE OFB_Mode // Ciphers // // #define CIPHER AES // #define CIPHER Blowfish // #define CIPHER BTEA // #define CIPHER Camellia // #define CIPHER CAST128 // #define CIPHER CAST256 // #define CIPHER DES // #define CIPHER DES_EDE2 #define CIPHER DES_EDE3 // #define CIPHER DES_XEX3 // #define CIPHER GOST // #define CIPHER IDEA // #define CIPHER MARS // #define CIPHER RC2 // #define CIPHER RC5 // #define CIPHER RC6 // #define CIPHER Rijndael // #define CIPHER SAFER_K // #define CIPHER SAFER_SK // #define CIPHER Serpent // #define CIPHER SHACAL2 // #define CIPHER SHARK // #define CIPHER SKIPJACK // #define CIPHER ThreeWay // #define CIPHER Twofish // #define CIPHER XTEA int main(int argc, char* argv[]) { // Key and IV setup byte key[ CryptoPP::CIPHER::DEFAULT_KEYLENGTH ], iv[ CryptoPP::CIPHER::BLOCKSIZE ]; ::memset( key, 0x01, CryptoPP::CIPHER::DEFAULT_KEYLENGTH ); ::memset( iv, 0x01, CryptoPP::CIPHER::BLOCKSIZE ); // Message M std::string PlainText = "Hello World"; // Cipher Text Sink std::string CipherText; // Encryptor CryptoPP::CIPHER_MODECryptoPP::CIPHER::Encryption Encryptor( key, sizeof(key), iv ); // Encryption CryptoPP::StringSource( PlainText, true, new CryptoPP::StreamTransformationFilter( Encryptor, new CryptoPP::StringSink( CipherText ) ) // StreamTransformationFilter ); // StringSource /////////////////////////////////////// // DMZ // /////////////////////////////////////// // Recovered Text Sink std::string RecoveredText; // Decryptor CryptoPP::CIPHER_MODECryptoPP::CIPHER::Decryption Decryptor( key, sizeof(key), iv ); // Decryption CryptoPP::StringSource( CipherText, true, new CryptoPP::StreamTransformationFilter( Decryptor, new CryptoPP::StringSink( RecoveredText ) ) // StreamTransformationFilter ); // StringSource ////////////////////////////////////////// // Output // ////////////////////////////////////////// std::cout std::cout std::cout std::cout std::cout
<< << << << <<
"Algorithm:" << std::endl; " " << Encryptor.AlgorithmName() << std::endl; "Minimum Key Size:" << std::endl; " " << Encryptor.MinKeyLength() << " bytes" << std::endl; std::endl;
std::cout << "Plain Text (" << PlainText.length() << " bytes)" << std::endl;
http://www.cryptopp.com/cgi-bin/fom.cgi?_recurse=1&file=1
04/04/2010
Crypto++ Faq-O-Matic
Page 8 of 15
std::cout << " '" << PlainText << "'" << std::endl; std::cout << std::endl; std::cout << "Recovered Text:" << std::endl; std::cout << " '" << RecoveredText << "'" << std::endl; std::cout << std::endl; return 0; }
2006-Nov-23 4:22pm noloader [Append to This Answer]
2007-Aug-16 5:14pm Crypto++ Faq-O-Matic :
How do I use a stream cipher? Moderator: weidai (inherited from parent) Stream ciphers implement the SymmetricCipher interface, which is documented at http://www.cryptopp.com/docs/ref/struct_symmetric_cipher_documentation.html. The following example uses the Sosemanuk stream cipher: byte plaintext[100], ciphertext[100], key[Sosemanuk::DEFAULT_KEYLENGTH], iv[Sosemanuk::IV_LENGTH]; // put data into key, iv, and plaintext here // encrypt Sosemanuk::Encryption enc(key, Sosemanuk::DEFAULT_KEYLENGTH, iv); enc.ProcessData(ciphertext, plaintext, 100); // now decrypt Sosemanuk::Decryption dec(key, Sosemanuk::DEFAULT_KEYLENGTH, iv); dec.ProcessData(plaintext, ciphertext, 100);
2007-Aug-16 5:11pm weidai [Append to This Answer]
2007-Aug-16 5:11pm Crypto++ Faq-O-Matic :
How do I use a hash function? Moderator: weidai (inherited from parent) (excerpt from a message posted to the Crypto++ mailing list) SHA-256 (or any other hash module) is used like this: #include "sha.h" . . . SHA256().CalculateDigest(pbOutputBuffer, pbData, nDataLen); // pbOutputBuffer must be SHA256::DIGESTSIZE bytes in length or, if you have data that's made up of multiple pieces: #include "sha.h" . . . SHA256 hash; hash.Update(pbData1, nData1Len); hash.Update(pbData2, nData2Len); hash.Update(pbData3, nData3Len); hash.Final(pbOutputBuffer); See also the definition of HashTransformation::CalculateDigest() in cryptlib.h.
2009-Mar-16 6:20pm faq-o-matic, weidai // example of hashing followed by base64 encoding, using filters #include "sha.h" #include "base64.h" std::string digest; CryptoPP::SHA256 hash;
// don't use MD5 anymore. It is considered insecure
// Thank you, Wei Dai, for making this possible: CryptoPP::StringSource foo("CryptoPP is cool", true, new CryptoPP::HashFilter(hash, new CryptoPP::Base64Encoder ( new CryptoPP::StringSink(digest)))); std::cout << digest << std::endl; --------------------Check: #!/bin/bash echo -n "CryptoPP is cool" | openssl dgst -sha256 -binary | openssl base64 -e
2009-Mar-17 6:04am cryptopp, weidai [Append to This Answer]
http://www.cryptopp.com/cgi-bin/fom.cgi?_recurse=1&file=1
04/04/2010
Crypto++ Faq-O-Matic
Page 9 of 15
2009-Mar-17 6:04am Crypto++ Faq-O-Matic :
How do I use a message authentication code? Moderator: weidai (inherited from parent) It's similar to using a hash function, except you have to key the MAC object first: #include "sha.h" // or "md5.h" for MD5, etc #include "hmac.h" . . . // pbOutputBuffer must be HMAC::DIGESTSIZE bytes in length HMAC(pbKey, nKeyLen)).CalculateDigest(pbOutputBuffer, pbData, nDataLen);
or, if you have data that's made up of multiple pieces: HMAC mac; mac.SetKey(pbKey, nKeyLen); mac.Update(pbData1, nData1Len); mac.Update(pbData2, nData2Len); mac.Update(pbData3, nData3Len); mac.Final(pbOutputBuffer);
2002-Dec-30 1:51pm weidai Some MACs, such as VMAC, require an IV for each message. So you need to use SetKeyWithIV() instead of SetKey(). For example: #include "vmac.h" #include "aes.h" VMAC mac; mac.SetKeyWithIV(pbKey, nKeyLen, pbIV); ... // reset IV for next message mac.Resynchronize(pbIV2); ...
2008-Jul-01 4:46pm weidai [Append to This Answer]
2008-Jul-01 4:46pm Crypto++ Faq-O-Matic :
How do I use a random number generator? Moderator: weidai (inherited from parent) If you're running on a Win32 OS, or a Unix OS with /dev/random, then you can use AutoSeededRandomPool: #include "osrng.h" using namespace CryptoPP; . . . AutoSeededRandomPool rng; byte randomBytes[10]; rng.GenerateBlock(randomBytes, 10);
Otherwise you should use RandomPool and seed it yourself with random, unpredictable data: RandomPool rng; rng.Put(seed, seedLen); byte randomBytes[10]; rng.GenerateBlock(randomBytes, 10);
2002-Dec-30 1:57pm weidai [Append to This Answer]
2002-Dec-30 1:57pm Crypto++ Faq-O-Matic :
How do I use a public key cryptosystem or signature scheme? Moderator: weidai (inherited from parent) There is sample code for RSA key generation, encryption, decryption, signing, and verifying in test.cpp, which is included in the distribution archive (or at http://www.cryptopp.com/docs/ref/test_8cpp-source.html). Other public key algorithms use the same interfaces, which are documented in cryptlib.h (or at http://www.cryptopp.com/docs/ref/cryptlib_8h.html) under abstract base classes that start with "PK_". 2007-Jan-11 6:45am weidai, weidai [Append to This Answer]
2007-Jan-11 6:45am Crypto++ Faq-O-Matic :
http://www.cryptopp.com/cgi-bin/fom.cgi?_recurse=1&file=1
04/04/2010
Crypto++ Faq-O-Matic
Page 10 of 15
How do I encrypt a message using a *private* key? (example of using signature with recovery) Moderator: weidai (inherited from parent) The Crypto++ API does not allow you to encrypt using a private key, because that is not a valid cryptographic concept. Perhaps what you really want to do is to use the private key to sign a message in such a way that you can recover the message from the signature during the signature verification process, thus avoiding having to send the message separately. Here is some sample code for doing this: #include "rsa.h" #include "pssr.h" #include "files.h" // ... FileSource f("rsa1024.dat", true, new HexDecoder); RSASS::Signer signer(f); RSASS::Verifier verifier(signer); // sign byte message[] = "test"; unsigned int messageLen = sizeof(message); SecByteBlock signature(signer.MaxSignatureLength(messageLen)); AutoSeededRandomPool rng; unsigned int signatureLen = signer.SignMessageWithRecovery(rng, message, messageLen, NULL, 0, signature); // verify and recover SecByteBlock recovered(verifier.MaxRecoverableLengthFromSignatureLength(signatureLen)); DecodingResult result = verifier.RecoverMessage(recovered, NULL, 0, signature, signatureLen); if (!result.isValidCoding) throw InvalidSignature(); unsigned int recoveredLen = result.messageLength;
2008-Aug-24 4:56am weidai, aspecialj [Append to This Answer]
2008-Aug-24 4:56am Crypto++ Faq-O-Matic :
How can I use an RSA key from Crypto++ in openssl? Moderator: weidai (inherited from parent) An RSA key generated with Crypto++ encoded with DER can be used in openssl if the key is specified to be PKCS#8 encoded. For example if a 4096 bit RSA public key is generated with: AutoSeededRandomPool rng; RSAES_OAEP_SHA_Decryptor priv(rng, 4096); TransparentFilter privFile(new FileSink("rsakey.der")); priv.DEREncode(privFile); privFile.MessageEnd();
The key can be converted by openssl with: `openssl pkcs8 -in rsakey.der -inform DER -out rsakey.pem -nocrypt`
Furthermore, the key can now be verified as a valid RSA key with: `openssl rsa -in rsakey.pem -check`
See the openssl man page for more information about using openssl. 2001-Oct-29 10:56pm mschatz, weidai See http://www.cryptopp.com/wiki/Basic_Encoding_Rules for more information related to key format. 2007-Dec-09 6:36pm weidai [Append to This Answer]
2007-Dec-09 6:36pm Crypto++ Faq-O-Matic :
The sample code shows how to work with a file, but my data is in a string (or vice versa). Moderator: weidai (inherited from parent) First, read this FAQ: How do I use the Filter class?. That should tell you how Crypto++ handles I/O using Source and Sink classes. Once you understand that, just replace FileSource with StringSource, and FileSink with StringSink (or vice versa). 2001-Jan-14 7:37pm weidai of42be3c9a35084f817d4ca3d68a04256 2006-Feb-13 9:17pm ksaup [Append to This Answer]
2006-Feb-13 9:17pm Crypto++ Faq-O-Matic :
Why is ElGamal key generation so slow? Moderator: weidai (inherited from parent) When you generate an ElGamal key pair, you have the option of specifying a prime modulus. If you do not specify the prime modulus, one will be
http://www.cryptopp.com/cgi-bin/fom.cgi?_recurse=1&file=1
04/04/2010
Crypto++ Faq-O-Matic
Page 11 of 15
generated, however because the modulus must be a safe prime (a prime p such that (p-1)/2 is also prime), and those are much rarer than regular primes, it takes a long time. I suggest that you use an existing well known safe prime instead. For example the following 2048-bit one from http://www.ietf.org/internetdrafts/draft-ietf-ipsec-ike-modp-groups-04.txt : "36F0255DDE973DCB3B399D747F23E32ED6FDB1F77598338BFDF44159C4EC64DDAEB5F78671CBFB22" "106AE64C32C5BCE4CFD4F5920DA0EBC8B01ECA9292AE3DBA1B7A4A899DA181390BB3BD1659C81294" "F400A3490BF9481211C79404A576605A5160DBEE83B4E019B6D799AE131BA4C23DFF83475E9C40FA" "6725B7C9E3AA2C6596E9C05702DB30A07C9AA2DC235C5269E39D0CA9DF7AAD44612AD6F88F696992" "98F3CAB1B54367FB0E8B93F735E7DE83CD6FA1B9D1C931C41C6188D3E7F179FC64D87C5D13F85D70" "4A3AA20F90B3AD3621D434096AA7E8E7C66AB683156A951AEA2DD9E76705FAEFEA8D71A575535597" "0000000000000001H"
The g (generator) value for this prime should be 2. 2002-May-14 6:54pm weidai [Append to This Answer]
2002-May-14 6:54pm Crypto++ Faq-O-Matic :
I'm trying to process multiple messages with a Filter, and MaxRetrievable() always returns 0 after the first one. Moderator: weidai (inherited from parent) You need to call GetNextMessage() after you finish getting each output message. 2003-Apr-03 10:25pm weidai [Append to This Answer]
2003-Apr-03 10:25pm Crypto++ Faq-O-Matic :
What are the supported compilers and platforms? Moderator: weidai (inherited from parent) The supported compilers and platforms are summarized at http://www.cryptopp.com#platforms. Below are detailed build status pages for individual Crypto++ releases. If you build (or fail to build) a Crypto++ release on a compiler/platform that is not listed on its status page, please report your success or problems to the Crypto++ mailing list so we can keep these pages up to date. Please note that older C++ compilers may not implement enough C++ features to make it possible to compile Crypto++ on them without rewriting large parts of it. If a compiler is listed under the "Failure" section in a build status page, it means some effort went into trying to port Crypto++ to that compiler and the effort did not succeed. 2006-Dec-22 11:45am weidai Build Status for Crypto++ 5.4 Build Status for Crypto++ 5.5 Build Status for Crypto++ 5.5.2 Build Status for Crypto++ 5.6.0 2006-Dec-22 7:48am weidai [New Answer in "What are the supported compilers and platforms?"]
2009-Mar-12 8:19am Crypto++ Faq-O-Matic :
What are the supported compilers and platforms? :
Build Status for Crypto++ 5.4 Moderator: weidai (inherited from parent)
Success with Default Compiler l l l l l l l l l l l l l l
MSVC 6.0 SP5 with Processor Pack on Windows XP SP2 x86 MSVC .NET 2003 SP1 on Windows XP SP2 x86 MSVC .NET 2005 SP1 on Windows XP SP2 x86 and Windows Vista x64 GCC 3.4.2 on FreeBSD 5.4 x86 GCC 3.4.4 on Cygwin 1.5.21 x86 GCC 3.3 and 4.0.1 on MacOS X 10.4 x86 [Shigeya Suzuki] GCC 3.3 on Darwin 8.0 x86 GCC 3.1 on MacOS X 10.2 powerpc GCC 4.1.2 on Ubuntu Server 6.10 (Linux 2.6) x86 GCC 3.3.3 on NetBSD 2.0.2 x86 GCC 3.3.3 on NetBSD 3.1 x86 [Shigeya Suzuki] GCC 3.4.2 on Fedora Core 3 AMD64 (Linux 2.6) GCC 4.0.2-8 on Fedora Core 4 AMD64 [Carlos Moreno] GCC 4.1.1 on Debian 4.0 (codename "etch", prerelease) x86 and hppa [Jens Peter Secher]
Success with Upgraded Compiler l l
GCC 4.1.2 on MacOS X 10.4 x86 [Shigeya Suzuki] GCC 4.0.2 on Solaris 10 x86 (install GCC from www.blastwave.org, overwrite /usr/ccs/bin/ld with /opt/csw/bin/gld, run "gmake AS=gas")
Success after Patching Crypto++ l l l
MSVC .NET 2002 SP1 on Windows XP SP2 x86 [Jeffery Walton] MSVC 6.0 SP6 on Windows XP SP2 x86 Turbo C++ / Borland C++Builder 2006 on Windows XP SP2 x86
http://www.cryptopp.com/cgi-bin/fom.cgi?_recurse=1&file=1
04/04/2010
Crypto++ Faq-O-Matic
l
Page 12 of 15
Sun Studio 11 CC 5.8 on Solaris 10 x86 and x64 (run "gmake CXX=CC")
Partial Success l l
GCC 3.3.5 on OpenBSD 3.8 x86 (validation test failure, code generation bug for validat1.cpp) GCC 4.0.2 on OpenBSD 3.8 x86 (must turn off -msse2)
Failure l l l l l
Open Watcom 1.5 on Windows XP x86 (problem with function templates) GCC 4.0.0 on Darwin 8.0 x86 (compiler error for esign.cpp) GCC 3.3.2 on Solaris 9 x86 ("Out of symbol table" Assembler error for dll.cpp. try rebuilding GCC to use GAS (GNU Assembler)) GCC 2.95.4 on Debian 3.0 Alpha () Borland C++ Builder 6 [Carlos Moreno]
2007-Apr-09 6:52am weidai [Append to This Answer]
2007-Apr-09 6:52am Crypto++ Faq-O-Matic :
What are the supported compilers and platforms? :
Build Status for Crypto++ 5.5 Moderator: weidai (inherited from parent)
Success with Default Compiler l l l l l l l l l l l l l l l
MSVC 6.0 SP5 with Processor Pack on Windows XP SP2 x86 MSVC .NET 2003 on Windows XP SP2 x86 MSVC .NET 2005 SP1 on Windows XP SP2 x86 and Windows Vista x64 Turbo C++ / Borland C++Builder 2006 on Windows XP SP2 x86 GCC 3.4.4 on Cygwin 1.5.21 on Windows XP SP2 x86 GCC 3.4.2 on MinGW 5.1.3 on Windows XP SP2 x86 GCC 4.1.2 on Ubuntu Server 6.10 (Linux 2.6) x86 ICC 9.1 on Ubuntu Server 6.10 x86 (run "make CXX=icpc") Sun Studio 11 CC 5.8 on Solaris 10 x86 and x64 (run "gmake CXX=CC") GCC 4.1.1 on Red Hat Ent Linux 5 ia64 ICC 9.1 on Red Hat Ent Linux 5 ia64 GCC 3.4.6 on Linux 2.6.14-gentoo-r5 ppc64 GCC 3.4.4 on FreeBSD 6.1 x86 GCC 3.3.5 on OpenBSD 4.0 x86 GCC 4.0.1 on Mac OS X 10.4.7 x86
Success with Upgraded Compiler l
l
GCC 4.1.1 on Solaris 10 x86 (install binutils from www.blastwave.org, compile GCC with "configure --with-gnu-as --withas=/opt/csw/bin/gas", overwrite /usr/ccs/bin/ld with /opt/csw/bin/gld, run "gmake AS=gas") GCC 4.1.1 on Solaris 10 x64 (same as above, plus set LD_LIBRARY_PATH=/usr/local/lib/amd64)
Success after Patching Crypto++ Partial Success l
MSVC "Orcas" Beta 1 on Windows XP SP2 x86 (triggers bug in std::heap for debug builds. bug has been reported at https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=275251)
Failure l
See Failure section for Crypto++ 5.4
2007-Aug-14 10:15pm weidai [Append to This Answer]
2007-Aug-14 10:15pm Crypto++ Faq-O-Matic :
What are the supported compilers and platforms? :
Build Status for Crypto++ 5.5.2 Moderator: weidai (inherited from parent)
Success with Default Compiler l l l l l l l l l l
MSVC 6.0 SP6 on Windows XP SP2 x86 MSVC .NET 2003 on Windows XP SP2 x86 (open cryptest.dsw) MSVC .NET 2005 SP1 on Windows XP SP2 x86 and Windows Vista x64 MSVC "Orcas" Beta 2 on Windows XP SP2 x86 GCC 3.3.5 on OpenBSD 4.0 x86 (run gmake) GCC 3.4.2 on MinGW 5.1.3 on Windows XP SP2 x86 GCC 3.4.4 on Cygwin 1.5.21 on Windows XP SP2 x86 GCC 3.4.4 on FreeBSD 6.1 x86 (run gmake) GCC 3.4.6 on Linux 2.6.14-gentoo-r5 ppc64 GCC 4.0.1 on Mac OS X 10.4.7 x86
http://www.cryptopp.com/cgi-bin/fom.cgi?_recurse=1&file=1
04/04/2010
Crypto++ Faq-O-Matic
l l l l l l l l l l
Page 13 of 15
GCC 4.1.1 on Red Hat Ent Linux 5 ia64 and x86-64 GCC 4.2.1 on OpenSUSE 10.3 (Linux 2.6) x86 ICC 9.1 on Ubuntu Server 6.10 x86 (make CXX=icpc) ICC 9.1 on SuSE Enterprise Server 10 x86-64 (make CXX=icpc) ICC 9.1 on Red Hat Ent Linux 5 ia64 (make CXX=icpc) ICC 9.1 on Windows XP SP2 x86 (convert to Intel project) ICC 10.0 on OpenSUSE 10.3 x86 (make CXX=icpc) ICC 10.0 on Windows XP SP2 x86 and Windows Vista x64 (convert to Intel project) Sun Studio 11 CC 5.8 on Solaris 10 x86 and x86-64 (run "gmake CXX=CC") Sun Studio 12 CC 5.9 on Solaris 10 x86 (run "gmake CXX=CC")
Success with Upgraded Compiler l
l
GCC 4.1.1 on Solaris 10 x86 (install binutils from www.blastwave.org, compile GCC with "configure --with-gnu-as --withas=/opt/csw/bin/gas", overwrite /usr/ccs/bin/ld with /opt/csw/bin/gld, run "gmake AS=gas") GCC 4.1.1 on Solaris 10 x86-64 (same as above, plus set LD_LIBRARY_PATH=/usr/local/lib/amd64)
Success after Patching Crypto++ Partial Success l l
Turbo C++ / Borland C++Builder 2006 on Windows XP SP2 x86 (validation tests fail when optimizations are turned on) Borland C++Builder 2007 on Windows XP SP2 x86 (validation tests fail when optimizations are turned on)
Failure l
See Failure section for Crypto++ 5.4
2007-Sep-25 4:09am weidai [Append to This Answer]
2007-Sep-25 4:09am Crypto++ Faq-O-Matic :
What are the supported compilers and platforms? :
Build Status for Crypto++ 5.6.0 Moderator: weidai (inherited from parent)
Success with Default Compiler l l l l l l l l l l l l l l l l l l l l l l l l
Visual C++ 6.0 SP6 on Windows Vista x64 SP1 Visual C++ 2003 .NET SP1 on Windows Vista x64 SP1 Visual C++ 2005 SP1 on Windows Vista x64 SP1, win32 and x64 targets Visual C++ 2008 SP1 on Windows Vista x64 SP1, win32 and x64 targets GCC 4.3.2 on Cygwin, AMD Athlon 64, x86 GCC 4.3.2 on Ubuntu 8.10, AMD Athlon 64, amd64, (-m32, -m32 -fPIC, and -m64 -O3) GCC 4.1.2 on Debian, TI UltraSparc IIe (Hummingbird), sparc64, -m32 and -m64 GCC 4.3.2 on Debian, PA8500 (PCX-W), hppa GCC 4.3.2 on Debian, Intel Madison, IA-64 GCC 4.1.2 on Debian, PowerPC G4 GCC 4.1.2 on Debian, AMD Opteron 8354, amd64, -m64 ICC 11.0 on Ubuntu 8.10, AMD Athlon 64, amd64, "LC_ALL=C make CXX=icpc", -m64 Sun CC 5.10 on OpenSolaris 2008.11, AMD Athlon 64, amd64, "make CXX=CC", -m64 GCC 3.4.3 on OpenSolaris 2008.11, AMD Athlon 64, amd64, -m32 and -m64 GCC 4.1.2 on Gentoo, ARM Feroceon 88FR131 GCC 3.3.5 on OpenBSD 4.4, AMD Athlon 64, amd64, "gmake" GCC 4.2.1 on FreeBSD 7.1, AMD Athlon 64, amd64, "gmake" GCC 4.1.2 on Ubuntu 6.10 Server, AMD Athlon 64, x86 ICC 9.1 on Ubuntu 6.10 Server, AMD Athlon 64, x86 GCC 4.1.2 on NetBSD 4.0.1, AMD Athlon 64, amd64 GCC 3.3.3 on OpenSUSE 11.1, AMD Athlon 64, x86, -m32 -fPIC GCC 4.2.1 on MacOS X Leopard, Intel Core 2, amd64, "make CXX=c++-4.2" -arch x86_64 GCC 4.0.1 on MacOS X Leopard, Intel Core 2, x86 CodeGears C++Builder 2009 (update 2) on Windows XP SP3, x86
Success with Upgraded Compiler Success after Patching Crypto++ Partial Success Failure l
See Failure section for Crypto++ 5.4
2009-Oct-06 11:49pm weidai [Append to This Answer]
2009-Oct-06 11:49pm Crypto++ Faq-O-Matic :
I am getting compiler errors with GCC.
http://www.cryptopp.com/cgi-bin/fom.cgi?_recurse=1&file=1
04/04/2010
Crypto++ Faq-O-Matic
Page 14 of 15
Moderator: weidai (inherited from parent) This is most commonly caused by two problems. First, make sure when you unzip the source distribution archive, you use the -a option to autoconvert text file line endings. Second, you need to use a version of GCC that is supported by Crypto++. Please see What are the supported compilers and platforms? 2006-Dec-22 8:12am weidai, weidai [Append to This Answer]
2006-Dec-22 8:13am Crypto++ Faq-O-Matic :
I get an "error opening file" message when I run cryptest.exe. Moderator: weidai (inherited from parent) Make sure you run cryptest.exe from the directory containing descert.dat and other .dat files. 2001-Feb-02 9:06pm weidai yes but i miss the edc.dat (not included in crypto 5.0)? what now 2002-Oct-28 8:53am x00179 edc.dat should contain a hex encoded SHA-1 hash of cryptest.exe, and it is used as part of start up self-test when FIPS 140-2 compliance mode is enabled at compile time. You must generate the file yourself and place it in the same directory as cryptest.exe. More details will be available in a upcoming FIPS 140-2 special release of Crypto++. 2002-Oct-28 12:56pm weidai [Append to This Answer]
2003-Feb-24 5:05am Crypto++ Faq-O-Matic :
Why can't I read Crypto++ objects from files via FileStore with STLport streams? Moderator: weidai (inherited from parent) STLport 4.5.x's (and other versions most likely) streams implementation doesn't allow seeking backwards in an istream once you've read to the stream's end. This appears to be a bug in STLport and will hopefully be fixed by them in an upcoming version. In the meantime, you may be able to work around this problem by writing an extra byte to the end of your files when you generate them. For example: // open a file for serialization CryptoPP::FileSink file("filename"); // write a Crypto++ object to the file object.DEREncode(file); // write an extra byte so FileStore read will work file.GetStream() << '\0';
2002-May-14 8:00pm erikd [Append to This Answer]
2002-May-14 8:00pm Crypto++ Faq-O-Matic :
I compiled cryptest.exe successfully, but am getting linker errors with my own application. Moderator: weidai (inherited from parent) Make sure Crypto++ and your application projects are using the same C++ run-time libraries. The option for this is under Project Settings/"C/C++"/Code Generation/Use run-time library. The Crypto++ library project defaults to multi-threaded non-DLL libraries. 2000-Nov-16 3:20am weidai Also make sure that they are using the same calling conventions. This is under Project Settings/"C/C++"/Code Generation/Calling convention. Note that Crypto++ has DLL and static library build configurations, and they use different calling conventions. 2006-Dec-11 11:00pm weidai, weidai Also, make sure you are linking against the right library. If you want to use the DLL form of Crypto++, link against cryptopp.lib in win32\dll_output or x64\dll_output. If you want to use the static library form, link against cryptlib.lib in win32\output or x64\output. (Directory names are relative to where you unzipped Crypto++.) This is for MSVC 2005. For other compilers do a file search to find where the appropriate .lib file is. Alternatively, you can add the appropriate Crypto++ project file to your solution/workspace as a dependent project, and link against it that way. 2006-Dec-12 5:28pm weidai See also Jeffery Walton's "Compiling and Integrating Crypto++ into the Microsoft Visual C++ Environment" at http://www.codeproject.com/useritems/CryptoPPIntegration.asp. It has a detailed discussion of common compiling and linking errors for MSVC 6. 2006-Dec-17 10:34pm weidai [Append to This Answer]
2008-Sep-19 10:11pm Crypto++ Faq-O-Matic :
I'm getting internal compiler errors on Windows 98. Moderator: weidai (inherited from parent) This seems to be a bug in MSVC which does occur only on Windows 9x and not on Windows NT/2000/XP. You can work around it by compiling the .cpp file that causes the error individually, and then continue the build process. Or, according to johnyang, disabling precompiled headers will solve this problem. 2002-Feb-19 8:04pm weidai I encountered the same problem attempting to build cryptlib.lib with MSVC 6 (SP5) on Win 98 SE. I tried compiling each cpp file individually. No
http://www.cryptopp.com/cgi-bin/fom.cgi?_recurse=1&file=1
04/04/2010
Crypto++ Faq-O-Matic
Page 15 of 15
problem with that, but still couldn't build the lib. Turning off use of the precompiled header did the trick. TIP: Don't remove the definition "USE_PRECOMPILED_HEADERS" from the Project Options. Even though it seems like a contradiction, the definition is needed in the build. Just go to the C/C++ tab under project settings, choose the Precompiled Headers category and select "Not using prcompiled headers." It's only necessary to do this for the cryptlib project. The crypttest project will build fine as-is. 2002-Jul-21 1:26pm ghaecker [Append to This Answer]
2008-Sep-19 7:37pm Crypto++ Faq-O-Matic :
How can I contribute to this FAQ? Moderator: weidai (inherited from parent) You can contribute on two levels: Anybody should feel free to add answers to the faq, perhaps by just posing an additional question. If you are a reasonably experienced Crypto++ user you might consider taking a moderation role over a part of the FAQ. If you'd like to, please contact the moderator. 2001-Jun-23 8:22pm alister To contribute, your first step should be to learn about the Faq-o-matic. Check out the Faq-o-matic Faq-o-matic which has a great users guide and a playground: http://www.dartmouth.edu/cgi-bin/cgiwrap/jonh/faq.pl The Faq-O-Matic link at the bottom of most pages goes there. It is pretty easy. If you want to just dive in you need to [Show Expert Editing Commands]. This can also be done by clicking the [Appearance] link at the bottom of the page. Set the editing commands to either show or compact. Most editing actions can only be performed by authenticated users (those who give an email address that they can read from). 2000-Aug-22 5:20am alister Below are some quick tips for formatting answers. Answers can be entered as natural text or monospaced text (for code or tables). The FOM has the capability for direct HTML but this has been turned off to improve consistency and increase the maintainability of the document. If you have a need for HTML, email the moderator who will be able to paste it in. 2001-Jan-12 10:11pm alister You can get some useful formatting within the natural text answer-type. Pressing [enter] twice in the text entry box forces a new line when the answer is displayed. Pressing [enter] three times, forces a blank line to be inserted. You can insert references to other pages within this faq-o-matic. See the Faq-o-matic Users Guide for details. You can also make any URL into a link by surrounding it in angle brackets. 2001-Jan-12 10:12pm alister Thank you for the nice library. But I just want to use only AES encryption with input file. So can you please say the areas that i need to change for including AES files only in this project? Thanks & Regards Prasad A K 2008-Sep-16 3:05am prasad.ak [Append to This Answer]
2008-Sep-16 3:05am This document is: http://www.cryptopp.com/cgi-bin/fom.cgi?file=1 [Search]
[Appearance]
[Show Top Category Only] This is a Faq-O-Matic 2.721.
[Show Expert Edit Commands]
This FAQ is administered by Wei Dai.
http://www.cryptopp.com/cgi-bin/fom.cgi?_recurse=1&file=1
04/04/2010