首页 > 解决方案 > C++ 包装器库中的 OpenSSL Fips 如何?Err:指纹不匹配

问题描述

我正在尝试编译一个包含静态 OpenSSL Fips 库的静态包装器 dll。

我已经链接:

C:\Work\win_x64\fipscanister.lib
C:\Work\libeayfips32.lib
C:\Work\ssleay32.lib
ws2_32.lib
crypt32.lib

我还将库的目录包含在包含目录中。

我添加了在 openssl-fip2.0 构建期间生成的 fips_premain.c 文件。我将 SHA1_HASH_SIG 调整为等于 fips_premain.c.sha1 中的值

我正在使用 Visual Studio 2017 来构建我的包装器 dll。我在我的项目中包含了包装器 dll。当我调用 FIPS_mode_set(1) 时,我收到以下错误:

17480:error:2D0A3073:FIPS routines:func(163):fips selftest failed:
.\crypto\ecdh\ech_ossl.c:125: Exception thrown:
'System.Exception' in Test.OpenSSL.dll [Test][11872][26]
ERROR [Native][-] 2018-10-03T01:13:54.971Z ERROR 
Setting fips mode: fingerprint does not match
[Native][11872][27] ERROR [Native][-] 2018-10-03T01:13:54.972Z 
ERROR Setting fips mode: fingerprint does not match Exception thrown: 'System.Exception'
in Test.OpenSSL.dll Exception thrown:
'System.NullReferenceException' in Test.OpenSSL.dll

当我运行nmake f ms\nt.mak test时,所有测试都成功完成

我一定是在某个地方错过了一步,我很好奇其他人是如何让这个工作的。

我建立了这样的图书馆:

perl Configure VC-WIN64A --prefix=C:\Build-OpenSSL-VC-64 
ms\do_win64a 
nmake -f ms\nt.mak  
nmake -f ms\nt.mak install

我使用 openssl-1.0.2p 和 openssl-fips-2.0.16 两者都正确构建,这让我认为这是我构建包装器的方式。或者它可能无法处理散列,因为它被包装了?

标签: c++cwindowsopensslfips

解决方案


所以我不得不将 fips_premain.c 添加到我的 Visual Studio 项目中。运行 fips_premain_dso.exe,传入我的新静态库(确保 fips_premain.c 没有更改,否则它不会生成哈希),然后将哈希值放入 fips_premain.c,然后在 Visual Studio 中重建,它可以工作:D


推荐阅读