diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index a7e5c49..cdf2f68 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,7 +1,7 @@ { "ImportPath": "github.com/sec51/twofactor", "GoVersion": "go1.6", - "GodepVersion": "v62", + "GodepVersion": "v74", "Deps": [ { "ImportPath": "github.com/sec51/convert", @@ -17,7 +17,7 @@ }, { "ImportPath": "github.com/sec51/cryptoengine", - "Rev": "36f5a7d2e2059ebd9e631d8a5d09c250f73975d3" + "Rev": "11617a465c082a1e82359b3c059f018f8dcbfc93" }, { "ImportPath": "github.com/sec51/gf256", diff --git a/vendor/github.com/sec51/cryptoengine/file_utils.go b/vendor/github.com/sec51/cryptoengine/file_utils.go index fa441d8..1e43dd0 100644 --- a/vendor/github.com/sec51/cryptoengine/file_utils.go +++ b/vendor/github.com/sec51/cryptoengine/file_utils.go @@ -1,27 +1,34 @@ package cryptoengine import ( - "encoding/base64" + "encoding/hex" "fmt" "io/ioutil" "log" "os" - "strconv" + "path/filepath" ) const ( - keyPath = "keys" testKeyPath = "test_keys" ) var ( - osSeparator, _ = strconv.Unquote(strconv.QuoteRuneToASCII(os.PathSeparator)) - keysFolderPrefixFormat = fmt.Sprintf("%s%s", keyPath, osSeparator) + "%s" - testKeysFolderPrefixFormat = fmt.Sprintf("%s%s", testKeyPath, osSeparator) + "%s" + keyPath string + keysFolderPrefixFormat string + testKeysFolderPrefixFormat string ) // create the keys folder if it does not exist, with the proper permission func init() { + if os.Getenv("SEC51_KEYPATH") != "" { + keyPath = os.Getenv("SEC51_KEYPATH") + } else { + keyPath = "keys" + } + + keysFolderPrefixFormat = filepath.Join(keyPath, "%s") + testKeysFolderPrefixFormat = filepath.Join(testKeyPath, "%s") if err := createBaseKeyFolder(keyPath); err != nil { log.Println(err) } @@ -73,9 +80,9 @@ func readKey(filename, pathFormat string) ([keySize]byte, error) { if err != nil { return data32, err } - // decode from base64 + // decode from hex dst := make([]byte, len(data)) - _, err = base64.StdEncoding.Decode(dst, data) + _, err = hex.Decode(dst, data) //.StdEncoding.Decode(dst, data) if err != nil { return data32, err } @@ -84,10 +91,10 @@ func readKey(filename, pathFormat string) ([keySize]byte, error) { return data32, err } -// Write the key file base64 encoded +// Write the key file hex encoded func writeKey(filename, pathFormat string, data []byte) error { - dst := make([]byte, base64.StdEncoding.EncodedLen(len(data))) - base64.StdEncoding.Encode(dst, data) + dst := make([]byte, hex.EncodedLen(len(data))) //StdEncoding.EncodedLen(len(data))) + hex.Encode(dst, data) // StdEncoding.Encode(dst, data) filePath := fmt.Sprintf(pathFormat, filename) return writeFile(filePath, dst) }