Hi list: I'm new to OpenSSL and have a problem when trying BIGNUM usage. The function ERR_get_error() returned 0 when BN_hex2bn() failed:
#include <openssl/bn.h> #include <openssl/err.h> #include <stdlib.h> int main() { int r; char * dec, * hex = "xFFFF"; char errmsg[256]; BIGNUM * b1 = NULL; unsigned long err; ERR_load_crypto_strings(); r = BN_hex2bn(&b1, hex); if (! r) { err = ERR_get_error(); ERR_error_string_n(err, errmsg, sizeof errmsg); fprintf(stderr, "BN_hex2bn(): %s\n", errmsg); exit(1); } dec = BN_bn2dec(b1); printf("0x%s = %s\n", hex, dec); OPENSSL_free(dec); return 0; } When running, it outputs like this: BN_hex2bn(): error:00000000:lib(0):func(0):reason(0) So how can I get the BN_hex2bn() error? Anybody can help? Thanks.