Expand ECC generate key tests - #665
Conversation
There was a problem hiding this comment.
Pull request overview
Expands the TBOR EccGenerateKey emulator integration tests to cover additional lifecycle/authorization scenarios and negative-path validation, strengthening confidence in ECC key generation behavior across curves and scopes.
Changes:
- Extend key generation coverage to assert fresh generation on repeated calls for each supported NIST curve.
- Add tests for scope lifecycle rules (Session allowed pre-finalize; Ephemeral rejected pre-finalize; SecurityDomain rejected before SD creation).
- Add negative-path tests for invalid curve/scope discriminants and mismatched session identifiers, plus a CU-session authorization test (with PSK rotation to avoid default-PSK gating).
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ad8621f to
d931f1c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (3)
ddi/tbor/types/tests/commands/ecc_generate_key.rs:174
- This test opens a rotated CO session via
bootstrap_rotated_co, but never closes it. Since the emulator session table is process-global, leaking the session can impact later tests. Consider wrapping the handshake inSessionGuardand usingsession.session_id()in the request.
let session = bootstrap_rotated_co(&ctx, &ROTATED_CO_PSK);
ctx.expect_fw_reject(
&TborEccGenerateKeyReq {
session_id: session.session_id,
scope: SCOPE_EPHEMERAL,
ddi/tbor/types/tests/commands/ecc_generate_key.rs:121
bootstrap_rotated_coreturns a rawSessionHandshakeand this test never closes the resulting session. The harness documents that leaked emulator session slots persist across serial tests, so this can cause cross-test failures. Wrap the handshake inSessionGuardso the session is reliably closed on drop.
This issue also appears on line 170 of the same file.
let session = bootstrap_rotated_co(&ctx, &ROTATED_CO_PSK);
generate(&ctx, session.session_id, SCOPE_SESSION, ECC_CURVE_P256);
ddi/tbor/types/tests/commands/ecc_generate_key.rs:145
- The CU session opened via
session_open_init_with_options/session_open_finishis never closed. The harness providesSessionGuardspecifically to prevent leaked emulator session slots from breaking subsequent tests; wrapping the returnedSessionHandshakewould make this panic-safe.
let session = ctx
.session_open_finish(pending)
.expect("finish CU session open");
generate(&ctx, session.session_id, SCOPE_SESSION, ECC_CURVE_P256);
| @@ -31,6 +36,8 @@ const SCOPE_SESSION: u8 = 0b001; | |||
| const SCOPE_EPHEMERAL: u8 = 0b010; | |||
| /// `KeyScope::Local` discriminant. | |||
| const SCOPE_LOCAL: u8 = 0b011; | |||
There was a problem hiding this comment.
these variables can common, please check if we can use common location to use the constants
d931f1c to
f607dc5
Compare
No description provided.