Skip to content

Commit 96d55c8

Browse files
dgarskedanielinux
authored andcommitted
Fix for unseal not properly using auth.
1 parent 0666ffe commit 96d55c8

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

include/tpm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ int wolfBoot_seal(const uint8_t* pubkey_hint, const uint8_t* policy, uint16_t po
7575
int wolfBoot_seal_auth(const uint8_t* pubkey_hint, const uint8_t* policy, uint16_t policySz,
7676
int index, const uint8_t* secret, int secret_sz, const uint8_t* auth, int authSz);
7777
int wolfBoot_seal_blob(const uint8_t* pubkey_hint, const uint8_t* policy, uint16_t policySz,
78-
WOLFTPM2_KEYBLOB* seal_blob, const uint8_t* secret, int secret_sz);
78+
WOLFTPM2_KEYBLOB* seal_blob, const uint8_t* secret, int secret_sz, const uint8_t* auth, int authSz);
7979
int wolfBoot_unseal(const uint8_t* pubkey_hint, const uint8_t* policy, uint16_t policySz,
8080
int index, uint8_t* secret, int* secret_sz);
8181
int wolfBoot_unseal_auth(const uint8_t* pubkey_hint, const uint8_t* policy, uint16_t policySz,
8282
int index, uint8_t* secret, int* secret_sz, const uint8_t* auth, int authSz);
8383
int wolfBoot_unseal_blob(const uint8_t* pubkey_hint, const uint8_t* policy, uint16_t policySz,
84-
WOLFTPM2_KEYBLOB* seal_blob, uint8_t* secret, int* secret_sz);
84+
WOLFTPM2_KEYBLOB* seal_blob, uint8_t* secret, int* secret_sz, const uint8_t* auth, int authSz);
8585

8686
int wolfBoot_read_blob(uint32_t nvIndex, WOLFTPM2_KEYBLOB* blob,
8787
const uint8_t* auth, uint32_t authSz);

src/tpm.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,8 @@ int wolfBoot_delete_blob(TPMI_RH_NV_AUTH authHandle, uint32_t nvIndex,
741741
/* The secret is sealed based on a policy authorization from a public key. */
742742
int wolfBoot_seal_blob(const uint8_t* pubkey_hint,
743743
const uint8_t* policy, uint16_t policySz,
744-
WOLFTPM2_KEYBLOB* seal_blob, const uint8_t* secret, int secret_sz)
744+
WOLFTPM2_KEYBLOB* seal_blob, const uint8_t* secret, int secret_sz,
745+
const uint8_t* auth, int authSz)
745746
{
746747
int rc;
747748
WOLFTPM2_SESSION policy_session;
@@ -802,8 +803,7 @@ int wolfBoot_seal_blob(const uint8_t* pubkey_hint,
802803
/* Create a new key for sealing using external signing auth */
803804
wolfTPM2_GetKeyTemplate_KeySeal(&template, pcrAlg);
804805
rc = wolfTPM2_CreateKeySeal_ex(&wolftpm_dev, seal_blob,
805-
&wolftpm_srk.handle, &template,
806-
seal_blob->handle.auth.buffer, seal_blob->handle.auth.size,
806+
&wolftpm_srk.handle, &template, auth, authSz,
807807
pcrAlg, NULL, 0, secret, secret_sz);
808808
}
809809

@@ -831,7 +831,7 @@ int wolfBoot_seal_auth(const uint8_t* pubkey_hint,
831831

832832
/* creates a sealed keyed hash object (not loaded to TPM) */
833833
rc = wolfBoot_seal_blob(pubkey_hint, policy, policySz, &seal_blob,
834-
secret, secret_sz);
834+
secret, secret_sz, auth, authSz);
835835
if (rc == 0) {
836836
#ifdef WOLFBOOT_DEBUG_TPM
837837
wolfBoot_printf("Sealed keyed hash (pub %d, priv %d bytes):\n",
@@ -878,7 +878,8 @@ int wolfBoot_seal(const uint8_t* pubkey_hint,
878878
/* The unseal requires a signed policy from HDR_POLICY_SIGNATURE */
879879
int wolfBoot_unseal_blob(const uint8_t* pubkey_hint,
880880
const uint8_t* policy, uint16_t policySz,
881-
WOLFTPM2_KEYBLOB* seal_blob, uint8_t* secret, int* secret_sz)
881+
WOLFTPM2_KEYBLOB* seal_blob, uint8_t* secret, int* secret_sz,
882+
const uint8_t* auth, int authSz)
882883
{
883884
int rc, i;
884885
WOLFTPM2_SESSION policy_session;
@@ -1004,6 +1005,8 @@ int wolfBoot_unseal_blob(const uint8_t* pubkey_hint,
10041005
wolfBoot_printf("Loaded seal blob to 0x%x\n",
10051006
(uint32_t)seal_blob->handle.hndl);
10061007
#endif
1008+
seal_blob->handle.auth.size = authSz;
1009+
memcpy(seal_blob->handle.auth.buffer, auth, authSz);
10071010
wolfTPM2_SetAuthHandle(&wolftpm_dev, 0, &seal_blob->handle);
10081011

10091012
/* unseal */
@@ -1038,10 +1041,8 @@ int wolfBoot_unseal_auth(const uint8_t* pubkey_hint,
10381041
rc = wolfBoot_read_blob(WOLFBOOT_TPM_SEAL_NV_BASE + index, &seal_blob,
10391042
NULL, 0);
10401043
if (rc == 0) {
1041-
seal_blob.handle.auth.size = authSz;
1042-
memcpy(seal_blob.handle.auth.buffer, auth, authSz);
10431044
rc = wolfBoot_unseal_blob(pubkey_hint, policy, policySz, &seal_blob,
1044-
secret, secret_sz);
1045+
secret, secret_sz, auth, authSz);
10451046
#ifdef WOLFBOOT_DEBUG_TPM
10461047
if (rc == 0) {
10471048
wolfBoot_printf("Unsealed keyed hash (pub %d, priv %d bytes):\n",

0 commit comments

Comments
 (0)