Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions sdk/python/teaclave.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,21 @@ def load_certificates(pem_bytes):
quote = report['isvEnclaveQuoteBody']
quote = base64.b64decode(quote)

# get report_data from the quote
report_data = quote[368:368 + 64]
# get EC pub key from the certificate
pub_key = cert.public_key().public_bytes(
cryptography.hazmat.primitives.serialization.Encoding.X962,
cryptography.hazmat.primitives.serialization.PublicFormat.
UncompressedPoint)

# verify whether the certificate is bound to the quote
assert (pub_key[0] == 4)
if pub_key[1:] != report_data:
raise TeaclaveException(
"Failed to verify the certificate agaist the report data in the quote"
)

# get mr_enclave and mr_signer from the quote
mr_enclave = quote[112:112 + 32].hex()
mr_signer = quote[176:176 + 32].hex()
Expand Down