From: dchaofei Date: Thu, 19 May 2022 02:02:50 +0000 (+0000) Subject: crypto/x509: optimize the performance of checkSignature X-Git-Tag: go1.22rc1~461 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ea3010d994c927907fda2d742799f5629cdf9265;p=gostls13.git crypto/x509: optimize the performance of checkSignature 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 Reviewed-by: David Chase Reviewed-by: Roland Shoemaker Auto-Submit: Roland Shoemaker --- diff --git a/src/crypto/x509/x509.go b/src/crypto/x509/x509.go index b2e31f76b4..c710655304 100644 --- a/src/crypto/x509/x509.go +++ b/src/crypto/x509/x509.go @@ -889,6 +889,7 @@ func checkSignature(algo SignatureAlgorithm, signed, signature []byte, publicKey if details.algo == algo { hashType = details.hash pubKeyAlgo = details.pubKeyAlgo + break } }