|
@ -89,11 +89,10 @@ func (s FileStore) Get(name string) (salt []byte, key []byte, info keys.Info, er |
|
|
// Info for all keys located in this directory.
|
|
|
// Info for all keys located in this directory.
|
|
|
func (s FileStore) List() (keys.Infos, error) { |
|
|
func (s FileStore) List() (keys.Infos, error) { |
|
|
dir, err := os.Open(s.keyDir) |
|
|
dir, err := os.Open(s.keyDir) |
|
|
defer dir.Close() |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, errors.Wrap(err, "List Keys") |
|
|
return nil, errors.Wrap(err, "List Keys") |
|
|
} |
|
|
} |
|
|
|
|
|
defer dir.Close() |
|
|
|
|
|
|
|
|
names, err := dir.Readdirnames(0) |
|
|
names, err := dir.Readdirnames(0) |
|
|
if err != nil { |
|
|
if err != nil { |
|
@ -141,11 +140,10 @@ func (s FileStore) nameToPaths(name string) (pub, priv string) { |
|
|
|
|
|
|
|
|
func readInfo(path string) (info keys.Info, err error) { |
|
|
func readInfo(path string) (info keys.Info, err error) { |
|
|
f, err := os.Open(path) |
|
|
f, err := os.Open(path) |
|
|
defer f.Close() |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return info, errors.Wrap(err, "Reading data") |
|
|
return info, errors.Wrap(err, "Reading data") |
|
|
} |
|
|
} |
|
|
|
|
|
defer f.Close() |
|
|
|
|
|
|
|
|
d, err := ioutil.ReadAll(f) |
|
|
d, err := ioutil.ReadAll(f) |
|
|
if err != nil { |
|
|
if err != nil { |
|
@ -170,11 +168,10 @@ func readInfo(path string) (info keys.Info, err error) { |
|
|
|
|
|
|
|
|
func read(path string) (salt, key []byte, name string, err error) { |
|
|
func read(path string) (salt, key []byte, name string, err error) { |
|
|
f, err := os.Open(path) |
|
|
f, err := os.Open(path) |
|
|
defer f.Close() |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, nil, "", errors.Wrap(err, "Reading data") |
|
|
return nil, nil, "", errors.Wrap(err, "Reading data") |
|
|
} |
|
|
} |
|
|
|
|
|
defer f.Close() |
|
|
|
|
|
|
|
|
d, err := ioutil.ReadAll(f) |
|
|
d, err := ioutil.ReadAll(f) |
|
|
if err != nil { |
|
|
if err != nil { |
|
@ -208,11 +205,10 @@ func read(path string) (salt, key []byte, name string, err error) { |
|
|
|
|
|
|
|
|
func writeInfo(path string, info keys.Info) error { |
|
|
func writeInfo(path string, info keys.Info) error { |
|
|
f, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, keyPerm) |
|
|
f, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, keyPerm) |
|
|
defer f.Close() |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return errors.Wrap(err, "Writing data") |
|
|
return errors.Wrap(err, "Writing data") |
|
|
} |
|
|
} |
|
|
|
|
|
defer f.Close() |
|
|
|
|
|
|
|
|
headers := map[string]string{"name": info.Name} |
|
|
headers := map[string]string{"name": info.Name} |
|
|
text := crypto.EncodeArmor(BlockType, headers, info.PubKey.Bytes()) |
|
|
text := crypto.EncodeArmor(BlockType, headers, info.PubKey.Bytes()) |
|
@ -223,11 +219,10 @@ func writeInfo(path string, info keys.Info) error { |
|
|
|
|
|
|
|
|
func write(path, name string, salt, key []byte) error { |
|
|
func write(path, name string, salt, key []byte) error { |
|
|
f, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, keyPerm) |
|
|
f, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, keyPerm) |
|
|
defer f.Close() |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return errors.Wrap(err, "Writing data") |
|
|
return errors.Wrap(err, "Writing data") |
|
|
} |
|
|
} |
|
|
|
|
|
defer f.Close() |
|
|
|
|
|
|
|
|
headers := map[string]string{ |
|
|
headers := map[string]string{ |
|
|
"name": name, |
|
|
"name": name, |
|
|