<?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>How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/109703/how-to-integrate-mbedtls-for-nrf9160-and-native-simulation-on-sdk-2-6</link><description>Dear Support Team 
 
 My goal is to build an application for two targets. The targets are an nrf9160 and a simulation target for running it natively on Linux (currently trying native_sim). 
 The application makes use of the mbedtls-API. For example the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 17 Apr 2024 14:49:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/109703/how-to-integrate-mbedtls-for-nrf9160-and-native-simulation-on-sdk-2-6" /><item><title>RE: How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/thread/479279?ContentTypeID=1</link><pubDate>Wed, 17 Apr 2024 14:49:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fc33596-757d-459b-b6e0-e8d7a3db2a28</guid><dc:creator>Cla</dc:creator><description>&lt;p&gt;Thank you, I will take a look.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/thread/479277?ContentTypeID=1</link><pubDate>Wed, 17 Apr 2024 14:42:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:788c68f3-7c1c-41be-a8d2-a93206b99ec3</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>[quote user="Cla"]Maybe I did not clarify my expectation clearly. For example the library `mbedtls_x509write` can be used on the nrf9160 without problem, but it can not be used with native sim, because it is not possible to activate the respective Kconfig option. But my expectation is, that it is possible, because I expect a software implementation of the `mbedtls_x509write`-interface to be available.&lt;br /&gt;&lt;br /&gt;Let me know, if I could explain my expectation and/or goal in a better way?[/quote]
&lt;p&gt;I found one developer in nordic with native_sim experience, and asked ca:&lt;br /&gt;&amp;quot;And SW mbedtls should not be too hard to make work with native_sim?&amp;quot;&lt;br /&gt;He answers:&lt;br /&gt;&amp;quot;it works already (at least in plain zephyr:&lt;br /&gt;tests/crypto/mbedtls/ builds and runs fine for native_sim )&lt;br /&gt;and it is used in quite a few other tests and samples&lt;br /&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;Can you take a look at that test and see if what you need is there?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/thread/478976?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2024 12:22:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee04101e-5215-42b0-8492-6463176011b7</guid><dc:creator>Cla</dc:creator><description>&lt;p&gt;Thank you for analyzing this.&lt;/p&gt;
[quote userid="106736" url="~/f/nordic-q-a/109703/how-to-integrate-mbedtls-for-nrf9160-and-native-simulation-on-sdk-2-6/478947"]Which APIs do you currently use in your code?[/quote]
&lt;p&gt;mbedtls_aes&lt;br /&gt;mbedtls_ecp&lt;br /&gt;mbedtls_mpi&lt;br /&gt;mbedtls_pk&lt;br /&gt;mbedtls_rsa&lt;br /&gt;mbedtls_sha256&lt;br /&gt;mbedtls_x509write&lt;/p&gt;
&lt;p&gt;My understanding is, that when building for nrf9160 with tfm activated, it will use the &amp;quot;alternative&amp;quot; implementation, when building with tfm. This will then cause the calls to be redirected to tfm-crypto?&lt;/p&gt;
&lt;p&gt;CONFIG_MBEDTLS_ENTROPY_HARDWARE_ALT=y&lt;br /&gt;CONFIG_MBEDTLS_AES_SETKEY_ENC_ALT=y&lt;br /&gt;CONFIG_MBEDTLS_AES_SETKEY_DEC_ALT=y&lt;br /&gt;CONFIG_MBEDTLS_AES_ENCRYPT_ALT=y&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;As for native_sim, the goal would be to use above libraries in their software implementation.&lt;/p&gt;
[quote userid="106736" url="~/f/nordic-q-a/109703/how-to-integrate-mbedtls-for-nrf9160-and-native-simulation-on-sdk-2-6/478947"]TF-M
&lt;ul&gt;
&lt;li&gt;I assume you need this?&lt;/li&gt;&lt;/ul&gt;[/quote]
&lt;p&gt;My understanding is, that this is not currently possible with native_sim. I heard it works on qemu with &lt;a id="" href="https://docs.zephyrproject.org/latest/boards/arm/mps2/doc/mps2_an521.html"&gt;https://docs.zephyrproject.org/latest/boards/arm/mps2/doc/mps2_an521.html&lt;/a&gt; but never tested. So if it uses the software implementation of the mbedtls libraries, I think it is not needed for native sim.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="106736" url="~/f/nordic-q-a/109703/how-to-integrate-mbedtls-for-nrf9160-and-native-simulation-on-sdk-2-6/478947"]Do you agree with this summary? &lt;br /&gt;Am I missing something? Do you disagree with anything?[/quote]
&lt;p&gt;Yes, sounds good. Maybe I did not clarify my expectation clearly. For example the library `mbedtls_x509write` can be used on the nrf9160 without problem, but it can not be used with native sim, because it is not possible to activate the respective Kconfig option. But my expectation is, that it is possible, because I expect a software implementation of the `mbedtls_x509write`-interface to be available.&lt;br /&gt;&lt;br /&gt;Let me know, if I could explain my expectation and/or goal in a better way?&lt;br /&gt;&lt;br /&gt;Thanks on the support so far.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/thread/478947?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2024 11:20:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f64b06b-55c1-40a0-86ba-4c37d54f79e2</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Doing some testing:&lt;/p&gt;
&lt;p&gt;zephyr/samples/drivers/crypto works with native_sim&lt;/p&gt;
&lt;p&gt;zephyr/samples/tfm_integration/tfm_psa_test does not work&amp;nbsp; with native_sim (even with vanilla zephyr)&lt;/p&gt;
&lt;p&gt;So to sum up parts that might have problems with native_sim:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Modem networking
&lt;ul&gt;
&lt;li&gt;Fix: Assuming IP works for native_sim, configure networking to use that instead&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;TF-M
&lt;ul&gt;
&lt;li&gt;I assume you need this?&lt;/li&gt;
&lt;li&gt;Not sure how or if to fix this for native_sim at the moment.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Crypto
&lt;ul&gt;
&lt;li&gt;Which APIs do you currently use in your code?&lt;/li&gt;
&lt;li&gt;Fix: I have never tried Mbedtls-shim before, but look into using that&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;HW specific components
&lt;ul&gt;
&lt;li&gt;Fix: Simulate&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Do you agree with this summary? &lt;br /&gt;Am I missing something? Do you disagree with anything?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/thread/478939?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2024 10:50:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3a52f81-b9cb-4121-be88-3625eb64a5a6</guid><dc:creator>Cla</dc:creator><description>&lt;p&gt;Thanks for the quick reply. Disabling and Mocking the crypto-stuff could be an option.&lt;br /&gt;&lt;br /&gt;I was just wondering, if there is a supported way to achieve this, since software implementations for Mbedtls exists.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/thread/478925?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2024 10:22:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8646a079-385d-4a64-afc9-52c7f590fb1b</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Speaking of the Dev, they just answered:&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;br /&gt;&lt;span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This is not something we claim to support. The NCS MbedTLS config is coupled with building for our products. &lt;/p&gt;
&lt;p&gt;I have no idea if their use case is feasible, I suspect it would require a lot of config and build system voodoo, but I don&amp;#39;t think we can support them on this. You are probably as likely as any of the developers to be able to provide advice here.&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;br /&gt;So yea, I can spend some time to try and build a crypto sample for native_sim, but i would not have high hopes. As they say the tight coupling between our SoC and libraries may make this hard.&lt;/p&gt;
&lt;p&gt;One alternative would be to disable crypto for your project, but that might make the whole exercise a bit pointless?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/thread/478923?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2024 10:12:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f662ac55-e887-4c10-93a3-aafc4739e1fa</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;The status on this ticket is that I have asked our crypto developers if they have any ideas here.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/thread/478816?ContentTypeID=1</link><pubDate>Mon, 15 Apr 2024 14:22:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:90e961d5-d1ea-4e8d-b95a-64d796a35a7e</guid><dc:creator>Cla</dc:creator><description>&lt;p&gt;We have some unit-test in place. They use the native-posix board with `CONFIG_ASAN` and `CONFIG_UBSAN` activated. We run the unit-test directly on the hardware also.&lt;br /&gt;&lt;br /&gt;In addition we would like to do some integration/system-testing with a simulation setup.In the past we have used `qemu`, but it is not possible to activate `CONFIG_ASAN` to my knowledge. We are evaluating `native_sim` (released with zephyr 3.5) to do system-testing in a simulation environment that allows us to use native debugging tools and other tooling like above mentioned address sanitizer.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Edit: on the hardware we run the unit tests without CONFIG_ASAN and CONFIG_UBSAN, because they are not supported to our knowledge.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/thread/477780?ContentTypeID=1</link><pubDate>Tue, 09 Apr 2024 11:32:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63000a54-1ddf-4a07-8d2e-ce808a2e2dcf</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;I am honestly a bit new to the whole testing stuff.&lt;/p&gt;
&lt;p&gt;So to learn, I have talked with a colleguea who knows more than me, and I think the first question to ask is:&lt;/p&gt;
&lt;p&gt;What exactly do you want to test?&lt;br /&gt;Is this a unit test or an integration test?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/thread/476879?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2024 12:34:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8dc2f9f2-88f8-40a8-8f5e-9bc8615a8277</guid><dc:creator>Cla</dc:creator><description>&lt;p&gt;We use `BUILD_WITH_TFM` (Not profile minimal though).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/thread/476877?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2024 12:30:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c68ed4fd-9fa8-4539-9d89-b867537326a1</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;I am missing one part:&lt;/p&gt;
[quote user="Cla"]Just to be clear, we do not use NRF_SECURITY for the nrf9160 either.[/quote]
&lt;p&gt;What are you doing on the nRF9160 from before?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/thread/476875?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2024 12:26:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e4c8040-440d-4602-8582-42fb7b5c57ef</guid><dc:creator>Cla</dc:creator><description>&lt;p&gt;It did, thanks. Just to be clear, we do not use NRF_SECURITY for the nrf9160 either.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;My thinking was to use MBEDTLS-APIs.&lt;br /&gt;&lt;br /&gt;Then when building for nrf9160 it would be forwarded to PSA_CRYPTO (which my understanding is, that is currently happending via the `_ALT` implementations), PSA_CRYPTO then uses the cryptocell hardware internally.&lt;/p&gt;
&lt;p&gt;Then when building for native_sim it would use software implementations for the same functions of MBEDTLS.&lt;br /&gt;&lt;br /&gt;This would have been my thinking. I do not know, if this is possible or, whether there is a better solution to achieve my goal. I try to also communicate my goal (X = build for nrf9160 and native_sim) and not just my current approach (Y = build MBEDTLS for native_sim) as not to cause the XY-communication problem.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I hope I could clearify my thinking.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/thread/476574?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2024 12:42:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e74a8b71-26a2-4c6c-96f3-da7006cc627b</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Right.&lt;/p&gt;
&lt;p&gt;Then the next question is:&amp;nbsp; Why would NRF_SECURITY not work on native_sim?&lt;br /&gt;The easy answer is likely &amp;quot;Because we have not put effort into supporting this&amp;quot;.&lt;/p&gt;
&lt;p&gt;But maybe before that: Do you use the cryptocell hardware for your crypto on the nRF9160? If so, I also doubt that the native_sim supports that. Using software implementations of&amp;nbsp; cypto on the other hand in theory should not be an issue I guess.&lt;/p&gt;
&lt;p&gt;This was not very coherent, but&amp;nbsp; I hope that it made some sense?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/thread/476547?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2024 11:50:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b0bc5fd-a93c-48af-9559-be1cbde7e83b</guid><dc:creator>Cla</dc:creator><description>&lt;p&gt;`nrf/subsys/nrf_security/Kconfig.tls` is sourced conditionally. It is only available if NRF_SECURITY is active. See line 47 of `nrfxlib/nrf_security/Kconfig`:&lt;br /&gt;&lt;br /&gt;```&lt;br /&gt;if NRF_SECURITY&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;# Include TLS/DTLS and x509 configurations&lt;br /&gt;rsource &amp;quot;Kconfig.tls&amp;quot;&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;endif # NRF_SECURITY&lt;br /&gt;&lt;br /&gt;```&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/thread/476458?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2024 08:02:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3dc2cae-b603-4909-8410-09fabbb7bca6</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>[quote user="Cla"]Alternatively, are there other options for running a simulation target except native_sim?[/quote]
&lt;p&gt;Not sure if it is better or not, but Renode exists:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://renodepedia.renode.io/boards/nrf9160dk_nrf9160/?view=software&amp;amp;demo=hello_world"&gt;https://renodepedia.renode.io/boards/nrf9160dk_nrf9160/?view=software&amp;amp;demo=hello_world&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;However, I think/hope it should be possible to make native_sim work here also.&lt;br /&gt;Are you able to find a sample and/or minimal sample I can reproduce your issue on?&lt;br /&gt;I find it odd that these are the dependencies, as I can not find them in the definition of MBEDTLS_X509_LIBRARY. (nrf/subsys/nrf_security/Kconfig.tls)&lt;/p&gt;
[quote user=""]Check these unsatisfied dependencies: (TFM_PROFILE_TYPE_MINIMAL || NRF_SECURITY) (=n).[/quote]&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/thread/476275?ContentTypeID=1</link><pubDate>Thu, 28 Mar 2024 09:28:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3bf1f43c-9216-4fbc-ab54-7c81c67ce55c</guid><dc:creator>Cla</dc:creator><description>&lt;p&gt;Alternatively, are there other options for running a simulation target except native_sim?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/thread/476270?ContentTypeID=1</link><pubDate>Thu, 28 Mar 2024 07:45:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b6d8977-405a-40d5-af75-0ba7e31c3a12</guid><dc:creator>Cla</dc:creator><description>[quote userid="106736" url="~/f/nordic-q-a/109703/how-to-integrate-mbedtls-for-nrf9160-and-native-simulation-on-sdk-2-6/476179"]Use VS Code extension Kconfig search of &amp;quot;west build -t menuconfig&amp;quot; to find which of these are &amp;quot;n&amp;quot; and then figure out why those are &amp;quot;n&amp;quot; and if you can make them become &amp;quot;y&amp;quot;.[/quote]
&lt;p&gt;Thanks for the quick reply.&lt;/p&gt;
&lt;p&gt;I consider the first part of my question answered and understand, that for `sdk 2.6` we should use the MBEDTLS linked in the `west.yml` from `sdk-nrf`.&lt;br /&gt;&lt;br /&gt;This leaves the second part all the more unclear. How can certain features of MBEDTLS be configured for native_sim?&lt;br /&gt;&lt;br /&gt;Lets take another look at the above mentioned config. As you point out there are the two unsatisfied dependencies (TFM_PROFILE_TYPE_MINIMAL || NRF_SECURITY) . Now neither of those can be activated to work with native_sim. For starter native_sim is not a NORDIC_SOC so NRF_SECURITY is not possible. On the other hand it does also not support TFM such that TFM_PROFILE_TYPE_MINIMAL can not be activated.&lt;br /&gt;&lt;br /&gt;I hope, that I could clarify my question about how to configure MBEDTLS in the above mentioned circumstances?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to integrate MBEDTLS for nrf9160 and native simulation on sdk 2.6?</title><link>https://devzone.nordicsemi.com/thread/476179?ContentTypeID=1</link><pubDate>Wed, 27 Mar 2024 14:10:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fed08e2d-cff4-4985-ba7c-1265175ed2c3</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi Cla,&lt;/p&gt;
[quote user=""]Which mbedtls-version to use with `sdk-2.6` (sdk vs upsteam, revision v3.5.2-ncs1 vs revision 66ed2279d6222056af172c188eaf4dcfed481032) ?[/quote]
&lt;p&gt;sdk-nrf is the boss of west includes. See &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/main/west.yml"&gt;west.yml&lt;/a&gt;. &lt;br /&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/60c316440ea2670f791a1bccb1427cd7ce883dee/west.yml#L77"&gt;name-allowlist&lt;/a&gt; decides which repos zephyr are allowed to include. Since mbedtls is not here, we know that mbedtls is not from zephyr.&lt;/p&gt;
&lt;p&gt;The two previous links was for main, but for v2.6.0 we now change to that. Here we can &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/3190fa573ff67bfb745028f203e9d0ea4144a1ce/west.yml#L138-L141"&gt;scroll down&lt;/a&gt; and find that mbedtls uses v3.5.2-ncs1.&lt;/p&gt;
&lt;p&gt;To verify this we can navigate in git bash to &amp;quot;ncs/modules/crypto/mbedtl&amp;quot; and do &amp;quot;git log&amp;quot;:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;commit acea48fc8a5eb227033b55e6ec012731218e257f (HEAD, tag: v3.3.0-ncs2-rc2, tag: v3.3.0-ncs2-2, tag: v3.3.0-ncs2-1-rc1, tag: v3.3.0-ncs2-1, tag: v3.3.0-ncs2, manifest-rev)
Author: Frank Audun Kvamtr&amp;#248; &amp;lt;frank.kvamtro@nordicsemi.no&amp;gt;
Date:   Tue Oct 17 09:13:17 2023 +0200

    [nrf noup]  Fix buffer overread with stream cipher
    
    Recreated from commit faf0b8604ac49456b0cff7a34ad27485ca145cce
    which provides the following information
    
    &amp;quot;With stream ciphers, add a check that there&amp;#39;s enough room to read a MAC
    in the record. Without this check, subtracting the MAC length from the
    data length resulted in an integer underflow, causing the MAC calculation
    to try reading (SIZE_MAX + 1 - maclen) bytes of input, which is a buffer
    overread.&amp;quot;
    
    This commit is a &amp;quot;noup&amp;quot; since TLS/DTLS is undergoing refactoring and
    the content of the commit had to be recreated.
    
    Signed-off-by: Frank Audun Kvamtr&amp;#248; &amp;lt;frank.kvamtro@nordicsemi.no&amp;gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user=""]How can we do all this, while ensuring, that hardware-crypto-acceleration is used when building for the nrf9160?[/quote]
&lt;p&gt;The hope is that zephyrs board-definition feature will be able to make sure that this works as expected.&lt;br /&gt;You should still verify this after it looks like it works though.&lt;/p&gt;
[quote user=""]Which way do you recommend to configure MBEDTLS to achieve the goal described above? Could we use `&lt;span&gt;CONFIG_MBEDTLS_CFG_FILE&lt;/span&gt;&lt;a href="https://docs.zephyrproject.org/latest/kconfig.html#CONFIG_MBEDTLS_CFG_FILE"&gt;&lt;/a&gt;` instead?[/quote]
&lt;p&gt;I think you need to do this step by step. Why does it fail now?&lt;br /&gt;Then create boards/native_sim.conf and add configurations needed for this board there until it works.&lt;br /&gt;And/or move configs from prj.conf to boards/nrf9160dk_nrf9160_ns.conf which are not needed for native_sim also.&lt;/p&gt;
[quote user=""]Check these unsatisfied dependencies: (TFM_PROFILE_TYPE_MINIMAL || NRF_SECURITY) (=n).[/quote]
&lt;p&gt;Use VS Code extension Kconfig search of &amp;quot;west build -t menuconfig&amp;quot; to find which of these are &amp;quot;n&amp;quot; and then figure out why those are &amp;quot;n&amp;quot; and if you can make them become &amp;quot;y&amp;quot;.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>