Update PSA transition guide for TF-PSA-Crypto 1.0 #472

Merged
gilles-peskine-arm merged 14 commits from psa-transition-guide-20250630 into development 2025-09-26 16:11:00 -05:00
gilles-peskine-arm commented 2025-09-23 11:37:59 -05:00 (Migrated from github.com)

Update the PSA transition guide for TF-PSA-Crypto 1.0. There is not a lot to change, since we already had most of the pieces in place in 3.6. In this PR:

  • Change the product name from “Mbed TLS” to “TF-PSA-Crypto”.
  • Keep all discussions related to migrating away from legacy APIs that have been removed.
  • Remove a few parts discussing how to mix PSA with legacy APIs that have now been removed.
  • Discuss a few new relevant features.

Note that links are still pointing to the 3.6 documentation, since we don't have TF-PSA-Crypto on readthedocs yet. For new functions, I linked to the source of the header file that describes it.

PR checklist

  • changelog provided | not required because: doc only
  • framework PR not required
  • mbedtls development PR provided Mbed-TLS/mbedtls# | not required because: crypto only
  • mbedtls 3.6 PR https://github.com/Mbed-TLS/mbedtls/pull/10421
  • tests not required because: doc only
Update the PSA transition guide for TF-PSA-Crypto 1.0. There is not a lot to change, since we already had most of the pieces in place in 3.6. In this PR: * Change the product name from “Mbed TLS” to “TF-PSA-Crypto”. * Keep all discussions related to migrating away from legacy APIs that have been removed. * Remove a few parts discussing how to mix PSA with legacy APIs that have now been removed. * Discuss a few new relevant features. Note that links are still pointing to the 3.6 documentation, since we don't [have TF-PSA-Crypto on readthedocs](https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/279) yet. For new functions, I linked to the source of the header file that describes it. ## PR checklist - [x] **changelog** provided | not required because: doc only - [x] **framework PR** not required - [x] **mbedtls development PR** provided Mbed-TLS/mbedtls# | not required because: crypto only - [x] **mbedtls 3.6 PR** https://github.com/Mbed-TLS/mbedtls/pull/10421 - **tests** not required because: doc only
dbuenzli commented 2025-09-24 17:53:57 -05:00 (Migrated from github.com)

Currently the pkg-config package to use PSA crypto is mbedcrypto is that expected to change?

Currently the `pkg-config` package to use PSA crypto is `mbedcrypto` is that expected to change?
mpg (Migrated from github.com) reviewed 2025-09-25 02:47:48 -05:00
mpg (Migrated from github.com) left a comment

I completed my first pass. I only reviewed what changed - so far I didn't check if other things should be changed as well.

I completed my first pass. I only reviewed what changed - so far I didn't check if other things should be changed as well.
@ -4,9 +4,7 @@
mpg (Migrated from github.com) commented 2025-09-23 16:20:13 -05:00

Minor: "has replaced A to B" -> s/to/with/ I think?

Minor: "has replaced A to B" -> s/to/with/ I think?
@ -23,3 +21,3 @@
**Reference**: The [PSA Crypto API specification](https://arm-software.github.io/psa-api/crypto/) is available online. Mbed TLS implements a large subset of the specification which is documented in the [`psa/crypto*.h` headers](https://mbed-tls.readthedocs.io/projects/api/en/development/api/file/crypto_8h/).
**Reference**: The [PSA Crypto API specification](https://arm-software.github.io/psa-api/crypto/) is available online. TF-PSA-Crypto implements a large subset of the specification which is documented in the [`psa/crypto*.h` headers](https://mbed-tls.readthedocs.io/projects/api/en/development/api/file/crypto_8h/).
mpg (Migrated from github.com) commented 2025-09-23 16:22:00 -05:00

Wrong thing copy-pasted in [Mbed TLS issues](here).

Wrong thing copy-pasted in `[Mbed TLS issues](here)`.
@ -41,24 +39,35 @@ Then use the [summary of API modules](#summary-of-api-modules), the table of con
* Mbed TLS 2.15.0 (Nov 2018): first release with a draft implementation of the PSA API.
mpg (Migrated from github.com) commented 2025-09-23 16:22:43 -05:00

Minor: the release will happen in October.

Minor: the release will happen in October.
mpg (Migrated from github.com) commented 2025-09-23 16:31:56 -05:00

TODO

TODO
@ -204,7 +211,6 @@ For example, the following configuration enables hashing with SHA-256, AEAD with
#define PSA_WANT_ALG_GCM 1
mpg (Migrated from github.com) commented 2025-09-23 16:38:56 -05:00

Nice trick! A few commits ago I was starting to think we should provide some helper... well there it is :)

Nice trick! A few commits ago I was starting to think we should provide some helper... well there it is :)
mpg (Migrated from github.com) commented 2025-09-23 16:45:23 -05:00

Minor: s/transition/migration/?

Minor: s/transition/migration/?
mpg (Migrated from github.com) commented 2025-09-23 16:47:40 -05:00

I believe we now pass a mbedtls_pk_sigalg_type_t value.

I believe we now pass a `mbedtls_pk_sigalg_type_t` value.
@ -1292,3 +1300,3 @@
The PSA API does not provide direct access to the exponentiation primitive as with `mbedtls_rsa_public` and `mbedtls_rsa_private`. If you need an RSA-based mechanism that is not supported by the PSA API, please [submit an issue on GitHub](https://github.com/ARM-software/psa-api/issues) so that we can extend the API to support it.
The PSA API does not support constructing RSA keys progressively from numbers with `mbedtls_rsa_import` or `mbedtls_rsa_import_raw` followed by `mbedtls_rsa_complete`. See “[Importing a PK key by wrapping](#importing-a-pk-key-by-wrapping)”.
The PSA API does not support constructing RSA keys progressively from numbers, like the legacy functions `mbedtls_rsa_import`, `mbedtls_rsa_import_raw` and `mbedtls_rsa_complete`. You will need to construct the standard ASN.1 representation and call `psa_import_key()` (see “[Creating keys for asymmetric cryptography](#creating-keys-for-asymmetric-cryptography)”).
mpg (Migrated from github.com) commented 2025-09-23 16:33:25 -05:00

Minor: s/transition/migration/ for consistency?

Minor: s/transition/migration/ for consistency?
gilles-peskine-arm commented 2025-09-25 03:23:47 -05:00 (Migrated from github.com)

Currently the pkg-config package to use PSA crypto is mbedcrypto is that expected to change?

Sorry, I have no idea about that and this is not related to the document under review here. Please file a new issue, or maybe it's related to https://github.com/Mbed-TLS/mbedtls/issues/10395.

> Currently the pkg-config package to use PSA crypto is mbedcrypto is that expected to change? Sorry, I have no idea about that and this is not related to the document under review here. Please file a new issue, or maybe it's related to https://github.com/Mbed-TLS/mbedtls/issues/10395.
ronald-cron-arm (Migrated from github.com) requested changes 2025-09-26 02:31:20 -05:00
ronald-cron-arm (Migrated from github.com) left a comment

This looks essentially good to me. I have a couple of questions and have suggested some rewording where I felt it could improve comprehension.

This looks essentially good to me. I have a couple of questions and have suggested some rewording where I felt it could improve comprehension.
@ -23,3 +21,3 @@
**Reference**: The [PSA Crypto API specification](https://arm-software.github.io/psa-api/crypto/) is available online. Mbed TLS implements a large subset of the specification which is documented in the [`psa/crypto*.h` headers](https://mbed-tls.readthedocs.io/projects/api/en/development/api/file/crypto_8h/).
**Reference**: The [PSA Crypto API specification](https://arm-software.github.io/psa-api/crypto/) is available online. TF-PSA-Crypto implements a large subset of the specification which is documented in the [`psa/crypto*.h` headers](https://mbed-tls.readthedocs.io/projects/api/en/development/api/file/crypto_8h/).
ronald-cron-arm (Migrated from github.com) commented 2025-09-25 06:56:08 -05:00

Comment not about this line but about line 22: "Mbed TLS implements a large subset ..." -> "TF-PSA-Crypto implements ..." ?

Comment not about this line but about line 22: "Mbed TLS implements a large subset ..." -> "TF-PSA-Crypto implements ..." ?
@ -41,24 +39,35 @@ Then use the [summary of API modules](#summary-of-api-modules), the table of con
* Mbed TLS 2.15.0 (Nov 2018): first release with a draft implementation of the PSA API.
ronald-cron-arm (Migrated from github.com) commented 2025-09-25 07:51:17 -05:00

I don’t really understand the meaning of the sentence “As an exception, it's safe to use the same content in the TF-PSA-Crypto configuration and in the Mbed TLS configuration.” Could you clarify?

I don’t really understand the meaning of the sentence “As an exception, it's safe to use the same content in the TF-PSA-Crypto configuration and in the Mbed TLS configuration.” Could you clarify?
ronald-cron-arm (Migrated from github.com) commented 2025-09-25 08:28:45 -05:00
The Mbed TLS configuration file in 4.x should not try to modify any option consumed by TF-PSA-Crypto: this would make Mbed TLS's use of cryptography inconsistent with what the crypto library provides. As an exception, it's safe to use the same content in the TF-PSA-Crypto configuration and in the Mbed TLS configuration.
``` ?
```suggestion The Mbed TLS configuration file in 4.x should not try to modify any option consumed by TF-PSA-Crypto: this would make Mbed TLS's use of cryptography inconsistent with what the crypto library provides. As an exception, it's safe to use the same content in the TF-PSA-Crypto configuration and in the Mbed TLS configuration. ``` ?
ronald-cron-arm (Migrated from github.com) commented 2025-09-25 07:05:07 -05:00

I am not sure what you mean here.

I am not sure what you mean here.
@ -69,10 +78,14 @@ The PSA subsystem has an internal random generator. As a consequence, you do not
ronald-cron-arm (Migrated from github.com) commented 2025-09-25 07:14:22 -05:00

"Most of the new APIs suggested in this document", you mean suggested as replacements for the legacy APIs?

"Most of the new APIs suggested in this document", you mean suggested as replacements for the legacy APIs?
@ -136,44 +148,37 @@ Note that a key consumes a key store entry, which is distinct from heap memory,
| `md.h` | `mbedtls_md_` | [Hashes and MAC](#hashes-and-mac) |
ronald-cron-arm (Migrated from github.com) commented 2025-09-25 08:47:44 -05:00
3.x note: `TF_PSA_CRYPTO_CONFIG_FILE` and `TF_PSA_CRYPTO_USER_CONFIG_FILE` were called `MBEDTLS_PSA_CRYPTO_CONFIG_FILE` and `MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE` respectively in Mbed TLS 3.x.
``` ?
```suggestion 3.x note: `TF_PSA_CRYPTO_CONFIG_FILE` and `TF_PSA_CRYPTO_USER_CONFIG_FILE` were called `MBEDTLS_PSA_CRYPTO_CONFIG_FILE` and `MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE` respectively in Mbed TLS 3.x. ``` ?
@ -204,7 +211,6 @@ For example, the following configuration enables hashing with SHA-256, AEAD with
#define PSA_WANT_ALG_GCM 1
ronald-cron-arm (Migrated from github.com) commented 2025-09-25 08:50:07 -05:00

Limited to 3.6? Should work with 3.x I'd say.

Limited to 3.6? Should work with 3.x I'd say.
ronald-cron-arm (Migrated from github.com) commented 2025-09-25 08:53:47 -05:00

I think this is too much details for this document.

I think this is too much details for this document.
ronald-cron-arm (Migrated from github.com) commented 2025-09-25 07:38:15 -05:00
The PSA API does not currently provide a dedicated interface for pseudorandom generation. The [key derivation interface](https://mbed-tls.readthedocs.io/projects/api/en/development/api/group/group__key__derivation/) can serve a similar purpose in some applications, but it does not offer CTR\_DRBG or HMAC\_DRBG.
```suggestion The PSA API does not currently provide a dedicated interface for pseudorandom generation. The [key derivation interface](https://mbed-tls.readthedocs.io/projects/api/en/development/api/group/group__key__derivation/) can serve a similar purpose in some applications, but it does not offer CTR\_DRBG or HMAC\_DRBG. ```
ronald-cron-arm (Migrated from github.com) commented 2025-09-25 09:55:23 -05:00
You will need to remove the Mbed TLS RNG boilerplate, calls to `mbedtls_entropy_init`, `mbedtls_ctr_drbg_init`, `mbedtls_ctr_drbg_seed`, `mbedtls_ctr_drbg_random`, `mbedtls_ctr_drbg_free`, and `mbedtls_entropy_free`, or the `hmac_drbg` equivalents of the `ctr_drbg` functions.
``` ?
```suggestion You will need to remove the Mbed TLS RNG boilerplate, calls to `mbedtls_entropy_init`, `mbedtls_ctr_drbg_init`, `mbedtls_ctr_drbg_seed`, `mbedtls_ctr_drbg_random`, `mbedtls_ctr_drbg_free`, and `mbedtls_entropy_free`, or the `hmac_drbg` equivalents of the `ctr_drbg` functions. ``` ?
ronald-cron-arm (Migrated from github.com) commented 2025-09-25 10:00:51 -05:00
The PSA random generator always uses the entropy source(s) configured at compile time. The configuration differs between Mbed TLS 3.x and TF-PSA-Crypto 1.0 and later. In TF-PSA-Crypto 1.0, PSA uses exactly one of three possible entropy sources, depending on which compilation option is enabled:
``` ?
```suggestion The PSA random generator always uses the entropy source(s) configured at compile time. The configuration differs between Mbed TLS 3.x and TF-PSA-Crypto 1.0 and later. In TF-PSA-Crypto 1.0, PSA uses exactly one of three possible entropy sources, depending on which compilation option is enabled: ``` ?
ronald-cron-arm (Migrated from github.com) commented 2025-09-25 07:38:52 -05:00
We expect to add PSA APIs for DRBG mechanisms in a future version of TF-PSA-Crypto.
```suggestion We expect to add PSA APIs for DRBG mechanisms in a future version of TF-PSA-Crypto. ```
ronald-cron-arm (Migrated from github.com) commented 2025-09-25 10:39:40 -05:00
The PSA API does not support constructing RSA keys progressively from numbers like the legacy API with `mbedtls_rsa_import` or `mbedtls_rsa_import_raw` followed by `mbedtls_rsa_complete`. You will need to construct the standard ASN.1 representation and call `psa_import_key()` (see “[Creating keys for asymmetric cryptography](#creating-keys-for-asymmetric-cryptography)”).
``` ?
```suggestion The PSA API does not support constructing RSA keys progressively from numbers like the legacy API with `mbedtls_rsa_import` or `mbedtls_rsa_import_raw` followed by `mbedtls_rsa_complete`. You will need to construct the standard ASN.1 representation and call `psa_import_key()` (see “[Creating keys for asymmetric cryptography](#creating-keys-for-asymmetric-cryptography)”). ``` ?
ronald-cron-arm (Migrated from github.com) commented 2025-09-26 02:11:21 -05:00

Why do we have less here? Because it is about the new legacy API?

Why do we have less here? Because it is about the new legacy API?
mpg (Migrated from github.com) reviewed 2025-09-26 03:54:12 -05:00
mpg (Migrated from github.com) left a comment
No description provided.
Thanks for addressing my comments.
gilles-peskine-arm (Migrated from github.com) reviewed 2025-09-26 05:15:18 -05:00
@ -69,10 +78,14 @@ The PSA subsystem has an internal random generator. As a consequence, you do not
gilles-peskine-arm (Migrated from github.com) commented 2025-09-26 05:15:18 -05:00

I mean APIs that this document suggests that the reader uses, which indeed are replacements for legacy APIs since that's the purpose of the document. I'm not sure how else to formulate that.

I mean APIs that this document suggests that the reader uses, which indeed are replacements for legacy APIs since that's the purpose of the document. I'm not sure how else to formulate that.
gilles-peskine-arm (Migrated from github.com) reviewed 2025-09-26 05:17:14 -05:00
gilles-peskine-arm (Migrated from github.com) commented 2025-09-26 05:17:14 -05:00

Sorry, I don't understand why “for” would be better than “to” here.

Sorry, I don't understand why “for” would be better than “to” here.
gilles-peskine-arm (Migrated from github.com) reviewed 2025-09-26 05:21:52 -05:00
@ -204,7 +211,6 @@ For example, the following configuration enables hashing with SHA-256, AEAD with
#define PSA_WANT_ALG_GCM 1
gilles-peskine-arm (Migrated from github.com) commented 2025-09-26 05:21:52 -05:00

I would recommend 3.6 because we fixed some bugs over the course of 3.x. We can't prevent people from trying it with older 3.x, but I'd rather not recommend it.

I would recommend 3.6 because we fixed some bugs over the course of 3.x. We can't prevent people from trying it with older 3.x, but I'd rather not recommend it.
gilles-peskine-arm (Migrated from github.com) reviewed 2025-09-26 05:22:22 -05:00
gilles-peskine-arm (Migrated from github.com) commented 2025-09-26 05:22:22 -05:00

Where else would you put it?

Where else would you put it?
gilles-peskine-arm (Migrated from github.com) reviewed 2025-09-26 05:28:26 -05:00
gilles-peskine-arm (Migrated from github.com) commented 2025-09-26 05:28:26 -05:00

Yes. mbedtls_pk_check_pair still exists, but the RSA/ECP functions no longer do.

Yes. `mbedtls_pk_check_pair` still exists, but the RSA/ECP functions no longer do.
ronald-cron-arm (Migrated from github.com) reviewed 2025-09-26 05:29:16 -05:00
ronald-cron-arm (Migrated from github.com) commented 2025-09-26 05:29:16 -05:00

I understand that we expect to add new PSA APIs to support DRBG mechanisms and in that context I would use "for" but I am not an English native speaker thus if you think they are equivalent here, that's fine by me.

I understand that we expect to add new PSA APIs to support DRBG mechanisms and in that context I would use "for" but I am not an English native speaker thus if you think they are equivalent here, that's fine by me.
mpg (Migrated from github.com) reviewed 2025-09-26 05:47:38 -05:00
mpg (Migrated from github.com) left a comment
No description provided.
LGTM, thanks!
ronald-cron-arm (Migrated from github.com) reviewed 2025-09-26 05:51:33 -05:00
ronald-cron-arm (Migrated from github.com) commented 2025-09-26 05:51:33 -05:00

It feels odd to provide users with a way to deal with the output of query_compile_time_config, so I would just remove it. But if you prefer to keep that's fine by me.

It feels odd to provide users with a way to deal with the output of `query_compile_time_config`, so I would just remove it. But if you prefer to keep that's fine by me.
mpg (Migrated from github.com) reviewed 2025-09-26 06:06:04 -05:00
mpg (Migrated from github.com) commented 2025-09-26 06:06:04 -05:00

Perhaps keep the sed invocation (as a user, I think I'd appreciate being able to just copy-paste it), but also provide a description of what it does in plain English for the benefit of user of platforms without sed?

Perhaps keep the sed invocation (as a user, I think I'd appreciate being able to just copy-paste it), but also provide a description of what it does in plain English for the benefit of user of platforms without sed?
ronald-cron-arm (Migrated from github.com) reviewed 2025-09-26 07:35:08 -05:00
ronald-cron-arm (Migrated from github.com) commented 2025-09-26 07:35:07 -05:00

Good compromise, thanks.

Good compromise, thanks.
ronald-cron-arm (Migrated from github.com) approved these changes 2025-09-26 07:45:46 -05:00
ronald-cron-arm (Migrated from github.com) left a comment

LGTM, thanks.

LGTM, thanks.
mpg (Migrated from github.com) approved these changes 2025-09-26 09:28:36 -05:00
mpg (Migrated from github.com) left a comment

LGTM!

LGTM!
gilles-peskine-arm commented 2025-09-26 12:46:25 -05:00 (Migrated from github.com)

Rebased again to try and pass the CI. No content change.

Rebased again to try and pass the CI. No content change.
gilles-peskine-arm commented 2025-09-26 12:47:37 -05:00 (Migrated from github.com)

The rebase preserved GitHub approvals, so I'll go ahead and queue this for merging. There's a 3.6 backport, but it isn't release-critical, unlike this 1.0 PR.

The rebase preserved GitHub approvals, so I'll go ahead and queue this for merging. There's a 3.6 backport, but it isn't release-critical, unlike this 1.0 PR.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-Mbed-TLS/TF-PSA-Crypto!472
No description provided.