【发布时间】:2019-09-10 19:06:00
【问题描述】:
我正在使用带有 OpenSSL (https://openssl.org/docs/fips/UserGuide-2.0.pdf) 的 FIPS 140-2 模块。我正在编写一个只获得 FIPS 模式的应用程序。
这是我的 Makefile:
TOOLCHAIN:=/home/marcos/work/nitere/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin:$PATH
CROSS_COMPILE:=arm-linux-gnueabihf-
OPENSSLDIR = /usr/local/ssl
INCLUDES = -I$(OPENSSLDIR)/include -I$(OPENSSLDIR)/fips-2.0/include
LIBS= -lcrypto
PATH:=${TOOLCHAIN}:${PATH}
all:
${CROSS_COMPILE}gcc fipsctl.c -o fipsctl $(INCLUDES) $(LIBS)
clean:
rm -Rf *.o fipsctl
这是我的代码:
#include <openssl/crypto.h>
#include <stdio.h>
...
int mode = FIPS_mode();
if(mode == 0)
{
printf("*** FIPS module is disabled. ***");
}
if(mode == 1)
{
printf("*** FIPS module is enabled. ***");
}
当我尝试交叉编译时,我得到了这个错误:
marcos@marcos-X450LD:~/work/nitere/app/nitere$ make
arm-linux-gnueabihf-gcc fipsctl.c -o fipsctl -I/usr/local/ssl/include -I/usr/local/ssl/fips-2.0/include -Lcrypto
/tmp/ccSQhRme.o: In function main': fipsctl.c:(.text+0x1a): undefined reference to `FIPS_mode
collect2: error: ld returned 1 exit status
make: *** [all] Error 1
有人知道我为什么会收到这个错误吗?
任何提示都会非常有帮助, 谢谢。
【问题讨论】:
-
我相信您需要构建/安装 FIPS 对象模块。这就是
*-fips-*下载。例如,openssl-fips-2.0.11.tar.gz。 -
您的 makefile 显示
-lcryptolowercase-ell 但您的日志显示-Lcryptouppercase-ell;是哪一个?如果您的 makefile 中确实有大写字母,那是错误的。 @jww:应用程序不会直接调用 FIPS 模块,只能通过“支持 FIPS 的”OpenSSL 库。如果FIPS_mode确实链接但在执行时返回 false,则可能是缺少 FIPS 模块。 -
感谢您的回答!我使用 ./config fips 安装了 FIPS 对象模块和 OpenSSL。我忘了包含一些参数吗?有没有办法检查我的 OpenSSL 安装是否支持 FIPS 140-2?