@@ -1848,7 +1848,8 @@ check_tpm_counter() {
18481848 TRACE_FUNC
18491849
18501850 LABEL=${2:- 3135106223}
1851- tpm_passphrase=" $3 "
1851+ # $3 (tpm_passphrase) was used by pre-PR #2068 code but is now intentionally
1852+ # ignored — counters are created with empty auth (-pwdc '') per TCG spec.
18521853 # if the /boot.hashes file already exists, read the TPM counter ID
18531854 # from it.
18541855 if [ -r " $1 " ]; then
@@ -1857,12 +1858,8 @@ check_tpm_counter() {
18571858 DEBUG " Extracted TPM_COUNTER: '$TPM_COUNTER ' from $1 "
18581859 else
18591860 DEBUG " $1 does not exist - creating new TPM counter"
1860- # Warn user: TPM Owner Passphrase is required to create a new TPM counter
1861- if [ ! -s /tmp/secret/tpm_owner_passphrase ]; then
1862- WARN " TPM Owner Passphrase is required to create a new TPM counter for /boot content rollback prevention"
1863- fi
1864-
1865- # attempt to make a new counter, capturing any stderr for debugging
1861+ # Create TPM counter with empty counter auth per TCG spec (no secret).
1862+ # Owner passphrase is not needed for the counter auth itself.
18661863 DEBUG " Invoking tpmr.sh counter_create with label $LABEL "
18671864 # run it, then record the exit status explicitly; the '!' operator
18681865 # cannot be used because it would hide the real return code.
@@ -1872,7 +1869,7 @@ check_tpm_counter() {
18721869 (
18731870 set +e
18741871 tpmr.sh counter_create \
1875- -pwdc " ${tpm_passphrase :- } " \
1872+ -pwdc ' ' \
18761873 -la " $LABEL " \
18771874 > /tmp/counter 2> >( tee >( SINK_LOG " tpm counter_create stderr" ) >&2 )
18781875 echo $? > /tmp/counter_create_rc
@@ -2050,22 +2047,11 @@ increment_tpm_counter() {
20502047 counter_present=" y"
20512048 fi
20522049
2053- # Prefer explicit passphrase, otherwise reuse cached TPM owner passphrase.
2050+ # TPM2 uses owner-auth fallback in tpm2_counter_inc; TPM1 uses empty counter
2051+ # auth (SHA1("")) per TCG spec — no owner passphrase needed for increment.
2052+ # Keep the cached owner passphrase for TPM2 fallback.
20542053 if [ -z " $tpm_passphrase " ] && [ -s /tmp/secret/tpm_owner_passphrase ]; then
20552054 tpm_passphrase=" $( cat /tmp/secret/tpm_owner_passphrase) "
2056- DEBUG " increment_tpm_counter: using cached TPM owner passphrase"
2057- fi
2058-
2059- # TPM1 counter_increment requires owner auth in practice on this path.
2060- # origin/master typically reached this with cached owner passphrase already set,
2061- # but the newer reseal/update flows can call this later in the session after
2062- # that cache is absent. Prompt once and cache to avoid empty -pwdc failures.
2063- if [ " $CONFIG_TPM2_TOOLS " != " y" ] && [ -z " $tpm_passphrase " ]; then
2064- WARN " TPM Owner Passphrase is required to update rollback counter before signing updated boot hashes."
2065- DEBUG " increment_tpm_counter: TPM1 path has no cached/provided owner passphrase; prompting now"
2066- prompt_tpm_owner_password
2067- tpm_passphrase=" $tpm_owner_passphrase "
2068- DEBUG " increment_tpm_counter: TPM1 owner passphrase obtained and cached"
20692055 fi
20702056
20712057 # Try to increment the counter. We normally hide the verbose
@@ -2094,7 +2080,7 @@ increment_tpm_counter() {
20942080 increment_ok=" y"
20952081 fi
20962082 else
2097- # TPM1 path uses owner auth in practice .
2083+ # TPM1 counter uses empty auth (SHA1 of "") per TCG spec .
20982084 # NOTE: tpmtotp C code prints ALL output (success + errors) to stdout.
20992085 # We must capture stdout to detect failures properly.
21002086 # DO_WITH_DEBUG internally captures the command's stderr (tee /dev/stderr
@@ -2104,7 +2090,7 @@ increment_tpm_counter() {
21042090 if (
21052091 set -o pipefail
21062092 DO_WITH_DEBUG --mask-position 5 \
2107- tpmr.sh counter_increment -ix " $counter_id " -pwdc " ${tpm_passphrase :- } " \
2093+ tpmr.sh counter_increment -ix " $counter_id " -pwdc ' ' \
21082094 2> /dev/null | tee /tmp/counter-" $counter_id " > /dev/null
21092095 ); then
21102096 increment_ok=" y"
@@ -2123,10 +2109,11 @@ increment_tpm_counter() {
21232109
21242110 # run counter_create but tee its stdout to a file so we still see
21252111 # the interactive prompt and any informational messages.
2112+ # Empty counter auth (-pwdc '') per TCG spec.
21262113 if (
21272114 set -o pipefail
21282115 DO_WITH_DEBUG --mask-position 3 \
2129- tpmr.sh counter_create -pwdc " ${tpm_passphrase :- } " -la 3135106223 \
2116+ tpmr.sh counter_create -pwdc ' ' -la 3135106223 \
21302117 2> >( tee >( SINK_LOG " tpm counter_create stderr" ) >&2 ) |
21312118 tee /tmp/new-counter > /dev/null
21322119 ); then
0 commit comments