mirror of
https://github.com/golang/go
synced 2024-11-11 21:20:21 -07:00
crypto/rsa: rsa.SignPSS with opts=nil shouldn't crash.
SignPSS is documented as allowing opts to be nil, but actually crashes in that case. This change fixes that. Change-Id: Ic48ff5f698c010a336e2bf720e0f44be1aecafa0 Reviewed-on: https://go-review.googlesource.com/2330 Reviewed-by: Minux Ma <minux@golang.org>
This commit is contained in:
parent
02f89331c2
commit
b1370742ee
@ -255,7 +255,7 @@ func SignPSS(rand io.Reader, priv *PrivateKey, hash crypto.Hash, hashed []byte,
|
||||
saltLength = hash.Size()
|
||||
}
|
||||
|
||||
if opts.Hash != 0 {
|
||||
if opts != nil && opts.Hash != 0 {
|
||||
hash = opts.Hash
|
||||
}
|
||||
|
||||
|
@ -189,6 +189,15 @@ func TestPSSOpenSSL(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPSSNilOpts(t *testing.T) {
|
||||
hash := crypto.SHA256
|
||||
h := hash.New()
|
||||
h.Write([]byte("testing"))
|
||||
hashed := h.Sum(nil)
|
||||
|
||||
SignPSS(rand.Reader, rsaPrivateKey, hash, hashed, nil)
|
||||
}
|
||||
|
||||
func TestPSSSigning(t *testing.T) {
|
||||
var saltLengthCombinations = []struct {
|
||||
signSaltLength, verifySaltLength int
|
||||
|
Loading…
Reference in New Issue
Block a user