mirror of
https://github.com/1f349/twofactor.git
synced 2024-12-22 07:24:12 +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",
|
"ImportPath": "github.com/sec51/twofactor",
|
||||||
"GoVersion": "go1.6",
|
"GoVersion": "go1.6",
|
||||||
"GodepVersion": "v62",
|
"GodepVersion": "v74",
|
||||||
"Deps": [
|
"Deps": [
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/sec51/convert",
|
"ImportPath": "github.com/sec51/convert",
|
||||||
@ -17,7 +17,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/sec51/cryptoengine",
|
"ImportPath": "github.com/sec51/cryptoengine",
|
||||||
"Rev": "36f5a7d2e2059ebd9e631d8a5d09c250f73975d3"
|
"Rev": "11617a465c082a1e82359b3c059f018f8dcbfc93"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/sec51/gf256",
|
"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
|
package cryptoengine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
keyPath = "keys"
|
|
||||||
testKeyPath = "test_keys"
|
testKeyPath = "test_keys"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
osSeparator, _ = strconv.Unquote(strconv.QuoteRuneToASCII(os.PathSeparator))
|
keyPath string
|
||||||
keysFolderPrefixFormat = fmt.Sprintf("%s%s", keyPath, osSeparator) + "%s"
|
keysFolderPrefixFormat string
|
||||||
testKeysFolderPrefixFormat = fmt.Sprintf("%s%s", testKeyPath, osSeparator) + "%s"
|
testKeysFolderPrefixFormat string
|
||||||
)
|
)
|
||||||
|
|
||||||
// create the keys folder if it does not exist, with the proper permission
|
// create the keys folder if it does not exist, with the proper permission
|
||||||
func init() {
|
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 {
|
if err := createBaseKeyFolder(keyPath); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
@ -73,9 +80,9 @@ func readKey(filename, pathFormat string) ([keySize]byte, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return data32, err
|
return data32, err
|
||||||
}
|
}
|
||||||
// decode from base64
|
// decode from hex
|
||||||
dst := make([]byte, len(data))
|
dst := make([]byte, len(data))
|
||||||
_, err = base64.StdEncoding.Decode(dst, data)
|
_, err = hex.Decode(dst, data) //.StdEncoding.Decode(dst, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return data32, err
|
return data32, err
|
||||||
}
|
}
|
||||||
@ -84,10 +91,10 @@ func readKey(filename, pathFormat string) ([keySize]byte, error) {
|
|||||||
return data32, err
|
return data32, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the key file base64 encoded
|
// Write the key file hex encoded
|
||||||
func writeKey(filename, pathFormat string, data []byte) error {
|
func writeKey(filename, pathFormat string, data []byte) error {
|
||||||
dst := make([]byte, base64.StdEncoding.EncodedLen(len(data)))
|
dst := make([]byte, hex.EncodedLen(len(data))) //StdEncoding.EncodedLen(len(data)))
|
||||||
base64.StdEncoding.Encode(dst, data)
|
hex.Encode(dst, data) // StdEncoding.Encode(dst, data)
|
||||||
filePath := fmt.Sprintf(pathFormat, filename)
|
filePath := fmt.Sprintf(pathFormat, filename)
|
||||||
return writeFile(filePath, dst)
|
return writeFile(filePath, dst)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user