<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPC MicrocontrollersのトピックRe: Likely a bug in HashCrypt() in TZ</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Likely-a-bug-in-HashCrypt-in-TZ/m-p/1590848#M51471</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/27788"&gt;@Alice_Yang&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your comment!&lt;/P&gt;&lt;P&gt;After adding code right next to resetting the peripheral in HASHCRYPT_Init() function, it works perfectly!&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void HASHCRYPT_Init(HASHCRYPT_Type *base)
{
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) &amp;amp;&amp;amp; FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
    CLOCK_EnableClock(kCLOCK_HashCrypt);
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
    RESET_PeripheralReset(kHASHCRYPT_RST_SHIFT_RSTn);

	// From NXP forum
	HASHCRYPT-&amp;gt;LOCK = HASHCRYPT-&amp;gt;LOCK | ((0x0A75&amp;lt;&amp;lt;4) | 0x1);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this snippet of code would be helpful to those who want to use cryptographic functions in a secure world.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jan 2023 23:32:06 GMT</pubDate>
    <dc:creator>mat1024</dc:creator>
    <dc:date>2023-01-31T23:32:06Z</dc:date>
    <item>
      <title>Likely a bug in HashCrypt() in TZ</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Likely-a-bug-in-HashCrypt-in-TZ/m-p/1588506#M51405</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Environment&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Board: LPC55s69
SDK version: 2.12.0
SW: MCUXPresso IDE&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was trying to exploit &lt;STRONG&gt;ECDSA sign/verify functions&lt;/STRONG&gt; in &lt;STRONG&gt;secure memory&lt;/STRONG&gt;, so I ported "lpcxpresso55s69_mbedtls_benchmark" project in SDK 2.12.0 to my TZ project.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found that when I use those functions in applications in secure world, &lt;STRONG&gt;it was always stuck&lt;/STRONG&gt; in '&lt;SPAN&gt;&lt;STRONG&gt;hashcrypt_sha_finalize&lt;/STRONG&gt;' or '&lt;STRONG&gt;hashcrypt_sha_process_message_data&lt;/STRONG&gt;'&amp;nbsp; functions, specifically in this while loop,&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;while (0U == (base-&amp;gt;STATUS &amp;amp; HASHCRYPT_STATUS_DIGEST_MASK))
     {
     }&lt;/LI-CODE&gt;&lt;P&gt;The status here was set to &lt;STRONG&gt;5&lt;/STRONG&gt; when I tried in &lt;STRONG&gt;secure world&lt;/STRONG&gt;, but it was &lt;STRONG&gt;3&lt;/STRONG&gt; when I tried in&lt;STRONG&gt; normal work&lt;/STRONG&gt;, &lt;STRONG&gt;where the code worked fine&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;To clarify why this happens, &lt;STRONG&gt;I changed the MEMADDR&lt;/STRONG&gt; where the message was given to &lt;STRONG&gt;any non-secure RAM&lt;/STRONG&gt; and &lt;STRONG&gt;it worked well&lt;/STRONG&gt;, which probably means that this is not the configuration issue, but the hardware/software bug using secure RAM.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;//  base-&amp;gt;MEMADDR = HASHCRYPT_MEMADDR_BASE(message);
    base-&amp;gt;MEMADDR = 0x2001bd4c;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would anybody help me to figure this out in more detail?&lt;/P&gt;&lt;P&gt;Here is the original question I posted a few days before.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/t5/LPC-Microcontrollers/Question-about-Hashcrypt-in-LPC55S69/m-p/1586892#M51358" target="_blank"&gt;https://community.nxp.com/t5/LPC-Microcontrollers/Question-about-Hashcrypt-in-LPC55S69/m-p/1586892#M51358&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 19:39:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Likely-a-bug-in-HashCrypt-in-TZ/m-p/1588506#M51405</guid>
      <dc:creator>mat1024</dc:creator>
      <dc:date>2023-01-26T19:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: Likely a bug in HashCrypt() in TZ</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Likely-a-bug-in-HashCrypt-in-TZ/m-p/1590224#M51452</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/204744"&gt;@mat1024&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How about add code&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;HASHCRYPT-&amp;gt;LOCK = HASHCRYPT-&amp;gt;LOCK | ((0x0A75&amp;lt;&amp;lt;4) | 0x1);&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Because t&lt;/SPAN&gt;he HASH-AES engine is unlocked by default. That means it will issue non-secure requests as AHB master, as shown below.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Alice_Yang_0-1675134717870.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/208886i41840B624EA5B929/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Alice_Yang_0-1675134717870.png" alt="Alice_Yang_0-1675134717870.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So we cannot use it at secure state when it is unlocked. We must lock it at secure state if we want to use it at secure state.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 03:12:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Likely-a-bug-in-HashCrypt-in-TZ/m-p/1590224#M51452</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2023-01-31T03:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Likely a bug in HashCrypt() in TZ</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Likely-a-bug-in-HashCrypt-in-TZ/m-p/1590848#M51471</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/27788"&gt;@Alice_Yang&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your comment!&lt;/P&gt;&lt;P&gt;After adding code right next to resetting the peripheral in HASHCRYPT_Init() function, it works perfectly!&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void HASHCRYPT_Init(HASHCRYPT_Type *base)
{
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) &amp;amp;&amp;amp; FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
    CLOCK_EnableClock(kCLOCK_HashCrypt);
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
    RESET_PeripheralReset(kHASHCRYPT_RST_SHIFT_RSTn);

	// From NXP forum
	HASHCRYPT-&amp;gt;LOCK = HASHCRYPT-&amp;gt;LOCK | ((0x0A75&amp;lt;&amp;lt;4) | 0x1);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this snippet of code would be helpful to those who want to use cryptographic functions in a secure world.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 23:32:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Likely-a-bug-in-HashCrypt-in-TZ/m-p/1590848#M51471</guid>
      <dc:creator>mat1024</dc:creator>
      <dc:date>2023-01-31T23:32:06Z</dc:date>
    </item>
  </channel>
</rss>

