Skip to content

Commit

Permalink
don't drop leading zeroes when performing generic ecdsa signing (#357)
Browse files Browse the repository at this point in the history
call ret.FillBytes() instead of ret.Bytes() to preserve leading zeroes that may have been dropped when converting the digest to an integer
  • Loading branch information
mwielgoszewski authored Nov 9, 2023
1 parent 93c5899 commit a3545df
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion attest/wrapped_tpm20.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a3545df

Please sign in to comment.