Leonardo Sandoval | 6eff3f7 | 2021-05-03 11:12:37 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright (c) 2021, Arm Limited. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | # Expect script for Linux/Buildroot using Measured Boot & fTPM |
| 7 | # |
| 8 | |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 9 | non_zero_pcr='(?!(\s00){16})((\s([0-9a-f]){2}){16}\s)' |
| 10 | |
| 11 | # Parse the event log from the debug logs and store the digests |
| 12 | # so they can be matched later with what the fTPM read. |
| 13 | |
| 14 | expect_string+=('m;Booting Trusted Firmware;Booting BL31;Digest(\s|\w)*:\s(\w{2}\s){16}@: (\w{2}\s){16}@Event(\s|\w)*:\s\w+\s') |
| 15 | |
| 16 | # Wait for the login prompt |
Leonardo Sandoval | 34f5183 | 2021-11-04 16:42:04 -0600 | [diff] [blame] | 17 | expect_string+=("i;buildroot login:") |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 18 | |
Leonardo Sandoval | 34f5183 | 2021-11-04 16:42:04 -0600 | [diff] [blame] | 19 | # Login then load the fTPM driver and retrieves PCR0 |
Manish V Badarkhe | fc146c4 | 2021-11-24 15:34:00 +0000 | [diff] [blame] | 20 | # Pass condition: PCR0 and PCR1 must not be all zeros. |
Leonardo Sandoval | 34f5183 | 2021-11-04 16:42:04 -0600 | [diff] [blame] | 21 | expect_string+=("i;#;;;root") |
| 22 | expect_string+=("i;${non_zero_pcr};;;ftpm") |
Manish V Badarkhe | fc146c4 | 2021-11-24 15:34:00 +0000 | [diff] [blame] | 23 | expect_string+=("i;#") |
| 24 | expect_string+=("i;${non_zero_pcr};;;pcrread -ha 1") |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 25 | |
| 26 | # Iterate over the rest of PCRs and check that they all are zeros. |
| 27 | zero_pcr="(\s00){16}\s+(00\s){16}" |
Manish V Badarkhe | fc146c4 | 2021-11-24 15:34:00 +0000 | [diff] [blame] | 28 | for i in $(seq 2 11); do |
Leonardo Sandoval | 34f5183 | 2021-11-04 16:42:04 -0600 | [diff] [blame] | 29 | expect_string+=("i;#") |
| 30 | expect_string+=("i;${zero_pcr};;;pcrread -ha $i") |
Leonardo Sandoval | 5cfc11f | 2021-09-08 16:08:13 -0500 | [diff] [blame] | 31 | done |
Chris Kay | 07756bc | 2022-11-24 17:21:48 +0000 | [diff] [blame] | 32 | |
| 33 | expect_string+=("i;#;;;@") # Flush newline after final prompt |