<?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 — ECC hash verification failure with P-521 curve]]></title>
		<link>https://www.wolfssl.com/forums/topic833-ecc-hash-verification-failure-with-p521-curve.html</link>
		<atom:link href="https://www.wolfssl.com/forums/feed-rss-topic833.xml" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in ECC hash verification failure with P-521 curve.]]></description>
		<lastBuildDate>Fri, 26 Aug 2016 20:56:49 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: ECC hash verification failure with P-521 curve]]></title>
			<link>https://www.wolfssl.com/forums/post2691.html#p2691</link>
			<description><![CDATA[<p>Hey Avenuti,</p><p>A fix for this issue has been pushed to GitHub PR#535:<br /><a href="https://github.com/wolfSSL/wolfssl/pull/535">https://github.com/wolfSSL/wolfssl/pull/535</a></p><p>Thanks, David Garske, wolfSSL</p>]]></description>
			<author><![CDATA[null@example.com (dgarske)]]></author>
			<pubDate>Fri, 26 Aug 2016 20:56:49 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2691.html#p2691</guid>
		</item>
		<item>
			<title><![CDATA[Re: ECC hash verification failure with P-521 curve]]></title>
			<link>https://www.wolfssl.com/forums/post2690.html#p2690</link>
			<description><![CDATA[<p>Hey Avenuti,</p><p>I am able to reproduce the error with normal math and ECC-521 on that board. I was then also able to reproduce on my Mac with 32-bit mode (-m32) and NO_64BIT defined. Happens with or without ECC_TIMING_RESISTANT.</p><p>This failure only happens on 32-bit systems with normal math. Until then please use fast math with ECC-521.</p><p>For reference the error is:<br />&quot;ecc_test_curve_size 66 failed!: -1023<br />ECC&nbsp; &nbsp; &nbsp; test failed!<br /> error = -1023&quot;</p><p>The error is happening inside the &quot;ecc_check_pubkey_order&quot; function, which returns -215 (ECC_INF_E).</p><p>We are investigating the cause and will let you know when we have a resolution. Thanks again for the report!</p><p>Thanks, David Garske, wolfSSL</p>]]></description>
			<author><![CDATA[null@example.com (dgarske)]]></author>
			<pubDate>Fri, 26 Aug 2016 19:41:53 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2690.html#p2690</guid>
		</item>
		<item>
			<title><![CDATA[Re: ECC hash verification failure with P-521 curve]]></title>
			<link>https://www.wolfssl.com/forums/post2682.html#p2682</link>
			<description><![CDATA[<p>Hey Avenuti,</p><p>Sorry about the confusion. I thought you meant it wasn&#039;t working with USE_FAST_MATH.</p><p>The most common reason for a failure with normal math is that it uses heap allocations for the big integers. If you want to get normal math working I&#039;d recommend increasing your heap size and trying again.</p><p>With USE_FAST_MATH disabled none of the options listed above are used except &quot;ECC_TIMING_RESISTANT&quot;. That&#039;s because TFM_ and FP_MAX_BITS_ECC are only used with fast math.</p><p>The fast math uses stack for its allocations while normal math uses heap. The fast math tends to be faster because there is no heap allocation/free overhead.</p><p>The &quot;ALT_ECC_SIZE&quot; will save memory if using RSA and ECC because it will use heap allocations of a reduced size for ECC points, but only works when used with USE_FAST_MATH.</p><p>I&#039;ll run some tests this week and see if I can locate any issues using normal math and ECC-521. I have an LPC1837 board here to test with and see if I can reproduce.</p><p>Thanks, David Garske, wolfSSL</p>]]></description>
			<author><![CDATA[null@example.com (dgarske)]]></author>
			<pubDate>Wed, 24 Aug 2016 00:09:15 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2682.html#p2682</guid>
		</item>
		<item>
			<title><![CDATA[Re: ECC hash verification failure with P-521 curve]]></title>
			<link>https://www.wolfssl.com/forums/post2679.html#p2679</link>
			<description><![CDATA[<p>To clarify: disabling USE_FAST_MATH is what caused the error.</p><p>I also tested various permutations of enabling/disabling the following:<br />FP_MAX_BITS_ECC (disabled or enabled with a few different sizes, as you suggested)<br />TFM_ASM<br />TFM_TIMING_RESISTANT<br />TFM_ECC521<br />ECC_TIMING_RESISTANT</p><p>None seemed to have an effect on success or failure, it always came down to: failure with USE_FAST_MATH disabled, success with it enabled.</p><p>Also, another question: what are any advantages/disadvantages/tradeoffs in using ALT_ECC_SIZE? Enabling/disabling this didn&#039;t seem to affect either code size or performance times.</p>]]></description>
			<author><![CDATA[null@example.com (avenuti)]]></author>
			<pubDate>Fri, 19 Aug 2016 17:36:46 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2679.html#p2679</guid>
		</item>
		<item>
			<title><![CDATA[Re: ECC hash verification failure with P-521 curve]]></title>
			<link>https://www.wolfssl.com/forums/post2678.html#p2678</link>
			<description><![CDATA[<p>Hey Avenuti,</p><p>I&#039;ll take a look at the TFM_ECC521 define. I personally testing that combination on a Cortex M4 without any issue, but its possible there is an problem with the FP_MAX_BITS_ECC calc on a 32-bit micro with TFM_ECC521. I&#039;ll let you know the results of my testing early tomorrow.</p><p>In the mean-time did you try it without &quot;FP_MAX_BITS_ECC&quot; defined? You could also try setting &quot;FP_MAX_BITS_ECC&quot; to a larger value like 1200 and see if that helps.</p><p>Thanks, David Garske, wolfSSL</p>]]></description>
			<author><![CDATA[null@example.com (dgarske)]]></author>
			<pubDate>Thu, 18 Aug 2016 22:22:08 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2678.html#p2678</guid>
		</item>
		<item>
			<title><![CDATA[Re: ECC hash verification failure with P-521 curve]]></title>
			<link>https://www.wolfssl.com/forums/post2676.html#p2676</link>
			<description><![CDATA[<p>Updating to 3.9.8 did fix the issue. I was able to run the tests successfully.</p><p>However, while testing performance/optimization, I rebuilt after disabling TFM. Running the test once again gives a -1023 error. </p><p>After I first pulled 3.9.8 I thought I successfully ran it with and without TFM. Since then I&#039;ve updated the chip library from LPCopen 2.12 to 2.18, so maybe this is causing some issue? (I could go back and double check on 2.12 but downgrading would be a pain)</p><p>Edit: I tried disabling just TFM_ECC521 (as opposed to disabling USE_FAST_MATH, ALT_ECC_SIZE, and every TFM_ entry), and the test worked. Maybe I just missed one of the related #defines?</p>]]></description>
			<author><![CDATA[null@example.com (avenuti)]]></author>
			<pubDate>Thu, 18 Aug 2016 20:47:53 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2676.html#p2676</guid>
		</item>
		<item>
			<title><![CDATA[Re: ECC hash verification failure with P-521 curve]]></title>
			<link>https://www.wolfssl.com/forums/post2642.html#p2642</link>
			<description><![CDATA[<p>Hey Avenuti,</p><p>Updating to lastest wolfSSL will resolve this. There were numerous fixes with ECC math back on May 4th that resolve the ecc_is_point check for ECC 521. If you have ALT_ECC_SIZE defined you&#039;ll want to make sure FP_MAX_BITS_ECC is set high enough (like 1088). If you update to the latest you can not define FP_MAX_BITS_ECC and let the tfm.h header handle it.</p><p>David</p>]]></description>
			<author><![CDATA[null@example.com (dgarske)]]></author>
			<pubDate>Wed, 03 Aug 2016 17:09:09 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2642.html#p2642</guid>
		</item>
		<item>
			<title><![CDATA[Re: ECC hash verification failure with P-521 curve]]></title>
			<link>https://www.wolfssl.com/forums/post2639.html#p2639</link>
			<description><![CDATA[<p>David,</p><p>ECC_SHAMIR was already enabled by default in the IDE/LPCXPRESSO user_settings file.<br />ECC_TIMING_RESSISTANT was not defined; adding this in had no effect (default curve success, P-521 curve failure).<br />TFM_ECC521 was also not defined; adding this in caused a different failure, even with the default curve:</p><p>From inside test_ecc, the failure occurred here, with output -1024:<br /></p><div class="codebox"><pre><code>    ret = wc_ecc_check_key(&amp;userA);
    if (ret != 0)
        return -1024;</code></pre></div><p>Here is where the failure occurs inside wc_ecc_check_key (err returns -1):<br /></p><div class="codebox"><pre><code>    /* make sure point is actually on curve */
    if (err == MP_OKAY)
        err = ecc_is_point(key-&gt;dp, &amp;key-&gt;pubkey, &amp;prime);</code></pre></div><p>I&#039;ll look into trying out 3.9.8.</p>]]></description>
			<author><![CDATA[null@example.com (avenuti)]]></author>
			<pubDate>Wed, 03 Aug 2016 14:09:16 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2639.html#p2639</guid>
		</item>
		<item>
			<title><![CDATA[Re: ECC hash verification failure with P-521 curve]]></title>
			<link>https://www.wolfssl.com/forums/post2636.html#p2636</link>
			<description><![CDATA[<p>Hello Avenuti,</p><p>Thanks for the detailed question.</p><p>It looks like you are not using the latest v3.9.8 wolfSSL release. There have been a few fixes/changes in that area of ECC vector testing. I&#039;ve seen this error and believe you can workaround it without an update by defining ECC_SHAMIR. I do recommend you update if you can.</p><p>For your NXP LPC1837 micro I would recommend the following settings:<br />#define USE_FAST_MATH<br />#define TFM_TIMING_RESISTANT<br />#define TFM_ARM (or TFM_ASM if that one fails)</p><p>#define HAVE_ECC<br />#define ECC_USER_CURVES<br />#define HAVE_ECC521<br />#define ECC_SHAMIR<br />#define ECC_TIMING_RESISTANT</p><p>#define ALT_ECC_SIZE<br />#define TFM_ECC521</p><p>For additional details on these and a good example of a user_settings.h configuration file see here:<br /><a href="https://github.com/wolfSSL/wolfssl/blob/master/IDE/ROWLEY-CROSSWORKS-ARM/user_settings.h">https://github.com/wolfSSL/wolfssl/blob … settings.h</a></p><p>Thanks and let me know if that resolves your failure.</p><p>David Garske</p>]]></description>
			<author><![CDATA[null@example.com (dgarske)]]></author>
			<pubDate>Wed, 03 Aug 2016 00:13:46 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2636.html#p2636</guid>
		</item>
		<item>
			<title><![CDATA[ECC hash verification failure with P-521 curve]]></title>
			<link>https://www.wolfssl.com/forums/post2635.html#p2635</link>
			<description><![CDATA[<p>My project involves implementing functions from wolfCrypt on an NXP LPC1837 MCU.</p><p>I&#039;m able to build and run the wolf_example project in the IDE/LPCXPRESSO directory. Running the test with default settings is a success, but if I attempt to add in support for the P-521 curve (#define HAVE_ECC521 in user_settings.h) the test fails, with error code -1023.</p><p>Separate from the wolf_example project, I&#039;ve also tested wolfCrypt within my own project by including just the necessary .c and .h files for the functions I need. I&#039;ve done a bit of digging to figure out exactly where the error occurs:</p><p>Hash verification fails at line 2469 of ecc.c<br /></p><div class="codebox"><pre><code>2467   /* does v == r */
2468   if (err == MP_OKAY) {
2469       if (mp_cmp(&amp;v, r) == MP_EQ)
2470           *stat = 1;
2471   }</code></pre></div><p>This happens within line 6261 of test.c, causing the return at 6266<br /></p><div class="codebox"><pre><code>6261    ret = wc_ecc_verify_hash(sig, x, (byte*)vector-&gt;msg, (word32)vector-&gt;msgLen, &amp;verify, userA);
6262    if (ret != 0)
6263        return -1021;
6264
6265    if (verify != 1)
6266        return -1023;</code></pre></div><p>which is called within line 6598 of test.c<br /></p><div class="codebox"><pre><code>6597        ecc521.curveName = &quot;nistp521&quot;;
6598        ret = ecc_test_raw_vector(&amp;ecc521, &amp;userA, sig, sizeof(sig));
6599        if (ret &lt; 0) {
6600            return ret;
6601        }</code></pre></div><br /><p>To utilize the P-521 curve, are the additional steps needed besides defining HAVE_ECC521?<br />If not, what else might be causing this issue?</p>]]></description>
			<author><![CDATA[null@example.com (avenuti)]]></author>
			<pubDate>Mon, 01 Aug 2016 20:49:28 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2635.html#p2635</guid>
		</item>
	</channel>
</rss>
