>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

Reply via email to