-
Notifications
You must be signed in to change notification settings - Fork 30
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
API function to register an existing key #242
Comments
It strikes me that this is closer to Import than it is to Generate. It is essentially Import, but instead of a buffer with the bits, that you need to move to a protected location, you already have the bits in a protected location and simply need to add the metadata. If the key is persistent, the metadata and the key material would end up being stored in different places. So, that leads to the question, does register need to support persistent keys. This does of course mean that the discussion on what happens if you try to destroy the key is moot. |
Hmmm, I hadn't really considered that. We did have a request for the volatile case to work. But I think the primary use case is a persistent metadata object:
I'd expect that in such scenarios, steps 2 and 3 tend to be done by different pieces of code, and the code that uses the key wouldn't know whether to call register and with what label. |
Good point |
Add the possibility to register a PSA key which is baked by some driver. The key material in this case will simply be a "label" that has to be known/understood from that driver. It implements requirements from: - ARM-software/psa-api#242 - Mbed-TLS/mbedtls#9255 Signed-off-by: Valerio Setti <vsetti@baylibre.com>
Add the possibility to register a PSA key which is baked by some driver. The key material in this case will simply be a "label" that has to be known/understood from that driver. It implements requirements from: - ARM-software/psa-api#242 - Mbed-TLS/mbedtls#9255 Signed-off-by: Valerio Setti <vsetti@baylibre.com>
Add the possibility to register a PSA key which is baked by some driver. The key material in this case will simply be a "label" that has to be known/understood from that driver. It implements requirements from: - ARM-software/psa-api#242 - Mbed-TLS/mbedtls#9255 Signed-off-by: Valerio Setti <vsetti@baylibre.com>
Is it ok to register a persistent key with a key ID outside the application range? This may be tempting in when the registered key is vendor-specific and not handled by normal application code. However, it would be difficult to specify and implement, since such keys should not interfere with volatile keys and any other mechanism by which an implementation may define keys in the implementation range. So I think the answer is no, the same key IDs are acceptable for register as for import/generate/derive. |
So this is intended for binding a PSA Crypto key identifier, and key attributes, to some existing key material that is already stored within the implementation under some other naming scheme (the API namePresumably, as the material is already internal, it will be stored in a specific key location, and the key lifetime in the provided key attributes is essential for the discovery and registration of the key id with the key material. Given that support for unbound key material, and the naming scheme, will be implementation and storage-location specific - I would like to propose that the API name dropped the As an alternative name, I would also suggest Key attribute handlingIs there any expectation of which key attributes would already be associated with the key material? For example:
On key destructionOn the question of what happens with A suggestion that enables both the intention of the application, and the behavior permitted by the implementation, to be clear, would be to add a separate unregister function that explicitly undoes the actions of We might want to consider if would be permitted, and what it would mean, to create a key, and then unregister it? |
With the statements on @athoelke, I'm happy to see "opaque" being dropped from the name in the initial proposal. Main criticisms:My main criticism of the initial proposal in this issue (as I've raised in the Mbed TLS biweekly):
When discussing the means of additional context-information that is retrieved from or passed to to any specialized (opaque) driver, I feel it is natural to also discuss a "standard case", where the driver-specific information is already provided, as-is, meaning that the "registration" is inherit in the system and is not something you are required to do with extra API calls. What I mean by this is the case when no additional context-information is required to be passed to any opaque driver to be able to use the driver and its keys Inherent-registration versus runtime-registrationInherent registration can be described as follows: Compile-time established link between between a Runtime-registration can be described as follows: Establishing the aforementioned link between Points for consideration:
Registering per-key or per-driverThe issue lists a proposal is focused on per-key registration which is the widest granularity possible for adding metadata to a key in a special driver. This is the main reason Regardless, if the registration is with the following API:
.. then there is a potential of a double registration of And there is an option that the information is vaguely passed from per-key registrations when it is indeed intended per-driver One option that is likely a bit clearer, which would allow for both types of registration (per-key and per-driver) is to extend the functionality of the I propose the following extension:
When using these APIs we would achieve the following:
Implementation details: It would be best for API to keep this additional feature in Implementation details: It is likely best for the API to store the additional metadata as a pointer and size so that ABIs breaks can be avoided Background: Builtin key support and SE drivers (driver)The additions in the raised issue is done to help transition away from the now deprecated methodology of SE drivers in Mbed TLS distribution (now placed in TF-PSA-Crypto) The existing functionality of SE drivers lives alongside the so-called builtin key support which has multiple points of documentation in the Proposed scope of documentation in TF-PSA-Crypto. The Using the existing Note: It is possible to provide any driver-specific metadata via the For any register-like calls where additional information is passed to support opaque drivers (via opaque keys) I hope the information is transferred all the way towards the driver (similar to the existing The implementation example provided here will assume a driver named APIs for registering per driverGiven the initial proposal for psa_register_key the implementation would likely be:
I deem this a double registration because the population of the attributes-type tied to key APIs for registering via
|
As the developer of an application (or application stack) using the PSA crypto API on a device with a secure element,
I want to access keys that are provisioned onto the device by a process outside of my control,
so that my application can use pre-provisioned keys while sticking to the PSA API.
The idea is that many devices that have a secure element have a factory process for injecting credentials. That process exists and can't be retooled easily, so we can't insist that this process becomes aware of the PSA API. The device does have a software stack that implements the PSA crypto API. Through that API, we can create new keys and use them. But there's no standard way to use the credentials that are provisioned during the device manufacturing.
More generally, there's interest in using a key through PSA even when it's created through proprietary means.
Mbed TLS implemented a function to do that alongside its original secure element interface:
mbedtls_psa_register_se_key()
. That API was tied to the interface, and had some limitations (notably, it can't be used with volatile keys), so in our next major release (TF-PSA-Crypyo 1.0), we are evolving the API. We have heard interest in making this feature official in the PSA API.The starting proposal is as follows:
This is a key creation function, taking
attributes
as input andkey_id
as output like the others. The way to obtain the key material is by associating the PSA key identifier with some existing “slot”. In PSA terms, the meaning of thelabel
parameter is implementation-specified, and likely to be different for each supported key location.With Mbed TLS opaque drivers, there are two plausible meanings for
label
:In practice, the primary intent is to pass a slot number, or slot label, or key name, in the secure element.
Unresolved question: does
psa_destroy_key
only destroy the PSA key stub, or does it also destroy the underlying key?Unresolved question: what can this function mean for transparent keys (keys in the location
PSA_KEY_LOCATION_LOCAL_STORAGE
)? Possibly this might duplicate the functionality that Mbed TLS calls “built-in keys”, which are a way to access keys that were not created through PSA, such as a HUK or HUK-derived key. These are independent features in Mbed TLS partly for historical reasons, but also because they are intended for different scenarios, and it's unclear whether a unified API would handle all the desired scenarios. Typically, the set of available built-in keys is decided by the device integrator and will not change over time, whereas registrable keys can be created dynamically if the proprietary provisioning scheme extends after the factory phase of the device lifecycle. Also they interact very differently with driver dispatch.Timeline: we would ideally like to release the official
psa_register_opaque_key
in TF-PSA-Crypto 1.0, which means the official API should be stable (not necessarily released) by late June 2025.The text was updated successfully, but these errors were encountered: