[issue132] gpgme_op_keylist_ext_start (CMS) fails to return any key if one of the patterns given is an OpenPGP fingerprint

Marc Mutz <[email protected]>
Newsgroups gmane.comp.encryption.gpg.gpa.devel
Message-ID <[email protected]>
New submission from Marc Mutz <[email protected]>:

The equivalent gpgsm command line works, though: 
 
$ gpgsm --list-secret-keys <S/MIME-KEY fingerprint> <OpenPGP-key fingerprint> 
<lists the S/MIME key only, doesn't return an error> 
 
compare this to 
 
$./test_gpgme_secret_keylisting <S/MIME-key fingerprint> <OpenPGP-key fpr> 
<lists nothing> 
$./test_gpgme_secret_keylisting <S/MIME-key fingerprint> (only that) 
<lists S/MIME key> 
 
The same thing on a context set to GPGME_PROTOCOL_OpenPGP works (ie. returns 
the OpenPGP key, ignores the S/MIME fingerprint). This is the expected result. 
Anything else makes op_keylist useless for looking up keys by person or email. 
 
Test app (code from info gpgme, adjusted to use _ext_, CMS, and argv, as well 
as to make it compile :P) attached.

----------
assignedto: werner
files: test_gpgme_secret_keylisting.c
messages: 608
nosy: marc, werner
priority: urgent
status: unread
title: gpgme_op_keylist_ext_start (CMS) fails to return any key if one of the patterns given is an OpenPGP fingerprint
topic: GPGME
______________________________________________________
Aegypten issue tracker <[email protected]>
<https://intevation.de/roundup/aegypten/issue132>
______________________________________________________

_______________________________________________
Gpa-dev mailing list
[email protected]
http://lists.gnupg.org/mailman/listinfo/gpa-dev
test_gpgme_secret_keylisting.c (text/x-csrc, 1.1 KB)
#include <gpgme.h>
#include <stdio.h>
#include <string.h>

int main( int argc, char ** argv ) {
     gpgme_ctx_t ctx;
     gpgme_key_t key;
     gpgme_error_t err = gpgme_new (&ctx);

     if ( err )
       return 1;

     err = gpgme_set_protocol( ctx, GPGME_PROTOCOL_CMS );

     if ( err )
       return 2;

     if ( argc < 2 )
       return 3;

     char ** what = (char**)malloc( argc * sizeof( char * ) );
     memset( what, 0, argc * sizeof( char * ) );
     memcpy( what, argv + 1, (argc - 1) * sizeof( char * ) );

     if (!err)
       {
         err = gpgme_op_keylist_ext_start (ctx, (const char**)what, 1, 0);
         while (!err)
           {
             err = gpgme_op_keylist_next (ctx, &key);
             if (err)
               break;
             printf ("%s: %s <%s>\n", key->subkeys->fpr, key->uids->name, key->uids->email);
             gpgme_key_release (key);
           }
         gpgme_release (ctx);
       }
     if (gpg_err_code (err) != GPG_ERR_EOF)
       {
         fprintf (stderr, "%s: can not list keys: %s\n",
                  argv[0], gpgme_strerror (err));
         exit (1);
       }

     return 0;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.