NRF_LOG crashes when used in crypto examples SDK17.1.0

Hello

We have been using the RSA example found in the nrf_cc310/rsa which uses INTEG_TEST_PRINT, a mask of SEGGER_RTT_printf, for debugging. When using NRF_LOG instead of INTEG_TEST_PRINT and functions like CRYS_RSA_PKCS1v15_Decrypt return any type of error, NRF_LOG crashes. When they do not fail, everything works as expected. 

Tried different configurations in the config.h file, but the issue persists. 


Why do you use INTEG_TEST_PRINT in the crypto examples instead of NRF_LOG? 

Is NRF_LOG using the same resources as the crypto library, which could create conflicts? 

The only relevant issue I found was this one.https://devzone.nordicsemi.com/f/nordic-q-a/84309/compile-examples-from-standalone-sdk-by-using-command-line-and-uart-traces/350958
But didn't seem to help in my case. By the way I now use RTT client for printing, but I am sure this issue is the same when using UART for NRF logs. 

Regards,

  • Hi,

    What do you mean by "NRF_LOG crashes"?

    I'm not sure exactly why INTEG_TEST_PRINT is used in the code, but the nrf_cc310 code is primarily from ARM. We recommend using nrf_crypto library instead of using the CC310 API directly, this have been more tested and implements more parameter tests to avoid issues.

    If you are using Segger Embedded Studio, please make sure you do not use the latest version, but the version mentioned in the SDK release notes.

    Best regards,
    Jørgen

  • Hi Jorgen,

    When I use NRF_LOG, printing stops after the call of  CRYS_RSA_PKCS1v15_Decrypt (if the function returns an error). It is likely that firmware stops working too, but I haven't confirmed that properly. If I use RTT or the INTEG_TEST_PRINT does not create the same issue. 

    Should I not use the CC310 API? 

    Can you direct me to an RSA example using the nrf_crypto library? 

    Is it correct that the nrf_crypto library uses hardware acceleration on nrf52840 and software in the other ICs?

    I am using GCC and makefiles. 

    It seems like my problem is very similar to this one here:
    https://devzone.nordicsemi.com/f/nordic-q-a/84309/compile-examples-from-standalone-sdk-by-using-command-line-and-uart-traces/350958

    But that solution didn't work for me. 

    If I could use the nrf_crypto for RSA I would probably prefer to do that because the only other viable solution would be to remove nrf_log and create my own library on top of SEGGER_RTT_printf. Which is not my go-to solution.


    Kind regards,

  • Shinmen said:
    When I use NRF_LOG, printing stops after the call of  CRYS_RSA_PKCS1v15_Decrypt (if the function returns an error). It is likely that firmware stops working too, but I haven't confirmed that properly. If I use RTT or the INTEG_TEST_PRINT does not create the same issue. 

    Did you initialize the logger through NRF_LOG_INIT() macro in the application? If you try to use NRF_LOG for logging without first initializing the library, it will likely crash.

    Shinmen said:
    Can you direct me to an RSA example using the nrf_crypto library? 

    Is it correct that the nrf_crypto library uses hardware acceleration on nrf52840 and software in the other ICs?

    My bad, I thought that the nrf_crypto library in nRF5 SDK supported RSA, but it seems that this is not implemented. It is however implemented in the corresponding nrf_security library in nRF Connect SDK.

    Shinmen said:
    Is it correct that the nrf_crypto library uses hardware acceleration on nrf52840 and software in the other ICs?

    This depends on the configuration set in your sdk_config.h file. You can choose to use SW backends for most cryptographic algorithms on nRF52840 as well, but the examples will by default configured to use the CC310 backend in pca10056 projects.

    Shinmen said:
    It seems like my problem is very similar to this one here:
    https://devzone.nordicsemi.com/f/nordic-q-a/84309/compile-examples-from-standalone-sdk-by-using-command-line-and-uart-traces/350958

    But that solution didn't work for me. 

    If I could use the nrf_crypto for RSA I would probably prefer to do that because the only other viable solution would be to remove nrf_log and create my own library on top of SEGGER_RTT_printf. Which is not my go-to solution.

    Please let me know if my suggestion on first paragraph does not help. I can't see any resource conflicts between NRF_LOG and the CC310 usage that should prevent you from using them together.

Related