Commit b1370742 authored by Adam Langley's avatar Adam Langley

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/2330Reviewed-by: 's avatarMinux Ma <minux@golang.org>
parent 02f89331
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment