SM4 support through the PSA API II #909

Open
opened 2026-09-15 03:15:47 -05:00 by ronald-cron-arm · 0 comments
ronald-cron-arm commented 2026-09-15 03:15:47 -05:00 (Migrated from github.com)

Freely available English translation of the Chinese SM4 block cipher and its mode of operations: https://datatracker.ietf.org/doc/html/draft-ribose-cfrg-sm4-10 (HTML) or https://www.ietf.org/archive/id/draft-ribose-cfrg-sm4-10.txt (txt).

An implementation has been proposed for SM4 in Mbed TLS: https://github.com/Mbed-TLS/mbedtls/pull/1165. No CLA valid label or DCO thus we cannot use it for the time being.

PSA cryptography API specification:

  • The PSA identifier for the key type is standardized: PSA_KEY_TYPE_SM4 == 0x2405, with a 128-bit key and 16-byte block, introduced in 1.0.1. Support for SM4 key derivation through psa_key_derivation_output_key().
  • 1.1.1: Explicit list of compatible algorithms: PSA_ALG_CBC_MAC, PSA_ALG_CMAC, PSA_ALG_CTR, PSA_ALG_CFB, PSA_ALG_OFB, PSA_ALG_XTS, PSA_ALG_CBC_NO_PADDING, PSA_ALG_CBC_PKCS7, PSA_ALG_ECB_NO_PADDING, PSA_ALG_CCM and PSA_ALG_GCM.

SM4 can reuse the existing mode machinery. The main work is adding SM4 as a
128-bit block primitive, registering ECB/CBC/CTR with the generic cipher layer,
and exposing GCM/CCM only through PSA's lightweight block-cipher path.

The PSA identifier is already standardized: PSA_KEY_TYPE_SM4 == 0x2405, with
a 128-bit key and 16-byte block. PSA explicitly permits ECB, CBC, CTR, GCM, and
CCM for it. PSA key-type specification

The following sequence adds the SM4-based algorithms with their initial positive
test coverage. Each step should remain buildable and testable on its own.

SM4 implementation

The following sequence form a dependency-ordered implementation stack. At each
step, the library should build and pass its test suites. For the pre-PSA commits, test
with the default configuration plus a temporary definition of
MBEDTLS_PSA_BUILTIN_KEY_TYPE_SM4. From the PSA commit onward,
PSA_WANT_KEY_TYPE_SM4 is enabled by the default PSA configuration and the
configuration adjustment code derives MBEDTLS_PSA_BUILTIN_KEY_TYPE_SM4.

1. Add the SM4 ECB primitive

Add:

  • drivers/builtin/src/sm4.c
  • drivers/builtin/include/tf-psa-crypto/private/sm4.h

The private API should follow Camellia/ARIA with tf_psa_crypto_ prefix:

  • tf_psa_crypto_sm4_init() / free()
  • tf_psa_crypto_sm4_setkey_enc() / setkey_dec()
  • tf_psa_crypto_sm4_crypt_ecb()

Ordinary sbox-table-based implementation.

Open question: Add a constant-time implementation without and with neon-based
acceleration.

Testing: add an SM4 self-test suite. Run the published single-block encryption
and decryption examples and the one-million-encryption vector from the SM4
specification/draft. The test suite itself only needs to invoke the self-test.

2. Register SM4-ECB in the cipher abstraction

Add the SM4 cipher identifier MBEDTLS_CIPHER_ID_SM4 and the identifier for the
SM4 cipher with 128-bit key and ECB mode MBEDTLS_CIPHER_SM4_128_ECB in cipher.h.

Follow the CAMELLIA registration in cipher_wrap.c: provide sm4_info
(no specific mode CBC, CFB ... for the time being) and sm4_128_ecb_info.
Reference them in the relevant tables.

Testing (test_suite_cipher.sm4.data): add cipher-abstraction known-answer tests
for ECB encryption and decryption using SM4 Example 1 from the specification.
The test function in test_vec_ecb.

3. Add the low-level SM4 cipher modes

In sm4.h and sm4.c, add:

  • tf_psa_crypto_sm4_crypt_cbc()
  • tf_psa_crypto_sm4_crypt_cfb128()
  • tf_psa_crypto_sm4_crypt_ofb()
  • tf_psa_crypto_sm4_crypt_ctr()

The SM4 draft
defines CBC, CFB, OFB and CTR in Sections 8.4 through 8.7, based on the modes in
NIST SP 800-38A. Use those definitions as the algorithmic reference and the
existing Camellia/AES code as the Mbed TLS implementation and API reference.

The differences to account for are that the draft also defines CFB-1, CFB-8
and CFB-64, whereas only CFB-128 needs to be implemented, and that the draft
permits any non-repeating CTR sequence, while the Mbed TLS convention increments
the complete 128-bit counter as a big-endian integer.

Follow the Camellia implementations for CBC, CFB128 and CTR, and the AES
implementation for OFB, while checking each operation against the SM4 draft.
Use the common counter increment helper for CTR and the existing
MBEDTLS_CIPHER_MODE_* guards.

Testing: extend the self-test in sm4.c; test_suite_sm4 remains unchanged and
continues to invoke it. Test CBC, CFB128, OFB and CTR encryption and decryption
with both vector sets from Appendix A of the SM4 draft, including the complete
64-byte CTR vectors. These known-answer tests confirm that the selected Mbed TLS
profiles agree with the SM4 mode definitions.

4. Register the SM4 cipher modes in the cipher abstraction

In cipher.h, add MBEDTLS_CIPHER_SM4_128_CBC,
MBEDTLS_CIPHER_SM4_128_CFB128, MBEDTLS_CIPHER_SM4_128_OFB and
MBEDTLS_CIPHER_SM4_128_CTR.

In cipher_wrap.c, add the corresponding callbacks to sm4_info, provide
sm4_128_cbc_info, sm4_128_cfb128_info, sm4_128_ofb_info and
sm4_128_ctr_info, and reference them in the cipher tables. Follow the
CAMELLIA registrations for CBC, CFB and CTR and the AES registration for OFB.
Do not add XTS, GCM or CCM here.

Testing (test_suite_cipher.sm4.data): add encryption and decryption
test_vec_crypt cases for CBC, CFB128, OFB and CTR using Appendix A vectors.
Increase the test_vec_crypt output buffer to 64 bytes and use the complete
published CTR vector.

5. Add SM4 to the block-cipher abstraction

In block_cipher.h, add MBEDTLS_BLOCK_CIPHER_ID_SM4 and the SM4 context to
the context union. In block_cipher.c, add the direct-software cases for
context initialization/free, encryption-key setup and block encryption. Follow
the CAMELLIA MBEDTLS_BLOCK_CIPHER_ENGINE_LEGACY implementation and use
MBEDTLS_PSA_BUILTIN_KEY_TYPE_SM4 as the SM4 implementation guard.

Update block_cipher_internal.h,
crypto_adjust_config_tweak_builtins.h and
tf_psa_crypto_check_config.h so CCM/GCM can select SM4 through
block_cipher.c. Add the MBEDTLS_BLOCK_CIPHER_SM4_VIA_LEGACY,
MBEDTLS_BLOCK_CIPHER_CAN_SM4 and MBEDTLS_CCM_GCM_CAN_SM4 capability
macros. “Legacy” here only identifies the direct-software block-cipher engine.
There is no public legacy SM4 API.

Testing (test_suite_block_cipher.data): add a test_vec case that performs
SM4 block encryption with specification Example 1.

6. Add SM4 CCM-star-no-tag to the cipher abstraction

In cipher.h, add MBEDTLS_CIPHER_SM4_128_CCM_STAR_NO_TAG. In
cipher_wrap.h, add
MBEDTLS_CIPHER_HAVE_CCM_STAR_NO_TAG_SM4_VIA_LEGACY_OR_USE_PSA.

In cipher_wrap.c, provide the CCM-backed ccm_sm4_info base and
sm4_128_ccm_star_no_tag_info. The set-key wrapper calls
mbedtls_ccm_setkey() with MBEDTLS_CIPHER_ID_SM4. Follow the existing
AES/ARIA/CAMELLIA CCM-star-no-tag registrations and shared CCM context handling.
This does not add tagged CCM or GCM to cipher.c.

Testing (test_suite_cipher.sm4.data): add encryption and decryption
test_vec_crypt known-answer cases for
MBEDTLS_CIPHER_SM4_128_CCM_STAR_NO_TAG, using the RFC 8998 Appendix A.2 key
and plaintext with independently derived ciphertext for a 13-byte nonce.

7. Add built-in PSA SM4 support

In crypto_values.h, define PSA_KEY_TYPE_SM4 as a fixed 128-bit block-cipher
key type. Update its documentation in crypto.h, enable
PSA_WANT_KEY_TYPE_SM4 in crypto_config.h, update crypto_sizes.h (definition
of PSA_CIPHER_MAX_KEY_LENGTH), and add the option to
scripts/data_files/config-options-current.txt.

Follow PSA_KEY_TYPE_CAMELLIA in psa_crypto.c for key-size validation and in
crypto_adjust_config_enable_builtins.h for configuration derivation. The
latter should derive MBEDTLS_PSA_BUILTIN_KEY_TYPE_SM4. Update
check_crypto_config.h for CCM/GCM prerequisites.

In psa_crypto_cipher.c, update mbedtls_cipher_validate_values() and
mbedtls_cipher_values_from_psa() to map SM4 and permit ECB, CBC without
padding, CBC-PKCS7, CFB, OFB, CTR, CMAC, CCM-star-no-tag, CCM and GCM. Follow
the mapping for CAMELLIA and the implementation of the relevant mode. In
cmac.c, accept MBEDTLS_CIPHER_SM4_128_ECB as a CMAC block cipher.

Once all SM4-based algorithms are available, update
framework/tests/include/test/psa_exercise_key.h and
framework/scripts/mbedtls_framework/crypto_knowledge.py so the framework
recognizes SM4 as a 128-bit block cipher. Do not advance the framework pointer
in the earlier commits.

Testing (test_suite_psa_crypto.sm4.data): cover valid and invalid key imports;
one-shot and multipart ECB/CBC/CFB/OFB/CTR operations, partial final blocks,
generated IVs, CBC-PKCS7 and invalid padding, CCM-star-no-tag, and CMAC. For
CCM/GCM, use the RFC 8998 known-answer vectors and cover one-shot and multipart
encryption/decryption, shortened tags, nonce limits, generated nonces and
authentication failures. Use:
. import_with_data for key import tests.
. cipher_alg_without_iv, cipher_encrypt_multipart, cipher_decrypt,
cipher_decrypt_multipart, cipher_verify_output_multipart,
cipher_encrypt_validation and cipher_decrypt_fail for cipher coverage.
. mac_sign for CMAC.
. aead_encrypt, aead_decrypt, aead_encrypt_decrypt,
aead_multipart_encrypt, aead_multipart_decrypt and
aead_multipart_generate_nonce for CCM/GCM.
. block_cipher_key_type and aead_algorithm cases to
test_suite_psa_crypto_metadata.data.
Document the provenance of all known-answer values.

8. Add PSA/external-driver acceleration for SM4

Add MBEDTLS_PSA_ACCEL_KEY_TYPE_SM4 to the configuration adjustment and test
driver configuration files:

  • config_adjust_test_accelerators.h
  • crypto_adjust_config_enable_builtins.h
  • crypto_adjust_config_tweak_builtins.h
  • tests/configs/crypto_config_test_driver_extension.h
  • tests/configs/user-config-test-driver-extension.h

Follow the AES/ARIA/CAMELLIA key-type acceleration pattern. Define
MBEDTLS_BLOCK_CIPHER_SM4_VIA_PSA, include it in
MBEDTLS_BLOCK_CIPHER_CAN_SM4, and retain
MBEDTLS_PSA_BUILTIN_KEY_TYPE_SM4 when a software block mode still requires
the built-in primitive.

In block_cipher.c, map MBEDTLS_BLOCK_CIPHER_ID_SM4 to
PSA_KEY_TYPE_SM4 in psa_key_type_from_block_cipher_id(). This supplies the
PSA engine used by CCM/GCM with externally stored or accelerated SM4 keys while
preserving the direct-software engine for built-in keys. Update
tests/scripts/components-configuration-crypto.sh, including the
no-decryption checks.

Testing (test_suite_psa_crypto_driver_wrappers.data): add an
SM4-CTR entry-point/failure case. Add SM4-CCM and SM4-GCM cases covering
one-shot encryption/decryption, multipart setup, RFC 8998 outputs, injected
allocation failures, and fallback. The cases should verify that the external
driver was actually reached. Use cipher_entry_points for SM4-CTR,
aead_encrypt and aead_decrypt for one-shot CCM/GCM, and
aead_encrypt_setup and aead_decrypt_setup for multipart setup.

9. Additional testing

  • Add boundary, negative, in-place, empty-input and chunking coverage through psa_cipher_, psa_aead_ and psa_mac_*.
  • Generate the same cases for every compatible block cipher. Do not omit a case that can reach a driver. It is okay if some negative generated tests do not reach the driver if it simplifies the generation of the tests.
Freely available English translation of the Chinese SM4 block cipher and its mode of operations: https://datatracker.ietf.org/doc/html/draft-ribose-cfrg-sm4-10 (HTML) or https://www.ietf.org/archive/id/draft-ribose-cfrg-sm4-10.txt (txt). An implementation has been proposed for SM4 in Mbed TLS: https://github.com/Mbed-TLS/mbedtls/pull/1165. No `CLA valid` label or DCO thus we cannot use it for the time being. PSA cryptography API specification: - The PSA identifier for the key type is standardized: `PSA_KEY_TYPE_SM4 == 0x2405`, with a 128-bit key and 16-byte block, introduced in 1.0.1. Support for SM4 key derivation through `psa_key_derivation_output_key()`. - 1.1.1: Explicit list of compatible algorithms: PSA_ALG_CBC_MAC, PSA_ALG_CMAC, PSA_ALG_CTR, PSA_ALG_CFB, PSA_ALG_OFB, PSA_ALG_XTS, PSA_ALG_CBC_NO_PADDING, PSA_ALG_CBC_PKCS7, PSA_ALG_ECB_NO_PADDING, PSA_ALG_CCM and PSA_ALG_GCM. SM4 can reuse the existing mode machinery. The main work is adding SM4 as a 128-bit block primitive, registering ECB/CBC/CTR with the generic cipher layer, and exposing GCM/CCM only through PSA's lightweight block-cipher path. The PSA identifier is already standardized: `PSA_KEY_TYPE_SM4 == 0x2405`, with a 128-bit key and 16-byte block. PSA explicitly permits ECB, CBC, CTR, GCM, and CCM for it. [PSA key-type specification](https://arm-software.github.io/psa-api/crypto/1.1/api/keys/types.html) The following sequence adds the SM4-based algorithms with their initial positive test coverage. Each step should remain buildable and testable on its own. # SM4 implementation The following sequence form a dependency-ordered implementation stack. At each step, the library should build and pass its test suites. For the pre-PSA commits, test with the default configuration plus a temporary definition of `MBEDTLS_PSA_BUILTIN_KEY_TYPE_SM4`. From the PSA commit onward, `PSA_WANT_KEY_TYPE_SM4` is enabled by the default PSA configuration and the configuration adjustment code derives `MBEDTLS_PSA_BUILTIN_KEY_TYPE_SM4`. ## 1. Add the SM4 ECB primitive Add: - `drivers/builtin/src/sm4.c` - `drivers/builtin/include/tf-psa-crypto/private/sm4.h` The private API should follow Camellia/ARIA with tf_psa_crypto_ prefix: - `tf_psa_crypto_sm4_init()` / `free()` - `tf_psa_crypto_sm4_setkey_enc()` / `setkey_dec()` - `tf_psa_crypto_sm4_crypt_ecb()` Ordinary sbox-table-based implementation. Open question: Add a constant-time implementation without and with neon-based acceleration. Testing: add an SM4 self-test suite. Run the published single-block encryption and decryption examples and the one-million-encryption vector from the SM4 specification/draft. The test suite itself only needs to invoke the self-test. ## 2. Register SM4-ECB in the cipher abstraction Add the SM4 cipher identifier MBEDTLS_CIPHER_ID_SM4 and the identifier for the SM4 cipher with 128-bit key and ECB mode MBEDTLS_CIPHER_SM4_128_ECB in cipher.h. Follow the CAMELLIA registration in `cipher_wrap.c`: provide `sm4_info` (no specific mode CBC, CFB ... for the time being) and `sm4_128_ecb_info`. Reference them in the relevant tables. Testing (test_suite_cipher.sm4.data): add cipher-abstraction known-answer tests for ECB encryption and decryption using SM4 Example 1 from the specification. The test function in `test_vec_ecb`. ## 3. Add the low-level SM4 cipher modes In `sm4.h` and `sm4.c`, add: - `tf_psa_crypto_sm4_crypt_cbc()` - `tf_psa_crypto_sm4_crypt_cfb128()` - `tf_psa_crypto_sm4_crypt_ofb()` - `tf_psa_crypto_sm4_crypt_ctr()` The [SM4 draft](https://datatracker.ietf.org/doc/html/draft-ribose-cfrg-sm4-10) defines CBC, CFB, OFB and CTR in Sections 8.4 through 8.7, based on the modes in NIST SP 800-38A. Use those definitions as the algorithmic reference and the existing Camellia/AES code as the Mbed TLS implementation and API reference. The differences to account for are that the draft also defines CFB-1, CFB-8 and CFB-64, whereas only CFB-128 needs to be implemented, and that the draft permits any non-repeating CTR sequence, while the Mbed TLS convention increments the complete 128-bit counter as a big-endian integer. Follow the Camellia implementations for CBC, CFB128 and CTR, and the AES implementation for OFB, while checking each operation against the SM4 draft. Use the common counter increment helper for CTR and the existing `MBEDTLS_CIPHER_MODE_*` guards. Testing: extend the self-test in `sm4.c`; `test_suite_sm4` remains unchanged and continues to invoke it. Test CBC, CFB128, OFB and CTR encryption and decryption with both vector sets from Appendix A of the SM4 draft, including the complete 64-byte CTR vectors. These known-answer tests confirm that the selected Mbed TLS profiles agree with the SM4 mode definitions. ## 4. Register the SM4 cipher modes in the cipher abstraction In `cipher.h`, add `MBEDTLS_CIPHER_SM4_128_CBC`, `MBEDTLS_CIPHER_SM4_128_CFB128`, `MBEDTLS_CIPHER_SM4_128_OFB` and `MBEDTLS_CIPHER_SM4_128_CTR`. In `cipher_wrap.c`, add the corresponding callbacks to `sm4_info`, provide `sm4_128_cbc_info`, `sm4_128_cfb128_info`, `sm4_128_ofb_info` and `sm4_128_ctr_info`, and reference them in the cipher tables. Follow the CAMELLIA registrations for CBC, CFB and CTR and the AES registration for OFB. Do not add XTS, GCM or CCM here. Testing (`test_suite_cipher.sm4.data`): add encryption and decryption `test_vec_crypt` cases for CBC, CFB128, OFB and CTR using Appendix A vectors. Increase the `test_vec_crypt` output buffer to 64 bytes and use the complete published CTR vector. ## 5. Add SM4 to the block-cipher abstraction In `block_cipher.h`, add `MBEDTLS_BLOCK_CIPHER_ID_SM4` and the SM4 context to the context union. In `block_cipher.c`, add the direct-software cases for context initialization/free, encryption-key setup and block encryption. Follow the CAMELLIA `MBEDTLS_BLOCK_CIPHER_ENGINE_LEGACY` implementation and use `MBEDTLS_PSA_BUILTIN_KEY_TYPE_SM4` as the SM4 implementation guard. Update `block_cipher_internal.h`, `crypto_adjust_config_tweak_builtins.h` and `tf_psa_crypto_check_config.h` so CCM/GCM can select SM4 through `block_cipher.c`. Add the `MBEDTLS_BLOCK_CIPHER_SM4_VIA_LEGACY`, `MBEDTLS_BLOCK_CIPHER_CAN_SM4` and `MBEDTLS_CCM_GCM_CAN_SM4` capability macros. “Legacy” here only identifies the direct-software block-cipher engine. There is no public legacy SM4 API. Testing (`test_suite_block_cipher.data`): add a `test_vec` case that performs SM4 block encryption with specification Example 1. ## 6. Add SM4 CCM-star-no-tag to the cipher abstraction In `cipher.h`, add `MBEDTLS_CIPHER_SM4_128_CCM_STAR_NO_TAG`. In `cipher_wrap.h`, add `MBEDTLS_CIPHER_HAVE_CCM_STAR_NO_TAG_SM4_VIA_LEGACY_OR_USE_PSA`. In `cipher_wrap.c`, provide the CCM-backed `ccm_sm4_info` base and `sm4_128_ccm_star_no_tag_info`. The set-key wrapper calls `mbedtls_ccm_setkey()` with `MBEDTLS_CIPHER_ID_SM4`. Follow the existing AES/ARIA/CAMELLIA CCM-star-no-tag registrations and shared CCM context handling. This does not add tagged CCM or GCM to `cipher.c`. Testing (`test_suite_cipher.sm4.data`): add encryption and decryption `test_vec_crypt` known-answer cases for `MBEDTLS_CIPHER_SM4_128_CCM_STAR_NO_TAG`, using the RFC 8998 Appendix A.2 key and plaintext with independently derived ciphertext for a 13-byte nonce. ## 7. Add built-in PSA SM4 support In `crypto_values.h`, define `PSA_KEY_TYPE_SM4` as a fixed 128-bit block-cipher key type. Update its documentation in `crypto.h`, enable `PSA_WANT_KEY_TYPE_SM4` in `crypto_config.h`, update `crypto_sizes.h` (definition of PSA_CIPHER_MAX_KEY_LENGTH), and add the option to `scripts/data_files/config-options-current.txt`. Follow `PSA_KEY_TYPE_CAMELLIA` in `psa_crypto.c` for key-size validation and in `crypto_adjust_config_enable_builtins.h` for configuration derivation. The latter should derive `MBEDTLS_PSA_BUILTIN_KEY_TYPE_SM4`. Update `check_crypto_config.h` for CCM/GCM prerequisites. In `psa_crypto_cipher.c`, update `mbedtls_cipher_validate_values()` and `mbedtls_cipher_values_from_psa()` to map SM4 and permit ECB, CBC without padding, CBC-PKCS7, CFB, OFB, CTR, CMAC, CCM-star-no-tag, CCM and GCM. Follow the mapping for CAMELLIA and the implementation of the relevant mode. In `cmac.c`, accept `MBEDTLS_CIPHER_SM4_128_ECB` as a CMAC block cipher. Once all SM4-based algorithms are available, update `framework/tests/include/test/psa_exercise_key.h` and `framework/scripts/mbedtls_framework/crypto_knowledge.py` so the framework recognizes SM4 as a 128-bit block cipher. Do not advance the framework pointer in the earlier commits. Testing (`test_suite_psa_crypto.sm4.data`): cover valid and invalid key imports; one-shot and multipart ECB/CBC/CFB/OFB/CTR operations, partial final blocks, generated IVs, CBC-PKCS7 and invalid padding, CCM-star-no-tag, and CMAC. For CCM/GCM, use the RFC 8998 known-answer vectors and cover one-shot and multipart encryption/decryption, shortened tags, nonce limits, generated nonces and authentication failures. Use: . `import_with_data` for key import tests. . `cipher_alg_without_iv`, `cipher_encrypt_multipart`, `cipher_decrypt`, `cipher_decrypt_multipart`, `cipher_verify_output_multipart`, `cipher_encrypt_validation` and `cipher_decrypt_fail` for cipher coverage. . `mac_sign` for CMAC. . `aead_encrypt`, `aead_decrypt`, `aead_encrypt_decrypt`, `aead_multipart_encrypt`, `aead_multipart_decrypt` and `aead_multipart_generate_nonce` for CCM/GCM. . `block_cipher_key_type` and `aead_algorithm` cases to `test_suite_psa_crypto_metadata.data`. Document the provenance of all known-answer values. ## 8. Add PSA/external-driver acceleration for SM4 Add `MBEDTLS_PSA_ACCEL_KEY_TYPE_SM4` to the configuration adjustment and test driver configuration files: - `config_adjust_test_accelerators.h` - `crypto_adjust_config_enable_builtins.h` - `crypto_adjust_config_tweak_builtins.h` - `tests/configs/crypto_config_test_driver_extension.h` - `tests/configs/user-config-test-driver-extension.h` Follow the AES/ARIA/CAMELLIA key-type acceleration pattern. Define `MBEDTLS_BLOCK_CIPHER_SM4_VIA_PSA`, include it in `MBEDTLS_BLOCK_CIPHER_CAN_SM4`, and retain `MBEDTLS_PSA_BUILTIN_KEY_TYPE_SM4` when a software block mode still requires the built-in primitive. In `block_cipher.c`, map `MBEDTLS_BLOCK_CIPHER_ID_SM4` to `PSA_KEY_TYPE_SM4` in `psa_key_type_from_block_cipher_id()`. This supplies the PSA engine used by CCM/GCM with externally stored or accelerated SM4 keys while preserving the direct-software engine for built-in keys. Update `tests/scripts/components-configuration-crypto.sh`, including the no-decryption checks. Testing (`test_suite_psa_crypto_driver_wrappers.data`): add an SM4-CTR entry-point/failure case. Add SM4-CCM and SM4-GCM cases covering one-shot encryption/decryption, multipart setup, RFC 8998 outputs, injected allocation failures, and fallback. The cases should verify that the external driver was actually reached. Use `cipher_entry_points` for SM4-CTR, `aead_encrypt` and `aead_decrypt` for one-shot CCM/GCM, and `aead_encrypt_setup` and `aead_decrypt_setup` for multipart setup. ## 9. Additional testing - Add boundary, negative, in-place, empty-input and chunking coverage through psa_cipher_*, psa_aead_* and psa_mac_*. - Generate the same cases for every compatible block cipher. Do not omit a case that can reach a driver. It is okay if some negative generated tests do not reach the driver if it simplifies the generation of the tests.
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#909
No description provided.