From: Adam Langley Date: Thu, 3 May 2012 20:39:57 +0000 (-0400) Subject: crypto/x509: fix panic when using unavailable hash function. X-Git-Tag: go1.1rc2~3257 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c8e1946f33ee2cf482922ba2398086189faf53f6;p=gostls13.git 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)