Implements FindSecretEntity

This commit is contained in:
Stephen McQuay 2018-02-27 18:45:25 -08:00
parent 302f738bea
commit 65e6137c37
Signed by untrusted user: sm
GPG Key ID: 4E4B72F479BA3CE5

View File

@ -331,5 +331,13 @@ func findKey(el openpgp.EntityList, id string) (*openpgp.Entity, error) {
// FindSecretEntity searches for id in the secret keyring.
func FindSecretEntity(root, id string) (*openpgp.Entity, error) {
return nil, errors.New("NYI")
if err := ensureDir(root); err != nil {
return nil, errors.Wrap(err, "can't find or create pgp dir")
}
srn, prn := getNames(root)
secs, _, err := getELs(srn, prn)
if err != nil {
return nil, errors.Wrap(err, "getting existing keyrings")
}
return findKey(secs, id)
}