aboutsummaryrefslogtreecommitdiffstats
path: root/lib/keystore.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/keystore.go')
-rw-r--r--lib/keystore.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/keystore.go b/lib/keystore.go
index df048f4f..c2110676 100644
--- a/lib/keystore.go
+++ b/lib/keystore.go
@@ -1,6 +1,7 @@
package lib
import (
+ "fmt"
"io"
"os"
"path"
@@ -52,6 +53,19 @@ func UnlockKeyring() {
os.Remove(lockpath)
}
+func GetSignerEntityByEmail(email string) (e *openpgp.Entity, err error) {
+ for _, key := range Keyring.DecryptionKeys() {
+ if key.Entity == nil {
+ continue
+ }
+ ident := key.Entity.PrimaryIdentity()
+ if ident != nil && ident.UserId.Email == email {
+ return key.Entity, nil
+ }
+ }
+ return nil, fmt.Errorf("entity not found in keyring")
+}
+
func ImportKeys(r io.Reader) error {
keys, err := openpgp.ReadKeyRing(r)
if err != nil {