m/p/tpm: fix garbage when logging PCRs
Casting an int to a string causes it to be interpreted as a byte of an
UTF-8 string, not converted to the respective UTF-8 character(s).
Use strconv instead to actually convert the integers to valid UTF-8
text.
Change-Id: I4878d9312f2fd2f2401e7fc3ba0e7a69cbca4d9e
Reviewed-on: https://review.monogon.dev/c/monogon/+/1925
Tested-by: Jenkins CI
Reviewed-by: Leopold Schabel <leo@monogon.tech>
diff --git a/metropolis/pkg/tpm/tpm.go b/metropolis/pkg/tpm/tpm.go
index 2ad1aaa..2a3f67a 100644
--- a/metropolis/pkg/tpm/tpm.go
+++ b/metropolis/pkg/tpm/tpm.go
@@ -286,7 +286,7 @@
// Logging this for auditing purposes
pcrList := []string{}
for _, pcr := range sealedBytes.SealedKey.Pcrs {
- pcrList = append(pcrList, string(pcr))
+ pcrList = append(pcrList, strconv.FormatUint(uint64(pcr), 10))
}
tpm.logger.Infof("Attempting to unseal key protected with PCRs %s", strings.Join(pcrList, ","))
unsealedKey, err := srk.Unseal(sealedBytes.SealedKey, tpm2tools.UnsealOpts{})