<div dir="ltr"><span style="font-family:monospace,monospace">ECDSA_verify fails if one of the signature components is negative</span><br><span style="font-family:monospace,monospace"></span><div class="gmail_quote"><div dir="ltr"><span style="font-family:monospace,monospace">because i2d_ECDSA_SIG returns the incorrect size;<br><br>problem is in ecs_vrf.c:<br><br>    derlen = i2d_ECDSA_SIG(s, &der);<br>    if (derlen != sig_len || memcmp(sigbuf, der, derlen))<br>        goto err;<br><br>If signature component is negative derlen is computed as 71 instead of 70.<br>So I get "Public Key operation error" ... but if I comment out the length<br>check I get "Signature Verified Successfully"<br><br>Here is the parse of the signature file. <br><br>openssl asn1parse -i -inform DER -in file -in pub.sig<br>    0:d=0  hl=2 l=  68 cons: SEQUENCE          <br>    2:d=1  hl=2 l=  32 prim:  INTEGER           :<wbr>4C5A2B4F5DF1540481A1B07A7A6007<wbr>284AD69C654AA12863A4B9728B1179<wbr>D0CB<br>   36:d=1  hl=2 l=  32 prim:  INTEGER           :-<wbr>37D6425BDFF8E68263205D4DD798AE<wbr>816B127B439AE29161662B23D15D77<wbr>3C7D<br></span><br><span style="font-family:monospace,monospace">od -t x1 pub.sig <br>0000000 30 44 02 20 4c 5a 2b 4f 5d f1 54 04 81 a1 b0 7a<br>0000020 7a 60 07 28 4a d6 9c 65 4a a1 28 63 a4 b9 72 8b<br>0000040 11 79 d0 cb 02 20 c8 29 bd a4 20 07 19 7d 9c df<br>0000060 a2 b2 28 67 51 7e 94 ed 84 bc 65 1d 6e 9e 99 d4<br>0000100 dc 2e a2 88 c3 83<br>0000106<br></span><br></div>
</div><br></div>