ssh: support RSA SHA-2 (RFC8332) signatures

This change adds support for RSA SHA-2 based signatures for host keys and certificates. It also switches the default certificate signature algorithm for RSA to use SHA-512. This is implemented by treating ssh.Signer specially when the key type is `ssh-rsa` by also allowing SHA-256 and SHA-512 signatures.

Fixes golang/go#37278

Change-Id: I2ee1ac4ae4c9c1de441a2d6cf1e806357ef18910
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/220037
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
This commit is contained in:
Hans Nielsen
2021-11-15 23:45:14 +00:00
committed by Jason A. Donenfeld
parent ceb1ce70b4
commit b4de73f9ec
12 changed files with 213 additions and 69 deletions
+8
View File
@@ -34,6 +34,14 @@ func init() {
panic(fmt.Sprintf("Unable to parse test key %s: %v", t, err))
}
testSigners[t], err = NewSignerFromKey(testPrivateKeys[t])
if v, ok := testSigners[t].(*rsaSigner); ok {
switch t {
case "rsa-sha2-256":
testSigners[t] = &rsaSigner{v, SigAlgoRSASHA2256}
case "rsa-sha2-512":
testSigners[t] = &rsaSigner{v, SigAlgoRSASHA2512}
}
}
if err != nil {
panic(fmt.Sprintf("Unable to create signer for test key %s: %v", t, err))
}