函数的隐式声明 'BN_init' 错误
Implicit declaration of function 'BN_init' error
我正在检查如何从私人比特币地址生成 public 密钥。
我找到了以下页面:
How do I obtain the public key from an ECDSA private key in OpenSSL?
但是当我尝试使用 gcc -Wall -Werror -O3 -o public_key public_key.c -lcrypto
进行编译时,出现以下错误:
public_key.c: In function 'generate_pubic_key':
public_key.c:26:13: error: storage size of 'start' isn't known
BIGNUM start;
^~~~~
public_key.c:32:6: error: implicit declaration of function 'BN_init' [-Werror=implicit-function-declaration]
BN_init(&start);
^~~~~~~
public_key.c:26:13: error: unused variable 'start' [-Werror=unused-variable]
BIGNUM start;
^~~~~
cc1: all warnings being treated as errors
我已经安装了 OpenSSL,并且直到现在还没有遇到任何与之相关的编程错误。有人可以指出我做错了什么吗?
您正在使用 已弃用 已删除 API。
根据 BN_new(3) 手册页:
删除的功能
void BN_init(BIGNUM *);
BN_init() is no longer available as of OpenSSL 1.1.0. It was used to
initialize an existing uninitialized BIGNUM. Typically this would be
done as follows:
BIGNUM a;
BN_init(&a);
Applications should replace use of BN_init with BN_new instead:
BIGNUM *a;
a = BN_new();
if(!a) /* Handle error */
...
BN_free(a);
我正在检查如何从私人比特币地址生成 public 密钥。
我找到了以下页面:
How do I obtain the public key from an ECDSA private key in OpenSSL?
但是当我尝试使用 gcc -Wall -Werror -O3 -o public_key public_key.c -lcrypto
进行编译时,出现以下错误:
public_key.c: In function 'generate_pubic_key':
public_key.c:26:13: error: storage size of 'start' isn't known
BIGNUM start;
^~~~~
public_key.c:32:6: error: implicit declaration of function 'BN_init' [-Werror=implicit-function-declaration]
BN_init(&start);
^~~~~~~
public_key.c:26:13: error: unused variable 'start' [-Werror=unused-variable]
BIGNUM start;
^~~~~
cc1: all warnings being treated as errors
我已经安装了 OpenSSL,并且直到现在还没有遇到任何与之相关的编程错误。有人可以指出我做错了什么吗?
您正在使用 已弃用 已删除 API。
根据 BN_new(3) 手册页:
删除的功能 void BN_init(BIGNUM *);
BN_init() is no longer available as of OpenSSL 1.1.0. It was used to initialize an existing uninitialized BIGNUM. Typically this would be done as follows:
BIGNUM a; BN_init(&a);
Applications should replace use of BN_init with BN_new instead:
BIGNUM *a; a = BN_new(); if(!a) /* Handle error */ ... BN_free(a);