Manish V Badarkhe | b87f37b | 2021-11-10 18:53:05 +0000 | [diff] [blame] | 1 | # |
Sandrine Bailleux | 0bcf413 | 2022-03-31 11:15:51 +0200 | [diff] [blame] | 2 | # Copyright (c) 2021-2022, Arm Limited. All rights reserved. |
Manish V Badarkhe | b87f37b | 2021-11-10 18:53:05 +0000 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | # Expect script for Linux/Buildroot using Measured Boot & fTPM |
| 7 | # It is a copy of linux-tpm.exp which doesn't check PCR0 value, |
| 8 | # as that doesn't apply to this config |
| 9 | # |
| 10 | |
| 11 | source [file join [file dirname [info script]] utils.inc] |
| 12 | source [file join [file dirname [info script]] handle-arguments.inc] |
| 13 | |
| 14 | # File to store the event log from the ftpm service. |
| 15 | set TFA_DIGEST [get_param tfa_digest "tfa_event_log"] |
Harrison Mutai | 47751e0 | 2025-02-28 12:08:09 +0000 | [diff] [blame] | 16 | set FTPM_DIGEST [get_param ftpm_digest "ftpm_event_log"] |
Manish V Badarkhe | b87f37b | 2021-11-10 18:53:05 +0000 | [diff] [blame] | 17 | |
| 18 | # regexp for non-zero PCR0 |
| 19 | set non_zero_pcr "(?!(\\s00){16})((\\s(\[0-9a-f\]){2}){16}\\s)" |
| 20 | |
Harrison Mutai | 47751e0 | 2025-02-28 12:08:09 +0000 | [diff] [blame] | 21 | capture_log $TFA_DIGEST "Booting BL31" |
Manish V Badarkhe | b87f37b | 2021-11-10 18:53:05 +0000 | [diff] [blame] | 22 | |
| 23 | expect { |
| 24 | "login" { |
| 25 | send "root\n" |
| 26 | } |
Manish V Badarkhe | b87f37b | 2021-11-10 18:53:05 +0000 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | expect { |
| 30 | "#" { |
| 31 | # Load the fTPM driver |
| 32 | send "ftpm\n" |
| 33 | } |
Manish V Badarkhe | b87f37b | 2021-11-10 18:53:05 +0000 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | expect { |
| 37 | "#" { } |
Manish V Badarkhe | b87f37b | 2021-11-10 18:53:05 +0000 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | # Iterate over the rest of PCRs and check that they all are zeros. |
| 41 | for {set i 1} {$i < 11} {incr i} { |
| 42 | send "pcrread -ha $i\n" |
| 43 | |
| 44 | expect { |
| 45 | -re "(\\s00){16}\\s+(00\\s){16}" { } |
| 46 | |
| 47 | -re $non_zero_pcr { |
| 48 | exit_uart -1 |
| 49 | } |
Manish V Badarkhe | b87f37b | 2021-11-10 18:53:05 +0000 | [diff] [blame] | 50 | } |
| 51 | } |
| 52 | |
Chris Kay | 07756bc | 2022-11-24 17:21:48 +0000 | [diff] [blame] | 53 | expect_string "#" "finished reading PCRs" |
| 54 | |
Harrison Mutai | 47751e0 | 2025-02-28 12:08:09 +0000 | [diff] [blame] | 55 | compare_log $TFA_DIGEST $FTPM_DIGEST |