<div dir="ltr">Hello Openssl Team,<div><br></div><div>Currently am seeing an issue as follows. </div><div><br></div><div>We would like to use our internal verification logics for the key exchange message received at SSL client. </div><div><br></div><div>As part of this, we have registered with our function pointers. </div><div><br></div><div>ECDSA_verify() is now calling our registered function to perform signature verification. </div><div><br></div><div>As part of signature verification, we first take lenght_of_signature received and compare with double the size of number_of_bytes from curve parameter. </div><div><br></div><div>Have converted the ECDSA_SIG to unsigned char * using the function i2d_ECDSA_SIG().</div><div><br></div><div>Length returned by i2d_ECDSA_SIG() is 103.</div><div><br></div><div>Whereas, the number_of_bytes value from curve parameter is 48. </div><div><br></div><div>Our verification failing as (103 != 2*48).</div><div><br></div><div>Can you please share do we need to skip any number of bytes from the sig_buf converted via i2d_ECDSA_SIG()? </div><div><br></div><div>Or, am i missing anything in this context?</div><div><br></div><div><br></div><div>Thanks,</div><div>Rajeswari.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 13, 2015 at 4:48 AM, Rajeswari K <span dir="ltr"><<a href="mailto:raji.kotamraju@gmail.com" target="_blank">raji.kotamraju@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello Dave,<div><br></div><div>Am really thankful to you. I am unaware that i2d_EC_PUBKEY() or i2d_xxxxx function will move the pointer to after the encoded data. Due to which am seeing unexpected data. </div><div><br></div><div>Based on your reply, i tried to print the data from the memory address which i allocated. Now the data is exactly same as what i inputted through d2i_PUBKEY().</div><div><br></div><div>This resolves my current issue. Once again, thanks alot.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Rajeswari.</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 13, 2015 at 2:36 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">> From: openssl-users On Behalf Of Rajeswari K<br>
> Sent: Thursday, February 12, 2015 00:40<br>
<span><br>
> I have a query on d2i_PUBKEY() and i2d_PUBKEY().<br>
<br>
> i have a EC public key in form of character buffer.<br>
> Have inputted this character buffer to d2i_PUBKEY() and got EVP_PKEY format EC key.<br>
<br>
</span>To be exact, a byte (or even more exact octet) buffer. In C<br>
(and C++ and ObjC) it's type 'char[]' or better 'unsigned char[]',<br>
but the values do not and often cannot represent *characters&.<br>
<span><br>
> Now i tried to input this EVP_PKEY to i2d_PUBKEY() to compare will i get<br>
> exactly same data which i gave as input to d2i_PUBKEY().<br>
<br>
> But i see that the outputs are completely different.<br>
<br>
> i2d_PUBKEY() is leaving lots of 0's at the o/p buffer.<br>
<br>
> 0<br>
> 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0<br>
> 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0<br>
> FD  1   10  DF  AB  12  34  CD  0   6F  0   0   0   0   1   83<br>
> F   8B  AF  D8  D  ................................................<br>
<br>
</span>You must be doing something wrong. Probably the most common is,<br>
are you looking at the beginning of the buffer? Remember that after<br>
calling i2d_whatever, the pointer you give it is moved to point<br>
*after* the encoded data, at unused and often junk memory.<br>
<br>
If that's not it, reduce your code to the minimum that shows the<br>
problem, post it, and identify the version and build you are using.<br>
<span><br>
> My goal is, to get complete EC public key in form of asn1 der<br>
> encoded from EC_KEY structure.<br>
<br>
</span>> I tried to use i2d_EC_PUBKEY() and i20_ECPublickey(). <snip><br>
<br>
Note that PUBKEY is the X.509 SPKI format: it contains an<br>
AlgorithmIdentifier identifying the algorithm and the curve,<br>
*and* the public key value (a point) embedded in a bitstring,<br>
all combined into an ASN.1 structure and DER encoded.<br>
<br>
i2o_ECPublicKey (letter o not zero) uses a special non-ASN1<br>
non-DER encoding that contains *only* the point.<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>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>