Expand HMAC support in Salt; require an identifier be passed in to specify type but allow generation with and without. Add a StaticSalt ID for testing functions. Fix bugs; unit tests pass.

This commit is contained in:
Jeff Mitchell
2015-09-18 17:36:42 -04:00
parent a4ca14cfbc
commit 1a22cb0b12
11 changed files with 114 additions and 67 deletions

View File

@@ -16,7 +16,7 @@ import (
//
// The structure is modified in-place.
func Hash(salter *salt.Salt, raw interface{}) error {
fn := salter.GetHMAC
fn := salter.GetIdentifiedHMAC
switch s := raw.(type) {
case *logical.Auth:
@@ -86,17 +86,6 @@ func HashStructure(s interface{}, cb HashCallback) (interface{}, error) {
// a value.
type HashCallback func(string) string
// HashSHA1 returns a HashCallback that hashes data with SHA1 and
// with an optional salt. If salt is a blank string, no salt is used.
/*
func HashSHA1(salt string) HashCallback {
return func(v string) (string, error) {
hashed := sha1.Sum([]byte(v + salt))
return "sha1:" + hex.EncodeToString(hashed[:]), nil
}
}
*/
// hashWalker implements interfaces for the reflectwalk package
// (github.com/mitchellh/reflectwalk) that can be used to automatically
// replace primitives with a hashed value.