Last active
October 14, 2025 02:01
-
-
Save misodengaku/abd457c2c85387c97567b5f7cc71f08d to your computer and use it in GitHub Desktop.
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
| import struct, uuid | |
| # https://www.amd.com/content/dam/amd/en/documents/epyc-technical-docs/specifications/58019.pdf p29 | |
| SERVICE_MANIFEST_GUID = uuid.UUID("63849ebb-3d92-4670-a1ff-58f9c94b87bb") | |
| # https://github.com/coconut-svsm/svsm/blob/74d5682c0fabcabedd80aa6e5f5ea9425a4f7171/kernel/src/protocols/attest.rs#L37 | |
| SVSM_ATTEST_VTPM_GUID = uuid.UUID("c476f1eb-0123-45a5-9641-b4e7dde5bfe3") | |
| def read_uuid(b): | |
| s = struct.unpack("<IHH2s6s", b[0:16]) | |
| return uuid.UUID(bytes=struct.pack(">IHH2s6s", s[0], s[1], s[2], s[3], s[4])) | |
| with open("services_manifest.bin", "rb") as f: | |
| b = f.read() | |
| guid = read_uuid(b) | |
| if guid != SERVICE_MANIFEST_GUID: | |
| print("error") | |
| exit() | |
| length, num = struct.unpack_from("<II", b, 16) | |
| print("Manifest GUID:", guid) | |
| print("Length:", length) | |
| print("Services:", num) | |
| print("----") | |
| off = 16 + 4 + 4 | |
| for i in range(num): | |
| # service table entry | |
| sg = read_uuid(b[off : off + 16]) | |
| off += 16 | |
| if sg != SVSM_ATTEST_VTPM_GUID: | |
| print("error") | |
| exit() | |
| so, sl = struct.unpack_from("<II", b, off) | |
| off += 8 | |
| print(f"Service {i}:\n\tGUID: {sg}\n\tOffset: {so}\n\tLength: {sl}") | |
| print("----") | |
| data = b[off:] | |
| print("Certificate data(hex):", data.hex()) | |
| f = open("cert.tpmt_public", "wb") | |
| f.write(data) | |
| f.close() | |
| # https://www.amd.com/content/dam/amd/en/documents/epyc-technical-docs/specifications/58019.pdf p36 | |
| print( | |
| "Wrote cert.tpmt_public. Use `tpm2_print -t TPMT_PUBLIC cert.tpmt_public` to parse." | |
| ) |
Author
misodengaku
commented
Oct 10, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment