From 5ccc50c8d6401ef5c987645165ffce9496ec88b7 Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Wed, 13 Jun 2012 16:23:40 -0400 Subject: [PATCH] [release-branch.go1] crypto/x509: fix panic when using unavailable hash function. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ««« 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 »»» --- src/pkg/crypto/x509/x509.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) -- 2.50.0