Skip to content

Meilu/tbor tests get unwrapping key - #695

Open
meilu-git wants to merge 3 commits into
mainfrom
meilu/tbor_tests_get_unwrapping_key
Open

Meilu/tbor tests get unwrapping key#695
meilu-git wants to merge 3 commits into
mainfrom
meilu/tbor_tests_get_unwrapping_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.

🟢 Approval recommended

The changes are isolated to test code and improve coverage/validation with only minor consistency/formatting nits noted.

Pull request overview

This PR expands the TBOR GetUnwrappingKey integration tests to more thoroughly validate the returned RSA-2048 public key and to cover additional role/access and error-path behaviors within the TBOR test harness.

Changes:

  • Strengthens “happy path” validation by checking RSA-2048 modulus bit properties and the standard exponent (65537).
  • Adds coverage for Crypto-User access (including default-PSK gate behavior) and verifies the key is consistent across CO/CU sessions and across PSK rotations.
  • Adds negative-path tests for closed/unknown session IDs.
File summaries
File Description
ddi/tbor/types/tests/commands/get_unwrapping_key.rs Expands GetUnwrappingKey emulator-gated integration tests to validate RSA key structure, role access behavior, stability across sessions, and key error cases.
Review details

Suppressed comments (1)

ddi/tbor/types/tests/commands/get_unwrapping_key.rs:141

  • There is an extraneous trailing comma in this assert! invocation; removing it avoids unnecessary diffs and keeps formatting consistent with other tests.
    assert!(modulus[0] & 1 != 0, "RSA modulus must be odd",);
  • Files reviewed: 1/1 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 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/get_unwrapping_key.rs Outdated
Comment thread ddi/tbor/types/tests/commands/get_unwrapping_key.rs Outdated
Copilot AI review requested due to automatic review settings September 3, 2026 20:07

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.

🟢 Approval recommended

The changes are test-only and add meaningful coverage without introducing functional risk.

Review details

Suppressed comments (3)

Previously missed (1) — in code that hasn't changed since the last review.

ddi/tbor/types/tests/commands/get_unwrapping_key.rs:114

  • This test duplicates the harness’s bootstrap_rotated_cu flow (open CU under default PSK → PskChange → reopen under rotated PSK). Reusing the helper reduces repetition and keeps rotated-PSK setup consistent across the suite.

This issue also appears in the following locations of the same file:

  • line 224
  • line 291

ddi/tbor/types/tests/commands/get_unwrapping_key.rs:243

  • This block re-implements the CU PSK rotation + session bootstrap sequence that already exists as crate::harness::bootstrap_rotated_cu. Using the shared helper avoids copy/paste and centralizes any future handshake/rotation changes.
    // Rotate the CU PSK so GetUnwrappingKey reaches its handler instead
    // of being rejected by the dispatcher's default-PSK gate.
    let bootstrap = ctx
        .open_session(CU, SessionType::PlainText)
        .expect("open bootstrap CU session");

    ctx.psk_change(bootstrap.handshake(), &ROTATED_CU_PSK)
        .expect("rotate CU PSK");

    bootstrap.close().expect("close bootstrap CU session");

    // Reopen CU under the rotated PSK.
    let opts = SessionOpenInitOptions::new(CU, SessionType::PlainText).with_psk(&ROTATED_CU_PSK);

    let pending = ctx
        .session_open_init_with_options(opts)
        .expect("open CU session under rotated PSK");

    let cu_session = ctx.session_open_finish(pending).expect("finish CU session");

ddi/tbor/types/tests/commands/get_unwrapping_key.rs:311

  • The CU PSK rotation + first-session setup duplicates crate::harness::bootstrap_rotated_cu. Using that helper here would shrink the test and keep the rotation logic consistent with other command tests.
    // Rotate the CU PSK.
    let bootstrap = ctx
        .open_session(CU, SessionType::PlainText)
        .expect("open bootstrap CU session");

    ctx.psk_change(bootstrap.handshake(), &ROTATED_CU_PSK)
        .expect("rotate CU PSK");

    bootstrap.close().expect("close bootstrap CU session");

    // First CU session.
    let opts = SessionOpenInitOptions::new(CU, SessionType::PlainText).with_psk(&ROTATED_CU_PSK);

    let pending = ctx
        .session_open_init_with_options(opts)
        .expect("open first CU session");

    let first_session = ctx
        .session_open_finish(pending)
        .expect("finish first CU session");

  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@vsonims
Vishal Soni (vsonims) deleted the meilu/tbor_tests_get_unwrapping_key branch September 12, 2026 19:26
@vsonims
Vishal Soni (vsonims) restored the meilu/tbor_tests_get_unwrapping_key branch September 12, 2026 19:47
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