Skip to content

Add KeyStack PTA - #1104

Open
Sangho Lee (sangho2) wants to merge 3 commits into
mainfrom
sanghle/optee/keystack_pta
Open

Add KeyStack PTA#1104
Sangho Lee (sangho2) wants to merge 3 commits into
mainfrom
sanghle/optee/keystack_pta

Conversation

@sangho2

@sangho2 Sangho Lee (sangho2) commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

This PR introduces a KeyStack PTA which derives a stack of keys based on a requesting TA's UUID, Secure Version Number (SVN), and extra data, enabling anti-rollback key derivation.

@sangho2

Copy link
Copy Markdown
Contributor Author

Replace #831 with this PR to maintain the compatibility with the mainline OP-TEE OS.

@sangho2 Sangho Lee (sangho2) added the discussion Open questions label Jul 29, 2026
@sangho2
Sangho Lee (sangho2) force-pushed the sanghle/optee/keystack_pta branch from 6c43996 to 8ab855f Compare July 29, 2026 23:41
@sangho2 Sangho Lee (sangho2) changed the title [DRAFT] Add KeyStack PTA Add KeyStack PTA Jul 29, 2026
Comment on lines +39 to +46
// TODO: Replace this placeholder with the UUID agreed upon with the
// consuming TA before this PTA is treated as a stable interface.
pub(crate) const UUID: TeeUuid = TeeUuid {
time_low: 0x978a_f7a7,
time_mid: 0x074f,
time_hi_and_version: 0x4f59,
clock_seq_and_node: [0xb3, 0xae, 0x33, 0xa5, 0x93, 0xc1, 0xd4, 0x88],
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

UUID

@sangho2
Sangho Lee (sangho2) marked this pull request as ready for review July 29, 2026 23:56
Comment thread litebox_shim_optee/src/syscalls/tests.rs Fixed
@sangho2
Sangho Lee (sangho2) force-pushed the sanghle/optee/keystack_pta branch 2 times, most recently from d575fc8 to a3a7ee0 Compare July 31, 2026 02:01
@sangho2 Sangho Lee (sangho2) added must-not-merge:blocked-on-other-changes Other changes/PRs to be handled first. Label not needed for non-main changes. and removed discussion Open questions labels Aug 3, 2026
Comment thread litebox_shim_optee/src/syscalls/pta.rs Outdated

/// Open a session to a PTA that carries no per-session state and takes no
/// parameters at session-open time.
pub(crate) fn open_default_pta_session(params: &UteeParams) -> Result<u32, TeeResult> {

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.

default_pta is a bit confusing. This implies a Default PTA that would be invoked.

Looking at the definition, this seems like some setup/validation.

)?;

// Derive keys from max SVN down to 0
for svn_idx in (0..svn_key_stack_size).rev() {

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.

If the input parameter has 2047, this section will create all the keys, but only send keys with svns <= ta_svn.

Does it make sense to only generate min(svm_key_stack_size, ta_svn) keys instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We can't do that because this key derivation is based on a sequential hash chain. It should compute a key with the maximum SVN first. That is, Key_v10 can be derived from Key_v11, but not from Key_v9.

@sangho2
Sangho Lee (sangho2) force-pushed the sanghle/optee/keystack_pta branch from a3a7ee0 to 9c84927 Compare August 31, 2026 17:01
@sangho2
Sangho Lee (sangho2) force-pushed the sanghle/optee/keystack_pta branch from 8024775 to dda3c8d Compare August 31, 2026 18:26
@sangho2 Sangho Lee (sangho2) removed the must-not-merge:blocked-on-other-changes Other changes/PRs to be handled first. Label not needed for non-main changes. label Aug 31, 2026
@github-actions

Copy link
Copy Markdown

🤖 SemverChecks 🤖 No breaking API changes detected

Note: this does not mean API is unchanged, or even that there are no breaking changes; simply, none of the detections triggered.

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