feat(engine): HSM lifecycle, logging, and provider-aligned OBK/MOBK#532
Open
walterchris wants to merge 2 commits into
Open
feat(engine): HSM lifecycle, logging, and provider-aligned OBK/MOBK#532walterchris wants to merge 2 commits into
walterchris wants to merge 2 commits into
Conversation
a5812db to
ce32596
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a lazily-initialized HSM lifecycle layer and env-driven tracing for the OpenSSL 1.1.x engine, aligning OBK/MOBK + POTA flows with the provider while keeping openssl engine -t as bind-only.
Changes:
- Introduces
EngineData/HsmContextstored inENGINEex_data to support on-demand partition init + session open. - Adds env-gated
tracing_subscribersetup for engine logging (stderr and/or file). - Wires engine bind to register/destroy ex_data and install logging; updates crate/workspace deps to support new functionality.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| plugins/ossl_engine/engine/src/logging.rs | Adds env-controlled tracing subscriber installation for stderr/file logging. |
| plugins/ossl_engine/engine/src/lib.rs | Registers cached ex_data slot, parks EngineData, installs logging at bind, and adds destroy handler. |
| plugins/ossl_engine/engine/src/context.rs | Implements lazy HSM open path (partition init + OBK/MOBK handling + POTA + session open) with mock-feature tests. |
| plugins/ossl_engine/engine/Cargo.toml | Adds dependencies/features needed for lifecycle/logging + mock tests. |
| Cargo.toml | Adds engine-resiliency workspace member and tracing-appender dependency. |
ce32596 to
35ab3e1
Compare
35ab3e1 to
d9660e3
Compare
d9660e3 to
c8f0ab1
Compare
c8f0ab1 to
067a5c5
Compare
067a5c5 to
8241b11
Compare
Wire the cdylib: EngineData parked in ENGINE ex_data; HsmContext opens the partition/session via env-configured credentials + resiliency. Provider-aligned OBK/MOBK init (mirrors azihsm_ossl_hsm.c): try the plaintext OBK first, fall back to the cached MOBK on Bk3AlreadyInitialized, persist mobk_vec() after a cold init. Adds env-gated tracing_subscriber logging. Signed-off-by: Christian Walter <christian.walter@9elements.com>
8241b11 to
7ae96b0
Compare
Comment on lines
+104
to
+108
| let installed = tracing_subscriber::registry() | ||
| .with(layers) | ||
| .with(filter) | ||
| .try_init() | ||
| .is_ok(); |
| #[serial] | ||
| fn open_hsm_with_resiliency_succeeds() { | ||
| let scratch = Scratch::new("open"); | ||
| fs::create_dir_all(scratch.0.join("res")).unwrap(); |
| #[serial] | ||
| fn open_hsm_is_idempotent() { | ||
| let scratch = Scratch::new("idem"); | ||
| fs::create_dir_all(scratch.0.join("res")).unwrap(); |
open_from_env_smoke drives EngineData::open_hsm_from_env() — the full partition open + init + session — using the ambient AZIHSM_* environment, so a provisioned HSM host can validate a configuration end to end (e.g. the TPM OBK/POTA sources, which the mock cannot exercise). Compiled only in non-mock builds and #[ignore]d, so it never runs in the mock CI cell; run it explicitly on hardware with the AZIHSM_* env set. Signed-off-by: Christian Walter <christian.walter@9elements.com>
Comment on lines
+467
to
+469
| let scratch = Scratch::new("open"); | ||
| fs::create_dir_all(scratch.0.join("res")).unwrap(); | ||
|
|
Comment on lines
+482
to
+484
| let scratch = Scratch::new("idem"); | ||
| fs::create_dir_all(scratch.0.join("res")).unwrap(); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the HSM lifecycle + logging layer to the OpenSSL 1.1.x engine, on top of the resiliency toolkit and azihsm_crypto's 1.1.x support.
No behavior change for current users: openssl engine -t still only binds; it does not touch a device.
For manual testing with TPM: