1

プロジェクトで暗号化を使用する必要があります (Visual C++ 2008 sp1、いくつかの dll を含む exe、いくつかのサードパーティ ライブラリを使用)。Crypto++ ライブラリを選択しました。静的ライブラリとして使用します。まず、テスト コンソール アプリケーションで必要なすべての機能をテストしたところ、すべて正常に動作しました。

次に、この機能をプロジェクトに統合し始めました。

そして、次のような非常に単純なものを含む、多くの Crypto++ 関数呼び出しでクラッシュします。

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

このコード行の呼び出し中に、アプリケーションは次のようにクラッシュします。

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

これが私のコールスタックです:

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    

私のプロジェクトと Crypto++ の両方で、マルチスレッド DLL ランタイム ライブラリを使用しています。

Crypto++ プロジェクト オプションを自分のプロジェクト オプションと同じになるように変更しようとしましたが、役に立ちません (いくつかの変更の後、別のコール スタックでアプリケーションがクラッシュします)。

どんなアイデアでも大歓迎です!

4

1 に答える 1

1

When I digged into cryptopp I found that it does some hidden validations. One of them was in fipstest.cpp. But try/catch inside of the library hides actual exception message.

When I got correct message I found that parameter passed was simply too short for specific algorithm (RSA). Those 64 bits were just taken from example on the web. When I changed the key to 1024 problem gone.

Cheers ;)

AutoSeededRandomPool prng;
RSA::PrivateKey privKey;
//privKey.GenerateRandomWithKeySize(prng, 64);  <- throws exception
privKey.GenerateRandomWithKeySize(prng, 1024);
于 2012-04-17T18:41:15.353 に答える