diff options
author | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-01-16 00:45:45 +0800 |
---|---|---|
committer | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-01-16 02:40:10 +0800 |
commit | 47d3b3dd58172c2e7c1f72fb072bd9385aff8205 (patch) | |
tree | 8df36e0ebbe29820066dc4640fcc8649b14cc28b /crypto/key_store_plain.go | |
parent | a1c2749380523178f87ae3fdfb02bc6641362924 (diff) | |
download | dexon-47d3b3dd58172c2e7c1f72fb072bd9385aff8205.tar dexon-47d3b3dd58172c2e7c1f72fb072bd9385aff8205.tar.gz dexon-47d3b3dd58172c2e7c1f72fb072bd9385aff8205.tar.bz2 dexon-47d3b3dd58172c2e7c1f72fb072bd9385aff8205.tar.lz dexon-47d3b3dd58172c2e7c1f72fb072bd9385aff8205.tar.xz dexon-47d3b3dd58172c2e7c1f72fb072bd9385aff8205.tar.zst dexon-47d3b3dd58172c2e7c1f72fb072bd9385aff8205.zip |
Address pull request comments
* Remove flags field from key struct
* Change JSON struct fields from string to []byte
* Change GenerateNewKey API to take io.Reader for random source
* Remove mixing entropy source function
* Use testing Fatal in tests
Diffstat (limited to 'crypto/key_store_plain.go')
-rw-r--r-- | crypto/key_store_plain.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/crypto/key_store_plain.go b/crypto/key_store_plain.go index 00d9767b6..2aa813f5e 100644 --- a/crypto/key_store_plain.go +++ b/crypto/key_store_plain.go @@ -27,6 +27,7 @@ import ( "code.google.com/p/go-uuid/uuid" "encoding/json" "fmt" + "io" "io/ioutil" "os" "os/user" @@ -35,7 +36,8 @@ import ( // TODO: rename to KeyStore when replacing existing KeyStore type KeyStore2 interface { - GenerateNewKey(string) (*Key, error) // create and store new key, optionally using auth string + // create new key using io.Reader entropy source and optionally using auth string + GenerateNewKey(io.Reader, string) (*Key, error) GetKey(*uuid.UUID, string) (*Key, error) // key from id and auth string StoreKey(*Key, string) error // store key optionally using auth string DeleteKey(*uuid.UUID, string) error // delete key by id and auth string @@ -57,17 +59,17 @@ func NewKeyStorePlain(path string) KeyStore2 { return ks } -func (ks keyStorePlain) GenerateNewKey(auth string) (key *Key, err error) { - return GenerateNewKeyDefault(ks, auth) +func (ks keyStorePlain) GenerateNewKey(rand io.Reader, auth string) (key *Key, err error) { + return GenerateNewKeyDefault(ks, rand, auth) } -func GenerateNewKeyDefault(ks KeyStore2, auth string) (key *Key, err error) { +func GenerateNewKeyDefault(ks KeyStore2, rand io.Reader, auth string) (key *Key, err error) { defer func() { if r := recover(); r != nil { err = fmt.Errorf("GenerateNewKey error: %v", r) } }() - key = NewKey() + key = NewKey(rand) err = ks.StoreKey(key, auth) return key, err } |