From e7586a80dfcd94dff442f5378b15133c5fc83a01 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Mon, 21 Aug 2017 17:14:02 -0700 Subject: [PATCH] nomad: Switch from SHA1 to Blake2 @chelseakomlo --- nomad/structs/funcs.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nomad/structs/funcs.go b/nomad/structs/funcs.go index 71f8f0f23..4db0092b7 100644 --- a/nomad/structs/funcs.go +++ b/nomad/structs/funcs.go @@ -2,13 +2,14 @@ package structs import ( crand "crypto/rand" - "crypto/sha1" "encoding/binary" "fmt" "math" "sort" "strings" + "golang.org/x/crypto/blake2b" + multierror "github.com/hashicorp/go-multierror" lru "github.com/hashicorp/golang-lru" "github.com/hashicorp/nomad/acl" @@ -263,7 +264,10 @@ func AllocName(job, group string, idx uint) string { // ACLPolicyListHash returns a consistent hash for a set of policies. func ACLPolicyListHash(policies []*ACLPolicy) string { - cacheKeyHash := sha1.New() + cacheKeyHash, err := blake2b.New256(nil) + if err != nil { + panic(err) + } for _, policy := range policies { cacheKeyHash.Write([]byte(policy.Name)) binary.Write(cacheKeyHash, binary.BigEndian, policy.ModifyIndex)