From a432568300e1432c3a49d80b48900411589a816d Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Mon, 16 Mar 2015 16:45:29 -0700 Subject: [PATCH] crypto/tls: panic with unknown hash functions. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Just so that we notice in the future if another hash function is added without updating this utility function, make it panic when passed an unknown handshake hash function. (Which should never happen.) Change-Id: I60a6fc01669441523d8c44e8fbe7ed435e7f04c8 Reviewed-on: https://go-review.googlesource.com/7646 Reviewed-by: Andrew Gerrand Reviewed-by: Joël Stemmer --- src/crypto/tls/prf.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/crypto/tls/prf.go b/src/crypto/tls/prf.go index f39a2a8e78..d2f9e28882 100644 --- a/src/crypto/tls/prf.go +++ b/src/crypto/tls/prf.go @@ -10,6 +10,7 @@ import ( "crypto/md5" "crypto/sha1" "hash" + "strconv" ) // Split a premaster secret in two as specified in RFC 4346, section 5. @@ -303,5 +304,5 @@ func tls12HashID(h crypto.Hash) uint8 { case crypto.SHA384: return hashSHA384 } - return 0 + panic("tls12HashID called with unknown hash " + strconv.Itoa(int(h))) } -- 2.48.1