<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>CRYS_ECDSA_Sign signature encoding?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/32129/crys_ecdsa_sign-signature-encoding</link><description>Hello, I am doing some testing with nRF52840 and its CryptoCell 310 and I am trying to produce an ECDSA signature and verify it using mbedTLS. 
 CC310 Sign &amp;amp; Verify is working great, but how can I convert this signature into another format? For example</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 08 Jan 2019 17:14:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/32129/crys_ecdsa_sign-signature-encoding" /><item><title>RE: CRYS_ECDSA_Sign signature encoding?</title><link>https://devzone.nordicsemi.com/thread/164571?ContentTypeID=1</link><pubDate>Tue, 08 Jan 2019 17:14:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c8cfd52-3109-453e-b9cc-b47c1f20d892</guid><dc:creator>DamianV</dc:creator><description>&lt;p&gt;It does, thnaks a lot.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CRYS_ECDSA_Sign signature encoding?</title><link>https://devzone.nordicsemi.com/thread/164561?ContentTypeID=1</link><pubDate>Tue, 08 Jan 2019 15:22:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14131d7c-7b0e-453a-b0ed-c70eba5396a1</guid><dc:creator>Dadas</dc:creator><description>&lt;p&gt;Hello, I ended up using ecdsa_signature_to_asn1 from mbedtls&lt;/p&gt;
&lt;p&gt;CRYS_ECDSA_Sign(&amp;amp;rndCtx,&amp;amp;signtmp,&amp;amp;Priv,HASHMODE,(uint8_t*)hash,hlen,hwsig,&amp;amp;hwsiglen);&lt;/p&gt;
&lt;p&gt;- output is written to the hwsig buffer, first half is the R parameter and second half is the S parameter, so I read these numbers into mbedtls MPI format and then call&amp;nbsp;&lt;span&gt;ecdsa_signature_to_asn1&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;mbedtls_mpi r, s;&lt;br /&gt; mbedtls_mpi_init( &amp;amp;r );&lt;br /&gt; mbedtls_mpi_init( &amp;amp;s );&lt;br /&gt; &lt;br /&gt; mbedtls_mpi_read_binary(&amp;amp;r,hwsig,keysize);&lt;br /&gt; mbedtls_mpi_read_binary(&amp;amp;s,hwsig+keysize,keysize);&lt;br /&gt; &lt;br /&gt; ecdsa_signature_to_asn1(&amp;amp;r,&amp;amp;s,sig,slen);&lt;/p&gt;
&lt;p&gt;Hope this helps, have a nice day&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CRYS_ECDSA_Sign signature encoding?</title><link>https://devzone.nordicsemi.com/thread/164538?ContentTypeID=1</link><pubDate>Tue, 08 Jan 2019 14:07:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cfb4b3b-93ef-48b8-9854-364682924bf8</guid><dc:creator>DamianV</dc:creator><description>&lt;p&gt;Hi Dadas,&lt;/p&gt;
&lt;p&gt;can you please tell me what is the output format of the Sign algorithm/how do yo convert the signature to DER format?&lt;/p&gt;
&lt;p&gt;I am stuck on this as well, and couldn&amp;#39;t figure it out from your answer.&lt;/p&gt;
&lt;p&gt;Thanks in advance!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CRYS_ECDSA_Sign signature encoding?</title><link>https://devzone.nordicsemi.com/thread/124652?ContentTypeID=1</link><pubDate>Thu, 15 Mar 2018 18:40:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb83d6a9-830d-4137-91fa-2092e8da5f7b</guid><dc:creator>Dadas</dc:creator><description>&lt;p&gt;Turns out I was doing the conversion correctly,&amp;nbsp;after calling&amp;nbsp;CRYS_ECDSA_Sign with the &amp;quot;&lt;em&gt;CRYS_ECPKI_AFTER_HASH_SHA256_mode&amp;quot;&lt;/em&gt;&lt;span&gt;&amp;nbsp;hash mode and feeding in its SHA256 hash instead of the message, it worked and MbedTLS has verified it properly.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Well, still not sure why it didn&amp;#39; work with &amp;quot;&lt;em&gt;CRYS_ECPKI_HASH_SHA256_mode&amp;quot;, but at least I got it working now&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>