mirror of
https://github.com/stefanberger/libtpms
synced 2026-01-08 21:13:59 +00:00
tpm2: NVMarshal: To read an OBJECT from NVRAM use NvReadObject not NvRead
NvReadObject knows how to read an OBJECT from NVRAM, so use it instead
of the low-level NvRead(). This prepares the code for possibly larger
OBJECTs in NVRAM in the future that may have been marshalled before
they were written into NVRAM (such as RSA 4096 keys or possibly keys
from QC if they will be stored in OBJECTs).
The call to NvReadObject() requires that the ref in NvReadObject points
to the handle of an NV_ENTRY_HEADER. An NV_ENTRY_HEADER looks like this:
typedef struct {
UINT32 size;
TPM_HANDLE handle;
} NV_ENTRY_HEADER;
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
fd7e5d76a2
commit
a5dfd26d45
@ -4561,11 +4561,9 @@ USER_NVRAM_Display(const char *msg)
|
||||
break;
|
||||
case TPM_HT_PERSISTENT:
|
||||
fprintf(stderr, " (PERSISTENT)");
|
||||
offset += sizeof(handle);
|
||||
|
||||
NvRead(&obj, entryRef + offset, sizeof(obj));
|
||||
offset += sizeof(obj);
|
||||
fprintf(stderr, " sizeof(obj): %zu\n", sizeof(obj));
|
||||
NvReadObject(entryRef + offset, &obj);
|
||||
fprintf(stderr, " sizeof(obj): %zu entrysize: %u\n", sizeof(obj), entrysize);
|
||||
break;
|
||||
default:
|
||||
TPMLIB_LogTPM2Error("USER_NVRAM: Corrupted handle: %08x\n", handle);
|
||||
@ -4637,10 +4635,7 @@ USER_NVRAM_Marshal(BYTE **buffer, INT32 *size)
|
||||
}
|
||||
break;
|
||||
case TPM_HT_PERSISTENT:
|
||||
offset += sizeof(handle);
|
||||
|
||||
NvRead(&obj, entryRef + offset, sizeof(obj));
|
||||
offset += sizeof(obj);
|
||||
NvReadObject(entryRef + offset, &obj);
|
||||
written += ANY_OBJECT_Marshal(&obj, buffer, size);
|
||||
break;
|
||||
default:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user