Skip to content

Commit 4a4c23d

Browse files
committed
crypto/x509: add SignatureAlgorithm.Hash()
Add method to return the hashing algorithm associated with a certificates signature algorithm. This is useful when generating TLS channel bindings as documented in RFC 5929. Fixes #33317
1 parent 9195948 commit 4a4c23d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/crypto/x509/x509.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,15 @@ func (algo SignatureAlgorithm) String() string {
219219
return strconv.Itoa(int(algo))
220220
}
221221

222+
func (algo SignatureAlgorithm) Hash() crypto.Hash {
223+
for _, details := range signatureAlgorithmDetails {
224+
if details.algo == algo {
225+
return details.hash
226+
}
227+
}
228+
return crypto.Hash(0)
229+
}
230+
222231
type PublicKeyAlgorithm int
223232

224233
const (

0 commit comments

Comments
 (0)