From 084376bb543d4ce80b030a77a6f51f3b3fd861dc Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 18 Aug 2021 15:55:37 +0200 Subject: [PATCH] make sure the standard algorithms are registered This makes sure that the expected algorithms are registered when using this package. Currently, the consumer of the package must import these, otherwise it's not registered, resultig in "unsupported digest algorithm" errors. Signed-off-by: Sebastiaan van Stijn --- algorithm_test.go | 2 -- digestset/set_test.go | 1 - sha.go | 6 ++++++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/algorithm_test.go b/algorithm_test.go index 060819e..a10b45d 100644 --- a/algorithm_test.go +++ b/algorithm_test.go @@ -19,8 +19,6 @@ import ( "bytes" "crypto" "crypto/rand" - _ "crypto/sha256" - _ "crypto/sha512" "flag" "fmt" "strings" diff --git a/digestset/set_test.go b/digestset/set_test.go index 7a01c24..d2c5174 100644 --- a/digestset/set_test.go +++ b/digestset/set_test.go @@ -17,7 +17,6 @@ package digestset import ( "crypto/sha256" - _ "crypto/sha512" "encoding/binary" "math/rand" "testing" diff --git a/sha.go b/sha.go index 0e2201f..a9f864f 100644 --- a/sha.go +++ b/sha.go @@ -2,6 +2,12 @@ package digest import ( "crypto" + + // make sure crypto.SHA256 is registered + _ "crypto/sha256" + + // make sure crypto.sha512 and crypto.SHA384 are registered + _ "crypto/sha512" ) const (