On Tue, Mar 18, 2014, axisofevil wrote: > I dug into source - it's in DER format so a sleezy hacked function is this: ( > I use curve NID_X9_62_prime256v1 ) > ECDSA_SIG * sig > BIGNUM * r; > BIGNUM * s; > > /* A correct DER-encoded signature has the following form: > > 0x30: a header byte indicating a compound structure. > A 1-byte length descriptor for all what follows. > 0x02: a header byte indicating an integer. > A 1-byte length descriptor for the R value > The R coordinate, as a big-endian integer. > 0x02: a header byte indicating an integer. > A 1-byte length descriptor for the S value. > The S coordinate, as a big-endian integer. > */ > > r = BN_bin2bn( src+ 4, 32, NULL ); // create new bn here > s = BN_bin2bn( src+ 4 +32 + 2, 32, NULL ); > > if(!BN_copy(sig->r, r)) goto err; > if(!BN_copy(sig->s, s)) goto err; > >
That wont always work because the number of octets in the ASN1 Integer isn't always the same. The ASN1 function d2i_ECDSA_SIG will corerectly parse the output. 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