<div dir="ltr">Hello Dave,<div><br></div><div>Based on your input, have stopped calling i2d_ECDSA_SIG() and used BN_bn2bin() to overcome the der headers. </div><div><br></div><div>And now, my verification is working fine. </div><div><br></div><div>Is there any function at openssl, to get the HASH used for the digest at ECDSA_verify()?</div><div><br></div><div>I see that, for ECDSA_verify(), first argument is type. But when its calling the function pointer, ECDSA_verify() is not passing the type of the hash. </div><div><br></div><div>So, would like to get the hash type from digest data. </div><div><br></div><div>I can understand that for TLS1.2, openssl uses SHA512. But the same information i would like to get from digest data. Is there any way to get this? Please share. </div><div><br></div><div>Thanks,</div><div>Rajeswari.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Feb 14, 2015 at 1:24 AM, Dave Thompson <span dir="ltr"><<a href="mailto:dthompson@prinpay.com" target="_blank">dthompson@prinpay.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> From: openssl-users On Behalf Of Rajeswari K<br>
</span>> Sent: Friday, February 13, 2015 09:48<br>
<snip><br>
> As part of [ECDSA] signature verification, we first take lenght_of_signature received<br>
<span class="">> and compare with double the size of number_of_bytes from curve parameter.<br>
> Have converted the ECDSA_SIG to unsigned char * using the function i2d_ECDSA_SIG().<br>
> Length returned by i2d_ECDSA_SIG() is 103.<br>
> Whereas, the number_of_bytes value from curve parameter is 48.<br>
<br>
</span>An EDCSA signature, like a DSA signature, and as the 'i2d' should clue you in,<br>
is an ASN1 DER-encoded value. Specifically it is a SEQUENCE of two INTEGERs.<br>
That means it consists of:<br>
<br>
2 octets tag and length for the sequence -- OR 3 if the components together<br>
exceed 127 octets, which will occur almost always if the curve size exceeds<br>
496 bits and sometimes for slightly smaller curves, see below.<br>
<br>
For each integer, 2 octets tag and length then N octets value, as long as the<br>
curve size does not exceed 1015 bits (and none currently come even close).<br>
Remember DER INTEGERs are two's complement, and the R and S values<br>
are positive numbers that are for practical purposes uniform random up to<br>
the curve order which is usually chosen to be nearly a power of two that<br>
is a multiple of 8 (like 192, 256, 384) and thus require an extra sign octet.<br>
<br>
Thus for a 384-bit curve, the encoded signature will be 6+2*48=102<br>
roughly 25% of the time, 6+48+49 about 50% and 6+49*2 about 25%.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
_______________________________________________<br>
openssl-users mailing list<br>
To unsubscribe: <a href="https://mta.openssl.org/mailman/listinfo/openssl-users" target="_blank">https://mta.openssl.org/mailman/listinfo/openssl-users</a><br>
</div></div></blockquote></div><br></div>