]> Cypherpunks repositories - gostls13.git/commitdiff
crypto/x509: fix panic when using unavailable hash function.
authorAdam Langley <agl@golang.org>
Thu, 3 May 2012 20:39:57 +0000 (16:39 -0400)
committerAdam Langley <agl@golang.org>
Thu, 3 May 2012 20:39:57 +0000 (16:39 -0400)
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

index 8dae7e7fcf948c302c0ac97dd1fa415e5fb6334a..c4d85e67f0c28667229388c19a061fe0540367b8 100644 (file)
@@ -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)