]> Cypherpunks.ru repositories - gostls13.git/commitdiff
crypto/x509: optimize the performance of checkSignature
authordchaofei <dchaofei@gmail.com>
Thu, 19 May 2022 02:02:50 +0000 (02:02 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 1 Nov 2023 19:04:52 +0000 (19:04 +0000)
The loop should be terminated immediately when `algo` has been found

Fixes #52955

Change-Id: Ib3865c4616a0c1af9b72daea45f5a1750f84562f
GitHub-Last-Rev: 721322725fb2d3a3ea410d09fd8320dfef865d8d
GitHub-Pull-Request: golang/go#52987
Reviewed-on: https://go-review.googlesource.com/c/go/+/407215
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>

src/crypto/x509/x509.go

index b2e31f76b4cb5ccbb03cc4f65339c75e50dd3e59..c7106553043b15643313f444e9d00708de8b16c8 100644 (file)
@@ -889,6 +889,7 @@ func checkSignature(algo SignatureAlgorithm, signed, signature []byte, publicKey
                if details.algo == algo {
                        hashType = details.hash
                        pubKeyAlgo = details.pubKeyAlgo
+                       break
                }
        }