mirror of https://github.com/golang/go.git
crypto/rsa: return err when key too small to compute salt for RSA PSS
When PSSSaltLengthAuto is passed to SignPSS, and the key size is too small to create a valid salt, return ErrMessageTooLong Change-Id: I4e0d70bdd54fcd667eae10e0a70b4f540a4ebe93 Reviewed-on: https://go-review.googlesource.com/c/go/+/450796 Reviewed-by: Filippo Valsorda <filippo@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Roland Shoemaker <roland@golang.org>
This commit is contained in:
parent
318ceda632
commit
d03e442e2d
|
|
@ -297,6 +297,9 @@ func SignPSS(rand io.Reader, priv *PrivateKey, hash crypto.Hash, digest []byte,
|
||||||
switch saltLength {
|
switch saltLength {
|
||||||
case PSSSaltLengthAuto:
|
case PSSSaltLengthAuto:
|
||||||
saltLength = (priv.N.BitLen()-1+7)/8 - 2 - hash.Size()
|
saltLength = (priv.N.BitLen()-1+7)/8 - 2 - hash.Size()
|
||||||
|
if saltLength < 0 {
|
||||||
|
return nil, ErrMessageTooLong
|
||||||
|
}
|
||||||
case PSSSaltLengthEqualsHash:
|
case PSSSaltLengthEqualsHash:
|
||||||
saltLength = hash.Size()
|
saltLength = hash.Size()
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue