<?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 — How to set a fixed per-message secret number of ECDSA in cyaSSL]]></title>
		<link>https://www.wolfssl.com/forums/topic624-how-to-set-a-fixed-permessage-secret-number-of-ecdsa-in-cyassl.html</link>
		<atom:link href="https://www.wolfssl.com/forums/feed-rss-topic624.xml" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in How to set a fixed per-message secret number of ECDSA in cyaSSL.]]></description>
		<lastBuildDate>Mon, 23 Nov 2015 03:23:53 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: How to set a fixed per-message secret number of ECDSA in cyaSSL]]></title>
			<link>https://www.wolfssl.com/forums/post2343.html#p2343</link>
			<description><![CDATA[<p>Hi Chrisc,</p><p>Thanks for your kindly comments, it is really helpful to us.&nbsp; <img src="https://www.wolfssl.com/forums/img/smilies/smile.png" width="15" height="15" alt="smile" /> </p><br /><p>Best regards,<br />Ryan</p>]]></description>
			<author><![CDATA[null@example.com (windsp)]]></author>
			<pubDate>Mon, 23 Nov 2015 03:23:53 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2343.html#p2343</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to set a fixed per-message secret number of ECDSA in cyaSSL]]></title>
			<link>https://www.wolfssl.com/forums/post2337.html#p2337</link>
			<description><![CDATA[<p>Hi windsp,</p><p>Yes, ecc_sign_hash() checks to make sure the value of &#039;k&#039; is within the required range.&nbsp; You can see this in ./wolfcrypt/src/ecc.c, around line #1738:</p><div class="codebox"><pre><code>   /* quick sanity check to make sure we&#039;re not dealing with a 0 key */
   if (err == MP_OKAY) {
       if (MP_YES == mp_iszero(&amp;key-&gt;k))
           err = MP_ZERO_E;
   }

   /* the key should be smaller than the order of base point */
   if (err == MP_OKAY) {
       if (mp_cmp(&amp;key-&gt;k, &amp;order) != MP_LT)
           err = mp_mod(&amp;key-&gt;k, &amp;order, &amp;key-&gt;k);
   }</code></pre></div><p>Best Regards,<br />Chris</p>]]></description>
			<author><![CDATA[null@example.com (chrisc)]]></author>
			<pubDate>Fri, 20 Nov 2015 21:59:20 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2337.html#p2337</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to set a fixed per-message secret number of ECDSA in cyaSSL]]></title>
			<link>https://www.wolfssl.com/forums/post2320.html#p2320</link>
			<description><![CDATA[<p>Hi John,</p><p>Sorry to reply you so late...<br />We are asked to calculate the secret number according to message payload data. This code modification had been completed by our team members in a modified wolfSSL library.</p><p>Currently, we are asked another requirement for ECDSA exception handling. There are 2 checking conditions for exception handling in ECDSA signing function[ecc_sign_hash()].</p><p>&lt;&lt; The request is described below: &gt;&gt;<br />When generating a digital signature, the application shall calculate a per-message Secret Number ‘k’.<br />1.&nbsp; &nbsp; If the value of &#039;k&#039; so calculated is zero or greater than n-1. or<br />2.&nbsp; &nbsp; Results in an ‘r’ or ‘s’ value of 0.<br />Then, a new value for k shall be re-calculated.</p><p>After checking the source code in ecc_sign_hash() function. We think that the checking for &#039;r&#039; or &#039;s&#039; value of 0 is included, but I am not sure if the checking for the &#039;k&#039; value (0 &lt; k &lt;= n-1) is included.</p><div class="codebox"><pre><code>int ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen, 
                  RNG* rng, ecc_key* key)
{
   ...

   /* make up a key and export the public copy */
   if (err == MP_OKAY) {
       ecc_key pubkey;
       ecc_init(&amp;pubkey);
       for (;;) {
           err = ecc_make_key_ex(rng, &amp;pubkey, key-&gt;dp, NULL);
           if (err != MP_OKAY) break;

           /* find r = x1 mod n */
           err = mp_mod(&amp;pubkey.pubkey.x, &amp;p, &amp;r);
           if (err != MP_OKAY) break;

           if (mp_iszero(&amp;r) == MP_YES)         /*** &lt;--- check r == 0 here. ***/
               ecc_free(&amp;pubkey);
           else { 
               /* find s = (e + xr)/k */
               err = mp_invmod(&amp;pubkey.k, &amp;p, &amp;pubkey.k);
               if (err != MP_OKAY) break;

               err = mp_mulmod(&amp;key-&gt;k, &amp;r, &amp;p, &amp;s);   /* s = xr */
               if (err != MP_OKAY) break;
           
               err = mp_add(&amp;e, &amp;s, &amp;s);               /* s = e +  xr */
               if (err != MP_OKAY) break;

               err = mp_mod(&amp;s, &amp;p, &amp;s);               /* s = e +  xr */
               if (err != MP_OKAY) break;

               err = mp_mulmod(&amp;s, &amp;pubkey.k, &amp;p, &amp;s); /* s = (e + xr)/k */
               if (err != MP_OKAY) break;

               ecc_free(&amp;pubkey);
               if (mp_iszero(&amp;s) == MP_NO)          /*** &lt;--- check s != 0 here. ***/
                   break;
            }
       }
       ecc_free(&amp;pubkey);
   }

   ...
}</code></pre></div><p>Could you please let me know if the checking of &#039;k&#039; value (0 &lt; k &lt;=&nbsp; n-1) is included in ecc_sign_hash() function?<br />If not included, could you kindly guide me how to modify the code for &#039;k&#039; value checking with &#039;n&#039; value? We would like to modify the code to implement the checking mechanism. <img src="https://www.wolfssl.com/forums/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (windsp)]]></author>
			<pubDate>Wed, 18 Nov 2015 07:18:52 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post2320.html#p2320</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to set a fixed per-message secret number of ECDSA in cyaSSL]]></title>
			<link>https://www.wolfssl.com/forums/post1960.html#p1960</link>
			<description><![CDATA[<p>ECDSA uses a random number as part of the signature process. If you call ecc_sign_hash() multiple times with the same data, you will get a different signature every time. But, all the signatures will verify correctly with ecc_verify_hash().&nbsp; Do they provide the secret number in a PEM or DER wrapper?</p>]]></description>
			<author><![CDATA[null@example.com (john)]]></author>
			<pubDate>Wed, 25 Feb 2015 20:17:22 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post1960.html#p1960</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to set a fixed per-message secret number of ECDSA in cyaSSL]]></title>
			<link>https://www.wolfssl.com/forums/post1957.html#p1957</link>
			<description><![CDATA[<p>Hi John,</p><p>Thanks for your reply.<br />Yes, for checking with customer&#039;s requirement, we need to verify the output(signature) with the same input(per-message secret number). This is an evidence to check if the product could generate the same signature according to the crypto vectors.</p><p>Thus, could you please let me know how to get a fixed signature with a static per-message secret number in ECDSA sign API (ecc_sign_hash)?</p><p>Many thanks.&nbsp; <img src="https://www.wolfssl.com/forums/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (windsp)]]></author>
			<pubDate>Wed, 25 Feb 2015 07:10:40 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post1957.html#p1957</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to set a fixed per-message secret number of ECDSA in cyaSSL]]></title>
			<link>https://www.wolfssl.com/forums/post1955.html#p1955</link>
			<description><![CDATA[<p>Are you sure you really want to do that? That&#039;s what got a large video game console manufacturer in trouble.</p>]]></description>
			<author><![CDATA[null@example.com (john)]]></author>
			<pubDate>Tue, 24 Feb 2015 21:53:28 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post1955.html#p1955</guid>
		</item>
		<item>
			<title><![CDATA[How to set a fixed per-message secret number of ECDSA in cyaSSL]]></title>
			<link>https://www.wolfssl.com/forums/post1953.html#p1953</link>
			<description><![CDATA[<p>Hi admin,</p><p>For clarification of ECDSA algorithm with some specific crypto vectors, I want to set a fixed per-message secret number in ECDSA algorithm.<br />Could you kindly let me how to set a fixed per-message secret number in ECDSA sign API (ecc_sign_hash)?</p><p>Thanks.&nbsp; <img src="https://www.wolfssl.com/forums/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (windsp)]]></author>
			<pubDate>Tue, 24 Feb 2015 11:59:41 +0000</pubDate>
			<guid>https://www.wolfssl.com/forums/post1953.html#p1953</guid>
		</item>
	</channel>
</rss>
