Reference for mutual TLS and private key handling

I intend to implement an application on nrf9160, that makes use of mutual-tls to communicate with a peer.

To this end, I need to store a private key in a save place on the nrf9160 and create tls-sockets from it.

My understanding of the recommended approach is as follows:

  1. Comparing the developer.nordicsemi.com/.../README.html flash a provisioning image to initialize the HUK, hardware unique keys.
  2. Flash the production image, that has protected storage enabled.
    1. Generate cryptographic randomness
    2. Write it to protected storage
    3. The protected storage will encrypt it using the identity key `NRF_KMU_SLOT_IDENT`
    4. Then write it to internal trusted storage (optionally additionaly encrypted with NRF_KMU_SLOTMKEK if configured that way by selecting CONFIG_TFM_ITS_ENCRYPTED)
    5. Read it to NSPE-RAM from protected storage to create csr with mbedtls.
    6. Read it to NSPE-RAM from protected storage to hand it off to zephyrs tls_credentials_add-API.

From devzone.nordicsemi.com/.../persistent-storage-of-keys-and-data-using-the-nrf-connect-sdk I understand, that the recommended approach would be to use the crypto api to generate a key with persistent live-time. This stores it in ITS, but would that not be unencrypted unless above config is set?

Am I understanding the recommended approach correctly?

Are there better alternative? For example:

  1. Can slots in the KMU be used to store the private key forgoing the need for protected storage altogether?
  2. Can the key be derrived from a HUK every time before use forgoing the need to store it anywhere persistently? If so which HUK shall be used?
  3. How many space is in the KMU? I understand 125 slots a 128 bits/slot?
  4. Is there an alternative to tls_credentials_add and mbedtls sockets, that allows to store the information persistently in some other way? Maybe developer.nordicsemi.com/.../sockets.html ?


Edit: please fix your forum. I had a much harder time making above text show properly then it should be.

Parents Reply Children
  • In that case, we usually recommend that you do TLS operations in the modem of the nRF9160, and not in the application.
    The modem has its own security features, so you do not have to handle that yourself, which will make life easier for everyone involved.

    To make sure this is not an XY Problem:

    Is there any reason that you use the application for TLS instead, and are you sure that is the way you want to do it?

  • Thank you for your reply. I intentionally asked the question as openly as I could to check, if there are alternatives, that I am unaware of.

    Please note, that I am not intending to use the nrf9160 for LTE. Instead I am using it with other networking interfaces.

    Can the TLS operations of the modem be used with (zephyr) sockets, that do not use the modem (LTE) but some other networking interface?

    If no, that is the reason that I use the application for TLS.
    If yes, could you give me some more information on it?

  • In other words, I am attempting to ask: what is the best way to do Y? Y=`generate and securely store a private key for mutual tls on an nrf9160 on a network interface, that is not LTE`?

  • My first though is: Why in the world would you use a nRF9160 and then go ahead and use another network interface?
    So if you want to entertain my curiosity, I am curious to what you are doing? (optional)

    However, that is besides the point. I agree that in your case, it makes sense to use TLS from the application, so I will help you with that, which is why you are here after all.

    Yes, TLS from the application is what I would recommend.

    I think the PSA TLS sample might be what you are looking for, but I suspect that you have seen this sample already.

    Next week I will look into the questions you got in the top of this ticket, cause I need to read some on this to be sure before I give answers.

  • Thanks.

    From the sample you linked, I understand, that one would add the credentials anew with `tls_credentials_add` after each reset. Do you agree?

Related