What version of Go are you using (go version)?
$ go version
go version go1.18 darwin/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOVERSION="go1.18"
What did you do?
I read the go source code and found a performance issue, checkSignature why the loop doesn't break after finding algo?
|
func checkSignature(algo SignatureAlgorithm, signed, signature []byte, publicKey crypto.PublicKey, allowSHA1 bool) (err error) { |
|
var hashType crypto.Hash |
|
var pubKeyAlgo PublicKeyAlgorithm |
|
|
|
for _, details := range signatureAlgorithmDetails { |
|
if details.algo == algo { |
|
hashType = details.hash |
|
pubKeyAlgo = details.pubKeyAlgo |
|
} |
|
} |
|
|
|
switch hashType { |
What did you expect to see?
The for of the checkSignature function requires an early break
for _, details := range signatureAlgorithmDetails {
if details.algo == algo {
hashType = details.hash
pubKeyAlgo = details.pubKeyAlgo
break
}
}
What did you see instead?
If this needs to be fixed, I'd be happy to submit a pr
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env)?go envOutputWhat did you do?
I read the
gosource code and found a performance issue, checkSignature why the loop doesn'tbreakafter findingalgo?go/src/crypto/x509/x509.go
Lines 818 to 829 in aedf298
What did you expect to see?
The
forof the checkSignature function requires an earlybreakWhat did you see instead?
If this needs to be fixed, I'd be happy to submit a
pr