Skip to content

Latest commit

 

History

History
132 lines (107 loc) · 6.72 KB

Interface-Profiles.md

File metadata and controls

132 lines (107 loc) · 6.72 KB

Crypto operation profiles

WT_ENGINE=native|hsm selects the crypto engine independently of the application API. WT_INTERFACE_PROFILE=default|extended selects the exported operations. Native is the default engine. Neither TPM nor PKCS#11 requires wolfHSM.

The default profile covers RNG, SHA-256 and P-256 key generation, signing and verification. It also includes the key, session and token management needed to use those operations. PKCS#11 retains PIN setup, login, attempt limits and recovery. config/crypto-profiles.json is the explicit default operation list. The extended profile retains the broader operations supported by the pinned libraries and this platform's algorithm and memory configuration.

Select operations

Use the same settings for the application and Secure image:

make secure-image CONFIG_PKCS11=y WT_ENGINE=native WT_INTERFACE_PROFILE=default
make secure-image CONFIG_TPM=y WT_ENGINE=hsm WT_INTERFACE_PROFILE=extended

WT_INTERFACE_ENABLE='pkcs11:C_GetObjectSize tpm:PCR_Read' \
WT_INTERFACE_DISABLE='pkcs11:C_GenerateRandom' \
  make secure-image CONFIG_PKCS11=y

Enable and disable lists contain whitespace-separated api:operation names. Overrides apply after the selected profile; disable wins if both lists name the same operation. They select entry points, not automatic dependencies between application calls. An application that removes initialization or a required key lifecycle call must use an appropriate lifecycle of its own.

A JSON file can replace individual lists. Unspecified lists retain the selected profile's defaults:

{
  "pkcs11": ["C_Initialize", "C_Finalize", "C_GetSlotList", "C_OpenSession",
             "C_CloseSession", "C_DigestInit", "C_Digest"],
  "mechanisms": ["CKM_SHA256"]
}

Pass its absolute path with WT_INTERFACE_CONFIG. The accepted fields are pkcs11, tpm, and mechanisms, each a JSON array of names. TPM 2.0 and PKCS#11 builds link no PSA Crypto, so a psa field or psa: override fails. An empty mechanism list exports no crypto mechanisms. Unknown fields and operation names fail the build. A CONFIG_TPM=y build requires at least one selected command; a CONFIG_PKCS11=y build accepts "tpm": []. A TPM selection must keep Startup: the provider also sends it to reset a departed client.

Inspect known dependency entry points or generate a selection directly:

python3 tools/crypto_profile.py --list
python3 tools/crypto_profile.py --output build/crypto-profile \
  --profile default --enable pkcs11:C_GetObjectSize --disable pkcs11:C_GenerateRandom

The command catalog includes dependency commands whose algorithm or feature family can be disabled by platform settings. Selection does not override those settings or provide missing NV storage. A default-derived TPM selection checks that every requested command survived those guards. The extended profile retains the dependency guards; TPM_CAP_COMMANDS reports the commands actually built.

What is removed

PKCS#11 keeps the standard function-list ABI. Disabled entries are typed stubs returning CKR_FUNCTION_NOT_SUPPORTED without a transport call. The provider also rejects a forged disabled wire operation before decoding its arguments or calling the backend. Removed mechanisms return CKR_MECHANISM_INVALID. Mechanism enumeration and action flags reflect the allowed operations.

TPM generation filters the pinned fwTPM dispatch table in the build directory. It preserves the original handlers and authorization metadata. Disabled commands return TPM_RC_COMMAND_CODE, disappear from TPM_CAP_COMMANDS, and no longer retain their handlers through the table. Dependency source and pins are not modified.

Removing an operation does not remove primitives needed internally. PKCS#11 PIN protection still needs PBKDF2/HMAC. Public AES and HMAC mechanism dispatch is omitted when unselected, while the internal PIN primitives and shared structure layouts stay intact. fwTPM can need hashing and symmetric crypto for object protection even when related public mechanisms are absent. TPM and PKCS#11 images link no wolfPSA Crypto implementation. Their psa_call functions are the FF-M IPC boundary.

The basic selection also omits unused AES-CTR, CCM and deterministic-ECDSA extensions from the Secure image. Extended profiles and broader custom command or mechanism selections restore those extensions. Required CFB and PIN primitives remain enabled. The basic TPM image uses wolfCrypt's original ASN codec; broader TPM profiles and PKCS#11 retain the template codec. Host tests cover both codecs, malformed keys and signatures, and cross-codec key decoding.

HSM callback dispatch for basic TPM/PKCS#11 selections retains RNG, SHA-256 and P-256. It omits unrequested AES and HKDF dispatch after loading the complete shared type definitions. Extended and broader custom selections retain the original callback. No dependency files or structure layouts are changed.

Reference builds and verification

FreeRTOS guest builds use WT_LTO=1 by default; WT_LTO=0 disables it. RTOS, startup, libc and cross-world transport objects keep their compilation boundaries. The reference TPM application, tests/firmware/interface-guest, is bare-metal and links wolfTPM's client crypto and wolfCrypt for HMAC and parameter-encrypted sessions. It takes entropy from TPM2_GetRandom and links no native or wolfHSM engine client, so it is the same image under both engines. The TPM service still selects native/HSM normally. TPM/PKCS#11 HSM providers omit unused software ECC fallback by default. WT_PROVIDER_ECC_FALLBACK=1 restores it; native builds always retain software ECC, and the HSM server keeps its own implementation. PSA retains the software ECC path required for deterministic ECDSA; that dependency is not removed.

The profile PKCS#11 reference suite exercises the default operations, capability filtering, disabled entry points, forged wire requests and PIN recovery. The all suite retains the 40-case broader regression. CI tests every engine and profile each Cortex-M33 port registers (STM32L562: native engine, default profile), with the bare-metal TPM 2.0 and PKCS#11 applications and their partition-isolation scenarios.

Run make test for the host regressions. The target runner builds the interface profile named by WT_PROFILE (default or extended) unless WT_INTERFACE_PROFILE is set; product builds default to default. Applications must match the selected operation list.

Footprint has the measured sizes, and tools/measure_interface_footprint.sh reproduces them.

TPM selections containing ZGen_2Phase retain software ECC point arithmetic because its full-point operation is outside the HSM ECDH callback. Adding that command restores the dependency automatically; it is absent from the small default profile.