On Wed, Nov 09, 2011, Markus Niedermann wrote: > Hi, > I want to use openSSL in C to sign/verify messages with ECDSA > (fixed curve). > Its the first time I use openSSL, maybe my questions are very trivial.. > > How can I import a key that I generated externally to a EC_KEY object? > I have 3 char-arrays: priv, pubX pubY > These keys are not encoded with DER or sth. > > I want to export the key to 3 char-arrays, too. > > The next step is to verify a message with a given signature. > this external signature has 2 char arrays: sigR, sigS > How can I import it to a ECDSA_Sig? > > The other direction would be interesting for me, too! >
Well you need to convert to and from an intermediate BIGNUM structure. You can use BN_bin2bn and BN_bn2bin for that: see manual pages. Once you have those you use EC_KEY_new_by_curve_name() to setup the curve. Then you can use EC_KEY_set_affine_coordinates but that is fairly new so you might instead need to create an EC_POINT and set it using EC_KEY_set_public_key. The private key component can be set with EC_KEY_set_private_key(). Signatures are stored in ECDSA_SIG which can be allocated using ECDSA_SIG_new() and you can set the sig->r and sig->s components. Converting a key back to components is the reverse operation. Steve. -- Dr Stephen N. Henson. OpenSSL project core developer. Commercial tech support now available see: http://www.openssl.org ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org