mirror of
https://github.com/1f349/twofactor.git
synced 2024-12-21 23:14:11 +00:00
update cryptoengine in vendor
This commit is contained in:
parent
cc1b87fe43
commit
9505c7b0fb
4
Godeps/Godeps.json
generated
4
Godeps/Godeps.json
generated
@ -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",
|
||||
|
29
vendor/github.com/sec51/cryptoengine/file_utils.go
generated
vendored
29
vendor/github.com/sec51/cryptoengine/file_utils.go
generated
vendored
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user