Skip to content

Commit 314e96b

Browse files
authored
Merge pull request #152 from tomoveu/no-ek-attest
Minor change for attestation examples, EK is not needed
2 parents fd79729 + 4f6e35f commit 314e96b

2 files changed

Lines changed: 5 additions & 36 deletions

File tree

examples/pcr/quote.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static void usage(void)
4444
printf("./examples/pcr/quote [pcr] [filename] [-ecc] [-aes/xor]\n");
4545
printf("* pcr: PCR index between 0-23 (default %d)\n", TPM2_TEST_PCR);
4646
printf("* filename: for saving the TPMS_ATTEST structure to a file\n");
47-
printf("* -ecc: Use RSA or ECC for EK/AIK\n");
47+
printf("* -ecc: Use RSA or ECC for SRK/AIK\n");
4848
printf("* -aes/xor: Use Parameter Encryption\n");
4949
printf("Demo usage without parameters, generates quote over PCR%d and\n"
5050
"saves the output TPMS_ATTEST structure to \"quote.blob\" file.\n",
@@ -60,7 +60,6 @@ int TPM2_Quote_Test(void* userCtx, int argc, char *argv[])
6060
WOLFTPM2_DEV dev;
6161
TPMS_ATTEST attestedData;
6262
TPMI_ALG_PUBLIC alg = TPM_ALG_RSA; /* TPM_ALG_ECC */
63-
WOLFTPM2_KEY endorse; /* EK */
6463
WOLFTPM2_KEY storage; /* SRK */
6564
WOLFTPM2_KEY aik; /* AIK */
6665
union {
@@ -77,7 +76,6 @@ int TPM2_Quote_Test(void* userCtx, int argc, char *argv[])
7776
XFILE f;
7877
#endif
7978

80-
XMEMSET(&endorse, 0, sizeof(endorse));
8179
XMEMSET(&storage, 0, sizeof(storage));
8280
XMEMSET(&aik, 0, sizeof(aik));
8381
XMEMSET(&tpmSession, 0, sizeof(tpmSession));
@@ -128,16 +126,6 @@ int TPM2_Quote_Test(void* userCtx, int argc, char *argv[])
128126
}
129127
printf("wolfTPM2_Init: success\n");
130128

131-
/* Create Endorsement Key, also called EK */
132-
rc = wolfTPM2_CreateEK(&dev, &endorse, alg);
133-
if (rc != TPM_RC_SUCCESS) {
134-
printf("wolfTPM2_CreateEK: Endorsement failed 0x%x: %s\n",
135-
rc, TPM2_GetRCString(rc));
136-
goto exit;
137-
}
138-
printf("wolfTPM2_CreateEK: Endorsement 0x%x (%d bytes)\n",
139-
(word32)endorse.handle.hndl, endorse.pub.size);
140-
141129
/* get SRK */
142130
rc = getPrimaryStoragekey(&dev, &storage, alg);
143131
if (rc != 0) goto exit;
@@ -234,7 +222,6 @@ int TPM2_Quote_Test(void* userCtx, int argc, char *argv[])
234222
/* Close key handles */
235223
wolfTPM2_UnloadHandle(&dev, &aik.handle);
236224
wolfTPM2_UnloadHandle(&dev, &storage.handle);
237-
wolfTPM2_UnloadHandle(&dev, &endorse.handle);
238225
wolfTPM2_UnloadHandle(&dev, &tpmSession.handle);
239226

240227
wolfTPM2_Cleanup(&dev);

examples/timestamp/signed_timestamp.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static void usage(void)
4343
{
4444
printf("Expected usage:\n");
4545
printf("./examples/timestamp/signed_timestamp [-ecc] [-aes/xor]\n");
46-
printf("* -ecc: Use RSA or ECC for EK/AIK\n");
46+
printf("* -ecc: Use RSA or ECC for SRK/AIK\n");
4747
printf("* -aes/xor: Use Parameter Encryption\n");
4848
}
4949

@@ -66,15 +66,13 @@ int TPM2_Timestamp_TestArgs(void* userCtx, int argc, char *argv[])
6666
PolicySecret_Out policySecret;
6767
byte maxOutput[MAX_RESPONSE_SIZE];
6868
} cmdOut;
69-
WOLFTPM2_KEY endorse; /* EK */
7069
WOLFTPM2_KEY storage; /* SRK */
7170
WOLFTPM2_KEY aik; /* AIK */
7271
TPMI_ALG_PUBLIC alg = TPM_ALG_RSA; /* TPM_ALG_ECC */
7372
TPM_ALG_ID paramEncAlg = TPM_ALG_NULL;
7473
WOLFTPM2_SESSION tpmSession;
7574
TPMA_SESSION sessionAttributes;
7675

77-
XMEMSET(&endorse, 0, sizeof(endorse));
7876
XMEMSET(&storage, 0, sizeof(storage));
7977
XMEMSET(&aik, 0, sizeof(aik));
8078
XMEMSET(&tpmSession, 0, sizeof(tpmSession));
@@ -123,17 +121,6 @@ int TPM2_Timestamp_TestArgs(void* userCtx, int argc, char *argv[])
123121
printf("TPM2_ReadClock: success\n");
124122

125123

126-
/* Create Endorsement Key, also called EK */
127-
rc = wolfTPM2_CreateEK(&dev, &endorse, alg);
128-
if (rc != TPM_RC_SUCCESS) {
129-
printf("wolfTPM2_CreateEK: Endorsement failed 0x%x: %s\n",
130-
rc, TPM2_GetRCString(rc));
131-
goto exit;
132-
}
133-
printf("wolfTPM2_CreateEK: Endorsement 0x%x (%d bytes)\n",
134-
(word32)endorse.handle.hndl, endorse.pub.size);
135-
136-
137124
/* Create Storage Key, also called SRK */
138125
rc = getPrimaryStoragekey(&dev, &storage, alg);
139126
if (rc != TPM_RC_SUCCESS) {
@@ -151,10 +138,6 @@ int TPM2_Timestamp_TestArgs(void* userCtx, int argc, char *argv[])
151138
printf("TPM2_StartAuthSession: sessionHandle 0x%x\n",
152139
(word32)tpmSession.handle.hndl);
153140

154-
/* Set the endorsement password (blank) */
155-
rc = wolfTPM2_SetAuthPassword(&dev, 0, NULL);
156-
if (rc != 0) goto exit;
157-
158141
/* Set PolicySecret for our session to enable use of the Endorsement Hierarchy */
159142
XMEMSET(&cmdIn.policySecret, 0, sizeof(cmdIn.policySecret));
160143
cmdIn.policySecret.authHandle = TPM_RH_ENDORSEMENT;
@@ -166,7 +149,7 @@ int TPM2_Timestamp_TestArgs(void* userCtx, int argc, char *argv[])
166149
}
167150
printf("TPM2_policySecret success\n"); /* No use of the output */
168151

169-
/* At this stage, the EK is created and NULL password has already been set
152+
/* At this stage, the SRK is created and NULL password has already been set
170153
* The EH is enabled through policySecret over the active TPM session and
171154
* the creation of Attestation Identity Key (AIK) under the EH can take place.
172155
*/
@@ -183,7 +166,7 @@ int TPM2_Timestamp_TestArgs(void* userCtx, int argc, char *argv[])
183166
(word32)aik.handle.hndl, aik.pub.size);
184167

185168

186-
/* set NULL password auth for using EK */
169+
/* set (the default) NULL password auth for using EH */
187170
wolfTPM2_SetAuthPassword(&dev, 0, NULL);
188171

189172
/* set auth for using the AIK */
@@ -202,7 +185,7 @@ int TPM2_Timestamp_TestArgs(void* userCtx, int argc, char *argv[])
202185
(void)sessionAttributes;
203186
#endif
204187

205-
/* At this stage: The EK is created, AIK is created and loaded,
188+
/* At this stage: The SRK is created, AIK is created and loaded,
206189
* Endorsement Hierarchy is enabled through policySecret,
207190
* the use of the loaded AIK is enabled through its usageAuth.
208191
* Invoking attestation of the TPM time structure can take place.
@@ -255,7 +238,6 @@ int TPM2_Timestamp_TestArgs(void* userCtx, int argc, char *argv[])
255238
}
256239

257240
wolfTPM2_UnloadHandle(&dev, &aik.handle);
258-
wolfTPM2_UnloadHandle(&dev, &endorse.handle);
259241
wolfTPM2_UnloadHandle(&dev, &tpmSession.handle);
260242

261243
wolfTPM2_Cleanup(&dev);

0 commit comments

Comments
 (0)