Crypto++ 5.6.0 をビルド

環境

手順

  1. cryptopp560.zip を入手し,D:\Develop\cryptopp に展開
  2. cryptest.sln を開く
  3. cryptopp.rc をテキストエディタで開き,10行目を編集する
    • include するものを afxres.h から windows.h に変更する
  4. 構成を DLL-Import Release とし,ソリューションのビルドを(依存関係の解明が面倒だから)エラーが出なくなるまで繰り返す

テスト

Win32\DLL_Output\Release に生成物が展開される.cryptest.exe や dlltest.exe を実行してテストできるらしい.こけた.

DLL-Import Debug 構成でビルドし,cryptest プロジェクトをデバッグ実行すると cryptlib.cpp 49行目のスローが発生した.部分コードを掲載する.throw が2つあるが,下側の throw が49行目.

Algorithm::Algorithm(bool checkSelfTestStatus)
{
	if (checkSelfTestStatus && FIPS_140_2_ComplianceEnabled())
	{
		if (GetPowerUpSelfTestStatus() == POWER_UP_SELF_TEST_NOT_DONE && !PowerUpSelfTestInProgressOnThisThread())
			throw SelfTestFailure("Cryptographic algorithms are disabled before the power-up self tests are performed.");

		if (GetPowerUpSelfTestStatus() == POWER_UP_SELF_TEST_FAILED)
			throw SelfTestFailure("Cryptographic algorithms are disabled after a power-up self test failed.");
	}
}

dlltest プロジェクトはどうかとデバッグ実行すると,こちらもこけた.

よって今は利用を諦めようかと考えている.

悪あがき

ビルド構成は他に Debug と Release とがある.こちらを試す.

Debug,Release 構成のどちらでも cryptest の実行が成功し,dlltest の実行に失敗する.

cryptest

コマンドウインドウの内容を示す.Usage らしい.

Test Driver for Crypto++(R) Library, a C++ Class Library of Cryptographic Scheme
s

- To generate an RSA key
        cryptest g

- To encrypt and decrypt a string using RSA
        cryptest r

- To sign a file using RSA
        cryptest rs privatekeyfile messagefile signaturefile

- To verify a signature of a file using RSA
        cryptest rv publickeyfile messagefile signaturefile

- To digest a file using several hash functions in parallel
        cryptest m file

- To encrypt and decrypt a string using DES-EDE in CBC mode
        cryptest t

- To encrypt or decrypt a file
        cryptest e|d input output

- To secret share a file (shares will be named file.000, file.001, etc)
        cryptest ss threshold number-of-shares file

- To reconstruct a secret-shared file
        cryptest sr file share1 share2 [....]
        (number of shares given must be equal to threshold)

- To information disperse a file (shares will be named file.000, file.001, etc)
        cryptest id threshold number-of-shares file

- To reconstruct an information-dispersed file
        cryptest ir file share1 share2 [....]
        (number of shares given must be equal to threshold)

- To gzip a file
        cryptest z compression-level input output

- To gunzip a file
        cryptest u input output

- To encrypt a file with AES in CTR mode
        cryptest ae input output

- To base64 encode a file
        cryptest e64 input output

- To base64 decode a file
        cryptest d64 input output

- To hex encode a file
        cryptest e16 input output

- To hex decode a file
        cryptest d16 input output

- To forward a TCP connection
        cryptest ft source-port destination-host destination-port

- To run the FIPS 140-2 sample application
        cryptest fips

- To generate 100000 random files using FIPS Approved X.917 RNG
        cryptest fips-rand

- To run Maurer's randomness test on a file
        cryptest mt input

- To run a test script (available in TestVectors subdirectory)
        cryptest tv filename

- To run validation tests
        cryptest v

- To display version number
       cryptest V

- To run benchmarks
        cryptest b [time allocated for each benchmark in seconds] [frequency of
CPU in gigahertz]
dlltest

Release ビルドデバッグ実行時の出力タブ

'dlltest.exe': 'D:\Develop\cryptopp\Win32\DLL_Output\Release\dlltest.exe' を読み込みました。シンボルが読み込まれました。
'dlltest.exe': 'C:\Windows\System32\ntdll.dll' を読み込みました
'dlltest.exe': 'C:\Windows\System32\kernel32.dll' を読み込みました
'dlltest.exe': 'D:\Develop\cryptopp\Win32\DLL_Output\Release\cryptopp.dll' を読み込みました。シンボルが読み込まれました。
'dlltest.exe': 'C:\Windows\System32\advapi32.dll' を読み込みました
'dlltest.exe': 'C:\Windows\System32\rpcrt4.dll' を読み込みました
In memory integrity check failed. This may be caused by debug breakpoints or DLL relocation.
Crypto++ DLL integrity check failed. Actual MAC is: FAE06A4B3AADB707B80A4ABB4CD71F15408A9789
dlltest.exe の 0x765d42eb で初回の例外が発生しました: Microsoft C++ の例外: int (メモリの場所 0x0012f9c4)。
プログラム '[1616] dlltest.exe: ネイティブ' はコード 3 (0x3) で終了しました。

スタティックリンク版については希望をもっていいのだろうか.