LCOV - code coverage report
Current view: top level - tests/gpg - t-keylist-sig.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 126 349 36.1 %
Date: 2016-11-29 15:07:43 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /* t-keylist-sig.c - Regression test.
       2             :    Copyright (C) 2000 Werner Koch (dd9jn)
       3             :    Copyright (C) 2001, 2003, 2004 g10 Code GmbH
       4             : 
       5             :    This file is part of GPGME.
       6             : 
       7             :    GPGME is free software; you can redistribute it and/or modify it
       8             :    under the terms of the GNU Lesser General Public License as
       9             :    published by the Free Software Foundation; either version 2.1 of
      10             :    the License, or (at your option) any later version.
      11             : 
      12             :    GPGME is distributed in the hope that it will be useful, but
      13             :    WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15             :    Lesser General Public License for more details.
      16             : 
      17             :    You should have received a copy of the GNU Lesser General Public
      18             :    License along with this program; if not, write to the Free Software
      19             :    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
      20             :    02111-1307, USA.  */
      21             : 
      22             : /* We need to include config.h so that we know whether we are building
      23             :    with large file system (LFS) support. */
      24             : #ifdef HAVE_CONFIG_H
      25             : #include <config.h>
      26             : #endif
      27             : 
      28             : #include <stdlib.h>
      29             : #include <stdio.h>
      30             : #include <string.h>
      31             : 
      32             : #include <gpgme.h>
      33             : 
      34             : #include "t-support.h"
      35             : 
      36             : 
      37             : struct
      38             : {
      39             :   const char *fpr;
      40             :   const char *sec_keyid;
      41             :   struct
      42             :   {
      43             :     const char *name;
      44             :     const char *comment;
      45             :     const char *email;
      46             :     struct
      47             :     {
      48             :       gpgme_pubkey_algo_t algo;
      49             :       const char *keyid;
      50             :       const char *name;
      51             :       const char *comment;
      52             :       const char *email;
      53             :       unsigned int sig_class;
      54             :       int exportable;
      55             :     } sig;
      56             :   } uid[3];
      57             : }
      58             : keys[] =
      59             :   {
      60             :     { "A0FF4590BB6122EDEF6E3C542D727CC768697734", "6AE6D7EE46A871F8",
      61             :       { { "Alfa Test", "demo key", "alfa@example.net",
      62             :           { GPGME_PK_DSA, "2D727CC768697734",
      63             :             "Alfa Test", "demo key", "alfa@example.net", 19, 1 } },
      64             :         { "Alpha Test", "demo key", "alpha@example.net",
      65             :           { GPGME_PK_DSA, "2D727CC768697734",
      66             :             "Alfa Test", "demo key", "alfa@example.net", 19, 1 } },
      67             :         { "Alice", "demo key", NULL,
      68             :           { GPGME_PK_DSA, "2D727CC768697734",
      69             :             "Alfa Test", "demo key", "alfa@example.net", 19, 1 } } } },
      70             :     { NULL }
      71             :   };
      72             : 
      73             : 
      74             : int
      75           1 : main (void)
      76             : {
      77             :   gpgme_error_t err;
      78             :   gpgme_ctx_t ctx;
      79             :   gpgme_key_t key;
      80             :   gpgme_keylist_result_t result;
      81             :   int mode;
      82           1 :   int i = 0;
      83             : 
      84           1 :   init_gpgme (GPGME_PROTOCOL_OpenPGP);
      85             : 
      86           1 :   err = gpgme_new (&ctx);
      87           1 :   fail_if_err (err);
      88             : 
      89           1 :   mode  = gpgme_get_keylist_mode (ctx);
      90           1 :   mode |= GPGME_KEYLIST_MODE_SIGS;
      91           1 :   err = gpgme_set_keylist_mode (ctx, mode);
      92           1 :   fail_if_err (err);
      93             : 
      94           1 :   err = gpgme_op_keylist_start (ctx, "Alpha", 0);
      95           1 :   fail_if_err (err);
      96             : 
      97           3 :   while (!(err = gpgme_op_keylist_next (ctx, &key)))
      98             :     {
      99           1 :       if (!keys[i].fpr)
     100             :         {
     101           0 :           fprintf (stderr, "More keys returned than expected\n");
     102           0 :           exit (1);
     103             :         }
     104             : 
     105             :       /* Global key flags.  */
     106           1 :       if (key->revoked)
     107             :         {
     108           0 :           fprintf (stderr, "Key unexpectedly revoked\n");
     109           0 :           exit (1);
     110             :         }
     111           1 :       if (key->expired)
     112             :         {
     113           0 :           fprintf (stderr, "Key unexpectedly expired\n");
     114           0 :           exit (1);
     115             :         }
     116           1 :       if (key->disabled)
     117             :         {
     118           0 :           fprintf (stderr, "Key unexpectedly disabled\n");
     119           0 :           exit (1);
     120             :         }
     121           1 :       if (key->invalid)
     122             :         {
     123           0 :           fprintf (stderr, "Key unexpectedly invalid\n");
     124           0 :           exit (1);
     125             :         }
     126           1 :       if (!key->can_encrypt)
     127             :         {
     128           0 :           fprintf (stderr, "Key unexpectedly unusable for encryption\n");
     129           0 :           exit (1);
     130             :         }
     131           1 :       if (!key->can_sign)
     132             :         {
     133           0 :           fprintf (stderr, "Key unexpectedly unusable for signing\n");
     134           0 :           exit (1);
     135             :         }
     136           1 :       if (!key->can_certify)
     137             :         {
     138           0 :           fprintf (stderr, "Key unexpectedly unusable for certifications\n");
     139           0 :           exit (1);
     140             :         }
     141           1 :       if (key->secret)
     142             :         {
     143           0 :           fprintf (stderr, "Key unexpectedly secret\n");
     144           0 :           exit (1);
     145             :         }
     146           1 :       if (key->protocol != GPGME_PROTOCOL_OpenPGP)
     147             :         {
     148           0 :           fprintf (stderr, "Key has unexpected protocol: %s\n",
     149           0 :                    gpgme_get_protocol_name (key->protocol));
     150           0 :           exit (1);
     151             :         }
     152           1 :       if (key->issuer_serial)
     153             :         {
     154           0 :           fprintf (stderr, "Key unexpectedly carries issuer serial: %s\n",
     155           0 :                    key->issuer_serial);
     156           0 :           exit (1);
     157             :         }
     158           1 :       if (key->issuer_name)
     159             :         {
     160           0 :           fprintf (stderr, "Key unexpectedly carries issuer name: %s\n",
     161           0 :                    key->issuer_name);
     162           0 :           exit (1);
     163             :         }
     164           1 :       if (key->chain_id)
     165             :         {
     166           0 :           fprintf (stderr, "Key unexpectedly carries chain ID: %s\n",
     167           0 :                    key->chain_id);
     168           0 :           exit (1);
     169             :         }
     170           1 :       if (key->owner_trust != GPGME_VALIDITY_UNKNOWN)
     171             :         {
     172           0 :           fprintf (stderr, "Key has unexpected owner trust: %i\n",
     173           0 :                    key->owner_trust);
     174           0 :           exit (1);
     175             :         }
     176           1 :       if (!key->subkeys || !key->subkeys->next || key->subkeys->next->next)
     177             :         {
     178           0 :           fprintf (stderr, "Key has unexpected number of subkeys\n");
     179           0 :           exit (1);
     180             :         }
     181             : 
     182             :       /* Primary key.  */
     183           1 :       if (key->subkeys->revoked)
     184             :         {
     185           0 :           fprintf (stderr, "Primary key unexpectedly revoked\n");
     186           0 :           exit (1);
     187             :         }
     188           1 :       if (key->subkeys->expired)
     189             :         {
     190           0 :           fprintf (stderr, "Primary key unexpectedly expired\n");
     191           0 :           exit (1);
     192             :         }
     193           1 :       if (key->subkeys->disabled)
     194             :         {
     195           0 :           fprintf (stderr, "Primary key unexpectedly disabled\n");
     196           0 :           exit (1);
     197             :         }
     198           1 :       if (key->subkeys->invalid)
     199             :         {
     200           0 :           fprintf (stderr, "Primary key unexpectedly invalid\n");
     201           0 :           exit (1);
     202             :         }
     203           1 :       if (key->subkeys->can_encrypt)
     204             :         {
     205           0 :           fprintf (stderr, "Primary key unexpectedly usable for encryption\n");
     206           0 :           exit (1);
     207             :         }
     208           1 :       if (!key->subkeys->can_sign)
     209             :         {
     210           0 :           fprintf (stderr, "Primary key unexpectedly unusable for signing\n");
     211           0 :           exit (1);
     212             :         }
     213           1 :       if (!key->subkeys->can_certify)
     214             :         {
     215           0 :           fprintf (stderr, "Primary key unexpectedly unusable for certifications\n");
     216           0 :           exit (1);
     217             :         }
     218           1 :       if (key->subkeys->secret)
     219             :         {
     220           0 :           fprintf (stderr, "Primary key unexpectedly secret\n");
     221           0 :           exit (1);
     222             :         }
     223           1 :       if (key->subkeys->pubkey_algo != GPGME_PK_DSA)
     224             :         {
     225           0 :           fprintf (stderr, "Primary key has unexpected public key algo: %s\n",
     226           0 :                    gpgme_pubkey_algo_name (key->subkeys->pubkey_algo));
     227           0 :           exit (1);
     228             :         }
     229           1 :       if (key->subkeys->length != 1024)
     230             :         {
     231           0 :           fprintf (stderr, "Primary key has unexpected length: %i\n",
     232           0 :                    key->subkeys->length);
     233           0 :           exit (1);
     234             :         }
     235           1 :       if (strcmp (key->subkeys->keyid, &keys[i].fpr[40 - 16]))
     236             :         {
     237           0 :           fprintf (stderr, "Primary key has unexpected key ID: %s\n",
     238           0 :                    key->subkeys->keyid);
     239           0 :           exit (1);
     240             :         }
     241           1 :       if (strcmp (key->subkeys->fpr, keys[i].fpr))
     242             :         {
     243           0 :           fprintf (stderr, "Primary key has unexpected fingerprint: %s\n",
     244           0 :                    key->subkeys->fpr);
     245           0 :           exit (1);
     246             :         }
     247           1 :       if (key->subkeys->expires)
     248             :         {
     249           0 :           fprintf (stderr, "Primary key unexpectedly expires: %lu\n",
     250           0 :                    key->subkeys->expires);
     251           0 :           exit (1);
     252             :         }
     253             : 
     254             :       /* Secondary key.  */
     255           1 :       if (key->subkeys->next->revoked)
     256             :         {
     257           0 :           fprintf (stderr, "Secondary key unexpectedly revoked\n");
     258           0 :           exit (1);
     259             :         }
     260           1 :       if (key->subkeys->next->expired)
     261             :         {
     262           0 :           fprintf (stderr, "Secondary key unexpectedly expired\n");
     263           0 :           exit (1);
     264             :         }
     265           1 :       if (key->subkeys->next->disabled)
     266             :         {
     267           0 :           fprintf (stderr, "Secondary key unexpectedly disabled\n");
     268           0 :           exit (1);
     269             :         }
     270           1 :       if (key->subkeys->next->invalid)
     271             :         {
     272           0 :           fprintf (stderr, "Secondary key unexpectedly invalid\n");
     273           0 :           exit (1);
     274             :         }
     275           1 :       if (!key->subkeys->next->can_encrypt)
     276             :         {
     277           0 :           fprintf (stderr, "Secondary key unexpectedly unusable for encryption\n");
     278           0 :           exit (1);
     279             :         }
     280           1 :       if (key->subkeys->next->can_sign)
     281             :         {
     282           0 :           fprintf (stderr, "Secondary key unexpectedly usable for signing\n");
     283           0 :           exit (1);
     284             :         }
     285           1 :       if (key->subkeys->next->can_certify)
     286             :         {
     287           0 :           fprintf (stderr, "Secondary key unexpectedly usable for certifications\n");
     288           0 :           exit (1);
     289             :         }
     290           1 :       if (key->subkeys->next->secret)
     291             :         {
     292           0 :           fprintf (stderr, "Secondary key unexpectedly secret\n");
     293           0 :           exit (1);
     294             :         }
     295           1 :       if (key->subkeys->next->pubkey_algo != GPGME_PK_ELG_E)
     296             :         {
     297           0 :           fprintf (stderr, "Secondary key has unexpected public key algo: %s\n",
     298           0 :                    gpgme_pubkey_algo_name (key->subkeys->next->pubkey_algo));
     299           0 :           exit (1);
     300             :         }
     301           1 :       if (key->subkeys->next->length != 1024)
     302             :         {
     303           0 :           fprintf (stderr, "Secondary key has unexpected length: %i\n",
     304           0 :                    key->subkeys->next->length);
     305           0 :           exit (1);
     306             :         }
     307           1 :       if (strcmp (key->subkeys->next->keyid, keys[i].sec_keyid))
     308             :         {
     309           0 :           fprintf (stderr, "Secondary key has unexpected key ID: %s\n",
     310           0 :                    key->subkeys->next->keyid);
     311           0 :           exit (1);
     312             :         }
     313           1 :       if (!key->subkeys->next->fpr)
     314             :         {
     315           0 :           fprintf (stderr, "Secondary key has unexpectedly no fingerprint\n");
     316           0 :           exit (1);
     317             :         }
     318           1 :       if (key->subkeys->next->expires)
     319             :         {
     320           0 :           fprintf (stderr, "Secondary key unexpectedly expires: %lu\n",
     321           0 :                    key->subkeys->next->expires);
     322           0 :           exit (1);
     323             :         }
     324             : 
     325             :       /* FIXME: The below test will crash if we want to check for a
     326             :          name, comment or email that doesn't exist in the key's user
     327             :          IDs.  */
     328           2 :       if (!((!keys[i].uid[0].name && !key->uids)
     329           1 :             || (keys[i].uid[0].name && !keys[i].uid[1].name
     330           0 :                 && key->uids && !key->uids->next)
     331           1 :             || (keys[i].uid[0].name && keys[i].uid[1].name
     332           1 :                 && !keys[i].uid[2].name
     333           0 :                 && key->uids && key->uids->next && !key->uids->next->next)
     334           2 :             || (keys[i].uid[0].name && keys[i].uid[1].name
     335           1 :                 && keys[i].uid[2].name
     336           1 :                 && key->uids && key->uids->next && key->uids->next->next
     337           1 :                 && !key->uids->next->next->next)))
     338             :           {
     339           0 :             fprintf (stderr, "Key has unexpected number of user IDs\n");
     340           0 :             exit (1);
     341             :           }
     342           1 :       if (key->uids && key->uids->revoked)
     343             :         {
     344           0 :           fprintf (stderr, "First user ID unexpectedly revoked\n");
     345           0 :           exit (1);
     346             :         }
     347           1 :       if (key->uids && key->uids->invalid)
     348             :         {
     349           0 :           fprintf (stderr, "First user ID unexpectedly invalid\n");
     350           0 :           exit (1);
     351             :         }
     352           1 :       if (key->uids && key->uids->validity != GPGME_VALIDITY_UNKNOWN)
     353             :         {
     354           0 :           fprintf (stderr, "First user ID has unexpectedly validity: %i\n",
     355           0 :                    key->uids->validity);
     356           0 :           exit (1);
     357             :         }
     358           1 :       if (keys[i].uid[0].name
     359           1 :           && strcmp (keys[i].uid[0].name, key->uids->name))
     360             :         {
     361           0 :           fprintf (stderr, "Unexpected name in first user ID: %s\n",
     362           0 :                    key->uids->name);
     363           0 :           exit (1);
     364             :         }
     365           1 :       if (keys[i].uid[0].comment
     366           1 :           && strcmp (keys[i].uid[0].comment, key->uids->comment))
     367             :         {
     368           0 :           fprintf (stderr, "Unexpected comment in first user ID: %s\n",
     369           0 :                    key->uids->comment);
     370           0 :           exit (1);
     371             :         }
     372           1 :       if (keys[i].uid[0].email
     373           1 :           && strcmp (keys[i].uid[0].email, key->uids->email))
     374             :         {
     375           0 :           fprintf (stderr, "Unexpected email in first user ID: %s\n",
     376           0 :                    key->uids->email);
     377           0 :           exit (1);
     378             :         }
     379           1 :       if (key->uids && (!key->uids->signatures || key->uids->signatures->next))
     380             :         {
     381           0 :           fprintf (stderr, "First user ID unexpected number of signatures\n");
     382           0 :           exit (1);
     383             :         }
     384           1 :       if (keys[i].uid[0].sig.algo != key->uids->signatures->pubkey_algo)
     385             :         {
     386           0 :           fprintf (stderr, "Unexpected algorithm in first user ID sig: %s\n",
     387           0 :                    gpgme_pubkey_algo_name (key->uids->signatures->pubkey_algo));
     388           0 :           exit (1);
     389             :         }
     390           1 :       if (strcmp (keys[i].uid[0].sig.keyid, key->uids->signatures->keyid))
     391             :         {
     392           0 :           fprintf (stderr, "Unexpected key ID in first user ID sig: %s\n",
     393           0 :                    key->uids->signatures->keyid);
     394           0 :           exit (1);
     395             :         }
     396           1 :       if (strcmp (keys[i].uid[0].sig.name, key->uids->signatures->name))
     397             :         {
     398           0 :           fprintf (stderr, "Unexpected name in first user ID sig: %s\n",
     399           0 :                    key->uids->signatures->name);
     400           0 :           exit (1);
     401             :         }
     402           1 :       if (strcmp (keys[i].uid[0].sig.comment, key->uids->signatures->comment))
     403             :         {
     404           0 :           fprintf (stderr, "Unexpected comment in first user ID sig: %s\n",
     405           0 :                    key->uids->signatures->comment);
     406           0 :           exit (1);
     407             :         }
     408           1 :       if (strcmp (keys[i].uid[0].sig.email, key->uids->signatures->email))
     409             :         {
     410           0 :           fprintf (stderr, "Unexpected email in first user ID sig: %s\n",
     411           0 :                    key->uids->signatures->email);
     412           0 :           exit (1);
     413             :         }
     414           1 :       if (keys[i].uid[0].sig.sig_class != key->uids->signatures->sig_class)
     415             :         {
     416           0 :           fprintf (stderr, "Unexpected class in first user ID sig: %i\n",
     417           0 :                    key->uids->signatures->sig_class);
     418           0 :           exit (1);
     419             :         }
     420           1 :       if (keys[i].uid[0].sig.exportable != key->uids->signatures->exportable)
     421             :         {
     422           0 :           fprintf (stderr, "Unexpected exportable stat in first user ID sig: %i\n",
     423           0 :                    key->uids->signatures->exportable);
     424           0 :           exit (1);
     425             :         }
     426             : 
     427           1 :       if (key->uids && key->uids->next && key->uids->next->revoked)
     428             :         {
     429           0 :           fprintf (stderr, "Second user ID unexpectedly revoked\n");
     430           0 :           exit (1);
     431             :         }
     432           1 :       if (key->uids && key->uids->next && key->uids->next->invalid)
     433             :         {
     434           0 :           fprintf (stderr, "Second user ID unexpectedly invalid\n");
     435           0 :           exit (1);
     436             :         }
     437           1 :       if (key->uids && key->uids->next
     438           1 :           && key->uids->next->validity != GPGME_VALIDITY_UNKNOWN)
     439             :         {
     440           0 :           fprintf (stderr, "Second user ID has unexpectedly validity: %i\n",
     441           0 :                    key->uids->next->validity);
     442           0 :           exit (1);
     443             :         }
     444           1 :       if (keys[i].uid[1].name
     445           1 :           && strcmp (keys[i].uid[1].name, key->uids->next->name))
     446             :         {
     447           0 :           fprintf (stderr, "Unexpected name in second user ID: %s\n",
     448           0 :                    key->uids->next->name);
     449           0 :           exit (1);
     450             :         }
     451           1 :       if (keys[i].uid[1].comment
     452           1 :           && strcmp (keys[i].uid[1].comment, key->uids->next->comment))
     453             :         {
     454           0 :           fprintf (stderr, "Unexpected comment in second user ID: %s\n",
     455           0 :                    key->uids->next->comment);
     456           0 :           exit (1);
     457             :         }
     458           1 :       if (keys[i].uid[1].email
     459           1 :           && strcmp (keys[i].uid[1].email, key->uids->next->email))
     460             :         {
     461           0 :           fprintf (stderr, "Unexpected email in second user ID: %s\n",
     462           0 :                    key->uids->next->email);
     463           0 :           exit (1);
     464             :         }
     465             :       /* Note: There is a bug in gpg 1.3.4 which duplicates a
     466             :          signature after importing the secret key.  Thus we disable
     467             :          the second part of the check. */
     468           1 :       if (key->uids && (!key->uids->next->signatures /*|| key->uids->next->signatures->next*/))
     469             :         {
     470           0 :           fprintf (stderr, "Second user ID unexpected number of signatures\n");
     471           0 :           exit (1);
     472             :         }
     473           1 :       if (keys[i].uid[1].sig.algo != key->uids->next->signatures->pubkey_algo)
     474             :         {
     475           0 :           fprintf (stderr, "Unexpected algorithm in second user ID sig: %s\n",
     476           0 :                    gpgme_pubkey_algo_name (key->uids->next->signatures->pubkey_algo));
     477           0 :           exit (1);
     478             :         }
     479           1 :       if (strcmp (keys[i].uid[1].sig.keyid, key->uids->next->signatures->keyid))
     480             :         {
     481           0 :           fprintf (stderr, "Unexpected key ID in second user ID sig: %s\n",
     482           0 :                    key->uids->next->signatures->keyid);
     483           0 :           exit (1);
     484             :         }
     485           1 :       if (strcmp (keys[i].uid[1].sig.name, key->uids->next->signatures->name))
     486             :         {
     487           0 :           fprintf (stderr, "Unexpected name in second user ID sig: %s\n",
     488           0 :                    key->uids->next->signatures->name);
     489           0 :           exit (1);
     490             :         }
     491           1 :       if (strcmp (keys[i].uid[1].sig.comment, key->uids->next->signatures->comment))
     492             :         {
     493           0 :           fprintf (stderr, "Unexpected comment in second user ID sig: %s\n",
     494           0 :                    key->uids->next->signatures->comment);
     495           0 :           exit (1);
     496             :         }
     497           1 :       if (strcmp (keys[i].uid[1].sig.email, key->uids->next->signatures->email))
     498             :         {
     499           0 :           fprintf (stderr, "Unexpected email in second user ID sig: %s\n",
     500           0 :                    key->uids->next->signatures->email);
     501           0 :           exit (1);
     502             :         }
     503           1 :       if (keys[i].uid[1].sig.sig_class != key->uids->next->signatures->sig_class)
     504             :         {
     505           0 :           fprintf (stderr, "Unexpected class in second user ID sig: %i\n",
     506           0 :                    key->uids->next->signatures->sig_class);
     507           0 :           exit (1);
     508             :         }
     509           1 :       if (keys[i].uid[1].sig.exportable != key->uids->next->signatures->exportable)
     510             :         {
     511           0 :           fprintf (stderr, "Unexpected exportable stat in second user ID sig: %i\n",
     512           0 :                    key->uids->next->signatures->exportable);
     513           0 :           exit (1);
     514             :         }
     515             : 
     516           1 :       if (key->uids && key->uids->next && key->uids->next->next
     517           1 :           && key->uids->next->next->revoked)
     518             :         {
     519           0 :           fprintf (stderr, "Third user ID unexpectedly revoked\n");
     520           0 :           exit (1);
     521             :         }
     522           1 :       if (key->uids && key->uids->next && key->uids->next->next
     523           1 :           && key->uids->next->next->invalid)
     524             :         {
     525           0 :           fprintf (stderr, "Third user ID unexpectedly invalid\n");
     526           0 :           exit (1);
     527             :         }
     528           1 :       if (key->uids && key->uids->next && key->uids->next->next
     529           1 :           && key->uids->next->next->validity != GPGME_VALIDITY_UNKNOWN)
     530             :         {
     531           0 :           fprintf (stderr, "Third user ID has unexpectedly validity: %i\n",
     532           0 :                    key->uids->next->next->validity);
     533           0 :           exit (1);
     534             :         }
     535           1 :       if (keys[i].uid[2].name
     536           1 :           && strcmp (keys[i].uid[2].name, key->uids->next->next->name))
     537             :         {
     538           0 :           fprintf (stderr, "Unexpected name in third user ID: %s\n",
     539           0 :                    key->uids->next->next->name);
     540           0 :           exit (1);
     541             :         }
     542           1 :       if (keys[i].uid[2].comment
     543           1 :           && strcmp (keys[i].uid[2].comment, key->uids->next->next->comment))
     544             :         {
     545           0 :           fprintf (stderr, "Unexpected comment in third user ID: %s\n",
     546           0 :                    key->uids->next->next->comment);
     547           0 :           exit (1);
     548             :         }
     549           1 :       if (keys[i].uid[2].email
     550           0 :           && strcmp (keys[i].uid[2].email, key->uids->next->next->email))
     551             :         {
     552           0 :           fprintf (stderr, "Unexpected email in third user ID: %s\n",
     553           0 :                    key->uids->next->next->email);
     554           0 :           exit (1);
     555             :         }
     556           1 :       if (key->uids && (!key->uids->next->next->signatures
     557           1 :                         || key->uids->next->next->signatures->next))
     558             :         {
     559           0 :           fprintf (stderr, "Third user ID unexpected number of signatures\n");
     560           0 :           exit (1);
     561             :         }
     562           1 :       if (keys[i].uid[2].sig.algo != key->uids->next->next->signatures->pubkey_algo)
     563             :         {
     564           0 :           fprintf (stderr, "Unexpected algorithm in third user ID sig: %s\n",
     565           0 :                    gpgme_pubkey_algo_name (key->uids->next->next->signatures->pubkey_algo));
     566           0 :           exit (1);
     567             :         }
     568           1 :       if (strcmp (keys[i].uid[2].sig.keyid, key->uids->next->next->signatures->keyid))
     569             :         {
     570           0 :           fprintf (stderr, "Unexpected key ID in third user ID sig: %s\n",
     571           0 :                    key->uids->next->next->signatures->keyid);
     572           0 :           exit (1);
     573             :         }
     574           1 :       if (strcmp (keys[i].uid[2].sig.name, key->uids->next->next->signatures->name))
     575             :         {
     576           0 :           fprintf (stderr, "Unexpected name in third user ID sig: %s\n",
     577           0 :                    key->uids->next->next->signatures->name);
     578           0 :           exit (1);
     579             :         }
     580           1 :       if (strcmp (keys[i].uid[2].sig.comment, key->uids->next->next->signatures->comment))
     581             :         {
     582           0 :           fprintf (stderr, "Unexpected comment in third user ID sig: %s\n",
     583           0 :                    key->uids->next->next->signatures->comment);
     584           0 :           exit (1);
     585             :         }
     586           1 :       if (strcmp (keys[i].uid[2].sig.email, key->uids->next->next->signatures->email))
     587             :         {
     588           0 :           fprintf (stderr, "Unexpected email in third user ID sig: %s\n",
     589           0 :                    key->uids->next->next->signatures->email);
     590           0 :           exit (1);
     591             :         }
     592           1 :       if (keys[i].uid[2].sig.sig_class != key->uids->next->next->signatures->sig_class)
     593             :         {
     594           0 :           fprintf (stderr, "Unexpected class in third user ID sig: %i\n",
     595           0 :                    key->uids->next->next->signatures->sig_class);
     596           0 :           exit (1);
     597             :         }
     598           1 :       if (keys[i].uid[2].sig.exportable != key->uids->next->next->signatures->exportable)
     599             :         {
     600           0 :           fprintf (stderr, "Unexpected exportable stat in third user ID sig: %i\n",
     601           0 :                    key->uids->next->next->signatures->exportable);
     602           0 :           exit (1);
     603             :         }
     604             : 
     605           1 :       gpgme_key_unref (key);
     606           1 :       i++;
     607             :     }
     608           1 :   if (gpgme_err_code (err) != GPG_ERR_EOF)
     609           0 :     fail_if_err (err);
     610           1 :   err = gpgme_op_keylist_end (ctx);
     611           1 :   fail_if_err (err);
     612             : 
     613           1 :   result = gpgme_op_keylist_result (ctx);
     614           1 :   if (result->truncated)
     615             :     {
     616           0 :       fprintf (stderr, "Key listing unexpectedly truncated\n");
     617           0 :       exit (1);
     618             :     }
     619             : 
     620           1 :   if (keys[i].fpr)
     621             :     {
     622           0 :       fprintf (stderr, "Less keys returned than expected\n");
     623           0 :       exit (1);
     624             :     }
     625             : 
     626           1 :   gpgme_release (ctx);
     627           1 :   return 0;
     628             : }

Generated by: LCOV version 1.11