{"data":{"slug":"discovered-a09ed59d41f174e82de58db9235f4a1f26756dd520dc67cd","title":"Cch Psa Driver Scaffold","summary":"Add a new PSA transparent driver algorithm or category (cipher, AEAD, MAC, sign\/verify, key agreement, entropy, key management) to ra\/fsp\/src\/rm_tf_psa_crypto using the 4-layer CCH pattern. Deliverable includes algorithm-specific files, dispatchers, and wrapper functions.","url":"https:\/\/skillshunter.net\/skills\/discovered-a09ed59d41f174e82de58db9235f4a1f26756dd520dc67cd","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-a09ed59d41f174e82de58db9235f4a1f26756dd520dc67cd","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-a09ed59d41f174e82de58db9235f4a1f26756dd520dc67cd.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-a09ed59d41f174e82de58db9235f4a1f26756dd520dc67cd\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before coding, check the required and optional entry points against the PRD. Do not implement out-of-scope functions. Add a unit test suite in `!test\/` and register it in `psa_crypto_tests_setup.c` if needed. Confirm file names with `git ls-files` before copying them.","instructions":"---\nname: cch-psa-driver-scaffold\ndescription: Use when adding a PSA transparent driver algorithm or category (cipher, AEAD, MAC, sign\/verify, key agreement, entropy, key management) to ra\/fsp\/src\/rm_tf_psa_crypto through the 4-layer CCH pattern. Triggers on \"add a new PSA driver\", \"wire up CCH for <algorithm>\", or \"follow the SHA pattern\".\n---\n\n# CCH \/ PSA driver scaffold (rm_tf_psa_crypto)\n\nStatus: compacted 2026-11-01. Checked: `cch_crypto.h` and `tf_psa_crypto_driver_wrappers.h` exist in `ra\/fsp\/src\/rm_tf_psa_crypto\/`. The `rsip_cm_*` reference files named in the older version of this note are NOT in the repo. The pattern below is a design template, not existing code. Confirm the file names with `git ls-files` before you copy them.\n\nDiagrams: `cch_layer_model.svg` (4-layer stack) and `cch_call_flow.svg` (`psa_sign_hash` branching) in this folder.\n\n## Layers\n- **L1a algorithm driver** (`inc\/rsip_cm_<algo>.h\/.c`): `_context`, `_init`, `_free`, `_clone`, `_starts`, `_update`, `_finish`. Returns `fsp_err_t`, never `psa_status_t`. Guard the file with `#if defined(PSA_WANT_ALG_<ALGO>)`. Branch on RSIP capability (`BSP_FEATURE_RSIP_RSIP_E51A\/E50D\/E31A_SUPPORTED`) only when the engine needs extra state. Call only `HW_SCE_*` primitives, never `mbedtls_internal_*`.\n- **L1b category dispatcher** (`inc\/rsip_cm_<category>.h\/.c`): an operation struct holding `psa_algorithm_t alg` and a union of per-algorithm contexts. `switch (alg)` in `_setup`, `_update`, `_finish`, `_abort`, `_clone`, and optionally `_compute`. `default:` returns `FSP_ERR_CRYPTO_INVALID_SIZE`. Create only for new categories. Hash is the existing one, and the others are not yet written.\n- **L2 CCH** (`cch_crypto.h`): `static inline cch_<category>_<op>()`. `_setup` rejects re-setup (`alg != 0`). `_finish` checks output size with the PSA size macro (`PSA_HASH_LENGTH`, `PSA_MAC_LENGTH`, `PSA_AEAD_TAG_LENGTH`, `PSA_CIPHER_IV_LENGTH`).\n- **L3 PSA wrapper** (`tf_psa_crypto_driver_wrappers.h`): `psa_driver_wrapper_<category>_<op>()`.\n  1. Under `PSA_CRYPTO_TRANSPARENT_DRIVER`: call the CCH function. On `FSP_SUCCESS`, set the driver ID and return `PSA_SUCCESS`. Any error other than `FSP_ERR_UNSUPPORTED` returns `PSA_ERROR_HARDWARE_FAILURE`. Hardware-required ops must not fall back silently.\n  2. Otherwise fall through to the `mbedtls_psa_<category>_<op>` software path.\n\n## Adding an algorithm to an existing category\n1. Layer 1a file for the algorithm.\n2. Add the union member and `case PSA_ALG_<ALGO>:` to the category dispatcher. No L2 or L3 change if dispatch is by `alg`.\n\n## Adding a new category\n1. Layer 1a files for each algorithm.\n2. Layer 1b dispatcher.\n3. Layer 2 `cch_<category>_*` in `cch_crypto.h`.\n4. Layer 3 `psa_driver_wrapper_<category>_*` in `tf_psa_crypto_driver_wrappers.h`.\n5. Check the required and optional entry points against the PRD before coding. Do not implement out-of-scope ones.\n6. Add a unit test suite in `!test\/` and register it in `psa_crypto_tests_setup.c` if needed.\n\n## Conventions\n- File header: `\/* ${REA_DISCLAIMER_PLACEHOLDER} *\/`.\n- `fsp_err_t` below the CCH boundary, `psa_status_t` at and above the PSA wrapper. Never mix.\n- No `mbedtls_internal_*` in layers 1, 1b or 2.\n- Guard each algorithm with `PSA_WANT_ALG_*` (or `MBEDTLS_PSA_ACCEL_ALG_*`).\n- Engine adapters are selected at build time. No function-pointer dispatch tables.\n","use_cases":["Adding a new PSA driver algorithm (e.g., cipher, AEAD, MAC)","Implementing a new category for PSA drivers (e.g., sign\/verify, key agreement)","Following the SHA pattern for driver implementation","Wire up CCH for a specific algorithm"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/minhnguyenyf\/skills\/blob\/7213d81500a27f3a96028144f5342ccfe4efbe4a\/psa\/cch-psa-driver-scaffold\/SKILL.md","source_commit":"7213d81500a27f3a96028144f5342ccfe4efbe4a","license":null,"version":null,"listing_approved_at":"2026-11-30","created_at":"2026-11-29T11:12:16.000000Z","updated_at":"2026-11-30T06:52:26.000000Z","seo_title":"CCH\/PSA Driver Scaffold for Adding New Algorithms or Categories","seo_description":"Use this scaffold to implement new PSA transparent driver algorithms or categories using the 4-layer CCH pattern in the rm_tf_psa_crypto module. Includes layer-specific\u6587\u4ef6","seo_keywords":["CCH driver scaffold","PSA driver implementation","rm_tf_psa_crypto","4-layer CCH pattern","PSA transparent driver","algorithm category addition","PSA wrapper function","CCH layer model"]}}