<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[wolfSSL - Embedded SSL Library — Unexpected results in ECC arithmetic]]></title>
		<link>https://www.wolfssl.com/forums/topic1911-unexpected-results-in-ecc-arithmetic.html</link>
		<atom:link href="https://www.wolfssl.com/forums/feed-rss-topic1911.xml" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Unexpected results in ECC arithmetic.]]></description>
		<lastBuildDate>Thu, 08 Sep 2022 19:17:09 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Unexpected results in ECC arithmetic]]></title>
			<link>https://www.wolfssl.com/forums/post6738.html#p6738</link>
			<description><![CDATA[<p>Hello embhorn,</p><p>Thank you for replying that fast. This is a school project and i am making the ecqv protocol described in the document in this link <a href="https://www.secg.org/sec4-1.0.pdf.">https://www.secg.org/sec4-1.0.pdf.</a></p><p>Based on your example I made a more elaborate example with logging and error handling. It is currently set for wolfssl. To switch to openssl Makefile needs changes in lines 1 and 2 from wolfssl to openssl. And ecc.c file to remove wolfssl from imports and just use openssl. If you run the code with ./ecqv -l ecqv.log ca_key.pem you can see the log inside ecqv.log.</p><p>The goal of protocol is to have points p_Qa_prim and p_Qa to be the same. And thats the case with openssl. But wolfssl returns different result.</p>]]></description>
			<author><![CDATA[null@example.com (beaverknight)]]></author>
			<pubDate>Thu, 08 Sep 2022 19:17:09 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post6738.html#p6738</guid>
		</item>
		<item>
			<title><![CDATA[Re: Unexpected results in ECC arithmetic]]></title>
			<link>https://www.wolfssl.com/forums/post6737.html#p6737</link>
			<description><![CDATA[<p>Hello beaverknight,</p><p>Thanks for joining the wolfSSL Forums. I&#039;ve created a crude test app from your example. Could you please add error checking and supply the example key file to get a reproducible test case for us to evaluate?</p><p>Could you tell us a bit about your project and the intended goals? </p><p>Kind regards,<br />Eric @ wolfSSL Support</p>]]></description>
			<author><![CDATA[null@example.com (embhorn)]]></author>
			<pubDate>Thu, 08 Sep 2022 15:02:29 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post6737.html#p6737</guid>
		</item>
		<item>
			<title><![CDATA[Unexpected results in ECC arithmetic]]></title>
			<link>https://www.wolfssl.com/forums/post6736.html#p6736</link>
			<description><![CDATA[<p>Hello,</p><p>I am using brainpoolP256r1 curve and I am trying to perform some ECC arithmetic. I managed to have everything working fine using openssl but when i use wolfssl it doesnt give expected result. </p><p>I was using openssl to perform following calculations:</p><p>1.Used PEM_read_PrivateKey to read key and then used EC_KEY_get0_group and&nbsp; EC_GROUP_get_order to get Elliptic curve parameters(group and order).<br />2. Generate an EC key pair (a , p_alphaG ) using the following:<br /> a = BN_new()<br /> BN_rand_range(a, order)<br /> p_alphaG = EC_POINT_new(group);<br /> EC_POINT_mul(group, p_alphaG, a,NULL, NULL, NULL) //this does a multiplied by generator according to openssl docs p_alphaG = a * G<br />3.&nbsp; Generate an EC key pair (k, p_kG)<br /> p_kG = EC_POINT_new(group)<br /> k = BN_new()<br /> BN_rand_range(k, order)<br /> EC_POINT_mul(group, p_kG, k,NULL, NULL, NULL) //this does k multiplied by generator according to openssl docs p_kG = k * G<br />4. Compute the elliptic curve point PU = p_alphaG + p_kG<br /> Pu = EC_POINT_new(group)<br /> EC_POINT_add(group, Pu, p_alphaG, p_kG, NULL) //addition<br />5. Generate Random bignum<br /> e = BN_new();<br /> BN_rand_range(e, order); //random bignum up to order<br />6. Compute the integer r = ek + c (mod n)<br /> BIGNUM *ek = BN_new()<br /> BN_mul(ek, e, k, ctx)<br /> c = EC_KEY_get0_private_key(ca_key) //ca_key is generated in first step by PEM_read_PrivateKey <br /> BN_mod_add(r, ek, c, order, ctx)<br />7. Compute the private key dU = r + ea (mod n)<br /> ealpha = BN_new()<br /> p_Qa_prim = EC_POINT_new(group)<br /> BN_mul(ealpha, e, a, ctx)<br /> dU = BN_new()<br /> BN_mod_add(dU, ealpha, r, order, ctx)<br /> EC_POINT_mul(group, p_Qa_prim, dU, NULL, NULL, NULL)<br /> //at this point i can compare<br /> EC_POINT_cmp(group, p_Qa, p_Qa_prim, ctx) //this should return 1 because these the points should be the same</p><p>Using wolfssl these two points are completely different. Nothing fails here but result is not expected. I expected that wolfssl compiled with openssl-extra should provide reproducible results as openssl. </p><p>Is there any device you can give me on this? What can be the reason that wolfssl does not give same results as openssl?</p><p>Thank you</p><p>Btw, all these calculations come from this standard document(https://www.secg.org/sec4-1.0.pdf)</p>]]></description>
			<author><![CDATA[null@example.com (beaverknight)]]></author>
			<pubDate>Thu, 08 Sep 2022 12:18:10 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post6736.html#p6736</guid>
		</item>
	</channel>
</rss>
