Use sha256 for slot token (#1155)

This commit is contained in:
Owen Cliffe
2018-08-03 19:07:28 +01:00
committed by GitHub
parent 0105f8321e
commit c3a46f9452

View File

@@ -2,7 +2,7 @@ package agent
import ( import (
"context" "context"
"crypto/sha1" "crypto/sha256"
"encoding/binary" "encoding/binary"
"hash" "hash"
"reflect" "reflect"
@@ -271,13 +271,12 @@ func (a *slotQueueMgr) deleteSlotQueue(slots *slotQueue) bool {
return isDeleted return isDeleted
} }
// TODO this should be at least SHA-256 or more var shapool = &sync.Pool{New: func() interface{} { return sha256.New() }}
var shapool = &sync.Pool{New: func() interface{} { return sha1.New() }}
// TODO do better; once we have app+route versions this function // TODO do better; once we have app+route versions this function
// can be simply app+route names & version // can be simply app+route names & version
func getSlotQueueKey(call *call) string { func getSlotQueueKey(call *call) string {
// return a sha1 hash of a (hopefully) unique string of all the config // return a sha256 hash of a (hopefully) unique string of all the config
// values, to make map lookups quicker [than the giant unique string] // values, to make map lookups quicker [than the giant unique string]
hash := shapool.Get().(hash.Hash) hash := shapool.Get().(hash.Hash)
@@ -349,7 +348,7 @@ func getSlotQueueKey(call *call) string {
hash.Write(unsafeBytes("\x00")) hash.Write(unsafeBytes("\x00"))
} }
var buf [sha1.Size]byte var buf [sha256.Size]byte
hash.Sum(buf[:0]) hash.Sum(buf[:0])
return string(buf[:]) return string(buf[:])
} }