<?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>Deriving ECC keys from HUK with TF-M</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/93954/deriving-ecc-keys-from-huk-with-tf-m</link><description>Hi! 
 
 I am currently testing out the TF-M features on the nRF9160 and I want to encrypt some data on the device. So my plan here is to use symmetric encryption with a key derived using ECDH. 
 To accomplish this I want to only exchange public keys between</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 21 Nov 2022 15:16:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/93954/deriving-ecc-keys-from-huk-with-tf-m" /><item><title>RE: Deriving ECC keys from HUK with TF-M</title><link>https://devzone.nordicsemi.com/thread/396723?ContentTypeID=1</link><pubDate>Mon, 21 Nov 2022 15:16:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d06376b7-b78b-46e0-8ec2-25b68eee9e2a</guid><dc:creator>Oskar</dc:creator><description>&lt;p&gt;Okay, that cleared it up! Thank you very much!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Deriving ECC keys from HUK with TF-M</title><link>https://devzone.nordicsemi.com/thread/396704?ContentTypeID=1</link><pubDate>Mon, 21 Nov 2022 14:39:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa82c0d2-372b-4dcf-9b86-222acf61415e</guid><dc:creator>Hakon</dc:creator><description>[quote user="Oskar"]I am not sure if I understand why the derived bytes would not correspond to a private key. Why is this the case?[/quote]
&lt;p&gt;The derived bytes command just returns you some random bytes. The ECC private keys depending on the curve will have some requirements. Meaning that you need to follow some characteristics, like for example that if you perform a scalar multiplication with the private ECC key and the base point of the curve then the result (public key) need to be a point inside the curve (defined by the algorithm that you choose). The important thing is that a random number may or may not be a private key, that&amp;#39;s why we need the psa_import_key to confirm this.&lt;/p&gt;
[quote user="Oskar"]Another, perhaps unrelated question, is protected storage and the key psa_crypto interfaces experimental using NCS? &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.1.1/nrf/ug_tfm.html"&gt;this&lt;/a&gt; seems to indicate so, but I am not entirely sure what parts of TF-M that is considered experimental and not.[/quote]
&lt;p&gt;Only the minimal profile of TF-M is in production stage. Everything else is experimental, the minimal profile doesn&amp;#39;t have the protected storage AFAIK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Deriving ECC keys from HUK with TF-M</title><link>https://devzone.nordicsemi.com/thread/396553?ContentTypeID=1</link><pubDate>Mon, 21 Nov 2022 07:31:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7034511-2387-49eb-9ca7-d7ca07be36ae</guid><dc:creator>Oskar</dc:creator><description>&lt;p&gt;I am not sure if I understand why the derived bytes would not correspond to a private key. Why is this the case?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;To add a little context, this whole operation would be a part of a device provisioning on the assembly line.&lt;/p&gt;
&lt;p&gt;Another possible solution for me could be to generate the ECC key, export the public key, then use the secondary, provisioned public key to generate a symmetric key and store that. Though it would be nice to keep the ECC key as well.&lt;/p&gt;
&lt;p&gt;Perhaps it would be a good idea to store the key in the protected storage provided by TF-M.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Another, perhaps unrelated question, is protected storage and the key psa_crypto interfaces experimental using NCS? &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.1.1/nrf/ug_tfm.html"&gt;this&lt;/a&gt; seems to indicate so, but I am not entirely sure what parts of TF-M that is considered experimental and not.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And thanks for the note on the key usage, it feels a bit convoluted to figure out which parameters to set as of now.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Deriving ECC keys from HUK with TF-M</title><link>https://devzone.nordicsemi.com/thread/396465?ContentTypeID=1</link><pubDate>Fri, 18 Nov 2022 15:46:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6236a182-f43a-4c88-8283-d48a7a425392</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Generating asymmetric keys using huk derivation directly is not currently supported. Ideally you can use the psa_generate_key to create a random private key. In case you necessarily wants the key to be derived from HUK then they can use the psa_key_derivation_output_bytes function and try to do a psa_import_key. The issue with this solution is that there is a chance that psa_import_key will fail since the derived bytes don&amp;#39;t necessarily correspond to a private key. So the solution with HUK will have to try multiple calls of the psa_key_derivation_output_bytes until psa_import_key succeeds.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also as a note, which is not relevant based on the answer above:&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;a href="https://armmbed.github.io/mbed-crypto/html/api/ops/kdf.html?highlight=key_derivation#c.psa_key_derivation_output_key"&gt;armmbed.github.io/.../kdf.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Ths key_derivation_output_key does as attributes expects the new key attributes. So for example for an ECC key it will expect usage attributes such as: PSA_KEY_USAGE_SIGN_HASH&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>