Jump to content
Tuts 4 You

using Crypto++


deepzero

Recommended Posts

Hi,

Today, i tried to implement a simple RSA en-decryption using "Crypto++" (www.cryptopp.com), as it`s supposed to be easy to use and powerful.

Since i had never used it before, i decided to start with something simple and calculate the SHA-x hash of a text string.

Fortunately, i even found an example code in the documentation:


/>http://www.cryptopp.com/fom-serve/cache/50.html

However, it wont compile. I`ve read through several FAQs, wiki entries, help files, online documentations - cant get it to work. :(

I downloaded the latest version of Crypto++ (5.6.1), extracted all the files to the core folder of my VS2008 C++ project and included the necessary headers:


#include "sha.h"int main()
{
CryptoPP::SHA256 hash;
}

As you can see, it`s only the most basic deceleration, but i keep getting linker errors:

temp.obj : error LNK2001: unresolved external symbol ""public: virtual void __thiscall CryptoPP::IteratedHashBase<unsigned int,class CryptoPP::HashTransformation>::Update(unsigned char const *,unsigned int)" (?Update@?$IteratedHashBase@IVHashTransformation@CryptoPP@@@CryptoPP@@UAEXPBEI@Z)".

I´m guessing i forgot to include some sort of header...?

deep

P.s. if anyone can suggest a (better) alternative, or a real beginner tut - let me know. :)

Link to comment

I don't really use C++, but since it's a linker error, I would assume that might mean that you have the library file (MSVC uses .lib I believe...?) in the wrong location. Try putting the Crypto++ library in MSVC's lib directory, wherever that is.

Edited by Hyperlisk
Link to comment
Try putting the Crypto++ library in MSVC's lib directory, wherever that is.

Or add Crypto++ library path to your IDE's library directory (setting somewhere in Extra - Options or w/e) and do a #pragma comment(lib, "whatever.lib") on top. If it still doesn't, I will d/l it and have a look.

Link to comment

#include sha.h MUST be used. in c++ link errors a because the function can not be found. to resolve this add the *.cpp file (sha.cpp) to your project

Link to comment

Taken from http://www.codeproject.com/KB/tips/CryptoPPIntegration.aspx:

Unresolved External Symbols

When using the DLL or FIPS DLL, the newsgroup occasional receives reports of LNK2001 and LINK2019 such as below. This is because the DLL and FIPS DLL only includes certified algorithms. So the DLL exports AES, but it does not export DES (DES has been deprecated in various standards). Also missing from the FIPS DLL are supporting classes such as Base64Encoder.

Crypto.obj : error LNK2019: unresolved external symbol

"public: virtual void __thiscall CryptoPP::Base64Encoder::IsolatedInitialize

(class CryptoPP::NameValuePairs const &)"

(? IsolatedInitialize@Base64Encoder@CryptoPP@@UAEXABVNameValuePairs@2@@Z)

referenced in function "public: __thiscall CryptoPP::Base64Encoder::Base64Encoder

(class CryptoPP::BufferedTransformation *,bool,int)"

(??0Base64Encoder@CryptoPP@@QAE@PAVBufferedTransformation@1@_NH@Z)

or

dlltest.obj : error LNK2001: unresolved external symbol "__declspec(dllimport)

public: __thiscall CryptoPP::DH_Domain<class CryptoPP::DL_GroupParameters_GFP_DefaultSafePrime,

struct CryptoPP::EnumToType<enum CryptoPP::CofactorMultiplicationOption,0>

...

DLL_Debug/dlltest.exe : fatal error LNK1120: 1 unresolved externals

To resolve, first read the "MSVC-Specific Information" in the readme.txt. Wei offers two solutions to the issue:

There are two ways you can deal with this, either change Crypto++ to export those classes, by using CRYPTOPP_DLL macro, or link with both the DLL export library and a static library that contains the non-DLL classes and functions. The latter can be built by using the "DLL-Import" configuration of the cryptlib project.

Note that in Wei's first solution, we are rebuilding the DLL (not the FIPS DLL) to export the additional functions we require by using the CRYPTO_DLL macro. We may also have to add the source files to the cryptdll project in the solution. In the second offering, we are using the FIPS DLL and supplementing it with functionality from Crypto++'s static library, since the FIPS DLL does not contain all the Crypto++ functionality we need.

HR.

Ghandi

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...