0

Calling the following method produces a segmentation fault on the BN_bin2bn call:

#include <openssl/ec.h>
#define ECIES_PUBLIC_KEY_SIZE 32

static int doBin2Bn(const uint8_t* someValue)
{
    BIGNUM *bn = NULL;
    bn = BN_new();
    BN_bin2bn(someValue, ECIES_PUBLIC_KEY_SIZE, bn);
}

The value of someValue in %02x format is 33313338.

Why would this cause a seg fault?

Brandon
  • 13,956
  • 16
  • 72
  • 114
  • 1
    The buffer pointed to by someValue must not be 32 bytes long. Post how you are calling the function; without seeing how you coming up with someValue it's hard to offer much help. – idz Oct 19 '17 at 05:49
  • *"How to troubleshoot OpenSSL BN_bin2bn()..."* - Compile OpenSSL and your program at `-O1`, and then use Valgrind. Valgrind requests `-O1`; see [The Valgrind Quick Start Guide](http://valgrind.org/docs/manual/quick-start.html#quick-start.prepare). – jww Oct 19 '17 at 07:47

0 Answers0