Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to provision/store keys in TA secure storage #3766

Closed
jpmiceli opened this issue Apr 20, 2020 · 14 comments
Closed

[Question] How to provision/store keys in TA secure storage #3766

jpmiceli opened this issue Apr 20, 2020 · 14 comments

Comments

@jpmiceli
Copy link

How is it possible to securely store/provision keys in a TA's secure storage ?

I've devices which communicates together. The message are encrypted/decrypted by
Optee using AES GCM. In the current prototype, the key is hard-coded in TA (which
is bad).
I'd like to provision/store this key in the secure storage, but:

  • The device does not have an eMCC
  • Using an encrypted partition of the SD card seems not safe because the plain
    key should read by the REE (Linux) before it can be sent to the TA

I-m using OP-TEE version 3.6.0 (a5a43d3c6-dev)

Thanks for your help

@jenswi-linaro
Copy link
Contributor

Even without RPMB the secure storage still provides confidentiality, rollback-protection is a so-so though.

Another option is to derive the key from HUK via the System PTA, TA function PTA_SYSTEM_DERIVE_TA_UNIQUE_KEY, which in turn uses huk_subkey_derive().

@jpmiceli
Copy link
Author

Thanks for your answer,

Even without RPMB the secure storage still provides confidentiality
No doubt about it !

If I understand it correctly, you propose to generate the key inside the Optee/TA, I'm correct ?

The key returned by huk_subkey_derive() is depending on the HW. On my system, each device can be different (based on rpi3/4, based on A64 SoC, ...). In this situation, this function can still be used ?

@jenswi-linaro
Copy link
Contributor

If I understand it correctly, you propose to generate the key inside the Optee/TA, I'm correct ?

The key returned by huk_subkey_derive() is depending on the HW. On my system, each device can be different (based on rpi3/4, based on A64 SoC, ...). In this situation, this function can still be used ?

If you know what the key will be because it has been recorded during production or so you'll have a shared secret.

@jpmiceli
Copy link
Author

I continue my research on this topic and I found this #3346 which may be a solution for my problem.

I don't fully got it (I'm a beginner with security and Optee). My understanding is

  • My TA should be encrypted (pTA cannot be encrypted)
  • The keys should be embedded with the TA
  • The TA can read the key and store it in a secure way

But how can the key be embedded with the TA ?

  • Using incbin directive, macros, variables (or something similar) ? Is it considered as safe because the TA image is encrypted ?
  • Others possibilities ?

Just to be sure, in which version of Optee the possibility to use encrypted TA was added ? my current version (3.6) does not have this feature.

@jforissier
Copy link
Contributor

It should be safe to store the key in the TA as long as the TA is encrypted on the device. The TA (and therefore the key) would be decrypted only when OP-TEE loads the TA and at that point it would reside in secure memory only.

Just to be sure, in which version of Optee the possibility to use encrypted TA was added ? my current version (3.6) does not have this feature.

The encrypted TAs you're referring to were added in commit 2de17fd ("TA dev kit: add support for TA encryption"), and are documented here, see "3. (REE-FS) Encrypted TAs". This feature has not been included in a release yet.

However, there is another option to encrypt TAs called "Secure storage TAs", see here. The main difference with the above is, the TA is not pre-encrypted, instead it is encrypted by OP-TEE when you install it. So, you need to have the unencrypted TA on the device first, then install it, then delete/scrub the unencrypted TA. It may or may not cause deployment issues, depending on your use case. In fact, this mechanism was introduced as a part of a bigger framework which could potentially deal with remote installation, upgrade etc.

@jpmiceli
Copy link
Author

Thanks all for your support. I've a view of the possible solutions.

I will report to my team to see what will fit better with our flow

@jenswi-linaro
If I get it right, with our proposal, there is one key per device, which can be saved/stored during produciont. It is correct ?

About the encrypted TA - #3346, it can be backported to my project or still under testing or something ? Any deadline for the release ?

@jpmiceli
Copy link
Author

I missed one point:

@jforissier

In fact, this mechanism was introduced as a part of a bigger framework

It is possible to get info about this framework ?

@jforissier
Copy link
Contributor

About the encrypted TA - #3346, it can be backported to my project or still under testing or something ?

It should be safe and easy to backport.

Any deadline for the release ?

Well it is now more than 3 months since 3.8.0, so in theory it would be time for a new release. @jbech-linaro what do you think?

@jforissier
Copy link
Contributor

I missed one point:

@jforissier

In fact, this mechanism was introduced as a part of a bigger framework

It is possible to get info about this framework ?

Never happened, discussed in #1928.

@jbech-linaro
Copy link
Contributor

Well it is now more than 3 months since 3.8.0, so in theory it would be time for a new release. @jbech-linaro what do you think?

May 22nd is the target date for 3.9.0. I.e. pushed a bit more than previous years.

@b49020
Copy link
Contributor

b49020 commented Apr 23, 2020

@jforissier @jpmiceli

The encrypted TAs you're referring to were added in commit 2de17fd ("TA dev kit: add support for TA encryption"), and are documented here, see "3. (REE-FS) Encrypted TAs". This feature has not been included in a release yet.

Just to update here that encrypted TAs support is present in OP-TEE v3.8.0 release (commit 2de17fd present). Its just the documentation which was updated recently, thanks to @jforissier reminder.

@jforissier
Copy link
Contributor

@b49020 you're right, my mistake. What happened is, I ran git describe 2de17fda5 which returned 3.7.0-87-g2de17fda5 and I totally forgot the last release was 3.8.0 😮

@b49020
Copy link
Contributor

b49020 commented Apr 23, 2020

@jforissier no worries.

@jpmiceli
Copy link
Author

Thanks for all the support.

I started experimentation around Secure Storage TA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants