[mirror] Go supplementary cryptography libraries
Перейти к файлу
Filippo Valsorda 1baeb1ce4c ssh: don't advertise rsa-sha2 algorithms if we can't use them
The server implementation looks at the HostKeys to advertise and
negotiate host key signature algorithms. A fundamental issue of the
Signer and AlgorithmSigner interfaces is that they don't expose the
supported signature algorithms, so really the server has to guess.

Currently, it would guess exclusively based on the PublicKey.Type,
regardless of whether the host key implemented AlgorithmSigner. This
means that a legacy Signer that only supports ssh-rsa still led the
server to negotiate rsa-sha2 algorithms. The server would then fail to
find a suitable host key to make the signature and crash.

This won't happen if only Signers from this package are used, but if a
custom Signer that doesn't support SignWithAlgorithm() but returns
"ssh-rsa" from PublicKey().Type() is used as a HostKey, the server is
vulnerable to DoS.

The only workable rules to determine what to advertise seems to be:

   1. a pure Signer will always Sign with the PublicKey.Type

   2. an AlgorithmSigner supports all algorithms associated with the
      PublicKey.Type

Rule number two means that we can't add new supported algorithms in the
future, which is not great, but it's too late to fix that.

rsaSigner was breaking rule number one, and although it would have been
fine where it's used, I didn't want to break our own interface contract.

It's unclear why we had separate test key entries for rsa-sha2
algorithms, since we can use the ssh-rsa key for those. The only test
that used them, TestCertTypes, seemed broken: the init was actually
failing at making the corresponding signers rsaSigners, and indeed the
test for the SHA-256 signer expected and checked a SHA-512 signature.

Pending CVE
For golang/go#49952

Change-Id: Ie658eefcadd87906e63fc7faae8249376aa96c79
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/392355
Trust: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-14 23:46:59 +00:00
acme acme/autocert: skip renewal tests broken on windows/arm64 2022-02-14 20:07:02 +00:00
argon2 all: add //go:build lines to assembly files 2021-05-13 12:29:33 +00:00
bcrypt bcrypt: benchmark defaults 2018-10-30 02:28:21 +00:00
blake2b all: add //go:build lines to assembly files 2021-05-13 12:29:33 +00:00
blake2s all: add //go:build lines to assembly files 2021-05-13 12:29:33 +00:00
blowfish all: deprecate broken and legacy packages 2019-02-22 23:25:34 +00:00
bn256 bn256: fix String methods when g.p == nil 2019-02-22 23:45:11 +00:00
cast5 all: deprecate broken and legacy packages 2019-02-22 23:25:34 +00:00
chacha20 all: add //go:build lines to assembly files 2021-05-13 12:29:33 +00:00
chacha20poly1305 poly1305: deprecate public package 2021-09-15 21:47:49 +00:00
cryptobyte cryptobyte: fix parsing of large ASN.1 OIDs 2021-12-15 15:39:01 +00:00
curve25519 curve25519/internal/field: fix generator module reference to x/crypto 2021-05-13 16:48:29 +00:00
ed25519 ed25519: drop Go 1.12 compatibility 2022-02-08 05:03:32 +00:00
hkdf hkdf: add Extract and Expand 2018-10-25 21:37:31 +00:00
internal internal/wycheproof: skip on builders with flaky network connections 2021-12-09 19:36:57 +00:00
md4 all: deprecate broken and legacy packages 2019-02-22 23:25:34 +00:00
nacl poly1305: deprecate public package 2021-09-15 21:47:49 +00:00
ocsp ocsp: fix typo 2022-02-08 23:39:18 +00:00
openpgp openpgp: fix deprecation message 2021-08-13 21:11:28 +00:00
otr all: deprecate broken and legacy packages 2019-02-22 23:25:34 +00:00
pbkdf2 pbkdf2: add benchmarks 2017-12-19 04:11:29 +00:00
pkcs12 pkcs12: drop PKCS#12 attributes with unknown OIDs 2020-07-09 23:00:13 +00:00
poly1305 poly1305: deprecate public package 2021-09-15 21:47:49 +00:00
ripemd160 all: deprecate broken and legacy packages 2019-02-22 23:25:34 +00:00
salsa20 all: add //go:build lines to assembly files 2021-05-13 12:29:33 +00:00
scrypt scrypt: use encoding/binary to simplify smix 2021-03-17 15:28:58 +00:00
sha3 acme, sha3, ssh: fix the typos 2022-02-09 15:53:12 +00:00
ssh ssh: don't advertise rsa-sha2 algorithms if we can't use them 2022-03-14 23:46:59 +00:00
tea all: deprecate broken and legacy packages 2019-02-22 23:25:34 +00:00
twofish all: deprecate broken and legacy packages 2019-02-22 23:25:34 +00:00
xtea all: deprecate broken and legacy packages 2019-02-22 23:25:34 +00:00
xts xts: reduce tweak allocations 2019-02-22 23:57:06 +00:00
.gitattributes crypto: copying .gitattributes to all subrepositories 2014-12-23 06:54:52 +00:00
.gitignore gitignore: remove obsolete reference to .hgignore in comment 2020-03-20 18:11:02 +00:00
AUTHORS all: use HTTPS for links that support it 2017-06-29 04:21:55 +00:00
CONTRIBUTING.md CONTRIBUTING.md: remove note about not accepting Pull Requests 2018-03-14 18:02:59 +00:00
CONTRIBUTORS all: use HTTPS for links that support it 2017-06-29 04:21:55 +00:00
LICENSE LICENSE: add 2012-03-17 15:19:30 +11:00
PATENTS go.crypto: add PATENTS file to the subrepo. 2012-04-16 11:25:08 +10:00
README.md README.md: add badge to pkg.go.dev 2020-12-08 17:14:46 +00:00
codereview.cfg crypto: add codereview.cfg 2015-03-18 17:04:25 +00:00
go.mod all: upgrade x/net to latest 2021-11-17 18:39:48 +00:00
go.sum all: upgrade x/net to latest 2021-11-17 18:39:48 +00:00

README.md

Go Cryptography

Go Reference

This repository holds supplementary Go cryptography libraries.

Download/Install

The easiest way to install is to run go get -u golang.org/x/crypto/.... You can also manually git clone the repository to $GOPATH/src/golang.org/x/crypto.

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://golang.org/doc/contribute.html.

The main issue tracker for the crypto repository is located at https://github.com/golang/go/issues. Prefix your issue with "x/crypto:" in the subject line, so it is easy to find.

Note that contributions to the cryptography package receive additional scrutiny due to their sensitive nature. Patches may take longer than normal to receive feedback.