Skip to content

Commit af37037

Browse files
shjalaOhmSpectator
authored andcommitted
tpm-tests: add refrence to key creation source of truth
We create the keys in test script based on the tpmmgr code. Add a comment and reminder, in case something changed. Signed-off-by: Shahriyar Jalayeri <[email protected]>
1 parent 0eb3a69 commit af37037

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

pkg/pillar/cmd/tpmmgr/tpmmgr.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,9 @@ func writeDeviceCertToFile(certBytes, keyBytes []byte) error {
714714
return os.WriteFile(types.DeviceCertName, certBytes, 0644)
715715
}
716716

717+
// These keys template and hierarchy are used in the tests/tpm/prep-and-test.sh
718+
// to create same keys and run tpm required unit-tests, in a unlikely event of
719+
// changing these values dont forget to update the test script.
717720
func createOtherKeys(override bool) error {
718721
if err := etpm.CreateKey(log, etpm.TpmDevicePath, etpm.TpmEKHdl, tpm2.HandleEndorsement, etpm.DefaultEkTemplate, override); err != nil {
719722
return fmt.Errorf("error in creating Endorsement key: %w ", err)

tests/tpm/prep-and-test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ export TPM2TOOLS_TCTI="swtpm:host=localhost,port=$TPM_SRV_PORT"
6969
# start fresh
7070
tpm2 clear
7171

72+
# The ek, srk and aik are created here based on what we do in createOtherKeys
73+
# in pkg/pillar/cmd/tpmmgr/tpmmgr.go.
7274
# create Endorsement Key
7375
tpm2 createek -c ek.ctx
7476

0 commit comments

Comments
 (0)