Keystoreless mode prototype #872

Open
gilles-peskine-arm wants to merge 1 commit from gilles-peskine-arm/keystoreless-prototype-1 into development
gilles-peskine-arm commented 2026-08-20 10:22:59 -05:00 (Migrated from github.com)

New compile-time MBEDTLS_PSA_CRYPTO_NO_KEY_STORE, to build PSA crypto without a key store. Key IDs (psa_key_id_t) are direct pointers to a heap-allocated key slot.

The library and the unit tests compile.

test_suite_psa_crypto_slot_management and test_suite_psa_crypto_init pass.

test_suite_psa_crypto and others crash under ASan, because (perhaps among other reasons) they routinely call psa_destroy_key() on their cleanup path, on a key that is already destroyed when the test passes.

Status

This is an unfinished prototype, shared to facilitate discussion.

Code size benefit

mbedtls-prepare-build -d build-nopersistent-m0plus -p m0plus --config-unset=MBEDTLS_PSA_CRYPTO_STORAGE_C,MBEDTLS_PSA_ITS_FILE_C,MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS,MBEDTLS_PSA_KEY_STORE_DYNAMIC` vs
mbedtls-prepare-build -d build-nokeystore-m0plus -p m0plus --config-set=MBEDTLS_PSA_CRYPTO_NO_KEY_STORE --config-unset=MBEDTLS_PSA_CRYPTO_STORAGE_C,MBEDTLS_PSA_ITS_FILE_C,MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS,MBEDTLS_PSA_KEY_STORE_DYNAMIC
make -C build-nopersistent-m0plus lib
make -C build-nokeystore-m0plus lib
size-diff  <(size -t build-nopersistent-m0plus/library/libmbedcrypto.a) <(size -t build-nokeystore-m0plus/library/libmbedcrypto.a)

→

  184719  183629 (TOTALS)
   23269   22733 psa_crypto.o
     620      66 psa_crypto_slot_management.o

PR checklist

Please remove the segment/s on either side of the | symbol as appropriate, and add any relevant link/s to the end of the line.
If the provided content is part of the present PR remove the # symbol.

  • changelog provided | not required because:
  • framework PR provided Mbed-TLS/mbedtls-framework# | not required
  • TF-PSA-Crypto development PR provided # | not required because:
  • TF-PSA-Crypto 1.1 PR provided # | not required because:
  • mbedtls development PR provided Mbed-TLS/mbedtls# | not required because:
  • mbedtls 4.1 PR provided Mbed-TLS/mbedtls# | not required because:
  • mbedtls 3.6 PR provided Mbed-TLS/mbedtls# | not required because:
  • tests provided | not required because:

Notes for the submitter

Please refer to the contributing guidelines, especially the
checklist for PR contributors.

Help make review efficient:

  • Multiple simple commits
    • please structure your PR into a series of small commits, each of which does one thing
  • Avoid force-push
    • please do not force-push to update your PR - just add new commit(s)
  • See our Guidelines for Contributors for more details about the review process.
New compile-time `MBEDTLS_PSA_CRYPTO_NO_KEY_STORE`, to build PSA crypto without a key store. Key IDs (`psa_key_id_t`) are direct pointers to a heap-allocated key slot. The library and the unit tests compile. `test_suite_psa_crypto_slot_management` and `test_suite_psa_crypto_init` pass. `test_suite_psa_crypto` and others crash under ASan, because (perhaps among other reasons) they routinely call `psa_destroy_key()` on their cleanup path, on a key that is already destroyed when the test passes. ## Status This is an unfinished prototype, shared to facilitate discussion. ## Code size benefit ``` mbedtls-prepare-build -d build-nopersistent-m0plus -p m0plus --config-unset=MBEDTLS_PSA_CRYPTO_STORAGE_C,MBEDTLS_PSA_ITS_FILE_C,MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS,MBEDTLS_PSA_KEY_STORE_DYNAMIC` vs mbedtls-prepare-build -d build-nokeystore-m0plus -p m0plus --config-set=MBEDTLS_PSA_CRYPTO_NO_KEY_STORE --config-unset=MBEDTLS_PSA_CRYPTO_STORAGE_C,MBEDTLS_PSA_ITS_FILE_C,MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS,MBEDTLS_PSA_KEY_STORE_DYNAMIC make -C build-nopersistent-m0plus lib make -C build-nokeystore-m0plus lib size-diff <(size -t build-nopersistent-m0plus/library/libmbedcrypto.a) <(size -t build-nokeystore-m0plus/library/libmbedcrypto.a) ``` → ``` 184719 183629 (TOTALS) 23269 22733 psa_crypto.o 620 66 psa_crypto_slot_management.o ``` ## PR checklist Please remove the segment/s on either side of the | symbol as appropriate, and add any relevant link/s to the end of the line. If the provided content is part of the present PR remove the # symbol. - [ ] **changelog** provided | not required because: - [ ] **framework PR** provided Mbed-TLS/mbedtls-framework# | not required - [ ] **TF-PSA-Crypto development PR** provided # | not required because: - [ ] **TF-PSA-Crypto 1.1 PR** provided # | not required because: - [ ] **mbedtls development PR** provided Mbed-TLS/mbedtls# | not required because: - [ ] **mbedtls 4.1 PR** provided Mbed-TLS/mbedtls# | not required because: - [ ] **mbedtls 3.6 PR** provided Mbed-TLS/mbedtls# | not required because: - **tests** provided | not required because: ## Notes for the submitter Please refer to the [contributing guidelines](https://github.com/Mbed-TLS/TF-PSA-Crypto/blob/development/CONTRIBUTING.md), especially the checklist for PR contributors. Help make review efficient: * Multiple simple commits - please structure your PR into a series of small commits, each of which does one thing * Avoid force-push - please do not force-push to update your PR - just add new commit(s) * See our [Guidelines for Contributors](https://mbed-tls.readthedocs.io/en/latest/reviews/review-for-contributors/) for more details about the review process.
This pull request has changes conflicting with the target branch.
  • framework
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'gilles-peskine-arm/keystoreless-prototype-1:gilles-peskine-arm/keystoreless-prototype-1'
git switch 'gilles-peskine-arm/keystoreless-prototype-1'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'development'
git merge --no-ff 'gilles-peskine-arm/keystoreless-prototype-1'
git switch 'gilles-peskine-arm/keystoreless-prototype-1'
git rebase 'development'
git switch 'development'
git merge --ff-only 'gilles-peskine-arm/keystoreless-prototype-1'
git switch 'gilles-peskine-arm/keystoreless-prototype-1'
git rebase 'development'
git switch 'development'
git merge --no-ff 'gilles-peskine-arm/keystoreless-prototype-1'
git switch 'development'
git merge --squash 'gilles-peskine-arm/keystoreless-prototype-1'
git switch 'development'
git merge --ff-only 'gilles-peskine-arm/keystoreless-prototype-1'
git switch 'development'
git merge 'gilles-peskine-arm/keystoreless-prototype-1'
git push origin 'development'
Sign in to join this conversation.
No reviewers
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!872
No description provided.