From c8e1946f33ee2cf482922ba2398086189faf53f6 Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Thu, 3 May 2012 16:39:57 -0400 Subject: [PATCH] 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 8dae7e7fcf9..c4d85e67f0c 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)