diff --git a/attest/wrapped_tpm20.go b/attest/wrapped_tpm20.go index 03ede645..1468c1bd 100644 --- a/attest/wrapped_tpm20.go +++ b/attest/wrapped_tpm20.go @@ -623,7 +623,9 @@ func signECDSA(rw io.ReadWriter, key tpmutil.Handle, digest []byte, curve ellipt if excess > 0 { ret.Rsh(ret, uint(excess)) } - digest = ret.Bytes() + // call ret.FillBytes() here instead of ret.Bytes() to preserve leading zeroes + // that may have been dropped when converting the digest to an integer + digest = ret.FillBytes(digest) sig, err := tpm2.Sign(rw, key, "", digest, nil, nil) if err != nil {