简体   繁体   中英

Implicit declaration of function 'BN_init' error

I was checking out how to generate public keys from a private bitcoin address.
I found the following page:
How do I obtain the public key from an ECDSA private key in OpenSSL?

But when I try to compile with gcc -Wall -Werror -O3 -o public_key public_key.c -lcrypto , I get the following errors:

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

I have OpenSSL installed and haven't had any programing errors related to it, until now. Can someone point out what it is that I'm doing wrong?

You are using deprecated removed API.

As per BN_new(3) man page:

REMOVED FUNCTIONALITY 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); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM