summaryrefslogtreecommitdiff
path: root/lib/crypto/gpg/gpgbin/keys.go
blob: 9c8b233f082eb32e626211a297359bc010087a57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
}

// GetKeyId runs gpg --list-keys s
func GetKeyId(s string) (string, error) {
	private := false
	id := getKeyId(s, private)
	if id == "" {
		return "", fmt.Errorf("no public key found")
	}
	return id, nil
}