]> Cypherpunks repositories - gostls13.git/commit
crypto/rsa: fix salt length calculation with PSSSaltLengthAuto
authorHimanshu Kishna Srivastava <28himanshu@gmail.com>
Tue, 16 Mar 2021 17:07:46 +0000 (22:37 +0530)
committerFilippo Valsorda <filippo@golang.org>
Mon, 29 Mar 2021 15:20:11 +0000 (15:20 +0000)
commit8f676144ad7b7c91adb0c6e1ec89aaa6283c6807
treec4d6b631c1d816cb5bb8f34de4f3f0ac6f21a203
parent565e70fcefd63c1f57989a0f794bf7c8bb4cf5ec
crypto/rsa: fix salt length calculation with PSSSaltLengthAuto

When PSSSaltLength is set, the maximum salt length must equal:

    (modulus_key_size - 1 + 7)/8 - hash_length - 2
and for example, with a 4096 bit modulus key, and a SHA-1 hash,
it should be:

     (4096 -1 + 7)/8 - 20 - 2 = 490
Previously we'd encounter this error:

     crypto/rsa: key size too small for PSS signature

Fixes #42741

Change-Id: I18bb82c41c511d564b3f4c443f4b3a38ab010ac5
Reviewed-on: https://go-review.googlesource.com/c/go/+/302230
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
src/crypto/rsa/pss.go
src/crypto/rsa/pss_test.go