distinguishing public from secret keys with gpgme
Werner Koch
wk at gnupg.org
Fri May 24 19:22:03 CEST 2013
On Fri, 24 May 2013 18:04, hans at guardianproject.info said:
> Hey all,
>
> Using gpgme 1.4.1, I'm trying to pick out which keys in the keyring have the
> secret component, and can be used for signing and decryption. I've tried:
>
> return key->secret
>
> and
>
> jboolean hasSecretKey = 0;
> gpgme_subkey_t subkey;
> for(subkey = key->subkeys; subkey; subkey = subkey->next)
> if (subkey->secret)
> return 1;
> return 0;
>
> Both of these always turn up false for every key in the keyring. `gpg2
> --list-secret-keys` shows that I have one secret key. What am I missing?
You need to pass true as the last argument to gpgme_op_keylist_start to
list the secret keys. Unfortunately this will only return secret keys
thus if you want to have a combined listing you need to match them.
Shalom-Salam,
Werner
--
Die Gedanken sind frei. Ausnahmen regelt ein Bundesgesetz.
More information about the Gnupg-devel
mailing list