Introduction
The Crypto++ User Group occasionally receives questions on Crypto++ and Microsoft's Environments. The questions are usually basic such as, "VC++ can't find a header file - how [where] do I..." or more ambiguous statement, "I can't compile." This article will attempt to resolve these common issues, and provide basic background information.
Source Code
The Crypto++ source code can be downloaded from the website at Crypto++ homepage. If the website is down, use the SourceForge page, or use an archiving service such as archive.org here.
Documentation
There are four sources of documentation for Crypto++. They are the Source Code, the Crypto++ Usenet Group, the Crypto++ FAQ, and the Crypto++ Wiki. Wei maintains an FAQ which can be found here. The Crypto++ users group can be found here. The Crypto++ Wiki can be found here. Finally, Dennis Bider has authored a User Guide and Help File which can be found here. My most used reference is the source code, which can be found online at the Crypto++ Library Reference Manual and Crypto++ Class Index.
Benchmarks
The Crypto++ library includes benchmarking capabilities through the test harness using the 'cryptest b' command line. In addition, the benchmark can take arguments such as bounding time for each test and the CPU speed. See usage.dat for details or run 'cryptest' with no arguments.
There are at least three published results of benchmarking available on the web. See Crypto++ 5.5 Benchmarks, Speedtest and Comparsion of Open-Source Cryptography Libraries and Compiler Flags and eBACS: ECRYPT Benchmarking of Cryptographic Systems.
Windows CE
Ugo Chirico maintains a port of Crypto++ 5.5.2 to Windows Mobile 2005 at Crypto++ 5.5.2 on Windows Mobile 2005. Dr. Chirico posts announcements to the Crypto++ user group. His initial post can be found at Crypto++ Users.
Managed Code
There are no special steps in using managed code. Note that if we are using the FIPS DLL, we might find that some functionality is missing (see the discussion below). For a well written example, see Mike Sinclair's CodeProject.com article, RSA Encryption with .NET 2.0 Cryptography Services and Crypto++ Wrapped as a Managed C++ Class Library.
FIPS Compliance
FIPS 140-2 certification means the library produces correct results and complies with certain cryptographic protocols. Protocols would include zeroing the memory of key material after the library is finished using it. When we refer to the FIPS compliant DLL, we will state FIPS DLL.
The FIPS DLL must be used in binary form as distributed by Wei (even though we have the source code and can build the same binary). This means we cannot build the Crypto++ DLL and claim it is FIPS compliant.
Version 5.5.2 is the last version of the library which Wei plans to submit for testing and validation. Details can be found here.
The module certification FAQ can be found under the Cryptographic Module Validation Program.
Single Threaded Versus Multi-threaded
In all cases, the Crypto++ library should be built using multi-threaded libraries. This was an issue with Visual C++ 6.0 and previous. At times, the Project Wizard would output a project using Singe Threaded project (/ML and /MLd).
Static Versus Dynamic Linking
C Runtime Library
When integrating Crypto++, the Crypto++ library must use the same runtime library linker setting as our Visual Studio project. The runtime library refers to the C Runtime Library. A stock Crypto++ distribution is built using static linking against the runtime (/MT and /MTd).
A default Visual Studio project created by the wizard will use dynamic runtime linking. The project would specify the /MD or /MDd linker switch for dynamic runtime linking, while the Crypto++ library would be using static linking (/MT or /MTd) from its build. This will cause a plethora of LINK2005 errors when linking. To resolve the Crypto++ library must be rebuilt. Table 1 below summarizes this discussion
| Project Setting |
Project Link Switch |
Desired Runtime Linking |
Action Required |
| Static Runtime Linking |
/MT or /MTd |
Static |
None |
| Dynamic Runtime Linking |
/MD or /MDd |
Dynamic |
Rebuild Crypto++ Library |
Rebuild Crypto++ Library means to rebuild the Crypto++ library after changing the settings to compile and link against dynamic versions of the runtime. Also see the section Unsupported Configuration below.
Static Runtime Linking
The Crypto++ library is distributed as a statically linked library. Static linking is usually preferred (versus the DLL or FIPS DLL). According to Wei Dai:
... there should not be any problems linking a DLL against a DLL. But using the static library saves on code size and I'd suggest it unless you need to use the DLL for some reason (such as FIPS compliance).
When creating a statically linked Visual Studio project, no additional settings need to be changed.
Dynamic Runtime Linking
When dynamically linking to the C Runtime (/MD or /MDd), the Crypto++ library must be rebuilt using the same link settings are the main project. Open the Crypto++ project and change the Crypto++ project setting for both Cryptlib and CryptDll. The settings should be changed to /MD or /MDd. For good measure, the setting should also be changed for Cryptest (and the validation test re-run: issue cryptest v).
Runtime Library Conflicts and the Crypto++ DLL/FIPS DLL
Runtime linking presents two difficult situations for the software author. First is the desire to link dynamically against the C runtime while using the FIPS DLL. The issue is derived as follows: Dynamic C Runtime linking is used by (/MD or /MDd) the application, but the distributed FIPS DLL is static (/MT or /MTd). The best solution is using the /NODEFAULTLIB switch, and hope that no runtime issues occur. This situation will create hard to track down runtime bugs and obscure initialization failures. Note that rebuilding the DLL using dynamic runtime linking is not available since we are using the FIPS DLL.
The second situation is created when using additional third party components. This includes MFC and ATL. Suppose we need to use the FIPS DLL. We change the Project settings to use the static version of the runtime, and link using the FIPS DLL. Next, we add the third party component which only offers dynamic linking against the C Runtime. We now have the situation previously described. The preferred work around it to contact the third party vendor, and acquire a library which uses the same runtime settings as our Project and Crypto++.
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.
Crypto++ Dll - New and Delete
At time, we might have to force Crypto++ to use new and delete from another library rather than the standard runtime. For this, we would want to call SetNewAndDeleteFunctionPointers. See dll.cpp for Wei's use of setting the function pointers for the standard runtime.
Also be aware that this usually has to be done early in the initialization process. This creates additional issues not related to Crypto++, such as linking libraries in the wrong order. Please see Knowledge Base Article 148652, LNK2005 error occurs when the CRT library and MFC libraries are linked in the wrong order in Visual C++.
Compiling Crypto++
Visit the Crypto++ homepage and fetch a version for download. This article is based on version 5.2.1, but any version should do. We should review the "Platforms" Matrix when choosing a Crypto++ distribution. When using Visual Studio 6.0, Microsoft's Processor Pack is recommended for Crypto++ 5.1 and earlier; and is required for Crypto++ 5.2 and later.
Create a directory on the hard drive for the distribution of Crypto++ downloaded. Locate the cryptest.dsw or cryptest.sln file, and open it. In this example, the ZIP file was extracted to C:\CryptoPP 5.2.1\.
From the Build Menu, Select Batch Build
For the purposes of this article, build only the Static Library by un-checking the appropriate selections.

Integrating Crypto++ into the Visual C++ Environment
This document will add the library to the Visual Studio environment rather than the Project environment. This means the settings affect every project, not just a Crypto++ project. Please see John Deters's comment below for reasons not to do so. It is well crafted and explained commentary which should prove useful. Once the build is complete, drill into the C:\CryptoPP 5.2.1\Debug\ folder. Rename the library file from cryptlib.lib to cryptlibd.lib (notice the addition of the "d" for Debug).
Move the Debug Library to the location of the Header and Source Files. In this example, the location is C:\CryptoPP 5.2.1\. Also, move (without renaming) the Release version to the same folder.
Visual C++ Integration
Add the location of the Header Files, Source Files, and Libraries to the VC++ Environment. Select Tools | Options, Directories Tab. Make the appropriate entry for the previously mentioned items in the drop down menu.

Project Integration
Add the location of the Header Files, Source Files, and Libraries to the VC++ Project.
This step will allow us to #include"ecp.h", rather than including ecp.h, all of its dependencies; and specifying full or relative paths. Also, since the Library is on path (and appropriately named), one can now issue the following #pragma to have the linker include the library:
#ifdef _DEBUG
# pragma comment ( lib, "cryptlibd" )
#else
# pragma comment ( lib, "cryptlib" )
#endif
Additional (Unsupported) Configuration
If interested, a project configuration exists which allows for building Crypto++ using both static and dynamic runtime linking. However, don't expect Wei to support it. The authors have used it for quite some time with both Visual Studio 8.0 and Visual Studio 9.0.
Unfortunately, the x64 build settings have been removed by the IDE because the x64 compiler and headers were not installed during installation. Fortunately, they can be easily added back into the project using the Configuration Manager.
The alternate configuration renames the cryptlib project to cryptlib.static. It also adds cryptlib.dynamic (with settings copied form cryptlib.static). Both the static and dynamic projects build debug and release libraries. ".dynamic" and ".static" were chosen rather than 'd' and 's' suffixes so that debug builds would not be confused with dynamic c runtime linking builds. Files offered by the configurations are:
- cryptlib.static.lib
- cryptlibd.static.lib
- cryptlib.dynamic.lib
- cryptlibd.dynamic.lib
To use the configuration, unzip the files over top of the Crypto++ files, replacing as required. For those who concern themselves with library size (before the linker removes unused functions), dynamic runtime linking produces considerably smaller code.

After building the four variant, use copylib.cmd to copy the libraries to the root of the Crypto++ distibution. Finally, include CryptlibInclude.h in the project. CryptlibInclude.h performs a switch based on _DLL (defined when using dynamic runtime linking) and DEBUG :

Also note that both the static and dynamic libraries use dll.cpp, even though we are not building the dll . If we don't use dll.cpp, we will receive LNK2001 errors stsing that a function (using _thiscall) could not be found, despite the fact that we specify _cdecl for compilation in the source file's properties. Below, VerifyHash (an ATL project which requires dynamic runtime linking) is using cryptlib.dynamic without dll.cpp.

We receive 20 errors (10 pairs) similar to below. The first error claims that the program cannot be linked because of a missing function in VerifyHash.obj. The second (referring to the same function) claims the function cannot be found in the Crypto++ library.
VerifyHash.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)
cryptlibd.dynamic.lib(md5.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 can't explain why functions from iterbase.h and iterbase.cpp are affected by inclusion or exclusion of dll.cpp.
Common Errors
This section will discuss common compiler and liner errors encountered when using the Crypto+ library. They are usually encountered because of an oversight in following these instructions. Once you have verified that these instructions were followed, please post your question to the Crypto++ User Group.
Compile Error 1001
If you receive Internal Compile Error COMPILE 1001 (C1001) shown below
You should perform the following:
- Verify your Source Code is correct
- Verify config.h (see below)
- Rearrange Functions (note the CL Error will output the Source Code line where the Compiler encountered problems - see below)
- Disable Precompiled Headers
- Update the Library
- Update the Compiler
- Post to the Crypto++ Newsgroup
- Contact Microsoft Support
Verify config.h
Depending on the version of Visual Studio, some compile time changes are invoked. One suspect to pay particular attention to is _MSC_VER < 1300. If using Visual Studio 7.1 or above, changing to below may do the trick.
#if defined(_MSC_VER) && _MSC_VER <= 1300
# define CRYPTOPP_CONSTANT(x) enum {x};
#else
# define CRYPTOPP_CONSTANT(x) static const int x;
#endif
Rearrange Functions
Function A
{ ... }
Function B
{ ... }
Change the above to:
Function B
{ ... }
Function A
{ ... }
I can't explain this one, but it has worked for me in the past when working with Crypto++ Elliptic Curve functions.
Compile Error 1083
If you do not add the path to the Crypto++ header files to the Visual C++ environment or your Project, COMPILE 1083 (C1083) Errors similar to below will be displayed.
Compile Error 1189
If you incorrectly match the C Runtime with MFC (for example, MFC as a DLL, Crypto++ and C Runtime as a Static Library), COMPILE 1189 (C1189), errors similar to those below will be displayed.
You should revisit the section Static Versus Dynamic Linking. MFC uses dynamic runtime linking.
Compile Warning 4530
If you receive Compile Warning COMPILE 4530 (C4530) ...
... then you should enable exception handling.
Link Error 1103
If you receive LINK 1103 (LNK1103) "debugging information corrupt" when using Visual C++ 6.0 and the latest Platform SDK (shown below) with libraries uuid.lib, shell32.lib, msxml2.lib, etc ...
... then you should roll back the Platform SDK to February 2003. One may be able to change the directory order in Visual C++ 6.0.
Link Error 1104
If you do not install MFC Unicode Library Versions (mfc42u.lib, mfc42ud.lib, etc.), but define UNICODE, LINK 1104 (LNK1104), then errors similar to those below will be displayed. This is a Visual C++ 6.0 and previous error, since Visual Studio 7.0 and above do not allow a non-Unicode installation.
To resolve, rerun setup and install the Unicode Libraries (performing a custom installation).
Link Error 1104
If you do not place the Crypto++ Library on the VC++ IDE path, LINK 1104 (LNK1104), then errors similar to those below will be displayed.
Link Error 2001
If you do not link the Crypto++ Library to the project, LINK 2001 (LNK2001), errors similar to those below will be displayed.
To resolve this, add the following to StdAfx.h (if using precompiled headers) or to the source file using Crypto++.
#ifdef _DEBUG
# pragma comment ( lib, "cryptlibd" )
#else
# pragma comment ( lib, "cryptlib" )
#endif
Alternately, one can add the Crypto++ Library through the Visual C++ IDE.
Link Error 2001
The Crypto++ output libraries are located at Win32\output\debug\cryptlib.lib and Win32\output\release\cryptlib.lib. The DLL and its export library are in Win32\dll_output. Note the "dll_" in the path name. Verify that you are using the correct paths.
Link Error 2005
If you do not change C Runtime Library settings on the Project, LINK 2005 (LNK2005), then errors similar to those below will be displayed.
You should use the Multithreaded versions of the C++ Runtime Library:
Link Error 2005 When Using ATL
Should you encounter LNK2005 when using ATL, recompile the Crypto++ library using the Multithreaded DLL and Multithreaded Debug DLL choices of the runtime library. This was not an issue in Visual C++ 6.0, but it is an issue in Visual Studio 2005.
Link Error 2019 When Using the FIPS DLL
This error is due to the FIPS DLL only exporting certified algorithms such as AES. Wei offers two solutions to the issue. First, you can statically link against the library. Second, you must use the DLL version of the library (not the FIPS DLL). Then, to export the missing classes of interest, add the CRYPTOPP_DLL macro to the class declaration. Then rebuild the DLL-Import project.
Integer Class std::cout Formatting

As distributed, the Integer class displays a suffix ('o', '.', or 'h') to denote base. In addition, the library uses uppercase characters for all hexadecimal output. To change the behavior so that Integer does not use a suffix and honors ios::uppercase flag, perform the following. First, remove the declaration for suffix and change the switch statement.
switch(f)
{
case std::ios::oct :
base = 8;
block = 8;
break;
case std::ios::hex :
base = 16;
block = 4;
break;
default :
base = 10;
block = 3;
}
Next, add the following.
const char* vec = NULL;
const char upper[]="0123456789ABCDEF";
const char lower[]="0123456789abcdef";
if( out.flags() & (long)std::ios::uppercase )
{ vec = upper; }
else
{ vec = lower; }
...
return out;

Revisions
- 01.12.2009 Added Benchmark links
- 07.08.2008 Added link to NIST certification FAQ
- 05.27.2008 Added Adhoc.cpp Information
- 05.27.2008 Added Dr. Chirico's Windows CE port
- 05.25.2008 Removed HashFilter AlgorithmName() fix
- 05.25.2008 Added Alternate Configuration (Static and Dynamic C Runtime Projects)
- 04.20.2008 Added Alternate Website and Download Links
- 03.21.2008 Added Managed Code Section
- 02.22.2008 Added Link Error 2019 (LNK2019)
- 02.22.2008 Added information on CRYPTOPP_DLL macro
- 11.29.2007 Added Single versus Multi-Threaded
- 11.28.2007 Added FIPS Compliance Section
- 11.28.2007 Reworked Static versus Dynamic Linking Section
- 11.28.2007 Removed Sample Project
- 06.04.2007 Added Link Error 2005 when using ATL (LNK2005)
- 12.31.2006 Added Crypto++ Wiki Site Link
- 12.27.2006 Updated Crypto++ Class and Library Reference (Crypto++ 5.4 Release)
- 12.23.2006 Added Additional Fix to Internal Compiler Error (C1001)
- 12.22.2006 Added Link to Chris Deter's Comments
- 12.22.2006 Added Startup Project Information
- 12.17.2006 Added Link Error 1103 (LNK1103)
- 12.15.2006 Updated Article Graphics
- 12.13.2006 Added HashFilter AlgorithName()
- 12.13.2006 Added FAQ, User Guide, and Crypto++ user Newsgroup
- 12.12.2006 Added Compile Warning 4530
- 12.11.2006 Added VC7 Directories Dialog
- 12.09.2006 Added Unicode Library Installation
- 12.09.2006 Added Additional Fix Internal Compiler Error (C1001)
- 11.21.2006 Added Internal Compiler Error (C1001)
- 11.16.2006 Added Integer
std::cout Formatting
- 11.15.2006 Added Static versus Dynamic Crytpo++ Linking
- 11.14.2006 Initial Release
| You must Sign In to use this message board. |
|
|
 |
|
 |
hi,
i am trying to do a comparison between RSA and ECC as encryption methods not as signingmethods,in C# language can i do that using crypto++ and visual studio 2008 C#? i tried to use the CNG in .NET 3.5 but it seems that the implementation of ECC in .NET is the ECDsaCNG class is for signing and no Encrypt()method avaliable like the Encrypt method in RSAcryptoServiceProvider class, so can i do the comparison in Crypt++ on visualstudio 2008 C#?
thanks alot
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi All,
Good day!
I am getting some linking errors while linking cryptopp.lib(which is created using cryptopp521) to my application. I created cryptopp.lib using Microsoft Visual Studio .Net 2003.
encryption.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@PAVBufferedTr ansformation@1@_NH@Z)
encryption.obj : error LNK2001: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std ::allocator<char> > const CryptoPP::BufferedTransformation::NULL_CHANNEL" (?NULL_CHANNEL@BufferedTransformation@CryptoPP@@2V?$basic_string@DU?$ char_traits@D@std@@V?$allocator@D@2@@std@@B)
encryption.obj : error LNK2001: unresolved external symbol "class CryptoPP::NullNameValuePairs const CryptoPP::g_nullNameValuePairs" (?g_nullNa meValuePairs@CryptoPP@@3VNullNameValuePairs@1@B)
encryption.obj : error LNK2001: unresolved external symbol "bool (__cdecl* CryptoPP::AssignIntToInteger)(class type_info const &,void *,void co nst *)" (?AssignIntToInteger@CryptoPP@@3P6A_NABVtype_info@@PAXPBX@ZA)
As said above, under Unresolved External Symbols i tried using
void CRYPTOPP_DLL Base64Encoder::IsolatedInitialize(const NameValuePairs ¶meters) in base64.cpp class CRYPTOPP_DLL Base64Encoder : public SimpleProxyFilter in base64.h
but still it is giving same errors. correct me if i am doing anything wrong.
Any help would be appreciated
Thanks Mahesh
|
| Sign In·View Thread·PermaLink | 1.00/5 |
|
|
|
 |
|
 |
I run into the following compile error when building dlltest.cpp with VS 2008: program files (x86)\microsoft visual studio 9.0\vc\include\intrin.h(204) : error C2373: '_InterlockedCompareExchange' : redefinition; different type modifiers
Anyone know the cause and/or a work around?
Thanks
Curt
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Might be some bug in VS related to SP1...
This worked for me:
#define _DO_NOT_DECLARE_INTERLOCKED_INTRINSICS_IN_MEMORY #include
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hello....
I have a ASP.NET page that sends an excrypted text to an ASP page using DES algorithm. On the other hand, the ASP page needs to retrieve that encrypted text and decrypt it.
In order to test encryption and decryption I am only encrypting a simple text using .NET and using Crypto++ library, which I wrapped in a COM+ component that is feasible to call from ASP.
The text I'm encrypting is only "h". The problem is that both environments generate different outputs.
This is how I'm encrypting in C#:
private byte[] key = { 0x21, 0x23, 0x24, 0x61, 0x35, 0x34, 0x3F, 0x33 }; private byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF }; DESCryptoServiceProvider des = new DESCryptoServiceProvider(); byte[] inputByteArray = Encoding.UTF8.GetBytes("h"); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(key, IV), CryptoStreamMode.Write); cs.Write(inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock();
The resulting array is: {Dimensions:[8]} [0]: 75 [1]: 255 [2]: 52 [3]: 167 [4]: 230 [5]: 34 [6]: 45 [7]: 39
And this is how I'm using Crypto++ library:
const byte key[] = {0x21, 0x23, 0x24, 0x61, 0x35, 0x34, 0x3f, 0x33}; const byte iv[] = {0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef};
byte plaintext[8]; memset(plaintext, 0, 8); plaintext[0] = 'h'; byte ciphertext[8];
CFB_FIPS_Mode::Encryption encryption_DES; encryption_DES.SetKeyWithIV(key, sizeof(key), iv); encryption_DES.ProcessString(ciphertext, plaintext, 8);
The resulting array is: {Dimensions:[8]} [0]: 166 [1]: 62 [2]: 35 [3]: 66 [4]: 62 [5]: 68 [6]: 110 [7]: 8
As you see, radically different results. What is wrong? The more frustrating thing is that when I decrypt, using the same library, for example, Crypto++, I get the original string.
Any help will be greatly appreciated Thanks
Jaime
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Finally I have found what was happening.
The problem was in Cipher Mode used and how the string was padded. I checked that .NET DESCryptoServiceProvider was using CBC cipher mode by default, and PKCS #7 padding mode.
By looking at the C++ code I realized that I was padding the string with 0x00 and using CFB mode (CFB_FIPS_Mode<DES>::Encryption).
The problem was solved by using CBC_Mode<DES>::Encryption instead and padding with the appropriate byte, according to .NET DESCryptoServiceProvider defaults.
Thanks anyway!
Jaime
|
| Sign In·View Thread·PermaLink | 3.00/5 |
|
|
|
 |
|
|
 |
|
 |
My code stopped working after upgrading to v5.6.0 and the reason is that CryptoPP started using RTTI while I didn't have RTTI turned on in my project.
FYI.
Jeff, can you please update the the article to reflect the fact that RTTI is a mandatory requirement starting v5.6.0?
Thanks,
Avi.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I made some corrections to the VC90 projects files but still the test projects do not link. Keep in mind to test them only on VC90+SP1 and latest release on libcrypt.
Here are the new files: http://nusunt.eu/wp-content/uploads/2009/04/cryptlib_vc9_proj_v2.zip[^]
Maybe someone can take a look and solve the problem with the test applications?
After this I will try to sent them for inclusion in the library codebase.
Errors: 1>------ Build started: Project: cryptdll, Configuration: Debug Win32 ------ 1>Linking... 1> Creating library c:\dev\pj\src\contrib\crypto\Win32\DLL_Output\Debug\cryptopp.lib and object c:\dev\pj\src\contrib\crypto\Win32\DLL_Output\Debug\cryptopp.exp 1>dll.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall CryptoPP::GCM_Base::GCTR::IncrementCounterBy256(void)" (?IncrementCounterBy256@GCTR@GCM_Base@CryptoPP@@MAEXXZ) 1>fipstest.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall CryptoPP::GCM_Base::GCTR::IncrementCounterBy256(void)" (?IncrementCounterBy256@GCTR@GCM_Base@CryptoPP@@MAEXXZ) 1>Win32\DLL_Output\Debug\cryptopp.dll : fatal error LNK1120: 1 unresolved externals
2>------ Build started: Project: cryptest, Configuration: Release Win32 ------ 2>Linking... 2>bench.obj : error LNK2001: unresolved external symbol "public: __thiscall CryptoPP::Algorithm::Algorithm(bool)" (??0Algorithm@CryptoPP@@QAE@_N@Z) 2>bench.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CryptoPP::RandomNumberGenerator::GenerateIntoBufferedTransformation(class CryptoPP::BufferedTransformation &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned __int64)" (?GenerateIntoBufferedTransformation@RandomNumberGenerator@CryptoPP@@UAEXAAVBufferedTransformation@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z) 2>bench.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CryptoPP::RandomNumberGenerator::DiscardBytes(unsigned int)" (?DiscardBytes@RandomNumberGenerator@CryptoPP@@UAEXI@Z) ... 2>Win32\Output\Release\cryptest.exe : fatal error LNK1120: 641 unresolved externals
Best regards, Sorin Sbarnea
|
| Sign In·View Thread·PermaLink | 4.00/5 |
|
|
|
 |
|
 |
Hi Sorin,
Mode such as EAX, CCM, and GCM were recently added, so I would not expect that Wei includes them in Dll Test (at least not at this point). There is some talks of a possible future FIPS certification. At that time, I would expect that CCM and GCM modes will be added. But EAX is like DES - it not a FIPS approved algorithm - so it most likely will not be included.
Jeff
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I don't see how this does relates to my question but I see that compiling & linking cryptolib is still a hard task.
I would like to see the day when you download the src and compile it without problems on VC9.
Best regards, Sorin Sbarnea
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Sorin,
> I don't see how this does relates to my question Project cryptdll did not build. So I would not expect that a dependency of cryptdll (dlltest) to build properly.
> I would like to see the day when you download the > src and compile it without problems on VC9. I've already done it. I posted the original ZIP file.
Jeff
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hi Sorin,
> they do no work well on multi-core machines on Vista/W7. I don't believe cores/processors is the issue. I use a dual processor machine (not dual core) which does not have a problem.
> ...Vista/W7 This could be a problem during builds (I know there is not a problem running cryptest.exe on Vista). I scavenged my Vista machine for a Linux box (I wanted to test Metasploit's Automation tests using Ruby on Rails), so I can't test the configuration right now.
> PS. I do not understand how it comes that on > http://www.cryptopp.com/[^] it appears that it > does compile MSVC 2008 SP1 without modifications > because it doesn't. Perhaps you can offer a patch and a note explaining the issue to Wei. He actively monitors the Crypto++ mailing list: cryptopp-users@googlegroups.com.
Jeff
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I still have a single linking issue:
cryptlibd.dynamic.lib(dll.obj) : error LNK2001: unresolved external symbol "protected: virtual void __thiscall CryptoPP::GCM_Base::GCTR::IncrementCounterBy256(void)" (?IncrementCounterBy256@GCTR@GCM_Base@CryptoPP@@MAEXXZ)
Any hints on how to get over it? (I compiled the lib using using CRYPTOPP_EXPORTS)
Be sure I will provide the patch as soon I see it working, last week I observed a small issue on the vc8 project files and Wei corrected it.
Best regards, Sorin Sbarnea
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Thanks, now it works! 
Do you know how to make the other 3 projects (cryptdll,cryptest, dlltest) compile? I would like to solve them in order to be able to send the entire set of project files to Wei for inclusion. I'm sure there are other people looking for them.
Best regards, Sorin Sbarnea
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Sorin,
I've downloaded the VC9 solution and project. So I'll try to touch up the configuration. I am using XP, so I may not encounter some of the issues you see with Vista (at this point in time). I'll try to get Sean the updated ZIP file to upload (CodeProject takes these abilities away from authors, so the delay will be on the CP side).
> Do you know how to make the other 3 projects > (cryptdll, cryptest, dlltest) compile? cryptest _should_ build. In all fairness, there should be both a cryptest.static and cryptest.dynamic.
I don't worry too much about the DLLs since I generally work with the static libraries (*.lib). Are you using the *.lib or *.dll file in your project? If you are not using the *.dll, delete the projects.
Jeff
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
> Do you know how to make the other 3 projects > (cryptdll,cryptest, dlltest) compile I emailed the updated project files to Sean. All projects compile cleanly (at level 3). I don't know when he will be able to copy over for download. Perhaps you can email the webmaster. Chris or Sean should answer rather quickly.
GCM.h required the following tweak:
class CRYPTOPP_DLL GCTR: public CTR_Mode_ExternalCipher::Encryption { protected: void IncrementCounterBy256(); }; Jeff
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Jeffrey Walton wrote: class CRYPTOPP_DLL GCTR: public CTR_Mode_ExternalCipher::Encryption { protected: void IncrementCounterBy256(); };
I submitted a patch to Wei. I don't know when it will be incorporated into SVN.
Jeff
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Sorin,
> Any hints on how to get over it? Some of the base GCM stuff is missing CRYPTOPP_DLL CRYPTOPP_NO_VTABLE. Please add it. Don't miss the inner class of GCM_Base.
Jeff
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
There are some linking problems. How can i solve? urgent please
Project: MSVS9.0, C++, MFC, MFC Ext. DLL
1>Linking... 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct>,class std::allocator >::~basic_string<char,struct>,class std::allocator >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in cryptlib.lib(cryptlib.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_string<char,struct>,class std::allocator > & __thiscall std::basic_string<char,struct>,class std::allocator >::operator=(class std::basic_string<char,struct>,class std::allocator > const &)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@ABV01@@Z) already defined in cryptlib.lib(cryptlib.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct>,class std::allocator >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) already defined in cryptlib.lib(cryptlib.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct>,class std::allocator >::basic_string<char,struct>,class std::allocator >(class std::basic_string<char,struct>,class std::allocator > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in cryptlib.lib(cryptlib.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_string<char,struct>,class std::allocator > & __thiscall std::basic_string<char,struct>,class std::allocator >::operator+=(char const *)" (??Y?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@Z) already defined in cryptlib.lib(cryptlib.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct>,class std::allocator >::basic_string<char,struct>,class std::allocator >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in cryptlib.lib(cryptlib.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: unsigned int __thiscall std::basic_string<char,struct>,class std::allocator >::size(void)const " (?size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) already defined in cryptlib.lib(cryptlib.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::_Container_base_secure::_Orphan_all(void)const " (?_Orphan_all@_Container_base_secure@std@@QBEXXZ) already defined in cryptlib.lib(cryptlib.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::_Container_base_secure::~_Container_base_secure(void)" (??1_Container_base_secure@std@@QAE@XZ) already defined in cryptlib.lib(cryptlib.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::_Container_base_secure::_Container_base_secure(void)" (??0_Container_base_secure@std@@QAE@XZ) already defined in cryptlib.lib(cryptlib.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: static unsigned int __cdecl std::char_traits::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in cryptlib.lib(cryptlib.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "class std::basic_string<char,struct>,class std::allocator > __cdecl std::operator+<char,struct>,class std::allocator >(class std::basic_string<char,struct>,class std::allocator > const &,char const *)" (??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@ABV10@PBD@Z) already defined in cryptlib.lib(cryptlib.obj)
|
| Sign In·View Thread·PermaLink | 5.00/5 |
|
|
|
 |
|
 |
Mehmet Suyuti Dindar wrote: urgent please
Urgent for you - some of us do have day jobs, mine keeps me busy 6 days a week ..
Unfortunately, I dont havnt this compiler - Im still on VC6
What headers are you including (and in what order) ?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hello,
I would like to know how to use the crypto++ dll from Visual Basic, C# or any other language to acomplish the use of DES encription.
Thanks in advance.
P.S.: I already searched in the wiki help of crypto++.
Mark Paint. Education is the ability to listen to everything without losing your temper and self-confidence.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|