]> Cypherpunks repositories - gostls13.git/commit
crypto/ecdsa: verify validity of signature parameters in Verify
authorRoland Shoemaker <roland@golang.org>
Mon, 28 Nov 2022 16:51:32 +0000 (08:51 -0800)
committerGopher Robot <gobot@golang.org>
Thu, 1 Dec 2022 17:28:18 +0000 (17:28 +0000)
commit34ab0bcc5eaf97cc0aff11cfe782e4c174d52ef0
tree72ca00bfe479ae38c088a9e7154d7755e0b9203d
parent15e705ea963b5008112793507365e24b743606bc
crypto/ecdsa: verify validity of signature parameters in Verify

CL 353849 removed validation of signature parameters being passed to
Verify which led to two distinct problems. If passed a R or S == 0,
encodeSignature would panic since it expects them to be non-zero.
encodeSignature would also normalize (i.e. make non-negative) parameters
by zero padding them, which would result in a signature being passed to
VerifyASN1 which did not match the input signature, resulting in success
in cases where it should've failed. This change re-adds the verification
that 0 < r,s < N before calling ecnodeSignature.

This was caught because tink runs the wycheproof ECDSA vectors against
Verify, where we only run the vectors against VerifyASN1. We should be
doing both.

Change-Id: I1dcf41626b4df2b43296e8b878dc607ff316a892
Reviewed-on: https://go-review.googlesource.com/c/go/+/453675
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>
src/crypto/ecdsa/ecdsa.go
src/crypto/ecdsa/ecdsa_legacy.go
src/crypto/ecdsa/ecdsa_test.go