简体   繁体   English

Crypto ++无法解释的崩溃

[英]Crypto++ unexplained crashes

I need to use cryptography in my project (visual c++ 2008 sp1, exe with several dlls, use some third party libs). 我需要在我的项目中使用加密技术(Visual C ++ 2008 sp1,带有多个dll的exe,使用一些第三方库)。 I chose Crypto++ library. 我选择了Crypto ++库。 I use it as static library. 我将其用作静态库。 First, I tested all functions I need in test console application, and everything works fine. 首先,我测试了测试控制台应用程序中所需的所有功能,并且一切正常。

Then I started to integrate this function to the project. 然后,我开始将此功能集成到项目中。

And it crashes on many of Crypto++ function calls, including very simple like this one: 并且它在许多Crypto ++函数调用上崩溃,包括非常简单的这样的调用:

CryptoPP::FileSource file("publicKeySign.der", true);

During the call of this line of code, application crashes with: 在此代码行的调用过程中,应用程序崩溃并导致:

Unhandled exception at 0x00c56619 in Starter.exe: 0xC0000005: Access violation reading location 0x00006f70.

Here is my call stack: 这是我的调用堆栈:

Starter.exe!CryptoPP::member_ptr<CryptoPP::AlgorithmParametersBase>::reset(CryptoPP::AlgorithmParametersBase * p=0x00000000)  Line 50 + 0x9 bytes   C++
Starter.exe!CryptoPP::AlgorithmParameters::operator()<char const *>(const char * name=0x00d8ec04, const char * const & value=0x00d88a44, bool throwIfNotUsed=true)  Line 356    C++
Starter.exe!CryptoPP::MakeParameters<char const *>(const char * name=0x00d8ec04, const char * const & value=0x00d88a44, bool throwIfNotUsed=true)  Line 388 + 0x2d bytes    C++
Starter.exe!CryptoPP::FileSource::FileSource(const char * filename=0x00d88a44, bool pumpAll=true, CryptoPP::BufferedTransformation * attachment=0x00000000, bool binary=true)  Line 65 + 0x6d bytes C++
Starter.exe!PDD::PDDApp2::Open()  Line 237  C++
Starter.exe!WinMain(HINSTANCE__ * __formal=0x00c50000, HINSTANCE__ * __formal=0x00c50000, HINSTANCE__ * __formal=0x00c50000, HINSTANCE__ * __formal=0x00c50000)  Line 387 + 0xb bytes   C++
Starter.exe!__tmainCRTStartup()  Line 578 + 0x1d bytes  C
kernel32.dll!@BaseThreadInitThunk@12()  + 0x12 bytes    
ntdll.dll!___RtlUserThreadStart@8()  + 0x27 bytes   
ntdll.dll!__RtlUserThreadStart@8()  + 0x1b bytes    

Both my project and Crypto++ use Multi-threaded DLL runtime libraries. 我的项目和Crypto ++都使用多线程DLL运行时库。

I tried to change Crypto++ project options for them to be the same as my project options, but it doesn't help (after some changes application crashes with another call stack). 我试图将其Crypto ++项目选项更改为与我的项目选项相同,但没有帮助(在某些更改后应用程序因另一个调用堆栈而崩溃)。

Any ideas will be appreciated! 任何想法将不胜感激!

When I digged into cryptopp I found that it does some hidden validations. 当我深入研究cryptopp时,发现它进行了一些隐藏的验证。 One of them was in fipstest.cpp. 其中之一在fipstest.cpp中。 But try/catch inside of the library hides actual exception message. 但是库中的try / catch隐藏了实际的异常消息。

When I got correct message I found that parameter passed was simply too short for specific algorithm (RSA). 当我得到正确的消息时,我发现传递的参数对于特定算法(RSA)来说太短了。 Those 64 bits were just taken from example on the web. 这64位只是从网络示例中获取的。 When I changed the key to 1024 problem gone. 当我将密钥更改为1024时,问题消失了。

Cheers ;) 干杯;)

AutoSeededRandomPool prng;
RSA::PrivateKey privKey;
//privKey.GenerateRandomWithKeySize(prng, 64);  <- throws exception
privKey.GenerateRandomWithKeySize(prng, 1024);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM