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>
saltLength = hash.Size()
}
- if opts.Hash != 0 {
+ if opts != nil && opts.Hash != 0 {
hash = opts.Hash
}
}
}
+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