From dbf52bb4b48748586bb6343ae4ad6d424f0631ac Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Fri, 29 Apr 2022 11:19:52 -0500 Subject: pgp: check for signing key before signing time Check that the signing key exists when the user issues the :sign command. The signing key ID will be displayed in the security status also, allowing the user to see what key will be used to sign the message. Signed-off-by: Tim Culverhouse Tested-by: Jens Grassel --- lib/crypto/gpg/gpgbin/keys.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 lib/crypto/gpg/gpgbin/keys.go (limited to 'lib/crypto/gpg/gpgbin/keys.go') diff --git a/lib/crypto/gpg/gpgbin/keys.go b/lib/crypto/gpg/gpgbin/keys.go new file mode 100644 index 00000000..660ce821 --- /dev/null +++ b/lib/crypto/gpg/gpgbin/keys.go @@ -0,0 +1,13 @@ +package gpgbin + +import "fmt" + +// GetPrivateKeyId runs gpg --list-secret-keys s +func GetPrivateKeyId(s string) (string, error) { + private := true + id := getKeyId(s, private) + if id == "" { + return "", fmt.Errorf("no private key found") + } + return id, nil +} -- cgit