From 82442e0e955be375a24923697acfc8cef2b33889 Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Wed, 3 Sep 2014 16:08:25 -0700 Subject: [PATCH] go.crypto/sha3: use the go1.4 tag to register the hash functions. Prior to Go 1.4, crypto didn't have the consts defined for SHA-3. LGTM=bradfitz R=bradfitz CC=golang-codereviews https://golang.org/cl/133540043 --- sha3/hashes.go | 8 -------- sha3/register.go | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 sha3/register.go diff --git a/sha3/hashes.go b/sha3/hashes.go index 6a383c9..2b51cf4 100644 --- a/sha3/hashes.go +++ b/sha3/hashes.go @@ -9,17 +9,9 @@ package sha3 // bytes. import ( - "crypto" "hash" ) -func init() { - crypto.RegisterHash(crypto.SHA3_224, New224) - crypto.RegisterHash(crypto.SHA3_256, New256) - crypto.RegisterHash(crypto.SHA3_384, New384) - crypto.RegisterHash(crypto.SHA3_512, New512) -} - // New224 creates a new SHA3-224 hash. // Its generic security strength is 224 bits against preimage attacks, // and 112 bits against collision attacks. diff --git a/sha3/register.go b/sha3/register.go new file mode 100644 index 0000000..3cf6a22 --- /dev/null +++ b/sha3/register.go @@ -0,0 +1,18 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build go1.4 + +package sha3 + +import ( + "crypto" +) + +func init() { + crypto.RegisterHash(crypto.SHA3_224, New224) + crypto.RegisterHash(crypto.SHA3_256, New256) + crypto.RegisterHash(crypto.SHA3_384, New384) + crypto.RegisterHash(crypto.SHA3_512, New512) +}