gpgme list secret keys

Matthijs Mohlmann matthijs at cacholong.nl
Wed Apr 27 10:06:15 CEST 2005


harry_b at mm.st wrote:
> Hi Matthijs,
>
> I am also fuzzing around with gpgme and its quite troublesome at some
> points.
> If you find a solution for this issue I'd like to know how you solved
> it. :-)
>
> In case you'd let me know how I'd greatly appreciate it!!
>
> TIA & cheers!
> Harry
>
I found out :)

(list is a GList *)

Here a code example how i use it:
   // Gpgme vars
   gpgme_ctx_t ctx;
   gpgme_error_t err = gpgme_new(&ctx);
   gpgme_key_t key;

   if (!err) {
     err = gpgme_op_keylist_start(ctx, NULL, secret);
     while (!(err = gpgme_op_keylist_next(ctx, &key))) {
       if (key->subkeys->secret) {
         // Add only the public keys to the list
         gaim_debug(GAIM_DEBUG_MISC, "gaim-gnupg", "Something going
wrong!\n");         list = g_list_append(list, key->uids->uid);
         list = g_list_append(list, key->subkeys->keyid);
       } else {
         // Add only the secret keys to the list
         gaim_debug(GAIM_DEBUG_MISC, "gaim-gnupg", "%s: %s\n",
key->subkeys->keyid, key->uids->uid);
         list = g_list_append(list, key->uids->uid);
         list = g_list_append(list, key->subkeys->keyid);
       }
     }
     gpgme_release(ctx);


>
> --On Sunday, April 24, 2005 22:11:01 +0200 Matthijs Mohlmann
> <matthijs at cacholong.nl> wrote:
>
>> I'm trying to write a plugin for gaim to get GPG encryption support in
>> gaim. Now i came across the following. I want the user to choose their
>> secret key. How can i do this ? I have the following piece of code and
>> read the documentation several times but it seems impossible (i think i
>> misread the documentation)
>>
>>   if (!err) {
>>     err = gpgme_op_keylist_start(ctx, NULL, 0);
>>     while (!err) {
>>       uid = key->uids;
>>       subkey = key->subkeys;
>>       printf("%s: %s <%s>\n", subkey->keyid, uid->name, uid->email);
>>       err = gpgme_op_keylist_next(ctx, &key);
>>     }
>>     gpgme_release(ctx);
>>   }
>>
>> Problem with this code is that i don't have a "key" at that moment
>> available. So i have to do something else.. but how can i do that ?
>>
>> I hope you can help me.

I hope it will work for you :)

Regards,

Matthijs Mohlmann
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : /pipermail/attachments/20050427/ac867111/signature.pgp


More information about the Gnupg-users mailing list