nomad: Switch from SHA1 to Blake2 @chelseakomlo

This commit is contained in:
Armon Dadgar 2017-08-21 17:14:02 -07:00
parent fc23a4e7e5
commit e7586a80df

View file

@ -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)