Created
March 7, 2023 19:59
-
-
Save williamcroberts/61cd244d5ea0fb1bee32528dce533318 to your computer and use it in GitHub Desktop.
Test code for sessions with getcap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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