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

Define some structure for lifetime values #3302

Conversation

gilles-peskine-arm
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm commented May 4, 2020

Here is a description of how to encode lifetime values. We intend to include the types and values defined in this pull request with the same semantics in an upcoming release of the PSA Cryptography API specification.

This proposal is backward-compatible with the current values for volatile keys (0) and persistent keys (1). Platforms with a secure element (i.e. a cryptoprocessor that can process keys which are not accessible to the PSA crypto core) should use the lifetime 0x1ff (whether the key material is stored inside the secure element, or in generic PSA storage in a form wrapped by the secure element).

This pull request defines the lifetime structure, but does not yet implement any new feature. A future pull request will adapt the (currently experimental) secure element support code accordingly.

This stems from an internal discussion (private link). This pull request is a continuation of ARMmbed/mbed-crypto#358. The first commit here is the final state of that mbed-crypto PR (the history there wasn't worth carrying over).

Status: API approved. Now needs to be implemented (treat all volatile values as such, even if they're in a secure element).

@gilles-peskine-arm gilles-peskine-arm added enhancement mbed TLS team needs-review Every commit must be reviewed by at least two team members, component-crypto Crypto primitives and low-level interfaces labels May 4, 2020
@gilles-peskine-arm gilles-peskine-arm requested a review from yanesca May 4, 2020 17:16
mpg
mpg previously approved these changes May 5, 2020
Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have:

Everything looks good to me.

@mpg
Copy link
Contributor

mpg commented May 5, 2020

I looked at the reported failure in the pr-merge job and it looks like a temporary glitch in the infrastructure - failed to clone the repo - not a problem with this PR.

yanesca
yanesca previously approved these changes May 5, 2020
Copy link
Contributor

@yanesca yanesca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave a second pass of review and did a spell check. I have a minor suggestion for improvement, other than that it looks good to me.

@gilles-peskine-arm gilles-peskine-arm dismissed stale reviews from yanesca and mpg via e216018 May 5, 2020 15:32
@gilles-peskine-arm gilles-peskine-arm force-pushed the psa-lifetime-persistence-indicator branch from e216018 to d021b66 Compare May 5, 2020 15:33
@gilles-peskine-arm gilles-peskine-arm requested review from yanesca and mpg May 5, 2020 15:33
yanesca
yanesca previously approved these changes May 5, 2020
Copy link
Contributor

@yanesca yanesca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

mpg
mpg previously approved these changes May 6, 2020
@mpg mpg removed the needs-review Every commit must be reviewed by at least two team members, label May 6, 2020
@mpg
Copy link
Contributor

mpg commented May 6, 2020

Does this need a ChangeLog entry? I'm not sure.

@gilles-peskine-arm
Copy link
Contributor Author

So far new PSA features haven't been getting a changelog entry, but we've started to write changelog entries for behavior change. In any case, this is documentation only so far, the new feature isn't implemented.

The documentation does indicate that certain lifetime values are now considered volatile, but the code doesn't treat them as such. (This is not a behavior change because the volatility of these values was previously unspecified.) So, annoyingly, we shouldn't merge this yet.

* Lower 8 bits: persistence level
    * 0: volatile
    * 1: persistent (default)
    * 2-127: persistent (reserved for future PSA specifications)
    * 128-254: persistent (reserved for vendors)
    * 255: read-only
* Upper 24 bits: location indicator
    * 0: built-in
    * 1: primary secure element
    * 2-0x7fffff: reserved for future PSA specifications
    * 0x800000-0xffffff: vendor-specific

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
gilles-peskine-arm and others added 11 commits May 11, 2020 11:14
Drop lifetime_ or LIFETIME_ to make the names shorter. They're still
unambiguous.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Call persistence "default" because that is genuinely the default that
applications should use if they don't know better. It's slightly
misleading in that the default persistence when you create a key is
volatile, not this: "default" is the default persistence for
persistent keys, not the default persistence for keys in general. But
we haven't found a better name.

Introduce the term "primary local storage" to designate the default
storage location.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Applications need this to combine implementation-specific values of
persistence levels and location indicators.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Co-authored-by: Janos Follath <janos.follath@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Now that lifetimes have structures and secure element drivers handle
all the lifetimes with a certain location, update driver registration
to take a location as argument rather than a lifetime.

This commit updates the PSA specification draft.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Now that lifetimes have structures and secure element drivers handle
all the lifetimes with a certain location, update driver registration
to take a location as argument rather than a lifetime.

This commit updates the Mbed TLS implementation.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Now that lifetimes have structures and secure element drivers handle
all the lifetimes with a certain location, update driver registration
to take a location as argument rather than a lifetime.

This commit updates the tests.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
@gilles-peskine-arm gilles-peskine-arm force-pushed the psa-lifetime-persistence-indicator branch from 7a2e015 to fb79dfe Compare May 11, 2020 09:18
Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approving after rebase on a more recent version of the base branch.

@gilles-peskine-arm gilles-peskine-arm added needs-review Every commit must be reviewed by at least two team members, and removed DO-NOT-MERGE labels May 12, 2020
Copy link
Contributor

@yanesca yanesca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beyond a rebase to more recent head, the PR contained new commits compared to my local copy. I am not sure if I have reviewed them previously and gave another pass just to be sure.

Looks good to me.

@mpg mpg added approved Design and code approved - may be waiting for CI or backports and removed needs-review Every commit must be reviewed by at least two team members, labels May 12, 2020
@gilles-peskine-arm gilles-peskine-arm merged commit ee61b66 into Mbed-TLS:development May 14, 2020
stevew817 added a commit to stevew817/mbedtls that referenced this pull request Jun 1, 2020
stevew817 added a commit to stevew817/mbedtls that referenced this pull request Jun 1, 2020
Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports component-crypto Crypto primitives and low-level interfaces enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants