Skip to content

Support for tpm persistent handles in TSS2 privkey - #165

Open
royalsreafer wants to merge 1 commit into
tpm2-software:masterfrom
royalsreafer:master
Open

royalsreafer wants to merge 1 commit into
tpm2-software:masterfrom
royalsreafer:master

Conversation

@royalsreafer

Copy link
Copy Markdown

This commit adds support for encoding and decoding of TSS2 pem files which contain references to persistent handles. The handle is stored in the same privkey area as the keyblob. The length(4 bytes) and the first byte(0x81 for persistent handles) distinguishes it as a persistent key stored in the TPM. This approach keeps true to the ASN1 structure defined in OID "2.23.133.10.1.3" .

I've used this patch for a while now and has been working out for our use-case. The use-case being adding support for TPM2 keys without changing the code of applications. Many applications supporting OpenSSL, do not support loading TPM keys with the handle:81xxxxxx due to the ossl_store_ex not being called. TSS2 pem keys circumvent this and adding persistent key handle support to this format solved the issue with TPM2 persistent key support.

Another pull request with a different approach #162

@royalsreafer
royalsreafer force-pushed the master branch 7 times, most recently from a82ff3e to d68463f Compare March 7, 2026 17:24
@royalsreafer royalsreafer reopened this Mar 7, 2026
@royalsreafer royalsreafer changed the title Added support for tpm persistent handles in TSS2 privkey Support for tpm persistent handles in TSS2 privkey Mar 8, 2026
@shmset

shmset commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

@royalsreafer I've just seen your approach to use persistent handles. Integrates much nicer into the existing ASN1 structure.

@LordGaav

LordGaav commented Jun 2, 2026

Copy link
Copy Markdown

Is there anything we can do to move this PR along? We're currently using a forked version of tpm2-openssl with this patch, which isn't a big deal on its own, but having it in the upstream release is even better.

@royalsreafer

Copy link
Copy Markdown
Author

@AndreasFuchsTPM @moritzbuhl I've tagged you since you seem to be the most active at the moment. I wonder If there is anything I/we can do to move the PR along? Any response is much appreciated.

@moritzbuhl

Copy link
Copy Markdown
Member

I'll take a look on Monday.

@moritzbuhl moritzbuhl self-assigned this Sep 12, 2026
@moritzbuhl

Copy link
Copy Markdown
Member

Could you rebase onto the recently committed CI fixes?

Comment thread test/ec_genpkey_check_handle.sh Resolved
Signed-off-by: RoyalReafer <royalsmods@hotmail.com>
@Peszto

Peszto commented Oct 16, 2026

Copy link
Copy Markdown

Hi! Just wanted to check if there’s anything else needed before this can be merged. Since it’s approved and all checks are passing, it would be great to get it into upstream. Thanks!

@moritzbuhl

Copy link
Copy Markdown
Member

Since the public part of the persistent key is in the PEM it would make senste to compare the public part with the one on the TPM right after esys_tr_from_tpm_public. Otherwise this is good.

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.

5 participants