Hi Dave, Thank you so much for your reply. I have been struggling with this issue for while. And I tried your method, but I got a problem with EC_KEY_new_by_curve_name: it always return NULL. Here is how I used it: EC_KEY *eckey = EC_KEY_new_by_curve_name(NID_ecdsa_with_SHA256); If(eckey == NULL) { Printf("ERROR: NULL ECKEY!\r\n"); } Do you happen to know the reason? And to answer your question about my 32-uchar array private key: I don't know yet. Another person gave me that private key and asked me to use it to sign the data. I will try to find out more about that. But for now, can you please advise on the previous NULL eckey issue? Again, thanks a lot. Regards, Chuong D. Khuc
On 5/21/12 9:38 PM, "Dave Thompson" <dthomp...@prinpay.com> wrote: >>From: owner-openssl-us...@openssl.org On Behalf Of Khuc, Chuong D. >>Sent: Friday, 18 May, 2012 17:22 > >>I have an ECDSA private key in the form of a 32 byte unsigned char >>array, >>and a data that needs to be signed using that key. So I wrote the >>following > >>code to load the key and use it to sign my data: ><snip: add PEM header/footer> >>in=BIO_new_mem_buf(tempkey,hdrlen+ftrlen+32); >>pkey=PEM_read_bio_ECPrivateKey(in, NULL, NULL, NULL); > >>And right there, pkey is returned to me as NULL. <snip> >>So please tell me what I did wrong. Thank you so much. > >What exactly is in your 32-uchar array? It can't possibly be >a PEM-body or even DER encoding of OpenSSL's ECPrivateKey, >which is minimum 112 chars or 82 bytes respectively. > >It would be the right size to be the raw priv_key value for >some 256-bit curve, perhaps secp256k1 which is fairly common. >If so, it appears to me you can use EC_KEY_new_by_curve_name >and put your privkey in a bignum and use EC_KEY_set_private_key. > > >______________________________________________________________________ >OpenSSL Project http://www.openssl.org >User Support Mailing List openssl-users@openssl.org >Automated List Manager majord...@openssl.org ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org