{"data":{"slug":"discovered-ef8132c93740210afa87d93c99cd1ce46675a4809f910639","title":"MbedTLS v4.1.0 \/ TF-PSA-Crypto Integration and Test Porting","summary":"Port RA4C1 PSA Crypto tests from mbedTLS v3.6.6 to mbedTLS 4.1.0 + TF-PSA-Crypto 1.1.x. Includes API migration, test porting, and environment setup for Linux (zsh) with Python 3.","url":"https:\/\/skillshunter.net\/skills\/discovered-ef8132c93740210afa87d93c99cd1ce46675a4809f910639","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-ef8132c93740210afa87d93c99cd1ce46675a4809f910639","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-ef8132c93740210afa87d93c99cd1ce46675a4809f910639.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-ef8132c93740210afa87d93c99cd1ce46675a4809f910639\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Ensure the Linux shell is zsh and use `bash -c` for multi-flag commands. Verify the RA4C1 board's data flash and memory limits in `bsp_cfg_ra4c1.h` before running tests.","instructions":"---\nname: mbedtlsv4-tf-psa-crypto-integrated\ndescription: Quick start for the FSPRA-5629 mbedTLS v4.1.0 \/ TF-PSA-Crypto integration and PSA crypto test porting. Read first when working on rm_tf_psa_crypto tests or the v3 to v4 port.\nmetadata:\n  type: reference\n  branch: FSPRA-5629_MbedTLS_v4.1.0_TRNG_Sync\n  compacted: 2026-11-01\n---\n\n# FSPRA-5629 quick start\n\nStatus: compacted 2026-11-01. Session logs and completed-work lists were removed. Detail is in the companion skills below.\n\n## Scope\n- Branch: `FSPRA-5629_MbedTLS_v4.1.0_TRNG_Sync`.\n- Goal: port RA4C1 PSA Crypto tests from mbedTLS v3.6.6 (`rm_psa_crypto`) to mbedTLS 4.1.0 + TF-PSA-Crypto 1.1.x (`rm_tf_psa_crypto`).\n- Done: API migration for TG1 to TG4 (TG5 in progress). Test porting for TG1 (SHA) and TG2 (GCM).\n- Resolved: ECC persistent-key bus fault (`TC_API_ECCGenerateKeyPairSignVerify256R1Persistent`) is handled by ignoring the test on E31A boards. Root cause still open (see the littlefs notes).\n\n## Environment\n- Shell is Linux (zsh). Use `python3`.\n- Under zsh, `$VAR` does not word-split. Run multi-flag commands through `bash -c`.\n\n## Companion skills (invoke by name or read the file)\n1. `mbedtls-v4-migration-notes\/SKILL.md`: API diffs, config changes, debugging recipes.\n2. `mbedtls-v4-migration-notes\/psa-storage-littlefs-stack.md`: persistent key storage and littlefs.\n3. `mbedtls-v4-migration-notes\/ecc-busfault-littlefs-investigation.md`: ECC bus fault.\n4. `mbedtls-v4-migration-notes\/changelog-3.6.6-to-4.1.0.md`: v3 to v4 changelog digest.\n5. `test-case-porting-guide\/SKILL.md`: porting checklist and common mistakes.\n6. `cch-psa-driver-scaffold\/SKILL.md`: PSA driver architecture.\n\n## Test porting checklist\n- Copy the whole test, not just the `TEST()` macro. Copy its helper functions (for example `cipher_example_*`).\n- Update `psa_crypto_tests_runner.c` (`RUN_TEST_CASE`).\n- Migrate API types (`psa_key_handle_t` to `psa_key_id_t`).\n- Find helpers and tests: `grep -n \"^psa_status_t\" file.c` and `grep -n \"^TEST(\" file.c`.\n\n## Migration rules\n- `PSA_KEY_LIFETIME_IS_PERSISTENT(l)` becomes `!PSA_KEY_LIFETIME_IS_VOLATILE(l)`. About 26 occurrences were converted.\n- `psa_key_handle_t` becomes `psa_key_id_t`.\n- `mbedtls_pk_parse_key` drops the RNG args (7 args become 5).\n- `psa_open_key` and `psa_close_key` are removed. Use the key ID directly.\n\n## Key files\n- Tests: `ra\/fsp\/src\/rm_tf_psa_crypto\/!test\/` (`psa_crypto_tests_tg1.c` to `tg11.c`, `psa_crypto_tests_runner.c`, `psa_crypto_tests_setup.c`).\n- Config: `projects\/rm_tf_psa_crypto.xml` (macros and include dirs), `test_files\/ra_cfg\/fsp_cfg\/rm_tf_psa_crypto_cfg.h`, `test_files\/ra_cfg\/fsp_cfg\/bsp\/bsp_cfg_ra4c1.h`.\n- v3 reference: `ra\/fsp\/src\/rm_psa_crypto\/!test\/` (v3 has more GCM multipart coverage).\n\n## Facts\n- Dynamic key storage (`MBEDTLS_PSA_KEY_STORE_DYNAMIC`) allocates a 108-byte persistent-key cache and a 640-byte volatile slice. Both are freed only by `mbedtls_psa_crypto_free()`. The leak check matches by size (`calloc_size_array`).\n- RA4C1 limits: data flash 8 KB (tight). The test config uses main stack and heap of 32 KB each. Verify these values against `bsp_cfg_ra4c1.h`.\n- littlefs `inline_max` decides when storage first allocates a block. A larger key blob crosses it.\n","use_cases":["Porting PSA Crypto tests from mbedTLS v3.6.6 to mbedTLS v4.1.0","Setting up a Linux (zsh) environment for TF-PSA-Crypto test porting","Migrating API types such as `psa_key_handle_t` to `psa_key_id_t`","Updating test runners and helper functions for PSA Crypto tests"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/minhnguyenyf\/skills\/blob\/7213d81500a27f3a96028144f5342ccfe4efbe4a\/psa\/mbedtlsv4-tf-psa-crypto-integrated\/SKILL.md","source_commit":"7213d81500a27f3a96028144f5342ccfe4efbe4a","license":null,"version":null,"listing_approved_at":"2026-11-30","created_at":"2026-11-29T11:12:21.000000Z","updated_at":"2026-11-30T06:52:26.000000Z","seo_title":"MbedTLS v4.1.0 \/ TF-PSA-Crypto Integration and Test Porting Guide","seo_description":"A guide for porting PSA Crypto tests from mbedTLS v3.6.6 to mbedTLS 4.1.0 with TF-PSA-Crypto 1.1.x, including API migration and test setup for Linux (zsh) environments.","seo_keywords":["mbedTLS v4.1.0","TF-PSA-Crypto","PSA Crypto test porting","mbedTLS migration","Linux zsh setup","RA4C1 board testing"]}}