From: Adam Langley Date: Wed, 13 Jun 2012 20:23:40 +0000 (-0400) Subject: [release-branch.go1] crypto/x509: fix panic when using unavailable hash function. X-Git-Tag: go1.0.2~101 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=5ccc50c8d6401ef5c987645165ffce9496ec88b7;p=gostls13.git [release-branch.go1] crypto/x509: fix panic when using unavailable hash function. ««« backport d8d358ddc6e0 crypto/x509: fix panic when using unavailable hash function. crypto.Hash.New() changed to panicking when the hash function isn't linked in, but crypto/x509 still expects it to return nil. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6175047 »»» --- diff --git a/src/pkg/crypto/x509/x509.go b/src/pkg/crypto/x509/x509.go index 8dae7e7fcf..c4d85e67f0 100644 --- a/src/pkg/crypto/x509/x509.go +++ b/src/pkg/crypto/x509/x509.go @@ -388,10 +388,10 @@ func (c *Certificate) CheckSignature(algo SignatureAlgorithm, signed, signature return ErrUnsupportedAlgorithm } - h := hashType.New() - if h == nil { + if !hashType.Available() { return ErrUnsupportedAlgorithm } + h := hashType.New() h.Write(signed) digest := h.Sum(nil)