-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI-Examples] python: Add
sgx-quote.py
script
This script shows how to generate an SGX quote in Python. Signed-off-by: Dmitrii Kuvaiskii <[email protected]>
- Loading branch information
Dmitrii Kuvaiskii
committed
May 10, 2022
1 parent
af9cbc7
commit 2598446
Showing
6 changed files
with
48 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
|
||
def tohex(b): | ||
return ''.join(format(x, '02x') for x in b) | ||
|
||
if not os.path.exists("/dev/attestation/user_report_data"): | ||
print("Cannot find `/dev/attestation/user_report_data`; " | ||
"are you running under SGX?") | ||
sys.exit(1) | ||
|
||
with open("/dev/attestation/user_report_data", "wb") as f: | ||
f.write(b'\0'*64) | ||
|
||
with open("/dev/attestation/quote", "rb") as f: | ||
quote = f.read() | ||
|
||
print(f"Extracted SGX quote with size = {len(quote)} and the following fields:") | ||
print(f" ATTRIBUTES.FLAGS: {quote[96:104].hex()} [ Debug bit: {quote[96] & 2 > 0} ]") | ||
print(f" ATTRIBUTES.XFRM: {quote[104:112].hex()}") | ||
print(f" MRENCLAVE: {quote[112:144].hex()}") | ||
print(f" MRSIGNER: {quote[176:208].hex()}") | ||
print(f" ISVPRODID: {quote[304:306].hex()}") | ||
print(f" ISVSVN: {quote[306:308].hex()}") | ||
print(f" REPORTDATA: {quote[368:400].hex()}") | ||
print(f" {quote[400:432].hex()}") |