Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Openssl FIPS_模式_集(1)错误:00000000:lib(0):func(0):原因(0)_Openssl_Fips - Fatal编程技术网

Openssl FIPS_模式_集(1)错误:00000000:lib(0):func(0):原因(0)

Openssl FIPS_模式_集(1)错误:00000000:lib(0):func(0):原因(0),openssl,fips,Openssl,Fips,我正在尝试使用以下代码启用FIPS模式: #include <openssl/crypto.h> #include <openssl/err.h> #include <stdio.h> int main ( int argc, char *argv[] ) { #ifdef OPENSSL_FIPS int mode, result; // Get FIPS mode if(strcmp("get",argv[1]) == 0)

我正在尝试使用以下代码启用FIPS模式:

#include <openssl/crypto.h>
#include <openssl/err.h>
#include <stdio.h>

int main ( int argc, char *argv[] )
{
#ifdef OPENSSL_FIPS 
    int mode, result;

    // Get FIPS mode
    if(strcmp("get",argv[1]) == 0)
    {
        mode = FIPS_mode();
        if(mode == 0)
        {
            printf("*** FIPS module is disabled. ***\n");
        }
        if(mode == 1)
        {
            printf("*** FIPS module is enabled. ***\n");
        }
    }

    // Set FIPS mode
    else if(strcmp("set",argv[1]) == 0)
    {
        if(strcmp("0",argv[2]) == 0)
        {
            printf("*** Disabling FIPS module. ***\n");
            result = FIPS_mode_set(0);
            if(result != 1)
            {
                ERR_load_crypto_strings();
                printf("*** Failed to disable FIPS module. ***\n"); 
                printf("%s\n", ERR_error_string(ERR_get_error(), NULL));
                return 1;
            }
        }
        else if (strcmp("1",argv[2]) == 0)
        {
            printf("*** Enabling FIPS module. ***\n");
            result = FIPS_mode_set(1);  
            if(result != 1)
            {
                ERR_load_crypto_strings();
                printf("*** Failed to enable FIPS module. ***\n");  
                printf("%s\n", ERR_error_string(ERR_get_error(), NULL));
                return 1;
            }   
        }
        else
        {
            printf("*** Error: unsupported option. ***\n");
            return 1;
        }
    }

    // Unsupported option
    else
    {
        printf("*** Error: unsupported option. ***\n");
        return 1;
    }

    return 0;

#else 
        printf("OPENSSL_FIPS is not defined"); 

#endif //OPENSSL_FIPS 
}   
它编译时没有错误。当我尝试启用FIPS模式时,我得到以下输出:

arm:~/nitere/new$ ./fipsctl set 1
*** Enabling FIPS module. ***
*** Failed to enable FIPS module. ***
error:00000000:lib(0):func(0):reason(0)
但FIPS仍处于禁用状态:

arm:~/nitere/new$ ./fipsctl get
*** FIPS module is disabled. ***
有人知道怎么回事吗

任何提示都会非常有用


谢谢。

请注意,成功设置FIPS模式只会影响调用
FIPS\u mode\u set
func的程序(直到程序结束或再次调用),因此它不是全局/持久的。此外,我发现支持FIPS的OpenSSL LIB是静态的:为此,您需要遵循(第5.3章-生成应用程序可执行对象),否则最好构建共享版本。
OPENSSL\u FIPS=1/usr/local/ssl/bin/OPENSSL md5/usr/local/ssl/bin/OPENSSL
输出什么?
arm:~/nitere/new$ ./fipsctl get
*** FIPS module is disabled. ***