ivila opened a new pull request, #339:
URL: https://github.com/apache/teaclave-trustzone-sdk/pull/339
The FFI was maintained by hand in two places, and both had drifted. None of
these mistakes are caught by the compiler or by the tests: they just make a
TA
misbehave at run time.
In `optee-utee-sys` / `optee-teec-sys`:
- The deprecated algorithm constants kept hand-copied values that no longer
match the headers: `TEE_ALG_ECDSA_P192` was `0x70001041` while the header
now
aliases it to `TEE_ALG_ECDSA_SHA1` (`0x70001042`), and the same for
`TEE_ALG_ECDH_P*`.
- Constants were missing outright as upstream grew.
In `optee-utee` itself (the safe wrapper), the copied values were wrong too:
- `TaInstanceKeepCrashed` used `gpd.ta.instanceKeepCrashed`, but the header
and
the TA runtime use `optee.ta.instanceKeepCrashed`, so the key never
matched.
- The `TEE_PROPSET_TEE_IMPLEMENTATION` key set did not match what OP-TEE
serves: `gpd.tee.sockets.version` and `gpd.tee.sockets.tcp.version` were
missing, while ten keys OP-TEE never implements
(`gpd.tee.cryptography.nist`,
`gpd.tee.trustedStorage.*.rollbackProtection`,
`gpd.tee.event.maxSources`, …) were exposed and could only return
`TEE_ERROR_ITEM_NOT_FOUND`.
- `AttributeId` named a constant that does not exist upstream
(`RsaOaepMgf1Hash`) and lacked the newer ones (`TEE_ATTR_BIT_PROTECTED`,
`TEE_ATTR_BIT_VALUE`).
Fixing these one at a time only moves the problem to the next OP-TEE bump, so
this takes the declarations out of human hands instead: generate them from
the
pinned headers, commit the result, and let CI check it.
## What this changes
- New root `xtask` with `generate-bindings (utee|teec|all)`. It runs bindgen
against the TA dev kit (`TA_DEV_KIT_DIR`) or the client export
(`OPTEE_CLIENT_EXPORT`) of the release pinned in `optee-version.txt`, and
rewrites `crates/optee-{utee,teec}-sys/src/generated.rs`.
- The committed output is plain Rust: ordinary builds need neither libclang
nor
OP-TEE headers. Only the few items bindgen cannot express (property-set
handles, parameter macros, the TA entry trampoline) stay hand-written in
`handwritten.rs`.
- `optee-utee` stops carrying literals: the property keys now use the
generated
`TA_PROP_STR_*` constants, and the attribute, storage, usage, data and
handle
ids come from the bindings, so a wrong value can no longer be typed in by
hand. Consumers also follow the generated names and `Option` callbacks.
- The `*-systest` crates are removed. A CI job rebuilds the dev kit and the
client export, re-generates both files and fails on any diff, which
replaces
that coverage. `docs/release-tips.md` gains the same step.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]