allow adding a raw key

This commit is contained in:
Mikaël Cluseau
2026-03-16 11:08:16 +01:00
parent 06a87a6d07
commit 1ad9785d07
7 changed files with 56 additions and 11 deletions

View File

@@ -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) {