【问题标题】:undefined reference to `FIPS_mode'未定义对“FIPS_mode”的引用
【发布时间】: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 显示 -lcrypto lowercase-ell 但您的日志显示 -Lcrypto uppercase-ell;是哪一个?如果您的 makefile 中确实有大写字母,那是错误的。 @jww:应用程序不会直接调用 FIPS 模块,只能通过“支持 FIPS 的”OpenSSL 库。如果 FIPS_mode 确实链接但在执行时返回 false,则可能是缺少 FIPS 模块。
  • 感谢您的回答!我使用 ./config fips 安装了 FIPS 对象模块和 OpenSSL。我忘了包含一些参数吗?有没有办法检查我的 OpenSSL 安装是否支持 FIPS 140-2?

标签: openssl fips


【解决方案1】:

我不知道我是否正确安装了 FIPS 模块。我遵循了这些命令:

安装 FIPS:

root@arm:~# cd
root@arm:~# cd openssl-fips-2.0.10
root@arm:~# ./config
root@arm:~# make
root@arm:~# make install

安装支持 FIPS 的 OpenSSL:

root@arm:~# cd 
root@arm:~# wget http://www.openssl.org/source/openssl-1.0.2e.tar.gz
root@arm:~# tar -xzvf openssl-1.0.2e.tar.gz
root@arm:~# cd openssl-1.0.2e
root@arm:~# ./config fips 
root@arm:~# make depend
root@arm:~# make 
root@arm:~# make install

对吗?

【解决方案2】:

您是否使用 FIPS ecp 发行版,如果是的话 在编译 openssl 时尝试使用 no-ec2m 选项,如下所示:

root@arm:~# cd openssl-1.0.2e root@arm:~# ./config fips no-ec2m

在 UserGuide2.pdf 中也提到: "请注意,当使用 "ecp" 发行版时,必须使用 noec2m 选项构建相应的 "FIPS 能力" OpenSSL。"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-27
    • 2022-01-22
    • 2016-04-04
    • 2015-11-03
    • 2011-08-11
    • 2019-07-22
    • 2015-07-20
    • 2019-06-22
    相关资源
    最近更新 更多