From 8037383527cd5105f38ef328db5171815b9c3ea4 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Fri, 23 Feb 2024 14:43:33 -0500 Subject: [PATCH] Use slices.Contains in ssl/test/runner Minor cleanup afforded by Go 1.21 Change-Id: I49a0f257f2585e54159014f1f442497a816e6589 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/66548 Commit-Queue: David Benjamin Reviewed-by: Bob Beck --- go.mod | 2 +- ssl/test/runner/common.go | 9 --------- ssl/test/runner/sign.go | 5 +++-- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index ad1fc2c42..4638955a7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module boringssl.googlesource.com/boringssl -go 1.19 +go 1.21 require ( golang.org/x/crypto v0.17.0 diff --git a/ssl/test/runner/common.go b/ssl/test/runner/common.go index 64f774189..666b4b65b 100644 --- a/ssl/test/runner/common.go +++ b/ssl/test/runner/common.go @@ -2339,15 +2339,6 @@ func unexpectedMessageError(wanted, got any) error { return fmt.Errorf("tls: received unexpected handshake message of type %T when waiting for %T", got, wanted) } -func isSupportedSignatureAlgorithm(sigAlg signatureAlgorithm, sigAlgs []signatureAlgorithm) bool { - for _, s := range sigAlgs { - if s == sigAlg { - return true - } - } - return false -} - var ( // See RFC 8446, section 4.1.3. downgradeTLS13 = []byte{0x44, 0x4f, 0x57, 0x4e, 0x47, 0x52, 0x44, 0x01} diff --git a/ssl/test/runner/sign.go b/ssl/test/runner/sign.go index 70541a1ec..e0c6a92b1 100644 --- a/ssl/test/runner/sign.go +++ b/ssl/test/runner/sign.go @@ -18,6 +18,7 @@ import ( "errors" "fmt" "math/big" + "slices" ) type signer interface { @@ -35,7 +36,7 @@ func selectSignatureAlgorithm(version uint16, key crypto.PrivateKey, config *Con } for _, sigAlg := range config.signSignatureAlgorithms() { - if !isSupportedSignatureAlgorithm(sigAlg, peerSigAlgs) { + if !slices.Contains(peerSigAlgs, sigAlg) { continue } @@ -68,7 +69,7 @@ func signMessage(version uint16, key crypto.PrivateKey, config *Config, sigAlg s } func verifyMessage(version uint16, key crypto.PublicKey, config *Config, sigAlg signatureAlgorithm, msg, sig []byte) error { - if version >= VersionTLS12 && !isSupportedSignatureAlgorithm(sigAlg, config.verifySignatureAlgorithms()) { + if version >= VersionTLS12 && !slices.Contains(config.verifySignatureAlgorithms(), sigAlg) { return errors.New("tls: unsupported signature algorithm") }