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 ( import (
crand "crypto/rand" crand "crypto/rand"
"crypto/sha1"
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"math" "math"
"sort" "sort"
"strings" "strings"
"golang.org/x/crypto/blake2b"
multierror "github.com/hashicorp/go-multierror" multierror "github.com/hashicorp/go-multierror"
lru "github.com/hashicorp/golang-lru" lru "github.com/hashicorp/golang-lru"
"github.com/hashicorp/nomad/acl" "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. // ACLPolicyListHash returns a consistent hash for a set of policies.
func ACLPolicyListHash(policies []*ACLPolicy) string { func ACLPolicyListHash(policies []*ACLPolicy) string {
cacheKeyHash := sha1.New() cacheKeyHash, err := blake2b.New256(nil)
if err != nil {
panic(err)
}
for _, policy := range policies { for _, policy := range policies {
cacheKeyHash.Write([]byte(policy.Name)) cacheKeyHash.Write([]byte(policy.Name))
binary.Write(cacheKeyHash, binary.BigEndian, policy.ModifyIndex) binary.Write(cacheKeyHash, binary.BigEndian, policy.ModifyIndex)