Skip to content

Expand ECC generate key tests - #665

Open
meilu-git wants to merge 4 commits into
mainfrom
meilu/tbor_tests_ecc_generate_key
Open

Expand ECC generate key tests#665
meilu-git wants to merge 4 commits into
mainfrom
meilu/tbor_tests_ecc_generate_key

Conversation

@meilu-git

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread ddi/tbor/types/tests/commands/ecc_generate_key.rs Outdated
Copilot AI review requested due to automatic review settings August 20, 2026 22:45
@meilu-git
meilu-git force-pushed the meilu/tbor_tests_ecc_generate_key branch from ad8621f to d931f1c Compare August 20, 2026 22:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in SessionGuard and using session.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_co returns a raw SessionHandshake and 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 in SessionGuard so 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_finish is never closed. The harness provides SessionGuard specifically to prevent leaked emulator session slots from breaking subsequent tests; wrapping the returned SessionHandshake would 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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these variables can common, please check if we can use common location to use the constants

Comment thread ddi/tbor/types/tests/commands/ecc_generate_key.rs Outdated
Comment thread ddi/tbor/types/tests/commands/ecc_generate_key.rs Outdated
@meilu-git
meilu-git force-pushed the meilu/tbor_tests_ecc_generate_key branch from d931f1c to f607dc5 Compare August 31, 2026 15:39
Copilot AI review requested due to automatic review settings August 31, 2026 15:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 31, 2026 15:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants