Skip to content

Commit 1d1b15f

Browse files
dasharo-security/tpm-support.robot: Add coverage for TPM 1.2
Add new keyword that allows conditional check of tpm commands. For TPM 1.2 tools, tpm_selftest prints out "TPM Test Results:", otherwise, it prints out error message (in case if no TPM or TPM 2.0) Signed-off-by: Sebastian Czapla <[email protected]>
1 parent 0b674a6 commit 1d1b15f

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

dasharo-security/tpm-support.robot

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ TPM001.001 TPM Support (firmware)
3535
Switch To Root User
3636
Get Cbmem From Cloud
3737
${out}= Execute Command In Terminal cbmem -L
38-
Should Contain ${out} TPM2 log
38+
Should Contain Any ${out} TPM2 log TCPA log
3939

4040
TPM001.002 TPM Support (Ubuntu)
4141
[Documentation] Check whether the TPM is initialized correctly and the
@@ -45,10 +45,7 @@ TPM001.002 TPM Support (Ubuntu)
4545
Boot System Or From Connected Disk ubuntu
4646
Login To Linux
4747
Switch To Root User
48-
Detect Or Install Package tpm2-tools
49-
${out}= Execute Command In Terminal tpm2_pcrread
50-
Should Contain ${out} sha1:
51-
Should Contain ${out} sha256:
48+
Validate Any TPM
5249

5350
TPM001.003 TPM Support (Windows)
5451
[Documentation] Check whether the TPM is initialized correctly and the
@@ -74,7 +71,7 @@ TPM002.001 Verify TPM version (firmware)
7471
Switch To Root User
7572
Get Cbmem From Cloud
7673
${out}= Execute Command In Terminal cbmem -L
77-
Should Contain ${out} TPM2 log
74+
Should Contain ${out} TPM2 log TCPA log
7875

7976
TPM002.002 Verify TPM version (Ubuntu)
8077
[Documentation] This test aims to verify that the TPM version is
@@ -86,8 +83,8 @@ TPM002.002 Verify TPM version (Ubuntu)
8683
Login To Linux
8784
Switch To Root User
8885
${out}= Execute Command In Terminal cat /sys/class/tpm/tpm0/tpm_version_major
89-
# TPM 2.0
90-
Should Contain ${out} 2
86+
# TPM 2.0 and 1.2
87+
Should Contain Any ${out} 1 2
9188

9289
TPM002.003 Verify TPM version (Windows)
9390
[Documentation] This test aims to verify that the TPM version is
@@ -121,7 +118,7 @@ TPM003.002 Check TPM Physical Presence Interface (Ubuntu)
121118
Login To Linux
122119
Switch To Root User
123120
${out}= Execute Command In Terminal cat /sys/class/tpm/tpm0/ppi/version
124-
Should Contain ${out} 1.3
121+
Should Contain Any ${out} 1.2 1.3
125122

126123
TPM003.003 Check TPM Physical Presence Interface (Windows)
127124
[Documentation] This test aims to verify that the TPM Physical Presence
@@ -138,3 +135,21 @@ TPM003.003 Check TPM Physical Presence Interface (Windows)
138135
# Skip If not ${tpm_support} TPM003.004 not supported
139136
# Skip If not ${tests_in_ubuntu_support} TPM003.004 not supported
140137
# TODO: https://docs.dasharo.com/unified-test-documentation/dasharo-security/200-tpm-support/#tpm003004-change-active-pcr-banks-with-tpm-ppi-firmware
138+
139+
140+
*** Keywords ***
141+
Validate Any TPM
142+
[Documentation] Checks for TPM major version, and validates it.
143+
${tpm_ver}= Execute Command In Terminal cat /sys/class/tpm/tpm0/tpm_version_major
144+
IF '${tpm_ver}' == '2'
145+
Detect Or Install Package tpm2-tools
146+
${out}= Execute Command In Terminal tpm2_pcrread
147+
Should Contain ${out} sha1:
148+
Should Contain ${out} sha256:
149+
ELSE IF '${tpm_ver}' == '1'
150+
Detect Or Install Package tpm-tools
151+
${out}= Execute Command In Terminal tpm_selftest
152+
Should Contain ${out} TPM Test Results:
153+
ELSE
154+
Fail No valid TPM version available.
155+
END

0 commit comments

Comments
 (0)