allow adding a raw key
This commit is contained in:
@@ -211,10 +211,13 @@ func (s *Store) Unlock(passphrase []byte) (ok bool) {
|
||||
}
|
||||
|
||||
func (s *Store) AddKey(name string, passphrase []byte) {
|
||||
key, hash := s.keyPairFromPassword(passphrase)
|
||||
key, _ := s.keyPairFromPassword(passphrase)
|
||||
memzero(passphrase)
|
||||
s.AddRawKey(name, key)
|
||||
}
|
||||
|
||||
defer memzero(key[:])
|
||||
func (s *Store) AddRawKey(name string, key [32]byte) {
|
||||
hash := sha512.Sum512(key[:])
|
||||
|
||||
k := KeyEntry{Name: name, Hash: hash}
|
||||
|
||||
@@ -222,6 +225,7 @@ func (s *Store) AddKey(name string, passphrase []byte) {
|
||||
copy(k.EncKey[:], encKey)
|
||||
|
||||
s.Keys = append(s.Keys, k)
|
||||
memzero(key[:])
|
||||
}
|
||||
|
||||
func (s *Store) keyPairFromPassword(password []byte) (key [32]byte, hash [64]byte) {
|
||||
|
||||
Reference in New Issue
Block a user