On 22/05/12 17:35, Khuc, Chuong D. wrote:
Hello,
Thank you so much for your response. I already sent an email to ask my colleague to find
out what curve I should use. However, when I tried using either NID_secp256k1 or
NID_X9_62_prime256v1 (because they are the only two curves of 256 bit). I keep getting
segmentation fault, so I never saw the print out of "Got here 2" from my code:
printf("Got here 1!\r\n");
EC_KEY *eckey; = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); // or
NID_secp256k1
printf("Got here 2!\r\n");
if(eckey == NULL)
{
printf("ERROR: NULL EC_KEY!\r\n");
return 0;
}
I know it's very likely to be user's error again (sorry I'm new at openssl).
But do you guys know the cause of this seg fault? Thank you very much.
Hmmm....odd.
Your code looks ok - apart from there appears to be a spurious ; in this
line:
EC_KEY *eckey; = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); // or
NID_secp256k1
However, I would have expected that to produce a compilation error, not
a seg fault!
The following code compiled and worked as expected on my machine:
#include <openssl/ssl.h>
int main (int argc, char *argv[])
{
/* one-time initialization */
ERR_load_crypto_strings();
OpenSSL_add_all_algorithms();
printf("Got here 1!\r\n");
EC_KEY *eckey = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
// or NID_secp256k1
printf("Got here 2!\r\n");
if(eckey == NULL)
{
printf("ERROR: NULL EC_KEY!\r\n");
return 0;
}
return 1;
}
Output was:
Got here 1!
Got here 2!
Matt
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majord...@openssl.org