in cvm-attestation/read_report.py [0:0]
def handle_hardware_report(report_type, output_path, attestation_client):
"""
Handle the hardware report generation and optional saving.
"""
logger = attestation_client.log
logger.info(f"Reading hardware report: {report_type}")
evidence = attestation_client.get_hardware_evidence()
if report_type == 'snp_report':
# Retrieve and deserialize the SNP report
report = AttestationReport.deserialize(evidence.hardware_report)
# Display the report
report.display()
filename = 'report.bin'
# Optionally save the report to a file
if output_path:
filename = output_path
with open(filename, 'wb') as file:
file.write(evidence.hardware_report)
logger.info(f"Report saved to: {filename}")
logger.info("Got attestation report successfully!")
elif report_type == 'td_quote':
try:
deserialized_td_quote = deserialize_td_quotev4(evidence.hardware_report)
print_td_quotev4(deserialized_td_quote)
except UnicodeDecodeError:
logger.error("Failed to decode the TD quote header. Ensure the report is valid.")
return
else:
raise ValueError(f"Invalid hardware report type: {report_type}")