2

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?

Yunnosch
  • 26,130
  • 9
  • 42
  • 54
Deanie
  • 2,316
  • 2
  • 19
  • 35
  • Chances are that you have openssl 1.1.0 or later, and that you are using previously deprecated and now fully removed functionality. See answer below – Ahmed Masud Dec 31 '17 at 22:31

1 Answers1

4

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);
Ahmed Masud
  • 21,655
  • 3
  • 33
  • 58