Skip to content

Instantly share code, notes, and snippets.

@williamcroberts
Created March 7, 2023 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save williamcroberts/61cd244d5ea0fb1bee32528dce533318 to your computer and use it in GitHub Desktop.
Save williamcroberts/61cd244d5ea0fb1bee32528dce533318 to your computer and use it in GitHub Desktop.
Test code for sessions with getcap
from tpm2_pytss import *
e = ESAPI()
phandle = e.create_primary(None)[0]
sym = TPMT_SYM_DEF(
algorithm=TPM2_ALG.XOR,
keyBits=TPMU_SYM_KEY_BITS(exclusiveOr=TPM2_ALG.SHA256),
mode=TPMU_SYM_MODE(aes=TPM2_ALG.CFB),
)
hmac_session = e.start_auth_session(
tpm_key=phandle,
bind=ESYS_TR.NONE,
session_type=TPM2_SE.HMAC,
symmetric=sym,
auth_hash=TPM2_ALG.SHA256,
)
# e.trsess_set_attributes(
# hmac_session, TPMA_SESSION.DECRYPT
# )
more = True
while more:
more, capdata = e.get_capability(
TPM2_CAP.COMMANDS, TPM2_CC.FIRST, TPM2_MAX.CAP_CC,
session1=hmac_session
)
for c in capdata.data.command:
print(c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment