-
I have a TPM NV handle value, e.g. 0x01500047, and I'm pretty sure that it is already created inside TPM. However, I don't know how to call this nv_read_public() below by passing this handle value (0x01500047) as parameter, to get this nv's public information. because this function requires a handle NvIndexHandle value, which is not the u32 value of 0x01500047. I understand that, please correct me if I am wrong, we can use this code below to convert this u32 value to NvIndexTpmHandle value: But now, the question is how to convert the value (nvtpmhandle) type of NvIndexTpmHandle to the type of NvIndexHandle, which is required to be passed into function nv_read_public()? Actually, there are too many handles, which is quite confusing to me. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
So if you want to skip to do the steps that are required when dealing with NV memory in the TPM, I suggest you look at abstractions feature where you have several functions which can help you dealing with NV memory. About the handles yes. There are a lot of handles. Because the specification specifies a lot of handles and they can be a bit confusing. They are there in order to some extent mimic the specification. ESAPI: TPM: So how would one go about looking up a TPM handle then and start interacting with the NV memory? Something like this.
let nv_tpm_index_handle = NvIndexTpmHandle::new(0x01500047).expect("Failed to create nv index tom handle.");
let new_nv_index_handle = context
.tr_from_tpm_public(nv_tpm_index_handle .into())
.map(NvIndexHandle::from)
.expect("Failed to retrieve nv index handle"); Now you have the handle needed in order to call the nv context methods. I hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Thank you so much. But with this code, i got an issue:
the error code is 0x00000982, which is decoded as below. I've no idea what is "inconsistent attributes" here.
Here is my code snippet.
I'm pretty sure my index 0x01500047 was created, because when I recreate it with nv_define_space(), I got an error code 0x0000014c (NV index or persisted object already defined). |
Beta Was this translation helpful? Give feedback.
-
maybe i knew the answer now. (please correct me?) the function tr_from_tpm_public() depends on TPM2_NV_ReadPublic(). unlike TPM2_NV_Read(), TPM2_NV_ReadPublic() doesn't need session for calling, but in my original code, I set session before calling it. More actually, I just checked this TPM2 spec, and found that NV_ReadPublic is the only function (among all the NV related functions) that may not need "session" to call. |
Beta Was this translation helpful? Give feedback.
looks like if I remove the "session" code below from fn nv_test()
then run the nv_test() again, it works as @Superhepper suggested.
Quite interesting. anyone can help explain this? Thank you.