-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added example for NV counter increment and Fixes for NV auth handling #243
Conversation
This link just takes me to the TPM.dev homepage. |
You'd probably need to register. This was in response to some issues with NV increment: Hi everyone. I am struggling with hybrid NV counters.
yielding a total value of We are supplying a constant password for that NV index. We are then able to increment the counter and read it using the constant password until the next TPM reset.
The wolftpm library we are using sets TPM2B_AUTH auth field of the TPM2_NV_DefineSpace command to set the password for the NV index. Thanks for engaging with our problem. We are using the wrapper WOLFTPM2_HANDLE handle;
memset(&handle, 0, sizeof(handle));
handle.hndl = TPM2_NV_INDEX_TRUST_ANCHOR_HASH_COUNTER;
memcpy(handle.auth.buffer, "test", 4);
handle.auth.size = 4;
// TODO this check probably is not necessary:
if (_dev.ctx.session) {
wolfTPM2_SetAuthHandle(&_dev, 0, &handle);
}
TPMS_NV_PUBLIC nv_public;
int result = wolfTPM2_NVReadPublic(&_dev, handle.hndl, &nv_public);
_assert_tpm_result("TPM NV read public:", result);
result = TPM2_HashNvPublic(&nv_public, (byte*)&handle.name.name, &handle.name.size);
_assert_tpm_result("TPM hash NV public:", result);
result = wolfTPM2_SetAuthHandleName(&_dev, 0, &handle);
_assert_tpm_result("TPM set auth handle name:", result);
result = wolfTPM2_SetAuthHandleName(&_dev, 1, &handle);
_assert_tpm_result("TPM set auth handle name:", result);
NV_Increment_In in;
memset(&in, 0, sizeof(in));
in.authHandle = handle.hndl;
in.nvIndex = TPM2_NV_INDEX_TRUST_ANCHOR_HASH_COUNTER;
result = TPM2_NV_Increment(&in);
_assert_tpm_result("TPM increment counter:", result); // This fails |
…s, unknown args and coding standards.
Re: https://developers.tpm.dev/chats/1689646