如何在Windows x64上编译支持fips的openssl?

3

我目前正在使用以下步骤,但编译时遇到了困难:

Add 64bit/32bit NASM to path: C:\Program Files\NASM for 64 bit

//On 32 bit simply switch to x86 native tool
Open native command prompt for VS2015 x64

or run "C:\Program Files (x86)\Microsoft Visual Studio 
14.0\VC\bin\amd64\vcvars64.bat"

== Environment variables that need to be set ==
Set FPSDIR=C:\Dev\OpenSSL\x64\openssl-fips-ecp-2.0.16
Set PROCESSOR_ARCHITECTURE=AMD64

== Building Fips compliant module ==
cd openssl-fips-ecp-2.0.16
xcopy inc32\* include\* /O /X /E /H /K 
=========
Open ms\do_fips.bat and remove "dll"

[Optional] add "debug" to same line

Open util\mk1mf.pl and add "libcmt.lib LIBCPMT.LIB libcmtd.lib LIBCPMTD.LIB" to EX_LIBS (Line 650 typically)
=========

ms\do_fips
mkdir lib
copy out32.dbg\* lib\*
mkdir bin
copy util\* bin\*
copy out32.dbg\fips_standalone_sha1.exe bin

== Building ==
cd openssl-1.0.2l

======
Open util\pl\VC-32.pl
remove "|| $fips " from line 48 and 133

[Optional]Open ms\do_win64a.bat and add "debug" to line 15 right before VC-WIN64A
======

perl Configure VC-WIN64A fips no-ec2m no-shared -DUNICODE -DOPENSSL_THREADS --with-fipsdir=C:\Dev\OpenSSL\x64\openssl-fips-ecp-2.0.16
ms\do_win64a
nmake -f ms\nt.mak clean
nmake -f ms\ntdll.mak clean
nmake -f ms\nt.mak


//On 32 bit be sure to do 32bit dir and
//Configure VC-WIN32
//ms\do_nasm (add debug here too)

编译器出错:
DOPENSSL_THREADS  -DDSO_WIN32 -DOPENSSL_FIPS -DOPENSSL_NO_ERR -DUNICODE -DOPENSSL_THREADS -W3 -Gs0 -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -IC:\Dev\OpenSSL\x64\openssl-fips-ecp-2.0.16/include -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DOPENSSL_NO_RC5 -DOPENSSL_NO_MD2 -DOPENSSL_NO_SSL2 -DOPENSSL_NO_KRB5 -DOPENSSL_FIPS -DOPENSSL_NO_JPAKE -DOPENSSL_NO_WEAK_SSL_CIPHERS -DOPENSSL_NO_DYNAMIC_ENGINE /Zl /Zi /Fdtmp32/lib -c .\crypto\rand\rand_lib.c

rand_lib.c

.\crypto\rand\rand_lib.c(191): error C2143: syntax error: missing ')' before     '*'
.\crypto\rand\rand_lib.c(191): error C2143: syntax error: missing '{' before '*'
.\crypto\rand\rand_lib.c(191): error C2059: syntax error: 'type'
.\crypto\rand\rand_lib.c(192): error C2059: syntax error: ')'

我看了一下代码,似乎它不知道什么。
DRBG_CTX

我搜索了一下,应该从FIPS目录中包含它,但实际上没有,我的构建步骤有什么问题吗?


我已经添加了适当的经过测试的完整构建程序,以防对某些人有帮助。 - Akumaburn
2个回答

3

我找到了,似乎默认情况下,“include”目录由于某种原因填充了0kb的文件。我用FIPS文件夹中32位“include”(inc32)目录的内容覆盖了“include”目录,并且问题似乎已经解决了。


假设您按照 Windows 上发布的 FIPS 程序操作,并且平台得到支持,那么这听起来像是一个 bug。您应该在 OpenSSL GitHub 上报告它。 - jww
目前没有公开的标准程序来静态构建FIPS(nt.mak将生成一个fipscontainer.lib静态库,但它将具有动态符号!),只能作为DLL,即使是这样,由于空文件和Windows的错误make脚本,它也不能正常工作。 - Akumaburn
1
你遇到的情况是因为OpenSSL.org的尼安德特人发布了openssl-fips tarball,并在其中创建了一些符号链接,这些链接无法与Windows基本压缩工具正常展开。如果你将压缩的tarball带到Unix(Linux、MacOS或其他)或Cygwin环境中,使用tar -xzvf提取它(这将解析符号链接),然后立即将其压缩(这将将符号链接复制为文件而不是链接),然后将其带到Windows环境中,所有这些0KB文件将成为应该是的正确副本。这是OpenSSL问题中的又一个小插曲。 - WhozCraig

1

如果有人想知道如何构建它并通过fips自测,请参考以下步骤。

 Add 64bit/32bit NASM to path: C:\Program Files\NASM for 64 bit

//On 32 bit simply switch to x86 native tool and Set PROCESSOR_ARCHITECTURE=x86
Open native command prompt for VS2015 x64
or run "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"

== Environment variables that need to be set ==
Set FPSDIR=C:\Dev\OpenSSL\x64\openssl-fips-ecp-2.0.16
Set PROCESSOR_ARCHITECTURE=AMD64

== Building Fips compliant module ==
cd openssl-fips-ecp-2.0.16

Open util\mk1mf.pl and add
$cflags.= " -DOPENSSL_FIPS_DEBUGGER";
after line 311

This will disable the fingerprint check for the module, whose purpose is to ensure that the source code hasn't been modified(but leave all other tests intact). 
This is done because the fingerprint check appears to be broken for static libraries.

ms\do_fips
mkdir lib
copy out32dll\* lib\*
mkdir bin
copy util\* bin\*
copy out32dll\fips_standalone_sha1.exe bin
xcopy inc32\* include\* /O /X /E /H /K 

== Building ==
cd openssl-1.0.2l
perl Configure VC-WIN64A fips no-ec2m no-shared -DUNICODE -DOPENSSL_FIPS_DEBUGGER -DOPENSSL_THREADS --with-fipsdir=C:\Dev\OpenSSL\openssl-fips-ecp-2.0.16
ms\do_win64a
nmake -f ms\nt.mak clean
nmake -f ms\ntdll.mak clean
nmake -f ms\nt.mak


//On 32 bit be sure to do 32bit dir and
//Configure VC-WIN32 ms\do_nasm

1
禁用指纹检查以使静态链接工作不违反安全策略吗?这有什么意义? - Timothy John Laird
重点是所有实际的FIPS测试都得以保留,虽然它违反了破损的安全策略,但它确实产生了符合FIPS标准的加密。 - Akumaburn
@TimothyJohnLaird 我想发布这个更新,一段时间以前,这个项目已经通过了某政府机构的FIPS认证测试。我觉得值得一提。 - Akumaburn

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接