in cvm-attestation/tpm_wrapper.py [0:0]
def read_nv_index(self, index):
tpm = Tpm()
tpm.connect()
handle = TPM_HANDLE(int(index, 16))
response = tpm.NV_ReadPublic(handle)
auth = TPM_HANDLE(TPM_RH.OWNER)
total_bytes_to_read = response.nvPublic.dataSize
bytes_read = 0
buffer_size = 1024
# store the hcl report
hcl_report = b''
while bytes_read < total_bytes_to_read:
# Calculate how many bytes to read in this iteration
bytes_to_read = min(buffer_size, total_bytes_to_read - bytes_read)
# Read the data into the buffer
data = tpm.NV_Read(auth, handle , bytes_to_read, bytes_read)
hcl_report = hcl_report + data
# Update the total bytes read
bytes_read += bytes_to_read
tpm.close()
return hcl_report