@@ -3,9 +3,8 @@ package encryption
4 "crypto/hmac"
4 "crypto/hmac"
5 "crypto/rand"
5 "crypto/rand"
6 "encoding/base64"
7 "encoding/base64"
8− "golang.org/x/crypto/blake2b"
11// Nonce generates a random n-byte slice
10// Nonce generates a random n-byte slice
@@ -18,16 +17,16 @@ func Nonce(length int) ([]byte, error) {
18 return b, nil
17 return b, nil
21−// HashNonce returns the BLAKE2b 256-bit hash of a nonce
20+// HashNonce returns the SHA256 hash of a nonce
22−// NOTE: Error checking (G104) is purposefully skipped:
23−// - `blake2b.New256` has no error path with a nil signing key
24−// - `hash.Hash` interface's `Write` has an error signature, but
25−// `blake2b.digest.Write` does not use it.
27func HashNonce(nonce []byte) string {
21func HashNonce(nonce []byte) string {
28− hasher, _ := blake2b.New256(nil)
22+ if nonce == nil {
26+ hasher := sha256.New()
29 hasher.Write(nonce)
27 hasher.Write(nonce)
30 sum := hasher.Sum(nil)
28 sum := hasher.Sum(nil)
31 return base64.RawURLEncoding.EncodeToString(sum)
30 return base64.RawURLEncoding.EncodeToString(sum)