distinguishing public from secret keys with gpgme
Hans-Christoph Steiner
hans at guardianproject.info
Sat May 25 01:55:49 CEST 2013
On 05/24/2013 01:22 PM, Werner Koch wrote:
> 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.
Ah perfect, that was easy. I had assumed that the gnupg-for-java was a lot
more complete than it is. But now its getting more complete :) I hope to
split it out of gnupg-for-android again, so its usable in any java app.
.hc
More information about the Gnupg-devel
mailing list