mirror of
https://github.com/stefanberger/swtpm.git
synced 2026-08-08 23:13:19 +00:00
Merge 93bd98c7e8 into a1d85c9ee7
This commit is contained in:
commit
9551c3287c
@ -175,6 +175,9 @@ static int ctrlchannel_return_state(ptm_getstate *pgs, int fd,
|
||||
if (!blobname)
|
||||
res = TPM_FAIL;
|
||||
|
||||
if (res == 0 && blobtype == PTM_BLOB_TYPE_PERMANENT)
|
||||
res = SWTPM_NVRAM_Store_Permanent();
|
||||
|
||||
if (res == 0 && blobtype == PTM_BLOB_TYPE_VOLATILE)
|
||||
res = SWTPM_NVRAM_Store_Volatile();
|
||||
|
||||
|
||||
@ -481,6 +481,37 @@ TPM_RESULT SWTPM_NVRAM_Store_Volatile(void)
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Flush libtpms's in-memory PERMANENT state to disk so that the next
|
||||
* SWTPM_NVRAM_GetStateBlob(PERMANENT) returns a blob consistent with what
|
||||
* libtpms is actually running. Counterpart to SWTPM_NVRAM_Store_Volatile().
|
||||
*
|
||||
* Without this, GET_STATEBLOB(PERMANENT) on the migration-out path reads a
|
||||
* file that may be missing, empty, or stale relative to libtpms RAM (the
|
||||
* file is only written by _plat__NvCommit() on UT_NV-class commands), and
|
||||
* an empty/short-read blob then poisons the destination's state restore.
|
||||
*/
|
||||
TPM_RESULT SWTPM_NVRAM_Store_Permanent(void)
|
||||
{
|
||||
TPM_RESULT rc = 0;
|
||||
char *name = TPM_PERMANENT_ALL_NAME;
|
||||
uint32_t tpm_number = 0;
|
||||
unsigned char *buffer = NULL;
|
||||
uint32_t buflen = 0;
|
||||
|
||||
TPM_DEBUG(" SWTPM_Store_Permanent: Name %s\n", name);
|
||||
if (rc == 0) {
|
||||
rc = TPMLIB_GetState(TPMLIB_STATE_PERMANENT, &buffer, &buflen);
|
||||
}
|
||||
if (rc == 0 && buflen > 0) {
|
||||
rc = SWTPM_NVRAM_StoreData(buffer, buflen, tpm_number, name);
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static TPM_RESULT
|
||||
SWTPM_NVRAM_KeyParamCheck(uint32_t keylen,
|
||||
enum encryption_mode encmode)
|
||||
|
||||
@ -69,6 +69,7 @@ TPM_RESULT SWTPM_NVRAM_DeleteName(uint32_t tpm_number,
|
||||
const char *name,
|
||||
TPM_BOOL mustExist);
|
||||
TPM_RESULT SWTPM_NVRAM_Store_Volatile(void);
|
||||
TPM_RESULT SWTPM_NVRAM_Store_Permanent(void);
|
||||
|
||||
TPM_RESULT SWTPM_NVRAM_Set_FileKey(const unsigned char *data,
|
||||
uint32_t length,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user