From ec2d7dfc2cb24b6b4cc34f68d91440b60b60c255 Mon Sep 17 00:00:00 2001 From: Kyle Rankin Date: Wed, 9 May 2018 14:25:43 -0700 Subject: [PATCH 1/2] Make TPM counter label a variable Currently the TPM counter label is hard-coded. By changing it to a variable in this function we can reuse all of the TPM counter functions to create other monotonic counters in the TPM (if the hardware supports it) with custom labels. --- initrd/etc/functions | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/initrd/etc/functions b/initrd/etc/functions index b2cfa4ef..4790e74b 100755 --- a/initrd/etc/functions +++ b/initrd/etc/functions @@ -143,13 +143,19 @@ check_tpm_counter() if [ -r "$1" ]; then TPM_COUNTER=`grep counter- "$1" | cut -d- -f2` else + # Initialize label to default if not set + if [ "$2" != "" ]; then + LABEL=$2 + else + LABEL=3135106223 + fi warn "$BOOT_HASHES does not exist; creating new TPM counter" read -s -p "TPM Owner password: " tpm_password echo tpm counter_create \ -pwdo "$tpm_password" \ -pwdc '' \ - -la 3135106223 \ + -la $LABEL \ | tee /tmp/counter \ || die "Unable to create TPM counter" TPM_COUNTER=`cut -d: -f1 < /tmp/counter` From fc72daa6e391b4aa21253075d8e80860c30e3f3e Mon Sep 17 00:00:00 2001 From: Kyle Rankin Date: Wed, 9 May 2018 14:28:36 -0700 Subject: [PATCH 2/2] Fix tabbing --- initrd/etc/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/initrd/etc/functions b/initrd/etc/functions index 4790e74b..17a81c27 100755 --- a/initrd/etc/functions +++ b/initrd/etc/functions @@ -145,7 +145,7 @@ check_tpm_counter() else # Initialize label to default if not set if [ "$2" != "" ]; then - LABEL=$2 + LABEL=$2 else LABEL=3135106223 fi