start_new_gpg_agent:
  609|     11|{
  610|     11|  return start_new_service (r_ctx, GNUPG_MODULE_NAME_AGENT,
  ------------------
  |  |  286|     11|#define GNUPG_MODULE_NAME_AGENT        1
  ------------------
  611|     11|                            errsource, agent_program,
  612|     11|                            opt_lc_ctype, opt_lc_messages, session_env,
  613|     11|                            autostart, verbose, debug,
  614|     11|                            status_cb, status_cb_arg);
  615|     11|}
asshelp.c:start_new_service:
  392|     11|{
  393|     11|  gpg_error_t err;
  394|     11|  assuan_context_t ctx;
  395|     11|  int did_success_msg = 0;
  396|     11|  char *sockname;
  397|     11|  const char *printed_name;
  398|     11|  const char *lock_name;
  399|     11|  const char *status_start_line;
  400|     11|  int no_service_err;
  401|     11|  int seconds_to_wait;
  402|     11|  unsigned int connect_flags = 0;
  403|     11|  const char *argv[6];
  404|       |
  405|     11|  *r_ctx = NULL;
  406|       |
  407|     11|  err = assuan_new (&ctx);
  408|     11|  if (err)
  ------------------
  |  Branch (408:7): [True: 0, False: 11]
  ------------------
  409|      0|    {
  410|      0|      log_error ("error allocating assuan context: %s\n", gpg_strerror (err));
  411|      0|      return err;
  412|      0|    }
  413|       |
  414|     11|  switch (module_name_id)
  415|     11|    {
  416|     11|    case GNUPG_MODULE_NAME_AGENT:
  ------------------
  |  |  286|     11|#define GNUPG_MODULE_NAME_AGENT        1
  ------------------
  |  Branch (416:5): [True: 11, False: 0]
  ------------------
  417|     11|      sockname = make_filename (gnupg_socketdir (), GPG_AGENT_SOCK_NAME, NULL);
  ------------------
  |  |  146|     11|#define GPG_AGENT_SOCK_NAME "S.gpg-agent"
  ------------------
  418|     11|      lock_name = "agent";
  419|     11|      printed_name = "gpg-agent";
  420|     11|      status_start_line = "starting_agent ? 0 0";
  421|     11|      no_service_err = GPG_ERR_NO_AGENT;
  422|     11|      seconds_to_wait = SECS_TO_WAIT_FOR_AGENT;
  ------------------
  |  |   57|     11|#define SECS_TO_WAIT_FOR_AGENT 5
  ------------------
  423|     11|      break;
  424|      0|    case GNUPG_MODULE_NAME_DIRMNGR:
  ------------------
  |  |  289|      0|#define GNUPG_MODULE_NAME_DIRMNGR      4
  ------------------
  |  Branch (424:5): [True: 0, False: 11]
  ------------------
  425|      0|      sockname = make_filename (gnupg_socketdir (), DIRMNGR_SOCK_NAME, NULL);
  ------------------
  |  |   64|      0|#define DIRMNGR_SOCK_NAME "S.dirmngr"
  ------------------
  426|      0|      lock_name = "dirmngr";
  427|      0|      printed_name = "dirmngr";
  428|      0|      status_start_line = "starting_dirmngr ? 0 0";
  429|      0|      no_service_err = GPG_ERR_NO_DIRMNGR;
  430|      0|      seconds_to_wait = SECS_TO_WAIT_FOR_DIRMNGR;
  ------------------
  |  |   59|      0|#define SECS_TO_WAIT_FOR_DIRMNGR 5
  ------------------
  431|      0|      break;
  432|      0|    case GNUPG_MODULE_NAME_KEYBOXD:
  ------------------
  |  |  298|      0|#define GNUPG_MODULE_NAME_KEYBOXD       13
  ------------------
  |  Branch (432:5): [True: 0, False: 11]
  ------------------
  433|      0|      sockname = make_filename (gnupg_socketdir (), KEYBOXD_SOCK_NAME, NULL);
  ------------------
  |  |  650|      0|#define KEYBOXD_SOCK_NAME "S.keyboxd"
  ------------------
  434|      0|      lock_name = "keyboxd";
  435|      0|      printed_name = "keyboxd";
  436|      0|      status_start_line = "starting_keyboxd ? 0 0";
  437|      0|      no_service_err = GPG_ERR_NO_KEYBOXD;
  438|      0|      seconds_to_wait = SECS_TO_WAIT_FOR_KEYBOXD;
  ------------------
  |  |   58|      0|#define SECS_TO_WAIT_FOR_KEYBOXD 5
  ------------------
  439|      0|      connect_flags |= ASSUAN_SOCKET_CONNECT_FDPASSING;
  440|      0|      break;
  441|      0|    default:
  ------------------
  |  Branch (441:5): [True: 0, False: 11]
  ------------------
  442|      0|      err = gpg_error (GPG_ERR_INV_ARG);
  443|      0|      assuan_release (ctx);
  444|      0|      return err;
  445|     11|    }
  446|       |
  447|     11|  err = assuan_socket_connect (ctx, sockname, 0, connect_flags);
  448|     11|  if (err && autostart)
  ------------------
  |  Branch (448:7): [True: 11, False: 0]
  |  Branch (448:14): [True: 0, False: 11]
  ------------------
  449|      0|    {
  450|      0|      char *abs_homedir;
  451|      0|      lock_spawn_t lock;
  ------------------
  |  |   52|      0|# define lock_spawn_t dotlock_t
  ------------------
  452|      0|      char *program = NULL;
  453|      0|      const char *program_arg = NULL;
  454|      0|      char *p;
  455|      0|      const char *s;
  456|      0|      int i;
  457|       |
  458|       |      /* With no success start a new server.  */
  459|      0|      if (!program_name || !*program_name)
  ------------------
  |  Branch (459:11): [True: 0, False: 0]
  |  Branch (459:28): [True: 0, False: 0]
  ------------------
  460|      0|        program_name = gnupg_module_name (module_name_id);
  461|      0|      else if ((s=strchr (program_name, '|')) && s[1] == '-' && s[2]=='-')
  ------------------
  |  Branch (461:16): [True: 0, False: 0]
  |  Branch (461:50): [True: 0, False: 0]
  |  Branch (461:65): [True: 0, False: 0]
  ------------------
  462|      0|        {
  463|       |          /* Hack to insert an additional option on the command line.  */
  464|      0|          program = xtrystrdup (program_name);
  ------------------
  |  |  103|      0|#define xtrystrdup(a)    gcry_strdup ((a))
  ------------------
  465|      0|          if (!program)
  ------------------
  |  Branch (465:15): [True: 0, False: 0]
  ------------------
  466|      0|            {
  467|      0|              gpg_error_t tmperr = gpg_err_make (errsource,
  468|      0|                                                 gpg_err_code_from_syserror ());
  469|      0|              xfree (sockname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  470|      0|              assuan_release (ctx);
  471|      0|              return tmperr;
  472|      0|            }
  473|      0|          p = strchr (program, '|');
  474|      0|          *p++ = 0;
  475|      0|          program_arg = p;
  476|      0|        }
  477|       |
  478|      0|      if (verbose)
  ------------------
  |  Branch (478:11): [True: 0, False: 0]
  ------------------
  479|      0|        log_info (_("no running %s - starting '%s'\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  480|      0|                  printed_name, program_name);
  481|       |
  482|      0|      if (status_cb)
  ------------------
  |  Branch (482:11): [True: 0, False: 0]
  ------------------
  483|      0|        status_cb (status_cb_arg, STATUS_PROGRESS, status_start_line, NULL);
  484|       |
  485|       |      /* We better pass an absolute home directory to the service just
  486|       |       * in case the service does not convert the passed name to an
  487|       |       * absolute one (which it should do).  */
  488|      0|      abs_homedir = make_absfilename_try (gnupg_homedir (), NULL);
  489|      0|      if (!abs_homedir)
  ------------------
  |  Branch (489:11): [True: 0, False: 0]
  ------------------
  490|      0|        {
  491|      0|          gpg_error_t tmperr = gpg_err_make (errsource,
  492|      0|                                             gpg_err_code_from_syserror ());
  493|      0|          log_error ("error building filename: %s\n", gpg_strerror (tmperr));
  494|      0|          xfree (sockname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  495|      0|          assuan_release (ctx);
  496|      0|          xfree (program);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  497|      0|          return tmperr;
  498|      0|        }
  499|       |
  500|      0|      if (fflush (NULL))
  ------------------
  |  Branch (500:11): [True: 0, False: 0]
  ------------------
  501|      0|        {
  502|      0|          gpg_error_t tmperr = gpg_err_make (errsource,
  503|      0|                                             gpg_err_code_from_syserror ());
  504|      0|          log_error ("error flushing pending output: %s\n", strerror (errno));
  505|      0|          xfree (sockname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  506|      0|          assuan_release (ctx);
  507|      0|          xfree (abs_homedir);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  508|      0|          xfree (program);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  509|      0|          return tmperr;
  510|      0|        }
  511|       |
  512|      0|      i = 0;
  513|      0|      argv[i++] = "--homedir";
  514|      0|      argv[i++] = abs_homedir;
  515|      0|      if (module_name_id == GNUPG_MODULE_NAME_AGENT)
  ------------------
  |  |  286|      0|#define GNUPG_MODULE_NAME_AGENT        1
  ------------------
  |  Branch (515:11): [True: 0, False: 0]
  ------------------
  516|      0|        argv[i++] = "--use-standard-socket";
  517|      0|      if (program_arg)
  ------------------
  |  Branch (517:11): [True: 0, False: 0]
  ------------------
  518|      0|        argv[i++] = program_arg;
  519|      0|      argv[i++] = "--daemon";
  520|      0|      argv[i++] = NULL;
  521|       |
  522|      0|      if (!(err = lock_spawning (&lock, gnupg_homedir (), lock_name, verbose))
  ------------------
  |  Branch (522:11): [True: 0, False: 0]
  ------------------
  523|      0|          && assuan_socket_connect (ctx, sockname, 0, connect_flags))
  ------------------
  |  Branch (523:14): [True: 0, False: 0]
  ------------------
  524|      0|        {
  525|       |#ifdef HAVE_W32_SYSTEM
  526|       |          err = gnupg_spawn_process_detached (program? program : program_name,
  527|       |                                              argv, NULL);
  528|       |#else /*!W32*/
  529|      0|          pid_t pid;
  530|       |
  531|      0|          err = gnupg_spawn_process_fd (program? program : program_name,
  ------------------
  |  Branch (531:41): [True: 0, False: 0]
  ------------------
  532|      0|                                        argv, -1, -1, -1, &pid);
  533|      0|          if (!err)
  ------------------
  |  Branch (533:15): [True: 0, False: 0]
  ------------------
  534|      0|            err = gnupg_wait_process (program? program : program_name,
  ------------------
  |  Branch (534:39): [True: 0, False: 0]
  ------------------
  535|      0|                                      pid, 1, NULL);
  536|      0|#endif /*!W32*/
  537|      0|          if (err)
  ------------------
  |  Branch (537:15): [True: 0, False: 0]
  ------------------
  538|      0|            log_error ("failed to start %s '%s': %s\n",
  539|      0|                       printed_name, program? program : program_name,
  ------------------
  |  Branch (539:38): [True: 0, False: 0]
  ------------------
  540|      0|                       gpg_strerror (err));
  541|      0|          else
  542|      0|            err = wait_for_sock (seconds_to_wait, module_name_id,
  543|      0|                                 sockname, connect_flags,
  544|      0|                                 verbose, ctx, &did_success_msg);
  545|      0|        }
  546|       |
  547|      0|      unlock_spawning (&lock, lock_name);
  548|      0|      xfree (abs_homedir);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  549|      0|      xfree (program);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  550|      0|    }
  551|     11|  xfree (sockname);
  ------------------
  |  |  104|     11|#define xfree(a)         gcry_free ((a))
  ------------------
  552|     11|  if (err)
  ------------------
  |  Branch (552:7): [True: 11, False: 0]
  ------------------
  553|     11|    {
  554|     11|      if (autostart || gpg_err_code (err) != GPG_ERR_ASS_CONNECT_FAILED)
  ------------------
  |  Branch (554:11): [True: 0, False: 11]
  |  Branch (554:24): [True: 0, False: 11]
  ------------------
  555|      0|        log_error ("can't connect to the %s: %s\n",
  556|      0|                   printed_name, gpg_strerror (err));
  557|     11|      assuan_release (ctx);
  558|     11|      return gpg_err_make (errsource, no_service_err);
  559|     11|    }
  560|       |
  561|      0|  if (debug && !did_success_msg)
  ------------------
  |  Branch (561:7): [True: 0, False: 0]
  |  Branch (561:16): [True: 0, False: 0]
  ------------------
  562|      0|    log_debug ("connection to the %s established\n", printed_name);
  563|       |
  564|      0|  if (module_name_id == GNUPG_MODULE_NAME_AGENT)
  ------------------
  |  |  286|      0|#define GNUPG_MODULE_NAME_AGENT        1
  ------------------
  |  Branch (564:7): [True: 0, False: 0]
  ------------------
  565|      0|    err = assuan_transact (ctx, "RESET",
  566|      0|                           NULL, NULL, NULL, NULL, NULL, NULL);
  567|       |
  568|      0|  if (!err
  ------------------
  |  Branch (568:7): [True: 0, False: 0]
  ------------------
  569|      0|      && module_name_id == GNUPG_MODULE_NAME_AGENT)
  ------------------
  |  |  286|      0|#define GNUPG_MODULE_NAME_AGENT        1
  ------------------
  |  Branch (569:10): [True: 0, False: 0]
  ------------------
  570|      0|    {
  571|      0|      err = send_pinentry_environment (ctx, errsource,
  572|      0|                                       opt_lc_ctype, opt_lc_messages,
  573|      0|                                       session_env);
  574|      0|      if (gpg_err_code (err) == GPG_ERR_FORBIDDEN
  ------------------
  |  Branch (574:11): [True: 0, False: 0]
  ------------------
  575|      0|          && gpg_err_source (err) == GPG_ERR_SOURCE_GPGAGENT)
  ------------------
  |  Branch (575:14): [True: 0, False: 0]
  ------------------
  576|      0|        {
  577|       |          /* Check whether the agent is in restricted mode.  */
  578|      0|          if (!assuan_transact (ctx, "GETINFO restricted",
  ------------------
  |  Branch (578:15): [True: 0, False: 0]
  ------------------
  579|      0|                                NULL, NULL, NULL, NULL, NULL, NULL))
  580|      0|            {
  581|      0|              if (verbose)
  ------------------
  |  Branch (581:19): [True: 0, False: 0]
  ------------------
  582|      0|                log_info (_("connection to the agent is in restricted mode\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  583|      0|              err = 0;
  584|      0|            }
  585|      0|        }
  586|      0|    }
  587|      0|  if (err)
  ------------------
  |  Branch (587:7): [True: 0, False: 0]
  ------------------
  588|      0|    {
  589|      0|      assuan_release (ctx);
  590|      0|      return err;
  591|      0|    }
  592|       |
  593|      0|  *r_ctx = ctx;
  594|      0|  return 0;
  595|      0|}

gnupg_initialize_compliance:
   82|      1|{
   83|      1|  log_assert (! initialized);
   84|       |
   85|       |  /* We accept both OpenPGP-style and gcrypt-style algorithm ids.
   86|       |   * Assert that they are compatible.  */
   87|      0|  log_assert ((int) GCRY_PK_RSA          == (int) PUBKEY_ALGO_RSA);
   88|      0|  log_assert ((int) GCRY_PK_RSA_E        == (int) PUBKEY_ALGO_RSA_E);
   89|      0|  log_assert ((int) GCRY_PK_RSA_S        == (int) PUBKEY_ALGO_RSA_S);
   90|      0|  log_assert ((int) GCRY_PK_ELG_E        == (int) PUBKEY_ALGO_ELGAMAL_E);
   91|      0|  log_assert ((int) GCRY_PK_DSA          == (int) PUBKEY_ALGO_DSA);
   92|      0|  log_assert ((int) GCRY_PK_ECC          == (int) PUBKEY_ALGO_ECDH);
   93|      0|  log_assert ((int) GCRY_PK_ELG          == (int) PUBKEY_ALGO_ELGAMAL);
   94|      0|  log_assert ((int) GCRY_CIPHER_NONE     == (int) CIPHER_ALGO_NONE);
   95|      0|  log_assert ((int) GCRY_CIPHER_IDEA     == (int) CIPHER_ALGO_IDEA);
   96|      0|  log_assert ((int) GCRY_CIPHER_3DES     == (int) CIPHER_ALGO_3DES);
   97|      0|  log_assert ((int) GCRY_CIPHER_CAST5    == (int) CIPHER_ALGO_CAST5);
   98|      0|  log_assert ((int) GCRY_CIPHER_BLOWFISH == (int) CIPHER_ALGO_BLOWFISH);
   99|      0|  log_assert ((int) GCRY_CIPHER_AES      == (int) CIPHER_ALGO_AES);
  100|      0|  log_assert ((int) GCRY_CIPHER_AES192   == (int) CIPHER_ALGO_AES192);
  101|      0|  log_assert ((int) GCRY_CIPHER_AES256   == (int) CIPHER_ALGO_AES256);
  102|      0|  log_assert ((int) GCRY_CIPHER_TWOFISH  == (int) CIPHER_ALGO_TWOFISH);
  103|      0|  log_assert ((int) GCRY_MD_MD5          == (int) DIGEST_ALGO_MD5);
  104|      0|  log_assert ((int) GCRY_MD_SHA1         == (int) DIGEST_ALGO_SHA1);
  105|      0|  log_assert ((int) GCRY_MD_RMD160       == (int) DIGEST_ALGO_RMD160);
  106|      0|  log_assert ((int) GCRY_MD_SHA256       == (int) DIGEST_ALGO_SHA256);
  107|      0|  log_assert ((int) GCRY_MD_SHA384       == (int) DIGEST_ALGO_SHA384);
  108|      0|  log_assert ((int) GCRY_MD_SHA512       == (int) DIGEST_ALGO_SHA512);
  109|      0|  log_assert ((int) GCRY_MD_SHA224       == (int) DIGEST_ALGO_SHA224);
  110|       |
  111|      0|  switch (gnupg_module_name)
  112|      1|    {
  113|      0|    case GNUPG_MODULE_NAME_GPGSM:
  ------------------
  |  |  292|      0|#define GNUPG_MODULE_NAME_GPGSM         7
  ------------------
  |  Branch (113:5): [True: 0, False: 1]
  ------------------
  114|      1|    case GNUPG_MODULE_NAME_GPG:
  ------------------
  |  |  293|      1|#define GNUPG_MODULE_NAME_GPG           8
  ------------------
  |  Branch (114:5): [True: 1, False: 0]
  ------------------
  115|      1|      break;
  116|       |
  117|      0|    default:
  ------------------
  |  Branch (117:5): [True: 0, False: 1]
  ------------------
  118|      0|      log_assert (!"no policies for this module");
  119|      1|    }
  120|       |
  121|      1|  module = gnupg_module_name;
  122|      1|  initialized = 1;
  123|      1|}

dotlock_create:
  885|      3|{
  886|      3|  static int initialized;
  887|      3|  dotlock_t h;
  888|       |
  889|      3|  if ( !initialized )
  ------------------
  |  Branch (889:8): [True: 1, False: 2]
  ------------------
  890|      1|    {
  891|      1|      atexit (dotlock_remove_lockfiles);
  892|      1|      initialized = 1;
  893|      1|    }
  894|       |
  895|      3|  if ( !file_to_lock )
  ------------------
  |  Branch (895:8): [True: 0, False: 3]
  ------------------
  896|      0|    return NULL;  /* Only initialization was requested.  */
  897|       |
  898|      3|  if (flags)
  ------------------
  |  Branch (898:7): [True: 0, False: 3]
  ------------------
  899|      0|    {
  900|      0|      my_set_errno (EINVAL);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  901|      0|      return NULL;
  902|      0|    }
  903|       |
  904|      3|  h = xtrycalloc (1, sizeof *h);
  ------------------
  |  |   99|      3|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  905|      3|  if (!h)
  ------------------
  |  Branch (905:7): [True: 0, False: 3]
  ------------------
  906|      0|    return NULL;
  907|      3|  h->extra_fd = -1;
  908|       |
  909|      3|  if (never_lock)
  ------------------
  |  Branch (909:7): [True: 0, False: 3]
  ------------------
  910|      0|    {
  911|      0|      h->disable = 1;
  912|      0|      LOCK_all_lockfiles ();
  ------------------
  |  |  424|      0|# define LOCK_all_lockfiles()   do { } while (0)
  |  |  ------------------
  |  |  |  Branch (424:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  913|      0|      h->next = all_lockfiles;
  914|      0|      all_lockfiles = h;
  915|      0|      UNLOCK_all_lockfiles ();
  ------------------
  |  |  425|      0|# define UNLOCK_all_lockfiles() do { } while (0)
  |  |  ------------------
  |  |  |  Branch (425:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  916|      0|      return h;
  917|      0|    }
  918|       |
  919|       |#ifdef HAVE_DOSISH_SYSTEM
  920|       |  return dotlock_create_w32 (h, file_to_lock);
  921|       |#else /*!HAVE_DOSISH_SYSTEM */
  922|      3|  return dotlock_create_unix (h, file_to_lock);
  923|      3|#endif /*!HAVE_DOSISH_SYSTEM*/
  924|      3|}
dotlock_destroy:
  980|      3|{
  981|      3|  dotlock_t hprev, htmp;
  982|       |
  983|      3|  if ( !h )
  ------------------
  |  Branch (983:8): [True: 0, False: 3]
  ------------------
  984|      0|    return;
  985|       |
  986|       |  /* First remove the handle from our global list of all locks. */
  987|      3|  LOCK_all_lockfiles ();
  ------------------
  |  |  424|      3|# define LOCK_all_lockfiles()   do { } while (0)
  |  |  ------------------
  |  |  |  Branch (424:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  988|      3|  for (hprev=NULL, htmp=all_lockfiles; htmp; hprev=htmp, htmp=htmp->next)
  ------------------
  |  Branch (988:40): [True: 1, False: 2]
  ------------------
  989|      1|    if (htmp == h)
  ------------------
  |  Branch (989:9): [True: 1, False: 0]
  ------------------
  990|      1|      {
  991|      1|        if (hprev)
  ------------------
  |  Branch (991:13): [True: 0, False: 1]
  ------------------
  992|      0|          hprev->next = htmp->next;
  993|      1|        else
  994|      1|          all_lockfiles = htmp->next;
  995|      1|        h->next = NULL;
  996|      1|        break;
  997|      1|      }
  998|      3|  UNLOCK_all_lockfiles ();
  ------------------
  |  |  425|      3|# define UNLOCK_all_lockfiles() do { } while (0)
  |  |  ------------------
  |  |  |  Branch (425:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  999|       |
 1000|       |  /* Then destroy the lock. */
 1001|      3|  if (!h->disable)
  ------------------
  |  Branch (1001:7): [True: 3, False: 0]
  ------------------
 1002|      3|    {
 1003|       |#ifdef HAVE_DOSISH_SYSTEM
 1004|       |      dotlock_destroy_w32 (h);
 1005|       |#else /* !HAVE_DOSISH_SYSTEM */
 1006|      3|      dotlock_destroy_unix (h);
 1007|      3|#endif /* HAVE_DOSISH_SYSTEM */
 1008|      3|      xfree (h->lockname);
  ------------------
  |  |  104|      3|#define xfree(a)         gcry_free ((a))
  ------------------
 1009|      3|    }
 1010|      3|  xfree(h);
  ------------------
  |  |  104|      3|#define xfree(a)         gcry_free ((a))
  ------------------
 1011|      3|}
dotlock_take:
 1281|     14|{
 1282|     14|  int ret;
 1283|       |
 1284|     14|  if ( h->disable )
  ------------------
  |  Branch (1284:8): [True: 0, False: 14]
  ------------------
 1285|      0|    return 0; /* Locks are completely disabled.  Return success. */
 1286|       |
 1287|     14|  if ( h->locked )
  ------------------
  |  Branch (1287:8): [True: 0, False: 14]
  ------------------
 1288|      0|    {
 1289|      0|      my_debug_1 ("Oops, '%s' is already locked\n", h->lockname);
  ------------------
  |  |  359|      0|# define my_debug_1(a,b)    log_debug ((a), (b))
  ------------------
 1290|      0|      return 0;
 1291|      0|    }
 1292|       |
 1293|       |#ifdef HAVE_DOSISH_SYSTEM
 1294|       |  ret = dotlock_take_w32 (h, timeout);
 1295|       |#else /*!HAVE_DOSISH_SYSTEM*/
 1296|     14|  ret = dotlock_take_unix (h, timeout);
 1297|     14|#endif /*!HAVE_DOSISH_SYSTEM*/
 1298|       |
 1299|     14|  return ret;
 1300|     14|}
dotlock_release:
 1367|     14|{
 1368|     14|  int ret;
 1369|       |
 1370|       |  /* To avoid atexit race conditions we first check whether there are
 1371|       |     any locks left.  It might happen that another atexit handler
 1372|       |     tries to release the lock while the atexit handler of this module
 1373|       |     already ran and thus H is undefined.  */
 1374|     14|  LOCK_all_lockfiles ();
  ------------------
  |  |  424|     14|# define LOCK_all_lockfiles()   do { } while (0)
  |  |  ------------------
  |  |  |  Branch (424:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1375|     14|  ret = !all_lockfiles;
 1376|     14|  UNLOCK_all_lockfiles ();
  ------------------
  |  |  425|     14|# define UNLOCK_all_lockfiles() do { } while (0)
  |  |  ------------------
  |  |  |  Branch (425:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1377|     14|  if (ret)
  ------------------
  |  Branch (1377:7): [True: 0, False: 14]
  ------------------
 1378|      0|    return 0;
 1379|       |
 1380|     14|  if ( h->disable )
  ------------------
  |  Branch (1380:8): [True: 0, False: 14]
  ------------------
 1381|      0|    return 0;
 1382|       |
 1383|     14|  if ( !h->locked )
  ------------------
  |  Branch (1383:8): [True: 0, False: 14]
  ------------------
 1384|      0|    {
 1385|      0|      my_debug_1 ("Oops, '%s' is not locked\n", h->lockname);
  ------------------
  |  |  359|      0|# define my_debug_1(a,b)    log_debug ((a), (b))
  ------------------
 1386|      0|      return 0;
 1387|      0|    }
 1388|       |
 1389|       |#ifdef HAVE_DOSISH_SYSTEM
 1390|       |  ret = dotlock_release_w32 (h);
 1391|       |#else
 1392|     14|  ret = dotlock_release_unix (h);
 1393|     14|#endif
 1394|       |
 1395|     14|  if (!ret)
  ------------------
  |  Branch (1395:7): [True: 14, False: 0]
  ------------------
 1396|     14|    h->locked = 0;
 1397|     14|  return ret;
 1398|     14|}
dotlock_remove_lockfiles:
 1407|      1|{
 1408|      1|  dotlock_t h, h2;
 1409|       |
 1410|       |  /* First set the lockfiles list to NULL so that for example
 1411|       |     dotlock_release is aware that this function is currently
 1412|       |     running.  */
 1413|      1|  LOCK_all_lockfiles ();
  ------------------
  |  |  424|      1|# define LOCK_all_lockfiles()   do { } while (0)
  |  |  ------------------
  |  |  |  Branch (424:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1414|      1|  h = all_lockfiles;
 1415|      1|  all_lockfiles = NULL;
 1416|      1|  UNLOCK_all_lockfiles ();
  ------------------
  |  |  425|      1|# define UNLOCK_all_lockfiles() do { } while (0)
  |  |  ------------------
  |  |  |  Branch (425:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1417|       |
 1418|      3|  while ( h )
  ------------------
  |  Branch (1418:11): [True: 2, False: 1]
  ------------------
 1419|      2|    {
 1420|      2|      h2 = h->next;
 1421|      2|      dotlock_destroy (h);
 1422|      2|      h = h2;
 1423|      2|    }
 1424|      1|}
dotlock.c:dotlock_create_unix:
  662|      3|{
  663|      3|  int  fd = -1;
  664|      3|  char pidstr[16];
  665|      3|  const char *nodename;
  666|      3|  const char *dirpart;
  667|      3|  int dirpartlen;
  668|      3|  struct utsname utsbuf;
  669|      3|  size_t tnamelen;
  670|       |
  671|      3|  snprintf (pidstr, sizeof pidstr, "%10d\n", (int)getpid() );
  ------------------
  |  |   84|      3|#define snprintf gpgrt_snprintf
  ------------------
  672|       |
  673|       |  /* Create a temporary file. */
  674|      3|  if ( uname ( &utsbuf ) )
  ------------------
  |  Branch (674:8): [True: 0, False: 3]
  ------------------
  675|      0|    nodename = "unknown";
  676|      3|  else
  677|      3|    nodename = utsbuf.nodename;
  678|       |
  679|      3|  if ( !(dirpart = strrchr (file_to_lock, DIRSEP_C)) )
  ------------------
  |  |  886|      3|#define DIRSEP_C '/'
  ------------------
  |  Branch (679:8): [True: 0, False: 3]
  ------------------
  680|      0|    {
  681|      0|      dirpart = EXTSEP_S;
  ------------------
  |  |  889|      0|#define EXTSEP_S "."
  ------------------
  682|      0|      dirpartlen = 1;
  683|      0|    }
  684|      3|  else
  685|      3|    {
  686|      3|      dirpartlen = dirpart - file_to_lock;
  687|      3|      dirpart = file_to_lock;
  688|      3|    }
  689|       |
  690|      3|  LOCK_all_lockfiles ();
  ------------------
  |  |  424|      3|# define LOCK_all_lockfiles()   do { } while (0)
  |  |  ------------------
  |  |  |  Branch (424:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  691|      3|  h->next = all_lockfiles;
  692|      3|  all_lockfiles = h;
  693|       |
  694|      3|  tnamelen = dirpartlen + 6 + 30 + strlen(nodename) + 10 + 1;
  695|      3|  h->tname = xtrymalloc (tnamelen + 1);
  ------------------
  |  |   97|      3|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  696|      3|  if (!h->tname)
  ------------------
  |  Branch (696:7): [True: 0, False: 3]
  ------------------
  697|      0|    {
  698|      0|      all_lockfiles = h->next;
  699|      0|      UNLOCK_all_lockfiles ();
  ------------------
  |  |  425|      0|# define UNLOCK_all_lockfiles() do { } while (0)
  |  |  ------------------
  |  |  |  Branch (425:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  700|      0|      xfree (h);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  701|      0|      return NULL;
  702|      0|    }
  703|      3|  h->nodename_len = strlen (nodename);
  704|       |
  705|      3|  snprintf (h->tname, tnamelen, "%.*s/.#lk%p.", dirpartlen, dirpart, h );
  ------------------
  |  |   84|      3|#define snprintf gpgrt_snprintf
  ------------------
  706|      3|  h->nodename_off = strlen (h->tname);
  707|      3|  snprintf (h->tname+h->nodename_off, tnamelen - h->nodename_off,
  ------------------
  |  |   84|      3|#define snprintf gpgrt_snprintf
  ------------------
  708|      3|           "%s.%d", nodename, (int)getpid ());
  709|       |
  710|      3|  do
  711|      3|    {
  712|      3|      my_set_errno (0);
  ------------------
  |  |  341|      3|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  713|      3|      fd = open (h->tname, O_WRONLY|O_CREAT|O_EXCL,
  714|      3|                 S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR );
  715|      3|    }
  716|      3|  while (fd == -1 && errno == EINTR);
  ------------------
  |  Branch (716:10): [True: 0, False: 3]
  |  Branch (716:22): [True: 0, False: 0]
  ------------------
  717|       |
  718|      3|  if ( fd == -1 )
  ------------------
  |  Branch (718:8): [True: 0, False: 3]
  ------------------
  719|      0|    {
  720|      0|      int saveerrno = errno;
  721|      0|      all_lockfiles = h->next;
  722|      0|      UNLOCK_all_lockfiles ();
  ------------------
  |  |  425|      0|# define UNLOCK_all_lockfiles() do { } while (0)
  |  |  ------------------
  |  |  |  Branch (425:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  723|      0|      my_error_2 (_("failed to create temporary file '%s': %s\n"),
  ------------------
  |  |  358|      0|# define my_error_2(a,b,c)  log_error ((a), (b), (c))
  ------------------
  724|      0|                  h->tname, strerror (errno));
  725|      0|      xfree (h->tname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  726|      0|      xfree (h);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  727|      0|      my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  728|      0|      return NULL;
  729|      0|    }
  730|      3|  if ( write (fd, pidstr, 11 ) != 11 )
  ------------------
  |  Branch (730:8): [True: 0, False: 3]
  ------------------
  731|      0|    goto write_failed;
  732|      3|  if ( write (fd, nodename, strlen (nodename) ) != strlen (nodename) )
  ------------------
  |  Branch (732:8): [True: 0, False: 3]
  ------------------
  733|      0|    goto write_failed;
  734|      3|  if ( write (fd, "\n", 1 ) != 1 )
  ------------------
  |  Branch (734:8): [True: 0, False: 3]
  ------------------
  735|      0|    goto write_failed;
  736|      3|  if ( close (fd) )
  ------------------
  |  Branch (736:8): [True: 0, False: 3]
  ------------------
  737|      0|    {
  738|      0|      if ( errno == EINTR )
  ------------------
  |  Branch (738:12): [True: 0, False: 0]
  ------------------
  739|      0|        fd = -1;
  740|      0|      goto write_failed;
  741|      0|    }
  742|      3|  fd = -1;
  743|       |
  744|       |  /* Check whether we support hard links.  */
  745|      3|  switch (use_hardlinks_p (h->tname))
  746|      3|    {
  747|      3|    case 0: /* Yes.  */
  ------------------
  |  Branch (747:5): [True: 3, False: 0]
  ------------------
  748|      3|      break;
  749|      0|    case 1: /* No.  */
  ------------------
  |  Branch (749:5): [True: 0, False: 3]
  ------------------
  750|      0|      unlink (h->tname);
  751|      0|      h->use_o_excl = 1;
  752|      0|      break;
  753|      0|    default:
  ------------------
  |  Branch (753:5): [True: 0, False: 3]
  ------------------
  754|      0|      {
  755|      0|        int saveerrno = errno;
  756|      0|        my_error_2 ("can't check whether hardlinks are supported for '%s': %s\n"
  ------------------
  |  |  358|      0|# define my_error_2(a,b,c)  log_error ((a), (b), (c))
  ------------------
  757|      0|                    , h->tname, strerror (saveerrno));
  758|      0|        my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  759|      0|      }
  760|      0|      goto write_failed;
  761|      3|    }
  762|       |
  763|      3|  h->lockname = xtrymalloc (strlen (file_to_lock) + 6 );
  ------------------
  |  |   97|      3|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  764|      3|  if (!h->lockname)
  ------------------
  |  Branch (764:7): [True: 0, False: 3]
  ------------------
  765|      0|    {
  766|      0|      int saveerrno = errno;
  767|      0|      all_lockfiles = h->next;
  768|      0|      UNLOCK_all_lockfiles ();
  ------------------
  |  |  425|      0|# define UNLOCK_all_lockfiles() do { } while (0)
  |  |  ------------------
  |  |  |  Branch (425:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  769|      0|      unlink (h->tname);
  770|      0|      xfree (h->tname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  771|      0|      xfree (h);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  772|      0|      my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  773|      0|      return NULL;
  774|      0|    }
  775|      3|  strcpy (stpcpy (h->lockname, file_to_lock), EXTSEP_S "lock");
  ------------------
  |  |  889|      3|#define EXTSEP_S "."
  ------------------
  776|      3|  UNLOCK_all_lockfiles ();
  ------------------
  |  |  425|      3|# define UNLOCK_all_lockfiles() do { } while (0)
  |  |  ------------------
  |  |  |  Branch (425:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  777|       |
  778|      3|  return h;
  779|       |
  780|      0| write_failed:
  781|      0|  {
  782|      0|    int saveerrno = errno;
  783|      0|    all_lockfiles = h->next;
  784|      0|    UNLOCK_all_lockfiles ();
  ------------------
  |  |  425|      0|# define UNLOCK_all_lockfiles() do { } while (0)
  |  |  ------------------
  |  |  |  Branch (425:47): [Folded - Ignored]
  |  |  ------------------
  ------------------
  785|      0|    my_error_2 (_("error writing to '%s': %s\n"), h->tname, strerror (errno));
  ------------------
  |  |  358|      0|# define my_error_2(a,b,c)  log_error ((a), (b), (c))
  ------------------
  786|      0|    if ( fd != -1 )
  ------------------
  |  Branch (786:10): [True: 0, False: 0]
  ------------------
  787|      0|      close (fd);
  788|      0|    unlink (h->tname);
  789|      0|    xfree (h->tname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  790|      0|    xfree (h);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  791|      0|    my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  792|      0|  }
  793|      0|  return NULL;
  794|      3|}
dotlock.c:use_hardlinks_p:
  623|      3|{
  624|      3|  char *lname;
  625|      3|  struct stat sb;
  626|      3|  unsigned int nlink;
  627|      3|  int res;
  628|       |
  629|      3|  if (stat (tname, &sb))
  ------------------
  |  Branch (629:7): [True: 0, False: 3]
  ------------------
  630|      0|    return -1;
  631|      3|  nlink = (unsigned int)sb.st_nlink;
  632|       |
  633|      3|  lname = xtrymalloc (strlen (tname) + 1 + 1);
  ------------------
  |  |   97|      3|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  634|      3|  if (!lname)
  ------------------
  |  Branch (634:7): [True: 0, False: 3]
  ------------------
  635|      0|    return -1;
  636|      3|  strcpy (lname, tname);
  637|      3|  strcat (lname, "x");
  638|       |
  639|       |  /* We ignore the return value of link() because it is unreliable.  */
  640|      3|  (void) link (tname, lname);
  641|       |
  642|      3|  if (stat (tname, &sb))
  ------------------
  |  Branch (642:7): [True: 0, False: 3]
  ------------------
  643|      0|    res = -1;  /* Ooops.  */
  644|      3|  else if (sb.st_nlink == nlink + 1)
  ------------------
  |  Branch (644:12): [True: 3, False: 0]
  ------------------
  645|      3|    res = 0;   /* Yeah, hardlinks are supported.  */
  646|      0|  else
  647|      0|    res = 1;   /* No hardlink support.  */
  648|       |
  649|      3|  unlink (lname);
  650|      3|  xfree (lname);
  ------------------
  |  |  104|      3|#define xfree(a)         gcry_free ((a))
  ------------------
  651|      3|  return res;
  652|      3|}
dotlock.c:dotlock_destroy_unix:
  950|      3|{
  951|      3|  if (h->locked && h->lockname)
  ------------------
  |  Branch (951:7): [True: 0, False: 3]
  |  Branch (951:20): [True: 0, False: 0]
  ------------------
  952|      0|    unlink (h->lockname);
  953|      3|  if (h->tname && !h->use_o_excl)
  ------------------
  |  Branch (953:7): [True: 3, False: 0]
  |  Branch (953:19): [True: 3, False: 0]
  ------------------
  954|      3|    unlink (h->tname);
  955|      3|  xfree (h->tname);
  ------------------
  |  |  104|      3|#define xfree(a)         gcry_free ((a))
  ------------------
  956|      3|}
dotlock.c:dotlock_take_unix:
 1020|     14|{
 1021|     14|  int wtime = 0;
 1022|     14|  int sumtime = 0;
 1023|     14|  int pid;
 1024|     14|  int lastpid = -1;
 1025|     14|  int ownerchanged;
 1026|     14|  const char *maybe_dead="";
 1027|     14|  int same_node;
 1028|     14|  int saveerrno;
 1029|     14|  int fd;
 1030|       |
 1031|     14| again:
 1032|     14|  if (h->use_o_excl)
  ------------------
  |  Branch (1032:7): [True: 0, False: 14]
  ------------------
 1033|      0|    {
 1034|       |      /* No hardlink support - use open(O_EXCL).  */
 1035|      0|      do
 1036|      0|        {
 1037|      0|          my_set_errno (0);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
 1038|      0|          fd = open (h->lockname, O_WRONLY|O_CREAT|O_EXCL,
 1039|      0|                     S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR );
 1040|      0|        }
 1041|      0|      while (fd == -1 && errno == EINTR);
  ------------------
  |  Branch (1041:14): [True: 0, False: 0]
  |  Branch (1041:26): [True: 0, False: 0]
  ------------------
 1042|       |
 1043|      0|      if (fd == -1 && errno == EEXIST)
  ------------------
  |  Branch (1043:11): [True: 0, False: 0]
  |  Branch (1043:23): [True: 0, False: 0]
  ------------------
 1044|      0|        ; /* Lock held by another process.  */
 1045|      0|      else if (fd == -1)
  ------------------
  |  Branch (1045:16): [True: 0, False: 0]
  ------------------
 1046|      0|        {
 1047|      0|          saveerrno = errno;
 1048|      0|          my_error_2 ("lock not made: open(O_EXCL) of '%s' failed: %s\n",
  ------------------
  |  |  358|      0|# define my_error_2(a,b,c)  log_error ((a), (b), (c))
  ------------------
 1049|      0|                      h->lockname, strerror (saveerrno));
 1050|      0|          my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
 1051|      0|          return -1;
 1052|      0|        }
 1053|      0|      else
 1054|      0|        {
 1055|      0|          char pidstr[16];
 1056|       |
 1057|      0|          snprintf (pidstr, sizeof pidstr, "%10d\n", (int)getpid());
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
 1058|      0|          if (write (fd, pidstr, 11 ) == 11
  ------------------
  |  Branch (1058:15): [True: 0, False: 0]
  ------------------
 1059|      0|              && write (fd, h->tname + h->nodename_off,h->nodename_len)
  ------------------
  |  Branch (1059:18): [True: 0, False: 0]
  ------------------
 1060|      0|              == h->nodename_len
 1061|      0|              && write (fd, "\n", 1) == 1
  ------------------
  |  Branch (1061:18): [True: 0, False: 0]
  ------------------
 1062|      0|              && !close (fd))
  ------------------
  |  Branch (1062:18): [True: 0, False: 0]
  ------------------
 1063|      0|            {
 1064|      0|              h->locked = 1;
 1065|      0|              return 0;
 1066|      0|            }
 1067|       |          /* Write error.  */
 1068|      0|          saveerrno = errno;
 1069|      0|          my_error_2 ("lock not made: writing to '%s' failed: %s\n",
  ------------------
  |  |  358|      0|# define my_error_2(a,b,c)  log_error ((a), (b), (c))
  ------------------
 1070|      0|                      h->lockname, strerror (errno));
 1071|      0|          close (fd);
 1072|      0|          unlink (h->lockname);
 1073|      0|          my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
 1074|      0|          return -1;
 1075|      0|        }
 1076|      0|    }
 1077|     14|  else /* Standard method:  Use hardlinks.  */
 1078|     14|    {
 1079|     14|      struct stat sb;
 1080|       |
 1081|       |      /* We ignore the return value of link() because it is unreliable.  */
 1082|     14|      (void) link (h->tname, h->lockname);
 1083|       |
 1084|     14|      if (stat (h->tname, &sb))
  ------------------
  |  Branch (1084:11): [True: 0, False: 14]
  ------------------
 1085|      0|        {
 1086|      0|          saveerrno = errno;
 1087|      0|          my_error_1 ("lock not made: Oops: stat of tmp file failed: %s\n",
  ------------------
  |  |  357|      0|# define my_error_1(a,b)    log_error ((a), (b))
  ------------------
 1088|      0|                      strerror (errno));
 1089|       |          /* In theory this might be a severe error: It is possible
 1090|       |             that link succeeded but stat failed due to changed
 1091|       |             permissions.  We can't do anything about it, though.  */
 1092|      0|          my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
 1093|      0|          return -1;
 1094|      0|        }
 1095|       |
 1096|     14|      if (sb.st_nlink == 2)
  ------------------
  |  Branch (1096:11): [True: 14, False: 0]
  ------------------
 1097|     14|        {
 1098|     14|          h->locked = 1;
 1099|     14|          return 0; /* Okay.  */
 1100|     14|        }
 1101|     14|    }
 1102|       |
 1103|       |  /* Check for stale lock files.  */
 1104|      0|  if ( (pid = read_lockfile (h, &same_node, &fd)) == -1 )
  ------------------
  |  Branch (1104:8): [True: 0, False: 0]
  ------------------
 1105|      0|    {
 1106|      0|      if ( errno != ENOENT )
  ------------------
  |  Branch (1106:12): [True: 0, False: 0]
  ------------------
 1107|      0|        {
 1108|      0|          saveerrno = errno;
 1109|      0|          my_info_0 ("cannot read lockfile\n");
  ------------------
  |  |  352|      0|# define my_info_0(a)       log_info ((a))
  ------------------
 1110|      0|          my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
 1111|      0|          return -1;
 1112|      0|        }
 1113|      0|      my_info_0 ("lockfile disappeared\n");
  ------------------
  |  |  352|      0|# define my_info_0(a)       log_info ((a))
  ------------------
 1114|      0|      goto again;
 1115|      0|    }
 1116|      0|  else if ( (pid == getpid() && same_node)
  ------------------
  |  Branch (1116:14): [True: 0, False: 0]
  |  Branch (1116:33): [True: 0, False: 0]
  ------------------
 1117|      0|            || (same_node && kill (pid, 0) && errno == ESRCH) )
  ------------------
  |  Branch (1117:17): [True: 0, False: 0]
  |  Branch (1117:30): [True: 0, False: 0]
  |  Branch (1117:47): [True: 0, False: 0]
  ------------------
 1118|       |    /* Stale lockfile is detected. */
 1119|      0|    {
 1120|      0|      struct stat sb;
 1121|       |
 1122|       |      /* Check if it's unlocked during examining the lockfile.  */
 1123|      0|      if (fstat (fd, &sb) || sb.st_nlink == 0)
  ------------------
  |  Branch (1123:11): [True: 0, False: 0]
  |  Branch (1123:30): [True: 0, False: 0]
  ------------------
 1124|      0|        {
 1125|       |          /* It's gone already by another process.  */
 1126|      0|          close (fd);
 1127|      0|          goto again;
 1128|      0|        }
 1129|       |
 1130|       |      /*
 1131|       |       * Here, although it's quite _rare_, we have a race condition.
 1132|       |       *
 1133|       |       * When multiple processes race on a stale lockfile, detecting
 1134|       |       * AND removing should be done atomically.  That is, to work
 1135|       |       * correctly, the file to be removed should be the one which is
 1136|       |       * examined for detection.
 1137|       |       *
 1138|       |       * But, when it's not atomic, consider the case for us where it
 1139|       |       * takes some time between the detection and the removal of the
 1140|       |       * lockfile.
 1141|       |       *
 1142|       |       * In this situation, it is possible that the file which was
 1143|       |       * detected as stale is already removed by another process and
 1144|       |       * then new lockfile is created (by that process or other one).
 1145|       |       *
 1146|       |       * And it is newly created valid lockfile which is going to be
 1147|       |       * removed by us.
 1148|       |       *
 1149|       |       * Consider this long comment as it expresses possible (long)
 1150|       |       * time between fstat above and unlink below; Meanwhile, the
 1151|       |       * lockfile in question may be removed and there may be new
 1152|       |       * valid one.
 1153|       |       *
 1154|       |       * In short, when you see the message of removing stale lockfile
 1155|       |       * when there are multiple processes for the work, there is
 1156|       |       * (very) little possibility something went wrong.
 1157|       |       */
 1158|       |
 1159|      0|      unlink (h->lockname);
 1160|      0|      my_info_1 (_("removing stale lockfile (created by %d)\n"), pid);
  ------------------
  |  |  353|      0|# define my_info_1(a,b)     log_info ((a), (b))
  ------------------
 1161|      0|      close (fd);
 1162|      0|      goto again;
 1163|      0|    }
 1164|       |
 1165|      0|  close (fd);
 1166|      0|  if (lastpid == -1)
  ------------------
  |  Branch (1166:7): [True: 0, False: 0]
  ------------------
 1167|      0|    lastpid = pid;
 1168|      0|  ownerchanged = (pid != lastpid);
 1169|       |
 1170|      0|  if (timeout)
  ------------------
  |  Branch (1170:7): [True: 0, False: 0]
  ------------------
 1171|      0|    {
 1172|      0|      struct timeval tv;
 1173|       |
 1174|       |      /* Wait until lock has been released.  We use increasing retry
 1175|       |         intervals of 50ms, 100ms, 200ms, 400ms, 800ms, 2s, 4s and 8s
 1176|       |         but reset it if the lock owner meanwhile changed.  */
 1177|      0|      if (!wtime || ownerchanged)
  ------------------
  |  Branch (1177:11): [True: 0, False: 0]
  |  Branch (1177:21): [True: 0, False: 0]
  ------------------
 1178|      0|        wtime = 50;
 1179|      0|      else if (wtime < 800)
  ------------------
  |  Branch (1179:16): [True: 0, False: 0]
  ------------------
 1180|      0|        wtime *= 2;
 1181|      0|      else if (wtime == 800)
  ------------------
  |  Branch (1181:16): [True: 0, False: 0]
  ------------------
 1182|      0|        wtime = 2000;
 1183|      0|      else if (wtime < 8000)
  ------------------
  |  Branch (1183:16): [True: 0, False: 0]
  ------------------
 1184|      0|        wtime *= 2;
 1185|       |
 1186|      0|      if (timeout > 0)
  ------------------
  |  Branch (1186:11): [True: 0, False: 0]
  ------------------
 1187|      0|        {
 1188|      0|          if (wtime > timeout)
  ------------------
  |  Branch (1188:15): [True: 0, False: 0]
  ------------------
 1189|      0|            wtime = timeout;
 1190|      0|          timeout -= wtime;
 1191|      0|        }
 1192|       |
 1193|      0|      sumtime += wtime;
 1194|      0|      if (sumtime >= 1500)
  ------------------
  |  Branch (1194:11): [True: 0, False: 0]
  ------------------
 1195|      0|        {
 1196|      0|          sumtime = 0;
 1197|      0|          my_info_3 (_("waiting for lock (held by %d%s) %s...\n"),
  ------------------
  |  |  355|      0|# define my_info_3(a,b,c,d) log_info ((a), (b), (c), (d))
  |  |  ------------------
  |  |  |  Branch (355:55): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1198|      0|                     pid, maybe_dead, maybe_deadlock(h)? _("(deadlock?) "):"");
 1199|      0|        }
 1200|       |
 1201|       |
 1202|      0|      tv.tv_sec = wtime / 1000;
 1203|      0|      tv.tv_usec = (wtime % 1000) * 1000;
 1204|      0|      select (0, NULL, NULL, NULL, &tv);
 1205|      0|      goto again;
 1206|      0|    }
 1207|       |
 1208|      0|  my_set_errno (EACCES);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
 1209|      0|  return -1;
 1210|      0|}
dotlock.c:read_lockfile:
  525|     14|{
  526|     14|  char buffer_space[10+1+70+1]; /* 70 is just an estimated value; node
  527|       |                                   names are usually shorter. */
  528|     14|  int fd;
  529|     14|  int pid = -1;
  530|     14|  char *buffer, *p;
  531|     14|  size_t expected_len;
  532|     14|  int res, nread;
  533|       |
  534|     14|  *same_node = 0;
  535|     14|  expected_len = 10 + 1 + h->nodename_len + 1;
  536|     14|  if ( expected_len >= sizeof buffer_space)
  ------------------
  |  Branch (536:8): [True: 0, False: 14]
  ------------------
  537|      0|    {
  538|      0|      buffer = xtrymalloc (expected_len);
  ------------------
  |  |   97|      0|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  539|      0|      if (!buffer)
  ------------------
  |  Branch (539:11): [True: 0, False: 0]
  ------------------
  540|      0|        return -1;
  541|      0|    }
  542|     14|  else
  543|     14|    buffer = buffer_space;
  544|       |
  545|     14|  if ( (fd = open (h->lockname, O_RDONLY)) == -1 )
  ------------------
  |  Branch (545:8): [True: 0, False: 14]
  ------------------
  546|      0|    {
  547|      0|      int e = errno;
  548|      0|      my_info_2 ("error opening lockfile '%s': %s\n",
  ------------------
  |  |  354|      0|# define my_info_2(a,b,c)   log_info ((a), (b), (c))
  ------------------
  549|      0|                 h->lockname, strerror(errno) );
  550|      0|      if (buffer != buffer_space)
  ------------------
  |  Branch (550:11): [True: 0, False: 0]
  ------------------
  551|      0|        xfree (buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  552|      0|      my_set_errno (e); /* Need to return ERRNO here. */
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  553|      0|      return -1;
  554|      0|    }
  555|       |
  556|     14|  p = buffer;
  557|     14|  nread = 0;
  558|     14|  do
  559|     14|    {
  560|     14|      res = read (fd, p, expected_len - nread);
  561|     14|      if (res == -1 && errno == EINTR)
  ------------------
  |  Branch (561:11): [True: 0, False: 14]
  |  Branch (561:24): [True: 0, False: 0]
  ------------------
  562|      0|        continue;
  563|     14|      if (res < 0)
  ------------------
  |  Branch (563:11): [True: 0, False: 14]
  ------------------
  564|      0|        {
  565|      0|          int e = errno;
  566|      0|          my_info_1 ("error reading lockfile '%s'\n", h->lockname );
  ------------------
  |  |  353|      0|# define my_info_1(a,b)     log_info ((a), (b))
  ------------------
  567|      0|          close (fd);
  568|      0|          if (buffer != buffer_space)
  ------------------
  |  Branch (568:15): [True: 0, False: 0]
  ------------------
  569|      0|            xfree (buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  570|      0|          my_set_errno (e);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  571|      0|          return -1;
  572|      0|        }
  573|     14|      p += res;
  574|     14|      nread += res;
  575|     14|    }
  576|     14|  while (res && nread != expected_len);
  ------------------
  |  Branch (576:10): [True: 14, False: 0]
  |  Branch (576:17): [True: 0, False: 14]
  ------------------
  577|       |
  578|     14|  if (r_fd)
  ------------------
  |  Branch (578:7): [True: 0, False: 14]
  ------------------
  579|      0|    *r_fd = fd;
  580|     14|  else
  581|     14|    close(fd);
  582|       |
  583|     14|  if (nread < 11)
  ------------------
  |  Branch (583:7): [True: 0, False: 14]
  ------------------
  584|      0|    {
  585|      0|      my_info_1 ("invalid size of lockfile '%s'\n", h->lockname);
  ------------------
  |  |  353|      0|# define my_info_1(a,b)     log_info ((a), (b))
  ------------------
  586|      0|      if (buffer != buffer_space)
  ------------------
  |  Branch (586:11): [True: 0, False: 0]
  ------------------
  587|      0|        xfree (buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  588|      0|      my_set_errno (EINVAL);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  589|      0|      return -1;
  590|      0|    }
  591|       |
  592|     14|  if (buffer[10] != '\n'
  ------------------
  |  Branch (592:7): [True: 0, False: 14]
  ------------------
  593|     14|      || (buffer[10] = 0, pid = atoi (buffer)) == -1
  ------------------
  |  Branch (593:10): [True: 0, False: 14]
  ------------------
  594|     14|      || !pid )
  ------------------
  |  Branch (594:10): [True: 0, False: 14]
  ------------------
  595|      0|    {
  596|      0|      my_error_2 ("invalid pid %d in lockfile '%s'\n", pid, h->lockname);
  ------------------
  |  |  358|      0|# define my_error_2(a,b,c)  log_error ((a), (b), (c))
  ------------------
  597|      0|      if (buffer != buffer_space)
  ------------------
  |  Branch (597:11): [True: 0, False: 0]
  ------------------
  598|      0|        xfree (buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  599|      0|      my_set_errno (EINVAL);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
  600|      0|      return -1;
  601|      0|    }
  602|       |
  603|     14|  if (nread == expected_len
  ------------------
  |  Branch (603:7): [True: 14, False: 0]
  ------------------
  604|     14|      && !memcmp (h->tname+h->nodename_off, buffer+11, h->nodename_len)
  ------------------
  |  Branch (604:10): [True: 14, False: 0]
  ------------------
  605|     14|      && buffer[11+h->nodename_len] == '\n')
  ------------------
  |  Branch (605:10): [True: 14, False: 0]
  ------------------
  606|     14|    *same_node = 1;
  607|       |
  608|     14|  if (buffer != buffer_space)
  ------------------
  |  Branch (608:7): [True: 0, False: 14]
  ------------------
  609|      0|    xfree (buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  610|     14|  return pid;
  611|     14|}
dotlock.c:dotlock_release_unix:
 1308|     14|{
 1309|     14|  int pid, same_node;
 1310|     14|  int saveerrno;
 1311|       |
 1312|     14|  pid = read_lockfile (h, &same_node, NULL);
 1313|     14|  if ( pid == -1 )
  ------------------
  |  Branch (1313:8): [True: 0, False: 14]
  ------------------
 1314|      0|    {
 1315|      0|      saveerrno = errno;
 1316|      0|      my_error_0 ("release_dotlock: lockfile error\n");
  ------------------
  |  |  356|      0|# define my_error_0(a)      log_error ((a))
  ------------------
 1317|      0|      my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
 1318|      0|      return -1;
 1319|      0|    }
 1320|     14|  if ( pid != getpid() || !same_node )
  ------------------
  |  Branch (1320:8): [True: 0, False: 14]
  |  Branch (1320:27): [True: 0, False: 14]
  ------------------
 1321|      0|    {
 1322|      0|      my_error_1 ("release_dotlock: not our lock (pid=%d)\n", pid);
  ------------------
  |  |  357|      0|# define my_error_1(a,b)    log_error ((a), (b))
  ------------------
 1323|      0|      my_set_errno (EACCES);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
 1324|      0|      return -1;
 1325|      0|    }
 1326|       |
 1327|     14|  if ( unlink( h->lockname ) )
  ------------------
  |  Branch (1327:8): [True: 0, False: 14]
  ------------------
 1328|      0|    {
 1329|      0|      saveerrno = errno;
 1330|      0|      my_error_1 ("release_dotlock: error removing lockfile '%s'\n",
  ------------------
  |  |  357|      0|# define my_error_1(a,b)    log_error ((a), (b))
  ------------------
 1331|      0|                  h->lockname);
 1332|      0|      my_set_errno (saveerrno);
  ------------------
  |  |  341|      0|#  define my_set_errno(e)  gpg_err_set_errno ((e))
  ------------------
 1333|      0|      return -1;
 1334|      0|    }
 1335|       |  /* Fixme: As an extra check we could check whether the link count is
 1336|       |     now really at 1. */
 1337|     14|  return 0;
 1338|     14|}

gnupg_get_time:
   68|     93|{
   69|     93|  time_t current = time (NULL);
   70|     93|  if (current == (time_t)(-1))
  ------------------
  |  Branch (70:7): [True: 0, False: 93]
  ------------------
   71|      0|    log_fatal ("time() failed\n");
   72|       |
   73|     93|  if (timemode == NORMAL)
  ------------------
  |  Branch (73:7): [True: 93, False: 0]
  ------------------
   74|     93|    return current;
   75|      0|  else if (timemode == FROZEN)
  ------------------
  |  Branch (75:12): [True: 0, False: 0]
  ------------------
   76|      0|    return timewarp;
   77|      0|  else if (timemode == FUTURE)
  ------------------
  |  Branch (77:12): [True: 0, False: 0]
  ------------------
   78|      0|    return current + timewarp;
   79|      0|  else
   80|      0|    return current - timewarp;
   81|     93|}
make_timestamp:
  169|     93|{
  170|     93|  time_t t = gnupg_get_time ();
  171|     93|  return (u32)t;
  172|     93|}
isotimestamp:
  663|  1.46k|{
  664|  1.46k|  static char buffer[25+5];
  665|  1.46k|  struct tm *tp;
  666|  1.46k|  time_t atime = stamp;
  667|       |
  668|  1.46k|  if (IS_INVALID_TIME_T (atime))
  ------------------
  |  |   53|  1.46k|# define IS_INVALID_TIME_T(a) ((a) < 0)
  |  |  ------------------
  |  |  |  Branch (53:31): [True: 0, False: 1.46k]
  |  |  ------------------
  ------------------
  669|      0|    {
  670|      0|      strcpy (buffer, "????" "-??" "-??" " " "??" ":" "??" ":" "??");
  671|      0|    }
  672|  1.46k|  else
  673|  1.46k|    {
  674|  1.46k|      tp = gmtime ( &atime );
  675|  1.46k|      snprintf (buffer, sizeof buffer, "%04d-%02d-%02d %02d:%02d:%02d",
  ------------------
  |  |   84|  1.46k|#define snprintf gpgrt_snprintf
  ------------------
  676|  1.46k|                1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday,
  677|  1.46k|                tp->tm_hour, tp->tm_min, tp->tm_sec);
  678|  1.46k|    }
  679|  1.46k|  return buffer;
  680|  1.46k|}

standard_homedir:
  234|      1|{
  235|       |#ifdef HAVE_W32_SYSTEM
  236|       |  static const char *dir;
  237|       |
  238|       |  if (!dir)
  239|       |    {
  240|       |      const char *rdir;
  241|       |
  242|       |      rdir = w32_rootdir ();
  243|       |      if (w32_portable_app)
  244|       |        {
  245|       |          dir = xstrconcat (rdir, DIRSEP_S "home", NULL);
  246|       |          gpgrt_annotate_leaked_object (dir);
  247|       |        }
  248|       |      else
  249|       |        {
  250|       |          char *path;
  251|       |
  252|       |          path = w32_shgetfolderpath (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE,
  253|       |                                      NULL, 0);
  254|       |          if (path)
  255|       |            {
  256|       |              dir = xstrconcat (path, "\\gnupg", NULL);
  257|       |              xfree (path);
  258|       |              gpgrt_annotate_leaked_object (dir);
  259|       |
  260|       |              /* Try to create the directory if it does not yet exists.  */
  261|       |              if (gnupg_access (dir, F_OK))
  262|       |                gnupg_mkdir (dir, "-rwx");
  263|       |            }
  264|       |          else
  265|       |            dir = GNUPG_DEFAULT_HOMEDIR;
  266|       |        }
  267|       |    }
  268|       |  return dir;
  269|       |#else/*!HAVE_W32_SYSTEM*/
  270|      1|  return GNUPG_DEFAULT_HOMEDIR;
  ------------------
  |  |  906|      1|#define GNUPG_DEFAULT_HOMEDIR "~/.gnupg"
  ------------------
  271|      1|#endif /*!HAVE_W32_SYSTEM*/
  272|      1|}
gnupg_set_homedir:
  742|      1|{
  743|      1|  char *tmp = NULL;
  744|       |
  745|      1|  if (!newdir || !*newdir)
  ------------------
  |  Branch (745:7): [True: 0, False: 1]
  |  Branch (745:18): [True: 0, False: 1]
  ------------------
  746|      0|    newdir = default_homedir ();
  747|      1|  else
  748|      1|    {
  749|      1|      tmp = copy_dir_with_fixup (newdir);
  750|      1|      if (tmp)
  ------------------
  |  Branch (750:11): [True: 1, False: 0]
  ------------------
  751|      1|        newdir = tmp;
  752|       |
  753|      1|      if (!is_gnupg_default_homedir (newdir))
  ------------------
  |  Branch (753:11): [True: 1, False: 0]
  ------------------
  754|      1|        non_default_homedir = 1;
  755|      1|    }
  756|      1|  xfree (the_gnupg_homedir);
  ------------------
  |  |  104|      1|#define xfree(a)         gcry_free ((a))
  ------------------
  757|      1|  the_gnupg_homedir = make_absfilename (newdir, NULL);;
  758|      1|  xfree (tmp);
  ------------------
  |  |  104|      1|#define xfree(a)         gcry_free ((a))
  ------------------
  759|       |  /* Fixme: Should we use
  760|       |   *   gpgrt_annotate_leaked_object(the_gnupg_homedir)
  761|       |   * despite that we may free and allocate a new one in some
  762|       |   * cases?  */
  763|      1|}
gnupg_homedir:
  803|      4|{
  804|       |  /* If a homedir has not been set, set it to the default.  */
  805|      4|  if (!the_gnupg_homedir)
  ------------------
  |  Branch (805:7): [True: 0, False: 4]
  ------------------
  806|      0|    the_gnupg_homedir = make_absfilename (default_homedir (), NULL);
  807|      4|  return the_gnupg_homedir;
  808|      4|}
_gnupg_socketdir_internal:
  866|      1|{
  867|       |#if defined(HAVE_W32_SYSTEM)
  868|       |  char *name;
  869|       |
  870|       |  (void)skip_checks;
  871|       |
  872|       |  *r_info = 0;
  873|       |
  874|       |  /* First make sure that non_default_homedir and w32_portable_app can
  875|       |   * be set.  */
  876|       |  gnupg_homedir ();
  877|       |
  878|       |  if (w32_portable_app)
  879|       |    {
  880|       |      name = xstrconcat (w32_rootdir (), DIRSEP_S, "gnupg", NULL);
  881|       |    }
  882|       |  else
  883|       |    {
  884|       |      char *path;
  885|       |
  886|       |      path = w32_shgetfolderpath (NULL,
  887|       |                                  CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE,
  888|       |                                  NULL, 0);
  889|       |      if (path)
  890|       |        {
  891|       |          name = xstrconcat (path, "\\gnupg", NULL);
  892|       |          xfree (path);
  893|       |          if (gnupg_access (name, F_OK))
  894|       |            gnupg_mkdir (name, "-rwx");
  895|       |        }
  896|       |      else
  897|       |        {
  898|       |          name = xstrdup (gnupg_homedir ());
  899|       |        }
  900|       |    }
  901|       |
  902|       |  /* If a non default homedir is used, we check whether an
  903|       |   * corresponding sub directory below the socket dir is available
  904|       |   * and use that.  We hash the non default homedir to keep the new
  905|       |   * subdir short enough.  */
  906|       |  if (non_default_homedir)
  907|       |    {
  908|       |      char sha1buf[20];
  909|       |      struct stat sb;
  910|       |      char *suffix;
  911|       |      char *p;
  912|       |
  913|       |      *r_info |= 32; /* Testing subdir.  */
  914|       |
  915|       |      /* Canonicalize the name to avoid problems with mixed case
  916|       |       * names.  Note that we use only 10 bytes of the hash because on
  917|       |       * Windows the account name is also part of the name.  */
  918|       |      suffix = ascii_strlwr (xstrdup (gnupg_homedir ()));
  919|       |      for (p=suffix; *p; p++)
  920|       |        if ( *p == '\\')
  921|       |          *p = '/';
  922|       |      gcry_md_hash_buffer (GCRY_MD_SHA1, sha1buf, suffix, strlen (suffix));
  923|       |      xfree (suffix);
  924|       |      suffix = zb32_encode (sha1buf, 8*10);
  925|       |      if (!suffix)
  926|       |        {
  927|       |          *r_info |= 1; /* Out of core etc. */
  928|       |          goto leave_w32;
  929|       |        }
  930|       |      p = xstrconcat (name, "\\d.", suffix, NULL);
  931|       |      xfree (suffix);
  932|       |      xfree (name);
  933|       |      name = p;
  934|       |
  935|       |      /* Stat that directory and check constraints.
  936|       |       * The command
  937|       |       *    gpgconf --remove-socketdir
  938|       |       * can be used to remove that directory.  */
  939|       |      if (gnupg_stat (name, &sb))
  940|       |        {
  941|       |          if (errno != ENOENT)
  942|       |            *r_info |= 1; /* stat failed. */
  943|       |          else if (!skip_checks)
  944|       |            {
  945|       |              /* Try to create the directory and check again.  */
  946|       |              if (gnupg_mkdir (name, "-rwx"))
  947|       |                *r_info |= 16; /* mkdir failed.  */
  948|       |              else if (gnupg_stat (name, &sb))
  949|       |                {
  950|       |                  if (errno != ENOENT)
  951|       |                    *r_info |= 1; /* stat failed. */
  952|       |                  else
  953|       |                    *r_info |= 64; /* Subdir does not exist.  */
  954|       |                }
  955|       |              else
  956|       |                goto leave_w32; /* Success!  */
  957|       |            }
  958|       |          else
  959|       |            *r_info |= 64; /* Subdir does not exist.  */
  960|       |          if (!skip_checks)
  961|       |            {
  962|       |              xfree (name);
  963|       |              name = NULL;
  964|       |              goto leave_w32;
  965|       |            }
  966|       |        }
  967|       |    }
  968|       |
  969|       | leave_w32:
  970|       |  /* If nothing works - fall back to the homedir.  */
  971|       |  if (!name)
  972|       |    {
  973|       |      *r_info |= 128; /* Fallback.  */
  974|       |      name = xstrdup (gnupg_homedir ());
  975|       |    }
  976|       |
  977|       |#elif !defined(HAVE_STAT)
  978|       |  char *name;
  979|       |
  980|       |  (void)skip_checks;
  981|       |  *r_info = 0;
  982|       |  name = xstrdup (gnupg_homedir ());
  983|       |
  984|       |#else /* Unix and stat(2) available. */
  985|       |
  986|      1|  static const char * const bases[] = {
  987|       |#ifdef USE_RUN_GNUPG_USER_SOCKET
  988|       |    "/run/gnupg",
  989|       |#endif
  990|      1|    "/run",
  991|       |#ifdef USE_RUN_GNUPG_USER_SOCKET
  992|       |    "/var/run/gnupg",
  993|       |#endif
  994|      1|    "/var/run",
  995|      1|    NULL
  996|      1|  };
  997|      1|  int i;
  998|      1|  struct stat sb;
  999|      1|  char prefix[19 + 1 + 20 + 6 + 1];
 1000|      1|  const char *s;
 1001|      1|  char *name = NULL;
 1002|       |
 1003|      1|  *r_info = 0;
 1004|       |
 1005|       |  /* First make sure that non_default_homedir can be set.  */
 1006|      1|  gnupg_homedir ();
 1007|       |
 1008|       |  /* It has been suggested to first check XDG_RUNTIME_DIR envvar.
 1009|       |   * However, the specs state that the lifetime of the directory MUST
 1010|       |   * be bound to the user being logged in.  Now GnuPG may also be run
 1011|       |   * as a background process with no (desktop) user logged in.  Thus
 1012|       |   * we better don't do that.  */
 1013|       |
 1014|       |  /* Check whether we have a /run/[gnupg/]user dir.  */
 1015|      3|  for (i=0; bases[i]; i++)
  ------------------
  |  Branch (1015:13): [True: 2, False: 1]
  ------------------
 1016|      2|    {
 1017|      2|      snprintf (prefix, sizeof prefix, "%s/user/%u",
  ------------------
  |  |   84|      2|#define snprintf gpgrt_snprintf
  ------------------
 1018|      2|                bases[i], (unsigned int)getuid ());
 1019|      2|      if (!stat (prefix, &sb) && S_ISDIR(sb.st_mode))
  ------------------
  |  Branch (1019:11): [True: 0, False: 2]
  ------------------
 1020|      0|        break;
 1021|      2|    }
 1022|      1|  if (!bases[i])
  ------------------
  |  Branch (1022:7): [True: 1, False: 0]
  ------------------
 1023|      1|    {
 1024|      1|      *r_info |= 2; /* No /run/user directory.  */
 1025|      1|      goto leave;
 1026|      1|    }
 1027|       |
 1028|      0|  if (sb.st_uid != getuid ())
  ------------------
  |  Branch (1028:7): [True: 0, False: 0]
  ------------------
 1029|      0|    {
 1030|      0|      *r_info |= 4; /* Not owned by the user.  */
 1031|      0|      if (!skip_checks)
  ------------------
  |  Branch (1031:11): [True: 0, False: 0]
  ------------------
 1032|      0|        goto leave;
 1033|      0|    }
 1034|       |
 1035|      0|  if (strlen (prefix) + 7 >= sizeof prefix)
  ------------------
  |  Branch (1035:7): [True: 0, False: 0]
  ------------------
 1036|      0|    {
 1037|      0|      *r_info |= 1; /* Ooops: Buffer too short to append "/gnupg".  */
 1038|      0|      goto leave;
 1039|      0|    }
 1040|      0|  strcat (prefix, "/gnupg");
 1041|       |
 1042|       |  /* Check whether the gnupg sub directory has proper permissions.  */
 1043|      0|  if (stat (prefix, &sb))
  ------------------
  |  Branch (1043:7): [True: 0, False: 0]
  ------------------
 1044|      0|    {
 1045|      0|      if (errno != ENOENT)
  ------------------
  |  Branch (1045:11): [True: 0, False: 0]
  ------------------
 1046|      0|        {
 1047|      0|          *r_info |= 1; /* stat failed.  */
 1048|      0|          goto leave;
 1049|      0|        }
 1050|       |
 1051|       |      /* Try to create the directory and check again.  */
 1052|      0|      if (gnupg_mkdir (prefix, "-rwx"))
  ------------------
  |  Branch (1052:11): [True: 0, False: 0]
  ------------------
 1053|      0|        {
 1054|      0|          *r_info |= 16; /* mkdir failed.  */
 1055|      0|          goto leave;
 1056|      0|        }
 1057|      0|      if (stat (prefix, &sb))
  ------------------
  |  Branch (1057:11): [True: 0, False: 0]
  ------------------
 1058|      0|        {
 1059|      0|          *r_info |= 1; /* stat failed.  */
 1060|      0|          goto leave;
 1061|      0|        }
 1062|      0|    }
 1063|       |  /* Check that it is a directory, owned by the user, and only the
 1064|       |   * user has permissions to use it.  */
 1065|      0|  if (!S_ISDIR(sb.st_mode)
  ------------------
  |  Branch (1065:7): [True: 0, False: 0]
  ------------------
 1066|      0|      || sb.st_uid != getuid ()
  ------------------
  |  Branch (1066:10): [True: 0, False: 0]
  ------------------
 1067|      0|      || (sb.st_mode & (S_IRWXG|S_IRWXO)))
  ------------------
  |  Branch (1067:10): [True: 0, False: 0]
  ------------------
 1068|      0|    {
 1069|      0|      *r_info |= 4; /* Bad permissions or not a directory. */
 1070|      0|      if (!skip_checks)
  ------------------
  |  Branch (1070:11): [True: 0, False: 0]
  ------------------
 1071|      0|        goto leave;
 1072|      0|    }
 1073|       |
 1074|       |  /* If a non default homedir is used, we check whether an
 1075|       |   * corresponding sub directory below the socket dir is available
 1076|       |   * and use that.  We hash the non default homedir to keep the new
 1077|       |   * subdir short enough.  */
 1078|      0|  if (non_default_homedir)
  ------------------
  |  Branch (1078:7): [True: 0, False: 0]
  ------------------
 1079|      0|    {
 1080|      0|      char sha1buf[20];
 1081|      0|      char *suffix;
 1082|       |
 1083|      0|      *r_info |= 32; /* Testing subdir.  */
 1084|      0|      s = gnupg_homedir ();
 1085|      0|      gcry_md_hash_buffer (GCRY_MD_SHA1, sha1buf, s, strlen (s));
 1086|      0|      suffix = zb32_encode (sha1buf, 8*15);
 1087|      0|      if (!suffix)
  ------------------
  |  Branch (1087:11): [True: 0, False: 0]
  ------------------
 1088|      0|        {
 1089|      0|          *r_info |= 1; /* Out of core etc. */
 1090|      0|          goto leave;
 1091|      0|        }
 1092|      0|      name = strconcat (prefix, "/d.", suffix, NULL);
 1093|      0|      xfree (suffix);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1094|      0|      if (!name)
  ------------------
  |  Branch (1094:11): [True: 0, False: 0]
  ------------------
 1095|      0|        {
 1096|      0|          *r_info |= 1; /* Out of core etc. */
 1097|      0|          goto leave;
 1098|      0|        }
 1099|       |
 1100|       |      /* Stat that directory and check constraints.
 1101|       |       * The command
 1102|       |       *    gpgconf --remove-socketdir
 1103|       |       * can be used to remove that directory.  */
 1104|      0|      if (stat (name, &sb))
  ------------------
  |  Branch (1104:11): [True: 0, False: 0]
  ------------------
 1105|      0|        {
 1106|      0|          if (errno != ENOENT)
  ------------------
  |  Branch (1106:15): [True: 0, False: 0]
  ------------------
 1107|      0|            *r_info |= 1; /* stat failed. */
 1108|      0|          else if (!skip_checks)
  ------------------
  |  Branch (1108:20): [True: 0, False: 0]
  ------------------
 1109|      0|            {
 1110|       |              /* Try to create the directory and check again.  */
 1111|      0|              if (gnupg_mkdir (name, "-rwx"))
  ------------------
  |  Branch (1111:19): [True: 0, False: 0]
  ------------------
 1112|      0|                *r_info |= 16; /* mkdir failed.  */
 1113|      0|              else if (stat (prefix, &sb))
  ------------------
  |  Branch (1113:24): [True: 0, False: 0]
  ------------------
 1114|      0|                {
 1115|      0|                  if (errno != ENOENT)
  ------------------
  |  Branch (1115:23): [True: 0, False: 0]
  ------------------
 1116|      0|                    *r_info |= 1; /* stat failed. */
 1117|      0|                  else
 1118|      0|                    *r_info |= 64; /* Subdir does not exist.  */
 1119|      0|                }
 1120|      0|              else
 1121|      0|                goto leave; /* Success!  */
 1122|      0|            }
 1123|      0|          else
 1124|      0|            *r_info |= 64; /* Subdir does not exist.  */
 1125|      0|          if (!skip_checks)
  ------------------
  |  Branch (1125:15): [True: 0, False: 0]
  ------------------
 1126|      0|            {
 1127|      0|              xfree (name);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1128|      0|              name = NULL;
 1129|      0|              goto leave;
 1130|      0|            }
 1131|      0|        }
 1132|      0|      else if (!S_ISDIR(sb.st_mode)
  ------------------
  |  Branch (1132:16): [True: 0, False: 0]
  ------------------
 1133|      0|               || sb.st_uid != getuid ()
  ------------------
  |  Branch (1133:19): [True: 0, False: 0]
  ------------------
 1134|      0|               || (sb.st_mode & (S_IRWXG|S_IRWXO)))
  ------------------
  |  Branch (1134:19): [True: 0, False: 0]
  ------------------
 1135|      0|        {
 1136|      0|          *r_info |= 8; /* Bad permissions or subdir is not a directory.  */
 1137|      0|          if (!skip_checks)
  ------------------
  |  Branch (1137:15): [True: 0, False: 0]
  ------------------
 1138|      0|            {
 1139|      0|              xfree (name);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1140|      0|              name = NULL;
 1141|      0|              goto leave;
 1142|      0|            }
 1143|      0|        }
 1144|      0|    }
 1145|      0|  else
 1146|      0|    name = xstrdup (prefix);
  ------------------
  |  |  112|      0|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
 1147|       |
 1148|      1| leave:
 1149|       |  /* If nothing works fall back to the homedir.  */
 1150|      1|  if (!name)
  ------------------
  |  Branch (1150:7): [True: 1, False: 0]
  ------------------
 1151|      1|    {
 1152|      1|      *r_info |= 128; /* Fallback.  */
 1153|      1|      name = xstrdup (gnupg_homedir ());
  ------------------
  |  |  112|      1|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
 1154|      1|    }
 1155|       |
 1156|      1|#endif /* Unix */
 1157|       |
 1158|      1|  return name;
 1159|      0|}
gnupg_socketdir:
 1168|     11|{
 1169|     11|  static char *name;
 1170|       |
 1171|     11|  if (!name)
  ------------------
  |  Branch (1171:7): [True: 1, False: 10]
  ------------------
 1172|      1|    {
 1173|      1|      unsigned int dummy;
 1174|      1|      name = _gnupg_socketdir_internal (0, &dummy);
 1175|      1|      gpgrt_annotate_leaked_object (name);
 1176|      1|    }
 1177|       |
 1178|     11|  return name;
 1179|     11|}
homedir.c:copy_dir_with_fixup:
  178|      1|{
  179|      1|  char *result = NULL;
  180|      1|  char *p;
  181|       |
  182|      1|  if (!*newdir)
  ------------------
  |  Branch (182:7): [True: 0, False: 1]
  ------------------
  183|      0|    return NULL;
  184|       |
  185|       |#ifdef HAVE_W32_SYSTEM
  186|       |  if (newdir[0] && newdir[1] == ':'
  187|       |      && !(newdir[2] == '/' || newdir[2] == '\\'))
  188|       |    {
  189|       |      /* Drive letter with missing leading slash.  */
  190|       |      p = result = xmalloc (strlen (newdir) + 1 + 1);
  191|       |      *p++ = newdir[0];
  192|       |      *p++ = newdir[1];
  193|       |      *p++ = '\\';
  194|       |      strcpy (p, newdir+2);
  195|       |
  196|       |      /* Remove trailing slashes.  */
  197|       |      p = result + strlen (result) - 1;
  198|       |      while (p > result+2 && (*p == '/' || *p == '\\'))
  199|       |        *p-- = 0;
  200|       |    }
  201|       |  else if (newdir[strlen (newdir)-1] == '/'
  202|       |           || newdir[strlen (newdir)-1] == '\\' )
  203|       |    {
  204|       |      result = xstrdup (newdir);
  205|       |      p = result + strlen (result) - 1;
  206|       |      while (p > result
  207|       |             && (*p == '/' || *p == '\\')
  208|       |             && (p-1 > result && p[-1] != ':')) /* We keep "c:/". */
  209|       |        *p-- = 0;
  210|       |    }
  211|       |
  212|       |#else /*!HAVE_W32_SYSTEM*/
  213|       |
  214|      1|  if (newdir[strlen (newdir)-1] == '/')
  ------------------
  |  Branch (214:7): [True: 1, False: 0]
  ------------------
  215|      1|    {
  216|      1|      result = xstrdup (newdir);
  ------------------
  |  |  112|      1|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
  217|      1|      p = result + strlen (result) - 1;
  218|      2|      while (p > result && *p == '/')
  ------------------
  |  Branch (218:14): [True: 2, False: 0]
  |  Branch (218:28): [True: 1, False: 1]
  ------------------
  219|      1|        *p-- = 0;
  220|      1|    }
  221|       |
  222|      1|#endif /*!HAVE_W32_SYSTEM*/
  223|       |
  224|      1|  return result;
  225|      1|}
homedir.c:is_gnupg_default_homedir:
  161|      1|{
  162|      1|  int result;
  163|      1|  char *a = make_absfilename (dir, NULL);
  164|      1|  char *b = make_absfilename (standard_homedir (), NULL);
  165|      1|  result = !compare_filenames (a, b);
  166|      1|  xfree (b);
  ------------------
  |  |  104|      1|#define xfree(a)         gcry_free ((a))
  ------------------
  167|      1|  xfree (a);
  ------------------
  |  |  104|      1|#define xfree(a)         gcry_free ((a))
  ------------------
  168|      1|  return result;
  169|      1|}

register_mem_cleanup_func:
   93|      1|{
   94|      1|  mem_cleanup_item_t item;
   95|       |
   96|      1|  for (item = mem_cleanup_list; item; item = item->next)
  ------------------
  |  Branch (96:33): [True: 0, False: 1]
  ------------------
   97|      0|    if (item->func == func)
  ------------------
  |  Branch (97:9): [True: 0, False: 0]
  ------------------
   98|      0|      return; /* Function has already been registered.  */
   99|       |
  100|      1|  item = malloc (sizeof *item);
  101|      1|  if (item)
  ------------------
  |  Branch (101:7): [True: 1, False: 0]
  ------------------
  102|      1|    {
  103|      1|      item->func = func;
  104|      1|      item->next = mem_cleanup_list;
  105|      1|      mem_cleanup_list = item;
  106|      1|    }
  107|      1|}

iobuf_alloc:
 1182|    162|{
 1183|    162|  iobuf_t a;
 1184|    162|  static int number = 0;
 1185|       |
 1186|    162|  assert (use == IOBUF_INPUT || use == IOBUF_INPUT_TEMP
 1187|    162|	  || use == IOBUF_OUTPUT || use == IOBUF_OUTPUT_TEMP);
 1188|    162|  if (bufsize == 0)
  ------------------
  |  Branch (1188:7): [True: 0, False: 162]
  ------------------
 1189|      0|    {
 1190|      0|      log_bug ("iobuf_alloc() passed a bufsize of 0!\n");
 1191|      0|      bufsize = iobuf_buffer_size;
 1192|      0|    }
 1193|       |
 1194|    162|  a = xcalloc (1, sizeof *a);
  ------------------
  |  |  109|    162|#define xcalloc(a,b)     gcry_xcalloc ((a),(b))
  ------------------
 1195|    162|  a->use = use;
 1196|    162|  a->d.buf = xmalloc (bufsize);
  ------------------
  |  |  107|    162|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 1197|    162|  a->d.size = bufsize;
 1198|    162|  a->e_d.buf = NULL;
 1199|    162|  a->e_d.len = 0;
 1200|    162|  a->e_d.used = 0;
 1201|    162|  a->e_d.preferred = 0;
 1202|    162|  a->no = ++number;
 1203|    162|  a->subno = 0;
 1204|    162|  a->real_fname = NULL;
 1205|    162|  return a;
 1206|    162|}
iobuf_close:
 1210|  2.32k|{
 1211|  2.32k|  iobuf_t a_chain;
 1212|  2.32k|  size_t dummy_len = 0;
 1213|  2.32k|  int rc = 0;
 1214|       |
 1215|  2.50k|  for (; a; a = a_chain)
  ------------------
  |  Branch (1215:10): [True: 181, False: 2.32k]
  ------------------
 1216|    181|    {
 1217|    181|      byte desc[MAX_IOBUF_DESC];
 1218|    181|      int rc2 = 0;
 1219|       |
 1220|    181|      a_chain = a->chain;
 1221|       |
 1222|    181|      if (a->use == IOBUF_OUTPUT && (rc = filter_flush (a)))
  ------------------
  |  Branch (1222:11): [True: 1, False: 180]
  |  Branch (1222:37): [True: 0, False: 1]
  ------------------
 1223|      0|	log_error ("filter_flush failed on close: %s\n", gpg_strerror (rc));
 1224|       |
 1225|    181|      if (DBG_IOBUF)
  ------------------
  |  |   98|    181|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 181]
  |  |  ------------------
  ------------------
 1226|      0|	log_debug ("iobuf-%d.%d: close '%s'\n",
 1227|      0|		   a->no, a->subno, iobuf_desc (a, desc));
 1228|       |
 1229|    181|      if (a->filter && (rc2 = a->filter (a->filter_ov, IOBUFCTRL_FREE,
  ------------------
  |  Branch (1229:11): [True: 21, False: 160]
  |  Branch (1229:24): [True: 0, False: 21]
  ------------------
 1230|     21|					 a->chain, NULL, &dummy_len)))
 1231|      0|	log_error ("IOBUFCTRL_FREE failed on close: %s\n", gpg_strerror (rc));
 1232|    181|      if (! rc && rc2)
  ------------------
  |  Branch (1232:11): [True: 181, False: 0]
  |  Branch (1232:19): [True: 0, False: 181]
  ------------------
 1233|       |	/* Whoops!  An error occurred.  Save it in RC if we haven't
 1234|       |	   already recorded an error.  */
 1235|      0|	rc = rc2;
 1236|       |
 1237|    181|      xfree (a->real_fname);
  ------------------
  |  |  104|    181|#define xfree(a)         gcry_free ((a))
  ------------------
 1238|    181|      if (a->d.buf)
  ------------------
  |  Branch (1238:11): [True: 181, False: 0]
  ------------------
 1239|    181|	{
 1240|    181|	  memset (a->d.buf, 0, a->d.size);	/* erase the buffer */
 1241|    181|	  xfree (a->d.buf);
  ------------------
  |  |  104|    181|#define xfree(a)         gcry_free ((a))
  ------------------
 1242|    181|	}
 1243|    181|      xfree (a);
  ------------------
  |  |  104|    181|#define xfree(a)         gcry_free ((a))
  ------------------
 1244|    181|    }
 1245|  2.32k|  return rc;
 1246|  2.32k|}
iobuf_temp:
 1296|     84|{
 1297|     84|  return iobuf_alloc (IOBUF_OUTPUT_TEMP, iobuf_buffer_size);
 1298|     84|}
iobuf_temp_with_content:
 1302|     24|{
 1303|     24|  iobuf_t a;
 1304|     24|  int i;
 1305|       |
 1306|     24|  a = iobuf_alloc (IOBUF_INPUT_TEMP, length);
 1307|     24|  assert (length == a->d.size);
 1308|       |  /* memcpy (a->d.buf, buffer, length); */
 1309|  26.1k|  for (i=0; i < length; i++)
  ------------------
  |  Branch (1309:13): [True: 26.1k, False: 24]
  ------------------
 1310|  26.1k|    a->d.buf[i] = buffer[i];
 1311|     24|  a->d.len = length;
 1312|       |
 1313|     24|  return a;
 1314|     24|}
iobuf_open:
 1391|     53|{
 1392|     53|  return do_open (fname, 1, IOBUF_INPUT, "rb", 0);
 1393|     53|}
iobuf_create:
 1397|      1|{
 1398|      1|  return do_open (fname, 1, IOBUF_OUTPUT, "wb", mode700);
 1399|      1|}
iobuf_ioctl:
 1504|     54|{
 1505|     54|  byte desc[MAX_IOBUF_DESC];
 1506|       |
 1507|     54|  if (cmd == IOBUF_IOCTL_KEEP_OPEN)
  ------------------
  |  Branch (1507:7): [True: 0, False: 54]
  ------------------
 1508|      0|    {
 1509|       |      /* Keep system filepointer/descriptor open.  This was used in
 1510|       |         the past by http.c; this ioctl is not directly used
 1511|       |         anymore.  */
 1512|      0|      if (DBG_IOBUF)
  ------------------
  |  |   98|      0|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1513|      0|	log_debug ("iobuf-%d.%d: ioctl '%s' keep_open=%d\n",
 1514|      0|		   a ? a->no : -1, a ? a->subno : -1, iobuf_desc (a, desc),
  ------------------
  |  Branch (1514:6): [True: 0, False: 0]
  |  Branch (1514:22): [True: 0, False: 0]
  ------------------
 1515|      0|		   intval);
 1516|      0|      for (; a; a = a->chain)
  ------------------
  |  Branch (1516:14): [True: 0, False: 0]
  ------------------
 1517|      0|	if (!a->chain && a->filter == file_filter)
  ------------------
  |  Branch (1517:6): [True: 0, False: 0]
  |  Branch (1517:19): [True: 0, False: 0]
  ------------------
 1518|      0|	  {
 1519|      0|	    file_filter_ctx_t *b = a->filter_ov;
 1520|      0|	    b->keep_open = intval;
 1521|      0|	    return 0;
 1522|      0|	  }
 1523|       |#ifdef HAVE_W32_SYSTEM
 1524|       |	else if (!a->chain && a->filter == sock_filter)
 1525|       |	  {
 1526|       |	    sock_filter_ctx_t *b = a->filter_ov;
 1527|       |	    b->keep_open = intval;
 1528|       |	    return 0;
 1529|       |	  }
 1530|       |#endif
 1531|      0|    }
 1532|     54|  else if (cmd == IOBUF_IOCTL_INVALIDATE_CACHE)
  ------------------
  |  Branch (1532:12): [True: 54, False: 0]
  ------------------
 1533|     54|    {
 1534|     54|      if (DBG_IOBUF)
  ------------------
  |  |   98|     54|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 54]
  |  |  ------------------
  ------------------
 1535|      0|	log_debug ("iobuf-*.*: ioctl '%s' invalidate\n",
 1536|      0|		   ptrval ? (char *) ptrval : "?");
  ------------------
  |  Branch (1536:6): [True: 0, False: 0]
  ------------------
 1537|     54|      if (!a && !intval && ptrval)
  ------------------
  |  Branch (1537:11): [True: 54, False: 0]
  |  Branch (1537:17): [True: 54, False: 0]
  |  Branch (1537:28): [True: 54, False: 0]
  ------------------
 1538|     54|	{
 1539|     54|	  if (fd_cache_invalidate (ptrval))
  ------------------
  |  Branch (1539:8): [True: 0, False: 54]
  ------------------
 1540|      0|            return -1;
 1541|     54|	  return 0;
 1542|     54|	}
 1543|     54|    }
 1544|      0|  else if (cmd == IOBUF_IOCTL_NO_CACHE)
  ------------------
  |  Branch (1544:12): [True: 0, False: 0]
  ------------------
 1545|      0|    {
 1546|      0|      if (DBG_IOBUF)
  ------------------
  |  |   98|      0|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1547|      0|	log_debug ("iobuf-%d.%d: ioctl '%s' no_cache=%d\n",
 1548|      0|		   a ? a->no : -1, a ? a->subno : -1, iobuf_desc (a, desc),
  ------------------
  |  Branch (1548:6): [True: 0, False: 0]
  |  Branch (1548:22): [True: 0, False: 0]
  ------------------
 1549|      0|		   intval);
 1550|      0|      for (; a; a = a->chain)
  ------------------
  |  Branch (1550:14): [True: 0, False: 0]
  ------------------
 1551|      0|	if (!a->chain && a->filter == file_filter)
  ------------------
  |  Branch (1551:6): [True: 0, False: 0]
  |  Branch (1551:19): [True: 0, False: 0]
  ------------------
 1552|      0|	  {
 1553|      0|	    file_filter_ctx_t *b = a->filter_ov;
 1554|      0|	    b->no_cache = intval;
 1555|      0|	    return 0;
 1556|      0|	  }
 1557|       |#ifdef HAVE_W32_SYSTEM
 1558|       |	else if (!a->chain && a->filter == sock_filter)
 1559|       |	  {
 1560|       |	    sock_filter_ctx_t *b = a->filter_ov;
 1561|       |	    b->no_cache = intval;
 1562|       |	    return 0;
 1563|       |	  }
 1564|       |#endif
 1565|      0|    }
 1566|      0|  else if (cmd == IOBUF_IOCTL_FSYNC)
  ------------------
  |  Branch (1566:12): [True: 0, False: 0]
  ------------------
 1567|      0|    {
 1568|       |      /* Do a fsync on the open fd and return any errors to the caller
 1569|       |         of iobuf_ioctl.  Note that we work on a file name here. */
 1570|      0|      if (DBG_IOBUF)
  ------------------
  |  |   98|      0|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1571|      0|        log_debug ("iobuf-*.*: ioctl '%s' fsync\n",
 1572|      0|                   ptrval? (const char*)ptrval:"<null>");
  ------------------
  |  Branch (1572:20): [True: 0, False: 0]
  ------------------
 1573|       |
 1574|      0|      if (!a && !intval && ptrval)
  ------------------
  |  Branch (1574:11): [True: 0, False: 0]
  |  Branch (1574:17): [True: 0, False: 0]
  |  Branch (1574:28): [True: 0, False: 0]
  ------------------
 1575|      0|        {
 1576|      0|          return fd_cache_synchronize (ptrval);
 1577|      0|        }
 1578|      0|    }
 1579|       |
 1580|       |
 1581|      0|  return -1;
 1582|     54|}
iobuf_push_filter:
 1593|     55|{
 1594|     55|  return iobuf_push_filter2 (a, f, ov, 0);
 1595|     55|}
iobuf_push_filter2:
 1602|     55|{
 1603|     55|  iobuf_t b;
 1604|     55|  size_t dummy_len = 0;
 1605|     55|  int rc = 0;
 1606|       |
 1607|     55|  if (a->use == IOBUF_OUTPUT && (rc = filter_flush (a)))
  ------------------
  |  Branch (1607:7): [True: 0, False: 55]
  |  Branch (1607:33): [True: 0, False: 0]
  ------------------
 1608|      0|    return rc;
 1609|       |
 1610|     55|  if (a->subno >= MAX_NESTING_FILTER)
  ------------------
  |  |   67|     55|#define MAX_NESTING_FILTER 64
  ------------------
  |  Branch (1610:7): [True: 0, False: 55]
  ------------------
 1611|      0|    {
 1612|      0|      log_error ("i/o filter too deeply nested - corrupted data?\n");
 1613|      0|      return GPG_ERR_BAD_DATA;
 1614|      0|    }
 1615|       |
 1616|       |  /* We want to create a new filter and put it in front of A.  A
 1617|       |     simple implementation would do:
 1618|       |
 1619|       |       b = iobuf_alloc (...);
 1620|       |       b->chain = a;
 1621|       |       return a;
 1622|       |
 1623|       |     This is a bit problematic: A is the head of the pipeline and
 1624|       |     there are potentially many pointers to it.  Requiring the caller
 1625|       |     to update all of these pointers is a burden.
 1626|       |
 1627|       |     An alternative implementation would add a level of indirection.
 1628|       |     For instance, we could use a pipeline object, which contains a
 1629|       |     pointer to the first filter in the pipeline.  This is not what we
 1630|       |     do either.
 1631|       |
 1632|       |     Instead, we allocate a new buffer (B) and copy the first filter's
 1633|       |     state into that and use the initial buffer (A) for the new
 1634|       |     filter.  One limitation of this approach is that it is not
 1635|       |     practical to maintain a pointer to a specific filter's state.
 1636|       |
 1637|       |     Before:
 1638|       |
 1639|       |           A
 1640|       |           |
 1641|       |           v 0x100               0x200
 1642|       |           +----------+          +----------+
 1643|       |           | filter x |--------->| filter y |---->....
 1644|       |           +----------+          +----------+
 1645|       |
 1646|       |     After:           B
 1647|       |                      |
 1648|       |                      v 0x300
 1649|       |                      +----------+
 1650|       |           A          | filter x |
 1651|       |           |          +----------+
 1652|       |           v 0x100    ^          v 0x200
 1653|       |           +----------+          +----------+
 1654|       |           | filter w |          | filter y |---->....
 1655|       |           +----------+          +----------+
 1656|       |
 1657|       |     Note: filter x's address changed from 0x100 to 0x300, but A still
 1658|       |     points to the head of the pipeline.
 1659|       |  */
 1660|       |
 1661|     55|  b = xmalloc (sizeof *b);
  ------------------
  |  |  107|     55|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 1662|     55|  memcpy (b, a, sizeof *b);
 1663|       |  /* fixme: it is stupid to keep a copy of the name at every level
 1664|       |   * but we need the name somewhere because the name known by file_filter
 1665|       |   * may have been released when we need the name of the file */
 1666|     55|  b->real_fname = a->real_fname ? xstrdup (a->real_fname) : NULL;
  ------------------
  |  |  112|     55|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
  |  Branch (1666:19): [True: 55, False: 0]
  ------------------
 1667|       |  /* remove the filter stuff from the new stream */
 1668|     55|  a->filter = NULL;
 1669|     55|  a->filter_ov = NULL;
 1670|     55|  a->filter_ov_owner = 0;
 1671|     55|  a->filter_eof = 0;
 1672|     55|  if (a->use == IOBUF_OUTPUT_TEMP)
  ------------------
  |  Branch (1672:7): [True: 0, False: 55]
  ------------------
 1673|       |    /* A TEMP filter buffers any data sent to it; it does not forward
 1674|       |       any data down the pipeline.  If we add a new filter to the
 1675|       |       pipeline, it shouldn't also buffer data.  It should send it
 1676|       |       downstream to be buffered.  Thus, the correct type for a filter
 1677|       |       added in front of an IOBUF_OUTPUT_TEMP filter is IOBUF_OUPUT, not
 1678|       |       IOBUF_OUTPUT_TEMP.  */
 1679|      0|    {
 1680|      0|      a->use = IOBUF_OUTPUT;
 1681|       |
 1682|       |      /* When pipeline is written to, the temp buffer's size is
 1683|       |	 increased accordingly.  We don't need to allocate a 10 MB
 1684|       |	 buffer for a non-terminal filter.  Just use the default
 1685|       |	 size.  */
 1686|      0|      a->d.size = iobuf_buffer_size;
 1687|      0|    }
 1688|     55|  else if (a->use == IOBUF_INPUT_TEMP)
  ------------------
  |  Branch (1688:12): [True: 0, False: 55]
  ------------------
 1689|       |    /* Same idea as above.  */
 1690|      0|    {
 1691|      0|      a->use = IOBUF_INPUT;
 1692|      0|      a->d.size = iobuf_buffer_size;
 1693|      0|    }
 1694|       |
 1695|       |  /* The new filter (A) gets a new buffer.
 1696|       |
 1697|       |     If the pipeline is an output or temp pipeline, then giving the
 1698|       |     buffer to the new filter means that data that was written before
 1699|       |     the filter was pushed gets sent to the filter.  That's clearly
 1700|       |     wrong.
 1701|       |
 1702|       |     If the pipeline is an input pipeline, then giving the buffer to
 1703|       |     the new filter (A) means that data that has read from (B), but
 1704|       |     not yet read from the pipeline won't be processed by the new
 1705|       |     filter (A)!  That's certainly not what we want.  */
 1706|     55|  a->d.buf = xmalloc (a->d.size);
  ------------------
  |  |  107|     55|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 1707|     55|  a->d.len = 0;
 1708|     55|  a->d.start = 0;
 1709|       |
 1710|       |  /* disable nlimit for the new stream */
 1711|     55|  a->ntotal = b->ntotal + b->nbytes;
 1712|     55|  a->nlimit = a->nbytes = 0;
 1713|     55|  a->nofast = 0;
 1714|       |  /* make a link from the new stream to the original stream */
 1715|     55|  a->chain = b;
 1716|       |
 1717|       |  /* setup the function on the new stream */
 1718|     55|  a->filter = f;
 1719|     55|  a->filter_ov = ov;
 1720|     55|  a->filter_ov_owner = rel_ov;
 1721|       |
 1722|     55|  a->subno = b->subno + 1;
 1723|       |
 1724|     55|  if (DBG_IOBUF)
  ------------------
  |  |   98|     55|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 55]
  |  |  ------------------
  ------------------
 1725|      0|    {
 1726|      0|      byte desc[MAX_IOBUF_DESC];
 1727|      0|      log_debug ("iobuf-%d.%d: push '%s'\n",
 1728|      0|		 a->no, a->subno, iobuf_desc (a, desc));
 1729|      0|      print_chain (a);
 1730|      0|    }
 1731|       |
 1732|       |  /* now we can initialize the new function if we have one */
 1733|     55|  if (a->filter && (rc = a->filter (a->filter_ov, IOBUFCTRL_INIT, a->chain,
  ------------------
  |  Branch (1733:7): [True: 55, False: 0]
  |  Branch (1733:20): [True: 0, False: 55]
  ------------------
 1734|     55|				    NULL, &dummy_len)))
 1735|      0|    log_error ("IOBUFCTRL_INIT failed: %s\n", gpg_strerror (rc));
 1736|     55|  return rc;
 1737|     55|}
iobuf_readbyte:
 2101|  2.09k|{
 2102|  2.09k|  int c;
 2103|       |
 2104|  2.09k|  if (a->use == IOBUF_OUTPUT || a->use == IOBUF_OUTPUT_TEMP)
  ------------------
  |  Branch (2104:7): [True: 0, False: 2.09k]
  |  Branch (2104:33): [True: 0, False: 2.09k]
  ------------------
 2105|      0|    {
 2106|      0|      log_bug ("iobuf_readbyte called on a non-INPUT pipeline!\n");
 2107|      0|      return -1;
 2108|      0|    }
 2109|       |
 2110|  2.09k|  assert (a->d.start <= a->d.len);
 2111|       |
 2112|  2.09k|  if (a->nlimit && a->nbytes >= a->nlimit)
  ------------------
  |  Branch (2112:7): [True: 0, False: 2.09k]
  |  Branch (2112:20): [True: 0, False: 0]
  ------------------
 2113|      0|    return -1;			/* forced EOF */
 2114|       |
 2115|  2.09k|  if (a->d.start < a->d.len)
  ------------------
  |  Branch (2115:7): [True: 92, False: 2.00k]
  ------------------
 2116|     92|    {
 2117|     92|      c = a->d.buf[a->d.start++];
 2118|     92|    }
 2119|  2.00k|  else if ((c = underflow (a, 1)) == -1)
  ------------------
  |  Branch (2119:12): [True: 1.04k, False: 955]
  ------------------
 2120|  1.04k|    return -1;			/* EOF */
 2121|       |
 2122|  1.04k|  assert (a->d.start <= a->d.len);
 2123|       |
 2124|       |  /* Note: if underflow doesn't return EOF, then it returns the first
 2125|       |     byte that was read and advances a->d.start appropriately.  */
 2126|       |
 2127|  1.04k|  a->nbytes++;
 2128|  1.04k|  return c;
 2129|  1.04k|}
iobuf_read:
 2134|  4.81k|{
 2135|  4.81k|  unsigned char *buf = (unsigned char *)buffer;
 2136|  4.81k|  int c, n;
 2137|       |
 2138|  4.81k|  if (a->use == IOBUF_OUTPUT || a->use == IOBUF_OUTPUT_TEMP)
  ------------------
  |  Branch (2138:7): [True: 0, False: 4.81k]
  |  Branch (2138:33): [True: 0, False: 4.81k]
  ------------------
 2139|      0|    {
 2140|      0|      log_bug ("iobuf_read called on a non-INPUT pipeline!\n");
 2141|      0|      return -1;
 2142|      0|    }
 2143|       |
 2144|  4.81k|  if (a->nlimit)
  ------------------
  |  Branch (2144:7): [True: 0, False: 4.81k]
  ------------------
 2145|      0|    {
 2146|       |      /* Handle special cases. */
 2147|      0|      for (n = 0; n < buflen; n++)
  ------------------
  |  Branch (2147:19): [True: 0, False: 0]
  ------------------
 2148|      0|	{
 2149|      0|	  if ((c = iobuf_readbyte (a)) == -1)
  ------------------
  |  Branch (2149:8): [True: 0, False: 0]
  ------------------
 2150|      0|	    {
 2151|      0|	      if (!n)
  ------------------
  |  Branch (2151:12): [True: 0, False: 0]
  ------------------
 2152|      0|		return -1;	/* eof */
 2153|      0|	      break;
 2154|      0|	    }
 2155|       |
 2156|      0|	  if (buf)
  ------------------
  |  Branch (2156:8): [True: 0, False: 0]
  ------------------
 2157|      0|	    {
 2158|      0|	      *buf = c;
 2159|      0|	      buf++;
 2160|      0|	    }
 2161|      0|	}
 2162|      0|      return n;
 2163|      0|    }
 2164|       |
 2165|  4.81k|  a->e_d.buf = NULL;
 2166|  4.81k|  a->e_d.len = 0;
 2167|       |
 2168|       |  /* Hint for how full to fill iobuf internal drain buffer. */
 2169|  4.81k|  a->e_d.preferred = (a->use != IOBUF_INPUT_TEMP)
  ------------------
  |  Branch (2169:22): [True: 4.70k, False: 113]
  ------------------
 2170|  4.81k|    && (buf && buflen >= IOBUF_ZEROCOPY_THRESHOLD_SIZE);
  ------------------
  |  |   71|  4.59k|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
  |  Branch (2170:9): [True: 4.59k, False: 108]
  |  Branch (2170:16): [True: 1, False: 4.59k]
  ------------------
 2171|       |
 2172|  4.81k|  n = 0;
 2173|  4.81k|  do
 2174|  4.94k|    {
 2175|  4.94k|      if (n < buflen && a->d.start < a->d.len)
  ------------------
  |  Branch (2175:11): [True: 4.94k, False: 0]
  |  Branch (2175:25): [True: 4.74k, False: 202]
  ------------------
 2176|       |	/* Drain the buffer.  */
 2177|  4.74k|	{
 2178|  4.74k|	  unsigned size = a->d.len - a->d.start;
 2179|  4.74k|	  if (size > buflen - n)
  ------------------
  |  Branch (2179:8): [True: 4.67k, False: 74]
  ------------------
 2180|  4.67k|	    size = buflen - n;
 2181|  4.74k|	  if (buf)
  ------------------
  |  Branch (2181:8): [True: 4.70k, False: 41]
  ------------------
 2182|  4.70k|	    memcpy (buf, a->d.buf + a->d.start, size);
 2183|  4.74k|	  n += size;
 2184|  4.74k|	  a->d.start += size;
 2185|  4.74k|	  if (buf)
  ------------------
  |  Branch (2185:8): [True: 4.70k, False: 41]
  ------------------
 2186|  4.70k|	    buf += size;
 2187|  4.74k|	}
 2188|  4.94k|      if (n < buflen)
  ------------------
  |  Branch (2188:11): [True: 276, False: 4.67k]
  ------------------
 2189|       |	/* Draining the internal buffer didn't fill BUFFER.  Call
 2190|       |	   underflow to read more data into the filter's internal
 2191|       |	   buffer.  */
 2192|    276|	{
 2193|    276|	  if (a->use != IOBUF_INPUT_TEMP && buf && n < buflen)
  ------------------
  |  Branch (2193:8): [True: 276, False: 0]
  |  Branch (2193:38): [True: 36, False: 240]
  |  Branch (2193:45): [True: 36, False: 0]
  ------------------
 2194|     36|	    {
 2195|       |	      /* Setup external drain buffer for faster moving of data
 2196|       |	       * (avoid memcpy). */
 2197|     36|	      a->e_d.buf = buf;
 2198|     36|	      a->e_d.len = (buflen - n) / IOBUF_ZEROCOPY_THRESHOLD_SIZE
  ------------------
  |  |   71|     36|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
 2199|     36|			    * IOBUF_ZEROCOPY_THRESHOLD_SIZE;
  ------------------
  |  |   71|     36|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
 2200|     36|	      if (a->e_d.len == 0)
  ------------------
  |  Branch (2200:12): [True: 36, False: 0]
  ------------------
 2201|     36|		a->e_d.buf = NULL;
 2202|     36|	      if (a->e_d.buf && DBG_IOBUF)
  ------------------
  |  |   98|      0|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2202:12): [True: 0, False: 36]
  ------------------
 2203|      0|		log_debug ("iobuf-%d.%d: reading to external buffer, %lu bytes\n",
 2204|      0|			   a->no, a->subno, (ulong)a->e_d.len);
 2205|     36|	    }
 2206|       |
 2207|    276|	  if ((c = underflow (a, 1)) == -1)
  ------------------
  |  Branch (2207:8): [True: 141, False: 135]
  ------------------
 2208|       |	    /* EOF.  If we managed to read something, don't return EOF
 2209|       |	       now.  */
 2210|    141|	    {
 2211|    141|	      a->e_d.buf = NULL;
 2212|    141|	      a->e_d.len = 0;
 2213|    141|	      a->nbytes += n;
 2214|    141|	      return n ? n : -1 /*EOF*/;
  ------------------
  |  Branch (2214:15): [True: 69, False: 72]
  ------------------
 2215|    141|	    }
 2216|       |
 2217|    135|	  if (a->e_d.buf && a->e_d.used > 0)
  ------------------
  |  Branch (2217:8): [True: 0, False: 135]
  |  Branch (2217:22): [True: 0, False: 0]
  ------------------
 2218|      0|	    {
 2219|       |	      /* Drain buffer was used, 'c' only contains return code
 2220|       |	       * 0 or -1. */
 2221|      0|	      n += a->e_d.used;
 2222|      0|	      buf += a->e_d.used;
 2223|      0|	    }
 2224|    135|	  else
 2225|    135|	    {
 2226|    135|	      if (buf)
  ------------------
  |  Branch (2226:12): [True: 3, False: 132]
  ------------------
 2227|      3|		*buf++ = c;
 2228|    135|	      n++;
 2229|    135|	    }
 2230|       |
 2231|    135|	  a->e_d.buf = NULL;
 2232|    135|	  a->e_d.len = 0;
 2233|    135|	}
 2234|  4.94k|    }
 2235|  4.81k|  while (n < buflen);
  ------------------
  |  Branch (2235:10): [True: 134, False: 4.67k]
  ------------------
 2236|  4.67k|  a->nbytes += n;
 2237|  4.67k|  return n;
 2238|  4.81k|}
iobuf_writebyte:
 2286|  1.48k|{
 2287|  1.48k|  int rc;
 2288|       |
 2289|  1.48k|  if (a->use == IOBUF_INPUT || a->use == IOBUF_INPUT_TEMP)
  ------------------
  |  Branch (2289:7): [True: 0, False: 1.48k]
  |  Branch (2289:32): [True: 0, False: 1.48k]
  ------------------
 2290|      0|    {
 2291|      0|      log_bug ("iobuf_writebyte called on an input pipeline!\n");
 2292|      0|      return -1;
 2293|      0|    }
 2294|       |
 2295|  1.48k|  if (a->d.len == a->d.size)
  ------------------
  |  Branch (2295:7): [True: 0, False: 1.48k]
  ------------------
 2296|      0|    if ((rc=filter_flush (a)))
  ------------------
  |  Branch (2296:9): [True: 0, False: 0]
  ------------------
 2297|      0|      return rc;
 2298|       |
 2299|  1.48k|  assert (a->d.len < a->d.size);
 2300|  1.48k|  a->d.buf[a->d.len++] = c;
 2301|  1.48k|  return 0;
 2302|  1.48k|}
iobuf_write:
 2307|    423|{
 2308|    423|  const unsigned char *buf = (const unsigned char *)buffer;
 2309|    423|  int rc;
 2310|       |
 2311|    423|  if (a->use == IOBUF_INPUT || a->use == IOBUF_INPUT_TEMP)
  ------------------
  |  Branch (2311:7): [True: 0, False: 423]
  |  Branch (2311:32): [True: 0, False: 423]
  ------------------
 2312|      0|    {
 2313|      0|      log_bug ("iobuf_write called on an input pipeline!\n");
 2314|      0|      return -1;
 2315|      0|    }
 2316|       |
 2317|    423|  a->e_d.buf = NULL;
 2318|    423|  a->e_d.len = 0;
 2319|       |
 2320|       |  /* Hint for how full to fill iobuf internal drain buffer. */
 2321|    423|  a->e_d.preferred = (a->use != IOBUF_OUTPUT_TEMP)
  ------------------
  |  Branch (2321:22): [True: 0, False: 423]
  ------------------
 2322|    423|    && (buflen >= IOBUF_ZEROCOPY_THRESHOLD_SIZE);
  ------------------
  |  |   71|      0|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
  |  Branch (2322:8): [True: 0, False: 0]
  ------------------
 2323|       |
 2324|    423|  do
 2325|    423|    {
 2326|    423|      if ((a->use != IOBUF_OUTPUT_TEMP)
  ------------------
  |  Branch (2326:11): [True: 0, False: 423]
  ------------------
 2327|    423|	  && a->d.len == 0 && buflen >= IOBUF_ZEROCOPY_THRESHOLD_SIZE)
  ------------------
  |  |   71|      0|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
  |  Branch (2327:7): [True: 0, False: 0]
  |  Branch (2327:24): [True: 0, False: 0]
  ------------------
 2328|      0|	{
 2329|       |	  /* Setup external drain buffer for faster moving of data
 2330|       |	    * (avoid memcpy). */
 2331|      0|	  a->e_d.buf = (byte *)buf;
 2332|      0|	  a->e_d.len = buflen / IOBUF_ZEROCOPY_THRESHOLD_SIZE
  ------------------
  |  |   71|      0|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
 2333|      0|			* IOBUF_ZEROCOPY_THRESHOLD_SIZE;
  ------------------
  |  |   71|      0|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
 2334|      0|	  if (a->e_d.len == 0)
  ------------------
  |  Branch (2334:8): [True: 0, False: 0]
  ------------------
 2335|      0|	    a->e_d.buf = NULL;
 2336|      0|	  if (a->e_d.buf && DBG_IOBUF)
  ------------------
  |  |   98|      0|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2336:8): [True: 0, False: 0]
  ------------------
 2337|      0|	    log_debug ("iobuf-%d.%d: writing from external buffer, %lu bytes\n",
 2338|      0|			a->no, a->subno, (ulong)a->e_d.len);
 2339|      0|	}
 2340|       |
 2341|    423|      if (a->e_d.buf == NULL && buflen && a->d.len < a->d.size)
  ------------------
  |  Branch (2341:11): [True: 423, False: 0]
  |  Branch (2341:33): [True: 423, False: 0]
  |  Branch (2341:43): [True: 423, False: 0]
  ------------------
 2342|    423|	{
 2343|    423|	  unsigned size;
 2344|       |
 2345|    423|	  if (a->e_d.preferred && a->d.len < IOBUF_ZEROCOPY_THRESHOLD_SIZE)
  ------------------
  |  |   71|      0|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
  |  Branch (2345:8): [True: 0, False: 423]
  |  Branch (2345:28): [True: 0, False: 0]
  ------------------
 2346|      0|	    size = IOBUF_ZEROCOPY_THRESHOLD_SIZE - a->d.len;
  ------------------
  |  |   71|      0|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
 2347|    423|	  else
 2348|    423|	    size = a->d.size - a->d.len;
 2349|       |
 2350|    423|	  if (size > buflen)
  ------------------
  |  Branch (2350:8): [True: 423, False: 0]
  ------------------
 2351|    423|	    size = buflen;
 2352|    423|	  memcpy (a->d.buf + a->d.len, buf, size);
 2353|    423|	  buflen -= size;
 2354|    423|	  buf += size;
 2355|    423|	  a->d.len += size;
 2356|    423|	}
 2357|       |
 2358|    423|      if (buflen)
  ------------------
  |  Branch (2358:11): [True: 0, False: 423]
  ------------------
 2359|      0|	{
 2360|      0|	  rc = filter_flush (a);
 2361|      0|          if (rc)
  ------------------
  |  Branch (2361:15): [True: 0, False: 0]
  ------------------
 2362|      0|	    {
 2363|      0|	      a->e_d.buf = NULL;
 2364|      0|	      a->e_d.len = 0;
 2365|      0|	      return rc;
 2366|      0|	    }
 2367|      0|	}
 2368|       |
 2369|    423|      if (a->e_d.buf && a->e_d.used > 0)
  ------------------
  |  Branch (2369:11): [True: 0, False: 423]
  |  Branch (2369:25): [True: 0, False: 0]
  ------------------
 2370|      0|	{
 2371|      0|	  buf += a->e_d.used;
 2372|      0|	  buflen -= a->e_d.used;
 2373|      0|	}
 2374|       |
 2375|    423|      a->e_d.buf = NULL;
 2376|    423|      a->e_d.len = 0;
 2377|    423|    }
 2378|    423|  while (buflen);
  ------------------
  |  Branch (2378:10): [True: 0, False: 423]
  ------------------
 2379|    423|  return 0;
 2380|    423|}
iobuf_write_temp:
 2399|     73|{
 2400|     73|  assert (source->use == IOBUF_OUTPUT || source->use == IOBUF_OUTPUT_TEMP);
 2401|     73|  assert (dest->use == IOBUF_OUTPUT || dest->use == IOBUF_OUTPUT_TEMP);
 2402|       |
 2403|     73|  iobuf_flush_temp (source);
 2404|     73|  return iobuf_write (dest, source->d.buf, source->d.len);
 2405|     73|}
iobuf_flush_temp:
 2481|     73|{
 2482|     73|  if (temp->use == IOBUF_INPUT || temp->use == IOBUF_INPUT_TEMP)
  ------------------
  |  Branch (2482:7): [True: 0, False: 73]
  |  Branch (2482:35): [True: 0, False: 73]
  ------------------
 2483|      0|    log_bug ("iobuf_flush_temp called on an input pipeline!\n");
 2484|     73|  while (temp->chain)
  ------------------
  |  Branch (2484:10): [True: 0, False: 73]
  ------------------
 2485|      0|    iobuf_pop_filter (temp, temp->filter, NULL);
 2486|     73|}
iobuf_get_fd:
 2580|     53|{
 2581|     53|  for (; a->chain; a = a->chain)
  ------------------
  |  Branch (2581:10): [True: 0, False: 53]
  ------------------
 2582|      0|    ;
 2583|       |
 2584|     53|  if (a->filter != file_filter)
  ------------------
  |  Branch (2584:7): [True: 0, False: 53]
  ------------------
 2585|      0|    return -1;
 2586|       |
 2587|     53|  {
 2588|     53|    file_filter_ctx_t *b = a->filter_ov;
 2589|     53|    gnupg_fd_t fp = b->fp;
 2590|       |
 2591|     53|    return FD2INT (fp);
  ------------------
  |  |   46|     53|#define FD2INT(h) (h)
  ------------------
 2592|     53|  }
 2593|     53|}
iobuf_set_partial_body_length_mode:
 2745|      2|{
 2746|      2|  if (!len)
  ------------------
  |  Branch (2746:7): [True: 0, False: 2]
  ------------------
 2747|       |    /* Disable partial body length mode.  */
 2748|      0|    {
 2749|      0|      if (a->use == IOBUF_INPUT)
  ------------------
  |  Branch (2749:11): [True: 0, False: 0]
  ------------------
 2750|      0|	log_debug ("iobuf_pop_filter called in set_partial_block_mode"
 2751|      0|		   " - please report\n");
 2752|       |
 2753|      0|      log_assert (a->filter == block_filter);
 2754|      0|      iobuf_pop_filter (a, block_filter, NULL);
 2755|      0|    }
 2756|      2|  else
 2757|       |    /* Enabled partial body length mode.  */
 2758|      2|    {
 2759|      2|      block_filter_ctx_t *ctx = xcalloc (1, sizeof *ctx);
  ------------------
  |  |  109|      2|#define xcalloc(a,b)     gcry_xcalloc ((a),(b))
  ------------------
 2760|      2|      ctx->use = a->use;
 2761|      2|      ctx->partial = 1;
 2762|      2|      ctx->size = 0;
 2763|      2|      ctx->first_c = len;
 2764|      2|      iobuf_push_filter (a, block_filter, ctx);
 2765|      2|    }
 2766|      2|}
iobuf_read_line:
 2773|  7.04k|{
 2774|  7.04k|  int c;
 2775|  7.04k|  char *buffer = (char *)*addr_of_buffer;
 2776|  7.04k|  unsigned length = *length_of_buffer;
 2777|  7.04k|  unsigned nbytes = 0;
 2778|  7.04k|  unsigned maxlen = *max_length;
 2779|  7.04k|  char *p;
 2780|       |
 2781|       |  /* The code assumes that we have space for at least a newline and a
 2782|       |     NUL character in the buffer.  This requires at least 2 bytes.  We
 2783|       |     don't complicate the code by handling the stupid corner case, but
 2784|       |     simply assert that it can't happen.  */
 2785|  7.04k|  assert (!buffer || length >= 2 || maxlen >= 2);
 2786|       |
 2787|  7.04k|  if (!buffer || length <= 1)
  ------------------
  |  Branch (2787:7): [True: 53, False: 6.99k]
  |  Branch (2787:18): [True: 0, False: 6.99k]
  ------------------
 2788|       |    /* must allocate a new buffer */
 2789|     53|    {
 2790|     53|      length = 256 <= maxlen ? 256 : maxlen;
  ------------------
  |  Branch (2790:16): [True: 53, False: 0]
  ------------------
 2791|     53|      buffer = xrealloc (buffer, length);
  ------------------
  |  |  111|     53|#define xrealloc(a,b)    gcry_xrealloc ((a),(b))
  ------------------
 2792|     53|      *addr_of_buffer = (unsigned char *)buffer;
 2793|     53|      *length_of_buffer = length;
 2794|     53|    }
 2795|       |
 2796|  7.04k|  p = buffer;
 2797|  7.39k|  while (1)
  ------------------
  |  Branch (2797:10): [Folded - Ignored]
  ------------------
 2798|  7.39k|    {
 2799|  7.39k|      if (!a->nofast && a->d.start < a->d.len && nbytes < length - 1)
  ------------------
  |  Branch (2799:11): [True: 7.39k, False: 0]
  |  Branch (2799:25): [True: 7.26k, False: 137]
  |  Branch (2799:50): [True: 7.26k, False: 0]
  ------------------
 2800|       |	/* Fast path for finding '\n' by using standard C library's optimized
 2801|       |	   memchr.  */
 2802|  7.26k|	{
 2803|  7.26k|	  unsigned size = a->d.len - a->d.start;
 2804|  7.26k|	  byte *newline_pos;
 2805|       |
 2806|  7.26k|	  if (size > length - 1 - nbytes)
  ------------------
  |  Branch (2806:8): [True: 7.00k, False: 256]
  ------------------
 2807|  7.00k|	    size = length - 1 - nbytes;
 2808|       |
 2809|  7.26k|	  newline_pos = memchr (a->d.buf + a->d.start, '\n', size);
 2810|  7.26k|	  if (newline_pos)
  ------------------
  |  Branch (2810:8): [True: 6.96k, False: 300]
  ------------------
 2811|  6.96k|	    {
 2812|       |	      /* Found newline, copy buffer and return. */
 2813|  6.96k|	      size = (newline_pos - (a->d.buf + a->d.start)) + 1;
 2814|  6.96k|	      memcpy (p, a->d.buf + a->d.start, size);
 2815|  6.96k|	      p += size;
 2816|  6.96k|	      nbytes += size;
 2817|  6.96k|	      a->d.start += size;
 2818|  6.96k|	      a->nbytes += size;
 2819|  6.96k|	      break;
 2820|  6.96k|	    }
 2821|    300|	  else
 2822|    300|	    {
 2823|       |	      /* No newline, copy buffer and continue. */
 2824|    300|	      memcpy (p, a->d.buf + a->d.start, size);
 2825|    300|	      p += size;
 2826|    300|	      nbytes += size;
 2827|    300|	      a->d.start += size;
 2828|    300|	      a->nbytes += size;
 2829|    300|	    }
 2830|  7.26k|	}
 2831|    137|      else
 2832|    137|	{
 2833|    137|	  c = iobuf_readbyte (a);
 2834|    137|	  if (c == -1)
  ------------------
  |  Branch (2834:8): [True: 84, False: 53]
  ------------------
 2835|     84|	    break;
 2836|     53|	  *p++ = c;
 2837|     53|	  nbytes++;
 2838|     53|	  if (c == '\n')
  ------------------
  |  Branch (2838:8): [True: 0, False: 53]
  ------------------
 2839|      0|	    break;
 2840|     53|	}
 2841|       |
 2842|    353|      if (nbytes == length - 1)
  ------------------
  |  Branch (2842:11): [True: 261, False: 92]
  ------------------
 2843|       |	/* We don't have enough space to add a \n and a \0.  Increase
 2844|       |	   the buffer size.  */
 2845|    261|	{
 2846|    261|	  if (length == maxlen)
  ------------------
  |  Branch (2846:8): [True: 0, False: 261]
  ------------------
 2847|       |	    /* We reached the buffer's size limit!  */
 2848|      0|	    {
 2849|       |	      /* Skip the rest of the line.  */
 2850|      0|	      while ((c = iobuf_get (a)) != -1 && c != '\n')
  ------------------
  |  |  500|      0|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 0]
  |  |  |  Branch (500:24): [True: 0, False: 0]
  |  |  ------------------
  |  |  501|      0|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (2850:15): [True: 0, False: 0]
  |  Branch (2850:44): [True: 0, False: 0]
  ------------------
 2851|      0|		;
 2852|       |
 2853|       |	      /* p is pointing at the last byte in the buffer.  We
 2854|       |		 always terminate the line with "\n\0" so overwrite
 2855|       |		 the previous byte with a \n.  */
 2856|      0|	      assert (p > buffer);
 2857|      0|	      p[-1] = '\n';
 2858|       |
 2859|       |	      /* Indicate truncation.  */
 2860|      0|	      *max_length = 0;
 2861|      0|	      break;
 2862|      0|	    }
 2863|       |
 2864|    261|	  length += length < 1024 ? 256 : 1024;
  ------------------
  |  Branch (2864:14): [True: 77, False: 184]
  ------------------
 2865|    261|	  if (length > maxlen)
  ------------------
  |  Branch (2865:8): [True: 0, False: 261]
  ------------------
 2866|      0|	    length = maxlen;
 2867|       |
 2868|    261|	  buffer = xrealloc (buffer, length);
  ------------------
  |  |  111|    261|#define xrealloc(a,b)    gcry_xrealloc ((a),(b))
  ------------------
 2869|    261|	  *addr_of_buffer = (unsigned char *)buffer;
 2870|    261|	  *length_of_buffer = length;
 2871|    261|	  p = buffer + nbytes;
 2872|    261|	}
 2873|    353|    }
 2874|       |  /* Add the terminating NUL.  */
 2875|  7.04k|  *p = 0;
 2876|       |
 2877|       |  /* Return the number of characters written to the buffer including
 2878|       |     the newline, but not including the terminating NUL.  */
 2879|  7.04k|  return nbytes;
 2880|  7.04k|}
iobuf_skip_rest:
 2915|  4.83k|{
 2916|  4.83k|  if ( partial )
  ------------------
  |  Branch (2916:8): [True: 0, False: 4.83k]
  ------------------
 2917|      0|    {
 2918|      0|      for (;;)
 2919|      0|        {
 2920|      0|          if (a->nofast || a->d.start >= a->d.len)
  ------------------
  |  Branch (2920:15): [True: 0, False: 0]
  |  Branch (2920:28): [True: 0, False: 0]
  ------------------
 2921|      0|            {
 2922|      0|              if (iobuf_readbyte (a) == -1)
  ------------------
  |  Branch (2922:19): [True: 0, False: 0]
  ------------------
 2923|      0|                {
 2924|      0|                  break;
 2925|      0|                }
 2926|      0|	    }
 2927|      0|          else
 2928|      0|            {
 2929|      0|              unsigned long count = a->d.len - a->d.start;
 2930|      0|              a->nbytes += count;
 2931|      0|              a->d.start = a->d.len;
 2932|      0|	    }
 2933|      0|	}
 2934|      0|    }
 2935|  4.83k|  else
 2936|  4.83k|    {
 2937|  4.83k|      unsigned long remaining = n;
 2938|  5.26k|      while (remaining > 0)
  ------------------
  |  Branch (2938:14): [True: 534, False: 4.73k]
  ------------------
 2939|    534|        {
 2940|    534|          if (a->nofast || a->d.start >= a->d.len)
  ------------------
  |  Branch (2940:15): [True: 0, False: 534]
  |  Branch (2940:28): [True: 253, False: 281]
  ------------------
 2941|    253|            {
 2942|    253|              if (iobuf_readbyte (a) == -1)
  ------------------
  |  Branch (2942:19): [True: 101, False: 152]
  ------------------
 2943|    101|                {
 2944|    101|                  break;
 2945|    101|		}
 2946|    152|              --remaining;
 2947|    152|	    }
 2948|    281|          else
 2949|    281|            {
 2950|    281|              unsigned long count = a->d.len - a->d.start;
 2951|    281|              if (count > remaining)
  ------------------
  |  Branch (2951:19): [True: 216, False: 65]
  ------------------
 2952|    216|                {
 2953|    216|                  count = remaining;
 2954|    216|		}
 2955|    281|              a->nbytes += count;
 2956|    281|              a->d.start += count;
 2957|    281|              remaining -= count;
 2958|    281|	    }
 2959|    534|	}
 2960|  4.83k|    }
 2961|  4.83k|}
iobuf.c:print_chain:
 1160|     36|{
 1161|     36|  if (!DBG_IOBUF)
  ------------------
  |  |   98|     36|#define DBG_IOBUF   iobuf_debug_mode
  ------------------
  |  Branch (1161:7): [True: 36, False: 0]
  ------------------
 1162|     36|    return;
 1163|      0|  for (; a; a = a->chain)
  ------------------
  |  Branch (1163:10): [True: 0, False: 0]
  ------------------
 1164|      0|    {
 1165|      0|      byte desc[MAX_IOBUF_DESC];
 1166|       |
 1167|      0|      log_debug ("iobuf chain: %d.%d '%s' filter_eof=%d start=%d len=%d\n",
 1168|      0|		 a->no, a->subno, iobuf_desc (a, desc), a->filter_eof,
 1169|      0|		 (int) a->d.start, (int) a->d.len);
 1170|      0|    }
 1171|      0|}
iobuf.c:do_open:
 1329|     54|{
 1330|     54|  iobuf_t a;
 1331|     54|  gnupg_fd_t fp;
 1332|     54|  file_filter_ctx_t *fcx;
 1333|     54|  size_t len = 0;
 1334|     54|  int print_only = 0;
 1335|     54|  int fd;
 1336|     54|  byte desc[MAX_IOBUF_DESC];
 1337|       |
 1338|     54|  assert (use == IOBUF_INPUT || use == IOBUF_OUTPUT);
 1339|       |
 1340|     54|  if (special_filenames
  ------------------
  |  Branch (1340:7): [True: 54, False: 0]
  ------------------
 1341|       |      /* NULL or '-'.  */
 1342|     54|      && (!fname || (*fname == '-' && !fname[1])))
  ------------------
  |  Branch (1342:11): [True: 0, False: 54]
  |  Branch (1342:22): [True: 0, False: 54]
  |  Branch (1342:39): [True: 0, False: 0]
  ------------------
 1343|      0|    {
 1344|      0|      if (use == IOBUF_INPUT)
  ------------------
  |  Branch (1344:11): [True: 0, False: 0]
  ------------------
 1345|      0|	{
 1346|      0|	  fp = FD_FOR_STDIN;
  ------------------
  |  |   84|      0|# define FD_FOR_STDIN  (0)
  ------------------
 1347|      0|	  fname = "[stdin]";
 1348|      0|	}
 1349|      0|      else
 1350|      0|	{
 1351|      0|	  fp = FD_FOR_STDOUT;
  ------------------
  |  |   85|      0|# define FD_FOR_STDOUT (1)
  ------------------
 1352|      0|	  fname = "[stdout]";
 1353|      0|	}
 1354|      0|      print_only = 1;
 1355|      0|    }
 1356|     54|  else if (!fname)
  ------------------
  |  Branch (1356:12): [True: 0, False: 54]
  ------------------
 1357|      0|    return NULL;
 1358|     54|  else if (special_filenames
  ------------------
  |  Branch (1358:12): [True: 54, False: 0]
  ------------------
 1359|     54|           && (fd = check_special_filename (fname, 0, 1)) != -1)
  ------------------
  |  Branch (1359:15): [True: 0, False: 54]
  ------------------
 1360|      0|    return iobuf_fdopen (translate_file_handle (fd, use == IOBUF_INPUT ? 0 : 1),
  ------------------
  |  Branch (1360:53): [True: 0, False: 0]
  ------------------
 1361|      0|			 opentype);
 1362|     54|  else
 1363|     54|    {
 1364|     54|      if (use == IOBUF_INPUT)
  ------------------
  |  Branch (1364:11): [True: 53, False: 1]
  ------------------
 1365|     53|	fp = fd_cache_open (fname, opentype);
 1366|      1|      else
 1367|      1|	fp = direct_open (fname, opentype, mode700);
 1368|     54|      if (fp == GNUPG_INVALID_FD)
  ------------------
  |  |   44|     54|#define GNUPG_INVALID_FD (-1)
  ------------------
  |  Branch (1368:11): [True: 0, False: 54]
  ------------------
 1369|      0|	return NULL;
 1370|     54|    }
 1371|       |
 1372|     54|  a = iobuf_alloc (use, iobuf_buffer_size);
 1373|     54|  fcx = xmalloc (sizeof *fcx + strlen (fname));
  ------------------
  |  |  107|     54|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 1374|     54|  fcx->fp = fp;
 1375|     54|  fcx->print_only_name = print_only;
 1376|     54|  strcpy (fcx->fname, fname);
 1377|     54|  if (!print_only)
  ------------------
  |  Branch (1377:7): [True: 54, False: 0]
  ------------------
 1378|     54|    a->real_fname = xstrdup (fname);
  ------------------
  |  |  112|     54|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
 1379|     54|  a->filter = file_filter;
 1380|     54|  a->filter_ov = fcx;
 1381|     54|  file_filter (fcx, IOBUFCTRL_INIT, NULL, NULL, &len);
 1382|     54|  if (DBG_IOBUF)
  ------------------
  |  |   98|     54|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 54]
  |  |  ------------------
  ------------------
 1383|      0|    log_debug ("iobuf-%d.%d: open '%s' desc=%s fd=%d\n",
 1384|      0|	       a->no, a->subno, fname, iobuf_desc (a, desc), FD2INT (fcx->fp));
  ------------------
  |  |   46|      0|#define FD2INT(h) (h)
  ------------------
 1385|       |
 1386|     54|  return a;
 1387|     54|}
iobuf.c:fd_cache_open:
  411|     53|{
  412|     53|  close_cache_t cc;
  413|       |
  414|     53|  assert (fname);
  415|    158|  for (cc = close_cache; cc; cc = cc->next)
  ------------------
  |  Branch (415:26): [True: 105, False: 53]
  ------------------
  416|    105|    {
  417|    105|      if (cc->fp != GNUPG_INVALID_FD && !fd_cache_strcmp (cc->fname, fname))
  ------------------
  |  |   44|    210|#define GNUPG_INVALID_FD (-1)
  ------------------
  |  Branch (417:11): [True: 0, False: 105]
  |  Branch (417:41): [True: 0, False: 0]
  ------------------
  418|      0|	{
  419|      0|	  gnupg_fd_t fp = cc->fp;
  420|      0|	  cc->fp = GNUPG_INVALID_FD;
  ------------------
  |  |   44|      0|#define GNUPG_INVALID_FD (-1)
  ------------------
  421|      0|	  if (DBG_IOBUF)
  ------------------
  |  |   98|      0|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  422|      0|	    log_debug ("fd_cache_open (%s) using cached fp\n", fname);
  423|       |#ifdef HAVE_W32_SYSTEM
  424|       |	  if (SetFilePointer (fp, 0, NULL, FILE_BEGIN) == 0xffffffff)
  425|       |	    {
  426|       |	      log_error ("rewind file failed on handle %p: ec=%d\n",
  427|       |			 fp, (int) GetLastError ());
  428|       |	      fp = GNUPG_INVALID_FD;
  429|       |	    }
  430|       |#else
  431|      0|	  if (lseek (fp, 0, SEEK_SET) == (off_t) - 1)
  ------------------
  |  Branch (431:8): [True: 0, False: 0]
  ------------------
  432|      0|	    {
  433|      0|	      log_error ("can't rewind fd %d: %s\n", fp, strerror (errno));
  434|      0|	      fp = GNUPG_INVALID_FD;
  ------------------
  |  |   44|      0|#define GNUPG_INVALID_FD (-1)
  ------------------
  435|      0|	    }
  436|      0|#endif
  437|      0|	  return fp;
  438|      0|	}
  439|    105|    }
  440|     53|  if (DBG_IOBUF)
  ------------------
  |  |   98|     53|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 53]
  |  |  ------------------
  ------------------
  441|      0|    log_debug ("fd_cache_open (%s) not cached\n", fname);
  442|     53|  return direct_open (fname, mode, 0);
  443|     53|}
iobuf.c:fd_cache_strcmp:
  186|    107|{
  187|       |#ifdef HAVE_DOSISH_SYSTEM
  188|       |  for (; *a && *b; a++, b++)
  189|       |    {
  190|       |      if (*a != *b && !((*a == '/' && *b == '\\')
  191|       |                        || (*a == '\\' && *b == '/')) )
  192|       |        break;
  193|       |    }
  194|       |  return *(const unsigned char *)a - *(const unsigned char *)b;
  195|       |#else
  196|    107|  return strcmp (a, b);
  197|    107|#endif
  198|    107|}
iobuf.c:direct_open:
  267|     54|{
  268|       |#ifdef HAVE_W32_SYSTEM
  269|       |  unsigned long da, cd, sm;
  270|       |  HANDLE hfile;
  271|       |
  272|       |  (void)mode700;
  273|       |  /* Note, that we do not handle all mode combinations */
  274|       |
  275|       |  /* According to the ReactOS source it seems that open() of the
  276|       |   * standard MSW32 crt does open the file in shared mode which is
  277|       |   * something new for MS applications ;-)
  278|       |   */
  279|       |  if (strchr (mode, '+'))
  280|       |    {
  281|       |      if (fd_cache_invalidate (fname))
  282|       |        return GNUPG_INVALID_FD;
  283|       |      da = GENERIC_READ | GENERIC_WRITE;
  284|       |      cd = OPEN_EXISTING;
  285|       |      sm = FILE_SHARE_READ | FILE_SHARE_WRITE;
  286|       |    }
  287|       |  else if (strchr (mode, 'w'))
  288|       |    {
  289|       |      if (fd_cache_invalidate (fname))
  290|       |        return GNUPG_INVALID_FD;
  291|       |      da = GENERIC_WRITE;
  292|       |      cd = CREATE_ALWAYS;
  293|       |      sm = FILE_SHARE_WRITE;
  294|       |    }
  295|       |  else
  296|       |    {
  297|       |      da = GENERIC_READ;
  298|       |      cd = OPEN_EXISTING;
  299|       |      sm = FILE_SHARE_READ;
  300|       |    }
  301|       |
  302|       |  /* We always use the Unicode version because it supports file names
  303|       |   * longer than MAX_PATH.  (requires gpgrt 1.45) */
  304|       |  if (1)
  305|       |    {
  306|       |      wchar_t *wfname = gpgrt_fname_to_wchar (fname);
  307|       |      if (wfname)
  308|       |        {
  309|       |          hfile = CreateFileW (wfname, da, sm, NULL, cd,
  310|       |                               FILE_ATTRIBUTE_NORMAL, NULL);
  311|       |          xfree (wfname);
  312|       |        }
  313|       |      else
  314|       |        hfile = INVALID_HANDLE_VALUE;
  315|       |    }
  316|       |
  317|       |  return hfile;
  318|       |
  319|       |#else /*!HAVE_W32_SYSTEM*/
  320|       |
  321|     54|  int oflag;
  322|     54|  int cflag = S_IRUSR | S_IWUSR;
  323|       |
  324|     54|  if (!mode700)
  ------------------
  |  Branch (324:7): [True: 54, False: 0]
  ------------------
  325|     54|    cflag |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
  326|       |
  327|       |  /* Note, that we do not handle all mode combinations */
  328|     54|  if (strchr (mode, '+'))
  ------------------
  |  Branch (328:7): [True: 0, False: 54]
  ------------------
  329|      0|    {
  330|      0|      if (fd_cache_invalidate (fname))
  ------------------
  |  Branch (330:11): [True: 0, False: 0]
  ------------------
  331|      0|        return GNUPG_INVALID_FD;
  ------------------
  |  |   44|      0|#define GNUPG_INVALID_FD (-1)
  ------------------
  332|      0|      oflag = O_RDWR;
  333|      0|    }
  334|     54|  else if (strchr (mode, 'w'))
  ------------------
  |  Branch (334:12): [True: 1, False: 53]
  ------------------
  335|      1|    {
  336|      1|      if (fd_cache_invalidate (fname))
  ------------------
  |  Branch (336:11): [True: 0, False: 1]
  ------------------
  337|      0|        return GNUPG_INVALID_FD;
  ------------------
  |  |   44|      0|#define GNUPG_INVALID_FD (-1)
  ------------------
  338|      1|      oflag = O_WRONLY | O_CREAT | O_TRUNC;
  339|      1|    }
  340|     53|  else
  341|     53|    {
  342|     53|      oflag = O_RDONLY;
  343|     53|    }
  344|       |#ifdef O_BINARY
  345|       |  if (strchr (mode, 'b'))
  346|       |    oflag |= O_BINARY;
  347|       |#endif
  348|       |
  349|       |#ifdef __riscos__
  350|       |  {
  351|       |    struct stat buf;
  352|       |
  353|       |    /* Don't allow iobufs on directories */
  354|       |    if (!stat (fname, &buf) && S_ISDIR (buf.st_mode) && !S_ISREG (buf.st_mode))
  355|       |      return __set_errno (EISDIR);
  356|       |  }
  357|       |#endif
  358|     54|  return open (fname, oflag, cflag);
  359|       |
  360|     54|#endif /*!HAVE_W32_SYSTEM*/
  361|     54|}
iobuf.c:file_filter:
  449|    214|{
  450|    214|  file_filter_ctx_t *a = opaque;
  451|    214|  gnupg_fd_t f = a->fp;
  452|    214|  size_t size = *ret_len;
  453|    214|  size_t nbytes = 0;
  454|    214|  int rc = 0;
  455|       |
  456|    214|  (void)chain; /* Not used.  */
  457|       |
  458|    214|  if (control == IOBUFCTRL_UNDERFLOW)
  ------------------
  |  Branch (458:7): [True: 105, False: 109]
  ------------------
  459|    105|    {
  460|    105|      log_assert (size); /* We need a buffer.  */
  461|    105|      if (a->eof_seen)
  ------------------
  |  Branch (461:11): [True: 0, False: 105]
  ------------------
  462|      0|	{
  463|      0|	  rc = -1;
  464|      0|	  *ret_len = 0;
  465|      0|	}
  466|    105|      else if (a->delayed_rc)
  ------------------
  |  Branch (466:16): [True: 52, False: 53]
  ------------------
  467|     52|        {
  468|     52|          rc = a->delayed_rc;
  469|     52|          a->delayed_rc = 0;
  470|     52|          if (rc == -1)
  ------------------
  |  Branch (470:15): [True: 52, False: 0]
  ------------------
  471|     52|            a->eof_seen = -1;
  472|     52|	  *ret_len = 0;
  473|     52|        }
  474|     53|      else
  475|     53|	{
  476|       |#ifdef HAVE_W32_SYSTEM
  477|       |	  unsigned long nread;
  478|       |
  479|       |	  nbytes = 0;
  480|       |	  if (!ReadFile (f, buf, size, &nread, NULL))
  481|       |	    {
  482|       |	      int ec = (int) GetLastError ();
  483|       |	      if (ec != ERROR_BROKEN_PIPE)
  484|       |		{
  485|       |		  rc = gpg_error_from_errno (ec);
  486|       |		  log_error ("%s: read error: ec=%d\n", a->fname, ec);
  487|       |		}
  488|       |	    }
  489|       |	  else if (!nread)
  490|       |	    {
  491|       |	      a->eof_seen = 1;
  492|       |	      rc = -1;
  493|       |	    }
  494|       |	  else
  495|       |	    {
  496|       |	      nbytes = nread;
  497|       |	    }
  498|       |
  499|       |#else
  500|       |
  501|     53|	  int n;
  502|       |
  503|     53|	  nbytes = 0;
  504|    106|        read_more:
  505|    106|          do
  506|    106|            {
  507|    106|              n = read (f, buf + nbytes, size - nbytes);
  508|    106|            }
  509|    106|          while (n == -1 && errno == EINTR);
  ------------------
  |  Branch (509:18): [True: 0, False: 106]
  |  Branch (509:29): [True: 0, False: 0]
  ------------------
  510|    106|          if (n > 0)
  ------------------
  |  Branch (510:15): [True: 53, False: 53]
  ------------------
  511|     53|            {
  512|     53|              nbytes += n;
  513|     53|              if (nbytes < size)
  ------------------
  |  Branch (513:19): [True: 53, False: 0]
  ------------------
  514|     53|                goto read_more;
  515|     53|            }
  516|     53|          else if (!n) /* eof */
  ------------------
  |  Branch (516:20): [True: 53, False: 0]
  ------------------
  517|     53|            {
  518|     53|              if (nbytes)
  ------------------
  |  Branch (518:19): [True: 53, False: 0]
  ------------------
  519|     53|                a->delayed_rc = -1;
  520|      0|              else
  521|      0|                {
  522|      0|                  a->eof_seen = 1;
  523|      0|                  rc = -1;
  524|      0|                }
  525|     53|            }
  526|      0|          else /* error */
  527|      0|            {
  528|      0|              rc = gpg_error_from_syserror ();
  529|      0|              if (gpg_err_code (rc) != GPG_ERR_EPIPE)
  ------------------
  |  Branch (529:19): [True: 0, False: 0]
  ------------------
  530|      0|                log_error ("%s: read error: %s\n", a->fname, gpg_strerror (rc));
  531|      0|              if (nbytes)
  ------------------
  |  Branch (531:19): [True: 0, False: 0]
  ------------------
  532|      0|                {
  533|      0|                  a->delayed_rc = rc;
  534|      0|                  rc = 0;
  535|      0|                }
  536|      0|            }
  537|     53|#endif
  538|     53|	  *ret_len = nbytes;
  539|     53|	}
  540|    105|    }
  541|    109|  else if (control == IOBUFCTRL_FLUSH)
  ------------------
  |  Branch (541:12): [True: 1, False: 108]
  ------------------
  542|      1|    {
  543|      1|      if (size)
  ------------------
  |  Branch (543:11): [True: 0, False: 1]
  ------------------
  544|      0|	{
  545|       |#ifdef HAVE_W32_SYSTEM
  546|       |	  byte *p = buf;
  547|       |	  unsigned long n;
  548|       |
  549|       |	  nbytes = size;
  550|       |	  do
  551|       |	    {
  552|       |	      if (size && !WriteFile (f, p, nbytes, &n, NULL))
  553|       |		{
  554|       |		  int ec = (int) GetLastError ();
  555|       |		  rc = gpg_error_from_errno (ec);
  556|       |		  log_error ("%s: write error: ec=%d\n", a->fname, ec);
  557|       |		  break;
  558|       |		}
  559|       |	      p += n;
  560|       |	      nbytes -= n;
  561|       |	    }
  562|       |	  while (nbytes);
  563|       |	  nbytes = p - buf;
  564|       |#else
  565|      0|	  byte *p = buf;
  566|      0|	  int n;
  567|       |
  568|      0|	  nbytes = size;
  569|      0|	  do
  570|      0|	    {
  571|      0|	      do
  572|      0|		{
  573|      0|		  n = write (f, p, nbytes);
  574|      0|		}
  575|      0|	      while (n == -1 && errno == EINTR);
  ------------------
  |  Branch (575:15): [True: 0, False: 0]
  |  Branch (575:26): [True: 0, False: 0]
  ------------------
  576|      0|	      if (n > 0)
  ------------------
  |  Branch (576:12): [True: 0, False: 0]
  ------------------
  577|      0|		{
  578|      0|		  p += n;
  579|      0|		  nbytes -= n;
  580|      0|		}
  581|      0|	    }
  582|      0|	  while (n != -1 && nbytes);
  ------------------
  |  Branch (582:11): [True: 0, False: 0]
  |  Branch (582:22): [True: 0, False: 0]
  ------------------
  583|      0|	  if (n == -1)
  ------------------
  |  Branch (583:8): [True: 0, False: 0]
  ------------------
  584|      0|	    {
  585|      0|	      rc = gpg_error_from_syserror ();
  586|      0|	      log_error ("%s: write error: %s\n", a->fname, strerror (errno));
  587|      0|	    }
  588|      0|	  nbytes = p - buf;
  589|      0|#endif
  590|      0|	}
  591|      1|      *ret_len = nbytes;
  592|      1|    }
  593|    108|  else if (control == IOBUFCTRL_INIT)
  ------------------
  |  Branch (593:12): [True: 54, False: 54]
  ------------------
  594|     54|    {
  595|     54|      a->eof_seen = 0;
  596|     54|      a->delayed_rc = 0;
  597|     54|      a->keep_open = 0;
  598|     54|      a->no_cache = 0;
  599|     54|    }
  600|     54|  else if (control == IOBUFCTRL_DESC)
  ------------------
  |  Branch (600:12): [True: 0, False: 54]
  ------------------
  601|      0|    {
  602|      0|      mem2str (buf, "file_filter(fd)", *ret_len);
  603|      0|    }
  604|     54|  else if (control == IOBUFCTRL_FREE)
  ------------------
  |  Branch (604:12): [True: 54, False: 0]
  ------------------
  605|     54|    {
  606|     54|      if (f != FD_FOR_STDIN && f != FD_FOR_STDOUT)
  ------------------
  |  |   84|    108|# define FD_FOR_STDIN  (0)
  ------------------
                    if (f != FD_FOR_STDIN && f != FD_FOR_STDOUT)
  ------------------
  |  |   85|     54|# define FD_FOR_STDOUT (1)
  ------------------
  |  Branch (606:11): [True: 54, False: 0]
  |  Branch (606:32): [True: 54, False: 0]
  ------------------
  607|     54|	{
  608|     54|	  if (DBG_IOBUF)
  ------------------
  |  |   98|     54|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 54]
  |  |  ------------------
  ------------------
  609|      0|	    log_debug ("%s: close fd/handle %d\n", a->fname, FD2INT (f));
  ------------------
  |  |   46|      0|#define FD2INT(h) (h)
  ------------------
  610|     54|	  if (!a->keep_open)
  ------------------
  |  Branch (610:8): [True: 54, False: 0]
  ------------------
  611|     54|	    fd_cache_close (a->no_cache ? NULL : a->fname, f);
  ------------------
  |  Branch (611:22): [True: 0, False: 54]
  ------------------
  612|     54|	}
  613|     54|      xfree (a); /* We can free our context now. */
  ------------------
  |  |  104|     54|#define xfree(a)         gcry_free ((a))
  ------------------
  614|     54|    }
  615|       |
  616|    214|  return rc;
  617|    214|}
iobuf.c:fd_cache_close:
  370|     54|{
  371|     54|  close_cache_t cc;
  372|       |
  373|     54|  assert (fp);
  374|     54|  if (!fname || !*fname)
  ------------------
  |  Branch (374:7): [True: 0, False: 54]
  |  Branch (374:17): [True: 0, False: 54]
  ------------------
  375|      0|    {
  376|       |#ifdef HAVE_W32_SYSTEM
  377|       |      CloseHandle (fp);
  378|       |#else
  379|      0|      close (fp);
  380|      0|#endif
  381|      0|      if (DBG_IOBUF)
  ------------------
  |  |   98|      0|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  382|      0|	log_debug ("fd_cache_close (%d) real\n", (int)fp);
  383|      0|      return;
  384|      0|    }
  385|       |  /* try to reuse a slot */
  386|     55|  for (cc = close_cache; cc; cc = cc->next)
  ------------------
  |  Branch (386:26): [True: 53, False: 2]
  ------------------
  387|     53|    {
  388|     53|      if (cc->fp == GNUPG_INVALID_FD && !fd_cache_strcmp (cc->fname, fname))
  ------------------
  |  |   44|    106|#define GNUPG_INVALID_FD (-1)
  ------------------
  |  Branch (388:11): [True: 53, False: 0]
  |  Branch (388:41): [True: 52, False: 1]
  ------------------
  389|     52|	{
  390|     52|	  cc->fp = fp;
  391|     52|	  if (DBG_IOBUF)
  ------------------
  |  |   98|     52|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 52]
  |  |  ------------------
  ------------------
  392|      0|	    log_debug ("fd_cache_close (%s) used existing slot\n", fname);
  393|     52|	  return;
  394|     52|	}
  395|     53|    }
  396|       |  /* add a new one */
  397|      2|  if (DBG_IOBUF)
  ------------------
  |  |   98|      2|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  ------------------
  398|      0|    log_debug ("fd_cache_close (%s) new slot created\n", fname);
  399|      2|  cc = xcalloc (1, sizeof *cc + strlen (fname));
  ------------------
  |  |  109|      2|#define xcalloc(a,b)     gcry_xcalloc ((a),(b))
  ------------------
  400|      2|  strcpy (cc->fname, fname);
  401|      2|  cc->fp = fp;
  402|      2|  cc->next = close_cache;
  403|      2|  close_cache = cc;
  404|      2|}
iobuf.c:fd_cache_invalidate:
  206|     55|{
  207|     55|  close_cache_t cc;
  208|     55|  int rc = 0;
  209|       |
  210|     55|  assert (fname);
  211|     55|  if (DBG_IOBUF)
  ------------------
  |  |   98|     55|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 55]
  |  |  ------------------
  ------------------
  212|      0|    log_debug ("fd_cache_invalidate (%s)\n", fname);
  213|       |
  214|    162|  for (cc = close_cache; cc; cc = cc->next)
  ------------------
  |  Branch (214:26): [True: 107, False: 55]
  ------------------
  215|    107|    {
  216|    107|      if (cc->fp != GNUPG_INVALID_FD && !fd_cache_strcmp (cc->fname, fname))
  ------------------
  |  |   44|    214|#define GNUPG_INVALID_FD (-1)
  ------------------
  |  Branch (216:11): [True: 54, False: 53]
  |  Branch (216:41): [True: 54, False: 0]
  ------------------
  217|     54|	{
  218|     54|	  if (DBG_IOBUF)
  ------------------
  |  |   98|     54|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 54]
  |  |  ------------------
  ------------------
  219|      0|	    log_debug ("                did (%s)\n", cc->fname);
  220|       |#ifdef HAVE_W32_SYSTEM
  221|       |	  if (!CloseHandle (cc->fp))
  222|       |            rc = -1;
  223|       |#else
  224|     54|	  rc = close (cc->fp);
  225|     54|#endif
  226|     54|	  cc->fp = GNUPG_INVALID_FD;
  ------------------
  |  |   44|     54|#define GNUPG_INVALID_FD (-1)
  ------------------
  227|     54|	}
  228|    107|    }
  229|     55|  return rc;
  230|     55|}
iobuf.c:filter_flush:
 2043|      1|{
 2044|      1|  int external_used = 0;
 2045|      1|  byte *src_buf;
 2046|      1|  size_t src_len;
 2047|      1|  size_t len;
 2048|      1|  int rc;
 2049|       |
 2050|      1|  a->e_d.used = 0;
 2051|       |
 2052|      1|  if (a->use == IOBUF_OUTPUT_TEMP)
  ------------------
  |  Branch (2052:7): [True: 0, False: 1]
  ------------------
 2053|      0|    {				/* increase the temp buffer */
 2054|      0|      size_t newsize = a->d.size + iobuf_buffer_size;
 2055|       |
 2056|      0|      if (DBG_IOBUF)
  ------------------
  |  |   98|      0|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2057|      0|	log_debug ("increasing temp iobuf from %lu to %lu\n",
 2058|      0|		   (ulong) a->d.size, (ulong) newsize);
 2059|       |
 2060|      0|      a->d.buf = xrealloc (a->d.buf, newsize);
  ------------------
  |  |  111|      0|#define xrealloc(a,b)    gcry_xrealloc ((a),(b))
  ------------------
 2061|      0|      a->d.size = newsize;
 2062|      0|      return 0;
 2063|      0|    }
 2064|      1|  else if (a->use != IOBUF_OUTPUT)
  ------------------
  |  Branch (2064:12): [True: 0, False: 1]
  ------------------
 2065|      0|    log_bug ("flush on non-output iobuf\n");
 2066|      1|  else if (!a->filter)
  ------------------
  |  Branch (2066:12): [True: 0, False: 1]
  ------------------
 2067|      0|    log_bug ("filter_flush: no filter\n");
 2068|       |
 2069|      1|  if (a->d.len == 0 && a->e_d.buf && a->e_d.len > 0)
  ------------------
  |  Branch (2069:7): [True: 1, False: 0]
  |  Branch (2069:24): [True: 0, False: 1]
  |  Branch (2069:38): [True: 0, False: 0]
  ------------------
 2070|      0|    {
 2071|      0|      src_buf = a->e_d.buf;
 2072|      0|      src_len = a->e_d.len;
 2073|      0|      external_used = 1;
 2074|      0|    }
 2075|      1|  else
 2076|      1|    {
 2077|      1|      src_buf = a->d.buf;
 2078|      1|      src_len = a->d.len;
 2079|      1|      external_used = 0;
 2080|      1|    }
 2081|       |
 2082|      1|  len = src_len;
 2083|      1|  rc = a->filter (a->filter_ov, IOBUFCTRL_FLUSH, a->chain, src_buf, &len);
 2084|      1|  if (!rc && len != src_len)
  ------------------
  |  Branch (2084:7): [True: 1, False: 0]
  |  Branch (2084:14): [True: 0, False: 1]
  ------------------
 2085|      0|    {
 2086|      0|      log_info ("filter_flush did not write all!\n");
 2087|      0|      rc = GPG_ERR_INTERNAL;
 2088|      0|    }
 2089|      1|  else if (rc)
  ------------------
  |  Branch (2089:12): [True: 0, False: 1]
  ------------------
 2090|      0|    a->error = rc;
 2091|      1|  a->d.len = 0;
 2092|      1|  if (external_used)
  ------------------
  |  Branch (2092:7): [True: 0, False: 1]
  ------------------
 2093|      0|    a->e_d.used = len;
 2094|       |
 2095|      1|  return rc;
 2096|      1|}
iobuf.c:underflow:
 1833|  2.28k|{
 1834|  2.28k|  return underflow_target (a, clear_pending_eof, 1);
 1835|  2.28k|}
iobuf.c:underflow_target:
 1844|  2.28k|{
 1845|  2.28k|  size_t len;
 1846|  2.28k|  int rc;
 1847|       |
 1848|  2.28k|  if (DBG_IOBUF)
  ------------------
  |  |   98|  2.28k|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2.28k]
  |  |  ------------------
  ------------------
 1849|      0|    log_debug ("iobuf-%d.%d: underflow: buffer size: %d; still buffered: %d => space for %d bytes\n",
 1850|      0|	       a->no, a->subno,
 1851|      0|	       (int) a->d.size, (int) (a->d.len - a->d.start),
 1852|      0|	       (int) (a->d.size - (a->d.len - a->d.start)));
 1853|       |
 1854|  2.28k|  if (a->use == IOBUF_INPUT_TEMP)
  ------------------
  |  Branch (1854:7): [True: 24, False: 2.25k]
  ------------------
 1855|       |    /* By definition, there isn't more data to read into the
 1856|       |       buffer.  */
 1857|     24|    return -1;
 1858|       |
 1859|  2.25k|  assert (a->use == IOBUF_INPUT);
 1860|       |
 1861|  2.25k|  a->e_d.used = 0;
 1862|       |
 1863|       |  /* If there is still some buffered data, then move it to the start
 1864|       |     of the buffer and try to fill the end of the buffer.  (This is
 1865|       |     useful if we are called from iobuf_peek().)  */
 1866|  2.25k|  assert (a->d.start <= a->d.len);
 1867|  2.25k|  a->d.len -= a->d.start;
 1868|  2.25k|  if (a->d.len)
  ------------------
  |  Branch (1868:7): [True: 0, False: 2.25k]
  ------------------
 1869|      0|    memmove (a->d.buf, &a->d.buf[a->d.start], a->d.len);
 1870|  2.25k|  a->d.start = 0;
 1871|       |
 1872|  2.25k|  if (a->d.len < target && a->filter_eof)
  ------------------
  |  Branch (1872:7): [True: 2.25k, False: 0]
  |  Branch (1872:28): [True: 38, False: 2.21k]
  ------------------
 1873|       |    /* The last time we tried to read from this filter, we got an EOF.
 1874|       |       We couldn't return the EOF, because there was buffered data.
 1875|       |       Since there is no longer any buffered data, return the
 1876|       |       error.  */
 1877|     38|    {
 1878|     38|      if (DBG_IOBUF)
  ------------------
  |  |   98|     38|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 38]
  |  |  ------------------
  ------------------
 1879|      0|	log_debug ("iobuf-%d.%d: underflow: eof (pending eof)\n",
 1880|      0|		   a->no, a->subno);
 1881|     38|      if (! clear_pending_eof)
  ------------------
  |  Branch (1881:11): [True: 0, False: 38]
  ------------------
 1882|      0|	return -1;
 1883|       |
 1884|     38|      if (a->chain)
  ------------------
  |  Branch (1884:11): [True: 0, False: 38]
  ------------------
 1885|       |	/* A filter follows this one.  Free this filter.  */
 1886|      0|	{
 1887|      0|	  iobuf_t b = a->chain;
 1888|      0|	  if (DBG_IOBUF)
  ------------------
  |  |   98|      0|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1889|      0|	    log_debug ("iobuf-%d.%d: filter popped (pending EOF returned)\n",
 1890|      0|		       a->no, a->subno);
 1891|      0|	  xfree (a->d.buf);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1892|      0|	  xfree (a->real_fname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1893|      0|	  memcpy (a, b, sizeof *a);
 1894|      0|	  xfree (b);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1895|      0|	  print_chain (a);
 1896|      0|	}
 1897|     38|      else
 1898|     38|	a->filter_eof = 0;	/* for the top level filter */
 1899|     38|      return -1;		/* return one(!) EOF */
 1900|     38|    }
 1901|       |
 1902|  2.21k|  if (a->d.len == 0 && a->error)
  ------------------
  |  Branch (1902:7): [True: 2.21k, False: 0]
  |  Branch (1902:24): [True: 3, False: 2.21k]
  ------------------
 1903|       |    /* The last time we tried to read from this filter, we got an
 1904|       |       error.  We couldn't return the error, because there was
 1905|       |       buffered data.  Since there is no longer any buffered data,
 1906|       |       return the error.  */
 1907|      3|    {
 1908|      3|      if (DBG_IOBUF)
  ------------------
  |  |   98|      3|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 3]
  |  |  ------------------
  ------------------
 1909|      0|	log_debug ("iobuf-%d.%d: pending error (%s) returned\n",
 1910|      0|		   a->no, a->subno, gpg_strerror (a->error));
 1911|      3|      return -1;
 1912|      3|    }
 1913|       |
 1914|  2.21k|  if (a->filter && ! a->filter_eof && ! a->error)
  ------------------
  |  Branch (1914:7): [True: 1.66k, False: 546]
  |  Branch (1914:20): [True: 1.66k, False: 0]
  |  Branch (1914:39): [True: 1.66k, False: 0]
  ------------------
 1915|       |    /* We have a filter function and the last time we tried to read we
 1916|       |       didn't get an EOF or an error.  Try to fill the buffer.  */
 1917|  1.66k|    {
 1918|       |      /* Be careful to account for any buffered data.  */
 1919|  1.66k|      len = a->d.size - a->d.len;
 1920|       |
 1921|  1.66k|      if (a->e_d.preferred && a->d.len < IOBUF_ZEROCOPY_THRESHOLD_SIZE
  ------------------
  |  |   71|  1.66k|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
  |  Branch (1921:11): [True: 0, False: 1.66k]
  |  Branch (1921:31): [True: 0, False: 0]
  ------------------
 1922|  1.66k|	  && (IOBUF_ZEROCOPY_THRESHOLD_SIZE - a->d.len) < len)
  ------------------
  |  |   71|      0|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
  |  Branch (1922:7): [True: 0, False: 0]
  ------------------
 1923|      0|	{
 1924|      0|	  if (DBG_IOBUF)
  ------------------
  |  |   98|      0|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1925|      0|	    log_debug ("iobuf-%d.%d: limit buffering as external drain is "
 1926|      0|			"preferred\n",  a->no, a->subno);
 1927|      0|	  len = IOBUF_ZEROCOPY_THRESHOLD_SIZE - a->d.len;
  ------------------
  |  |   71|      0|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
 1928|      0|	}
 1929|       |
 1930|  1.66k|      if (len == 0)
  ------------------
  |  Branch (1930:11): [True: 0, False: 1.66k]
  ------------------
 1931|       |	/* There is no space for more data.  Don't bother calling
 1932|       |	   A->FILTER.  */
 1933|      0|	rc = 0;
 1934|  1.66k|      else
 1935|  1.66k|      {
 1936|       |	/* If no buffered data and drain buffer has been setup, and drain
 1937|       |	 * buffer is largish, read data directly to drain buffer. */
 1938|  1.66k|	if (a->d.len == 0
  ------------------
  |  Branch (1938:6): [True: 1.66k, False: 0]
  ------------------
 1939|  1.66k|	    && a->e_d.buf
  ------------------
  |  Branch (1939:9): [True: 0, False: 1.66k]
  ------------------
 1940|  1.66k|	    && a->e_d.len >= IOBUF_ZEROCOPY_THRESHOLD_SIZE)
  ------------------
  |  |   71|      0|#define IOBUF_ZEROCOPY_THRESHOLD_SIZE 1024
  ------------------
  |  Branch (1940:9): [True: 0, False: 0]
  ------------------
 1941|      0|	  {
 1942|      0|	    len = a->e_d.len;
 1943|       |
 1944|      0|	    if (DBG_IOBUF)
  ------------------
  |  |   98|      0|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1945|      0|	      log_debug ("iobuf-%d.%d: underflow: A->FILTER (%lu bytes, to external drain)\n",
 1946|      0|			 a->no, a->subno, (ulong)len);
 1947|       |
 1948|      0|	    rc = a->filter (a->filter_ov, IOBUFCTRL_UNDERFLOW, a->chain,
 1949|      0|			    a->e_d.buf, &len);
 1950|      0|	    a->e_d.used = len;
 1951|      0|	    len = 0;
 1952|      0|	  }
 1953|  1.66k|	else
 1954|  1.66k|	  {
 1955|  1.66k|	    if (DBG_IOBUF)
  ------------------
  |  |   98|  1.66k|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1.66k]
  |  |  ------------------
  ------------------
 1956|      0|	      log_debug ("iobuf-%d.%d: underflow: A->FILTER (%lu bytes)\n",
 1957|      0|			 a->no, a->subno, (ulong)len);
 1958|       |
 1959|  1.66k|	    rc = a->filter (a->filter_ov, IOBUFCTRL_UNDERFLOW, a->chain,
 1960|  1.66k|			    &a->d.buf[a->d.len], &len);
 1961|  1.66k|	  }
 1962|  1.66k|      }
 1963|  1.66k|      a->d.len += len;
 1964|       |
 1965|  1.66k|      if (DBG_IOBUF)
  ------------------
  |  |   98|  1.66k|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1.66k]
  |  |  ------------------
  ------------------
 1966|      0|	log_debug ("iobuf-%d.%d: A->FILTER() returned rc=%d (%s), read %lu bytes%s\n",
 1967|      0|		   a->no, a->subno,
 1968|      0|		   rc, rc == 0 ? "ok" : rc == -1 ? "EOF" : gpg_strerror (rc),
  ------------------
  |  Branch (1968:10): [True: 0, False: 0]
  |  Branch (1968:27): [True: 0, False: 0]
  ------------------
 1969|      0|		   (ulong)(a->e_d.used ? a->e_d.used : len),
  ------------------
  |  Branch (1969:14): [True: 0, False: 0]
  ------------------
 1970|      0|		   a->e_d.used ? " (to external buffer)" : "");
  ------------------
  |  Branch (1970:6): [True: 0, False: 0]
  ------------------
 1971|       |/*  	    if( a->no == 1 ) */
 1972|       |/*                   log_hexdump ("     data:", a->d.buf, len); */
 1973|       |
 1974|  1.66k|      if (rc == -1)
  ------------------
  |  Branch (1974:11): [True: 88, False: 1.58k]
  ------------------
 1975|       |	/* EOF.  */
 1976|     88|	{
 1977|     88|	  size_t dummy_len = 0;
 1978|       |
 1979|       |	  /* Tell the filter to free itself */
 1980|     88|	  if ((rc = a->filter (a->filter_ov, IOBUFCTRL_FREE, a->chain,
  ------------------
  |  Branch (1980:8): [True: 0, False: 88]
  ------------------
 1981|     88|			       NULL, &dummy_len)))
 1982|      0|	    log_error ("IOBUFCTRL_FREE failed: %s\n", gpg_strerror (rc));
 1983|       |
 1984|       |	  /* Free everything except for the internal buffer.  */
 1985|     88|	  if (a->filter_ov && a->filter_ov_owner)
  ------------------
  |  Branch (1985:8): [True: 88, False: 0]
  |  Branch (1985:24): [True: 0, False: 88]
  ------------------
 1986|      0|	    xfree (a->filter_ov);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1987|     88|	  a->filter_ov = NULL;
 1988|     88|	  a->filter = NULL;
 1989|     88|	  a->filter_eof = 1;
 1990|       |
 1991|     88|	  if (clear_pending_eof && a->d.len == 0 && a->e_d.used == 0
  ------------------
  |  Branch (1991:8): [True: 88, False: 0]
  |  Branch (1991:29): [True: 88, False: 0]
  |  Branch (1991:46): [True: 88, False: 0]
  ------------------
 1992|     88|	      && a->chain)
  ------------------
  |  Branch (1992:11): [True: 36, False: 52]
  ------------------
 1993|       |	    /* We don't need to keep this filter around at all:
 1994|       |
 1995|       |	         - we got an EOF
 1996|       |		 - we have no buffered data
 1997|       |		 - a filter follows this one.
 1998|       |
 1999|       |	      Unlink this filter.  */
 2000|     36|	    {
 2001|     36|	      iobuf_t b = a->chain;
 2002|     36|	      if (DBG_IOBUF)
  ------------------
  |  |   98|     36|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 36]
  |  |  ------------------
  ------------------
 2003|      0|		log_debug ("iobuf-%d.%d: pop in underflow (nothing buffered, got EOF)\n",
 2004|      0|			   a->no, a->subno);
 2005|     36|	      xfree (a->d.buf);
  ------------------
  |  |  104|     36|#define xfree(a)         gcry_free ((a))
  ------------------
 2006|     36|	      xfree (a->real_fname);
  ------------------
  |  |  104|     36|#define xfree(a)         gcry_free ((a))
  ------------------
 2007|     36|	      memcpy (a, b, sizeof *a);
 2008|     36|	      xfree (b);
  ------------------
  |  |  104|     36|#define xfree(a)         gcry_free ((a))
  ------------------
 2009|       |
 2010|     36|	      print_chain (a);
 2011|       |
 2012|     36|	      return -1;
 2013|     36|	    }
 2014|     52|	  else if (a->d.len == 0 && a->e_d.used == 0)
  ------------------
  |  Branch (2014:13): [True: 52, False: 0]
  |  Branch (2014:30): [True: 52, False: 0]
  ------------------
 2015|       |	    /* We can't unlink this filter (it is the only one in the
 2016|       |	       pipeline), but we can immediately return EOF.  */
 2017|     52|	    return -1;
 2018|     88|	}
 2019|  1.58k|      else if (rc)
  ------------------
  |  Branch (2019:16): [True: 2, False: 1.57k]
  ------------------
 2020|       |	/* Record the error.  */
 2021|      2|	{
 2022|      2|	  a->error = rc;
 2023|       |
 2024|      2|	  if (a->d.len == 0 && a->e_d.used == 0)
  ------------------
  |  Branch (2024:8): [True: 0, False: 2]
  |  Branch (2024:25): [True: 0, False: 0]
  ------------------
 2025|       |	    /* There is no buffered data.  Immediately return EOF.  */
 2026|      0|	    return -1;
 2027|      2|	}
 2028|  1.66k|    }
 2029|       |
 2030|  2.12k|  assert (a->d.start <= a->d.len);
 2031|  2.12k|  if (a->e_d.used > 0)
  ------------------
  |  Branch (2031:7): [True: 0, False: 2.12k]
  ------------------
 2032|      0|    return 0;
 2033|  2.12k|  if (a->d.start < a->d.len)
  ------------------
  |  Branch (2033:7): [True: 1.09k, False: 1.03k]
  ------------------
 2034|  1.09k|    return a->d.buf[a->d.start++];
 2035|       |
 2036|       |  /* EOF.  */
 2037|  1.03k|  return -1;
 2038|  2.12k|}
iobuf.c:block_filter:
  837|      7|{
  838|      7|  block_filter_ctx_t *a = opaque;
  839|      7|  char *buf = (char *)buffer;
  840|      7|  size_t size = *ret_len;
  841|      7|  int c, needed, rc = 0;
  842|      7|  char *p;
  843|       |
  844|      7|  if (control == IOBUFCTRL_UNDERFLOW)
  ------------------
  |  Branch (844:7): [True: 3, False: 4]
  ------------------
  845|      3|    {
  846|      3|      size_t n = 0;
  847|       |
  848|      3|      p = buf;
  849|      3|      assert (size);		/* need a buffer */
  850|      3|      if (a->eof)		/* don't read any further */
  ------------------
  |  Branch (850:11): [True: 1, False: 2]
  ------------------
  851|      1|	rc = -1;
  852|  4.10k|      while (!rc && size)
  ------------------
  |  Branch (852:14): [True: 4.09k, False: 2]
  |  Branch (852:21): [True: 4.09k, False: 0]
  ------------------
  853|  4.09k|	{
  854|  4.09k|	  if (!a->size)
  ------------------
  |  Branch (854:8): [True: 4.09k, False: 0]
  ------------------
  855|  4.09k|	    {			/* get the length bytes */
  856|  4.09k|	      if (a->partial == 2)
  ------------------
  |  Branch (856:12): [True: 1, False: 4.09k]
  ------------------
  857|      1|		{
  858|      1|		  a->eof = 1;
  859|      1|		  if (!n)
  ------------------
  |  Branch (859:9): [True: 0, False: 1]
  ------------------
  860|      0|		    rc = -1;
  861|      1|		  break;
  862|      1|		}
  863|  4.09k|	      else if (a->partial)
  ------------------
  |  Branch (863:17): [True: 4.09k, False: 0]
  ------------------
  864|  4.09k|		{
  865|       |		  /* These OpenPGP introduced huffman like encoded length
  866|       |		   * bytes are really a mess :-( */
  867|  4.09k|		  if (a->first_c)
  ------------------
  |  Branch (867:9): [True: 2, False: 4.09k]
  ------------------
  868|      2|		    {
  869|      2|		      c = a->first_c;
  870|      2|		      a->first_c = 0;
  871|      2|		    }
  872|  4.09k|		  else if ((c = iobuf_get (chain)) == -1)
  ------------------
  |  |  500|  4.09k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 4.09k]
  |  |  |  Branch (500:24): [True: 0, False: 4.09k]
  |  |  ------------------
  |  |  501|  4.09k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (872:14): [True: 0, False: 4.09k]
  ------------------
  873|      0|		    {
  874|      0|		      log_error ("block_filter: 1st length byte missing\n");
  875|      0|		      rc = GPG_ERR_BAD_DATA;
  876|      0|		      break;
  877|      0|		    }
  878|  4.09k|		  if (c < 192)
  ------------------
  |  Branch (878:9): [True: 0, False: 4.09k]
  ------------------
  879|      0|		    {
  880|      0|		      a->size = c;
  881|      0|		      a->partial = 2;
  882|      0|		      if (!a->size)
  ------------------
  |  Branch (882:13): [True: 0, False: 0]
  ------------------
  883|      0|			{
  884|      0|			  a->eof = 1;
  885|      0|			  if (!n)
  ------------------
  |  Branch (885:10): [True: 0, False: 0]
  ------------------
  886|      0|			    rc = -1;
  887|      0|			  break;
  888|      0|			}
  889|      0|		    }
  890|  4.09k|		  else if (c < 224)
  ------------------
  |  Branch (890:14): [True: 1, False: 4.09k]
  ------------------
  891|      1|		    {
  892|      1|		      a->size = (c - 192) * 256;
  893|      1|		      if ((c = iobuf_get (chain)) == -1)
  ------------------
  |  |  500|      1|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 1]
  |  |  |  Branch (500:24): [True: 0, False: 1]
  |  |  ------------------
  |  |  501|      1|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (893:13): [True: 0, False: 1]
  ------------------
  894|      0|			{
  895|      0|			  log_error
  896|      0|			    ("block_filter: 2nd length byte missing\n");
  897|      0|			  rc = GPG_ERR_BAD_DATA;
  898|      0|			  break;
  899|      0|			}
  900|      1|		      a->size += c + 192;
  901|      1|		      a->partial = 2;
  902|      1|		      if (!a->size)
  ------------------
  |  Branch (902:13): [True: 0, False: 1]
  ------------------
  903|      0|			{
  904|      0|			  a->eof = 1;
  905|      0|			  if (!n)
  ------------------
  |  Branch (905:10): [True: 0, False: 0]
  ------------------
  906|      0|			    rc = -1;
  907|      0|			  break;
  908|      0|			}
  909|      1|		    }
  910|  4.09k|		  else if (c == 255)
  ------------------
  |  Branch (910:14): [True: 0, False: 4.09k]
  ------------------
  911|      0|		    {
  912|      0|                      size_t len = 0;
  913|      0|                      int i;
  914|       |
  915|      0|                      for (i = 0; i < 4; i++)
  ------------------
  |  Branch (915:35): [True: 0, False: 0]
  ------------------
  916|      0|                        if ((c = iobuf_get (chain)) == -1)
  ------------------
  |  |  500|      0|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 0]
  |  |  |  Branch (500:24): [True: 0, False: 0]
  |  |  ------------------
  |  |  501|      0|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (916:29): [True: 0, False: 0]
  ------------------
  917|      0|                          break;
  918|      0|                        else
  919|      0|                          len = ((len << 8) | c);
  920|       |
  921|      0|                      if (i < 4)
  ------------------
  |  Branch (921:27): [True: 0, False: 0]
  ------------------
  922|      0|			{
  923|      0|			  log_error ("block_filter: invalid 4 byte length\n");
  924|      0|			  rc = GPG_ERR_BAD_DATA;
  925|      0|			  break;
  926|      0|			}
  927|      0|                      a->size = len;
  928|      0|                      a->partial = 2;
  929|      0|                      if (!a->size)
  ------------------
  |  Branch (929:27): [True: 0, False: 0]
  ------------------
  930|      0|                        {
  931|      0|                          a->eof = 1;
  932|      0|                          if (!n)
  ------------------
  |  Branch (932:31): [True: 0, False: 0]
  ------------------
  933|      0|                            rc = -1;
  934|      0|                          break;
  935|      0|			}
  936|      0|		    }
  937|  4.09k|		  else
  938|  4.09k|		    { /* Next partial body length. */
  939|  4.09k|		      a->size = 1 << (c & 0x1f);
  940|  4.09k|		    }
  941|       |		  /*  log_debug("partial: ctx=%p c=%02x size=%u\n", a, c, a->size); */
  942|  4.09k|		}
  943|      0|	      else
  944|      0|		BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  945|  4.09k|	    }
  946|       |
  947|  8.19k|	  while (!rc && size && a->size)
  ------------------
  |  Branch (947:11): [True: 8.19k, False: 1]
  |  Branch (947:18): [True: 8.19k, False: 0]
  |  Branch (947:26): [True: 4.09k, False: 4.09k]
  ------------------
  948|  4.09k|	    {
  949|  4.09k|	      needed = size < a->size ? size : a->size;
  ------------------
  |  Branch (949:17): [True: 0, False: 4.09k]
  ------------------
  950|  4.09k|	      c = iobuf_read (chain, p, needed);
  951|  4.09k|	      if (c < needed)
  ------------------
  |  Branch (951:12): [True: 1, False: 4.09k]
  ------------------
  952|      1|		{
  953|      1|		  if (c == -1)
  ------------------
  |  Branch (953:9): [True: 1, False: 0]
  ------------------
  954|      1|		    c = 0;
  955|      1|		  log_error
  956|      1|		    ("block_filter %p: read error (size=%lu,a->size=%lu)\n",
  957|      1|		     a, (ulong) size + c, (ulong) a->size + c);
  958|      1|		  rc = GPG_ERR_BAD_DATA;
  959|      1|		}
  960|  4.09k|	      else
  961|  4.09k|		{
  962|  4.09k|		  size -= c;
  963|  4.09k|		  a->size -= c;
  964|  4.09k|		  p += c;
  965|  4.09k|		  n += c;
  966|  4.09k|		}
  967|  4.09k|	    }
  968|  4.09k|	}
  969|      3|      *ret_len = n;
  970|      3|    }
  971|      4|  else if (control == IOBUFCTRL_FLUSH)
  ------------------
  |  Branch (971:12): [True: 0, False: 4]
  ------------------
  972|      0|    {
  973|      0|      if (a->partial)
  ------------------
  |  Branch (973:11): [True: 0, False: 0]
  ------------------
  974|      0|	{			/* the complicated openpgp scheme */
  975|      0|	  size_t blen, n, nbytes = size + a->buflen;
  976|       |
  977|      0|	  assert (a->buflen <= OP_MIN_PARTIAL_CHUNK);
  978|      0|	  if (nbytes < OP_MIN_PARTIAL_CHUNK)
  ------------------
  |  |  144|      0|#define OP_MIN_PARTIAL_CHUNK	  512
  ------------------
  |  Branch (978:8): [True: 0, False: 0]
  ------------------
  979|      0|	    {
  980|       |	      /* not enough to write a partial block out; so we store it */
  981|      0|	      if (!a->buffer)
  ------------------
  |  Branch (981:12): [True: 0, False: 0]
  ------------------
  982|      0|		a->buffer = xmalloc (OP_MIN_PARTIAL_CHUNK);
  ------------------
  |  |  107|      0|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  983|      0|	      memcpy (a->buffer + a->buflen, buf, size);
  984|      0|	      a->buflen += size;
  985|      0|	    }
  986|      0|	  else
  987|      0|	    {			/* okay, we can write out something */
  988|       |	      /* do this in a loop to use the most efficient block lengths */
  989|      0|	      p = buf;
  990|      0|	      do
  991|      0|		{
  992|       |		  /* find the best matching block length - this is limited
  993|       |		   * by the size of the internal buffering */
  994|      0|		  for (blen = OP_MIN_PARTIAL_CHUNK * 2,
  ------------------
  |  |  144|      0|#define OP_MIN_PARTIAL_CHUNK	  512
  ------------------
  995|      0|		       c = OP_MIN_PARTIAL_CHUNK_2POW + 1; blen <= nbytes;
  ------------------
  |  |  145|      0|#define OP_MIN_PARTIAL_CHUNK_2POW 9
  ------------------
  |  Branch (995:45): [True: 0, False: 0]
  ------------------
  996|      0|		       blen *= 2, c++)
  997|      0|		    ;
  998|      0|		  blen /= 2;
  999|      0|		  c--;
 1000|       |		  /* write the partial length header */
 1001|      0|		  assert (c <= 0x1f);	/*;-) */
 1002|      0|		  c |= 0xe0;
 1003|      0|		  iobuf_put (chain, c);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1004|      0|		  if ((n = a->buflen))
  ------------------
  |  Branch (1004:9): [True: 0, False: 0]
  ------------------
 1005|      0|		    {		/* write stuff from the buffer */
 1006|      0|		      assert (n == OP_MIN_PARTIAL_CHUNK);
 1007|      0|		      if (iobuf_write (chain, a->buffer, n))
  ------------------
  |  Branch (1007:13): [True: 0, False: 0]
  ------------------
 1008|      0|			rc = gpg_error_from_syserror ();
 1009|      0|		      a->buflen = 0;
 1010|      0|		      nbytes -= n;
 1011|      0|		    }
 1012|      0|		  if ((n = nbytes) > blen)
  ------------------
  |  Branch (1012:9): [True: 0, False: 0]
  ------------------
 1013|      0|		    n = blen;
 1014|      0|		  if (n && iobuf_write (chain, p, n))
  ------------------
  |  Branch (1014:9): [True: 0, False: 0]
  |  Branch (1014:14): [True: 0, False: 0]
  ------------------
 1015|      0|		    rc = gpg_error_from_syserror ();
 1016|      0|		  p += n;
 1017|      0|		  nbytes -= n;
 1018|      0|		}
 1019|      0|	      while (!rc && nbytes >= OP_MIN_PARTIAL_CHUNK);
  ------------------
  |  |  144|      0|#define OP_MIN_PARTIAL_CHUNK	  512
  ------------------
  |  Branch (1019:15): [True: 0, False: 0]
  |  Branch (1019:22): [True: 0, False: 0]
  ------------------
 1020|       |	      /* store the rest in the buffer */
 1021|      0|	      if (!rc && nbytes)
  ------------------
  |  Branch (1021:12): [True: 0, False: 0]
  |  Branch (1021:19): [True: 0, False: 0]
  ------------------
 1022|      0|		{
 1023|      0|		  assert (!a->buflen);
 1024|      0|		  assert (nbytes < OP_MIN_PARTIAL_CHUNK);
 1025|      0|		  if (!a->buffer)
  ------------------
  |  Branch (1025:9): [True: 0, False: 0]
  ------------------
 1026|      0|		    a->buffer = xmalloc (OP_MIN_PARTIAL_CHUNK);
  ------------------
  |  |  107|      0|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 1027|      0|		  memcpy (a->buffer, p, nbytes);
 1028|      0|		  a->buflen = nbytes;
 1029|      0|		}
 1030|      0|	    }
 1031|      0|	}
 1032|      0|      else
 1033|      0|	BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1034|      0|    }
 1035|      4|  else if (control == IOBUFCTRL_INIT)
  ------------------
  |  Branch (1035:12): [True: 2, False: 2]
  ------------------
 1036|      2|    {
 1037|      2|      if (DBG_IOBUF)
  ------------------
  |  |   98|      2|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  ------------------
 1038|      0|	log_debug ("init block_filter %p\n", a);
 1039|      2|      if (a->partial)
  ------------------
  |  Branch (1039:11): [True: 2, False: 0]
  ------------------
 1040|      2|	a->count = 0;
 1041|      0|      else if (a->use == IOBUF_INPUT)
  ------------------
  |  Branch (1041:16): [True: 0, False: 0]
  ------------------
 1042|      0|	a->count = a->size = 0;
 1043|      0|      else
 1044|      0|	a->count = a->size;	/* force first length bytes */
 1045|      2|      a->eof = 0;
 1046|      2|      a->buffer = NULL;
 1047|      2|      a->buflen = 0;
 1048|      2|    }
 1049|      2|  else if (control == IOBUFCTRL_DESC)
  ------------------
  |  Branch (1049:12): [True: 0, False: 2]
  ------------------
 1050|      0|    {
 1051|      0|      mem2str (buf, "block_filter", *ret_len);
 1052|      0|    }
 1053|      2|  else if (control == IOBUFCTRL_FREE)
  ------------------
  |  Branch (1053:12): [True: 2, False: 0]
  ------------------
 1054|      2|    {
 1055|      2|      if (a->use == IOBUF_OUTPUT)
  ------------------
  |  Branch (1055:11): [True: 0, False: 2]
  ------------------
 1056|      0|	{			/* write the end markers */
 1057|      0|	  if (a->partial)
  ------------------
  |  Branch (1057:8): [True: 0, False: 0]
  ------------------
 1058|      0|	    {
 1059|      0|	      u32 len;
 1060|       |	      /* write out the remaining bytes without a partial header
 1061|       |	       * the length of this header may be 0 - but if it is
 1062|       |	       * the first block we are not allowed to use a partial header
 1063|       |	       * and frankly we can't do so, because this length must be
 1064|       |	       * a power of 2. This is _really_ complicated because we
 1065|       |	       * have to check the possible length of a packet prior
 1066|       |	       * to it's creation: a chain of filters becomes complicated
 1067|       |	       * and we need a lot of code to handle compressed packets etc.
 1068|       |	       *   :-(((((((
 1069|       |	       */
 1070|       |	      /* construct header */
 1071|      0|	      len = a->buflen;
 1072|       |	      /*log_debug("partial: remaining length=%u\n", len ); */
 1073|      0|	      if (len < 192)
  ------------------
  |  Branch (1073:12): [True: 0, False: 0]
  ------------------
 1074|      0|		rc = iobuf_put (chain, len);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1075|      0|	      else if (len < 8384)
  ------------------
  |  Branch (1075:17): [True: 0, False: 0]
  ------------------
 1076|      0|		{
 1077|      0|		  if (!(rc = iobuf_put (chain, ((len - 192) / 256) + 192)))
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  |  Branch (1077:9): [True: 0, False: 0]
  ------------------
 1078|      0|		    rc = iobuf_put (chain, ((len - 192) % 256));
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1079|      0|		}
 1080|      0|	      else
 1081|      0|		{		/* use a 4 byte header */
 1082|      0|		  if (!(rc = iobuf_put (chain, 0xff)))
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  |  Branch (1082:9): [True: 0, False: 0]
  ------------------
 1083|      0|		    if (!(rc = iobuf_put (chain, (len >> 24) & 0xff)))
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  |  Branch (1083:11): [True: 0, False: 0]
  ------------------
 1084|      0|		      if (!(rc = iobuf_put (chain, (len >> 16) & 0xff)))
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  |  Branch (1084:13): [True: 0, False: 0]
  ------------------
 1085|      0|			if (!(rc = iobuf_put (chain, (len >> 8) & 0xff)))
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  |  Branch (1085:8): [True: 0, False: 0]
  ------------------
 1086|      0|			  rc = iobuf_put (chain, len & 0xff);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1087|      0|		}
 1088|      0|	      if (!rc && len)
  ------------------
  |  Branch (1088:12): [True: 0, False: 0]
  |  Branch (1088:19): [True: 0, False: 0]
  ------------------
 1089|      0|		rc = iobuf_write (chain, a->buffer, len);
 1090|      0|	      if (rc)
  ------------------
  |  Branch (1090:12): [True: 0, False: 0]
  ------------------
 1091|      0|		{
 1092|      0|		  log_error ("block_filter: write error: %s\n",
 1093|      0|			     strerror (errno));
 1094|      0|		  rc = gpg_error_from_syserror ();
 1095|      0|		}
 1096|      0|	      xfree (a->buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1097|      0|	      a->buffer = NULL;
 1098|      0|	      a->buflen = 0;
 1099|      0|	    }
 1100|      0|	  else
 1101|      0|	    BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1102|      0|	}
 1103|      2|      else if (a->size)
  ------------------
  |  Branch (1103:16): [True: 1, False: 1]
  ------------------
 1104|      1|	{
 1105|      1|	  log_error ("block_filter: pending bytes!\n");
 1106|      1|	}
 1107|      2|      if (DBG_IOBUF)
  ------------------
  |  |   98|      2|#define DBG_IOBUF   iobuf_debug_mode
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  ------------------
 1108|      0|	log_debug ("free block_filter %p\n", a);
 1109|      2|      xfree (a);		/* we can free our context now */
  ------------------
  |  |  104|      2|#define xfree(a)         gcry_free ((a))
  ------------------
 1110|      2|    }
 1111|       |
 1112|      7|  return rc;
 1113|      7|}

openpgp_oidbuf_to_str:
  224|     24|{
  225|     24|  char *string, *p;
  226|     24|  int n = 0;
  227|     24|  unsigned long val, valmask;
  228|       |
  229|     24|  valmask = (unsigned long)0xfe << (8 * (sizeof (valmask) - 1));
  230|       |  /* The first bytes gives the length; check consistency.  */
  231|       |
  232|     24|  if (!len || buf[0] != len -1)
  ------------------
  |  Branch (232:7): [True: 0, False: 24]
  |  Branch (232:15): [True: 0, False: 24]
  ------------------
  233|      0|    {
  234|      0|      gpg_err_set_errno (EINVAL);
  235|      0|      return NULL;
  236|      0|    }
  237|       |  /* Skip length byte.  */
  238|     24|  len--;
  239|     24|  buf++;
  240|       |
  241|       |  /* To calculate the length of the string we can safely assume an
  242|       |     upper limit of 3 decimal characters per byte.  Two extra bytes
  243|       |     account for the special first octet */
  244|     24|  string = p = xtrymalloc (len*(1+3)+2+1);
  ------------------
  |  |   97|     24|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  245|     24|  if (!string)
  ------------------
  |  Branch (245:7): [True: 0, False: 24]
  ------------------
  246|      0|    return NULL;
  247|     24|  if (!len)
  ------------------
  |  Branch (247:7): [True: 0, False: 24]
  ------------------
  248|      0|    {
  249|      0|      *p = 0;
  250|      0|      return string;
  251|      0|    }
  252|       |
  253|     24|  if (buf[0] < 40)
  ------------------
  |  Branch (253:7): [True: 0, False: 24]
  ------------------
  254|      0|    p += sprintf (p, "0.%d", buf[n]);
  255|     24|  else if (buf[0] < 80)
  ------------------
  |  Branch (255:12): [True: 24, False: 0]
  ------------------
  256|     24|    p += sprintf (p, "1.%d", buf[n]-40);
  257|      0|  else {
  258|      0|    val = buf[n] & 0x7f;
  259|      0|    while ( (buf[n]&0x80) && ++n < len )
  ------------------
  |  Branch (259:13): [True: 0, False: 0]
  |  Branch (259:30): [True: 0, False: 0]
  ------------------
  260|      0|      {
  261|      0|        if ( (val & valmask) )
  ------------------
  |  Branch (261:14): [True: 0, False: 0]
  ------------------
  262|      0|          goto badoid;  /* Overflow.  */
  263|      0|        val <<= 7;
  264|      0|        val |= buf[n] & 0x7f;
  265|      0|      }
  266|      0|    if (val < 80)
  ------------------
  |  Branch (266:9): [True: 0, False: 0]
  ------------------
  267|      0|      goto badoid;
  268|      0|    val -= 80;
  269|      0|    sprintf (p, "2.%lu", val);
  270|      0|    p += strlen (p);
  271|      0|  }
  272|    144|  for (n++; n < len; n++)
  ------------------
  |  Branch (272:13): [True: 120, False: 24]
  ------------------
  273|    120|    {
  274|    120|      val = buf[n] & 0x7f;
  275|    168|      while ( (buf[n]&0x80) && ++n < len )
  ------------------
  |  Branch (275:15): [True: 48, False: 120]
  |  Branch (275:32): [True: 48, False: 0]
  ------------------
  276|     48|        {
  277|     48|          if ( (val & valmask) )
  ------------------
  |  Branch (277:16): [True: 0, False: 48]
  ------------------
  278|      0|            goto badoid;  /* Overflow.  */
  279|     48|          val <<= 7;
  280|     48|          val |= buf[n] & 0x7f;
  281|     48|        }
  282|    120|      sprintf (p, ".%lu", val);
  283|    120|      p += strlen (p);
  284|    120|    }
  285|       |
  286|     24|  *p = 0;
  287|     24|  return string;
  288|       |
  289|      0| badoid:
  290|       |  /* Return a special OID (gnu.gnupg.badoid) to indicate the error
  291|       |     case.  The OID is broken and thus we return one which can't do
  292|       |     any harm.  Formally this does not need to be a bad OID but an OID
  293|       |     with an arc that can't be represented in a 32 bit word is more
  294|       |     than likely corrupt.  */
  295|      0|  xfree (string);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  296|      0|  return xtrystrdup ("1.3.6.1.4.1.11591.2.12242973");
  ------------------
  |  |  103|      0|#define xtrystrdup(a)    gcry_strdup ((a))
  ------------------
  297|     24|}
openpgp_oid_to_str:
  304|     16|{
  305|     16|  const unsigned char *buf;
  306|     16|  unsigned int lengthi;
  307|       |
  308|     16|  if (!a
  ------------------
  |  Branch (308:7): [True: 0, False: 16]
  ------------------
  309|     16|      || !gcry_mpi_get_flag (a, GCRYMPI_FLAG_OPAQUE)
  ------------------
  |  Branch (309:10): [True: 0, False: 16]
  ------------------
  310|     16|      || !(buf = gcry_mpi_get_opaque (a, &lengthi)))
  ------------------
  |  Branch (310:10): [True: 0, False: 16]
  ------------------
  311|      0|    {
  312|      0|      gpg_err_set_errno (EINVAL);
  313|      0|      return NULL;
  314|      0|    }
  315|       |
  316|     16|  return openpgp_oidbuf_to_str (buf, (lengthi+7)/8);
  317|     16|}

gnupg_block_all_signals:
  243|     11|{
  244|     11|  do_block(1);
  245|     11|}
gnupg_unblock_all_signals:
  249|     11|{
  250|     11|  do_block(0);
  251|     11|}
signal.c:do_block:
  188|     22|{
  189|       |#ifdef HAVE_DOSISH_SYSTEM
  190|       |  (void)block;
  191|       |#else /*!HAVE_DOSISH_SYSTEM*/
  192|     22|  static int is_blocked;
  193|     22|#ifdef HAVE_SIGPROCMASK
  194|     22|  static sigset_t oldmask;
  195|       |
  196|     22|  if (block)
  ------------------
  |  Branch (196:7): [True: 11, False: 11]
  ------------------
  197|     11|    {
  198|     11|      sigset_t newmask;
  199|       |
  200|     11|      if (is_blocked)
  ------------------
  |  Branch (200:11): [True: 0, False: 11]
  ------------------
  201|      0|        log_bug ("signals are already blocked\n");
  202|     11|      sigfillset( &newmask );
  203|     11|      sigprocmask( SIG_BLOCK, &newmask, &oldmask );
  204|     11|      is_blocked = 1;
  205|     11|    }
  206|     11|  else
  207|     11|    {
  208|     11|      if (!is_blocked)
  ------------------
  |  Branch (208:11): [True: 0, False: 11]
  ------------------
  209|      0|        log_bug("signals are not blocked\n");
  210|     11|      sigprocmask (SIG_SETMASK, &oldmask, NULL);
  211|     11|      is_blocked = 0;
  212|     11|    }
  213|       |#else /*!HAVE_SIGPROCMASK*/
  214|       |  static void (*disposition[MAXSIG])();
  215|       |  int sig;
  216|       |
  217|       |  if (block)
  218|       |    {
  219|       |      if (is_blocked)
  220|       |        log_bug("signals are already blocked\n");
  221|       |      for (sig=1; sig < MAXSIG; sig++)
  222|       |        {
  223|       |          disposition[sig] = sigset (sig, SIG_HOLD);
  224|       |        }
  225|       |      is_blocked = 1;
  226|       |    }
  227|       |  else
  228|       |    {
  229|       |      if (!is_blocked)
  230|       |        log_bug ("signals are not blocked\n");
  231|       |      for (sig=1; sig < MAXSIG; sig++) {
  232|       |        sigset (sig, disposition[sig]);
  233|       |      }
  234|       |      is_blocked = 0;
  235|       |    }
  236|       |#endif /*!HAVE_SIGPROCMASK*/
  237|     22|#endif /*!HAVE_DOSISH_SYSTEM*/
  238|     22|}

length_sans_trailing_chars:
  305|  1.49k|{
  306|  1.49k|  const unsigned char *p, *mark;
  307|  1.49k|  size_t n;
  308|       |
  309|  48.2k|  for( mark=NULL, p=line, n=0; n < len; n++, p++ )
  ------------------
  |  Branch (309:32): [True: 46.7k, False: 1.49k]
  ------------------
  310|  46.7k|    {
  311|  46.7k|      if (strchr (trimchars, *p ))
  ------------------
  |  Branch (311:11): [True: 6.22k, False: 40.5k]
  ------------------
  312|  6.22k|        {
  313|  6.22k|          if( !mark )
  ------------------
  |  Branch (313:15): [True: 4.14k, False: 2.08k]
  ------------------
  314|  4.14k|            mark = p;
  315|  6.22k|        }
  316|  40.5k|      else
  317|  40.5k|        mark = NULL;
  318|  46.7k|    }
  319|       |
  320|  1.49k|  if (mark)
  ------------------
  |  Branch (320:7): [True: 1.48k, False: 5]
  ------------------
  321|  1.48k|    return mark - line;
  322|      5|  return len;
  323|  1.49k|}
length_sans_trailing_ws:
  330|  1.49k|{
  331|  1.49k|  return length_sans_trailing_chars (line, len, " \t\r\n");
  332|  1.49k|}
make_filename:
  612|     13|{
  613|     13|  va_list arg_ptr;
  614|     13|  char *result;
  615|       |
  616|     13|  va_start (arg_ptr, first_part);
  617|     13|  result = do_make_filename (1, first_part, arg_ptr);
  618|     13|  va_end (arg_ptr);
  619|     13|  return result;
  620|     13|}
make_absfilename:
  642|      3|{
  643|      3|  va_list arg_ptr;
  644|      3|  char *result;
  645|       |
  646|      3|  va_start (arg_ptr, first_part);
  647|      3|  result = do_make_filename (3, first_part, arg_ptr);
  648|      3|  va_end (arg_ptr);
  649|      3|  return result;
  650|      3|}
compare_filenames:
  676|      1|{
  677|       |#ifdef HAVE_DOSISH_SYSTEM
  678|       |  for ( ; *a && *b; a++, b++ )
  679|       |    {
  680|       |      if (*a != *b
  681|       |          && (toupper (*(const unsigned char*)a)
  682|       |              != toupper (*(const unsigned char*)b) )
  683|       |          && !((*a == '/' && *b == '\\') || (*a == '\\' && *b == '/')))
  684|       |        break;
  685|       |    }
  686|       |  if ((*a == '/' && *b == '\\') || (*a == '\\' && *b == '/'))
  687|       |    return 0;
  688|       |  else
  689|       |    return (toupper (*(const unsigned char*)a)
  690|       |            - toupper (*(const unsigned char*)b));
  691|       |#else
  692|      1|    return strcmp(a,b);
  693|      1|#endif
  694|      1|}
stringhelp.c:do_make_filename:
  444|     16|{
  445|     16|  const char *argv[32];
  446|     16|  int argc;
  447|     16|  size_t n;
  448|     16|  int skip = 1;
  449|     16|  char *home_buffer = NULL;
  450|     16|  char *name, *home, *p;
  451|     16|  int want_abs;
  452|       |
  453|     16|  want_abs = !!(xmode & 2);
  454|     16|  xmode &= 1;
  455|       |
  456|     16|  n = strlen (first_part) + 1;
  457|     16|  argc = 0;
  458|     29|  while ( (argv[argc] = va_arg (arg_ptr, const char *)) )
  ------------------
  |  Branch (458:11): [True: 13, False: 16]
  ------------------
  459|     13|    {
  460|     13|      n += strlen (argv[argc]) + 1;
  461|     13|      if (argc >= DIM (argv)-1)
  ------------------
  |  |   47|     13|#define DIM(v)		     (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (461:11): [True: 0, False: 13]
  ------------------
  462|      0|        {
  463|      0|          if (xmode)
  ------------------
  |  Branch (463:15): [True: 0, False: 0]
  ------------------
  464|      0|            BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  465|      0|          gpg_err_set_errno (EINVAL);
  466|      0|          return NULL;
  467|      0|        }
  468|     13|      argc++;
  469|     13|    }
  470|     16|  n++;
  471|       |
  472|     16|  home = NULL;
  473|     16|  if (*first_part == '~')
  ------------------
  |  Branch (473:7): [True: 1, False: 15]
  ------------------
  474|      1|    {
  475|      1|      if (first_part[1] == '/' || !first_part[1])
  ------------------
  |  Branch (475:11): [True: 1, False: 0]
  |  Branch (475:35): [True: 0, False: 0]
  ------------------
  476|      1|        {
  477|       |          /* This is the "~/" or "~" case.  */
  478|      1|          home = getenv("HOME");
  479|      1|          if (!home)
  ------------------
  |  Branch (479:15): [True: 0, False: 1]
  ------------------
  480|      0|            home = home_buffer = get_pwdir (xmode, NULL);
  481|      1|          if (home && *home)
  ------------------
  |  Branch (481:15): [True: 1, False: 0]
  |  Branch (481:23): [True: 1, False: 0]
  ------------------
  482|      1|            n += strlen (home);
  483|      1|        }
  484|      0|      else
  485|      0|        {
  486|       |          /* This is the "~username/" or "~username" case.  */
  487|      0|          char *user;
  488|       |
  489|      0|          if (xmode)
  ------------------
  |  Branch (489:15): [True: 0, False: 0]
  ------------------
  490|      0|            user = xstrdup (first_part+1);
  ------------------
  |  |  112|      0|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
  491|      0|          else
  492|      0|            {
  493|      0|              user = xtrystrdup (first_part+1);
  ------------------
  |  |  103|      0|#define xtrystrdup(a)    gcry_strdup ((a))
  ------------------
  494|      0|              if (!user)
  ------------------
  |  Branch (494:19): [True: 0, False: 0]
  ------------------
  495|      0|                return NULL;
  496|      0|            }
  497|      0|          p = strchr (user, '/');
  498|      0|          if (p)
  ------------------
  |  Branch (498:15): [True: 0, False: 0]
  ------------------
  499|      0|            *p = 0;
  500|      0|          skip = 1 + strlen (user);
  501|       |
  502|      0|          home = home_buffer = get_pwdir (xmode, user);
  503|      0|          xfree (user);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  504|      0|          if (home)
  ------------------
  |  Branch (504:15): [True: 0, False: 0]
  ------------------
  505|      0|            n += strlen (home);
  506|      0|          else
  507|      0|            skip = 1;
  508|      0|        }
  509|      1|    }
  510|       |
  511|     16|  if (xmode)
  ------------------
  |  Branch (511:7): [True: 16, False: 0]
  ------------------
  512|     16|    name = xmalloc (n);
  ------------------
  |  |  107|     16|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  513|      0|  else
  514|      0|    {
  515|      0|      name = xtrymalloc (n);
  ------------------
  |  |   97|      0|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  516|      0|      if (!name)
  ------------------
  |  Branch (516:11): [True: 0, False: 0]
  ------------------
  517|      0|        {
  518|      0|          xfree (home_buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  519|      0|          return NULL;
  520|      0|        }
  521|      0|    }
  522|       |
  523|     16|  if (home)
  ------------------
  |  Branch (523:7): [True: 1, False: 15]
  ------------------
  524|      1|    p = stpcpy (stpcpy (name, home), first_part + skip);
  525|     15|  else
  526|     15|    p = stpcpy (name, first_part);
  527|       |
  528|     16|  xfree (home_buffer);
  ------------------
  |  |  104|     16|#define xfree(a)         gcry_free ((a))
  ------------------
  529|     29|  for (argc=0; argv[argc]; argc++)
  ------------------
  |  Branch (529:16): [True: 13, False: 16]
  ------------------
  530|     13|    {
  531|       |      /* Avoid a leading double slash if the first part was "/".  */
  532|     13|      if (!argc && name[0] == '/' && !name[1])
  ------------------
  |  Branch (532:11): [True: 13, False: 0]
  |  Branch (532:20): [True: 13, False: 0]
  |  Branch (532:38): [True: 0, False: 13]
  ------------------
  533|      0|        p = stpcpy (p, argv[argc]);
  534|     13|      else
  535|     13|        p = stpcpy (stpcpy (p, "/"), argv[argc]);
  536|     13|    }
  537|       |
  538|     16|  if (want_abs)
  ------------------
  |  Branch (538:7): [True: 3, False: 13]
  ------------------
  539|      3|    {
  540|       |#ifdef HAVE_DRIVE_LETTERS
  541|       |      p = strchr (name, ':');
  542|       |      if (p)
  543|       |        p++;
  544|       |      else
  545|       |        p = name;
  546|       |#else
  547|      3|      p = name;
  548|      3|#endif
  549|      3|      if (*p != '/'
  ------------------
  |  Branch (549:11): [True: 0, False: 3]
  ------------------
  550|       |#ifdef HAVE_DRIVE_LETTERS
  551|       |          && *p != '\\'
  552|       |#endif
  553|      3|          )
  554|      0|        {
  555|      0|          home = gnupg_getcwd ();
  556|      0|          if (!home)
  ------------------
  |  Branch (556:15): [True: 0, False: 0]
  ------------------
  557|      0|            {
  558|      0|              if (xmode)
  ------------------
  |  Branch (558:19): [True: 0, False: 0]
  ------------------
  559|      0|                {
  560|      0|                  fprintf (stderr, "\nfatal: getcwd failed: %s\n",
  561|      0|                           strerror (errno));
  562|      0|                  exit(2);
  563|      0|                }
  564|      0|              xfree (name);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  565|      0|              return NULL;
  566|      0|            }
  567|      0|          n = strlen (home) + 1 + strlen (name) + 1;
  568|      0|          if (xmode)
  ------------------
  |  Branch (568:15): [True: 0, False: 0]
  ------------------
  569|      0|            home_buffer = xmalloc (n);
  ------------------
  |  |  107|      0|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  570|      0|          else
  571|      0|            {
  572|      0|              home_buffer = xtrymalloc (n);
  ------------------
  |  |   97|      0|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  573|      0|              if (!home_buffer)
  ------------------
  |  Branch (573:19): [True: 0, False: 0]
  ------------------
  574|      0|                {
  575|      0|                  xfree (home);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  576|      0|                  xfree (name);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  577|      0|                  return NULL;
  578|      0|                }
  579|      0|            }
  580|      0|          if (p == name)
  ------------------
  |  Branch (580:15): [True: 0, False: 0]
  ------------------
  581|      0|            p = home_buffer;
  582|      0|          else /* Windows case.  */
  583|      0|            {
  584|      0|              memcpy (home_buffer, p, p - name + 1);
  585|      0|              p = home_buffer + (p - name + 1);
  586|      0|            }
  587|       |
  588|       |          /* Avoid a leading double slash if the cwd is "/".  */
  589|      0|          if (home[0] == '/' && !home[1])
  ------------------
  |  Branch (589:15): [True: 0, False: 0]
  |  Branch (589:33): [True: 0, False: 0]
  ------------------
  590|      0|            strcpy (stpcpy (p, "/"), name);
  591|      0|          else
  592|      0|            strcpy (stpcpy (stpcpy (p, home), "/"), name);
  593|       |
  594|      0|          xfree (home);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  595|      0|          xfree (name);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  596|      0|          name = home_buffer;
  597|       |          /* Let's do a simple compression to catch the most common
  598|       |             case of using "." for gpg's --homedir option.  */
  599|      0|          n = strlen (name);
  600|      0|          if (n > 2 && name[n-2] == '/' && name[n-1] == '.')
  ------------------
  |  Branch (600:15): [True: 0, False: 0]
  |  Branch (600:24): [True: 0, False: 0]
  |  Branch (600:44): [True: 0, False: 0]
  ------------------
  601|      0|            name[n-2] = 0;
  602|      0|        }
  603|      3|    }
  604|     16|  return change_slashes (name);
  605|     16|}
stringhelp.c:change_slashes:
   70|     16|{
   71|       |#ifdef HAVE_DOSISH_SYSTEM
   72|       |  char *p;
   73|       |
   74|       |  if (strchr (name, '\\'))
   75|       |    {
   76|       |      for (p=name; *p; p++)
   77|       |        if (*p == '/')
   78|       |          *p = '\\';
   79|       |    }
   80|       |#endif /*HAVE_DOSISH_SYSTEM*/
   81|     16|  return name;
   82|     16|}

free_strlist:
   46|  1.62k|{
   47|  1.62k|    strlist_t sl2;
   48|       |
   49|  1.62k|    for(; sl; sl = sl2 ) {
  ------------------
  |  Branch (49:11): [True: 0, False: 1.62k]
  ------------------
   50|      0|	sl2 = sl->next;
   51|      0|	xfree(sl);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
   52|      0|    }
   53|  1.62k|}

check_special_filename:
  582|     54|{
  583|     54|  if (allow_special_filenames
  ------------------
  |  Branch (583:7): [True: 0, False: 54]
  ------------------
  584|     54|      && fname && *fname == '-' && fname[1] == '&')
  ------------------
  |  Branch (584:10): [True: 0, False: 0]
  |  Branch (584:19): [True: 0, False: 0]
  |  Branch (584:36): [True: 0, False: 0]
  ------------------
  585|      0|    {
  586|      0|      int i;
  587|       |
  588|      0|      fname += 2;
  589|      0|      for (i=0; digitp (fname+i); i++ )
  ------------------
  |  |  408|      0|#define digitp(p)   (*(p) >= '0' && *(p) <= '9')
  |  |  ------------------
  |  |  |  Branch (408:22): [True: 0, False: 0]
  |  |  |  Branch (408:37): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  590|      0|        ;
  591|      0|      if (!fname[i])
  ------------------
  |  Branch (591:11): [True: 0, False: 0]
  ------------------
  592|      0|        return notranslate? atoi (fname)
  ------------------
  |  Branch (592:16): [True: 0, False: 0]
  ------------------
  593|      0|          /**/            : translate_sys2libc_fd_int (atoi (fname), for_write);
  594|      0|    }
  595|     54|  return -1;
  596|     54|}
gnupg_rename_file:
  850|     22|{
  851|     22|  gpg_error_t err = 0;
  852|       |
  853|     22|  if (block_signals && *block_signals)
  ------------------
  |  Branch (853:7): [True: 11, False: 11]
  |  Branch (853:24): [True: 11, False: 0]
  ------------------
  854|     11|    gnupg_block_all_signals ();
  855|       |
  856|       |#ifdef HAVE_DOSISH_SYSTEM
  857|       |  {
  858|       |    int wtime = 0;
  859|       |
  860|       |    gnupg_remove (newname);
  861|       |  again:
  862|       |    if (w32_rename (oldname, newname))
  863|       |      {
  864|       |        if (GetLastError () == ERROR_SHARING_VIOLATION)
  865|       |          {
  866|       |            /* Another process has the file open.  We do not use a
  867|       |             * lock for read but instead we wait until the other
  868|       |             * process has closed the file.  This may take long but
  869|       |             * that would also be the case with a dotlock approach for
  870|       |             * read and write.  Note that we don't need this on Unix
  871|       |             * due to the inode concept.
  872|       |             *
  873|       |             * So let's wait until the rename has worked.  The retry
  874|       |             * intervals are 50, 100, 200, 400, 800, 50ms, ...  */
  875|       |            if (!wtime || wtime >= 800)
  876|       |              wtime = 50;
  877|       |            else
  878|       |              wtime *= 2;
  879|       |
  880|       |            if (wtime >= 800)
  881|       |              log_info (_("waiting for file '%s' to become accessible ...\n"),
  882|       |                        oldname);
  883|       |
  884|       |            Sleep (wtime);
  885|       |            goto again;
  886|       |          }
  887|       |        err = my_error_from_syserror ();
  888|       |      }
  889|       |  }
  890|       |#else /* Unix */
  891|     22|  {
  892|       |#ifdef __riscos__
  893|       |    gnupg_remove (newname);
  894|       |#endif
  895|     22|    if (rename (oldname, newname) )
  ------------------
  |  Branch (895:9): [True: 0, False: 22]
  ------------------
  896|      0|      err = my_error_from_syserror ();
  897|     22|  }
  898|     22|#endif /* Unix */
  899|       |
  900|     22|  if (block_signals && *block_signals && err)
  ------------------
  |  Branch (900:7): [True: 11, False: 11]
  |  Branch (900:24): [True: 11, False: 0]
  |  Branch (900:42): [True: 0, False: 11]
  ------------------
  901|      0|    {
  902|      0|      gnupg_unblock_all_signals ();
  903|      0|      *block_signals = 0;
  904|      0|    }
  905|       |
  906|     22|  if (err)
  ------------------
  |  Branch (906:7): [True: 0, False: 22]
  ------------------
  907|      0|    log_error (_("renaming '%s' to '%s' failed: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  908|      0|               oldname, newname, gpg_strerror (err));
  909|     22|  return err;
  910|     22|}
gnupg_access:
 1235|     57|{
 1236|     57|  return gpgrt_access (name, mode);
 1237|     57|}
gnupg_stat:
 1244|      1|{
 1245|       |# ifdef HAVE_W32_SYSTEM
 1246|       |#  if __MINGW32_MAJOR_VERSION > 3
 1247|       |    /* mingw.org's MinGW */
 1248|       |#   define STRUCT_STAT _stat
 1249|       |#  elif defined(_USE_32BIT_TIME_T)
 1250|       |    /* MinGW64 for i686 */
 1251|       |#   define STRUCT_STAT _stat32
 1252|       |#  else
 1253|       |    /* MinGW64 for x86_64 */
 1254|       |#   define STRUCT_STAT _stat64i32
 1255|       |#  endif
 1256|       |  if (any8bitchar (name))
 1257|       |    {
 1258|       |      wchar_t *wname;
 1259|       |      struct STRUCT_STAT st32;
 1260|       |      int ret;
 1261|       |
 1262|       |      wname = utf8_to_wchar (name);
 1263|       |      if (!wname)
 1264|       |        return -1;
 1265|       |      ret = _wstat (wname, &st32);
 1266|       |      xfree (wname);
 1267|       |      if (!ret)
 1268|       |        {
 1269|       |          statbuf->st_dev   = st32.st_dev;
 1270|       |          statbuf->st_ino   = st32.st_ino;
 1271|       |          statbuf->st_mode  = st32.st_mode;
 1272|       |          statbuf->st_nlink = st32.st_nlink;
 1273|       |          statbuf->st_uid   = st32.st_uid;
 1274|       |          statbuf->st_gid   = st32.st_gid;
 1275|       |          statbuf->st_rdev  = st32.st_rdev;
 1276|       |          statbuf->st_size  = st32.st_size;
 1277|       |          statbuf->st_atime = st32.st_atime;
 1278|       |          statbuf->st_mtime = st32.st_mtime;
 1279|       |          statbuf->st_ctime = st32.st_ctime;
 1280|       |        }
 1281|       |      return ret;
 1282|       |    }
 1283|       |  else
 1284|       |    return stat (name, statbuf);
 1285|       |# else
 1286|      1|  return stat (name, statbuf);
 1287|      1|# endif
 1288|      1|}
gnupg_open:
 1295|      1|{
 1296|       |#ifdef HAVE_W32_SYSTEM
 1297|       |  if (any8bitchar (name))
 1298|       |    {
 1299|       |      wchar_t *wname;
 1300|       |      int ret;
 1301|       |
 1302|       |      wname = utf8_to_wchar (name);
 1303|       |      if (!wname)
 1304|       |        return -1;
 1305|       |      ret = _wopen (wname, flags, mode);
 1306|       |      xfree (wname);
 1307|       |      return ret;
 1308|       |    }
 1309|       |  else
 1310|       |    return open (name, flags, mode);
 1311|       |#else
 1312|      1|  return open (name, flags, mode);
 1313|      1|#endif
 1314|      1|}

native_to_utf8:
  320|      1|{
  321|      1|  const unsigned char *string = (const unsigned char *)orig_string;
  322|      1|  const unsigned char *s;
  323|      1|  char *buffer;
  324|      1|  unsigned char *p;
  325|      1|  size_t length = 0;
  326|       |
  327|      1|  if (no_translation)
  ------------------
  |  Branch (327:7): [True: 0, False: 1]
  ------------------
  328|      0|    {
  329|       |      /* Already utf-8 encoded. */
  330|      0|      buffer = xstrdup (orig_string);
  ------------------
  |  |  112|      0|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
  331|      0|    }
  332|      1|  else if (!use_iconv)
  ------------------
  |  Branch (332:12): [True: 1, False: 0]
  ------------------
  333|      1|    {
  334|       |      /* For Latin-1 we can avoid the iconv overhead. */
  335|     20|      for (s = string; *s; s++)
  ------------------
  |  Branch (335:24): [True: 19, False: 1]
  ------------------
  336|     19|	{
  337|     19|	  length++;
  338|     19|	  if (*s & 0x80)
  ------------------
  |  Branch (338:8): [True: 0, False: 19]
  ------------------
  339|      0|	    length++;
  340|     19|	}
  341|      1|      buffer = xmalloc (length + 1);
  ------------------
  |  |  107|      1|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  342|     20|      for (p = (unsigned char *)buffer, s = string; *s; s++)
  ------------------
  |  Branch (342:53): [True: 19, False: 1]
  ------------------
  343|     19|	{
  344|     19|	  if ( (*s & 0x80 ))
  ------------------
  |  Branch (344:9): [True: 0, False: 19]
  ------------------
  345|      0|	    {
  346|      0|	      *p++ = 0xc0 | ((*s >> 6) & 3);
  347|      0|	      *p++ = 0x80 | (*s & 0x3f);
  348|      0|	    }
  349|     19|	  else
  350|     19|	    *p++ = *s;
  351|     19|	}
  352|      1|      *p = 0;
  353|      1|    }
  354|      0|  else
  355|      0|    {
  356|       |      /* Need to use iconv.  */
  357|      0|      iconv_t cd;
  358|      0|      const char *inptr;
  359|      0|      char *outptr;
  360|      0|      size_t inbytes, outbytes;
  361|       |
  362|      0|      cd = iconv_open ("utf-8", active_charset_name);
  363|      0|      if (cd == (iconv_t)-1)
  ------------------
  |  Branch (363:11): [True: 0, False: 0]
  ------------------
  364|      0|        {
  365|      0|          handle_iconv_error ("utf-8", active_charset_name, 1);
  366|      0|          return native_to_utf8 (string);
  367|      0|        }
  368|       |
  369|      0|      for (s=string; *s; s++ )
  ------------------
  |  Branch (369:22): [True: 0, False: 0]
  ------------------
  370|      0|        {
  371|      0|          length++;
  372|      0|          if ((*s & 0x80))
  ------------------
  |  Branch (372:15): [True: 0, False: 0]
  ------------------
  373|      0|            length += 5; /* We may need up to 6 bytes for the utf8 output. */
  374|      0|        }
  375|      0|      buffer = xmalloc (length + 1);
  ------------------
  |  |  107|      0|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  376|       |
  377|      0|      inptr = string;
  378|      0|      inbytes = strlen (string);
  379|      0|      outptr = buffer;
  380|      0|      outbytes = length;
  381|      0|      if ( iconv (cd, (ICONV_CONST char **)&inptr, &inbytes,
  ------------------
  |  Branch (381:12): [True: 0, False: 0]
  ------------------
  382|      0|                  &outptr, &outbytes) == (size_t)-1)
  383|      0|        {
  384|      0|          static int shown;
  385|       |
  386|      0|          if (!shown)
  ------------------
  |  Branch (386:15): [True: 0, False: 0]
  ------------------
  387|      0|            log_info (_("conversion from '%s' to '%s' failed: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  388|      0|                      active_charset_name, "utf-8", strerror (errno));
  389|      0|          shown = 1;
  390|       |          /* We don't do any conversion at all but use the strings as is. */
  391|      0|          strcpy (buffer, string);
  392|      0|        }
  393|      0|      else /* Success.  */
  394|      0|        {
  395|      0|          *outptr = 0;
  396|       |          /* We could realloc the buffer now but I doubt that it makes
  397|       |             much sense given that it will get freed anyway soon
  398|       |             after.  */
  399|      0|        }
  400|      0|      iconv_close (cd);
  401|      0|    }
  402|      1|  return buffer;
  403|      1|}
utf8_to_native:
  689|     11|{
  690|     11|  return do_utf8_to_native (string, length, delim, use_iconv);
  691|     11|}
utf8conv.c:do_utf8_to_native:
  410|     11|{
  411|     11|  int nleft;
  412|     11|  int i;
  413|     11|  unsigned char encbuf[8];
  414|     11|  int encidx;
  415|     11|  const unsigned char *s;
  416|     11|  size_t n;
  417|     11|  char *buffer = NULL;
  418|     11|  char *p = NULL;
  419|     11|  unsigned long val = 0;
  420|     11|  size_t slen;
  421|     11|  int resync = 0;
  422|       |
  423|       |  /* First pass (p==NULL): count the extended utf-8 characters.  */
  424|       |  /* Second pass (p!=NULL): create string.  */
  425|     11|  for (;;)
  426|     22|    {
  427|     22|      for (slen = length, nleft = encidx = 0, n = 0,
  428|     22|             s = (const unsigned char *)string;
  429|    488|           slen;
  ------------------
  |  Branch (429:12): [True: 466, False: 22]
  ------------------
  430|    466|	   s++, slen--)
  431|    466|	{
  432|    466|	  if (resync)
  ------------------
  |  Branch (432:8): [True: 0, False: 466]
  ------------------
  433|      0|	    {
  434|      0|	      if (!(*s < 128 || (*s >= 0xc0 && *s <= 0xfd)))
  ------------------
  |  Branch (434:14): [True: 0, False: 0]
  |  Branch (434:27): [True: 0, False: 0]
  |  Branch (434:41): [True: 0, False: 0]
  ------------------
  435|      0|		{
  436|       |		  /* Still invalid. */
  437|      0|		  if (p)
  ------------------
  |  Branch (437:9): [True: 0, False: 0]
  ------------------
  438|      0|		    {
  439|      0|		      sprintf (p, "\\x%02x", *s);
  440|      0|		      p += 4;
  441|      0|		    }
  442|      0|		  n += 4;
  443|      0|		  continue;
  444|      0|		}
  445|      0|	      resync = 0;
  446|      0|	    }
  447|    466|	  if (!nleft)
  ------------------
  |  Branch (447:8): [True: 466, False: 0]
  ------------------
  448|    466|	    {
  449|    466|	      if (!(*s & 0x80))
  ------------------
  |  Branch (449:12): [True: 466, False: 0]
  ------------------
  450|    466|		{
  451|       |                  /* Plain ascii. */
  452|    466|		  if ( delim != -1
  ------------------
  |  Branch (452:10): [True: 466, False: 0]
  ------------------
  453|    466|                       && (*s < 0x20 || *s == 0x7f || *s == delim
  ------------------
  |  Branch (453:28): [True: 0, False: 466]
  |  Branch (453:41): [True: 0, False: 466]
  |  Branch (453:55): [True: 0, False: 466]
  ------------------
  454|    466|                           || (delim && *s == '\\')))
  ------------------
  |  Branch (454:32): [True: 0, False: 466]
  |  Branch (454:41): [True: 0, False: 0]
  ------------------
  455|      0|		    {
  456|      0|		      n++;
  457|      0|		      if (p)
  ------------------
  |  Branch (457:13): [True: 0, False: 0]
  ------------------
  458|      0|			*p++ = '\\';
  459|      0|		      switch (*s)
  460|      0|			{
  461|      0|                        case '\n': n++; if ( p ) *p++ = 'n'; break;
  ------------------
  |  Branch (461:25): [True: 0, False: 0]
  |  Branch (461:46): [True: 0, False: 0]
  ------------------
  462|      0|                        case '\r': n++; if ( p ) *p++ = 'r'; break;
  ------------------
  |  Branch (462:25): [True: 0, False: 0]
  |  Branch (462:46): [True: 0, False: 0]
  ------------------
  463|      0|                        case '\f': n++; if ( p ) *p++ = 'f'; break;
  ------------------
  |  Branch (463:25): [True: 0, False: 0]
  |  Branch (463:46): [True: 0, False: 0]
  ------------------
  464|      0|                        case '\v': n++; if ( p ) *p++ = 'v'; break;
  ------------------
  |  Branch (464:25): [True: 0, False: 0]
  |  Branch (464:46): [True: 0, False: 0]
  ------------------
  465|      0|                        case '\b': n++; if ( p ) *p++ = 'b'; break;
  ------------------
  |  Branch (465:25): [True: 0, False: 0]
  |  Branch (465:46): [True: 0, False: 0]
  ------------------
  466|      0|                        case    0: n++; if ( p ) *p++ = '0'; break;
  ------------------
  |  Branch (466:25): [True: 0, False: 0]
  |  Branch (466:46): [True: 0, False: 0]
  ------------------
  467|      0|			default:
  ------------------
  |  Branch (467:4): [True: 0, False: 0]
  ------------------
  468|      0|			  n += 3;
  469|      0|			  if (p)
  ------------------
  |  Branch (469:10): [True: 0, False: 0]
  ------------------
  470|      0|			    {
  471|      0|			      sprintf (p, "x%02x", *s);
  472|      0|			      p += 3;
  473|      0|			    }
  474|      0|			  break;
  475|      0|			}
  476|      0|		    }
  477|    466|		  else
  478|    466|		    {
  479|    466|		      if (p)
  ------------------
  |  Branch (479:13): [True: 233, False: 233]
  ------------------
  480|    233|			*p++ = *s;
  481|    466|		      n++;
  482|    466|		    }
  483|    466|		}
  484|      0|	      else if ((*s & 0xe0) == 0xc0) /* 110x xxxx */
  ------------------
  |  Branch (484:17): [True: 0, False: 0]
  ------------------
  485|      0|		{
  486|      0|		  val = *s & 0x1f;
  487|      0|		  nleft = 1;
  488|      0|		  encidx = 0;
  489|      0|		  encbuf[encidx++] = *s;
  490|      0|		}
  491|      0|	      else if ((*s & 0xf0) == 0xe0) /* 1110 xxxx */
  ------------------
  |  Branch (491:17): [True: 0, False: 0]
  ------------------
  492|      0|		{
  493|      0|		  val = *s & 0x0f;
  494|      0|		  nleft = 2;
  495|      0|		  encidx = 0;
  496|      0|		  encbuf[encidx++] = *s;
  497|      0|		}
  498|      0|	      else if ((*s & 0xf8) == 0xf0) /* 1111 0xxx */
  ------------------
  |  Branch (498:17): [True: 0, False: 0]
  ------------------
  499|      0|		{
  500|      0|		  val = *s & 0x07;
  501|      0|		  nleft = 3;
  502|      0|		  encidx = 0;
  503|      0|		  encbuf[encidx++] = *s;
  504|      0|		}
  505|      0|	      else if ((*s & 0xfc) == 0xf8) /* 1111 10xx */
  ------------------
  |  Branch (505:17): [True: 0, False: 0]
  ------------------
  506|      0|		{
  507|      0|		  val = *s & 0x03;
  508|      0|		  nleft = 4;
  509|      0|		  encidx = 0;
  510|      0|		  encbuf[encidx++] = *s;
  511|      0|		}
  512|      0|	      else if ((*s & 0xfe) == 0xfc) /* 1111 110x */
  ------------------
  |  Branch (512:17): [True: 0, False: 0]
  ------------------
  513|      0|		{
  514|      0|		  val = *s & 0x01;
  515|      0|		  nleft = 5;
  516|      0|		  encidx = 0;
  517|      0|		  encbuf[encidx++] = *s;
  518|      0|		}
  519|      0|	      else /* Invalid encoding: print as \xNN. */
  520|      0|		{
  521|      0|		  if (p)
  ------------------
  |  Branch (521:9): [True: 0, False: 0]
  ------------------
  522|      0|		    {
  523|      0|		      sprintf (p, "\\x%02x", *s);
  524|      0|		      p += 4;
  525|      0|		    }
  526|      0|		  n += 4;
  527|      0|		  resync = 1;
  528|      0|		}
  529|    466|	    }
  530|      0|	  else if (*s < 0x80 || *s >= 0xc0) /* Invalid utf-8 */
  ------------------
  |  Branch (530:13): [True: 0, False: 0]
  |  Branch (530:26): [True: 0, False: 0]
  ------------------
  531|      0|	    {
  532|      0|	      if (p)
  ------------------
  |  Branch (532:12): [True: 0, False: 0]
  ------------------
  533|      0|		{
  534|      0|		  for (i = 0; i < encidx; i++)
  ------------------
  |  Branch (534:17): [True: 0, False: 0]
  ------------------
  535|      0|		    {
  536|      0|		      sprintf (p, "\\x%02x", encbuf[i]);
  537|      0|		      p += 4;
  538|      0|		    }
  539|      0|		  sprintf (p, "\\x%02x", *s);
  540|      0|		  p += 4;
  541|      0|		}
  542|      0|	      n += 4 + 4 * encidx;
  543|      0|	      nleft = 0;
  544|      0|	      encidx = 0;
  545|      0|	      resync = 1;
  546|      0|	    }
  547|      0|	  else
  548|      0|	    {
  549|      0|	      encbuf[encidx++] = *s;
  550|      0|	      val <<= 6;
  551|      0|	      val |= *s & 0x3f;
  552|      0|	      if (!--nleft)  /* Ready. */
  ------------------
  |  Branch (552:12): [True: 0, False: 0]
  ------------------
  553|      0|		{
  554|      0|		  if (no_translation)
  ------------------
  |  Branch (554:9): [True: 0, False: 0]
  ------------------
  555|      0|		    {
  556|      0|		      if (p)
  ------------------
  |  Branch (556:13): [True: 0, False: 0]
  ------------------
  557|      0|			{
  558|      0|			  for (i = 0; i < encidx; i++)
  ------------------
  |  Branch (558:18): [True: 0, False: 0]
  ------------------
  559|      0|			    *p++ = encbuf[i];
  560|      0|			}
  561|      0|		      n += encidx;
  562|      0|		      encidx = 0;
  563|      0|		    }
  564|      0|                  else if (with_iconv)
  ------------------
  |  Branch (564:28): [True: 0, False: 0]
  ------------------
  565|      0|                    {
  566|       |                      /* Our strategy for using iconv is a bit strange
  567|       |                         but it better keeps compatibility with
  568|       |                         previous versions in regard to how invalid
  569|       |                         encodings are displayed.  What we do is to
  570|       |                         keep the utf-8 as is and have the real
  571|       |                         translation step then at the end.  Yes, I
  572|       |                         know that this is ugly.  However we are short
  573|       |                         of the 1.4 release and for this branch we
  574|       |                         should not mess too much around with iconv
  575|       |                         things.  One reason for this is that we don't
  576|       |                         know enough about non-GNU iconv
  577|       |                         implementation and want to minimize the risk
  578|       |                         of breaking the code on too many platforms.  */
  579|      0|                        if ( p )
  ------------------
  |  Branch (579:30): [True: 0, False: 0]
  ------------------
  580|      0|                          {
  581|      0|                            for (i=0; i < encidx; i++ )
  ------------------
  |  Branch (581:39): [True: 0, False: 0]
  ------------------
  582|      0|                              *p++ = encbuf[i];
  583|      0|                          }
  584|      0|                        n += encidx;
  585|      0|                        encidx = 0;
  586|      0|                    }
  587|      0|		  else 	/* Latin-1 case. */
  588|      0|                    {
  589|      0|		      if (val >= 0x80 && val < 256)
  ------------------
  |  Branch (589:13): [True: 0, False: 0]
  |  Branch (589:28): [True: 0, False: 0]
  ------------------
  590|      0|			{
  591|       |                          /* We can simply print this character */
  592|      0|			  n++;
  593|      0|			  if (p)
  ------------------
  |  Branch (593:10): [True: 0, False: 0]
  ------------------
  594|      0|			    *p++ = val;
  595|      0|			}
  596|      0|		      else
  597|      0|			{
  598|       |                          /* We do not have a translation: print utf8. */
  599|      0|			  if (p)
  ------------------
  |  Branch (599:10): [True: 0, False: 0]
  ------------------
  600|      0|			    {
  601|      0|			      for (i = 0; i < encidx; i++)
  ------------------
  |  Branch (601:22): [True: 0, False: 0]
  ------------------
  602|      0|				{
  603|      0|				  sprintf (p, "\\x%02x", encbuf[i]);
  604|      0|				  p += 4;
  605|      0|				}
  606|      0|			    }
  607|      0|			  n += encidx * 4;
  608|      0|			  encidx = 0;
  609|      0|			}
  610|      0|		    }
  611|      0|		}
  612|       |
  613|      0|	    }
  614|    466|	}
  615|     22|      if (!buffer)
  ------------------
  |  Branch (615:11): [True: 11, False: 11]
  ------------------
  616|     11|	{
  617|       |          /* Allocate the buffer after the first pass. */
  618|     11|	  buffer = p = xmalloc (n + 1);
  ------------------
  |  |  107|     11|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  619|     11|	}
  620|     11|      else if (with_iconv)
  ------------------
  |  Branch (620:16): [True: 0, False: 11]
  ------------------
  621|      0|        {
  622|       |          /* Note: See above for comments.  */
  623|      0|          iconv_t cd;
  624|      0|          const char *inptr;
  625|      0|          char *outbuf, *outptr;
  626|      0|          size_t inbytes, outbytes;
  627|       |
  628|      0|          *p = 0;  /* Terminate the buffer. */
  629|       |
  630|      0|          cd = iconv_open (active_charset_name, "utf-8");
  631|      0|          if (cd == (iconv_t)-1)
  ------------------
  |  Branch (631:15): [True: 0, False: 0]
  ------------------
  632|      0|            {
  633|      0|              handle_iconv_error (active_charset_name, "utf-8", 1);
  634|      0|              xfree (buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  635|      0|              return utf8_to_native (string, length, delim);
  636|      0|            }
  637|       |
  638|       |          /* Allocate a new buffer large enough to hold all possible
  639|       |             encodings. */
  640|      0|          n = p - buffer + 1;
  641|      0|          inbytes = n - 1;;
  642|      0|          inptr = buffer;
  643|      0|          outbytes = n * MB_LEN_MAX;
  ------------------
  |  |   63|      0|#define MB_LEN_MAX 16
  ------------------
  644|      0|          if (outbytes / MB_LEN_MAX != n)
  ------------------
  |  |   63|      0|#define MB_LEN_MAX 16
  ------------------
  |  Branch (644:15): [True: 0, False: 0]
  ------------------
  645|      0|            BUG (); /* Actually an overflow. */
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  646|      0|          outbuf = outptr = xmalloc (outbytes);
  ------------------
  |  |  107|      0|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  647|      0|          if ( iconv (cd, (ICONV_CONST char **)&inptr, &inbytes,
  ------------------
  |  Branch (647:16): [True: 0, False: 0]
  ------------------
  648|      0|                      &outptr, &outbytes) == (size_t)-1)
  649|      0|            {
  650|      0|              static int shown;
  651|       |
  652|      0|              if (!shown)
  ------------------
  |  Branch (652:19): [True: 0, False: 0]
  ------------------
  653|      0|                log_info (_("conversion from '%s' to '%s' failed: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  654|      0|                          "utf-8", active_charset_name, strerror (errno));
  655|      0|              shown = 1;
  656|       |              /* Didn't worked out.  Try again but without iconv.  */
  657|      0|              xfree (buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  658|      0|              buffer = NULL;
  659|      0|              xfree (outbuf);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  660|      0|              outbuf = do_utf8_to_native (string, length, delim, 0);
  661|      0|            }
  662|      0|            else /* Success.  */
  663|      0|              {
  664|      0|                *outptr = 0; /* Make sure it is a string. */
  665|       |                /* We could realloc the buffer now but I doubt that it
  666|       |                   makes much sense given that it will get freed
  667|       |                   anyway soon after.  */
  668|      0|                xfree (buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  669|      0|              }
  670|      0|          iconv_close (cd);
  671|      0|          return outbuf;
  672|      0|        }
  673|     11|      else /* Not using iconv. */
  674|     11|	{
  675|     11|	  *p = 0; /* Make sure it is a string. */
  676|     11|	  return buffer;
  677|     11|	}
  678|     22|    }
  679|     11|}

xasprintf:
   45|  1.46k|{
   46|  1.46k|  va_list ap;
   47|  1.46k|  char *buf;
   48|       |
   49|  1.46k|  va_start (ap, fmt);
   50|  1.46k|  if (gpgrt_vasprintf (&buf, fmt, ap) < 0)
  ------------------
  |  Branch (50:7): [True: 0, False: 1.46k]
  ------------------
   51|      0|    log_fatal ("estream_asprintf failed: %s\n", strerror (errno));
   52|  1.46k|  va_end (ap);
   53|  1.46k|  return buf;
   54|  1.46k|}
xtryasprintf:
   59|    624|{
   60|    624|  int rc;
   61|    624|  va_list ap;
   62|    624|  char *buf;
   63|       |
   64|    624|  va_start (ap, fmt);
   65|    624|  rc = gpgrt_vasprintf (&buf, fmt, ap);
   66|    624|  va_end (ap);
   67|    624|  if (rc < 0)
  ------------------
  |  Branch (67:7): [True: 0, False: 624]
  ------------------
   68|      0|    return NULL;
   69|    624|  return buf;
   70|    624|}

keyid.c:buf32_to_u32:
  105|  2.05k|{
  106|  2.05k|  const unsigned char *p = buffer;
  107|       |
  108|  2.05k|  return (((u32)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
  109|  2.05k|}
parse-packet.c:buf32_to_ulong:
   89|    108|{
   90|    108|  const unsigned char *p = buffer;
   91|       |
   92|    108|  return (((unsigned long)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
   93|    108|}
parse-packet.c:buf32_to_size_t:
   81|  1.65k|{
   82|  1.65k|  const unsigned char *p = buffer;
   83|       |
   84|  1.65k|  return (((size_t)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
   85|  1.65k|}
parse-packet.c:buf32_to_u32:
  105|    228|{
  106|    228|  const unsigned char *p = buffer;
  107|       |
  108|    228|  return (((u32)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
  109|    228|}
tdbio.c:buf32_to_ulong:
   89|    877|{
   90|    877|  const unsigned char *p = buffer;
   91|       |
   92|    877|  return (((unsigned long)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
   93|    877|}

new_armor_context:
  115|     53|{
  116|     53|  armor_filter_context_t *afx;
  117|     53|  gpg_error_t err;
  118|       |
  119|     53|  afx = xcalloc (1, sizeof *afx);
  ------------------
  |  |  109|     53|#define xcalloc(a,b)     gcry_xcalloc ((a),(b))
  ------------------
  120|     53|  if (afx)
  ------------------
  |  Branch (120:7): [True: 53, False: 0]
  ------------------
  121|     53|    {
  122|     53|      err = gcry_md_open (&afx->crc_md, GCRY_MD_CRC24_RFC2440, 0);
  123|     53|      if (err != 0)
  ------------------
  |  Branch (123:11): [True: 0, False: 53]
  ------------------
  124|      0|	{
  125|      0|	  log_error ("gcry_md_open failed for GCRY_MD_CRC24_RFC2440: %s",
  126|      0|		    gpg_strerror (err));
  127|      0|	  xfree (afx);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  128|      0|	  return NULL;
  129|      0|	}
  130|       |
  131|     53|      afx->refcount = 1;
  132|     53|    }
  133|       |
  134|     53|  return afx;
  135|     53|}
release_armor_context:
  141|    106|{
  142|    106|  if (!afx)
  ------------------
  |  Branch (142:7): [True: 0, False: 106]
  ------------------
  143|      0|    return;
  144|    106|  log_assert (afx->refcount);
  145|    106|  if ( --afx->refcount )
  ------------------
  |  Branch (145:8): [True: 53, False: 53]
  ------------------
  146|     53|    return;
  147|     53|  gcry_md_close (afx->crc_md);
  148|     53|  xfree (afx);
  ------------------
  |  |  104|     53|#define xfree(a)         gcry_free ((a))
  ------------------
  149|     53|}
push_armor_filter:
  154|     53|{
  155|     53|  int rc;
  156|       |
  157|     53|  afx->refcount++;
  158|     53|  rc = iobuf_push_filter (iobuf, armor_filter, afx);
  159|     53|  if (rc)
  ------------------
  |  Branch (159:7): [True: 0, False: 53]
  ------------------
  160|      0|    afx->refcount--;
  161|     53|  return rc;
  162|     53|}
armor.c:is_armored:
  218|  1.36k|{
  219|  1.36k|  int ctb, pkttype;
  220|  1.36k|  int indeterminate_length_allowed;
  221|       |
  222|  1.36k|    ctb = *buf;
  223|  1.36k|    if( !(ctb & 0x80) )
  ------------------
  |  Branch (223:9): [True: 1.30k, False: 60]
  ------------------
  224|       |      /* The most significant bit of the CTB must be set.  Since it is
  225|       |         cleared, this is not a binary OpenPGP message.  Assume it is
  226|       |         armored.  */
  227|  1.30k|      return 1;
  228|       |
  229|     60|    pkttype =  ctb & 0x40 ? (ctb & 0x3f) : ((ctb>>2)&0xf);
  ------------------
  |  Branch (229:16): [True: 48, False: 12]
  ------------------
  230|     60|    switch( pkttype ) {
  231|      0|      case PKT_PUBKEY_ENC:
  ------------------
  |  Branch (231:7): [True: 0, False: 60]
  ------------------
  232|      2|      case PKT_SIGNATURE:
  ------------------
  |  Branch (232:7): [True: 2, False: 58]
  ------------------
  233|      5|      case PKT_SYMKEY_ENC:
  ------------------
  |  Branch (233:7): [True: 3, False: 57]
  ------------------
  234|      5|      case PKT_ONEPASS_SIG:
  ------------------
  |  Branch (234:7): [True: 0, False: 60]
  ------------------
  235|      8|      case PKT_SECRET_KEY:
  ------------------
  |  Branch (235:7): [True: 3, False: 57]
  ------------------
  236|     16|      case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (236:7): [True: 8, False: 52]
  ------------------
  237|     16|      case PKT_SECRET_SUBKEY:
  ------------------
  |  Branch (237:7): [True: 0, False: 60]
  ------------------
  238|     16|      case PKT_MARKER:
  ------------------
  |  Branch (238:7): [True: 0, False: 60]
  ------------------
  239|     18|      case PKT_RING_TRUST:
  ------------------
  |  Branch (239:7): [True: 2, False: 58]
  ------------------
  240|     19|      case PKT_USER_ID:
  ------------------
  |  Branch (240:7): [True: 1, False: 59]
  ------------------
  241|     19|      case PKT_PUBLIC_SUBKEY:
  ------------------
  |  Branch (241:7): [True: 0, False: 60]
  ------------------
  242|     20|      case PKT_ATTRIBUTE:
  ------------------
  |  Branch (242:7): [True: 1, False: 59]
  ------------------
  243|     20|      case PKT_MDC:
  ------------------
  |  Branch (243:7): [True: 0, False: 60]
  ------------------
  244|     20|	indeterminate_length_allowed = 0;
  245|     20|        break;
  246|       |
  247|      0|      case PKT_COMPRESSED:
  ------------------
  |  Branch (247:7): [True: 0, False: 60]
  ------------------
  248|      1|      case PKT_ENCRYPTED:
  ------------------
  |  Branch (248:7): [True: 1, False: 59]
  ------------------
  249|      1|      case PKT_ENCRYPTED_MDC:
  ------------------
  |  Branch (249:7): [True: 0, False: 60]
  ------------------
  250|      1|      case PKT_ENCRYPTED_AEAD:
  ------------------
  |  Branch (250:7): [True: 0, False: 60]
  ------------------
  251|      3|      case PKT_PLAINTEXT:
  ------------------
  |  Branch (251:7): [True: 2, False: 58]
  ------------------
  252|      3|      case PKT_OLD_COMMENT:
  ------------------
  |  Branch (252:7): [True: 0, False: 60]
  ------------------
  253|      4|      case PKT_COMMENT:
  ------------------
  |  Branch (253:7): [True: 1, False: 59]
  ------------------
  254|      4|      case PKT_GPG_CONTROL:
  ------------------
  |  Branch (254:7): [True: 0, False: 60]
  ------------------
  255|      4|	indeterminate_length_allowed = 1;
  256|      4|        break;
  257|       |
  258|     36|      default:
  ------------------
  |  Branch (258:7): [True: 36, False: 24]
  ------------------
  259|       |        /* Invalid packet type.  */
  260|     36|        return 1;
  261|     60|    }
  262|       |
  263|     24|    if (! indeterminate_length_allowed)
  ------------------
  |  Branch (263:9): [True: 20, False: 4]
  ------------------
  264|       |      /* It is only legal to use an indeterminate length with a few
  265|       |         packet types.  If a packet uses an indeterminate length, but
  266|       |         that is not allowed, then the data is not valid binary
  267|       |         OpenPGP data.  */
  268|     20|      {
  269|     20|        int new_format;
  270|     20|        int indeterminate_length;
  271|       |
  272|     20|        new_format = !! (ctb & (1 << 6));
  273|     20|        if (new_format)
  ------------------
  |  Branch (273:13): [True: 10, False: 10]
  ------------------
  274|     10|          indeterminate_length = (buf[1] >= 224 && buf[1] < 255);
  ------------------
  |  Branch (274:35): [True: 0, False: 10]
  |  Branch (274:52): [True: 0, False: 0]
  ------------------
  275|     10|        else
  276|     10|          indeterminate_length = (ctb & 3) == 3;
  277|       |
  278|     20|        if (indeterminate_length)
  ------------------
  |  Branch (278:13): [True: 0, False: 20]
  ------------------
  279|      0|          return 1;
  280|     20|      }
  281|       |
  282|       |    /* The first CTB seems legit.  It is probably not armored
  283|       |       data.  */
  284|     24|    return 0;
  285|     24|}
armor.c:armor_filter:
 1284|  1.66k|{
 1285|  1.66k|    size_t size = *ret_len;
 1286|  1.66k|    armor_filter_context_t *afx = opaque;
 1287|  1.66k|    int rc=0, c;
 1288|  1.66k|    byte radbuf[3];
 1289|  1.66k|    int  idx, idx2;
 1290|  1.66k|    size_t n=0;
 1291|  1.66k|    u32 crc;
 1292|       |#if 0
 1293|       |    static FILE *fp ;
 1294|       |
 1295|       |    if( !fp ) {
 1296|       |	fp = fopen("armor.out", "w");
 1297|       |	log_assert(fp);
 1298|       |    }
 1299|       |#endif
 1300|       |
 1301|  1.66k|    if( DBG_FILTER )
  ------------------
  |  |  351|  1.66k|#define DBG_FILTER (opt.debug & DBG_FILTER_VALUE)
  |  |  ------------------
  |  |  |  |  335|  1.66k|#define DBG_FILTER_VALUE  8	/* debug internal filter handling */
  |  |  ------------------
  |  |  |  Branch (351:20): [True: 0, False: 1.66k]
  |  |  ------------------
  ------------------
 1302|      0|	log_debug("armor-filter: control: %d\n", control );
 1303|  1.66k|    if( control == IOBUFCTRL_UNDERFLOW && afx->inp_bypass ) {
  ------------------
  |  Branch (1303:9): [True: 1.56k, False: 106]
  |  Branch (1303:43): [True: 23, False: 1.53k]
  ------------------
 1304|     23|	n = 0;
 1305|     23|	if( afx->buffer_len ) {
  ------------------
  |  Branch (1305:6): [True: 0, False: 23]
  ------------------
 1306|       |            /* Copy the data from AFX->BUFFER to BUF.  */
 1307|      0|	    for(; n < size && afx->buffer_pos < afx->buffer_len; n++ )
  ------------------
  |  Branch (1307:12): [True: 0, False: 0]
  |  Branch (1307:24): [True: 0, False: 0]
  ------------------
 1308|      0|		buf[n++] = afx->buffer[afx->buffer_pos++];
 1309|      0|	    if( afx->buffer_pos >= afx->buffer_len )
  ------------------
  |  Branch (1309:10): [True: 0, False: 0]
  ------------------
 1310|      0|		afx->buffer_len = 0;
 1311|      0|	}
 1312|       |        /* If there is still space in BUF, read directly into it.  */
 1313|  77.9k|	for(; n < size; n++ ) {
  ------------------
  |  Branch (1313:8): [True: 77.9k, False: 0]
  ------------------
 1314|  77.9k|	    if( (c=iobuf_get(a)) == -1 )
  ------------------
  |  |  500|  77.9k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 77.9k]
  |  |  |  Branch (500:24): [True: 23, False: 77.9k]
  |  |  ------------------
  |  |  501|  77.9k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (1314:10): [True: 23, False: 77.9k]
  ------------------
 1315|     23|		break;
 1316|  77.9k|	    buf[n] = c & 0xff;
 1317|  77.9k|	}
 1318|     23|	if( !n )
  ------------------
  |  Branch (1318:6): [True: 13, False: 10]
  ------------------
 1319|       |            /* We didn't get any data.  EOF.  */
 1320|     13|	    rc = -1;
 1321|     23|	*ret_len = n;
 1322|     23|    }
 1323|  1.64k|    else if( control == IOBUFCTRL_UNDERFLOW ) {
  ------------------
  |  Branch (1323:14): [True: 1.53k, False: 106]
  ------------------
 1324|       |        /* We need some space for the faked packet.  The minmum
 1325|       |         * required size is the PARTIAL_CHUNK size plus a byte for the
 1326|       |         * length itself */
 1327|  1.53k|	if( size < PARTIAL_CHUNK+1 )
  ------------------
  |  |  636|  1.53k|#define PARTIAL_CHUNK 512
  ------------------
  |  Branch (1327:6): [True: 0, False: 1.53k]
  ------------------
 1328|      0|	    BUG(); /* supplied buffer too short */
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1329|       |
 1330|  1.53k|	if( afx->faked )
  ------------------
  |  Branch (1330:6): [True: 0, False: 1.53k]
  ------------------
 1331|      0|	    rc = fake_packet( afx, a, &n, buf, size );
 1332|  1.53k|	else if( !afx->inp_checked ) {
  ------------------
  |  Branch (1332:11): [True: 1.53k, False: 4]
  ------------------
 1333|  1.53k|	    rc = check_input( afx, a );
 1334|  1.53k|	    if( afx->inp_bypass ) {
  ------------------
  |  Branch (1334:10): [True: 24, False: 1.51k]
  ------------------
 1335|   107k|		for(n=0; n < size && afx->buffer_pos < afx->buffer_len; )
  ------------------
  |  Branch (1335:12): [True: 107k, False: 0]
  |  Branch (1335:24): [True: 107k, False: 24]
  ------------------
 1336|   107k|		    buf[n++] = afx->buffer[afx->buffer_pos++];
 1337|     24|		if( afx->buffer_pos >= afx->buffer_len )
  ------------------
  |  Branch (1337:7): [True: 24, False: 0]
  ------------------
 1338|     24|		    afx->buffer_len = 0;
 1339|     24|		if( !n )
  ------------------
  |  Branch (1339:7): [True: 0, False: 24]
  ------------------
 1340|      0|		    rc = -1;
 1341|     24|	    }
 1342|  1.51k|	    else if( afx->faked ) {
  ------------------
  |  Branch (1342:15): [True: 0, False: 1.51k]
  ------------------
 1343|      0|	        unsigned int hashes = afx->hashes;
 1344|      0|                const byte *sesmark;
 1345|      0|                size_t sesmarklen;
 1346|       |
 1347|      0|                sesmark = get_session_marker( &sesmarklen );
 1348|      0|                if ( sesmarklen > 20 )
  ------------------
  |  Branch (1348:22): [True: 0, False: 0]
  ------------------
 1349|      0|                    BUG();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1350|       |
 1351|       |		/* the buffer is at least 15+n*15 bytes long, so it
 1352|       |		 * is easy to construct the packets */
 1353|       |
 1354|      0|		hashes &= 1|2|8|16|32|64;
 1355|      0|		if( !hashes ) {
  ------------------
  |  Branch (1355:7): [True: 0, False: 0]
  ------------------
 1356|      0|		    hashes |= 2;  /* Default to SHA-1. */
 1357|      0|		}
 1358|      0|		n=0;
 1359|       |                /* First a gpg control packet... */
 1360|      0|                buf[n++] = 0xff; /* new format, type 63, 1 length byte */
 1361|      0|                n++;   /* see below */
 1362|      0|                memcpy(buf+n, sesmark, sesmarklen ); n+= sesmarklen;
 1363|      0|                buf[n++] = CTRLPKT_CLEARSIGN_START;
 1364|      0|                buf[n++] = afx->not_dash_escaped? 0:1; /* sigclass */
  ------------------
  |  Branch (1364:28): [True: 0, False: 0]
  ------------------
 1365|      0|                if( hashes & 1 )
  ------------------
  |  Branch (1365:21): [True: 0, False: 0]
  ------------------
 1366|      0|                    buf[n++] = DIGEST_ALGO_RMD160;
 1367|      0|                if( hashes & 2 )
  ------------------
  |  Branch (1367:21): [True: 0, False: 0]
  ------------------
 1368|      0|                    buf[n++] = DIGEST_ALGO_SHA1;
 1369|      0|                if( hashes & 8 )
  ------------------
  |  Branch (1369:21): [True: 0, False: 0]
  ------------------
 1370|      0|                    buf[n++] = DIGEST_ALGO_SHA224;
 1371|      0|                if( hashes & 16 )
  ------------------
  |  Branch (1371:21): [True: 0, False: 0]
  ------------------
 1372|      0|                    buf[n++] = DIGEST_ALGO_SHA256;
 1373|      0|                if( hashes & 32 )
  ------------------
  |  Branch (1373:21): [True: 0, False: 0]
  ------------------
 1374|      0|                    buf[n++] = DIGEST_ALGO_SHA384;
 1375|      0|                if( hashes & 64 )
  ------------------
  |  Branch (1375:21): [True: 0, False: 0]
  ------------------
 1376|      0|                    buf[n++] = DIGEST_ALGO_SHA512;
 1377|      0|                buf[1] = n - 2;
 1378|       |
 1379|       |		/* ...followed by an invented plaintext packet.
 1380|       |		   Amusingly enough, this packet is not compliant with
 1381|       |		   2440 as the initial partial length is less than 512
 1382|       |		   bytes.  Of course, we'll accept it anyway ;) */
 1383|       |
 1384|      0|		buf[n++] = 0xCB; /* new packet format, type 11 */
 1385|      0|		buf[n++] = 0xE1; /* 2^1 == 2 bytes */
 1386|      0|		buf[n++] = 't';  /* canonical text mode */
 1387|      0|		buf[n++] = 0;	 /* namelength */
 1388|      0|		buf[n++] = 0xE2; /* 2^2 == 4 more bytes */
 1389|      0|		memset(buf+n, 0, 4); /* timestamp */
 1390|      0|		n += 4;
 1391|      0|	    }
 1392|  1.51k|	    else if( !rc )
  ------------------
  |  Branch (1392:15): [True: 1.50k, False: 4]
  ------------------
 1393|  1.50k|		rc = radix64_read( afx, a, &n, buf, size );
 1394|  1.53k|	}
 1395|      4|	else
 1396|      4|	    rc = radix64_read( afx, a, &n, buf, size );
 1397|       |#if 0
 1398|       |	if( n )
 1399|       |	    if( fwrite(buf, n, 1, fp ) != 1 )
 1400|       |		BUG();
 1401|       |#endif
 1402|  1.53k|	*ret_len = n;
 1403|  1.53k|    }
 1404|    106|    else if( control == IOBUFCTRL_FLUSH && !afx->cancel ) {
  ------------------
  |  Branch (1404:14): [True: 0, False: 106]
  |  Branch (1404:44): [True: 0, False: 0]
  ------------------
 1405|      0|	if( !afx->status ) { /* write the header line */
  ------------------
  |  Branch (1405:6): [True: 0, False: 0]
  ------------------
 1406|      0|	    const char *s;
 1407|      0|	    strlist_t comment=opt.comments;
 1408|       |
 1409|      0|	    if( afx->what >= DIM(head_strings) )
  ------------------
  |  |   47|      0|#define DIM(v)		     (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (1409:10): [True: 0, False: 0]
  ------------------
 1410|      0|		log_bug("afx->what=%d", afx->what);
 1411|      0|	    iobuf_writestr(a, "-----");
 1412|      0|	    iobuf_writestr(a, head_strings[afx->what] );
 1413|      0|	    iobuf_writestr(a, "-----" );
 1414|      0|	    iobuf_writestr(a,afx->eol);
 1415|      0|	    if (opt.emit_version)
  ------------------
  |  Branch (1415:10): [True: 0, False: 0]
  ------------------
 1416|      0|	      {
 1417|      0|		iobuf_writestr (a, "Version: "GNUPG_NAME" v");
 1418|      0|                for (s=VERSION; *s && *s != '.'; s++)
  ------------------
  |  |  811|      0|#define VERSION "2.3.9"
  ------------------
  |  Branch (1418:33): [True: 0, False: 0]
  |  Branch (1418:39): [True: 0, False: 0]
  ------------------
 1419|      0|                  iobuf_writebyte (a, *s);
 1420|      0|                if (opt.emit_version > 1 && *s)
  ------------------
  |  Branch (1420:21): [True: 0, False: 0]
  |  Branch (1420:45): [True: 0, False: 0]
  ------------------
 1421|      0|                  {
 1422|      0|                    iobuf_writebyte (a, *s++);
 1423|      0|                    for (; *s && *s != '.'; s++)
  ------------------
  |  Branch (1423:28): [True: 0, False: 0]
  |  Branch (1423:34): [True: 0, False: 0]
  ------------------
 1424|      0|                      iobuf_writebyte (a, *s);
 1425|      0|                    if (opt.emit_version > 2)
  ------------------
  |  Branch (1425:25): [True: 0, False: 0]
  ------------------
 1426|      0|                      {
 1427|      0|                        for (; *s && *s != '-' && !spacep (s); s++)
  ------------------
  |  |  407|      0|#define spacep(p)   (*(p) == ' ' || *(p) == '\t')
  |  |  ------------------
  |  |  |  Branch (407:22): [True: 0, False: 0]
  |  |  |  Branch (407:37): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1427:32): [True: 0, False: 0]
  |  Branch (1427:38): [True: 0, False: 0]
  ------------------
 1428|      0|                          iobuf_writebyte (a, *s);
 1429|      0|                        if (opt.emit_version > 3)
  ------------------
  |  Branch (1429:29): [True: 0, False: 0]
  ------------------
 1430|      0|                          iobuf_writestr (a, " (" PRINTABLE_OS_NAME ")");
 1431|      0|                      }
 1432|      0|                  }
 1433|      0|		iobuf_writestr(a,afx->eol);
 1434|      0|	      }
 1435|       |
 1436|       |	    /* write the comment strings */
 1437|      0|	    for(;comment;comment=comment->next)
  ------------------
  |  Branch (1437:11): [True: 0, False: 0]
  ------------------
 1438|      0|	      {
 1439|      0|		iobuf_writestr(a, "Comment: " );
 1440|      0|		for( s=comment->d; *s; s++ )
  ------------------
  |  Branch (1440:22): [True: 0, False: 0]
  ------------------
 1441|      0|		  {
 1442|      0|		    if( *s == '\n' )
  ------------------
  |  Branch (1442:11): [True: 0, False: 0]
  ------------------
 1443|      0|		      iobuf_writestr(a, "\\n" );
 1444|      0|		    else if( *s == '\r' )
  ------------------
  |  Branch (1444:16): [True: 0, False: 0]
  ------------------
 1445|      0|		      iobuf_writestr(a, "\\r" );
 1446|      0|		    else if( *s == '\v' )
  ------------------
  |  Branch (1446:16): [True: 0, False: 0]
  ------------------
 1447|      0|		      iobuf_writestr(a, "\\v" );
 1448|      0|		    else
 1449|      0|		      iobuf_put(a, *s );
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1450|      0|		  }
 1451|       |
 1452|      0|		iobuf_writestr(a,afx->eol);
 1453|      0|	      }
 1454|       |
 1455|      0|	    if ( afx->hdrlines ) {
  ------------------
  |  Branch (1455:11): [True: 0, False: 0]
  ------------------
 1456|      0|                for ( s = afx->hdrlines; *s; s++ ) {
  ------------------
  |  Branch (1456:42): [True: 0, False: 0]
  ------------------
 1457|       |#ifdef HAVE_DOSISH_SYSTEM
 1458|       |                    if ( *s == '\n' )
 1459|       |                        iobuf_put( a, '\r');
 1460|       |#endif
 1461|      0|                    iobuf_put(a, *s );
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1462|      0|                }
 1463|      0|            }
 1464|       |
 1465|      0|	    iobuf_writestr(a,afx->eol);
 1466|      0|	    afx->status++;
 1467|      0|	    afx->idx = 0;
 1468|      0|	    afx->idx2 = 0;
 1469|      0|	    gcry_md_reset (afx->crc_md);
 1470|      0|	}
 1471|       |
 1472|      0|	if( size ) {
  ------------------
  |  Branch (1472:6): [True: 0, False: 0]
  ------------------
 1473|      0|	    gcry_md_write (afx->crc_md, buf, size);
 1474|      0|	    armor_output_buf_as_radix64 (afx, a, buf, size);
 1475|      0|        }
 1476|      0|    }
 1477|    106|    else if( control == IOBUFCTRL_INIT )
  ------------------
  |  Branch (1477:14): [True: 53, False: 53]
  ------------------
 1478|     53|      {
 1479|     53|	if( !is_initialized )
  ------------------
  |  Branch (1479:6): [True: 1, False: 52]
  ------------------
 1480|      1|	  initialize();
 1481|       |
 1482|       |	/* Figure out what we're using for line endings if the caller
 1483|       |	   didn't specify. */
 1484|     53|	if(afx->eol[0]==0)
  ------------------
  |  Branch (1484:5): [True: 53, False: 0]
  ------------------
 1485|     53|	  {
 1486|       |#ifdef HAVE_DOSISH_SYSTEM
 1487|       |	    afx->eol[0]='\r';
 1488|       |	    afx->eol[1]='\n';
 1489|       |#else
 1490|     53|	    afx->eol[0]='\n';
 1491|     53|#endif
 1492|     53|	  }
 1493|     53|      }
 1494|     53|    else if( control == IOBUFCTRL_CANCEL ) {
  ------------------
  |  Branch (1494:14): [True: 0, False: 53]
  ------------------
 1495|      0|	afx->cancel = 1;
 1496|      0|    }
 1497|     53|    else if( control == IOBUFCTRL_FREE ) {
  ------------------
  |  Branch (1497:14): [True: 53, False: 0]
  ------------------
 1498|     53|	if( afx->cancel )
  ------------------
  |  Branch (1498:6): [True: 0, False: 53]
  ------------------
 1499|      0|	    ;
 1500|     53|	else if( afx->status ) { /* pad, write cecksum, and bottom line */
  ------------------
  |  Branch (1500:11): [True: 0, False: 53]
  ------------------
 1501|      0|	    gcry_md_final (afx->crc_md);
 1502|      0|	    crc = get_afx_crc (afx);
 1503|      0|	    idx = afx->idx;
 1504|      0|	    idx2 = afx->idx2;
 1505|      0|	    if( idx ) {
  ------------------
  |  Branch (1505:10): [True: 0, False: 0]
  ------------------
 1506|      0|		c = bintoasc[(afx->radbuf[0]>>2)&077];
 1507|      0|		iobuf_put(a, c);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1508|      0|		if( idx == 1 ) {
  ------------------
  |  Branch (1508:7): [True: 0, False: 0]
  ------------------
 1509|      0|		    c = bintoasc[((afx->radbuf[0] << 4) & 060) & 077];
 1510|      0|		    iobuf_put(a, c);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1511|      0|		    iobuf_put(a, '=');
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1512|      0|		    iobuf_put(a, '=');
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1513|      0|		}
 1514|      0|		else { /* 2 */
 1515|      0|		    c = bintoasc[(((afx->radbuf[0]<<4)&060)
 1516|      0|                                  |((afx->radbuf[1]>>4)&017))&077];
 1517|      0|		    iobuf_put(a, c);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1518|      0|		    c = bintoasc[((afx->radbuf[1] << 2) & 074) & 077];
 1519|      0|		    iobuf_put(a, c);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1520|      0|		    iobuf_put(a, '=');
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1521|      0|		}
 1522|      0|		if( ++idx2 >= (64/4) )
  ------------------
  |  Branch (1522:7): [True: 0, False: 0]
  ------------------
 1523|      0|		  { /* pgp doesn't like 72 here */
 1524|      0|		    iobuf_writestr(a,afx->eol);
 1525|      0|		    idx2=0;
 1526|      0|		  }
 1527|      0|	    }
 1528|       |	    /* may need a linefeed */
 1529|      0|	    if( idx2 )
  ------------------
  |  Branch (1529:10): [True: 0, False: 0]
  ------------------
 1530|      0|	      iobuf_writestr(a,afx->eol);
 1531|       |	    /* write the CRC */
 1532|      0|	    iobuf_put(a, '=');
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1533|      0|	    radbuf[0] = crc >>16;
 1534|      0|	    radbuf[1] = crc >> 8;
 1535|      0|	    radbuf[2] = crc;
 1536|      0|	    c = bintoasc[(*radbuf >> 2) & 077];
 1537|      0|	    iobuf_put(a, c);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1538|      0|	    c = bintoasc[(((*radbuf<<4)&060)|((radbuf[1] >> 4)&017))&077];
 1539|      0|	    iobuf_put(a, c);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1540|      0|	    c = bintoasc[(((radbuf[1]<<2)&074)|((radbuf[2]>>6)&03))&077];
 1541|      0|	    iobuf_put(a, c);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1542|      0|	    c = bintoasc[radbuf[2]&077];
 1543|      0|	    iobuf_put(a, c);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1544|      0|	    iobuf_writestr(a,afx->eol);
 1545|       |	    /* and the trailer */
 1546|      0|	    if( afx->what >= DIM(tail_strings) )
  ------------------
  |  |   47|      0|#define DIM(v)		     (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (1546:10): [True: 0, False: 0]
  ------------------
 1547|      0|		log_bug("afx->what=%d", afx->what);
 1548|      0|	    iobuf_writestr(a, "-----");
 1549|      0|	    iobuf_writestr(a, tail_strings[afx->what] );
 1550|      0|	    iobuf_writestr(a, "-----" );
 1551|      0|	    iobuf_writestr(a,afx->eol);
 1552|      0|	}
 1553|     53|	else if( !afx->any_data && !afx->inp_bypass ) {
  ------------------
  |  Branch (1553:11): [True: 36, False: 17]
  |  Branch (1553:29): [True: 12, False: 24]
  ------------------
 1554|     12|	    log_error(_("no valid OpenPGP data found.\n"));
  ------------------
  |  |   28|     12|#  define _(a) gettext (a)
  ------------------
 1555|     12|	    afx->no_openpgp_data = 1;
 1556|     12|	    write_status_text( STATUS_NODATA, "1" );
 1557|     12|	}
 1558|       |        /* Note that in a cleartext signature truncated lines in the
 1559|       |         * plaintext are detected and propagated to the signature
 1560|       |         * checking code by inserting a \f into the plaintext.  We do
 1561|       |         * not use log_info here because some of the truncated lines
 1562|       |         * are harmless.  */
 1563|     53|	if( afx->truncated )
  ------------------
  |  Branch (1563:6): [True: 0, False: 53]
  ------------------
 1564|      0|	    log_info(_("invalid armor: line longer than %d characters\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1565|      0|		      MAX_LINELEN );
  ------------------
  |  |   38|      0|#define MAX_LINELEN 20000
  ------------------
 1566|       |	/* issue an error to enforce dissemination of correct software */
 1567|     53|	if( afx->qp_detected )
  ------------------
  |  Branch (1567:6): [True: 0, False: 53]
  ------------------
 1568|      0|	    log_error(_("quoted printable character in armor - "
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1569|      0|			"probably a buggy MTA has been used\n") );
 1570|     53|	xfree( afx->buffer );
  ------------------
  |  |  104|     53|#define xfree(a)         gcry_free ((a))
  ------------------
 1571|     53|	afx->buffer = NULL;
 1572|     53|        release_armor_context (afx);
 1573|     53|    }
 1574|      0|    else if( control == IOBUFCTRL_DESC )
  ------------------
  |  Branch (1574:14): [True: 0, False: 0]
  ------------------
 1575|      0|        mem2str (buf, "armor_filter", *ret_len);
 1576|  1.66k|    return rc;
 1577|  1.66k|}
armor.c:is_armor_header:
  393|  3.00k|{
  394|  3.00k|    const char *s;
  395|  3.00k|    byte *save_p, *p;
  396|  3.00k|    int save_c;
  397|  3.00k|    int i;
  398|       |
  399|  3.00k|    if( len < 15 )
  ------------------
  |  Branch (399:9): [True: 908, False: 2.09k]
  ------------------
  400|    908|	return -1; /* too short */
  401|  2.09k|    if( memcmp( line, "-----", 5 ) )
  ------------------
  |  Branch (401:9): [True: 466, False: 1.63k]
  ------------------
  402|    466|	return -1; /* no */
  403|  1.63k|    p = strstr( line+5, "-----");
  404|  1.63k|    if( !p )
  ------------------
  |  Branch (404:9): [True: 87, False: 1.54k]
  ------------------
  405|     87|	return -1;
  406|  1.54k|    save_p = p;
  407|  1.54k|    p += 5;
  408|       |
  409|       |    /* Some Windows environments seem to add whitespace to the end of
  410|       |       the line, so we strip it here.  This becomes strict if
  411|       |       --rfc2440 is set since 2440 reads "The header lines, therefore,
  412|       |       MUST start at the beginning of a line, and MUST NOT have text
  413|       |       following them on the same line."  It is unclear whether "text"
  414|       |       refers to all text or just non-whitespace text.  4880 clarified
  415|       |       this was only non-whitespace text. */
  416|       |
  417|  1.54k|    if(RFC2440)
  ------------------
  |  |  373|  1.54k|#define RFC2440 (opt.compliance==CO_RFC2440)
  |  |  ------------------
  |  |  |  Branch (373:17): [True: 0, False: 1.54k]
  |  |  ------------------
  ------------------
  418|      0|      {
  419|      0|	if( *p == '\r' )
  ------------------
  |  Branch (419:6): [True: 0, False: 0]
  ------------------
  420|      0|	  p++;
  421|      0|	if( *p == '\n' )
  ------------------
  |  Branch (421:6): [True: 0, False: 0]
  ------------------
  422|      0|	  p++;
  423|      0|      }
  424|  1.54k|    else
  425|  3.07k|      while(*p==' ' || *p=='\r' || *p=='\n' || *p=='\t')
  ------------------
  |  Branch (425:13): [True: 0, False: 3.07k]
  |  Branch (425:24): [True: 0, False: 3.07k]
  |  Branch (425:36): [True: 1.52k, False: 1.54k]
  |  Branch (425:48): [True: 0, False: 1.54k]
  ------------------
  426|  1.52k|	p++;
  427|       |
  428|  1.54k|    if( *p )
  ------------------
  |  Branch (428:9): [True: 18, False: 1.52k]
  ------------------
  429|     18|	return -1; /* garbage after dashes */
  430|  1.52k|    save_c = *save_p; *save_p = 0;
  431|  1.52k|    p = line+5;
  432|  3.34k|    for(i=0; (s=head_strings[i]); i++ )
  ------------------
  |  Branch (432:14): [True: 3.31k, False: 36]
  ------------------
  433|  3.31k|	if( !strcmp(s, p) )
  ------------------
  |  Branch (433:6): [True: 1.49k, False: 1.82k]
  ------------------
  434|  1.49k|	    break;
  435|  1.52k|    *save_p = save_c;
  436|  1.52k|    if (!s)
  ------------------
  |  Branch (436:9): [True: 36, False: 1.49k]
  ------------------
  437|     36|      {
  438|     36|        if (!strncmp (p, "BEGIN ", 6))
  ------------------
  |  Branch (438:13): [True: 27, False: 9]
  ------------------
  439|     27|          return 42;
  440|      9|	return -1; /* unknown armor line */
  441|     36|      }
  442|       |
  443|  1.49k|    if( opt.verbose > 1 )
  ------------------
  |  Branch (443:9): [True: 0, False: 1.49k]
  ------------------
  444|      0|	log_info(_("armor: %s\n"), head_strings[i]);
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  445|  1.49k|    return i;
  446|  1.52k|}
armor.c:parse_header_line:
  458|  1.49k|{
  459|  1.49k|    byte *p;
  460|  1.49k|    int hashes=0;
  461|  1.49k|    unsigned int len2;
  462|       |
  463|  1.49k|    len2 = length_sans_trailing_ws ( line, len );
  464|  1.49k|    if( !len2 ) {
  ------------------
  |  Branch (464:9): [True: 666, False: 828]
  ------------------
  465|    666|        afx->buffer_pos = len2;  /* (it is not the fine way to do it here) */
  466|    666|	return 0; /* WS only: same as empty line */
  467|    666|    }
  468|       |
  469|       |    /*
  470|       |      This is fussy.  The spec says that a header line is delimited
  471|       |      with a colon-space pair.  This means that a line such as
  472|       |      "Comment: " (with nothing else) is actually legal as an empty
  473|       |      string comment.  However, email and cut-and-paste being what it
  474|       |      is, that trailing space may go away.  Therefore, we accept empty
  475|       |      headers delimited with only a colon.  --rfc2440, as always,
  476|       |      makes this strict and enforces the colon-space pair. -dms
  477|       |    */
  478|       |
  479|    828|    p = strchr( line, ':');
  480|    828|    if (!p && afx->dearmor_state)
  ------------------
  |  Branch (480:9): [True: 698, False: 130]
  |  Branch (480:15): [True: 0, False: 698]
  ------------------
  481|      0|      return 0; /* Special treatment in --dearmor mode.  */
  482|    828|    if( !p || (RFC2440 && p[1]!=' ')
  ------------------
  |  |  373|    260|#define RFC2440 (opt.compliance==CO_RFC2440)
  |  |  ------------------
  |  |  |  Branch (373:17): [True: 0, False: 130]
  |  |  ------------------
  ------------------
  |  Branch (482:9): [True: 698, False: 130]
  |  Branch (482:27): [True: 0, False: 0]
  ------------------
  483|    828|	|| (!RFC2440 && p[1]!=' ' && p[1]!='\n' && p[1]!='\r'))
  ------------------
  |  |  373|    260|#define RFC2440 (opt.compliance==CO_RFC2440)
  ------------------
  |  Branch (483:6): [True: 130, False: 0]
  |  Branch (483:18): [True: 129, False: 1]
  |  Branch (483:31): [True: 129, False: 0]
  |  Branch (483:45): [True: 128, False: 1]
  ------------------
  484|    826|      {
  485|    826|	log_error (_("invalid armor header: "));
  ------------------
  |  |   28|    826|#  define _(a) gettext (a)
  ------------------
  486|    826|	es_write_sanitized (log_get_stream (), line, len, NULL, NULL);
  487|    826|	log_printf ("\n");
  488|    826|	return -1;
  489|    826|      }
  490|       |
  491|       |    /* Chop off the whitespace we detected before */
  492|      2|    len=len2;
  493|      2|    line[len2]='\0';
  494|       |
  495|      2|    if( opt.verbose ) {
  ------------------
  |  Branch (495:9): [True: 0, False: 2]
  ------------------
  496|      0|	log_info(_("armor header: "));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  497|      0|	es_write_sanitized (log_get_stream (), line, len, NULL, NULL);
  498|      0|	log_printf ("\n");
  499|      0|    }
  500|       |
  501|      2|    if (afx->dearmor_mode)
  ------------------
  |  Branch (501:9): [True: 0, False: 2]
  ------------------
  502|      0|      ;
  503|      2|    else if (afx->in_cleartext)
  ------------------
  |  Branch (503:14): [True: 0, False: 2]
  ------------------
  504|      0|      {
  505|      0|	if( (hashes=parse_hash_header( line )) )
  ------------------
  |  Branch (505:6): [True: 0, False: 0]
  ------------------
  506|      0|	  afx->hashes |= hashes;
  507|      0|	else if( strlen(line) > 15 && !memcmp( line, "NotDashEscaped:", 15 ) )
  ------------------
  |  Branch (507:11): [True: 0, False: 0]
  |  Branch (507:32): [True: 0, False: 0]
  ------------------
  508|      0|	  afx->not_dash_escaped = 1;
  509|      0|	else
  510|      0|	  {
  511|      0|	    log_error(_("invalid clearsig header\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  512|      0|	    return -1;
  513|      0|	  }
  514|      0|      }
  515|      2|    else if(!is_armor_tag(line))
  ------------------
  |  Branch (515:13): [True: 1, False: 1]
  ------------------
  516|      1|      {
  517|       |	/* Section 6.2: "Unknown keys should be reported to the user,
  518|       |	   but OpenPGP should continue to process the message."  Note
  519|       |	   that in a clearsigned message this applies to the signature
  520|       |	   part (i.e. "BEGIN PGP SIGNATURE") and not the signed data
  521|       |	   ("BEGIN PGP SIGNED MESSAGE").  The only key allowed in the
  522|       |	   signed data section is "Hash". */
  523|       |
  524|      1|	log_info(_("unknown armor header: "));
  ------------------
  |  |   28|      1|#  define _(a) gettext (a)
  ------------------
  525|      1|	es_write_sanitized (log_get_stream (), line, len, NULL, NULL);
  526|      1|	log_printf ("\n");
  527|      1|      }
  528|       |
  529|      2|    return 1;
  530|      2|}
armor.c:is_armor_tag:
  375|      2|{
  376|      2|  if(strncmp(line,"Version",7)==0
  ------------------
  |  Branch (376:6): [True: 1, False: 1]
  ------------------
  377|      2|     || strncmp(line,"Comment",7)==0
  ------------------
  |  Branch (377:9): [True: 0, False: 1]
  ------------------
  378|      2|     || strncmp(line,"MessageID",9)==0
  ------------------
  |  Branch (378:9): [True: 0, False: 1]
  ------------------
  379|      2|     || strncmp(line,"Hash",4)==0
  ------------------
  |  Branch (379:9): [True: 0, False: 1]
  ------------------
  380|      2|     || strncmp(line,"Charset",7)==0)
  ------------------
  |  Branch (380:9): [True: 0, False: 1]
  ------------------
  381|      1|    return 1;
  382|       |
  383|      1|  return 0;
  384|      2|}
armor.c:check_input:
  537|  1.53k|{
  538|  1.53k|    int rc = 0;
  539|  1.53k|    int i;
  540|  1.53k|    byte *line;
  541|  1.53k|    unsigned len;
  542|  1.53k|    unsigned maxlen;
  543|  1.53k|    int hdr_line = -1;
  544|       |
  545|       |    /* read the first line to see whether this is armored data */
  546|  1.53k|    maxlen = MAX_LINELEN;
  ------------------
  |  |   38|  1.53k|#define MAX_LINELEN 20000
  ------------------
  547|  1.53k|    len = afx->buffer_len = iobuf_read_line( a, &afx->buffer,
  548|  1.53k|					     &afx->buffer_size, &maxlen );
  549|  1.53k|    line = afx->buffer;
  550|  1.53k|    if( !maxlen ) {
  ------------------
  |  Branch (550:9): [True: 0, False: 1.53k]
  ------------------
  551|       |	/* line has been truncated: assume not armored */
  552|      0|	afx->inp_checked = 1;
  553|      0|	afx->inp_bypass = 1;
  554|      0|	return 0;
  555|      0|    }
  556|       |
  557|  1.53k|    if( !len ) {
  ------------------
  |  Branch (557:9): [True: 4, False: 1.53k]
  ------------------
  558|      4|	return -1; /* eof */
  559|      4|    }
  560|       |
  561|       |    /* (the line is always a C string but maybe longer) */
  562|  1.53k|    if( *line == '\n' || ( len && (*line == '\r' && line[1]=='\n') ) )
  ------------------
  |  Branch (562:9): [True: 165, False: 1.36k]
  |  Branch (562:28): [True: 1.36k, False: 0]
  |  Branch (562:36): [True: 3, False: 1.36k]
  |  Branch (562:53): [True: 1, False: 2]
  ------------------
  563|    166|	;
  564|  1.36k|    else if (len >= 2 && !is_armored (line)) {
  ------------------
  |  Branch (564:14): [True: 1.36k, False: 0]
  |  Branch (564:26): [True: 24, False: 1.34k]
  ------------------
  565|     24|	afx->inp_checked = 1;
  566|     24|	afx->inp_bypass = 1;
  567|     24|	return 0;
  568|     24|    }
  569|       |
  570|       |    /* find the armor header */
  571|  3.02k|    while(len) {
  ------------------
  |  Branch (571:11): [True: 3.00k, False: 14]
  ------------------
  572|  3.00k|	i = is_armor_header( line, len );
  573|  3.00k|        if ( i == 42 ) {
  ------------------
  |  Branch (573:14): [True: 27, False: 2.98k]
  ------------------
  574|     27|            if (afx->dearmor_mode) {
  ------------------
  |  Branch (574:17): [True: 0, False: 27]
  ------------------
  575|      0|                afx->dearmor_state = 1;
  576|      0|                break;
  577|      0|            }
  578|     27|        }
  579|  2.98k|        else if (i >= 0
  ------------------
  |  Branch (579:18): [True: 1.49k, False: 1.48k]
  ------------------
  580|  2.98k|                 && !(afx->only_keyblocks && i != 1 && i != 5 && i != 6 )) {
  ------------------
  |  Branch (580:23): [True: 1.49k, False: 0]
  |  Branch (580:46): [True: 19, False: 1.47k]
  |  Branch (580:56): [True: 0, False: 19]
  |  Branch (580:66): [True: 0, False: 0]
  ------------------
  581|  1.49k|	    hdr_line = i;
  582|  1.49k|	    if( hdr_line == BEGIN_SIGNED_MSG_IDX ) {
  ------------------
  |  |   83|  1.49k|#define BEGIN_SIGNED_MSG_IDX 3
  ------------------
  |  Branch (582:10): [True: 0, False: 1.49k]
  ------------------
  583|      0|	        if( afx->in_cleartext ) {
  ------------------
  |  Branch (583:14): [True: 0, False: 0]
  ------------------
  584|      0|		    log_error(_("nested clear text signatures\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  585|      0|		    rc = gpg_error (GPG_ERR_INV_ARMOR);
  586|      0|                }
  587|      0|		afx->in_cleartext = 1;
  588|      0|	    }
  589|  1.49k|	    break;
  590|  1.49k|	}
  591|       |
  592|       |	/* read the next line (skip all truncated lines) */
  593|  1.51k|	do {
  594|  1.51k|	    maxlen = MAX_LINELEN;
  ------------------
  |  |   38|  1.51k|#define MAX_LINELEN 20000
  ------------------
  595|  1.51k|	    afx->buffer_len = iobuf_read_line( a, &afx->buffer,
  596|  1.51k|					       &afx->buffer_size, &maxlen );
  597|  1.51k|	    line = afx->buffer;
  598|  1.51k|	    len = afx->buffer_len;
  599|  1.51k|	} while( !maxlen );
  ------------------
  |  Branch (599:11): [True: 0, False: 1.51k]
  ------------------
  600|  1.51k|    }
  601|       |
  602|       |    /* Parse the header lines.  */
  603|  1.50k|    while(len) {
  ------------------
  |  Branch (603:11): [True: 1.49k, False: 14]
  ------------------
  604|       |	/* Read the next line (skip all truncated lines). */
  605|  1.49k|	do {
  606|  1.49k|	    maxlen = MAX_LINELEN;
  ------------------
  |  |   38|  1.49k|#define MAX_LINELEN 20000
  ------------------
  607|  1.49k|	    afx->buffer_len = iobuf_read_line( a, &afx->buffer,
  608|  1.49k|					       &afx->buffer_size, &maxlen );
  609|  1.49k|	    line = afx->buffer;
  610|  1.49k|	    len = afx->buffer_len;
  611|  1.49k|	} while( !maxlen );
  ------------------
  |  Branch (611:11): [True: 0, False: 1.49k]
  ------------------
  612|       |
  613|  1.49k|	i = parse_header_line( afx, line, len );
  614|  1.49k|	if( i <= 0 ) {
  ------------------
  |  Branch (614:6): [True: 1.49k, False: 2]
  ------------------
  615|  1.49k|	    if (i && RFC2440)
  ------------------
  |  |  373|    826|#define RFC2440 (opt.compliance==CO_RFC2440)
  |  |  ------------------
  |  |  |  Branch (373:17): [True: 0, False: 826]
  |  |  ------------------
  ------------------
  |  Branch (615:10): [True: 826, False: 666]
  ------------------
  616|      0|		rc = GPG_ERR_INV_ARMOR;
  617|  1.49k|	    break;
  618|  1.49k|	}
  619|  1.49k|    }
  620|       |
  621|       |
  622|  1.50k|    if( rc )
  ------------------
  |  Branch (622:9): [True: 0, False: 1.50k]
  ------------------
  623|      0|	invalid_armor();
  624|  1.50k|    else if( afx->in_cleartext )
  ------------------
  |  Branch (624:14): [True: 0, False: 1.50k]
  ------------------
  625|      0|	afx->faked = 1;
  626|  1.50k|    else {
  627|  1.50k|	afx->inp_checked = 1;
  628|  1.50k|	gcry_md_reset (afx->crc_md);
  629|  1.50k|	afx->idx = 0;
  630|  1.50k|	afx->radbuf[0] = 0;
  631|  1.50k|    }
  632|       |
  633|  1.50k|    return rc;
  634|  1.53k|}
armor.c:radix64_read:
  843|  1.51k|{
  844|  1.51k|    byte val;
  845|  1.51k|    int c;
  846|  1.51k|    u32 binc;
  847|  1.51k|    int checkcrc=0;
  848|  1.51k|    int rc = 0;
  849|  1.51k|    size_t n = 0;
  850|  1.51k|    int idx, onlypad=0;
  851|  1.51k|    int skip_fast = 0;
  852|       |
  853|  1.51k|    idx = afx->idx;
  854|  1.51k|    val = afx->radbuf[0];
  855|  35.2k|    for( n=0; n < size; ) {
  ------------------
  |  Branch (855:15): [True: 35.2k, False: 0]
  ------------------
  856|       |
  857|  35.2k|	if( afx->buffer_pos < afx->buffer_len )
  ------------------
  |  Branch (857:6): [True: 32.8k, False: 2.39k]
  ------------------
  858|  32.8k|	    c = afx->buffer[afx->buffer_pos++];
  859|  2.39k|	else { /* read the next line */
  860|  2.39k|	    unsigned maxlen = MAX_LINELEN;
  ------------------
  |  |   38|  2.39k|#define MAX_LINELEN 20000
  ------------------
  861|  2.39k|	    afx->buffer_pos = 0;
  862|  2.39k|	    afx->buffer_len = iobuf_read_line( a, &afx->buffer,
  863|  2.39k|					       &afx->buffer_size, &maxlen );
  864|  2.39k|	    if( !maxlen )
  ------------------
  |  Branch (864:10): [True: 0, False: 2.39k]
  ------------------
  865|      0|		afx->truncated++;
  866|  2.39k|	    if( !afx->buffer_len )
  ------------------
  |  Branch (866:10): [True: 25, False: 2.37k]
  ------------------
  867|     25|		break; /* eof */
  868|  2.37k|	    continue;
  869|  2.39k|	}
  870|       |
  871|  32.8k|      again:
  872|  32.8k|	binc = asctobin[0][c];
  873|       |
  874|  32.8k|	if( binc != 0xffffffffUL )
  ------------------
  |  Branch (874:6): [True: 11.8k, False: 21.0k]
  ------------------
  875|  11.8k|	  {
  876|  11.8k|	    if( idx == 0 && skip_fast == 0
  ------------------
  |  Branch (876:10): [True: 5.30k, False: 6.53k]
  |  Branch (876:22): [True: 4.75k, False: 552]
  ------------------
  877|  11.8k|		&& afx->buffer_pos + (16 - 1) < afx->buffer_len
  ------------------
  |  Branch (877:6): [True: 2.89k, False: 1.85k]
  ------------------
  878|  11.8k|		&& n + 12 < size)
  ------------------
  |  Branch (878:6): [True: 2.89k, False: 0]
  ------------------
  879|  2.89k|	      {
  880|       |		/* Fast path for radix64 to binary conversion.  */
  881|  2.89k|		u32 b0,b1,b2,b3;
  882|       |
  883|       |		/* Speculatively load 15 more input bytes.  */
  884|  2.89k|		b0 = binc << (3 * 6);
  885|  2.89k|		b0 |= asctobin[2][afx->buffer[afx->buffer_pos + 0]];
  886|  2.89k|		b0 |= asctobin[1][afx->buffer[afx->buffer_pos + 1]];
  887|  2.89k|		b0 |= asctobin[0][afx->buffer[afx->buffer_pos + 2]];
  888|  2.89k|		b1  = asctobin[3][afx->buffer[afx->buffer_pos + 3]];
  889|  2.89k|		b1 |= asctobin[2][afx->buffer[afx->buffer_pos + 4]];
  890|  2.89k|		b1 |= asctobin[1][afx->buffer[afx->buffer_pos + 5]];
  891|  2.89k|		b1 |= asctobin[0][afx->buffer[afx->buffer_pos + 6]];
  892|  2.89k|		b2  = asctobin[3][afx->buffer[afx->buffer_pos + 7]];
  893|  2.89k|		b2 |= asctobin[2][afx->buffer[afx->buffer_pos + 8]];
  894|  2.89k|		b2 |= asctobin[1][afx->buffer[afx->buffer_pos + 9]];
  895|  2.89k|		b2 |= asctobin[0][afx->buffer[afx->buffer_pos + 10]];
  896|  2.89k|		b3  = asctobin[3][afx->buffer[afx->buffer_pos + 11]];
  897|  2.89k|		b3 |= asctobin[2][afx->buffer[afx->buffer_pos + 12]];
  898|  2.89k|		b3 |= asctobin[1][afx->buffer[afx->buffer_pos + 13]];
  899|  2.89k|		b3 |= asctobin[0][afx->buffer[afx->buffer_pos + 14]];
  900|       |
  901|       |		/* Check if any of the input bytes were invalid. */
  902|  2.89k|		if( (b0 | b1 | b2 | b3) != 0xffffffffUL )
  ------------------
  |  Branch (902:7): [True: 1.84k, False: 1.05k]
  ------------------
  903|  1.84k|		  {
  904|       |		    /* All 16 bytes are valid. */
  905|  1.84k|		    buf[n + 0] = b0 >> (2 * 8);
  906|  1.84k|		    buf[n + 1] = b0 >> (1 * 8);
  907|  1.84k|		    buf[n + 2] = b0 >> (0 * 8);
  908|  1.84k|		    buf[n + 3] = b1 >> (2 * 8);
  909|  1.84k|		    buf[n + 4] = b1 >> (1 * 8);
  910|  1.84k|		    buf[n + 5] = b1 >> (0 * 8);
  911|  1.84k|		    buf[n + 6] = b2 >> (2 * 8);
  912|  1.84k|		    buf[n + 7] = b2 >> (1 * 8);
  913|  1.84k|		    buf[n + 8] = b2 >> (0 * 8);
  914|  1.84k|		    buf[n + 9] = b3 >> (2 * 8);
  915|  1.84k|		    buf[n + 10] = b3 >> (1 * 8);
  916|  1.84k|		    buf[n + 11] = b3 >> (0 * 8);
  917|  1.84k|		    afx->buffer_pos += 16 - 1;
  918|  1.84k|		    n += 12;
  919|  1.84k|		    continue;
  920|  1.84k|		  }
  921|  1.05k|		else if( b0 == 0xffffffffUL )
  ------------------
  |  Branch (921:12): [True: 381, False: 676]
  ------------------
  922|    381|		  {
  923|       |		    /* byte[1..3] have invalid character(s).  Switch to slow
  924|       |		       path.  */
  925|    381|		    skip_fast = 1;
  926|    381|		  }
  927|    676|		else if( b1 == 0xffffffffUL )
  ------------------
  |  Branch (927:12): [True: 298, False: 378]
  ------------------
  928|    298|		  {
  929|       |		    /* byte[4..7] have invalid character(s), first 4 bytes are
  930|       |		       valid.  */
  931|    298|		    buf[n + 0] = b0 >> (2 * 8);
  932|    298|		    buf[n + 1] = b0 >> (1 * 8);
  933|    298|		    buf[n + 2] = b0 >> (0 * 8);
  934|    298|		    afx->buffer_pos += 4 - 1;
  935|    298|		    n += 3;
  936|    298|		    skip_fast = 1;
  937|    298|		    continue;
  938|    298|		  }
  939|    378|		else if( b2 == 0xffffffffUL )
  ------------------
  |  Branch (939:12): [True: 259, False: 119]
  ------------------
  940|    259|		  {
  941|       |		    /* byte[8..11] have invalid character(s), first 8 bytes are
  942|       |		       valid.  */
  943|    259|		    buf[n + 0] = b0 >> (2 * 8);
  944|    259|		    buf[n + 1] = b0 >> (1 * 8);
  945|    259|		    buf[n + 2] = b0 >> (0 * 8);
  946|    259|		    buf[n + 3] = b1 >> (2 * 8);
  947|    259|		    buf[n + 4] = b1 >> (1 * 8);
  948|    259|		    buf[n + 5] = b1 >> (0 * 8);
  949|    259|		    afx->buffer_pos += 8 - 1;
  950|    259|		    n += 6;
  951|    259|		    skip_fast = 1;
  952|    259|		    continue;
  953|    259|		  }
  954|    119|		else /*if( b3 == 0xffffffffUL )*/
  955|    119|		  {
  956|       |		    /* byte[12..15] have invalid character(s), first 12 bytes
  957|       |		       are valid.  */
  958|    119|		    buf[n + 0] = b0 >> (2 * 8);
  959|    119|		    buf[n + 1] = b0 >> (1 * 8);
  960|    119|		    buf[n + 2] = b0 >> (0 * 8);
  961|    119|		    buf[n + 3] = b1 >> (2 * 8);
  962|    119|		    buf[n + 4] = b1 >> (1 * 8);
  963|    119|		    buf[n + 5] = b1 >> (0 * 8);
  964|    119|		    buf[n + 6] = b2 >> (2 * 8);
  965|    119|		    buf[n + 7] = b2 >> (1 * 8);
  966|    119|		    buf[n + 8] = b2 >> (0 * 8);
  967|    119|		    afx->buffer_pos += 12 - 1;
  968|    119|		    n += 9;
  969|    119|		    skip_fast = 1;
  970|    119|		    continue;
  971|    119|		  }
  972|  2.89k|	      }
  973|       |
  974|  9.32k|	    switch(idx)
  ------------------
  |  Branch (974:13): [True: 0, False: 9.32k]
  ------------------
  975|  9.32k|	      {
  976|  2.78k|		case 0: val =  binc << 2; break;
  ------------------
  |  Branch (976:3): [True: 2.78k, False: 6.53k]
  ------------------
  977|  2.31k|		case 1: val |= (binc>>4)&3; buf[n++]=val;val=(binc<<4)&0xf0;break;
  ------------------
  |  Branch (977:3): [True: 2.31k, False: 7.01k]
  ------------------
  978|  2.21k|		case 2: val |= (binc>>2)&15; buf[n++]=val;val=(binc<<6)&0xc0;break;
  ------------------
  |  Branch (978:3): [True: 2.21k, False: 7.10k]
  ------------------
  979|  2.00k|		case 3: val |= binc&0x3f; buf[n++] = val; break;
  ------------------
  |  Branch (979:3): [True: 2.00k, False: 7.31k]
  ------------------
  980|  9.32k|	      }
  981|  9.32k|	    idx = (idx+1) % 4;
  982|       |
  983|  9.32k|	    continue;
  984|  9.32k|	  }
  985|       |
  986|  21.0k|	skip_fast = 0;
  987|       |
  988|  21.0k|	if( c == '\n' || c == ' ' || c == '\r' || c == '\t' )
  ------------------
  |  Branch (988:6): [True: 1.96k, False: 19.0k]
  |  Branch (988:19): [True: 390, False: 18.6k]
  |  Branch (988:31): [True: 237, False: 18.4k]
  |  Branch (988:44): [True: 1, False: 18.4k]
  ------------------
  989|  2.59k|	    continue;
  990|  18.4k|	else if( c == '=' ) { /* pad character: stop */
  ------------------
  |  Branch (990:11): [True: 1.48k, False: 16.9k]
  ------------------
  991|       |	    /* some mailers leave quoted-printable encoded characters
  992|       |	     * so we try to workaround this */
  993|  1.48k|	    if( afx->buffer_pos+2 < afx->buffer_len ) {
  ------------------
  |  Branch (993:10): [True: 1.15k, False: 331]
  ------------------
  994|  1.15k|		int cc1, cc2, cc3;
  995|  1.15k|		cc1 = afx->buffer[afx->buffer_pos];
  996|  1.15k|		cc2 = afx->buffer[afx->buffer_pos+1];
  997|  1.15k|		cc3 = afx->buffer[afx->buffer_pos+2];
  998|  1.15k|		if( isxdigit(cc1) && isxdigit(cc2)
  999|  1.15k|				  && strchr( "=\n\r\t ", cc3 )) {
  ------------------
  |  Branch (999:10): [True: 0, False: 43]
  ------------------
 1000|       |		    /* well it seems to be the case - adjust */
 1001|      0|		    c = isdigit(cc1)? (cc1 - '0'): (ascii_toupper(cc1)-'A'+10);
 1002|      0|		    c <<= 4;
 1003|      0|		    c |= isdigit(cc2)? (cc2 - '0'): (ascii_toupper(cc2)-'A'+10);
 1004|      0|		    afx->buffer_pos += 2;
 1005|      0|		    afx->qp_detected = 1;
 1006|      0|		    goto again;
 1007|      0|		}
 1008|  1.15k|	    }
 1009|       |
 1010|       |            /* Occasionally a bug MTA will leave the = escaped as
 1011|       |               =3D.  If the 4 characters following that are valid
 1012|       |               Radix64 characters and they are following by a new
 1013|       |               line, assume that this is the case and skip the
 1014|       |               3D.  */
 1015|  1.48k|            if (afx->buffer_pos + 6 < afx->buffer_len
  ------------------
  |  Branch (1015:17): [True: 230, False: 1.25k]
  ------------------
 1016|  1.48k|                && afx->buffer[afx->buffer_pos + 0] == '3'
  ------------------
  |  Branch (1016:20): [True: 0, False: 230]
  ------------------
 1017|  1.48k|                && afx->buffer[afx->buffer_pos + 1] == 'D'
  ------------------
  |  Branch (1017:20): [True: 0, False: 0]
  ------------------
 1018|  1.48k|                && asctobin[0][afx->buffer[afx->buffer_pos + 2]] != 0xffffffffUL
  ------------------
  |  Branch (1018:20): [True: 0, False: 0]
  ------------------
 1019|  1.48k|                && asctobin[0][afx->buffer[afx->buffer_pos + 3]] != 0xffffffffUL
  ------------------
  |  Branch (1019:20): [True: 0, False: 0]
  ------------------
 1020|  1.48k|                && asctobin[0][afx->buffer[afx->buffer_pos + 4]] != 0xffffffffUL
  ------------------
  |  Branch (1020:20): [True: 0, False: 0]
  ------------------
 1021|  1.48k|                && asctobin[0][afx->buffer[afx->buffer_pos + 5]] != 0xffffffffUL
  ------------------
  |  Branch (1021:20): [True: 0, False: 0]
  ------------------
 1022|  1.48k|                && afx->buffer[afx->buffer_pos + 6] == '\n')
  ------------------
  |  Branch (1022:20): [True: 0, False: 0]
  ------------------
 1023|      0|              {
 1024|      0|                afx->buffer_pos += 2;
 1025|      0|                afx->qp_detected = 1;
 1026|      0|              }
 1027|       |
 1028|  1.48k|	    if (!n)
  ------------------
  |  Branch (1028:10): [True: 779, False: 706]
  ------------------
 1029|    779|	      onlypad = 1;
 1030|       |
 1031|  1.48k|	    if( idx == 1 )
  ------------------
  |  Branch (1031:10): [True: 471, False: 1.01k]
  ------------------
 1032|    471|		buf[n++] = val;
 1033|  1.48k|	    checkcrc++;
 1034|  1.48k|	    break;
 1035|  1.48k|	}
 1036|  16.9k|        else if (afx->dearmor_state && c == '-'
  ------------------
  |  Branch (1036:18): [True: 0, False: 16.9k]
  |  Branch (1036:40): [True: 0, False: 0]
  ------------------
 1037|  16.9k|                 && afx->buffer_pos + 8 < afx->buffer_len
  ------------------
  |  Branch (1037:21): [True: 0, False: 0]
  ------------------
 1038|  16.9k|                 && !strncmp (afx->buffer, "-----END ", 8)) {
  ------------------
  |  Branch (1038:21): [True: 0, False: 0]
  ------------------
 1039|      0|            break; /* End in --dearmor mode.  */
 1040|      0|        }
 1041|  16.9k|	else {
 1042|  16.9k|	    log_error(_("invalid radix64 character %02X skipped\n"), c);
  ------------------
  |  |   28|  16.9k|#  define _(a) gettext (a)
  ------------------
 1043|  16.9k|	    continue;
 1044|  16.9k|	}
 1045|  21.0k|    }
 1046|       |
 1047|  1.51k|    afx->idx = idx;
 1048|  1.51k|    afx->radbuf[0] = val;
 1049|       |
 1050|  1.51k|    if( n )
  ------------------
  |  Branch (1050:9): [True: 1.00k, False: 509]
  ------------------
 1051|  1.00k|      gcry_md_write (afx->crc_md, buf, n);
 1052|       |
 1053|  1.51k|    if( checkcrc ) {
  ------------------
  |  Branch (1053:9): [True: 1.48k, False: 25]
  ------------------
 1054|  1.48k|	gcry_md_final (afx->crc_md);
 1055|  1.48k|	afx->any_data = 1;
 1056|  1.48k|	afx->inp_checked=0;
 1057|  1.48k|	afx->faked = 0;
 1058|  2.71k|	for(;;) { /* skip lf and pad characters */
 1059|  2.71k|	    if( afx->buffer_pos < afx->buffer_len )
  ------------------
  |  Branch (1059:10): [True: 2.60k, False: 103]
  ------------------
 1060|  2.60k|		c = afx->buffer[afx->buffer_pos++];
 1061|    103|	    else { /* read the next line */
 1062|    103|		unsigned maxlen = MAX_LINELEN;
  ------------------
  |  |   38|    103|#define MAX_LINELEN 20000
  ------------------
 1063|    103|		afx->buffer_pos = 0;
 1064|    103|		afx->buffer_len = iobuf_read_line( a, &afx->buffer,
 1065|    103|						   &afx->buffer_size, &maxlen );
 1066|    103|		if( !maxlen )
  ------------------
  |  Branch (1066:7): [True: 0, False: 103]
  ------------------
 1067|      0|		    afx->truncated++;
 1068|    103|		if( !afx->buffer_len )
  ------------------
  |  Branch (1068:7): [True: 1, False: 102]
  ------------------
 1069|      1|		    break; /* eof */
 1070|    102|		continue;
 1071|    103|	    }
 1072|  2.60k|	    if( c == '\n' || c == ' ' || c == '\r'
  ------------------
  |  Branch (1072:10): [True: 103, False: 2.50k]
  |  Branch (1072:23): [True: 0, False: 2.50k]
  |  Branch (1072:35): [True: 623, False: 1.88k]
  ------------------
 1073|  2.60k|		|| c == '\t' || c == '=' )
  ------------------
  |  Branch (1073:6): [True: 191, False: 1.69k]
  |  Branch (1073:19): [True: 208, False: 1.48k]
  ------------------
 1074|  1.12k|		continue;
 1075|  1.48k|	    break;
 1076|  2.60k|	}
 1077|  1.48k|	if( !afx->buffer_len )
  ------------------
  |  Branch (1077:6): [True: 1, False: 1.48k]
  ------------------
 1078|      1|	    log_error(_("premature eof (no CRC)\n"));
  ------------------
  |  |   28|      1|#  define _(a) gettext (a)
  ------------------
 1079|  1.48k|	else {
 1080|  1.48k|	    u32 mycrc = 0;
 1081|  1.48k|	    idx = 0;
 1082|  1.61k|	    do {
 1083|  1.61k|		if( (binc = asctobin[0][c]) == 0xffffffffUL )
  ------------------
  |  Branch (1083:7): [True: 1.44k, False: 172]
  ------------------
 1084|  1.44k|		    break;
 1085|    172|		switch(idx) {
  ------------------
  |  Branch (1085:10): [True: 0, False: 172]
  ------------------
 1086|     43|		  case 0: val =  binc << 2; break;
  ------------------
  |  Branch (1086:5): [True: 43, False: 129]
  ------------------
 1087|     43|		  case 1: val |= (binc>>4)&3; mycrc |= val << 16;val=(binc<<4)&0xf0;break;
  ------------------
  |  Branch (1087:5): [True: 43, False: 129]
  ------------------
 1088|     43|		  case 2: val |= (binc>>2)&15; mycrc |= val << 8;val=(binc<<6)&0xc0;break;
  ------------------
  |  Branch (1088:5): [True: 43, False: 129]
  ------------------
 1089|     43|		  case 3: val |= binc&0x3f; mycrc |= val; break;
  ------------------
  |  Branch (1089:5): [True: 43, False: 129]
  ------------------
 1090|    172|		}
 1091|    172|		for(;;) {
 1092|    172|		    if( afx->buffer_pos < afx->buffer_len )
  ------------------
  |  Branch (1092:11): [True: 172, False: 0]
  ------------------
 1093|    172|			c = afx->buffer[afx->buffer_pos++];
 1094|      0|		    else { /* read the next line */
 1095|      0|			unsigned maxlen = MAX_LINELEN;
  ------------------
  |  |   38|      0|#define MAX_LINELEN 20000
  ------------------
 1096|      0|			afx->buffer_pos = 0;
 1097|      0|			afx->buffer_len = iobuf_read_line( a, &afx->buffer,
 1098|      0|							   &afx->buffer_size,
 1099|      0|								&maxlen );
 1100|      0|			if( !maxlen )
  ------------------
  |  Branch (1100:8): [True: 0, False: 0]
  ------------------
 1101|      0|			    afx->truncated++;
 1102|      0|			if( !afx->buffer_len )
  ------------------
  |  Branch (1102:8): [True: 0, False: 0]
  ------------------
 1103|      0|			    break; /* eof */
 1104|      0|			continue;
 1105|      0|		    }
 1106|    172|		    break;
 1107|    172|		}
 1108|    172|		if( !afx->buffer_len )
  ------------------
  |  Branch (1108:7): [True: 0, False: 172]
  ------------------
 1109|      0|		    break; /* eof */
 1110|    172|	    } while( ++idx < 4 );
  ------------------
  |  Branch (1110:15): [True: 129, False: 43]
  ------------------
 1111|  1.48k|	    if( !afx->buffer_len ) {
  ------------------
  |  Branch (1111:10): [True: 0, False: 1.48k]
  ------------------
 1112|      0|		log_info(_("premature eof (in CRC)\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1113|      0|		rc = invalid_crc();
 1114|      0|	    }
 1115|  1.48k|	    else if( idx == 0 ) {
  ------------------
  |  Branch (1115:15): [True: 1.44k, False: 43]
  ------------------
 1116|       |	        /* No CRC at all is legal ("MAY") */
 1117|  1.44k|	        rc=0;
 1118|  1.44k|	    }
 1119|     43|	    else if( idx != 4 ) {
  ------------------
  |  Branch (1119:15): [True: 0, False: 43]
  ------------------
 1120|      0|		log_info(_("malformed CRC\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1121|      0|		rc = invalid_crc();
 1122|      0|	    }
 1123|     43|	    else if( mycrc != get_afx_crc (afx) ) {
  ------------------
  |  Branch (1123:15): [True: 1, False: 42]
  ------------------
 1124|      1|		log_info (_("CRC error; %06lX - %06lX\n"),
  ------------------
  |  |   28|      1|#  define _(a) gettext (a)
  ------------------
 1125|      1|				    (ulong)get_afx_crc (afx), (ulong)mycrc);
 1126|      1|		rc = invalid_crc();
 1127|      1|	    }
 1128|     42|	    else {
 1129|     42|		rc = 0;
 1130|       |                /* FIXME: Here we should emit another control packet,
 1131|       |                 * so that we know in mainproc that we are processing
 1132|       |                 * a clearsign message */
 1133|       |#if 0
 1134|       |		for(rc=0;!rc;) {
 1135|       |		    rc = 0 /*check_trailer( &fhdr, c )*/;
 1136|       |		    if( !rc ) {
 1137|       |			if( (c=iobuf_get(a)) == -1 )
 1138|       |			    rc = 2;
 1139|       |		    }
 1140|       |		}
 1141|       |		if( rc == -1 )
 1142|       |		    rc = 0;
 1143|       |		else if( rc == 2 ) {
 1144|       |		    log_error(_("premature eof (in trailer)\n"));
 1145|       |		    rc = GPG_ERR_INV_ARMOR;
 1146|       |		}
 1147|       |		else {
 1148|       |		    log_error(_("error in trailer line\n"));
 1149|       |		    rc = GPG_ERR_INV_ARMOR;
 1150|       |		}
 1151|       |#endif
 1152|     42|	    }
 1153|  1.48k|	}
 1154|  1.48k|    }
 1155|       |
 1156|  1.51k|    if( !n && !onlypad )
  ------------------
  |  Branch (1156:9): [True: 509, False: 1.00k]
  |  Branch (1156:15): [True: 18, False: 491]
  ------------------
 1157|     18|	rc = -1;
 1158|       |
 1159|  1.51k|    *retn = n;
 1160|  1.51k|    return rc;
 1161|  1.51k|}
armor.c:invalid_crc:
  832|      1|{
  833|      1|  if ( opt.ignore_crc_error )
  ------------------
  |  Branch (833:8): [True: 0, False: 1]
  ------------------
  834|      0|    return 0;
  835|      1|  log_inc_errorcount();
  836|      1|  return gpg_error (GPG_ERR_INV_ARMOR);
  837|      1|}
armor.c:initialize:
  170|      1|{
  171|      1|    u32 i;
  172|      1|    const byte *s;
  173|       |
  174|       |    /* Build the helptable for radix64 to bin conversion.  Value 0xffffffff is
  175|       |       used to detect invalid characters.  */
  176|      1|    memset (asctobin, 0xff, sizeof(asctobin));
  177|     65|    for(s=bintoasc,i=0; *s; s++,i++ )
  ------------------
  |  Branch (177:25): [True: 64, False: 1]
  ------------------
  178|     64|      {
  179|     64|	asctobin[0][*s] = i << (0 * 6);
  180|     64|	asctobin[1][*s] = i << (1 * 6);
  181|     64|	asctobin[2][*s] = i << (2 * 6);
  182|     64|	asctobin[3][*s] = i << (3 * 6);
  183|     64|      }
  184|       |
  185|      1|    is_initialized=1;
  186|      1|}
armor.c:get_afx_crc:
  191|     44|{
  192|     44|  const byte *crc_buf;
  193|     44|  u32 crc;
  194|       |
  195|     44|  crc_buf = gcry_md_read (afx->crc_md, GCRY_MD_CRC24_RFC2440);
  196|       |
  197|     44|  crc = crc_buf[0];
  198|     44|  crc <<= 8;
  199|     44|  crc |= crc_buf[1];
  200|     44|  crc <<= 8;
  201|     44|  crc |= crc_buf[2];
  202|       |
  203|     44|  return crc;
  204|     44|}

build_keyblock_image:
   88|     11|{
   89|     11|  gpg_error_t err;
   90|     11|  iobuf_t iobuf;
   91|     11|  kbnode_t kbctx, node;
   92|       |
   93|     11|  *r_iobuf = NULL;
   94|       |
   95|     11|  iobuf = iobuf_temp ();
   96|     95|  for (kbctx = NULL; (node = walk_kbnode (keyblock, &kbctx, 0));)
  ------------------
  |  Branch (96:22): [True: 84, False: 11]
  ------------------
   97|     84|    {
   98|       |      /* Make sure to use only packets valid on a keyblock.  */
   99|     84|      switch (node->pkt->pkttype)
  100|     84|        {
  101|     11|        case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (101:9): [True: 11, False: 73]
  ------------------
  102|     14|        case PKT_PUBLIC_SUBKEY:
  ------------------
  |  Branch (102:9): [True: 3, False: 81]
  ------------------
  103|     73|        case PKT_SIGNATURE:
  ------------------
  |  Branch (103:9): [True: 59, False: 25]
  ------------------
  104|     84|        case PKT_USER_ID:
  ------------------
  |  Branch (104:9): [True: 11, False: 73]
  ------------------
  105|     84|        case PKT_ATTRIBUTE:
  ------------------
  |  Branch (105:9): [True: 0, False: 84]
  ------------------
  106|     84|        case PKT_RING_TRUST:
  ------------------
  |  Branch (106:9): [True: 0, False: 84]
  ------------------
  107|     84|          break;
  108|      0|        default:
  ------------------
  |  Branch (108:9): [True: 0, False: 84]
  ------------------
  109|      0|          continue;
  110|     84|        }
  111|       |
  112|     84|      err = build_packet_and_meta (iobuf, node->pkt);
  113|     84|      if (err)
  ------------------
  |  Branch (113:11): [True: 0, False: 84]
  ------------------
  114|      0|        {
  115|      0|          iobuf_close (iobuf);
  116|      0|          return err;
  117|      0|        }
  118|     84|    }
  119|       |
  120|     11|  *r_iobuf = iobuf;
  121|     11|  return 0;
  122|     11|}
build_packet:
  129|     84|{
  130|     84|  int rc = 0;
  131|     84|  int new_ctb = 0;
  132|     84|  int ctb, pkttype;
  133|       |
  134|     84|  if (DBG_PACKET)
  ------------------
  |  |  348|     84|#define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
  |  |  ------------------
  |  |  |  |  331|     84|#define DBG_PACKET_VALUE  1	/* debug packet reading/writing */
  |  |  ------------------
  |  |  |  Branch (348:20): [True: 0, False: 84]
  |  |  ------------------
  ------------------
  135|      0|    log_debug ("build_packet() type=%d\n", pkt->pkttype);
  136|     84|  log_assert (pkt->pkt.generic);
  137|       |
  138|      0|  switch ((pkttype = pkt->pkttype))
  139|     84|    {
  140|     11|    case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (140:5): [True: 11, False: 73]
  ------------------
  141|     11|      if (pkt->pkt.public_key->seckey_info)
  ------------------
  |  Branch (141:11): [True: 0, False: 11]
  ------------------
  142|      0|        pkttype = PKT_SECRET_KEY;
  143|     11|      break;
  144|      3|    case PKT_PUBLIC_SUBKEY:
  ------------------
  |  Branch (144:5): [True: 3, False: 81]
  ------------------
  145|      3|      if (pkt->pkt.public_key->seckey_info)
  ------------------
  |  Branch (145:11): [True: 0, False: 3]
  ------------------
  146|      0|        pkttype = PKT_SECRET_SUBKEY;
  147|      3|      break;
  148|      0|    case PKT_PLAINTEXT:
  ------------------
  |  Branch (148:5): [True: 0, False: 84]
  ------------------
  149|      0|      new_ctb = pkt->pkt.plaintext->new_ctb;
  150|      0|      break;
  151|      0|    case PKT_ENCRYPTED:
  ------------------
  |  Branch (151:5): [True: 0, False: 84]
  ------------------
  152|      0|    case PKT_ENCRYPTED_MDC:
  ------------------
  |  Branch (152:5): [True: 0, False: 84]
  ------------------
  153|      0|    case PKT_ENCRYPTED_AEAD:
  ------------------
  |  Branch (153:5): [True: 0, False: 84]
  ------------------
  154|      0|      new_ctb = pkt->pkt.encrypted->new_ctb;
  155|      0|      break;
  156|      0|    case PKT_COMPRESSED:
  ------------------
  |  Branch (156:5): [True: 0, False: 84]
  ------------------
  157|      0|      new_ctb = pkt->pkt.compressed->new_ctb;
  158|      0|      break;
  159|     11|    case PKT_USER_ID:
  ------------------
  |  Branch (159:5): [True: 11, False: 73]
  ------------------
  160|     11|      if (pkt->pkt.user_id->attrib_data)
  ------------------
  |  Branch (160:11): [True: 0, False: 11]
  ------------------
  161|      0|        pkttype = PKT_ATTRIBUTE;
  162|     11|      break;
  163|     59|    default:
  ------------------
  |  Branch (163:5): [True: 59, False: 25]
  ------------------
  164|     59|      break;
  165|     84|    }
  166|       |
  167|     84|  if (new_ctb || pkttype > 15) /* new format */
  ------------------
  |  Branch (167:7): [True: 0, False: 84]
  |  Branch (167:18): [True: 0, False: 84]
  ------------------
  168|      0|    ctb = (0xc0 | (pkttype & 0x3f));
  169|     84|  else
  170|     84|    ctb = (0x80 | ((pkttype & 15)<<2));
  171|     84|  switch (pkttype)
  172|     84|    {
  173|      0|    case PKT_ATTRIBUTE:
  ------------------
  |  Branch (173:5): [True: 0, False: 84]
  ------------------
  174|     11|    case PKT_USER_ID:
  ------------------
  |  Branch (174:5): [True: 11, False: 73]
  ------------------
  175|     11|      rc = do_user_id (out, ctb, pkt->pkt.user_id);
  176|     11|      break;
  177|      0|    case PKT_OLD_COMMENT:
  ------------------
  |  Branch (177:5): [True: 0, False: 84]
  ------------------
  178|      0|    case PKT_COMMENT:
  ------------------
  |  Branch (178:5): [True: 0, False: 84]
  ------------------
  179|       |      /* Ignore these.  Theoretically, this will never be called as we
  180|       |       * have no way to output comment packets any longer, but just in
  181|       |       * case there is some code path that would end up outputting a
  182|       |       * comment that was written before comments were dropped (in the
  183|       |       * public key?) this is a no-op. 	*/
  184|      0|      break;
  185|      3|    case PKT_PUBLIC_SUBKEY:
  ------------------
  |  Branch (185:5): [True: 3, False: 81]
  ------------------
  186|     14|    case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (186:5): [True: 11, False: 73]
  ------------------
  187|     14|    case PKT_SECRET_SUBKEY:
  ------------------
  |  Branch (187:5): [True: 0, False: 84]
  ------------------
  188|     14|    case PKT_SECRET_KEY:
  ------------------
  |  Branch (188:5): [True: 0, False: 84]
  ------------------
  189|     14|      rc = do_key (out, ctb, pkt->pkt.public_key);
  190|     14|      break;
  191|      0|    case PKT_SYMKEY_ENC:
  ------------------
  |  Branch (191:5): [True: 0, False: 84]
  ------------------
  192|      0|      rc = do_symkey_enc (out, ctb, pkt->pkt.symkey_enc);
  193|      0|      break;
  194|      0|    case PKT_PUBKEY_ENC:
  ------------------
  |  Branch (194:5): [True: 0, False: 84]
  ------------------
  195|      0|      rc = do_pubkey_enc (out, ctb, pkt->pkt.pubkey_enc);
  196|      0|      break;
  197|      0|    case PKT_PLAINTEXT:
  ------------------
  |  Branch (197:5): [True: 0, False: 84]
  ------------------
  198|      0|      rc = do_plaintext (out, ctb, pkt->pkt.plaintext);
  199|      0|      break;
  200|      0|    case PKT_ENCRYPTED:
  ------------------
  |  Branch (200:5): [True: 0, False: 84]
  ------------------
  201|      0|      rc = do_encrypted (out, ctb, pkt->pkt.encrypted);
  202|      0|      break;
  203|      0|    case PKT_ENCRYPTED_MDC:
  ------------------
  |  Branch (203:5): [True: 0, False: 84]
  ------------------
  204|      0|      rc = do_encrypted_mdc (out, ctb, pkt->pkt.encrypted);
  205|      0|      break;
  206|      0|    case PKT_ENCRYPTED_AEAD:
  ------------------
  |  Branch (206:5): [True: 0, False: 84]
  ------------------
  207|      0|      rc = do_encrypted_aead (out, ctb, pkt->pkt.encrypted);
  208|      0|      break;
  209|      0|    case PKT_COMPRESSED:
  ------------------
  |  Branch (209:5): [True: 0, False: 84]
  ------------------
  210|      0|      rc = do_compressed (out, ctb, pkt->pkt.compressed);
  211|      0|      break;
  212|     59|    case PKT_SIGNATURE:
  ------------------
  |  Branch (212:5): [True: 59, False: 25]
  ------------------
  213|     59|      rc = do_signature (out, ctb, pkt->pkt.signature);
  214|     59|      break;
  215|      0|    case PKT_ONEPASS_SIG:
  ------------------
  |  Branch (215:5): [True: 0, False: 84]
  ------------------
  216|      0|      rc = do_onepass_sig (out, ctb, pkt->pkt.onepass_sig);
  217|      0|      break;
  218|      0|    case PKT_RING_TRUST:
  ------------------
  |  Branch (218:5): [True: 0, False: 84]
  ------------------
  219|       |      /* Ignore it (only written by build_packet_and_meta)  */
  220|      0|      break;
  221|      0|    case PKT_MDC:
  ------------------
  |  Branch (221:5): [True: 0, False: 84]
  ------------------
  222|       |      /* We write it directly, so we should never see it here. */
  223|      0|    default:
  ------------------
  |  Branch (223:5): [True: 0, False: 84]
  ------------------
  224|      0|      log_bug ("invalid packet type in build_packet()\n");
  225|      0|      break;
  226|     84|    }
  227|       |
  228|     84|  return rc;
  229|     84|}
build_packet_and_meta:
  237|     84|{
  238|     84|  gpg_error_t err;
  239|     84|  PKT_ring_trust rt = {0};
  240|       |
  241|     84|  err = build_packet (out, pkt);
  242|     84|  if (err)
  ------------------
  |  Branch (242:7): [True: 0, False: 84]
  ------------------
  243|      0|    ;
  244|     84|  else if (pkt->pkttype == PKT_SIGNATURE)
  ------------------
  |  Branch (244:12): [True: 59, False: 25]
  ------------------
  245|     59|    {
  246|     59|      PKT_signature *sig = pkt->pkt.signature;
  247|       |
  248|     59|      rt.subtype = RING_TRUST_SIG;
  ------------------
  |  |  516|     59|#define RING_TRUST_SIG 0  /* The classical signature cache.  */
  ------------------
  249|       |      /* Note: trustval is not yet used.  */
  250|     59|      if (sig->flags.checked)
  ------------------
  |  Branch (250:11): [True: 6, False: 53]
  ------------------
  251|      6|        {
  252|      6|          rt.sigcache = 1;
  253|      6|          if (sig->flags.valid)
  ------------------
  |  Branch (253:15): [True: 6, False: 0]
  ------------------
  254|      6|            rt.sigcache |= 2;
  255|      6|        }
  256|     59|      err = do_ring_trust (out, &rt);
  257|     59|    }
  258|     25|  else if (pkt->pkttype == PKT_USER_ID
  ------------------
  |  Branch (258:12): [True: 11, False: 14]
  ------------------
  259|     25|           || pkt->pkttype == PKT_ATTRIBUTE)
  ------------------
  |  Branch (259:15): [True: 0, False: 14]
  ------------------
  260|     11|    {
  261|     11|      PKT_user_id *uid = pkt->pkt.user_id;
  262|       |
  263|     11|      rt.subtype = RING_TRUST_UID;
  ------------------
  |  |  518|     11|#define RING_TRUST_UID 2  /* A KEYORG on a user id.          */
  ------------------
  264|     11|      rt.keyorg = uid->keyorg;
  265|     11|      rt.keyupdate = uid->keyupdate;
  266|     11|      rt.url = uid->updateurl;
  267|     11|      err = do_ring_trust (out, &rt);
  268|     11|      rt.url = NULL;
  269|     11|    }
  270|     14|  else if (pkt->pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (270:12): [True: 11, False: 3]
  ------------------
  271|     14|           || pkt->pkttype == PKT_SECRET_KEY)
  ------------------
  |  Branch (271:15): [True: 0, False: 3]
  ------------------
  272|     11|    {
  273|     11|      PKT_public_key *pk = pkt->pkt.public_key;
  274|       |
  275|     11|      rt.subtype = RING_TRUST_KEY;
  ------------------
  |  |  517|     11|#define RING_TRUST_KEY 1  /* A KEYORG on a primary key.      */
  ------------------
  276|     11|      rt.keyorg = pk->keyorg;
  277|     11|      rt.keyupdate = pk->keyupdate;
  278|     11|      rt.url = pk->updateurl;
  279|     11|      err = do_ring_trust (out, &rt);
  280|     11|      rt.url = NULL;
  281|       |
  282|     11|    }
  283|       |
  284|     84|  return err;
  285|     84|}
gpg_mpi_write:
  295|     31|{
  296|     31|  gpg_error_t err;
  297|     31|  unsigned int nwritten = 0;
  298|       |
  299|     31|  if (gcry_mpi_get_flag (a, GCRYMPI_FLAG_OPAQUE))
  ------------------
  |  Branch (299:7): [True: 0, False: 31]
  ------------------
  300|      0|    {
  301|      0|      unsigned int nbits;
  302|      0|      const unsigned char *p;
  303|      0|      unsigned char lenhdr[2];
  304|       |
  305|       |      /* gcry_log_debugmpi ("a", a); */
  306|      0|      p = gcry_mpi_get_opaque (a, &nbits);
  307|      0|      if (p)
  ------------------
  |  Branch (307:11): [True: 0, False: 0]
  ------------------
  308|      0|        {
  309|       |          /* Strip leading zero bits.  */
  310|      0|          for (; nbits >= 8 && !*p; p++, nbits -= 8)
  ------------------
  |  Branch (310:18): [True: 0, False: 0]
  |  Branch (310:32): [True: 0, False: 0]
  ------------------
  311|      0|            ;
  312|      0|          if (nbits >= 8 && !(*p & 0x80))
  ------------------
  |  Branch (312:15): [True: 0, False: 0]
  |  Branch (312:29): [True: 0, False: 0]
  ------------------
  313|      0|            if (--nbits >= 7 && !(*p & 0x40))
  ------------------
  |  Branch (313:17): [True: 0, False: 0]
  |  Branch (313:33): [True: 0, False: 0]
  ------------------
  314|      0|              if (--nbits >= 6 && !(*p & 0x20))
  ------------------
  |  Branch (314:19): [True: 0, False: 0]
  |  Branch (314:35): [True: 0, False: 0]
  ------------------
  315|      0|                if (--nbits >= 5 && !(*p & 0x10))
  ------------------
  |  Branch (315:21): [True: 0, False: 0]
  |  Branch (315:37): [True: 0, False: 0]
  ------------------
  316|      0|                  if (--nbits >= 4 && !(*p & 0x08))
  ------------------
  |  Branch (316:23): [True: 0, False: 0]
  |  Branch (316:39): [True: 0, False: 0]
  ------------------
  317|      0|                    if (--nbits >= 3 && !(*p & 0x04))
  ------------------
  |  Branch (317:25): [True: 0, False: 0]
  |  Branch (317:41): [True: 0, False: 0]
  ------------------
  318|      0|                      if (--nbits >= 2 && !(*p & 0x02))
  ------------------
  |  Branch (318:27): [True: 0, False: 0]
  |  Branch (318:43): [True: 0, False: 0]
  ------------------
  319|      0|                        if (--nbits >= 1 && !(*p & 0x01))
  ------------------
  |  Branch (319:29): [True: 0, False: 0]
  |  Branch (319:45): [True: 0, False: 0]
  ------------------
  320|      0|                          --nbits;
  321|      0|        }
  322|       |      /* gcry_log_debug ("   [%u bit]\n", nbits); */
  323|       |      /* gcry_log_debughex (" ", p, (nbits+7)/8); */
  324|      0|      lenhdr[0] = nbits >> 8;
  325|      0|      lenhdr[1] = nbits;
  326|      0|      err = out? iobuf_write (out, lenhdr, 2) : 0;
  ------------------
  |  Branch (326:13): [True: 0, False: 0]
  ------------------
  327|      0|      if (!err)
  ------------------
  |  Branch (327:11): [True: 0, False: 0]
  ------------------
  328|      0|        {
  329|      0|          nwritten += 2;
  330|      0|          if (p)
  ------------------
  |  Branch (330:15): [True: 0, False: 0]
  ------------------
  331|      0|            {
  332|      0|              err = out? iobuf_write (out, p, (nbits+7)/8) : 0;
  ------------------
  |  Branch (332:21): [True: 0, False: 0]
  ------------------
  333|      0|              if (!err)
  ------------------
  |  Branch (333:19): [True: 0, False: 0]
  ------------------
  334|      0|                nwritten += (nbits+7)/8;
  335|      0|            }
  336|      0|        }
  337|      0|    }
  338|     31|  else
  339|     31|    {
  340|     31|      char buffer[(MAX_EXTERN_MPI_BITS+7)/8+2]; /* 2 is for the mpi length. */
  341|     31|      size_t nbytes;
  342|       |
  343|     31|      nbytes = DIM(buffer);
  ------------------
  |  |   47|     31|#define DIM(v)		     (sizeof(v)/sizeof((v)[0]))
  ------------------
  344|     31|      err = gcry_mpi_print (GCRYMPI_FMT_PGP, buffer, nbytes, &nbytes, a );
  345|     31|      if (!err)
  ------------------
  |  Branch (345:11): [True: 31, False: 0]
  ------------------
  346|     31|        {
  347|     31|          err = out? iobuf_write (out, buffer, nbytes) : 0;
  ------------------
  |  Branch (347:17): [True: 31, False: 0]
  ------------------
  348|     31|          if (!err)
  ------------------
  |  Branch (348:15): [True: 31, False: 0]
  ------------------
  349|     31|            nwritten += nbytes;
  350|     31|        }
  351|      0|      else if (gpg_err_code (err) == GPG_ERR_TOO_SHORT )
  ------------------
  |  Branch (351:16): [True: 0, False: 0]
  ------------------
  352|      0|        {
  353|      0|          log_info ("mpi too large (%u bits)\n", gcry_mpi_get_nbits (a));
  354|       |          /* The buffer was too small.  We better tell the user about
  355|       |           * the MPI. */
  356|      0|          err = gpg_error (GPG_ERR_TOO_LARGE);
  357|      0|        }
  358|     31|    }
  359|       |
  360|     31|  if (r_nwritten)
  ------------------
  |  Branch (360:7): [True: 0, False: 31]
  ------------------
  361|      0|    *r_nwritten = nwritten;
  362|     31|  return err;
  363|     31|}
gpg_mpi_write_nohdr:
  435|      8|{
  436|      8|  int rc;
  437|       |
  438|      8|  if (gcry_mpi_get_flag (a, GCRYMPI_FLAG_OPAQUE))
  ------------------
  |  Branch (438:7): [True: 8, False: 0]
  ------------------
  439|      8|    {
  440|      8|      unsigned int nbits;
  441|      8|      const void *p;
  442|       |
  443|      8|      p = gcry_mpi_get_opaque (a, &nbits);
  444|      8|      rc = p ? iobuf_write (out, p, (nbits+7)/8) : 0;
  ------------------
  |  Branch (444:12): [True: 8, False: 0]
  ------------------
  445|      8|    }
  446|      0|  else
  447|      0|    rc = gpg_error (GPG_ERR_BAD_MPI);
  448|       |
  449|      8|  return rc;
  450|      8|}
build-packet.c:do_ring_trust:
  510|     81|{
  511|     81|  unsigned int namelen = 0;
  512|     81|  unsigned int pktlen = 6;
  513|       |
  514|     81|  if (rt->subtype == RING_TRUST_KEY || rt->subtype == RING_TRUST_UID)
  ------------------
  |  |  517|    162|#define RING_TRUST_KEY 1  /* A KEYORG on a primary key.      */
  ------------------
                if (rt->subtype == RING_TRUST_KEY || rt->subtype == RING_TRUST_UID)
  ------------------
  |  |  518|     70|#define RING_TRUST_UID 2  /* A KEYORG on a user id.          */
  ------------------
  |  Branch (514:7): [True: 11, False: 70]
  |  Branch (514:40): [True: 11, False: 59]
  ------------------
  515|     22|    {
  516|     22|      if (rt->url)
  ------------------
  |  Branch (516:11): [True: 0, False: 22]
  ------------------
  517|      0|        namelen = strlen (rt->url);
  518|     22|      pktlen += 1 + 4 + 1 + namelen;
  519|     22|    }
  520|       |
  521|     81|  write_header (out, (0x80 | ((PKT_RING_TRUST & 15)<<2)), pktlen);
  522|     81|  iobuf_put (out, rt->trustval);
  ------------------
  |  |  548|     81|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  523|     81|  iobuf_put (out, rt->sigcache);
  ------------------
  |  |  548|     81|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  524|     81|  iobuf_write (out, "gpg", 3);
  525|     81|  iobuf_put (out, rt->subtype);
  ------------------
  |  |  548|     81|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  526|     81|  if (rt->subtype == RING_TRUST_KEY || rt->subtype == RING_TRUST_UID)
  ------------------
  |  |  517|    162|#define RING_TRUST_KEY 1  /* A KEYORG on a primary key.      */
  ------------------
                if (rt->subtype == RING_TRUST_KEY || rt->subtype == RING_TRUST_UID)
  ------------------
  |  |  518|     70|#define RING_TRUST_UID 2  /* A KEYORG on a user id.          */
  ------------------
  |  Branch (526:7): [True: 11, False: 70]
  |  Branch (526:40): [True: 11, False: 59]
  ------------------
  527|     22|    {
  528|     22|      iobuf_put (out, rt->keyorg);
  ------------------
  |  |  548|     22|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  529|     22|      write_32 (out, rt->keyupdate);
  530|     22|      iobuf_put (out, namelen);
  ------------------
  |  |  548|     22|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  531|     22|      if (namelen)
  ------------------
  |  Branch (531:11): [True: 0, False: 22]
  ------------------
  532|      0|        iobuf_write (out, rt->url, namelen);
  533|     22|    }
  534|       |
  535|     81|  return 0;
  536|     81|}
build-packet.c:write_header:
 1909|    135|{
 1910|    135|    return write_header2( out, ctb, len, 0 );
 1911|    135|}
build-packet.c:write_header2:
 1951|    160|{
 1952|    160|  if (ctb_new_format_p (ctb))
  ------------------
  |  Branch (1952:7): [True: 0, False: 160]
  ------------------
 1953|      0|    return write_new_header( out, ctb, len, hdrlen );
 1954|       |
 1955|       |  /* An old format packet.  Refer to RFC 4880, Section 4.2.1 to
 1956|       |     understand how lengths are encoded in this case.  */
 1957|       |
 1958|       |  /* The length encoding is stored in the two least significant bits.
 1959|       |     Make sure they are cleared.  */
 1960|    160|  log_assert ((ctb & 3) == 0);
 1961|       |
 1962|      0|  log_assert (hdrlen == 0 || hdrlen == 2 || hdrlen == 3 || hdrlen == 5);
 1963|       |
 1964|    160|  if (hdrlen)
  ------------------
  |  Branch (1964:7): [True: 0, False: 160]
  ------------------
 1965|       |    /* Header length is given.  */
 1966|      0|    {
 1967|      0|      if( hdrlen == 2 && len < 256 )
  ------------------
  |  Branch (1967:11): [True: 0, False: 0]
  |  Branch (1967:26): [True: 0, False: 0]
  ------------------
 1968|       |        /* 00 => 1 byte length.  */
 1969|      0|	;
 1970|      0|      else if( hdrlen == 3 && len < 65536 )
  ------------------
  |  Branch (1970:16): [True: 0, False: 0]
  |  Branch (1970:31): [True: 0, False: 0]
  ------------------
 1971|       |        /* 01 => 2 byte length.  If len < 256, this is not the most
 1972|       |           compact encoding, but it is a correct encoding.  */
 1973|      0|	ctb |= 1;
 1974|      0|      else if (hdrlen == 5)
  ------------------
  |  Branch (1974:16): [True: 0, False: 0]
  ------------------
 1975|       |        /* 10 => 4 byte length.  If len < 65536, this is not the most
 1976|       |           compact encoding, but it is a correct encoding.  */
 1977|      0|	ctb |= 2;
 1978|      0|      else
 1979|      0|        log_bug ("Can't encode length=%d in a %d byte header!\n",
 1980|      0|                 len, hdrlen);
 1981|      0|    }
 1982|    160|  else
 1983|    160|    {
 1984|    160|      if( !len )
  ------------------
  |  Branch (1984:11): [True: 0, False: 160]
  ------------------
 1985|       |        /* 11 => Indeterminate length.  */
 1986|      0|	ctb |= 3;
 1987|    160|      else if( len < 256 )
  ------------------
  |  Branch (1987:16): [True: 145, False: 15]
  ------------------
 1988|       |        /* 00 => 1 byte length.  */
 1989|    145|	;
 1990|     15|      else if( len < 65536 )
  ------------------
  |  Branch (1990:16): [True: 15, False: 0]
  ------------------
 1991|       |        /* 01 => 2 byte length.  */
 1992|     15|	ctb |= 1;
 1993|      0|      else
 1994|       |        /* 10 => 4 byte length.  */
 1995|      0|	ctb |= 2;
 1996|    160|    }
 1997|       |
 1998|    160|  if( iobuf_put(out, ctb ) )
  ------------------
  |  |  548|    160|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  |  |  ------------------
  |  |  |  Branch (548:24): [True: 0, False: 160]
  |  |  ------------------
  ------------------
 1999|      0|    return -1;
 2000|       |
 2001|    160|  if( len || hdrlen )
  ------------------
  |  Branch (2001:7): [True: 160, False: 0]
  |  Branch (2001:14): [True: 0, False: 0]
  ------------------
 2002|    160|    {
 2003|    160|      if( ctb & 2 )
  ------------------
  |  Branch (2003:11): [True: 0, False: 160]
  ------------------
 2004|      0|	{
 2005|      0|	  if(iobuf_put(out, len >> 24 ))
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  |  |  ------------------
  |  |  |  Branch (548:24): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2006|      0|	    return -1;
 2007|      0|	  if(iobuf_put(out, len >> 16 ))
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  |  |  ------------------
  |  |  |  Branch (548:24): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2008|      0|	    return -1;
 2009|      0|	}
 2010|       |
 2011|    160|      if( ctb & 3 )
  ------------------
  |  Branch (2011:11): [True: 15, False: 145]
  ------------------
 2012|     15|	if(iobuf_put(out, len >> 8 ))
  ------------------
  |  |  548|     15|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  |  |  ------------------
  |  |  |  Branch (548:24): [True: 0, False: 15]
  |  |  ------------------
  ------------------
 2013|      0|	  return -1;
 2014|       |
 2015|    160|      if( iobuf_put(out, len ) )
  ------------------
  |  |  548|    160|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  |  |  ------------------
  |  |  |  Branch (548:24): [True: 0, False: 160]
  |  |  ------------------
  ------------------
 2016|      0|	return -1;
 2017|    160|    }
 2018|       |
 2019|    160|  return 0;
 2020|    160|}
build-packet.c:ctb_new_format_p:
   62|    247|{
   63|       |  /* Bit 7 must always be set.  */
   64|    247|  log_assert ((ctb & (1 << 7)));
   65|       |  /* Bit 6 indicates whether the packet is a new format packet.  */
   66|      0|  return (ctb & (1 << 6));
   67|    247|}
build-packet.c:write_32:
 1867|     63|{
 1868|     63|    iobuf_put(out, a>> 24);
  ------------------
  |  |  548|     63|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1869|     63|    iobuf_put(out, a>> 16);
  ------------------
  |  |  548|     63|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1870|     63|    iobuf_put(out, a>> 8);
  ------------------
  |  |  548|     63|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1871|     63|    return iobuf_put(out, a);
  ------------------
  |  |  548|     63|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1872|     63|}
build-packet.c:do_user_id:
  546|     11|{
  547|     11|  int rc;
  548|     11|  int hdrlen;
  549|       |
  550|     11|  log_assert (ctb_pkttype (ctb) == PKT_USER_ID
  551|     11|              || ctb_pkttype (ctb) == PKT_ATTRIBUTE);
  552|       |
  553|       |  /* We need to take special care of a user ID with a length of 0:
  554|       |   * Without forcing HDRLEN to 2 in this case an indeterminate length
  555|       |   * packet would be written which is not allowed.  Note that we are
  556|       |   * always called with a CTB indicating an old packet header format,
  557|       |   * so that forcing a 2 octet header works.  We also check for the
  558|       |   * maximum allowed packet size by the parser using an arbitrary
  559|       |   * extra 10 bytes for header data. */
  560|     11|  if (uid->attrib_data)
  ------------------
  |  Branch (560:7): [True: 0, False: 11]
  ------------------
  561|      0|    {
  562|      0|      if (uid->attrib_len > MAX_ATTR_PACKET_LENGTH - 10)
  ------------------
  |  |   40|      0|#define MAX_ATTR_PACKET_LENGTH    ( 16 * 1024*1024)
  ------------------
  |  Branch (562:11): [True: 0, False: 0]
  ------------------
  563|      0|        return gpg_error (GPG_ERR_TOO_LARGE);
  564|      0|      hdrlen = uid->attrib_len? 0 : 2;
  ------------------
  |  Branch (564:16): [True: 0, False: 0]
  ------------------
  565|      0|      write_header2 (out, ctb, uid->attrib_len, hdrlen);
  566|      0|      rc = iobuf_write( out, uid->attrib_data, uid->attrib_len );
  567|      0|    }
  568|     11|  else
  569|     11|    {
  570|     11|      if (uid->len > MAX_UID_PACKET_LENGTH - 10)
  ------------------
  |  |   38|     11|#define MAX_UID_PACKET_LENGTH     (  2 * 1024)
  ------------------
  |  Branch (570:11): [True: 0, False: 11]
  ------------------
  571|      0|        return gpg_error (GPG_ERR_TOO_LARGE);
  572|     11|      hdrlen = uid->len? 0 : 2;
  ------------------
  |  Branch (572:16): [True: 11, False: 0]
  ------------------
  573|     11|      write_header2 (out, ctb, uid->len, hdrlen);
  574|     11|      rc = iobuf_write( out, uid->name, uid->len );
  575|     11|    }
  576|     11|  return rc;
  577|     11|}
build-packet.c:ctb_pkttype:
   72|     87|{
   73|     87|  if (ctb_new_format_p (ctb))
  ------------------
  |  Branch (73:7): [True: 0, False: 87]
  ------------------
   74|       |    /* Bits 0 through 5 are the packet type.  */
   75|      0|    return (ctb & ((1 << 6) - 1));
   76|     87|  else
   77|       |    /* Bits 2 through 5 are the packet type.  */
   78|     87|    return (ctb & ((1 << 6) - 1)) >> 2;
   79|     87|}
build-packet.c:do_key:
  595|     14|{
  596|     14|  gpg_error_t err = 0;
  597|     14|  iobuf_t a;
  598|     14|  int i, nskey, npkey;
  599|     14|  u32 pkbytes = 0;
  600|     14|  int is_v5;
  601|       |
  602|     14|  log_assert (pk->version == 0 || pk->version == 4 || pk->version == 5);
  603|      0|  log_assert (ctb_pkttype (ctb) == PKT_PUBLIC_KEY
  604|     14|              || ctb_pkttype (ctb) == PKT_PUBLIC_SUBKEY
  605|     14|              || ctb_pkttype (ctb) == PKT_SECRET_KEY
  606|     14|              || ctb_pkttype (ctb) == PKT_SECRET_SUBKEY);
  607|       |
  608|       |  /* The length of the body is stored in the packet's header, which
  609|       |   * occurs before the body.  Unfortunately, we don't know the length
  610|       |   * of the packet's body until we've written all of the data!  To
  611|       |   * work around this, we first write the data into this temporary
  612|       |   * buffer, then generate the header, and finally copy the content
  613|       |   * of this buffer to OUT.  */
  614|      0|  a = iobuf_temp();
  615|       |
  616|       |  /* Note that the Version number, Timestamp, Algo, and the v5 Key
  617|       |   * material count are written at the end of the function. */
  618|       |
  619|     14|  is_v5 = (pk->version == 5);
  620|       |
  621|       |  /* Get number of secret and public parameters.  They are held in one
  622|       |     array: the public ones followed by the secret ones.  */
  623|     14|  nskey = pubkey_get_nskey (pk->pubkey_algo);
  624|     14|  npkey = pubkey_get_npkey (pk->pubkey_algo);
  625|       |
  626|       |  /* If we don't have any public parameters - which is for example the
  627|       |     case if we don't know the algorithm used - the parameters are
  628|       |     stored as one blob in a faked (opaque) MPI. */
  629|     14|  if (!npkey)
  ------------------
  |  Branch (629:7): [True: 0, False: 14]
  ------------------
  630|      0|    {
  631|      0|      write_fake_data (a, pk->pkey[0]);
  632|      0|      goto leave;
  633|      0|    }
  634|     14|  log_assert (npkey < nskey);
  635|       |
  636|     42|  for (i=0; i < npkey; i++ )
  ------------------
  |  Branch (636:13): [True: 28, False: 14]
  ------------------
  637|     28|    {
  638|     28|      if (   (pk->pubkey_algo == PUBKEY_ALGO_ECDSA && (i == 0))
  ------------------
  |  Branch (638:15): [True: 16, False: 12]
  |  Branch (638:55): [True: 8, False: 8]
  ------------------
  639|     28|          || (pk->pubkey_algo == PUBKEY_ALGO_EDDSA && (i == 0))
  ------------------
  |  Branch (639:15): [True: 0, False: 20]
  |  Branch (639:55): [True: 0, False: 0]
  ------------------
  640|     28|          || (pk->pubkey_algo == PUBKEY_ALGO_ECDH  && (i == 0 || i == 2)))
  ------------------
  |  Branch (640:15): [True: 0, False: 20]
  |  Branch (640:56): [True: 0, False: 0]
  |  Branch (640:66): [True: 0, False: 0]
  ------------------
  641|      8|        err = gpg_mpi_write_nohdr (a, pk->pkey[i]);
  642|     20|      else if (pk->pubkey_algo == PUBKEY_ALGO_ECDSA
  ------------------
  |  Branch (642:16): [True: 8, False: 12]
  ------------------
  643|     20|               || pk->pubkey_algo == PUBKEY_ALGO_EDDSA
  ------------------
  |  Branch (643:19): [True: 0, False: 12]
  ------------------
  644|     20|               || pk->pubkey_algo == PUBKEY_ALGO_ECDH)
  ------------------
  |  Branch (644:19): [True: 0, False: 12]
  ------------------
  645|      8|        err = sos_write (a, pk->pkey[i], NULL);
  646|     12|      else
  647|     12|        err = gpg_mpi_write (a, pk->pkey[i], NULL);
  648|     28|      if (err)
  ------------------
  |  Branch (648:11): [True: 0, False: 28]
  ------------------
  649|      0|        goto leave;
  650|     28|    }
  651|       |
  652|       |  /* Record the length of the public key part.  */
  653|     14|  pkbytes = iobuf_get_temp_length (a);
  ------------------
  |  |  638|     14|#define iobuf_get_temp_length(a) ( (a)->d.len )
  ------------------
  654|       |
  655|     14|  if (pk->seckey_info)
  ------------------
  |  Branch (655:7): [True: 0, False: 14]
  ------------------
  656|      0|    {
  657|       |      /* This is a secret key packet.  */
  658|      0|      struct seckey_info *ski = pk->seckey_info;
  659|       |
  660|       |      /* Build the header for protected (encrypted) secret parameters.  */
  661|      0|      if (ski->is_protected)
  ------------------
  |  Branch (661:11): [True: 0, False: 0]
  ------------------
  662|      0|        {
  663|      0|          iobuf_put (a, ski->sha1chk? 0xfe : 0xff); /* S2k usage.  */
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  |  |  ------------------
  |  |  |  Branch (548:42): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  664|      0|          if (is_v5)
  ------------------
  |  Branch (664:15): [True: 0, False: 0]
  ------------------
  665|      0|            {
  666|       |              /* For a v5 key determine the count of the following
  667|       |               * key-protection material and write it.  */
  668|      0|              int count = 1;  /* Pubkey algo octet. */
  669|      0|              if (ski->s2k.mode >= 1000)
  ------------------
  |  Branch (669:19): [True: 0, False: 0]
  ------------------
  670|      0|                count += 6;   /* GNU specific mode descriptor.  */
  671|      0|              else
  672|      0|                count += 2;   /* Mode and hash algo.  */
  673|      0|              if (ski->s2k.mode == 1 || ski->s2k.mode == 3)
  ------------------
  |  Branch (673:19): [True: 0, False: 0]
  |  Branch (673:41): [True: 0, False: 0]
  ------------------
  674|      0|                count += 8;   /* Salt.  */
  675|      0|              if (ski->s2k.mode == 3)
  ------------------
  |  Branch (675:19): [True: 0, False: 0]
  ------------------
  676|      0|                count++;      /* S2K.COUNT */
  677|      0|              if (ski->s2k.mode != 1001 && ski->s2k.mode != 1002
  ------------------
  |  Branch (677:19): [True: 0, False: 0]
  |  Branch (677:44): [True: 0, False: 0]
  ------------------
  678|      0|                   && ski->s2k.mode != 1003)
  ------------------
  |  Branch (678:23): [True: 0, False: 0]
  ------------------
  679|      0|                count += ski->ivlen;
  680|       |
  681|      0|              iobuf_put (a, count);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  682|      0|            }
  683|      0|          iobuf_put (a, ski->algo);  /* Pubkey algo octet.  */
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  684|      0|          if (ski->s2k.mode >= 1000)
  ------------------
  |  Branch (684:15): [True: 0, False: 0]
  ------------------
  685|      0|            {
  686|       |              /* These modes are not possible in OpenPGP, we use them
  687|       |                 to implement our extensions, 101 can be viewed as a
  688|       |                 private/experimental extension (this is not specified
  689|       |                 in rfc2440 but the same scheme is used for all other
  690|       |                 algorithm identifiers). */
  691|      0|              iobuf_put (a, 101);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  692|      0|              iobuf_put (a, ski->s2k.hash_algo);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  693|      0|              iobuf_write (a, "GNU", 3 );
  694|      0|              iobuf_put (a, ski->s2k.mode - 1000);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  695|      0|            }
  696|      0|          else
  697|      0|            {
  698|      0|              iobuf_put (a, ski->s2k.mode);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  699|      0|              iobuf_put (a, ski->s2k.hash_algo);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  700|      0|            }
  701|       |
  702|      0|          if (ski->s2k.mode == 1 || ski->s2k.mode == 3)
  ------------------
  |  Branch (702:15): [True: 0, False: 0]
  |  Branch (702:37): [True: 0, False: 0]
  ------------------
  703|      0|            iobuf_write (a, ski->s2k.salt, 8);
  704|       |
  705|      0|          if (ski->s2k.mode == 3)
  ------------------
  |  Branch (705:15): [True: 0, False: 0]
  ------------------
  706|      0|            iobuf_put (a, ski->s2k.count);
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  707|       |
  708|       |          /* For our special modes 1001..1003 we do not need an IV. */
  709|      0|          if (ski->s2k.mode != 1001 && ski->s2k.mode != 1002
  ------------------
  |  Branch (709:15): [True: 0, False: 0]
  |  Branch (709:40): [True: 0, False: 0]
  ------------------
  710|      0|               && ski->s2k.mode != 1003)
  ------------------
  |  Branch (710:19): [True: 0, False: 0]
  ------------------
  711|      0|            iobuf_write (a, ski->iv, ski->ivlen);
  712|       |
  713|      0|        }
  714|      0|      else /* Not protected. */
  715|      0|        {
  716|      0|          iobuf_put (a, 0 );  /* S2K usage = not protected.  */
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  717|      0|          if (is_v5)
  ------------------
  |  Branch (717:15): [True: 0, False: 0]
  ------------------
  718|      0|            iobuf_put (a, 0); /* Zero octets of key-protection
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  719|       |                               * material follows.  */
  720|      0|        }
  721|       |
  722|      0|      if (ski->s2k.mode == 1001)
  ------------------
  |  Branch (722:11): [True: 0, False: 0]
  ------------------
  723|      0|        {
  724|       |          /* GnuPG extension - don't write a secret key at all. */
  725|      0|          if (is_v5)
  ------------------
  |  Branch (725:15): [True: 0, False: 0]
  ------------------
  726|      0|            write_32 (a, 0); /* Zero octets of key material.  */
  727|      0|        }
  728|      0|      else if (ski->s2k.mode == 1002)
  ------------------
  |  Branch (728:16): [True: 0, False: 0]
  ------------------
  729|      0|        {
  730|       |          /* GnuPG extension - divert to OpenPGP smartcard. */
  731|      0|          if (is_v5)
  ------------------
  |  Branch (731:15): [True: 0, False: 0]
  ------------------
  732|      0|            write_32 (a, 1 + ski->ivlen);
  733|       |          /* Length of the serial number or 0 for no serial number. */
  734|      0|          iobuf_put (a, ski->ivlen );
  ------------------
  |  |  548|      0|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  735|       |          /* The serial number gets stored in the IV field.  */
  736|      0|          iobuf_write (a, ski->iv, ski->ivlen);
  737|      0|        }
  738|      0|      else if (ski->s2k.mode == 1003)
  ------------------
  |  Branch (738:16): [True: 0, False: 0]
  ------------------
  739|      0|        {
  740|       |          /* GnuPG extension - Store raw s-expression. */
  741|      0|          byte *p;
  742|      0|          unsigned int ndatabits;
  743|       |
  744|      0|          log_assert (gcry_mpi_get_flag (pk->pkey[npkey], GCRYMPI_FLAG_OPAQUE));
  745|       |
  746|      0|          p = gcry_mpi_get_opaque (pk->pkey[npkey], &ndatabits);
  747|       |          /* For v5 keys we first write the number of octets of the
  748|       |           * following key material.  */
  749|      0|          if (is_v5)
  ------------------
  |  Branch (749:15): [True: 0, False: 0]
  ------------------
  750|      0|            write_32 (a, p? (ndatabits+7)/8 : 0);
  ------------------
  |  Branch (750:26): [True: 0, False: 0]
  ------------------
  751|      0|          if (p)
  ------------------
  |  Branch (751:15): [True: 0, False: 0]
  ------------------
  752|      0|            iobuf_write (a, p, (ndatabits+7)/8 );
  753|      0|        }
  754|      0|      else if (ski->is_protected)
  ------------------
  |  Branch (754:16): [True: 0, False: 0]
  ------------------
  755|      0|        {
  756|       |          /* The secret key is protected - write it out as it is.  */
  757|      0|          byte *p;
  758|      0|          unsigned int ndatabits;
  759|       |
  760|      0|          log_assert (gcry_mpi_get_flag (pk->pkey[npkey], GCRYMPI_FLAG_OPAQUE));
  761|      0|          p = gcry_mpi_get_opaque (pk->pkey[npkey], &ndatabits);
  762|       |          /* For v5 keys we first write the number of octets of the
  763|       |           * following encrypted key material.  */
  764|      0|          if (is_v5)
  ------------------
  |  Branch (764:15): [True: 0, False: 0]
  ------------------
  765|      0|            write_32 (a, p? (ndatabits+7)/8 : 0);
  ------------------
  |  Branch (765:26): [True: 0, False: 0]
  ------------------
  766|      0|          if (p)
  ------------------
  |  Branch (766:15): [True: 0, False: 0]
  ------------------
  767|      0|            iobuf_write (a, p, (ndatabits+7)/8 );
  768|      0|        }
  769|      0|      else
  770|      0|        {
  771|       |          /* Non-protected key. */
  772|      0|          if (is_v5)
  ------------------
  |  Branch (772:15): [True: 0, False: 0]
  ------------------
  773|      0|            {
  774|      0|              unsigned int skbytes = 0;
  775|      0|              unsigned int n;
  776|      0|              int j;
  777|       |
  778|      0|              for (j=i; j < nskey; j++ )
  ------------------
  |  Branch (778:25): [True: 0, False: 0]
  ------------------
  779|      0|                {
  780|      0|                  if (pk->pubkey_algo == PUBKEY_ALGO_ECDSA
  ------------------
  |  Branch (780:23): [True: 0, False: 0]
  ------------------
  781|      0|                      || pk->pubkey_algo == PUBKEY_ALGO_EDDSA
  ------------------
  |  Branch (781:26): [True: 0, False: 0]
  ------------------
  782|      0|                      || pk->pubkey_algo == PUBKEY_ALGO_ECDH)
  ------------------
  |  Branch (782:26): [True: 0, False: 0]
  ------------------
  783|      0|                    {
  784|      0|                      if ((err = sos_write (NULL, pk->pkey[j], &n)))
  ------------------
  |  Branch (784:27): [True: 0, False: 0]
  ------------------
  785|      0|                        goto leave;
  786|      0|                    }
  787|      0|                  else
  788|      0|                    {
  789|      0|                      if ( (err = gpg_mpi_write (a, pk->pkey[i], NULL)))
  ------------------
  |  Branch (789:28): [True: 0, False: 0]
  ------------------
  790|      0|                        goto leave;
  791|      0|                    }
  792|      0|                  skbytes += n;
  793|      0|                }
  794|       |
  795|      0|              write_32 (a, skbytes);
  796|      0|            }
  797|       |
  798|      0|          for ( ; i < nskey; i++ )
  ------------------
  |  Branch (798:19): [True: 0, False: 0]
  ------------------
  799|      0|            if (pk->pubkey_algo == PUBKEY_ALGO_ECDSA
  ------------------
  |  Branch (799:17): [True: 0, False: 0]
  ------------------
  800|      0|                || pk->pubkey_algo == PUBKEY_ALGO_EDDSA
  ------------------
  |  Branch (800:20): [True: 0, False: 0]
  ------------------
  801|      0|                || pk->pubkey_algo == PUBKEY_ALGO_ECDH)
  ------------------
  |  Branch (801:20): [True: 0, False: 0]
  ------------------
  802|      0|              {
  803|      0|                if ((err = sos_write (a, pk->pkey[i], NULL)))
  ------------------
  |  Branch (803:21): [True: 0, False: 0]
  ------------------
  804|      0|                  goto leave;
  805|      0|              }
  806|      0|            else
  807|      0|              if ((err = gpg_mpi_write (a, pk->pkey[i], NULL)))
  ------------------
  |  Branch (807:19): [True: 0, False: 0]
  ------------------
  808|      0|                goto leave;
  809|       |
  810|      0|          write_16 (a, ski->csum );
  811|      0|        }
  812|      0|    }
  813|       |
  814|     14| leave:
  815|     14|  if (!err)
  ------------------
  |  Branch (815:7): [True: 14, False: 0]
  ------------------
  816|     14|    {
  817|       |      /* Build the header of the packet - which we must do after
  818|       |       * writing all the other stuff, so that we know the length of
  819|       |       * the packet */
  820|     14|      u32 len = iobuf_get_temp_length (a);
  ------------------
  |  |  638|     14|#define iobuf_get_temp_length(a) ( (a)->d.len )
  ------------------
  821|     14|      len += 1; /* version number  */
  822|     14|      len += 4; /* timestamp  */
  823|     14|      len += 1; /* algo  */
  824|     14|      if (is_v5)
  ------------------
  |  Branch (824:11): [True: 0, False: 14]
  ------------------
  825|      0|        len += 4; /* public key material count  */
  826|       |
  827|     14|      write_header2 (out, ctb, len, 0);
  828|       |       /* And finally write it out to the real stream. */
  829|     14|      iobuf_put (out, pk->version? pk->version : 4); /* version number  */
  ------------------
  |  |  548|     28|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  |  |  ------------------
  |  |  |  Branch (548:42): [True: 14, False: 0]
  |  |  ------------------
  ------------------
  830|     14|      write_32 (out, pk->timestamp );
  831|     14|      iobuf_put (out, pk->pubkey_algo);  /* algo */
  ------------------
  |  |  548|     14|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  832|     14|      if (is_v5)
  ------------------
  |  Branch (832:11): [True: 0, False: 14]
  ------------------
  833|      0|        write_32 (out, pkbytes);        /* public key material count  */
  834|     14|      err = iobuf_write_temp (out, a);  /* pub and sec key material */
  835|     14|    }
  836|       |
  837|     14|  iobuf_close (a); /* Close the temporary buffer */
  838|     14|  return err;
  839|     14|}
build-packet.c:write_fake_data:
  491|      4|{
  492|      4|  unsigned int n;
  493|      4|  void *p;
  494|       |
  495|      4|  if (!a)
  ------------------
  |  Branch (495:7): [True: 3, False: 1]
  ------------------
  496|      3|    return 0;
  497|      1|  if (!gcry_mpi_get_flag (a, GCRYMPI_FLAG_OPAQUE))
  ------------------
  |  Branch (497:7): [True: 0, False: 1]
  ------------------
  498|      0|    return 0; /* e.g. due to generating a key with wrong usage.  */
  499|      1|  p = gcry_mpi_get_opaque ( a, &n);
  500|      1|  if (!p)
  ------------------
  |  Branch (500:7): [True: 1, False: 0]
  ------------------
  501|      1|    return 0; /* For example due to a read error in
  502|       |                 parse-packet.c:read_rest.  */
  503|      0|  return iobuf_write (out, p, (n+7)/8 );
  504|      1|}
build-packet.c:sos_write:
  374|     80|{
  375|     80|  gpg_error_t err;
  376|     80|  unsigned int nwritten = 0;
  377|       |
  378|     80|  if (gcry_mpi_get_flag (a, GCRYMPI_FLAG_OPAQUE))
  ------------------
  |  Branch (378:7): [True: 80, False: 0]
  ------------------
  379|     80|    {
  380|     80|      unsigned int nbits;
  381|     80|      const unsigned char *p;
  382|     80|      unsigned char lenhdr[2];
  383|       |
  384|       |      /* gcry_log_debugmpi ("a", a); */
  385|     80|      p = gcry_mpi_get_opaque (a, &nbits);
  386|       |      /* gcry_log_debug ("   [%u bit]\n", nbits); */
  387|       |      /* gcry_log_debughex (" ", p, (nbits+7)/8); */
  388|       |
  389|     80|      if (p && *p)
  ------------------
  |  Branch (389:11): [True: 80, False: 0]
  |  Branch (389:16): [True: 80, False: 0]
  ------------------
  390|     80|        {
  391|     80|          nbits = ((nbits + 7) / 8) * 8;
  392|       |
  393|     80|          if (nbits >= 8 && !(*p & 0x80))
  ------------------
  |  Branch (393:15): [True: 80, False: 0]
  |  Branch (393:29): [True: 80, False: 0]
  ------------------
  394|     80|            if (--nbits >= 7 && !(*p & 0x40))
  ------------------
  |  Branch (394:17): [True: 80, False: 0]
  |  Branch (394:33): [True: 80, False: 0]
  ------------------
  395|     80|              if (--nbits >= 6 && !(*p & 0x20))
  ------------------
  |  Branch (395:19): [True: 80, False: 0]
  |  Branch (395:35): [True: 80, False: 0]
  ------------------
  396|     80|                if (--nbits >= 5 && !(*p & 0x10))
  ------------------
  |  Branch (396:21): [True: 80, False: 0]
  |  Branch (396:37): [True: 44, False: 36]
  ------------------
  397|     44|                  if (--nbits >= 4 && !(*p & 0x08))
  ------------------
  |  Branch (397:23): [True: 44, False: 0]
  |  Branch (397:39): [True: 8, False: 36]
  ------------------
  398|      8|                    if (--nbits >= 3 && !(*p & 0x04))
  ------------------
  |  Branch (398:25): [True: 8, False: 0]
  |  Branch (398:41): [True: 0, False: 8]
  ------------------
  399|      0|                      if (--nbits >= 2 && !(*p & 0x02))
  ------------------
  |  Branch (399:27): [True: 0, False: 0]
  |  Branch (399:43): [True: 0, False: 0]
  ------------------
  400|      0|                        if (--nbits >= 1 && !(*p & 0x01))
  ------------------
  |  Branch (400:29): [True: 0, False: 0]
  |  Branch (400:45): [True: 0, False: 0]
  ------------------
  401|      0|                          --nbits;
  402|     80|        }
  403|       |
  404|     80|      lenhdr[0] = nbits >> 8;
  405|     80|      lenhdr[1] = nbits;
  406|     80|      err = out? iobuf_write (out, lenhdr, 2) : 0;
  ------------------
  |  Branch (406:13): [True: 80, False: 0]
  ------------------
  407|     80|      if (!err)
  ------------------
  |  Branch (407:11): [True: 80, False: 0]
  ------------------
  408|     80|        {
  409|     80|          nwritten += 2;
  410|     80|          if (p)
  ------------------
  |  Branch (410:15): [True: 80, False: 0]
  ------------------
  411|     80|            {
  412|     80|              err = out? iobuf_write (out, p, (nbits+7)/8) : 0;
  ------------------
  |  Branch (412:21): [True: 80, False: 0]
  ------------------
  413|     80|              if (!err)
  ------------------
  |  Branch (413:19): [True: 80, False: 0]
  ------------------
  414|     80|                nwritten += (nbits+7)/8;
  415|     80|            }
  416|     80|        }
  417|     80|    }
  418|      0|  else
  419|      0|    {
  420|      0|      log_info ("non-opaque MPI (%u bits) for SOS\n", gcry_mpi_get_nbits (a));
  421|      0|      err = gpg_error (GPG_ERR_INV_DATA);
  422|      0|    }
  423|       |
  424|     80|  if (r_nwritten)
  ------------------
  |  Branch (424:7): [True: 0, False: 80]
  ------------------
  425|      0|    *r_nwritten = nwritten;
  426|     80|  return err;
  427|     80|}
build-packet.c:write_16:
 1857|    100|{
 1858|    100|    iobuf_put(out, a>>8);
  ------------------
  |  |  548|    100|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1859|    100|    if( iobuf_put(out,a) )
  ------------------
  |  |  548|    100|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  |  |  ------------------
  |  |  |  Branch (548:24): [True: 0, False: 100]
  |  |  ------------------
  ------------------
 1860|      0|	return -1;
 1861|    100|    return 0;
 1862|    100|}
build-packet.c:do_signature:
 1760|     59|{
 1761|     59|  int rc = 0;
 1762|     59|  int n, i;
 1763|     59|  IOBUF a = iobuf_temp();
 1764|       |
 1765|     59|  log_assert (ctb_pkttype (ctb) == PKT_SIGNATURE);
 1766|       |
 1767|     59|  if ( !sig->version || sig->version == 3)
  ------------------
  |  Branch (1767:8): [True: 3, False: 56]
  |  Branch (1767:25): [True: 6, False: 50]
  ------------------
 1768|      9|    {
 1769|      9|      iobuf_put( a, 3 );
  ------------------
  |  |  548|      9|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1770|       |
 1771|       |      /* Version 3 packets don't support subpackets.  Actually we
 1772|       |       * should never get to here but real life is different and thus
 1773|       |       * we now use a log_fatal instead of a log_assert here. */
 1774|      9|      if (sig->hashed || sig->unhashed)
  ------------------
  |  Branch (1774:11): [True: 0, False: 9]
  |  Branch (1774:26): [True: 0, False: 9]
  ------------------
 1775|      0|        log_fatal ("trying to write a subpacket to a v3 signature (%d,%d)\n",
 1776|      0|                   !!sig->hashed, !!sig->unhashed);
 1777|      9|    }
 1778|     50|  else
 1779|     50|    iobuf_put( a, sig->version );
  ------------------
  |  |  548|     50|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1780|     59|  if ( sig->version < 4 )
  ------------------
  |  Branch (1780:8): [True: 9, False: 50]
  ------------------
 1781|      9|    iobuf_put (a, 5 ); /* Constant used by pre-v4 signatures. */
  ------------------
  |  |  548|      9|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1782|     59|  iobuf_put (a, sig->sig_class );
  ------------------
  |  |  548|     59|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1783|     59|  if ( sig->version < 4 )
  ------------------
  |  Branch (1783:8): [True: 9, False: 50]
  ------------------
 1784|      9|    {
 1785|      9|      write_32(a, sig->timestamp );
 1786|      9|      write_32(a, sig->keyid[0] );
 1787|      9|      write_32(a, sig->keyid[1] );
 1788|      9|    }
 1789|     59|  iobuf_put(a, sig->pubkey_algo );
  ------------------
  |  |  548|     59|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1790|     59|  iobuf_put(a, sig->digest_algo );
  ------------------
  |  |  548|     59|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1791|     59|  if ( sig->version >= 4 )
  ------------------
  |  Branch (1791:8): [True: 50, False: 9]
  ------------------
 1792|     50|    {
 1793|     50|      size_t nn;
 1794|       |      /* Timestamp and keyid must have been packed into the subpackets
 1795|       |	 prior to the call of this function, because these subpackets
 1796|       |	 are hashed. */
 1797|     50|      nn = sig->hashed? sig->hashed->len : 0;
  ------------------
  |  Branch (1797:12): [True: 50, False: 0]
  ------------------
 1798|     50|      write_16(a, nn);
 1799|     50|      if (nn)
  ------------------
  |  Branch (1799:11): [True: 50, False: 0]
  ------------------
 1800|     50|        iobuf_write( a, sig->hashed->data, nn );
 1801|     50|      nn = sig->unhashed? sig->unhashed->len : 0;
  ------------------
  |  Branch (1801:12): [True: 9, False: 41]
  ------------------
 1802|     50|      write_16(a, nn);
 1803|     50|      if (nn)
  ------------------
  |  Branch (1803:11): [True: 9, False: 41]
  ------------------
 1804|      9|        iobuf_write( a, sig->unhashed->data, nn );
 1805|     50|    }
 1806|     59|  iobuf_put(a, sig->digest_start[0] );
  ------------------
  |  |  548|     59|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1807|     59|  iobuf_put(a, sig->digest_start[1] );
  ------------------
  |  |  548|     59|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1808|     59|  n = pubkey_get_nsig( sig->pubkey_algo );
 1809|     59|  if ( !n )
  ------------------
  |  Branch (1809:8): [True: 4, False: 55]
  ------------------
 1810|      4|    write_fake_data( a, sig->data[0] );
 1811|     59|  if (sig->pubkey_algo == PUBKEY_ALGO_ECDSA
  ------------------
  |  Branch (1811:7): [True: 36, False: 23]
  ------------------
 1812|     59|      || sig->pubkey_algo == PUBKEY_ALGO_EDDSA)
  ------------------
  |  Branch (1812:10): [True: 0, False: 23]
  ------------------
 1813|    108|    for (i=0; i < n && !rc ; i++ )
  ------------------
  |  Branch (1813:15): [True: 72, False: 36]
  |  Branch (1813:24): [True: 72, False: 0]
  ------------------
 1814|     72|      rc = sos_write (a, sig->data[i], NULL);
 1815|     23|  else
 1816|     42|    for (i=0; i < n && !rc ; i++ )
  ------------------
  |  Branch (1816:15): [True: 19, False: 23]
  |  Branch (1816:24): [True: 19, False: 0]
  ------------------
 1817|     19|      rc = gpg_mpi_write (a, sig->data[i], NULL);
 1818|       |
 1819|     59|  if (!rc)
  ------------------
  |  Branch (1819:7): [True: 59, False: 0]
  ------------------
 1820|     59|    {
 1821|     59|      if ( is_RSA(sig->pubkey_algo) && sig->version < 4 )
  ------------------
  |  |   64|    118|#define is_RSA(a)     ((a)==PUBKEY_ALGO_RSA || (a)==PUBKEY_ALGO_RSA_E \
  |  |  ------------------
  |  |  |  Branch (64:24): [True: 14, False: 45]
  |  |  |  Branch (64:48): [True: 5, False: 40]
  |  |  ------------------
  |  |   65|    118|		       || (a)==PUBKEY_ALGO_RSA_S )
  |  |  ------------------
  |  |  |  Branch (65:13): [True: 0, False: 40]
  |  |  ------------------
  ------------------
  |  Branch (1821:40): [True: 5, False: 14]
  ------------------
 1822|      5|        write_sign_packet_header(out, ctb, iobuf_get_temp_length(a) );
  ------------------
  |  |  638|      5|#define iobuf_get_temp_length(a) ( (a)->d.len )
  ------------------
 1823|     54|      else
 1824|     54|        write_header(out, ctb, iobuf_get_temp_length(a) );
  ------------------
  |  |  638|     54|#define iobuf_get_temp_length(a) ( (a)->d.len )
  ------------------
 1825|     59|      rc = iobuf_write_temp( out, a );
 1826|     59|    }
 1827|       |
 1828|     59|  iobuf_close(a);
 1829|     59|  return rc;
 1830|     59|}
build-packet.c:write_sign_packet_header:
 1916|      5|{
 1917|      5|  (void)ctb;
 1918|       |
 1919|       |  /* Work around a bug in the pgp read function for signature packets,
 1920|       |     which are not correctly coded and silently assume at some point 2
 1921|       |     byte length headers.*/
 1922|      5|  iobuf_put (out, 0x89 );
  ------------------
  |  |  548|      5|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1923|      5|  iobuf_put (out, len >> 8 );
  ------------------
  |  |  548|      5|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
 1924|      5|  return iobuf_put (out, len) == -1 ? -1:0;
  ------------------
  |  |  548|      5|#define iobuf_put(a,c)	iobuf_writebyte(a,c)
  ------------------
  |  Branch (1924:10): [True: 0, False: 5]
  ------------------
 1925|      5|}

agent_probe_secret_key:
 2199|     11|{
 2200|     11|  gpg_error_t err;
 2201|     11|  char line[ASSUAN_LINELENGTH];
 2202|     11|  char *hexgrip;
 2203|       |
 2204|     11|  struct keyinfo_data_parm_s keyinfo;
 2205|       |
 2206|     11|  memset (&keyinfo, 0, sizeof keyinfo);
 2207|       |
 2208|     11|  err = start_agent (ctrl, 0);
 2209|     11|  if (err)
  ------------------
  |  Branch (2209:7): [True: 11, False: 0]
  ------------------
 2210|     11|    return err;
 2211|       |
 2212|      0|  err = hexkeygrip_from_pk (pk, &hexgrip);
 2213|      0|  if (err)
  ------------------
  |  Branch (2213:7): [True: 0, False: 0]
  ------------------
 2214|      0|    return err;
 2215|       |
 2216|      0|  snprintf (line, sizeof line, "KEYINFO %s", hexgrip);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
 2217|      0|  xfree (hexgrip);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2218|       |
 2219|      0|  err = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL,
 2220|      0|                         keyinfo_status_cb, &keyinfo);
 2221|      0|  xfree (keyinfo.serialno);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2222|      0|  if (err)
  ------------------
  |  Branch (2222:7): [True: 0, False: 0]
  ------------------
 2223|      0|    return 0;
 2224|       |
 2225|      0|  if (keyinfo.card_available)
  ------------------
  |  Branch (2225:7): [True: 0, False: 0]
  ------------------
 2226|      0|    return 4;
 2227|       |
 2228|      0|  if (keyinfo.passphrase_cached)
  ------------------
  |  Branch (2228:7): [True: 0, False: 0]
  ------------------
 2229|      0|    return 3;
 2230|       |
 2231|      0|  if (keyinfo.is_smartcard)
  ------------------
  |  Branch (2231:7): [True: 0, False: 0]
  ------------------
 2232|      0|    return 2;
 2233|       |
 2234|      0|  return 1;
 2235|      0|}
call-agent.c:start_agent:
  235|     11|{
  236|     11|  int rc;
  237|       |
  238|     11|  (void)ctrl;  /* Not yet used.  */
  239|       |
  240|       |  /* Fixme: We need a context for each thread or serialize the access
  241|       |     to the agent. */
  242|     11|  if (agent_ctx)
  ------------------
  |  Branch (242:7): [True: 0, False: 11]
  ------------------
  243|      0|    rc = 0;
  244|     11|  else
  245|     11|    {
  246|     11|      rc = start_new_gpg_agent (&agent_ctx,
  247|     11|                                GPG_ERR_SOURCE_DEFAULT,
  ------------------
  |  |   34|     11|#define GPG_ERR_SOURCE_DEFAULT  GPG_ERR_SOURCE_GPG
  ------------------
  248|     11|                                opt.agent_program,
  249|     11|                                opt.lc_ctype, opt.lc_messages,
  250|     11|                                opt.session_env,
  251|     11|                                opt.autostart, opt.verbose, DBG_IPC,
  ------------------
  |  |  355|     11|#define DBG_IPC     (opt.debug & DBG_IPC_VALUE)
  |  |  ------------------
  |  |  |  |  342|     11|#define DBG_IPC_VALUE     1024  /* debug assuan communication */
  |  |  ------------------
  ------------------
  252|     11|                                NULL, NULL);
  253|     11|      if (!opt.autostart && gpg_err_code (rc) == GPG_ERR_NO_AGENT)
  ------------------
  |  Branch (253:11): [True: 11, False: 0]
  |  Branch (253:29): [True: 11, False: 0]
  ------------------
  254|     11|        {
  255|     11|          static int shown;
  256|       |
  257|     11|          if (!shown)
  ------------------
  |  Branch (257:15): [True: 1, False: 10]
  ------------------
  258|      1|            {
  259|      1|              shown = 1;
  260|      1|              log_info (_("no gpg-agent running in this session\n"));
  ------------------
  |  |   28|      1|#  define _(a) gettext (a)
  ------------------
  261|      1|            }
  262|     11|        }
  263|      0|      else if (!rc
  ------------------
  |  Branch (263:16): [True: 0, False: 0]
  ------------------
  264|      0|               && !(rc = warn_version_mismatch (agent_ctx, GPG_AGENT_NAME, 0)))
  ------------------
  |  |  143|      0|#define GPG_AGENT_NAME "gpg-agent"
  ------------------
  |  Branch (264:19): [True: 0, False: 0]
  ------------------
  265|      0|        {
  266|       |          /* Tell the agent that we support Pinentry notifications.
  267|       |             No error checking so that it will work also with older
  268|       |             agents.  */
  269|      0|          assuan_transact (agent_ctx, "OPTION allow-pinentry-notify",
  270|      0|                           NULL, NULL, NULL, NULL, NULL, NULL);
  271|       |          /* Tell the agent about what version we are aware.  This is
  272|       |             here used to indirectly enable GPG_ERR_FULLY_CANCELED.  */
  273|      0|          assuan_transact (agent_ctx, "OPTION agent-awareness=2.1.0",
  274|      0|                           NULL, NULL, NULL, NULL, NULL, NULL);
  275|       |          /* Pass on the pinentry mode.  */
  276|      0|          if (opt.pinentry_mode)
  ------------------
  |  Branch (276:15): [True: 0, False: 0]
  ------------------
  277|      0|            {
  278|      0|              char *tmp = xasprintf ("OPTION pinentry-mode=%s",
  279|      0|                                     str_pinentry_mode (opt.pinentry_mode));
  280|      0|              rc = assuan_transact (agent_ctx, tmp,
  281|      0|                               NULL, NULL, NULL, NULL, NULL, NULL);
  282|      0|              xfree (tmp);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  283|      0|              if (rc)
  ------------------
  |  Branch (283:19): [True: 0, False: 0]
  ------------------
  284|      0|                {
  285|      0|                  log_error ("setting pinentry mode '%s' failed: %s\n",
  286|      0|                             str_pinentry_mode (opt.pinentry_mode),
  287|      0|                             gpg_strerror (rc));
  288|      0|                  write_status_error ("set_pinentry_mode", rc);
  289|      0|                }
  290|      0|            }
  291|       |
  292|       |          /* Pass on the request origin.  */
  293|      0|          if (opt.request_origin)
  ------------------
  |  Branch (293:15): [True: 0, False: 0]
  ------------------
  294|      0|            {
  295|      0|              char *tmp = xasprintf ("OPTION pretend-request-origin=%s",
  296|      0|                                     str_request_origin (opt.request_origin));
  297|      0|              rc = assuan_transact (agent_ctx, tmp,
  298|      0|                               NULL, NULL, NULL, NULL, NULL, NULL);
  299|      0|              xfree (tmp);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  300|      0|              if (rc)
  ------------------
  |  Branch (300:19): [True: 0, False: 0]
  ------------------
  301|      0|                {
  302|      0|                  log_error ("setting request origin '%s' failed: %s\n",
  303|      0|                             str_request_origin (opt.request_origin),
  304|      0|                             gpg_strerror (rc));
  305|      0|                  write_status_error ("set_request_origin", rc);
  306|      0|                }
  307|      0|            }
  308|       |
  309|       |          /* In DE_VS mode under Windows we require that the JENT RNG
  310|       |           * is active.  */
  311|       |#ifdef HAVE_W32_SYSTEM
  312|       |          if (!rc && opt.compliance == CO_DE_VS)
  313|       |            {
  314|       |              if (assuan_transact (agent_ctx, "GETINFO jent_active",
  315|       |                                   NULL, NULL, NULL, NULL, NULL, NULL))
  316|       |                {
  317|       |                  rc = gpg_error (GPG_ERR_FORBIDDEN);
  318|       |                  log_error (_("%s is not compliant with %s mode\n"),
  319|       |                             GPG_AGENT_NAME,
  320|       |                             gnupg_compliance_option_string (opt.compliance));
  321|       |                  write_status_error ("random-compliance", rc);
  322|       |                }
  323|       |            }
  324|       |#endif /*HAVE_W32_SYSTEM*/
  325|       |
  326|      0|        }
  327|     11|    }
  328|       |
  329|     11|  if (!rc && flag_for_card && !did_early_card_test)
  ------------------
  |  Branch (329:7): [True: 0, False: 11]
  |  Branch (329:14): [True: 0, False: 0]
  |  Branch (329:31): [True: 0, False: 0]
  ------------------
  330|      0|    {
  331|       |      /* Request the serial number of the card for an early test.  */
  332|      0|      struct agent_card_info_s info;
  333|       |
  334|      0|      memset (&info, 0, sizeof info);
  335|       |
  336|      0|      if (!(flag_for_card & FLAG_FOR_CARD_SUPPRESS_ERRORS))
  ------------------
  |  |  229|      0|#define FLAG_FOR_CARD_SUPPRESS_ERRORS 2
  ------------------
  |  Branch (336:11): [True: 0, False: 0]
  ------------------
  337|      0|        rc = warn_version_mismatch (agent_ctx, SCDAEMON_NAME, 2);
  ------------------
  |  |  719|      0|#define SCDAEMON_NAME "scdaemon"
  ------------------
  338|      0|      if (!rc)
  ------------------
  |  Branch (338:11): [True: 0, False: 0]
  ------------------
  339|      0|        rc = assuan_transact (agent_ctx,
  340|      0|                              opt.flags.use_only_openpgp_card?
  ------------------
  |  Branch (340:31): [True: 0, False: 0]
  ------------------
  341|      0|                              "SCD SERIALNO openpgp" : "SCD SERIALNO",
  342|      0|                              NULL, NULL, NULL, NULL,
  343|      0|                              learn_status_cb, &info);
  344|      0|      if (rc && !(flag_for_card & FLAG_FOR_CARD_SUPPRESS_ERRORS))
  ------------------
  |  |  229|      0|#define FLAG_FOR_CARD_SUPPRESS_ERRORS 2
  ------------------
  |  Branch (344:11): [True: 0, False: 0]
  |  Branch (344:17): [True: 0, False: 0]
  ------------------
  345|      0|        {
  346|      0|          switch (gpg_err_code (rc))
  347|      0|            {
  348|      0|            case GPG_ERR_NOT_SUPPORTED:
  ------------------
  |  Branch (348:13): [True: 0, False: 0]
  ------------------
  349|      0|            case GPG_ERR_NO_SCDAEMON:
  ------------------
  |  Branch (349:13): [True: 0, False: 0]
  ------------------
  350|      0|              write_status_text (STATUS_CARDCTRL, "6");
  351|      0|              break;
  352|      0|            case GPG_ERR_OBJ_TERM_STATE:
  ------------------
  |  Branch (352:13): [True: 0, False: 0]
  ------------------
  353|      0|              write_status_text (STATUS_CARDCTRL, "7");
  354|      0|              break;
  355|      0|            default:
  ------------------
  |  Branch (355:13): [True: 0, False: 0]
  ------------------
  356|      0|              write_status_text (STATUS_CARDCTRL, "4");
  357|      0|              log_info ("selecting card failed: %s\n", gpg_strerror (rc));
  358|      0|              break;
  359|      0|            }
  360|      0|        }
  361|       |
  362|      0|      if (!rc && is_status_enabled () && info.serialno)
  ------------------
  |  Branch (362:11): [True: 0, False: 0]
  |  Branch (362:18): [True: 0, False: 0]
  |  Branch (362:42): [True: 0, False: 0]
  ------------------
  363|      0|        {
  364|      0|          char *buf;
  365|       |
  366|      0|          buf = xasprintf ("3 %s", info.serialno);
  367|      0|          write_status_text (STATUS_CARDCTRL, buf);
  368|      0|          xfree (buf);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  369|      0|        }
  370|       |
  371|      0|      agent_release_card_info (&info);
  372|       |
  373|      0|      if (!rc)
  ------------------
  |  Branch (373:11): [True: 0, False: 0]
  ------------------
  374|      0|        did_early_card_test = 1;
  375|      0|    }
  376|       |
  377|       |
  378|     11|  return rc;
  379|     11|}

gpg_dirmngr_deinit_session_data:
  127|     53|{
  128|     53|  dirmngr_local_t dml;
  129|       |
  130|     53|  while ((dml = ctrl->dirmngr_local))
  ------------------
  |  Branch (130:10): [True: 0, False: 53]
  ------------------
  131|      0|    {
  132|      0|      ctrl->dirmngr_local = dml->next;
  133|      0|      if (dml->is_active)
  ------------------
  |  Branch (133:11): [True: 0, False: 0]
  ------------------
  134|      0|        log_error ("oops: trying to cleanup an active dirmngr context\n");
  135|      0|      else
  136|      0|        assuan_release (dml->ctx);
  137|      0|      xfree (dml);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  138|      0|    }
  139|     53|}

keydb_new:
  255|    379|{
  256|    379|  gpg_error_t err;
  257|    379|  KEYDB_HANDLE hd;
  258|       |
  259|    379|  if (DBG_CLOCK)
  ------------------
  |  |  356|    379|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|    379|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 379]
  |  |  ------------------
  ------------------
  260|      0|    log_clock ("keydb_new");
  261|       |
  262|    379|  hd = xtrycalloc (1, sizeof *hd);
  ------------------
  |  |   99|    379|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  263|    379|  if (!hd)
  ------------------
  |  Branch (263:7): [True: 0, False: 379]
  ------------------
  264|      0|    {
  265|      0|      err = gpg_error_from_syserror ();
  266|      0|      goto leave;
  267|      0|    }
  268|       |
  269|    379|  if (!opt.use_keyboxd)
  ------------------
  |  Branch (269:7): [True: 379, False: 0]
  ------------------
  270|    379|    {
  271|    379|      err = internal_keydb_init (hd);
  272|    379|      goto leave;
  273|    379|    }
  274|      0|  hd->use_keyboxd = 1;
  275|      0|  hd->ctrl = ctrl;
  276|       |
  277|      0|  err = open_context (ctrl, &hd->kbl);
  278|       |
  279|    379| leave:
  280|    379|  if (err)
  ------------------
  |  Branch (280:7): [True: 0, False: 379]
  ------------------
  281|      0|    {
  282|      0|      int rc;
  283|      0|      log_error (_("error opening key DB: %s\n"), gpg_strerror (err));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  284|      0|      xfree (hd);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  285|      0|      hd = NULL;
  286|      0|      if (!(rc = gpg_err_code_to_errno (err)))
  ------------------
  |  Branch (286:11): [True: 0, False: 0]
  ------------------
  287|      0|        rc = gpg_err_code_to_errno (GPG_ERR_EIO);
  288|      0|      gpg_err_set_errno (rc);
  289|      0|    }
  290|    379|  return hd;
  291|      0|}
keydb_release:
  297|    812|{
  298|    812|  keyboxd_local_t kbl;
  299|       |
  300|    812|  if (!hd)
  ------------------
  |  Branch (300:7): [True: 433, False: 379]
  ------------------
  301|    433|    return;
  302|       |
  303|    379|  if (DBG_CLOCK)
  ------------------
  |  |  356|    379|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|    379|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 379]
  |  |  ------------------
  ------------------
  304|      0|    log_clock ("keydb_release");
  305|    379|  if (!hd->use_keyboxd)
  ------------------
  |  Branch (305:7): [True: 379, False: 0]
  ------------------
  306|    379|    internal_keydb_deinit (hd);
  307|      0|  else
  308|      0|    {
  309|      0|      kbl = hd->kbl;
  310|      0|      if (DBG_CLOCK)
  ------------------
  |  |  356|      0|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|      0|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  311|      0|        log_clock ("close_context (found)");
  312|      0|      if (!kbl->is_active)
  ------------------
  |  Branch (312:11): [True: 0, False: 0]
  ------------------
  313|      0|        log_fatal ("closing inactive keyboxd context %p\n", kbl);
  314|      0|      kbl->is_active = 0;
  315|      0|      hd->kbl = NULL;
  316|      0|      hd->ctrl = NULL;
  317|      0|    }
  318|    379|  xfree (hd);
  ------------------
  |  |  104|    379|#define xfree(a)         gcry_free ((a))
  ------------------
  319|    379|}
keydb_lock:
  325|     11|{
  326|     11|  if (!hd)
  ------------------
  |  Branch (326:7): [True: 0, False: 11]
  ------------------
  327|      0|    return gpg_error (GPG_ERR_INV_ARG);
  328|       |
  329|     11|  if (!hd->use_keyboxd)
  ------------------
  |  Branch (329:7): [True: 11, False: 0]
  ------------------
  330|     11|    return internal_keydb_lock (hd);
  331|       |
  332|      0|  return 0;
  333|     11|}
keydb_get_keyblock:
  347|     24|{
  348|     24|  gpg_error_t err;
  349|       |
  350|     24|  *ret_kb = NULL;
  351|       |
  352|     24|  if (!hd)
  ------------------
  |  Branch (352:7): [True: 0, False: 24]
  ------------------
  353|      0|    return gpg_error (GPG_ERR_INV_ARG);
  354|       |
  355|     24|  if (DBG_CLOCK)
  ------------------
  |  |  356|     24|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|     24|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 24]
  |  |  ------------------
  ------------------
  356|      0|    log_clock ("%s enter", __func__);
  357|       |
  358|     24|  if (!hd->use_keyboxd)
  ------------------
  |  Branch (358:7): [True: 24, False: 0]
  ------------------
  359|     24|    {
  360|     24|      err = internal_keydb_get_keyblock (hd, ret_kb);
  361|     24|      goto leave;
  362|     24|    }
  363|       |
  364|      0|  if (hd->kbl->search_result)
  ------------------
  |  Branch (364:7): [True: 0, False: 0]
  ------------------
  365|      0|    {
  366|      0|      err = keydb_parse_keyblock (hd->kbl->search_result,
  367|      0|                                  hd->last_ubid_valid? hd->last_pk_no  : 0,
  ------------------
  |  Branch (367:35): [True: 0, False: 0]
  ------------------
  368|      0|                                  hd->last_ubid_valid? hd->last_uid_no : 0,
  ------------------
  |  Branch (368:35): [True: 0, False: 0]
  ------------------
  369|      0|                                  ret_kb);
  370|       |      /* In contrast to the old code we close the iobuf here and thus
  371|       |       * this function may be called only once to get a keyblock.  */
  372|      0|      iobuf_close (hd->kbl->search_result);
  373|      0|      hd->kbl->search_result = NULL;
  374|      0|    }
  375|      0|  else
  376|      0|    {
  377|      0|      err = gpg_error (GPG_ERR_VALUE_NOT_FOUND);
  378|      0|      goto leave;
  379|      0|    }
  380|       |
  381|     24| leave:
  382|     24|  if (DBG_CLOCK)
  ------------------
  |  |  356|     24|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|     24|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 24]
  |  |  ------------------
  ------------------
  383|      0|    log_clock ("%s leave%s", __func__, err? " (failed)":"");
  ------------------
  |  Branch (383:40): [True: 0, False: 0]
  ------------------
  384|     24|  return err;
  385|      0|}
keydb_update_keyblock:
  434|      9|{
  435|      9|  gpg_error_t err;
  436|      9|  iobuf_t iobuf = NULL;
  437|      9|  struct store_parm_s parm = {NULL};
  438|       |
  439|      9|  log_assert (kb);
  440|      0|  log_assert (kb->pkt->pkttype == PKT_PUBLIC_KEY);
  441|       |
  442|      9|  if (!hd)
  ------------------
  |  Branch (442:7): [True: 0, False: 9]
  ------------------
  443|      0|    return gpg_error (GPG_ERR_INV_ARG);
  444|       |
  445|      9|  if (!hd->use_keyboxd)
  ------------------
  |  Branch (445:7): [True: 9, False: 0]
  ------------------
  446|      9|    {
  447|      9|      err = internal_keydb_update_keyblock (ctrl, hd, kb);
  448|      9|      goto leave;
  449|      9|    }
  450|       |
  451|      0|  if (opt.dry_run)
  ------------------
  |  Branch (451:7): [True: 0, False: 0]
  ------------------
  452|      0|    {
  453|      0|      err = 0;
  454|      0|      goto leave;
  455|      0|    }
  456|       |
  457|      0|  err = build_keyblock_image (kb, &iobuf);
  458|      0|  if (err)
  ------------------
  |  Branch (458:7): [True: 0, False: 0]
  ------------------
  459|      0|    goto leave;
  460|       |
  461|      0|  parm.ctx = hd->kbl->ctx;
  462|      0|  parm.data = iobuf_get_temp_buffer (iobuf);
  ------------------
  |  |  637|      0|#define iobuf_get_temp_buffer(a) ( (a)->d.buf )
  ------------------
  463|      0|  parm.datalen = iobuf_get_temp_length (iobuf);
  ------------------
  |  |  638|      0|#define iobuf_get_temp_length(a) ( (a)->d.len )
  ------------------
  464|      0|  err = assuan_transact (hd->kbl->ctx, "STORE --update",
  465|      0|                         NULL, NULL,
  466|      0|                         store_inq_cb, &parm,
  467|      0|                         NULL, NULL);
  468|       |
  469|      9| leave:
  470|      9|  iobuf_close (iobuf);
  471|      9|  return err;
  472|      0|}
keydb_insert_keyblock:
  488|      2|{
  489|      2|  gpg_error_t err;
  490|      2|  iobuf_t iobuf = NULL;
  491|      2|  struct store_parm_s parm = {NULL};
  492|       |
  493|      2|  if (!hd)
  ------------------
  |  Branch (493:7): [True: 0, False: 2]
  ------------------
  494|      0|    return gpg_error (GPG_ERR_INV_ARG);
  495|       |
  496|      2|  if (!hd->use_keyboxd)
  ------------------
  |  Branch (496:7): [True: 2, False: 0]
  ------------------
  497|      2|    {
  498|      2|      err = internal_keydb_insert_keyblock (hd, kb);
  499|      2|      goto leave;
  500|      2|    }
  501|       |
  502|      0|  if (opt.dry_run)
  ------------------
  |  Branch (502:7): [True: 0, False: 0]
  ------------------
  503|      0|    {
  504|      0|      err = 0;
  505|      0|      goto leave;
  506|      0|    }
  507|       |
  508|      0|  err = build_keyblock_image (kb, &iobuf);
  509|      0|  if (err)
  ------------------
  |  Branch (509:7): [True: 0, False: 0]
  ------------------
  510|      0|    goto leave;
  511|       |
  512|      0|  parm.ctx = hd->kbl->ctx;
  513|      0|  parm.data = iobuf_get_temp_buffer (iobuf);
  ------------------
  |  |  637|      0|#define iobuf_get_temp_buffer(a) ( (a)->d.buf )
  ------------------
  514|      0|  parm.datalen = iobuf_get_temp_length (iobuf);
  ------------------
  |  |  638|      0|#define iobuf_get_temp_length(a) ( (a)->d.len )
  ------------------
  515|      0|  err = assuan_transact (hd->kbl->ctx, "STORE --insert",
  516|      0|                         NULL, NULL,
  517|      0|                         store_inq_cb, &parm,
  518|      0|                         NULL, NULL);
  519|       |
  520|      2| leave:
  521|      2|  iobuf_close (iobuf);
  522|      2|  return err;
  523|      0|}
keydb_search_reset:
  577|  1.44k|{
  578|  1.44k|  gpg_error_t err;
  579|       |
  580|  1.44k|  if (!hd)
  ------------------
  |  Branch (580:7): [True: 0, False: 1.44k]
  ------------------
  581|      0|    return gpg_error (GPG_ERR_INV_ARG);
  582|       |
  583|  1.44k|  if (DBG_CLOCK)
  ------------------
  |  |  356|  1.44k|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|  1.44k|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 1.44k]
  |  |  ------------------
  ------------------
  584|      0|    log_clock ("%s", __func__);
  585|  1.44k|  if (DBG_CACHE)
  ------------------
  |  |  352|  1.44k|#define DBG_CACHE  (opt.debug & DBG_CACHE_VALUE)
  |  |  ------------------
  |  |  |  |  338|  1.44k|#define DBG_CACHE_VALUE   64	/* debug the caching */
  |  |  ------------------
  |  |  |  Branch (352:20): [True: 0, False: 1.44k]
  |  |  ------------------
  ------------------
  586|      0|    log_debug ("%s (hd=%p)", __func__, hd);
  587|       |
  588|  1.44k|  if (!hd->use_keyboxd)
  ------------------
  |  Branch (588:7): [True: 1.44k, False: 0]
  ------------------
  589|  1.44k|    {
  590|  1.44k|      err = internal_keydb_search_reset (hd);
  591|  1.44k|      goto leave;
  592|  1.44k|    }
  593|       |
  594|       |  /* All we need is to tell search that a reset is pending.  Note that
  595|       |   * keydb_new sets this flag as well.  To comply with the
  596|       |   * specification of keydb_delete_keyblock we also need to clear the
  597|       |   * ubid flag so that after a reset a delete can't be performed.  */
  598|      0|  hd->kbl->need_search_reset = 1;
  599|      0|  hd->last_ubid_valid = 0;
  600|      0|  err = 0;
  601|       |
  602|  1.44k| leave:
  603|  1.44k|  return err;
  604|      0|}
keydb_search:
  677|  1.82k|{
  678|  1.82k|  gpg_error_t err;
  679|  1.82k|  int i;
  680|  1.82k|  char line[ASSUAN_LINELENGTH];
  681|  1.82k|  char *buffer;
  682|  1.82k|  size_t len;
  683|       |
  684|  1.82k|  if (!hd)
  ------------------
  |  Branch (684:7): [True: 0, False: 1.82k]
  ------------------
  685|      0|    return gpg_error (GPG_ERR_INV_ARG);
  686|       |
  687|  1.82k|  if (descindex)
  ------------------
  |  Branch (687:7): [True: 0, False: 1.82k]
  ------------------
  688|      0|    *descindex = 0; /* Make sure it is always set on return.  */
  689|       |
  690|  1.82k|  if (DBG_CLOCK)
  ------------------
  |  |  356|  1.82k|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|  1.82k|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 1.82k]
  |  |  ------------------
  ------------------
  691|      0|    log_clock ("%s enter", __func__);
  692|       |
  693|  1.82k|  if (DBG_LOOKUP)
  ------------------
  |  |  357|  1.82k|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|  1.82k|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 1.82k]
  |  |  ------------------
  ------------------
  694|      0|    {
  695|      0|      log_debug ("%s: %zu search descriptions:\n", __func__, ndesc);
  696|      0|      for (i = 0; i < ndesc; i ++)
  ------------------
  |  Branch (696:19): [True: 0, False: 0]
  ------------------
  697|      0|        {
  698|      0|          char *t = keydb_search_desc_dump (&desc[i]);
  699|      0|          log_debug ("%s   %d: %s\n", __func__, i, t);
  700|      0|          xfree (t);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  701|      0|        }
  702|      0|    }
  703|       |
  704|  1.82k|  if (!hd->use_keyboxd)
  ------------------
  |  Branch (704:7): [True: 1.82k, False: 0]
  ------------------
  705|  1.82k|    {
  706|  1.82k|      err = internal_keydb_search (hd, desc, ndesc, descindex);
  707|  1.82k|      goto leave;
  708|  1.82k|    }
  709|       |
  710|       |  /* Clear the result objects.  */
  711|      0|  if (hd->kbl->search_result)
  ------------------
  |  Branch (711:7): [True: 0, False: 0]
  ------------------
  712|      0|    {
  713|      0|      iobuf_close (hd->kbl->search_result);
  714|      0|      hd->kbl->search_result = NULL;
  715|      0|    }
  716|       |
  717|       |  /* Check whether this is a NEXT search.  */
  718|      0|  if (!hd->kbl->need_search_reset)
  ------------------
  |  Branch (718:7): [True: 0, False: 0]
  ------------------
  719|      0|    {
  720|       |      /* No reset requested thus continue the search.  The keyboxd
  721|       |       * keeps the context of the search and thus the NEXT operates on
  722|       |       * the last search pattern.  This is how we always used the
  723|       |       * keydb.c functions.  In theory we were able to modify the
  724|       |       * search pattern between searches but that is not anymore
  725|       |       * supported by keyboxd and a cursory check does not show that
  726|       |       * we actually made used of that misfeature.  */
  727|      0|      snprintf (line, sizeof line, "NEXT");
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  728|      0|      goto do_search;
  729|      0|    }
  730|       |
  731|      0|  hd->kbl->need_search_reset = 0;
  732|       |
  733|      0|  if (!ndesc)
  ------------------
  |  Branch (733:7): [True: 0, False: 0]
  ------------------
  734|      0|    {
  735|      0|      err = gpg_error (GPG_ERR_INV_ARG);
  736|      0|      goto leave;
  737|      0|    }
  738|      0|  for (i = 0; i < ndesc; i++)
  ------------------
  |  Branch (738:15): [True: 0, False: 0]
  ------------------
  739|      0|    if (desc->mode == KEYDB_SEARCH_MODE_FIRST)
  ------------------
  |  Branch (739:9): [True: 0, False: 0]
  ------------------
  740|      0|      {
  741|       |        /* If any description has mode FIRST, this item trumps all
  742|       |         * other descriptions.  */
  743|      0|        snprintf (line, sizeof line, "SEARCH --openpgp");
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  744|      0|        goto do_search;
  745|      0|      }
  746|       |
  747|      0|  for ( ; ndesc; desc++, ndesc--)
  ------------------
  |  Branch (747:11): [True: 0, False: 0]
  ------------------
  748|      0|    {
  749|      0|      const char *more = ndesc > 1 ? "--openpgp --more" : "--openpgp";
  ------------------
  |  Branch (749:26): [True: 0, False: 0]
  ------------------
  750|       |
  751|      0|      switch (desc->mode)
  752|      0|        {
  753|      0|        case KEYDB_SEARCH_MODE_EXACT:
  ------------------
  |  Branch (753:9): [True: 0, False: 0]
  ------------------
  754|      0|          snprintf (line, sizeof line, "SEARCH %s -- =%s", more, desc->u.name);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  755|      0|          break;
  756|       |
  757|      0|        case KEYDB_SEARCH_MODE_SUBSTR:
  ------------------
  |  Branch (757:9): [True: 0, False: 0]
  ------------------
  758|      0|          snprintf (line, sizeof line, "SEARCH %s -- *%s", more, desc->u.name);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  759|      0|          break;
  760|       |
  761|      0|        case KEYDB_SEARCH_MODE_MAIL:
  ------------------
  |  Branch (761:9): [True: 0, False: 0]
  ------------------
  762|      0|          snprintf (line, sizeof line, "SEARCH %s -- <%s",
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  763|      0|                    more, desc->u.name+(desc->u.name[0] == '<') );
  764|      0|          break;
  765|       |
  766|      0|        case KEYDB_SEARCH_MODE_MAILSUB:
  ------------------
  |  Branch (766:9): [True: 0, False: 0]
  ------------------
  767|      0|          snprintf (line, sizeof line, "SEARCH %s -- @%s", more, desc->u.name);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  768|      0|          break;
  769|       |
  770|      0|        case KEYDB_SEARCH_MODE_MAILEND:
  ------------------
  |  Branch (770:9): [True: 0, False: 0]
  ------------------
  771|      0|          snprintf (line, sizeof line, "SEARCH %s -- .%s", more, desc->u.name);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  772|      0|          break;
  773|       |
  774|      0|        case KEYDB_SEARCH_MODE_WORDS:
  ------------------
  |  Branch (774:9): [True: 0, False: 0]
  ------------------
  775|      0|          snprintf (line, sizeof line, "SEARCH %s -- +%s", more, desc->u.name);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  776|      0|          break;
  777|       |
  778|      0|        case KEYDB_SEARCH_MODE_SHORT_KID:
  ------------------
  |  Branch (778:9): [True: 0, False: 0]
  ------------------
  779|      0|          snprintf (line, sizeof line, "SEARCH %s -- 0x%08lX", more,
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  780|      0|                    (ulong)desc->u.kid[1]);
  781|      0|          break;
  782|       |
  783|      0|        case KEYDB_SEARCH_MODE_LONG_KID:
  ------------------
  |  Branch (783:9): [True: 0, False: 0]
  ------------------
  784|      0|          snprintf (line, sizeof line, "SEARCH %s -- 0x%08lX%08lX", more,
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  785|      0|                    (ulong)desc->u.kid[0], (ulong)desc->u.kid[1]);
  786|      0|          break;
  787|       |
  788|      0|        case KEYDB_SEARCH_MODE_FPR:
  ------------------
  |  Branch (788:9): [True: 0, False: 0]
  ------------------
  789|      0|          {
  790|      0|            unsigned char hexfpr[MAX_FINGERPRINT_LEN * 2 + 1];
  791|      0|            log_assert (desc->fprlen <= MAX_FINGERPRINT_LEN);
  792|      0|            bin2hex (desc->u.fpr, desc->fprlen, hexfpr);
  793|      0|            snprintf (line, sizeof line, "SEARCH %s -- 0x%s", more, hexfpr);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  794|      0|          }
  795|      0|          break;
  796|       |
  797|      0|        case KEYDB_SEARCH_MODE_ISSUER:
  ------------------
  |  Branch (797:9): [True: 0, False: 0]
  ------------------
  798|      0|          snprintf (line, sizeof line, "SEARCH %s -- #/%s", more, desc->u.name);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  799|      0|          break;
  800|       |
  801|      0|        case KEYDB_SEARCH_MODE_ISSUER_SN:
  ------------------
  |  Branch (801:9): [True: 0, False: 0]
  ------------------
  802|      0|        case KEYDB_SEARCH_MODE_SN:
  ------------------
  |  Branch (802:9): [True: 0, False: 0]
  ------------------
  803|      0|          snprintf (line, sizeof line, "SEARCH %s -- #%s", more, desc->u.name);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  804|      0|          break;
  805|       |
  806|      0|        case KEYDB_SEARCH_MODE_SUBJECT:
  ------------------
  |  Branch (806:9): [True: 0, False: 0]
  ------------------
  807|      0|          snprintf (line, sizeof line, "SEARCH %s -- /%s", more, desc->u.name);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  808|      0|          break;
  809|       |
  810|      0|        case KEYDB_SEARCH_MODE_KEYGRIP:
  ------------------
  |  Branch (810:9): [True: 0, False: 0]
  ------------------
  811|      0|          {
  812|      0|            unsigned char hexgrip[KEYGRIP_LEN * 2 + 1];
  813|      0|            bin2hex (desc->u.grip, KEYGRIP_LEN, hexgrip);
  ------------------
  |  |   56|      0|#define KEYGRIP_LEN 20
  ------------------
  814|      0|            snprintf (line, sizeof line, "SEARCH %s -- &%s", more, hexgrip);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  815|      0|          }
  816|      0|          break;
  817|       |
  818|      0|        case KEYDB_SEARCH_MODE_UBID:
  ------------------
  |  Branch (818:9): [True: 0, False: 0]
  ------------------
  819|      0|          {
  820|      0|            unsigned char hexubid[UBID_LEN * 2 + 1];
  821|      0|            bin2hex (desc->u.ubid, UBID_LEN, hexubid);
  ------------------
  |  |   60|      0|#define UBID_LEN    20
  ------------------
  822|      0|            snprintf (line, sizeof line, "SEARCH %s -- ^%s", more, hexubid);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  823|      0|          }
  824|      0|          break;
  825|       |
  826|      0|        case KEYDB_SEARCH_MODE_NEXT:
  ------------------
  |  Branch (826:9): [True: 0, False: 0]
  ------------------
  827|      0|          log_debug ("%s: mode next - we should not get to here!\n", __func__);
  828|      0|          snprintf (line, sizeof line, "NEXT");
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  829|      0|          break;
  830|       |
  831|      0|        case KEYDB_SEARCH_MODE_FIRST:
  ------------------
  |  Branch (831:9): [True: 0, False: 0]
  ------------------
  832|      0|          log_debug ("%s: mode first - we should not get to here!\n", __func__);
  833|       |          /*fallthru*/
  834|      0|        default:
  ------------------
  |  Branch (834:9): [True: 0, False: 0]
  ------------------
  835|      0|          err = gpg_error (GPG_ERR_INV_ARG);
  836|      0|          goto leave;
  837|      0|        }
  838|       |
  839|      0|      if (ndesc > 1)
  ------------------
  |  Branch (839:11): [True: 0, False: 0]
  ------------------
  840|      0|        {
  841|      0|          err = kbx_client_data_simple (hd->kbl->kcd, line);
  842|      0|          if (err)
  ------------------
  |  Branch (842:15): [True: 0, False: 0]
  ------------------
  843|      0|            goto leave;
  844|      0|        }
  845|      0|    }
  846|      0|  while (ndesc);
  ------------------
  |  Branch (846:10): [True: 0, False: 0]
  ------------------
  847|       |
  848|       |
  849|      0| do_search:
  850|      0|  hd->last_ubid_valid = 0;
  851|      0|  err = kbx_client_data_cmd (hd->kbl->kcd, line, search_status_cb, hd);
  852|      0|  if (!err && !(err = kbx_client_data_wait (hd->kbl->kcd, &buffer, &len)))
  ------------------
  |  Branch (852:7): [True: 0, False: 0]
  |  Branch (852:15): [True: 0, False: 0]
  ------------------
  853|      0|    {
  854|      0|      hd->kbl->search_result = iobuf_temp_with_content (buffer, len);
  855|      0|      xfree (buffer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  856|      0|      if (DBG_LOOKUP && hd->last_ubid_valid)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (856:25): [True: 0, False: 0]
  ------------------
  857|      0|        log_printhex (hd->last_ubid, 20, "found UBID (%d,%d):",
  858|      0|                      hd->last_uid_no, hd->last_pk_no);
  859|      0|    }
  860|       |
  861|  1.82k| leave:
  862|  1.82k|  if (DBG_CLOCK)
  ------------------
  |  |  356|  1.82k|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|  1.82k|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 1.82k]
  |  |  ------------------
  ------------------
  863|      0|    log_clock ("%s leave (%sfound)", __func__, err? "not ":"");
  ------------------
  |  Branch (863:48): [True: 0, False: 0]
  ------------------
  864|  1.82k|  return err;
  865|      0|}

is_status_enabled:
  132|     68|{
  133|     68|  return !!statusfp;
  134|     68|}
write_status_strings:
  149|     12|{
  150|     12|  va_list arg_ptr;
  151|     12|  const char *s;
  152|       |
  153|     12|  if (!statusfp || !status_currently_allowed (no) )
  ------------------
  |  Branch (153:7): [True: 12, False: 0]
  |  Branch (153:20): [True: 0, False: 0]
  ------------------
  154|     12|    return;  /* Not enabled or allowed. */
  155|       |
  156|      0|  es_fputs ("[GNUPG:] ", statusfp);
  157|      0|  es_fputs (get_status_string (no), statusfp);
  158|      0|  if ( text )
  ------------------
  |  Branch (158:8): [True: 0, False: 0]
  ------------------
  159|      0|    {
  160|      0|      es_putc ( ' ', statusfp);
  161|      0|      va_start (arg_ptr, text);
  162|      0|      s = text;
  163|      0|      do
  164|      0|        {
  165|      0|          for (; *s; s++)
  ------------------
  |  Branch (165:18): [True: 0, False: 0]
  ------------------
  166|      0|            {
  167|      0|              if (*s == '\n')
  ------------------
  |  Branch (167:19): [True: 0, False: 0]
  ------------------
  168|      0|                es_fputs ("\\n", statusfp);
  169|      0|              else if (*s == '\r')
  ------------------
  |  Branch (169:24): [True: 0, False: 0]
  ------------------
  170|      0|                es_fputs ("\\r", statusfp);
  171|      0|              else
  172|      0|                es_fputc (*(const byte *)s, statusfp);
  173|      0|            }
  174|      0|        }
  175|      0|      while ((s = va_arg (arg_ptr, const char*)));
  ------------------
  |  Branch (175:14): [True: 0, False: 0]
  ------------------
  176|      0|      va_end (arg_ptr);
  177|      0|    }
  178|      0|  es_putc ('\n', statusfp);
  179|      0|  if (es_fflush (statusfp) && opt.exit_on_status_write_error)
  ------------------
  |  Branch (179:7): [True: 0, False: 0]
  |  Branch (179:31): [True: 0, False: 0]
  ------------------
  180|      0|    g10_exit (0);
  181|      0|}
write_status_text:
  230|     12|{
  231|     12|  write_status_strings (no, text, NULL);
  232|     12|}

free_symkey_enc:
   76|    674|{
   77|    674|    xfree(enc);
  ------------------
  |  |  104|    674|#define xfree(a)         gcry_free ((a))
  ------------------
   78|    674|}
free_seckey_enc:
   94|  2.26k|{
   95|  2.26k|  int n, i;
   96|       |
   97|  2.26k|  n = pubkey_get_nsig( sig->pubkey_algo );
   98|  2.26k|  if( !n )
  ------------------
  |  Branch (98:7): [True: 2.05k, False: 215]
  ------------------
   99|  2.05k|    mpi_release(sig->data[0]);
  100|  2.64k|  for(i=0; i < n; i++ )
  ------------------
  |  Branch (100:12): [True: 372, False: 2.26k]
  ------------------
  101|    372|    mpi_release( sig->data[i] );
  102|       |
  103|  2.26k|  xfree(sig->revkey);
  ------------------
  |  |  104|  2.26k|#define xfree(a)         gcry_free ((a))
  ------------------
  104|  2.26k|  xfree(sig->hashed);
  ------------------
  |  |  104|  2.26k|#define xfree(a)         gcry_free ((a))
  ------------------
  105|  2.26k|  xfree(sig->unhashed);
  ------------------
  |  |  104|  2.26k|#define xfree(a)         gcry_free ((a))
  ------------------
  106|       |
  107|  2.26k|  xfree (sig->signers_uid);
  ------------------
  |  |  104|  2.26k|#define xfree(a)         gcry_free ((a))
  ------------------
  108|       |
  109|  2.26k|  xfree(sig);
  ------------------
  |  |  104|  2.26k|#define xfree(a)         gcry_free ((a))
  ------------------
  110|  2.26k|}
release_public_key_parts:
  115|  2.19k|{
  116|  2.19k|  int n, i;
  117|       |
  118|  2.19k|  if (pk->seckey_info)
  ------------------
  |  Branch (118:7): [True: 422, False: 1.77k]
  ------------------
  119|    422|    n = pubkey_get_nskey (pk->pubkey_algo);
  120|  1.77k|  else
  121|  1.77k|    n = pubkey_get_npkey (pk->pubkey_algo);
  122|  2.19k|  if (!n)
  ------------------
  |  Branch (122:7): [True: 1.54k, False: 647]
  ------------------
  123|  1.54k|    mpi_release (pk->pkey[0]);
  124|  5.01k|  for (i=0; i < n; i++ )
  ------------------
  |  Branch (124:13): [True: 2.81k, False: 2.19k]
  ------------------
  125|  2.81k|    {
  126|  2.81k|      mpi_release (pk->pkey[i]);
  127|  2.81k|      pk->pkey[i] = NULL;
  128|  2.81k|    }
  129|  2.19k|  if (pk->seckey_info)
  ------------------
  |  Branch (129:7): [True: 422, False: 1.77k]
  ------------------
  130|    422|    {
  131|    422|      xfree (pk->seckey_info);
  ------------------
  |  |  104|    422|#define xfree(a)         gcry_free ((a))
  ------------------
  132|    422|      pk->seckey_info = NULL;
  133|    422|    }
  134|  2.19k|  if (pk->prefs)
  ------------------
  |  Branch (134:7): [True: 0, False: 2.19k]
  ------------------
  135|      0|    {
  136|      0|      xfree (pk->prefs);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  137|      0|      pk->prefs = NULL;
  138|      0|    }
  139|  2.19k|  free_user_id (pk->user_id);
  140|  2.19k|  pk->user_id = NULL;
  141|  2.19k|  if (pk->revkey)
  ------------------
  |  Branch (141:7): [True: 0, False: 2.19k]
  ------------------
  142|      0|    {
  143|      0|      xfree(pk->revkey);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  144|      0|      pk->revkey=NULL;
  145|      0|      pk->numrevkeys=0;
  146|      0|    }
  147|  2.19k|  if (pk->serialno)
  ------------------
  |  Branch (147:7): [True: 0, False: 2.19k]
  ------------------
  148|      0|    {
  149|      0|      xfree (pk->serialno);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  150|      0|      pk->serialno = NULL;
  151|      0|    }
  152|  2.19k|  if (pk->updateurl)
  ------------------
  |  Branch (152:7): [True: 0, False: 2.19k]
  ------------------
  153|      0|    {
  154|      0|      xfree (pk->updateurl);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  155|      0|      pk->updateurl = NULL;
  156|      0|    }
  157|  2.19k|}
free_public_key:
  164|  2.93k|{
  165|  2.93k|  if (pk)
  ------------------
  |  Branch (165:7): [True: 2.19k, False: 740]
  ------------------
  166|  2.19k|    {
  167|  2.19k|      release_public_key_parts (pk);
  168|  2.19k|      xfree(pk);
  ------------------
  |  |  104|  2.19k|#define xfree(a)         gcry_free ((a))
  ------------------
  169|  2.19k|    }
  170|  2.93k|}
copy_prefs:
  192|    313|{
  193|    313|    size_t n;
  194|    313|    prefitem_t *new;
  195|       |
  196|    313|    if (!prefs)
  ------------------
  |  Branch (196:9): [True: 313, False: 0]
  ------------------
  197|    313|        return NULL;
  198|       |
  199|      0|    for (n=0; prefs[n].type; n++)
  ------------------
  |  Branch (199:15): [True: 0, False: 0]
  ------------------
  200|      0|        ;
  201|      0|    new = xmalloc ( sizeof (*new) * (n+1));
  ------------------
  |  |  107|      0|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  202|      0|    for (n=0; prefs[n].type; n++) {
  ------------------
  |  Branch (202:15): [True: 0, False: 0]
  ------------------
  203|      0|        new[n].type = prefs[n].type;
  204|      0|        new[n].value = prefs[n].value;
  205|      0|    }
  206|      0|    new[n].type = PREFTYPE_NONE;
  207|      0|    new[n].value = 0;
  208|       |
  209|      0|    return new;
  210|    313|}
copy_public_key:
  218|    313|{
  219|    313|  int n, i;
  220|       |
  221|    313|  if (!d)
  ------------------
  |  Branch (221:7): [True: 313, False: 0]
  ------------------
  222|    313|    d = xmalloc (sizeof *d);
  ------------------
  |  |  107|    313|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  223|    313|  memcpy (d, s, sizeof *d);
  224|    313|  d->seckey_info = NULL;
  225|    313|  d->user_id = scopy_user_id (s->user_id);
  226|    313|  d->prefs = copy_prefs (s->prefs);
  227|       |
  228|    313|  n = pubkey_get_npkey (s->pubkey_algo);
  229|    313|  i = 0;
  230|    313|  if (!n)
  ------------------
  |  Branch (230:7): [True: 141, False: 172]
  ------------------
  231|    141|    d->pkey[i++] = my_mpi_copy (s->pkey[0]);
  232|    172|  else
  233|    172|    {
  234|    516|      for (; i < n; i++ )
  ------------------
  |  Branch (234:14): [True: 344, False: 172]
  ------------------
  235|    344|        d->pkey[i] = my_mpi_copy (s->pkey[i]);
  236|    172|    }
  237|  2.01k|  for (; i < PUBKEY_MAX_NSKEY; i++)
  ------------------
  |  |   44|  2.01k|#define PUBKEY_MAX_NSKEY  OPENPGP_MAX_NSKEY
  |  |  ------------------
  |  |  |  |  204|  2.01k|#define OPENPGP_MAX_NSKEY  7  /* Maximum number of secret key parameters. */
  |  |  ------------------
  ------------------
  |  Branch (237:10): [True: 1.70k, False: 313]
  ------------------
  238|  1.70k|    d->pkey[i] = NULL;
  239|       |
  240|    313|  if (!s->revkey && s->numrevkeys)
  ------------------
  |  Branch (240:7): [True: 313, False: 0]
  |  Branch (240:21): [True: 0, False: 313]
  ------------------
  241|      0|    BUG();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  242|    313|  if (s->numrevkeys)
  ------------------
  |  Branch (242:7): [True: 0, False: 313]
  ------------------
  243|      0|    {
  244|      0|      d->revkey = xmalloc(sizeof(struct revocation_key)*s->numrevkeys);
  ------------------
  |  |  107|      0|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  245|      0|      memcpy(d->revkey,s->revkey,sizeof(struct revocation_key)*s->numrevkeys);
  246|      0|    }
  247|    313|  else
  248|    313|    d->revkey = NULL;
  249|       |
  250|    313|  if (s->serialno)
  ------------------
  |  Branch (250:7): [True: 0, False: 313]
  ------------------
  251|      0|    d->serialno = xstrdup (s->serialno);
  ------------------
  |  |  112|      0|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
  252|    313|  if (s->updateurl)
  ------------------
  |  Branch (252:7): [True: 0, False: 313]
  ------------------
  253|      0|    d->updateurl = xstrdup (s->updateurl);
  ------------------
  |  |  112|      0|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
  254|       |
  255|    313|  return d;
  256|    313|}
copy_signature:
  262|    340|{
  263|    340|    int n, i;
  264|       |
  265|    340|    if( !d )
  ------------------
  |  Branch (265:9): [True: 340, False: 0]
  ------------------
  266|    340|	d = xmalloc(sizeof *d);
  ------------------
  |  |  107|    340|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  267|    340|    memcpy( d, s, sizeof *d );
  268|    340|    n = pubkey_get_nsig( s->pubkey_algo );
  269|    340|    if( !n )
  ------------------
  |  Branch (269:9): [True: 340, False: 0]
  ------------------
  270|    340|	d->data[0] = my_mpi_copy(s->data[0]);
  271|      0|    else {
  272|      0|	for(i=0; i < n; i++ )
  ------------------
  |  Branch (272:11): [True: 0, False: 0]
  ------------------
  273|      0|	    d->data[i] = my_mpi_copy( s->data[i] );
  274|      0|    }
  275|    340|    d->hashed = cp_subpktarea (s->hashed);
  276|    340|    d->unhashed = cp_subpktarea (s->unhashed);
  277|    340|    if (s->signers_uid)
  ------------------
  |  Branch (277:9): [True: 0, False: 340]
  ------------------
  278|      0|      d->signers_uid = xstrdup (s->signers_uid);
  ------------------
  |  |  112|      0|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
  279|    340|    if(s->numrevkeys)
  ------------------
  |  Branch (279:8): [True: 0, False: 340]
  ------------------
  280|      0|      {
  281|      0|	d->revkey=NULL;
  282|      0|	d->numrevkeys=0;
  283|      0|	parse_revkeys(d);
  284|      0|      }
  285|    340|    return d;
  286|    340|}
scopy_user_id:
  294|    317|{
  295|    317|    if (s)
  ------------------
  |  Branch (295:9): [True: 0, False: 317]
  ------------------
  296|      0|        s->ref++;
  297|    317|    return s;
  298|    317|}
free_comment:
  304|    692|{
  305|    692|    xfree(rem);
  ------------------
  |  |  104|    692|#define xfree(a)         gcry_free ((a))
  ------------------
  306|    692|}
free_attributes:
  310|  1.63k|{
  311|  1.63k|  if (!uid)
  ------------------
  |  Branch (311:7): [True: 0, False: 1.63k]
  ------------------
  312|      0|    return;
  313|       |
  314|  1.63k|  xfree(uid->attribs);
  ------------------
  |  |  104|  1.63k|#define xfree(a)         gcry_free ((a))
  ------------------
  315|  1.63k|  xfree(uid->attrib_data);
  ------------------
  |  |  104|  1.63k|#define xfree(a)         gcry_free ((a))
  ------------------
  316|       |
  317|  1.63k|  uid->attribs=NULL;
  318|  1.63k|  uid->attrib_data=NULL;
  319|  1.63k|  uid->attrib_len=0;
  320|  1.63k|}
free_user_id:
  324|  3.83k|{
  325|  3.83k|  if (!uid)
  ------------------
  |  Branch (325:7): [True: 2.19k, False: 1.63k]
  ------------------
  326|  2.19k|    return;
  327|       |
  328|  1.63k|  log_assert (uid->ref > 0);
  329|  1.63k|  if (--uid->ref)
  ------------------
  |  Branch (329:7): [True: 0, False: 1.63k]
  ------------------
  330|      0|    return;
  331|       |
  332|  1.63k|  free_attributes(uid);
  333|  1.63k|  xfree (uid->prefs);
  ------------------
  |  |  104|  1.63k|#define xfree(a)         gcry_free ((a))
  ------------------
  334|  1.63k|  xfree (uid->namehash);
  ------------------
  |  |  104|  1.63k|#define xfree(a)         gcry_free ((a))
  ------------------
  335|  1.63k|  xfree (uid->updateurl);
  ------------------
  |  |  104|  1.63k|#define xfree(a)         gcry_free ((a))
  ------------------
  336|  1.63k|  xfree (uid->mbox);
  ------------------
  |  |  104|  1.63k|#define xfree(a)         gcry_free ((a))
  ------------------
  337|  1.63k|  xfree (uid);
  ------------------
  |  |  104|  1.63k|#define xfree(a)         gcry_free ((a))
  ------------------
  338|  1.63k|}
free_compressed:
  342|      2|{
  343|      2|  if (!zd)
  ------------------
  |  Branch (343:7): [True: 0, False: 2]
  ------------------
  344|      0|    return;
  345|       |
  346|      2|  if (zd->buf)
  ------------------
  |  Branch (346:7): [True: 2, False: 0]
  ------------------
  347|      2|    {
  348|       |      /* We need to skip some bytes.  Because don't have any
  349|       |       * information about the length, so we assume this is the last
  350|       |       * packet */
  351|      5|      while (iobuf_read( zd->buf, NULL, 1<<30 ) != -1)
  ------------------
  |  Branch (351:14): [True: 3, False: 2]
  ------------------
  352|      3|        ;
  353|      2|    }
  354|      2|  xfree(zd);
  ------------------
  |  |  104|      2|#define xfree(a)         gcry_free ((a))
  ------------------
  355|      2|}
free_encrypted:
  359|     33|{
  360|     33|  if (!ed)
  ------------------
  |  Branch (360:7): [True: 0, False: 33]
  ------------------
  361|      0|    return;
  362|       |
  363|     33|  if (ed->buf)
  ------------------
  |  Branch (363:7): [True: 33, False: 0]
  ------------------
  364|     33|    {
  365|       |      /* We need to skip some bytes. */
  366|     33|      if (ed->is_partial)
  ------------------
  |  Branch (366:11): [True: 1, False: 32]
  ------------------
  367|      1|        {
  368|      3|          while (iobuf_read( ed->buf, NULL, 1<<30 ) != -1)
  ------------------
  |  Branch (368:18): [True: 2, False: 1]
  ------------------
  369|      2|            ;
  370|      1|	}
  371|     32|      else
  372|     32|        {
  373|     96|          while (ed->len)
  ------------------
  |  Branch (373:18): [True: 64, False: 32]
  ------------------
  374|     64|            {
  375|       |              /* Skip the packet. */
  376|     64|              int n = iobuf_read( ed->buf, NULL, ed->len );
  377|     64|              if (n == -1)
  ------------------
  |  Branch (377:19): [True: 32, False: 32]
  ------------------
  378|     32|                ed->len = 0;
  379|     32|              else
  380|     32|                ed->len -= n;
  381|     64|            }
  382|     32|	}
  383|     33|    }
  384|     33|  xfree (ed);
  ------------------
  |  |  104|     33|#define xfree(a)         gcry_free ((a))
  ------------------
  385|     33|}
free_plaintext:
  390|     34|{
  391|     34|  if (!pt)
  ------------------
  |  Branch (391:7): [True: 0, False: 34]
  ------------------
  392|      0|    return;
  393|       |
  394|     34|  if (pt->buf)
  ------------------
  |  Branch (394:7): [True: 34, False: 0]
  ------------------
  395|     34|    { /* We need to skip some bytes.  */
  396|     34|      if (pt->is_partial)
  ------------------
  |  Branch (396:11): [True: 33, False: 1]
  ------------------
  397|     33|        {
  398|     34|          while (iobuf_read( pt->buf, NULL, 1<<30 ) != -1)
  ------------------
  |  Branch (398:18): [True: 1, False: 33]
  ------------------
  399|      1|            ;
  400|     33|        }
  401|      1|      else
  402|      1|        {
  403|      3|          while( pt->len )
  ------------------
  |  Branch (403:18): [True: 2, False: 1]
  ------------------
  404|      2|            { /* Skip the packet.  */
  405|      2|              int n = iobuf_read( pt->buf, NULL, pt->len );
  406|      2|              if (n == -1)
  ------------------
  |  Branch (406:19): [True: 1, False: 1]
  ------------------
  407|      1|                pt->len = 0;
  408|      1|              else
  409|      1|                pt->len -= n;
  410|      2|            }
  411|      1|	}
  412|     34|    }
  413|     34|  xfree (pt);
  ------------------
  |  |  104|     34|#define xfree(a)         gcry_free ((a))
  ------------------
  414|     34|}
free_packet:
  422|  16.6k|{
  423|  16.6k|  if (!pkt || !pkt->pkt.generic)
  ------------------
  |  Branch (423:7): [True: 8.26k, False: 8.39k]
  |  Branch (423:15): [True: 324, False: 8.07k]
  ------------------
  424|  8.58k|    {
  425|  8.58k|      if (parsectx && parsectx->last_pkt.pkt.generic)
  ------------------
  |  Branch (425:11): [True: 8.58k, False: 0]
  |  Branch (425:23): [True: 4.55k, False: 4.03k]
  ------------------
  426|  4.55k|        {
  427|  4.55k|          if (parsectx->free_last_pkt)
  ------------------
  |  Branch (427:15): [True: 553, False: 4.00k]
  ------------------
  428|    553|            {
  429|    553|              free_packet (&parsectx->last_pkt, NULL);
  430|    553|              parsectx->free_last_pkt = 0;
  431|    553|            }
  432|  4.55k|          parsectx->last_pkt.pkttype = 0;
  433|  4.55k|          parsectx->last_pkt.pkt.generic = NULL;
  434|  4.55k|        }
  435|  8.58k|      return;
  436|  8.58k|    }
  437|       |
  438|  8.07k|  if (DBG_MEMORY)
  ------------------
  |  |  361|  8.07k|#define DBG_MEMORY    memory_debug_mode
  |  |  ------------------
  |  |  |  Branch (361:23): [True: 0, False: 8.07k]
  |  |  ------------------
  ------------------
  439|      0|    log_debug ("free_packet() type=%d\n", pkt->pkttype);
  440|       |
  441|       |  /* If we have a parser context holding PKT then do not free the
  442|       |   * packet but set a flag that the packet in the parser context is
  443|       |   * now a deep copy.  */
  444|  8.07k|  if (parsectx && !parsectx->free_last_pkt
  ------------------
  |  Branch (444:7): [True: 2.43k, False: 5.64k]
  |  Branch (444:19): [True: 2.43k, False: 0]
  ------------------
  445|  8.07k|      && parsectx->last_pkt.pkttype == pkt->pkttype
  ------------------
  |  Branch (445:10): [True: 553, False: 1.87k]
  ------------------
  446|  8.07k|      && parsectx->last_pkt.pkt.generic == pkt->pkt.generic)
  ------------------
  |  Branch (446:10): [True: 553, False: 0]
  ------------------
  447|    553|    {
  448|    553|      parsectx->last_pkt = *pkt;
  449|    553|      parsectx->free_last_pkt = 1;
  450|    553|      pkt->pkt.generic = NULL;
  451|    553|      return;
  452|    553|    }
  453|       |
  454|  7.52k|  switch (pkt->pkttype)
  455|  7.52k|    {
  456|  2.26k|    case PKT_SIGNATURE:
  ------------------
  |  Branch (456:5): [True: 2.26k, False: 5.25k]
  ------------------
  457|  2.26k|      free_seckey_enc (pkt->pkt.signature);
  458|  2.26k|      break;
  459|      0|    case PKT_PUBKEY_ENC:
  ------------------
  |  Branch (459:5): [True: 0, False: 7.52k]
  ------------------
  460|      0|      free_pubkey_enc (pkt->pkt.pubkey_enc);
  461|      0|      break;
  462|    674|    case PKT_SYMKEY_ENC:
  ------------------
  |  Branch (462:5): [True: 674, False: 6.84k]
  ------------------
  463|    674|      free_symkey_enc (pkt->pkt.symkey_enc);
  464|    674|      break;
  465|    924|    case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (465:5): [True: 924, False: 6.59k]
  ------------------
  466|  1.07k|    case PKT_PUBLIC_SUBKEY:
  ------------------
  |  Branch (466:5): [True: 154, False: 7.36k]
  ------------------
  467|  1.35k|    case PKT_SECRET_KEY:
  ------------------
  |  Branch (467:5): [True: 272, False: 7.24k]
  ------------------
  468|  1.77k|    case PKT_SECRET_SUBKEY:
  ------------------
  |  Branch (468:5): [True: 423, False: 7.09k]
  ------------------
  469|  1.77k|      free_public_key (pkt->pkt.public_key);
  470|  1.77k|      break;
  471|    692|    case PKT_COMMENT:
  ------------------
  |  Branch (471:5): [True: 692, False: 6.82k]
  ------------------
  472|    692|      free_comment (pkt->pkt.comment);
  473|    692|      break;
  474|  1.63k|    case PKT_USER_ID:
  ------------------
  |  Branch (474:5): [True: 1.63k, False: 5.88k]
  ------------------
  475|  1.63k|      free_user_id (pkt->pkt.user_id);
  476|  1.63k|      break;
  477|      2|    case PKT_COMPRESSED:
  ------------------
  |  Branch (477:5): [True: 2, False: 7.51k]
  ------------------
  478|      2|      free_compressed (pkt->pkt.compressed);
  479|      2|      break;
  480|      1|    case PKT_ENCRYPTED:
  ------------------
  |  Branch (480:5): [True: 1, False: 7.51k]
  ------------------
  481|      1|    case PKT_ENCRYPTED_MDC:
  ------------------
  |  Branch (481:5): [True: 0, False: 7.52k]
  ------------------
  482|     33|    case PKT_ENCRYPTED_AEAD:
  ------------------
  |  Branch (482:5): [True: 32, False: 7.48k]
  ------------------
  483|     33|      free_encrypted (pkt->pkt.encrypted);
  484|     33|      break;
  485|     34|    case PKT_PLAINTEXT:
  ------------------
  |  Branch (485:5): [True: 34, False: 7.48k]
  ------------------
  486|     34|      free_plaintext (pkt->pkt.plaintext);
  487|     34|      break;
  488|    405|    default:
  ------------------
  |  Branch (488:5): [True: 405, False: 7.11k]
  ------------------
  489|    405|      xfree (pkt->pkt.generic);
  ------------------
  |  |  104|    405|#define xfree(a)         gcry_free ((a))
  ------------------
  490|    405|      break;
  491|  7.52k|    }
  492|       |
  493|  7.52k|  pkt->pkt.generic = NULL;
  494|  7.52k|}
cmp_public_keys:
  502|     13|{
  503|     13|    int n, i;
  504|       |
  505|     13|    if( a->timestamp != b->timestamp )
  ------------------
  |  Branch (505:9): [True: 0, False: 13]
  ------------------
  506|      0|	return -1;
  507|     13|    if( a->version < 4 && a->expiredate != b->expiredate )
  ------------------
  |  Branch (507:9): [True: 0, False: 13]
  |  Branch (507:27): [True: 0, False: 0]
  ------------------
  508|      0|	return -1;
  509|     13|    if( a->pubkey_algo != b->pubkey_algo )
  ------------------
  |  Branch (509:9): [True: 0, False: 13]
  ------------------
  510|      0|	return -1;
  511|       |
  512|     13|    n = pubkey_get_npkey( b->pubkey_algo );
  513|     13|    if( !n ) { /* unknown algorithm, rest is in opaque MPI */
  ------------------
  |  Branch (513:9): [True: 0, False: 13]
  ------------------
  514|      0|	if( mpi_cmp( a->pkey[0], b->pkey[0] ) )
  515|      0|	    return -1; /* can't compare due to unknown algorithm */
  516|     13|    } else {
  517|     39|	for(i=0; i < n; i++ ) {
  ------------------
  |  Branch (517:11): [True: 26, False: 13]
  ------------------
  518|     26|	    if( mpi_cmp( a->pkey[i], b->pkey[i] ) )
  519|      0|		return -1;
  520|     26|	}
  521|     13|    }
  522|       |
  523|     13|    return 0;
  524|     13|}
cmp_signatures:
  530|     32|{
  531|     32|    int n, i;
  532|       |
  533|     32|    if( a->keyid[0] != b->keyid[0] )
  ------------------
  |  Branch (533:9): [True: 2, False: 30]
  ------------------
  534|      2|	return -1;
  535|     30|    if( a->keyid[1] != b->keyid[1] )
  ------------------
  |  Branch (535:9): [True: 0, False: 30]
  ------------------
  536|      0|	return -1;
  537|     30|    if( a->pubkey_algo != b->pubkey_algo )
  ------------------
  |  Branch (537:9): [True: 0, False: 30]
  ------------------
  538|      0|	return -1;
  539|       |
  540|     30|    n = pubkey_get_nsig( a->pubkey_algo );
  541|     30|    if( !n )
  ------------------
  |  Branch (541:9): [True: 0, False: 30]
  ------------------
  542|      0|	return -1; /* can't compare due to unknown algorithm */
  543|     32|    for(i=0; i < n; i++ ) {
  ------------------
  |  Branch (543:14): [True: 30, False: 2]
  ------------------
  544|     30|	if( mpi_cmp( a->data[i] , b->data[i] ) )
  545|     28|	    return -1;
  546|     30|    }
  547|      2|    return 0;
  548|     30|}
cmp_user_ids:
  556|     18|{
  557|     18|    int res=1;
  558|       |
  559|     18|    if( a == b )
  ------------------
  |  Branch (559:9): [True: 0, False: 18]
  ------------------
  560|      0|        return 0;
  561|       |
  562|     18|    if( a->attrib_data && b->attrib_data )
  ------------------
  |  Branch (562:9): [True: 0, False: 18]
  |  Branch (562:27): [True: 0, False: 0]
  ------------------
  563|      0|      {
  564|      0|	res = a->attrib_len - b->attrib_len;
  565|      0|	if( !res )
  ------------------
  |  Branch (565:6): [True: 0, False: 0]
  ------------------
  566|      0|	  res = memcmp( a->attrib_data, b->attrib_data, a->attrib_len );
  567|      0|      }
  568|     18|    else if( !a->attrib_data && !b->attrib_data )
  ------------------
  |  Branch (568:14): [True: 18, False: 0]
  |  Branch (568:33): [True: 18, False: 0]
  ------------------
  569|     18|      {
  570|     18|	res = a->len - b->len;
  571|     18|	if( !res )
  ------------------
  |  Branch (571:6): [True: 18, False: 0]
  ------------------
  572|     18|	  res = memcmp( a->name, b->name, a->len );
  573|     18|      }
  574|       |
  575|     18|    return res;
  576|     18|}
free-packet.c:my_mpi_copy:
   53|    825|{
   54|    825|  if (a
  ------------------
  |  Branch (54:7): [True: 825, False: 0]
  ------------------
   55|    825|      && gcry_mpi_get_flag (a, GCRYMPI_FLAG_OPAQUE)
  ------------------
  |  Branch (55:10): [True: 543, False: 282]
  ------------------
   56|    825|      && !gcry_mpi_get_opaque (a, NULL))
  ------------------
  |  Branch (56:10): [True: 0, False: 543]
  ------------------
   57|      0|    return NULL;
   58|       |
   59|    825|  if (is_mpi_copy_broken ())
  ------------------
  |  Branch (59:7): [True: 0, False: 825]
  ------------------
   60|      0|    {
   61|      0|      int flag_user2 = a? gcry_mpi_get_flag (a, GCRYMPI_FLAG_USER2) : 0;
  ------------------
  |  Branch (61:24): [True: 0, False: 0]
  ------------------
   62|      0|      gcry_mpi_t b;
   63|       |
   64|      0|      b = gcry_mpi_copy (a);
   65|      0|      if (b && flag_user2)
  ------------------
  |  Branch (65:11): [True: 0, False: 0]
  |  Branch (65:16): [True: 0, False: 0]
  ------------------
   66|      0|        gcry_mpi_set_flag (b, GCRYMPI_FLAG_USER2);
   67|      0|      return b;
   68|      0|    }
   69|       |
   70|    825|  return gcry_mpi_copy (a);
   71|    825|}
free-packet.c:is_mpi_copy_broken:
   37|    825|{
   38|    825|  static char result;
   39|       |
   40|    825|  if (!result)
  ------------------
  |  Branch (40:7): [True: 1, False: 824]
  ------------------
   41|      1|    {
   42|      1|      result = !gcry_check_version ("1.8.6");
   43|      1|      result |= 0x80;
   44|      1|    }
   45|    825|  return (result & 1);
   46|    825|}
free-packet.c:cp_subpktarea:
  175|    680|{
  176|    680|    subpktarea_t *d;
  177|       |
  178|    680|    if( !s )
  ------------------
  |  Branch (178:9): [True: 680, False: 0]
  ------------------
  179|    680|	return NULL;
  180|      0|    d = xmalloc (sizeof (*d) + s->size - 1 );
  ------------------
  |  |  107|      0|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  181|      0|    d->size = s->size;
  182|      0|    d->len = s->len;
  183|      0|    memcpy (d->data, s->data, s->len);
  184|      0|    return d;
  185|    680|}

getkey_disable_caches:
  264|     53|{
  265|     53|#if MAX_PK_CACHE_ENTRIES
  266|     53|  {
  267|     53|    pk_cache_entry_t ce, ce2;
  268|       |
  269|     53|    for (ce = pk_cache; ce; ce = ce2)
  ------------------
  |  Branch (269:25): [True: 0, False: 53]
  ------------------
  270|      0|      {
  271|      0|	ce2 = ce->next;
  272|      0|	free_public_key (ce->pk);
  273|      0|	xfree (ce);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  274|      0|      }
  275|     53|    pk_cache_disabled = 1;
  276|     53|    pk_cache_entries = 0;
  277|     53|    pk_cache = NULL;
  278|     53|  }
  279|     53|#endif
  280|       |  /* fixme: disable user id cache ? */
  281|     53|}
get_pubkey:
  360|  1.44k|{
  361|  1.44k|  int internal = 0;
  362|  1.44k|  int rc = 0;
  363|       |
  364|  1.44k|#if MAX_PK_CACHE_ENTRIES
  365|  1.44k|  if (pk)
  ------------------
  |  Branch (365:7): [True: 1.44k, False: 0]
  ------------------
  366|  1.44k|    {
  367|       |      /* Try to get it from the cache.  We don't do this when pk is
  368|       |         NULL as it does not guarantee that the user IDs are
  369|       |         cached. */
  370|  1.44k|      pk_cache_entry_t ce;
  371|  1.44k|      for (ce = pk_cache; ce; ce = ce->next)
  ------------------
  |  Branch (371:27): [True: 0, False: 1.44k]
  ------------------
  372|      0|	{
  373|      0|	  if (ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1])
  ------------------
  |  Branch (373:8): [True: 0, False: 0]
  |  Branch (373:36): [True: 0, False: 0]
  ------------------
  374|       |	    /* XXX: We don't check PK->REQ_USAGE here, but if we don't
  375|       |	       read from the cache, we do check it!  */
  376|      0|	    {
  377|      0|	      copy_public_key (pk, ce->pk);
  378|      0|	      return 0;
  379|      0|	    }
  380|      0|	}
  381|  1.44k|    }
  382|  1.44k|#endif
  383|       |  /* More init stuff.  */
  384|  1.44k|  if (!pk)
  ------------------
  |  Branch (384:7): [True: 0, False: 1.44k]
  ------------------
  385|      0|    {
  386|      0|      internal++;
  387|      0|      pk = xtrycalloc (1, sizeof *pk);
  ------------------
  |  |   99|      0|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  388|      0|      if (!pk)
  ------------------
  |  Branch (388:11): [True: 0, False: 0]
  ------------------
  389|      0|        {
  390|      0|          rc = gpg_error_from_syserror ();
  391|      0|          goto leave;
  392|      0|        }
  393|      0|    }
  394|       |
  395|       |
  396|       |  /* Do a lookup.  */
  397|  1.44k|  {
  398|  1.44k|    struct getkey_ctx_s ctx;
  399|  1.44k|    kbnode_t kb = NULL;
  400|  1.44k|    kbnode_t found_key = NULL;
  401|       |
  402|  1.44k|    memset (&ctx, 0, sizeof ctx);
  403|  1.44k|    ctx.exact = 1; /* Use the key ID exactly as given.  */
  404|  1.44k|    ctx.not_allocated = 1;
  405|       |
  406|  1.44k|    if (ctrl && ctrl->cached_getkey_kdb)
  ------------------
  |  Branch (406:9): [True: 1.44k, False: 0]
  |  Branch (406:17): [True: 1.43k, False: 13]
  ------------------
  407|  1.43k|      {
  408|  1.43k|        ctx.kr_handle = ctrl->cached_getkey_kdb;
  409|  1.43k|        ctrl->cached_getkey_kdb = NULL;
  410|  1.43k|        keydb_search_reset (ctx.kr_handle);
  411|  1.43k|      }
  412|     13|    else
  413|     13|      {
  414|     13|        ctx.kr_handle = keydb_new (ctrl);
  415|     13|        if (!ctx.kr_handle)
  ------------------
  |  Branch (415:13): [True: 0, False: 13]
  ------------------
  416|      0|          {
  417|      0|            rc = gpg_error_from_syserror ();
  418|      0|            goto leave;
  419|      0|          }
  420|     13|      }
  421|  1.44k|    ctx.nitems = 1;
  422|  1.44k|    ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID;
  423|  1.44k|    ctx.items[0].u.kid[0] = keyid[0];
  424|  1.44k|    ctx.items[0].u.kid[1] = keyid[1];
  425|  1.44k|    ctx.req_usage = pk->req_usage;
  426|  1.44k|    rc = lookup (ctrl, &ctx, 0, &kb, &found_key);
  427|  1.44k|    if (!rc)
  ------------------
  |  Branch (427:9): [True: 0, False: 1.44k]
  ------------------
  428|      0|      {
  429|      0|	pk_from_block (pk, kb, found_key);
  430|      0|      }
  431|  1.44k|    getkey_end (ctrl, &ctx);
  432|  1.44k|    release_kbnode (kb);
  433|  1.44k|  }
  434|  1.44k|  if (!rc)
  ------------------
  |  Branch (434:7): [True: 0, False: 1.44k]
  ------------------
  435|      0|    goto leave;
  436|       |
  437|  1.44k|  rc = GPG_ERR_NO_PUBKEY;
  438|       |
  439|  1.44k|leave:
  440|  1.44k|  if (!rc)
  ------------------
  |  Branch (440:7): [True: 0, False: 1.44k]
  ------------------
  441|      0|    cache_public_key (pk);
  442|  1.44k|  if (internal)
  ------------------
  |  Branch (442:7): [True: 0, False: 1.44k]
  ------------------
  443|      0|    free_public_key (pk);
  444|  1.44k|  return rc;
  445|  1.44k|}
get_pubkey_fast:
  496|     37|{
  497|     37|  int rc = 0;
  498|     37|  KEYDB_HANDLE hd;
  499|     37|  KBNODE keyblock;
  500|     37|  u32 pkid[2];
  501|       |
  502|     37|  log_assert (pk);
  503|      0|#if MAX_PK_CACHE_ENTRIES
  504|      0|  {
  505|       |    /* Try to get it from the cache */
  506|     37|    pk_cache_entry_t ce;
  507|       |
  508|     37|    for (ce = pk_cache; ce; ce = ce->next)
  ------------------
  |  Branch (508:25): [True: 0, False: 37]
  ------------------
  509|      0|      {
  510|      0|	if (ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1]
  ------------------
  |  Branch (510:6): [True: 0, False: 0]
  |  Branch (510:34): [True: 0, False: 0]
  ------------------
  511|       |	    /* Only consider primary keys.  */
  512|      0|	    && ce->pk->keyid[0] == ce->pk->main_keyid[0]
  ------------------
  |  Branch (512:9): [True: 0, False: 0]
  ------------------
  513|      0|	    && ce->pk->keyid[1] == ce->pk->main_keyid[1])
  ------------------
  |  Branch (513:9): [True: 0, False: 0]
  ------------------
  514|      0|	  {
  515|      0|	    if (pk)
  ------------------
  |  Branch (515:10): [True: 0, False: 0]
  ------------------
  516|      0|	      copy_public_key (pk, ce->pk);
  517|      0|	    return 0;
  518|      0|	  }
  519|      0|      }
  520|     37|  }
  521|     37|#endif
  522|       |
  523|     37|  hd = keydb_new (ctrl);
  524|     37|  if (!hd)
  ------------------
  |  Branch (524:7): [True: 0, False: 37]
  ------------------
  525|      0|    return gpg_error_from_syserror ();
  526|     37|  rc = keydb_search_kid (hd, keyid);
  527|     37|  if (gpg_err_code (rc) == GPG_ERR_NOT_FOUND)
  ------------------
  |  Branch (527:7): [True: 37, False: 0]
  ------------------
  528|     37|    {
  529|     37|      keydb_release (hd);
  530|     37|      return GPG_ERR_NO_PUBKEY;
  531|     37|    }
  532|      0|  rc = keydb_get_keyblock (hd, &keyblock);
  533|      0|  keydb_release (hd);
  534|      0|  if (rc)
  ------------------
  |  Branch (534:7): [True: 0, False: 0]
  ------------------
  535|      0|    {
  536|      0|      log_error ("keydb_get_keyblock failed: %s\n", gpg_strerror (rc));
  537|      0|      return GPG_ERR_NO_PUBKEY;
  538|      0|    }
  539|       |
  540|      0|  log_assert (keyblock && keyblock->pkt
  541|      0|              && keyblock->pkt->pkttype == PKT_PUBLIC_KEY);
  542|       |
  543|       |  /* We return the primary key.  If KEYID matched a subkey, then we
  544|       |     return an error.  */
  545|      0|  keyid_from_pk (keyblock->pkt->pkt.public_key, pkid);
  546|      0|  if (keyid[0] == pkid[0] && keyid[1] == pkid[1])
  ------------------
  |  Branch (546:7): [True: 0, False: 0]
  |  Branch (546:30): [True: 0, False: 0]
  ------------------
  547|      0|    copy_public_key (pk, keyblock->pkt->pkt.public_key);
  548|      0|  else
  549|      0|    rc = GPG_ERR_NO_PUBKEY;
  550|       |
  551|      0|  release_kbnode (keyblock);
  552|       |
  553|       |  /* Not caching key here since it won't have all of the fields
  554|       |     properly set. */
  555|       |
  556|      0|  return rc;
  557|      0|}
get_pubkey_byfprint:
 1836|    176|{
 1837|    176|  int rc;
 1838|       |
 1839|    176|  if (r_keyblock)
  ------------------
  |  Branch (1839:7): [True: 172, False: 4]
  ------------------
 1840|    172|    *r_keyblock = NULL;
 1841|       |
 1842|    176|  if (fprint_len == 32 || fprint_len == 20 || fprint_len == 16)
  ------------------
  |  Branch (1842:7): [True: 1, False: 175]
  |  Branch (1842:27): [True: 175, False: 0]
  |  Branch (1842:47): [True: 0, False: 0]
  ------------------
 1843|    176|    {
 1844|    176|      struct getkey_ctx_s ctx;
 1845|    176|      KBNODE kb = NULL;
 1846|    176|      KBNODE found_key = NULL;
 1847|       |
 1848|    176|      memset (&ctx, 0, sizeof ctx);
 1849|    176|      ctx.exact = 1;
 1850|    176|      ctx.not_allocated = 1;
 1851|       |      /* FIXME: We should get the handle from the cache like we do in
 1852|       |       * get_pubkey.  */
 1853|    176|      ctx.kr_handle = keydb_new (ctrl);
 1854|    176|      if (!ctx.kr_handle)
  ------------------
  |  Branch (1854:11): [True: 0, False: 176]
  ------------------
 1855|      0|        return gpg_error_from_syserror ();
 1856|       |
 1857|    176|      ctx.nitems = 1;
 1858|    176|      ctx.items[0].mode = KEYDB_SEARCH_MODE_FPR;
 1859|    176|      memcpy (ctx.items[0].u.fpr, fprint, fprint_len);
 1860|    176|      ctx.items[0].fprlen = fprint_len;
 1861|    176|      if (pk)
  ------------------
  |  Branch (1861:11): [True: 0, False: 176]
  ------------------
 1862|      0|        ctx.req_usage = pk->req_usage;
 1863|    176|      rc = lookup (ctrl, &ctx, 0, &kb, &found_key);
 1864|    176|      if (!rc && pk)
  ------------------
  |  Branch (1864:11): [True: 4, False: 172]
  |  Branch (1864:18): [True: 0, False: 4]
  ------------------
 1865|      0|	pk_from_block (pk, kb, found_key);
 1866|    176|      if (!rc && r_keyblock)
  ------------------
  |  Branch (1866:11): [True: 4, False: 172]
  |  Branch (1866:18): [True: 0, False: 4]
  ------------------
 1867|      0|	{
 1868|      0|	  *r_keyblock = kb;
 1869|      0|	  kb = NULL;
 1870|      0|	}
 1871|    176|      release_kbnode (kb);
 1872|    176|      getkey_end (ctrl, &ctx);
 1873|    176|    }
 1874|      0|  else
 1875|      0|    rc = GPG_ERR_GENERAL; /* Oops */
 1876|    176|  return rc;
 1877|    176|}
get_keyblock_byfprint_fast:
 1921|     11|{
 1922|     11|  gpg_error_t err;
 1923|     11|  KEYDB_HANDLE hd;
 1924|     11|  kbnode_t keyblock;
 1925|     11|  byte fprbuf[MAX_FINGERPRINT_LEN];
 1926|     11|  int i;
 1927|       |
 1928|     11|  if (r_keyblock)
  ------------------
  |  Branch (1928:7): [True: 11, False: 0]
  ------------------
 1929|     11|    *r_keyblock = NULL;
 1930|     11|  if (r_hd)
  ------------------
  |  Branch (1930:7): [True: 11, False: 0]
  ------------------
 1931|     11|    *r_hd = NULL;
 1932|       |
 1933|    231|  for (i = 0; i < MAX_FINGERPRINT_LEN && i < fprint_len; i++)
  ------------------
  |  |   49|    462|#define MAX_FINGERPRINT_LEN 32
  ------------------
  |  Branch (1933:15): [True: 231, False: 0]
  |  Branch (1933:42): [True: 220, False: 11]
  ------------------
 1934|    220|    fprbuf[i] = fprint[i];
 1935|       |
 1936|     11|  hd = keydb_new (ctrl);
 1937|     11|  if (!hd)
  ------------------
  |  Branch (1937:7): [True: 0, False: 11]
  ------------------
 1938|      0|    return gpg_error_from_syserror ();
 1939|       |
 1940|     11|  if (lock)
  ------------------
  |  Branch (1940:7): [True: 11, False: 0]
  ------------------
 1941|     11|    {
 1942|     11|      err = keydb_lock (hd);
 1943|     11|      if (err)
  ------------------
  |  Branch (1943:11): [True: 0, False: 11]
  ------------------
 1944|      0|        {
 1945|       |          /* If locking did not work, we better don't return a handle
 1946|       |           * at all - there was a reason that locking has been
 1947|       |           * requested.  */
 1948|      0|          keydb_release (hd);
 1949|      0|          return err;
 1950|      0|        }
 1951|     11|      keydb_disable_caching (hd);
 1952|     11|    }
 1953|       |
 1954|       |  /* For all other errors we return the handle.  */
 1955|     11|  if (r_hd)
  ------------------
  |  Branch (1955:7): [True: 11, False: 0]
  ------------------
 1956|     11|    *r_hd = hd;
 1957|       |
 1958|     11|  err = keydb_search_fpr (hd, fprbuf, fprint_len);
 1959|     11|  if (gpg_err_code (err) == GPG_ERR_NOT_FOUND)
  ------------------
  |  Branch (1959:7): [True: 2, False: 9]
  ------------------
 1960|      2|    {
 1961|      2|      if (!r_hd)
  ------------------
  |  Branch (1961:11): [True: 0, False: 2]
  ------------------
 1962|      0|        keydb_release (hd);
 1963|      2|      return gpg_error (GPG_ERR_NO_PUBKEY);
 1964|      2|    }
 1965|      9|  err = keydb_get_keyblock (hd, &keyblock);
 1966|      9|  if (err)
  ------------------
  |  Branch (1966:7): [True: 0, False: 9]
  ------------------
 1967|      0|    {
 1968|      0|      log_error ("keydb_get_keyblock failed: %s\n", gpg_strerror (err));
 1969|      0|      if (!r_hd)
  ------------------
  |  Branch (1969:11): [True: 0, False: 0]
  ------------------
 1970|      0|        keydb_release (hd);
 1971|      0|      return gpg_error (GPG_ERR_NO_PUBKEY);
 1972|      0|    }
 1973|       |
 1974|      9|  log_assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY
 1975|      9|              || keyblock->pkt->pkttype == PKT_PUBLIC_SUBKEY);
 1976|       |
 1977|       |  /* Not caching key here since it won't have all of the fields
 1978|       |     properly set. */
 1979|       |
 1980|      9|  if (r_keyblock)
  ------------------
  |  Branch (1980:7): [True: 9, False: 0]
  ------------------
 1981|      9|    *r_keyblock = keyblock;
 1982|      0|  else
 1983|      0|    release_kbnode (keyblock);
 1984|       |
 1985|      9|  if (!r_hd)
  ------------------
  |  Branch (1985:7): [True: 0, False: 9]
  ------------------
 1986|      0|    keydb_release (hd);
 1987|       |
 1988|      9|  return 0;
 1989|      9|}
getkey_end:
 2333|  1.62k|{
 2334|  1.62k|  if (ctx)
  ------------------
  |  Branch (2334:7): [True: 1.62k, False: 0]
  ------------------
 2335|  1.62k|    {
 2336|       |#ifdef HAVE_W32_SYSTEM
 2337|       |
 2338|       |      /* FIXME: This creates a big regression for Windows because the
 2339|       |       * keyring is only released after the global ctrl is released.
 2340|       |       * So if an operation does a getkey and then tries to modify the
 2341|       |       * keyring it will fail on Windows with a sharing violation.  We
 2342|       |       * need to modify all keyring write operations to also take the
 2343|       |       * ctrl and close the cached_getkey_kdb handle to make writing
 2344|       |       * work.  See: GnuPG-bug-id: 3097  */
 2345|       |      (void)ctrl;
 2346|       |      keydb_release (ctx->kr_handle);
 2347|       |
 2348|       |#else /*!HAVE_W32_SYSTEM*/
 2349|       |
 2350|  1.62k|      if (ctrl && !ctrl->cached_getkey_kdb)
  ------------------
  |  Branch (2350:11): [True: 1.62k, False: 0]
  |  Branch (2350:19): [True: 1.45k, False: 173]
  ------------------
 2351|  1.45k|        ctrl->cached_getkey_kdb = ctx->kr_handle;
 2352|    173|      else
 2353|    173|        keydb_release (ctx->kr_handle);
 2354|       |
 2355|  1.62k|#endif /*!HAVE_W32_SYSTEM*/
 2356|       |
 2357|  1.62k|      free_strlist (ctx->extra_list);
 2358|  1.62k|      if (!ctx->not_allocated)
  ------------------
  |  Branch (2358:11): [True: 0, False: 1.62k]
  ------------------
 2359|      0|	xfree (ctx);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2360|  1.62k|    }
 2361|  1.62k|}
merge_keys_and_selfsig:
 2410|     11|{
 2411|     11|  if (!keyblock)
  ------------------
  |  Branch (2411:7): [True: 0, False: 11]
  ------------------
 2412|      0|    ;
 2413|     11|  else if (keyblock->pkt->pkttype == PKT_PUBLIC_KEY)
  ------------------
  |  Branch (2413:12): [True: 11, False: 0]
  ------------------
 2414|     11|    merge_selfsigs (ctrl, keyblock);
 2415|      0|  else
 2416|      0|    log_debug ("FIXME: merging secret key blocks is not anymore available\n");
 2417|     11|}
get_user_id_byfpr_native:
 4232|     11|{
 4233|     11|  size_t rn;
 4234|     11|  char *p = get_user_id_byfpr (ctrl, fpr, fprlen, &rn);
 4235|     11|  char *p2 = utf8_to_native (p, rn, 0);
 4236|     11|  xfree (p);
  ------------------
  |  |  104|     11|#define xfree(a)         gcry_free ((a))
  ------------------
 4237|     11|  return p2;
 4238|     11|}
have_secret_key_with_kid:
 4451|    139|{
 4452|    139|  gpg_error_t err;
 4453|    139|  KEYDB_HANDLE kdbhd;
 4454|    139|  KEYDB_SEARCH_DESC desc;
 4455|    139|  kbnode_t keyblock;
 4456|    139|  kbnode_t node;
 4457|    139|  int result = 0;
 4458|       |
 4459|    139|  kdbhd = keydb_new (ctrl);
 4460|    139|  if (!kdbhd)
  ------------------
  |  Branch (4460:7): [True: 0, False: 139]
  ------------------
 4461|      0|    return 0;
 4462|    139|  memset (&desc, 0, sizeof desc);
 4463|    139|  desc.mode = KEYDB_SEARCH_MODE_LONG_KID;
 4464|    139|  desc.u.kid[0] = keyid[0];
 4465|    139|  desc.u.kid[1] = keyid[1];
 4466|    150|  while (!result)
  ------------------
  |  Branch (4466:10): [True: 139, False: 11]
  ------------------
 4467|    139|    {
 4468|    139|      err = keydb_search (kdbhd, &desc, 1, NULL);
 4469|    139|      if (err)
  ------------------
  |  Branch (4469:11): [True: 128, False: 11]
  ------------------
 4470|    128|        break;
 4471|       |
 4472|     11|      err = keydb_get_keyblock (kdbhd, &keyblock);
 4473|     11|      if (err)
  ------------------
  |  Branch (4473:11): [True: 0, False: 11]
  ------------------
 4474|      0|        {
 4475|      0|          log_error (_("error reading keyblock: %s\n"), gpg_strerror (err));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 4476|      0|          break;
 4477|      0|        }
 4478|       |
 4479|     11|      for (node = keyblock; node; node = node->next)
  ------------------
  |  Branch (4479:29): [True: 11, False: 0]
  ------------------
 4480|     11|	{
 4481|       |          /* Bit 0 of the flags is set if the search found the key
 4482|       |             using that key or subkey.  Note: a search will only ever
 4483|       |             match a single key or subkey.  */
 4484|     11|	  if ((node->flag & 1))
  ------------------
  |  Branch (4484:8): [True: 11, False: 0]
  ------------------
 4485|     11|            {
 4486|     11|              log_assert (node->pkt->pkttype == PKT_PUBLIC_KEY
 4487|     11|                          || node->pkt->pkttype == PKT_PUBLIC_SUBKEY);
 4488|       |
 4489|     11|              if (agent_probe_secret_key (NULL, node->pkt->pkt.public_key))
  ------------------
  |  Branch (4489:19): [True: 11, False: 0]
  ------------------
 4490|     11|		result = 1; /* Secret key available.  */
 4491|      0|	      else
 4492|      0|		result = 0;
 4493|       |
 4494|     11|	      break;
 4495|     11|	    }
 4496|     11|	}
 4497|     11|      release_kbnode (keyblock);
 4498|     11|    }
 4499|       |
 4500|    139|  keydb_release (kdbhd);
 4501|    139|  return result;
 4502|    139|}
getkey.c:merge_selfsigs:
 3450|     15|{
 3451|     15|  KBNODE k;
 3452|     15|  int revoked;
 3453|     15|  struct revoke_info rinfo;
 3454|     15|  PKT_public_key *main_pk;
 3455|     15|  prefitem_t *prefs;
 3456|     15|  unsigned int mdc_feature;
 3457|     15|  unsigned int aead_feature;
 3458|       |
 3459|     15|  if (keyblock->pkt->pkttype != PKT_PUBLIC_KEY)
  ------------------
  |  Branch (3459:7): [True: 0, False: 15]
  ------------------
 3460|      0|    {
 3461|      0|      if (keyblock->pkt->pkttype == PKT_SECRET_KEY)
  ------------------
  |  Branch (3461:11): [True: 0, False: 0]
  ------------------
 3462|      0|	{
 3463|      0|	  log_error ("expected public key but found secret key "
 3464|      0|		     "- must stop\n");
 3465|       |	  /* We better exit here because a public key is expected at
 3466|       |	   * other places too.  FIXME: Figure this out earlier and
 3467|       |	   * don't get to here at all */
 3468|      0|	  g10_exit (1);
 3469|      0|	}
 3470|      0|      BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 3471|      0|    }
 3472|       |
 3473|     15|  merge_selfsigs_main (ctrl, keyblock, &revoked, &rinfo);
 3474|       |
 3475|       |  /* Now merge in the data from each of the subkeys.  */
 3476|    134|  for (k = keyblock; k; k = k->next)
  ------------------
  |  Branch (3476:22): [True: 119, False: 15]
  ------------------
 3477|    119|    {
 3478|    119|      if (k->pkt->pkttype == PKT_PUBLIC_SUBKEY)
  ------------------
  |  Branch (3478:11): [True: 6, False: 113]
  ------------------
 3479|      6|	{
 3480|      6|	  merge_selfsigs_subkey (ctrl, keyblock, k);
 3481|      6|	}
 3482|    119|    }
 3483|       |
 3484|     15|  main_pk = keyblock->pkt->pkt.public_key;
 3485|     15|  if (revoked || main_pk->has_expired || !main_pk->flags.valid)
  ------------------
  |  Branch (3485:7): [True: 0, False: 15]
  |  Branch (3485:18): [True: 0, False: 15]
  |  Branch (3485:42): [True: 15, False: 0]
  ------------------
 3486|     15|    {
 3487|       |      /* If the primary key is revoked, expired, or invalid we
 3488|       |       * better set the appropriate flags on that key and all
 3489|       |       * subkeys.  */
 3490|    134|      for (k = keyblock; k; k = k->next)
  ------------------
  |  Branch (3490:26): [True: 119, False: 15]
  ------------------
 3491|    119|	{
 3492|    119|	  if (k->pkt->pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (3492:8): [True: 15, False: 104]
  ------------------
 3493|    119|	      || k->pkt->pkttype == PKT_PUBLIC_SUBKEY)
  ------------------
  |  Branch (3493:11): [True: 6, False: 98]
  ------------------
 3494|     21|	    {
 3495|     21|	      PKT_public_key *pk = k->pkt->pkt.public_key;
 3496|     21|	      if (!main_pk->flags.valid)
  ------------------
  |  Branch (3496:12): [True: 21, False: 0]
  ------------------
 3497|     21|		pk->flags.valid = 0;
 3498|     21|	      if (revoked && !pk->flags.revoked)
  ------------------
  |  Branch (3498:12): [True: 0, False: 21]
  |  Branch (3498:23): [True: 0, False: 0]
  ------------------
 3499|      0|		{
 3500|      0|		  pk->flags.revoked = revoked;
 3501|      0|		  memcpy (&pk->revoked, &rinfo, sizeof (rinfo));
 3502|      0|		}
 3503|     21|	      if (main_pk->has_expired)
  ------------------
  |  Branch (3503:12): [True: 0, False: 21]
  ------------------
 3504|      0|		{
 3505|      0|		  pk->has_expired = main_pk->has_expired;
 3506|      0|		  if (!pk->expiredate || pk->expiredate > main_pk->expiredate)
  ------------------
  |  Branch (3506:9): [True: 0, False: 0]
  |  Branch (3506:28): [True: 0, False: 0]
  ------------------
 3507|      0|		    pk->expiredate = main_pk->expiredate;
 3508|      0|		}
 3509|     21|	    }
 3510|    119|	}
 3511|     15|      return;
 3512|     15|    }
 3513|       |
 3514|       |  /* Set the preference list of all keys to those of the primary real
 3515|       |   * user ID.  Note: we use these preferences when we don't know by
 3516|       |   * which user ID the key has been selected.
 3517|       |   * fixme: we should keep atoms of commonly used preferences or
 3518|       |   * use reference counting to optimize the preference lists storage.
 3519|       |   * FIXME: it might be better to use the intersection of
 3520|       |   * all preferences.
 3521|       |   * Do a similar thing for the MDC feature flag.  */
 3522|      0|  prefs = NULL;
 3523|      0|  mdc_feature = aead_feature = 0;
 3524|      0|  for (k = keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY; k = k->next)
  ------------------
  |  Branch (3524:22): [True: 0, False: 0]
  |  Branch (3524:27): [True: 0, False: 0]
  ------------------
 3525|      0|    {
 3526|      0|      if (k->pkt->pkttype == PKT_USER_ID
  ------------------
  |  Branch (3526:11): [True: 0, False: 0]
  ------------------
 3527|      0|	  && !k->pkt->pkt.user_id->attrib_data
  ------------------
  |  Branch (3527:7): [True: 0, False: 0]
  ------------------
 3528|      0|	  && k->pkt->pkt.user_id->flags.primary)
  ------------------
  |  Branch (3528:7): [True: 0, False: 0]
  ------------------
 3529|      0|	{
 3530|      0|	  prefs = k->pkt->pkt.user_id->prefs;
 3531|      0|	  mdc_feature = k->pkt->pkt.user_id->flags.mdc;
 3532|      0|	  aead_feature = k->pkt->pkt.user_id->flags.aead;
 3533|      0|	  break;
 3534|      0|	}
 3535|      0|    }
 3536|      0|  for (k = keyblock; k; k = k->next)
  ------------------
  |  Branch (3536:22): [True: 0, False: 0]
  ------------------
 3537|      0|    {
 3538|      0|      if (k->pkt->pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (3538:11): [True: 0, False: 0]
  ------------------
 3539|      0|	  || k->pkt->pkttype == PKT_PUBLIC_SUBKEY)
  ------------------
  |  Branch (3539:7): [True: 0, False: 0]
  ------------------
 3540|      0|	{
 3541|      0|	  PKT_public_key *pk = k->pkt->pkt.public_key;
 3542|      0|	  if (pk->prefs)
  ------------------
  |  Branch (3542:8): [True: 0, False: 0]
  ------------------
 3543|      0|	    xfree (pk->prefs);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 3544|      0|	  pk->prefs = copy_prefs (prefs);
 3545|      0|	  pk->flags.mdc = mdc_feature;
 3546|      0|	  pk->flags.aead = aead_feature;
 3547|      0|	}
 3548|      0|    }
 3549|      0|}
getkey.c:merge_selfsigs_main:
 2669|     15|{
 2670|     15|  PKT_public_key *pk = NULL;
 2671|     15|  KBNODE k;
 2672|     15|  u32 kid[2];
 2673|     15|  u32 sigdate, uiddate, uiddate2;
 2674|     15|  KBNODE signode, uidnode, uidnode2;
 2675|     15|  u32 curtime = make_timestamp ();
 2676|     15|  unsigned int key_usage = 0;
 2677|     15|  u32 keytimestamp = 0;  /* Creation time of the key.  */
 2678|     15|  u32 key_expire = 0;
 2679|     15|  int key_expire_seen = 0;
 2680|     15|  byte sigversion = 0;
 2681|       |
 2682|     15|  *r_revoked = 0;
 2683|     15|  memset (rinfo, 0, sizeof (*rinfo));
 2684|       |
 2685|       |  /* Section 11.1 of RFC 4880 determines the order of packets within a
 2686|       |   * message.  There are three sections, which must occur in the
 2687|       |   * following order: the public key, the user ids and user attributes
 2688|       |   * and the subkeys.  Within each section, each primary packet (e.g.,
 2689|       |   * a user id packet) is followed by one or more signature packets,
 2690|       |   * which modify that packet.  */
 2691|       |
 2692|       |  /* According to Section 11.1 of RFC 4880, the public key must be the
 2693|       |     first packet.  Note that parse_keyblock_image ensures that the
 2694|       |     first packet is the public key.  */
 2695|     15|  if (keyblock->pkt->pkttype != PKT_PUBLIC_KEY)
  ------------------
  |  Branch (2695:7): [True: 0, False: 15]
  ------------------
 2696|      0|    BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 2697|     15|  pk = keyblock->pkt->pkt.public_key;
 2698|     15|  keytimestamp = pk->timestamp;
 2699|       |
 2700|     15|  keyid_from_pk (pk, kid);
 2701|     15|  pk->main_keyid[0] = kid[0];
 2702|     15|  pk->main_keyid[1] = kid[1];
 2703|       |
 2704|     15|  if (pk->version < 4)
  ------------------
  |  Branch (2704:7): [True: 0, False: 15]
  ------------------
 2705|      0|    {
 2706|       |      /* Before v4 the key packet itself contains the expiration date
 2707|       |       * and there was no way to change it, so we start with the one
 2708|       |       * from the key packet.  We do not support v3 keys anymore but
 2709|       |       * we keep the code in case a future key versions introduces a
 2710|       |       * hadr expire time again. */
 2711|      0|      key_expire = pk->max_expiredate;
 2712|      0|      key_expire_seen = 1;
 2713|      0|    }
 2714|       |
 2715|       |  /* First pass:
 2716|       |   *
 2717|       |   * - Find the latest direct key self-signature.  We assume that the
 2718|       |   *   newest one overrides all others.
 2719|       |   *
 2720|       |   * - Determine whether the key has been revoked.
 2721|       |   *
 2722|       |   * - Gather all revocation keys (unlike other data, we don't just
 2723|       |   *   take them from the latest self-signed packet).
 2724|       |   *
 2725|       |   * - Determine max (sig[...]->version).
 2726|       |   */
 2727|       |
 2728|       |  /* Reset this in case this key was already merged. */
 2729|     15|  xfree (pk->revkey);
  ------------------
  |  |  104|     15|#define xfree(a)         gcry_free ((a))
  ------------------
 2730|     15|  pk->revkey = NULL;
 2731|     15|  pk->numrevkeys = 0;
 2732|       |
 2733|     15|  signode = NULL;
 2734|     15|  sigdate = 0; /* Helper variable to find the latest signature.  */
 2735|       |
 2736|       |  /* According to Section 11.1 of RFC 4880, the public key comes first
 2737|       |   * and is immediately followed by any signature packets that modify
 2738|       |   * it.  */
 2739|     15|  for (k = keyblock;
 2740|     40|       k && k->pkt->pkttype != PKT_USER_ID
  ------------------
  |  Branch (2740:8): [True: 40, False: 0]
  |  Branch (2740:13): [True: 31, False: 9]
  ------------------
 2741|     40|	 && k->pkt->pkttype != PKT_ATTRIBUTE
  ------------------
  |  Branch (2741:6): [True: 31, False: 0]
  ------------------
 2742|     40|	 && k->pkt->pkttype != PKT_PUBLIC_SUBKEY;
  ------------------
  |  Branch (2742:6): [True: 25, False: 6]
  ------------------
 2743|     25|       k = k->next)
 2744|     25|    {
 2745|     25|      if (k->pkt->pkttype == PKT_SIGNATURE)
  ------------------
  |  Branch (2745:11): [True: 10, False: 15]
  ------------------
 2746|     10|	{
 2747|     10|	  PKT_signature *sig = k->pkt->pkt.signature;
 2748|     10|	  if (sig->keyid[0] == kid[0] && sig->keyid[1] == kid[1])
  ------------------
  |  Branch (2748:8): [True: 0, False: 10]
  |  Branch (2748:35): [True: 0, False: 0]
  ------------------
 2749|      0|	    { /* Self sig.  */
 2750|       |
 2751|      0|	      if (check_key_signature (ctrl, keyblock, k, NULL))
  ------------------
  |  Branch (2751:12): [True: 0, False: 0]
  ------------------
 2752|      0|		; /* Signature did not verify.  */
 2753|      0|	      else if (IS_KEY_REV (sig))
  ------------------
  |  |   45|      0|#define IS_KEY_REV(s)    ((s)->sig_class == 0x20)
  |  |  ------------------
  |  |  |  Branch (45:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2754|      0|		{
 2755|       |		  /* Key has been revoked - there is no way to
 2756|       |		   * override such a revocation, so we theoretically
 2757|       |		   * can stop now.  We should not cope with expiration
 2758|       |		   * times for revocations here because we have to
 2759|       |		   * assume that an attacker can generate all kinds of
 2760|       |		   * signatures.  However due to the fact that the key
 2761|       |		   * has been revoked it does not harm either and by
 2762|       |		   * continuing we gather some more info on that
 2763|       |		   * key.  */
 2764|      0|		  *r_revoked = 1;
 2765|      0|		  sig_to_revoke_info (sig, rinfo);
 2766|      0|		}
 2767|      0|	      else if (IS_KEY_SIG (sig))
  ------------------
  |  |   40|      0|#define IS_KEY_SIG(s)    ((s)->sig_class == 0x1f)
  |  |  ------------------
  |  |  |  Branch (40:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2768|      0|		{
 2769|       |		  /* Add the indicated revocations keys from all
 2770|       |		   * signatures not just the latest.  We do this
 2771|       |		   * because you need multiple 1F sigs to properly
 2772|       |		   * handle revocation keys (PGP does it this way, and
 2773|       |		   * a revocation key could be sensitive and hence in
 2774|       |		   * a different signature).  */
 2775|      0|		  if (sig->revkey)
  ------------------
  |  Branch (2775:9): [True: 0, False: 0]
  ------------------
 2776|      0|		    {
 2777|      0|		      int i;
 2778|       |
 2779|      0|		      pk->revkey =
 2780|      0|			xrealloc (pk->revkey, sizeof (struct revocation_key) *
  ------------------
  |  |  111|      0|#define xrealloc(a,b)    gcry_xrealloc ((a),(b))
  ------------------
 2781|      0|				  (pk->numrevkeys + sig->numrevkeys));
 2782|       |
 2783|      0|		      for (i = 0; i < sig->numrevkeys; i++, pk->numrevkeys++)
  ------------------
  |  Branch (2783:21): [True: 0, False: 0]
  ------------------
 2784|      0|                        {
 2785|      0|                          pk->revkey[pk->numrevkeys].class
 2786|      0|                            = sig->revkey[i].class;
 2787|      0|                          pk->revkey[pk->numrevkeys].algid
 2788|      0|                            = sig->revkey[i].algid;
 2789|      0|                          pk->revkey[pk->numrevkeys].fprlen
 2790|      0|                            = sig->revkey[i].fprlen;
 2791|      0|                          memcpy (pk->revkey[pk->numrevkeys].fpr,
 2792|      0|                                  sig->revkey[i].fpr, sig->revkey[i].fprlen);
 2793|      0|                          memset (pk->revkey[pk->numrevkeys].fpr
 2794|      0|                                  + sig->revkey[i].fprlen,
 2795|      0|                                  0,
 2796|      0|                                  sizeof (sig->revkey[i].fpr)
 2797|      0|                                  - sig->revkey[i].fprlen);
 2798|      0|                        }
 2799|      0|		    }
 2800|       |
 2801|      0|		  if (sig->timestamp >= sigdate)
  ------------------
  |  Branch (2801:9): [True: 0, False: 0]
  ------------------
 2802|      0|		    { /* This is the latest signature so far.  */
 2803|       |
 2804|      0|		      if (sig->flags.expired)
  ------------------
  |  Branch (2804:13): [True: 0, False: 0]
  ------------------
 2805|      0|			; /* Signature has expired - ignore it.  */
 2806|      0|		      else
 2807|      0|			{
 2808|      0|			  sigdate = sig->timestamp;
 2809|      0|			  signode = k;
 2810|      0|			  if (sig->version > sigversion)
  ------------------
  |  Branch (2810:10): [True: 0, False: 0]
  ------------------
 2811|      0|			    sigversion = sig->version;
 2812|       |
 2813|      0|			}
 2814|      0|		    }
 2815|      0|		}
 2816|      0|	    }
 2817|     10|	}
 2818|     25|    }
 2819|       |
 2820|       |  /* Remove dupes from the revocation keys.  */
 2821|     15|  if (pk->revkey)
  ------------------
  |  Branch (2821:7): [True: 0, False: 15]
  ------------------
 2822|      0|    {
 2823|      0|      int i, j, x, changed = 0;
 2824|       |
 2825|      0|      for (i = 0; i < pk->numrevkeys; i++)
  ------------------
  |  Branch (2825:19): [True: 0, False: 0]
  ------------------
 2826|      0|	{
 2827|      0|	  for (j = i + 1; j < pk->numrevkeys; j++)
  ------------------
  |  Branch (2827:20): [True: 0, False: 0]
  ------------------
 2828|      0|	    {
 2829|      0|	      if (memcmp (&pk->revkey[i], &pk->revkey[j],
  ------------------
  |  Branch (2829:12): [True: 0, False: 0]
  ------------------
 2830|      0|			  sizeof (struct revocation_key)) == 0)
 2831|      0|		{
 2832|       |		  /* remove j */
 2833|       |
 2834|      0|		  for (x = j; x < pk->numrevkeys - 1; x++)
  ------------------
  |  Branch (2834:17): [True: 0, False: 0]
  ------------------
 2835|      0|		    pk->revkey[x] = pk->revkey[x + 1];
 2836|       |
 2837|      0|		  pk->numrevkeys--;
 2838|      0|		  j--;
 2839|      0|		  changed = 1;
 2840|      0|		}
 2841|      0|	    }
 2842|      0|	}
 2843|       |
 2844|      0|      if (changed)
  ------------------
  |  Branch (2844:11): [True: 0, False: 0]
  ------------------
 2845|      0|	pk->revkey = xrealloc (pk->revkey,
  ------------------
  |  |  111|      0|#define xrealloc(a,b)    gcry_xrealloc ((a),(b))
  ------------------
 2846|      0|			       pk->numrevkeys *
 2847|      0|			       sizeof (struct revocation_key));
 2848|      0|    }
 2849|       |
 2850|       |  /* SIGNODE is the direct key signature packet (sigclass 0x1f) with
 2851|       |   * the latest creation time.  Extract some information from it.  */
 2852|     15|  if (signode)
  ------------------
  |  Branch (2852:7): [True: 0, False: 15]
  ------------------
 2853|      0|    {
 2854|       |      /* Some information from a direct key signature take precedence
 2855|       |       * over the same information given in UID sigs.  */
 2856|      0|      PKT_signature *sig = signode->pkt->pkt.signature;
 2857|      0|      const byte *p;
 2858|       |
 2859|      0|      key_usage = parse_key_usage (sig);
 2860|       |
 2861|      0|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_KEY_EXPIRE, NULL);
 2862|      0|      if (p && buf32_to_u32 (p))
  ------------------
  |  Branch (2862:11): [True: 0, False: 0]
  |  Branch (2862:16): [True: 0, False: 0]
  ------------------
 2863|      0|	{
 2864|      0|	  key_expire = keytimestamp + buf32_to_u32 (p);
 2865|      0|	  key_expire_seen = 1;
 2866|      0|	}
 2867|       |
 2868|       |      /* Mark that key as valid: One direct key signature should
 2869|       |       * render a key as valid.  */
 2870|      0|      pk->flags.valid = 1;
 2871|      0|    }
 2872|       |
 2873|       |  /* Pass 1.5: Look for key revocation signatures that were not made
 2874|       |   * by the key (i.e. did a revocation key issue a revocation for
 2875|       |   * us?).  Only bother to do this if there is a revocation key in the
 2876|       |   * first place and we're not revoked already.  */
 2877|       |
 2878|     15|  if (!*r_revoked && pk->revkey)
  ------------------
  |  Branch (2878:7): [True: 15, False: 0]
  |  Branch (2878:22): [True: 0, False: 15]
  ------------------
 2879|      0|    for (k = keyblock; k && k->pkt->pkttype != PKT_USER_ID; k = k->next)
  ------------------
  |  Branch (2879:24): [True: 0, False: 0]
  |  Branch (2879:29): [True: 0, False: 0]
  ------------------
 2880|      0|      {
 2881|      0|	if (k->pkt->pkttype == PKT_SIGNATURE)
  ------------------
  |  Branch (2881:6): [True: 0, False: 0]
  ------------------
 2882|      0|	  {
 2883|      0|	    PKT_signature *sig = k->pkt->pkt.signature;
 2884|       |
 2885|      0|	    if (IS_KEY_REV (sig) &&
  ------------------
  |  |   45|      0|#define IS_KEY_REV(s)    ((s)->sig_class == 0x20)
  |  |  ------------------
  |  |  |  Branch (45:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2886|      0|		(sig->keyid[0] != kid[0] || sig->keyid[1] != kid[1]))
  ------------------
  |  Branch (2886:4): [True: 0, False: 0]
  |  Branch (2886:31): [True: 0, False: 0]
  ------------------
 2887|      0|	      {
 2888|      0|		int rc = check_revocation_keys (ctrl, pk, sig);
 2889|      0|		if (rc == 0)
  ------------------
  |  Branch (2889:7): [True: 0, False: 0]
  ------------------
 2890|      0|		  {
 2891|      0|		    *r_revoked = 2;
 2892|      0|		    sig_to_revoke_info (sig, rinfo);
 2893|       |		    /* Don't continue checking since we can't be any
 2894|       |		     * more revoked than this.  */
 2895|      0|		    break;
 2896|      0|		  }
 2897|      0|		else if (gpg_err_code (rc) == GPG_ERR_NO_PUBKEY)
  ------------------
  |  Branch (2897:12): [True: 0, False: 0]
  ------------------
 2898|      0|		  pk->flags.maybe_revoked = 1;
 2899|       |
 2900|       |		/* A failure here means the sig did not verify, was
 2901|       |		 * not issued by a revocation key, or a revocation
 2902|       |		 * key loop was broken.  If a revocation key isn't
 2903|       |		 * findable, however, the key might be revoked and
 2904|       |		 * we don't know it.  */
 2905|       |
 2906|       |		/* Fixme: In the future handle subkey and cert
 2907|       |		 * revocations?  PGP doesn't, but it's in 2440.  */
 2908|      0|	      }
 2909|      0|	  }
 2910|      0|      }
 2911|       |
 2912|       |  /* Second pass: Look at the self-signature of all user IDs.  */
 2913|       |
 2914|       |  /* According to RFC 4880 section 11.1, user id and attribute packets
 2915|       |   * are in the second section, after the public key packet and before
 2916|       |   * the subkey packets.  */
 2917|     15|  signode = uidnode = NULL;
 2918|     15|  sigdate = 0; /* Helper variable to find the latest signature in one UID. */
 2919|     86|  for (k = keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY; k = k->next)
  ------------------
  |  Branch (2919:22): [True: 77, False: 9]
  |  Branch (2919:27): [True: 71, False: 6]
  ------------------
 2920|     71|    {
 2921|     71|      if (k->pkt->pkttype == PKT_USER_ID || k->pkt->pkttype == PKT_ATTRIBUTE)
  ------------------
  |  Branch (2921:11): [True: 9, False: 62]
  |  Branch (2921:45): [True: 0, False: 62]
  ------------------
 2922|      9|	{ /* New user id packet.  */
 2923|       |
 2924|       |          /* Apply the data from the most recent self-signed packet to
 2925|       |	   * the preceding user id packet.  */
 2926|      9|	  if (uidnode && signode)
  ------------------
  |  Branch (2926:8): [True: 0, False: 9]
  |  Branch (2926:19): [True: 0, False: 0]
  ------------------
 2927|      0|	    {
 2928|      0|	      fixup_uidnode (uidnode, signode, keytimestamp);
 2929|      0|	      pk->flags.valid = 1;
 2930|      0|	    }
 2931|       |
 2932|       |	  /* Clear SIGNODE.  The only relevant self-signed data for
 2933|       |	   * UIDNODE follows it.  */
 2934|      9|	  if (k->pkt->pkttype == PKT_USER_ID)
  ------------------
  |  Branch (2934:8): [True: 9, False: 0]
  ------------------
 2935|      9|	    uidnode = k;
 2936|      0|	  else
 2937|      0|	    uidnode = NULL;
 2938|       |
 2939|      9|	  signode = NULL;
 2940|      9|	  sigdate = 0;
 2941|      9|	}
 2942|     62|      else if (k->pkt->pkttype == PKT_SIGNATURE && uidnode)
  ------------------
  |  Branch (2942:16): [True: 47, False: 15]
  |  Branch (2942:52): [True: 37, False: 10]
  ------------------
 2943|     37|	{
 2944|     37|	  PKT_signature *sig = k->pkt->pkt.signature;
 2945|     37|	  if (sig->keyid[0] == kid[0] && sig->keyid[1] == kid[1])
  ------------------
  |  Branch (2945:8): [True: 0, False: 37]
  |  Branch (2945:35): [True: 0, False: 0]
  ------------------
 2946|      0|	    {
 2947|      0|	      if (check_key_signature (ctrl, keyblock, k, NULL))
  ------------------
  |  Branch (2947:12): [True: 0, False: 0]
  ------------------
 2948|      0|		;		/* signature did not verify */
 2949|      0|	      else if ((IS_UID_SIG (sig) || IS_UID_REV (sig))
  ------------------
  |  |   41|      0|#define IS_UID_SIG(s)    (((s)->sig_class & ~3) == 0x10)
  |  |  ------------------
  |  |  |  Branch (41:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
              	      else if ((IS_UID_SIG (sig) || IS_UID_REV (sig))
  ------------------
  |  |   46|      0|#define IS_UID_REV(s)    ((s)->sig_class == 0x30)
  |  |  ------------------
  |  |  |  Branch (46:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2950|      0|		       && sig->timestamp >= sigdate)
  ------------------
  |  Branch (2950:13): [True: 0, False: 0]
  ------------------
 2951|      0|		{
 2952|       |		  /* Note: we allow invalidation of cert revocations
 2953|       |		   * by a newer signature.  An attacker can't use this
 2954|       |		   * because a key should be revoked with a key revocation.
 2955|       |		   * The reason why we have to allow for that is that at
 2956|       |		   * one time an email address may become invalid but later
 2957|       |		   * the same email address may become valid again (hired,
 2958|       |		   * fired, hired again).  */
 2959|       |
 2960|      0|		  sigdate = sig->timestamp;
 2961|      0|		  signode = k;
 2962|      0|		  signode->pkt->pkt.signature->flags.chosen_selfsig = 0;
 2963|      0|		  if (sig->version > sigversion)
  ------------------
  |  Branch (2963:9): [True: 0, False: 0]
  ------------------
 2964|      0|		    sigversion = sig->version;
 2965|      0|		}
 2966|      0|	    }
 2967|     37|	}
 2968|     71|    }
 2969|     15|  if (uidnode && signode)
  ------------------
  |  Branch (2969:7): [True: 9, False: 6]
  |  Branch (2969:18): [True: 0, False: 9]
  ------------------
 2970|      0|    {
 2971|      0|      fixup_uidnode (uidnode, signode, keytimestamp);
 2972|      0|      pk->flags.valid = 1;
 2973|      0|    }
 2974|       |
 2975|       |  /* If the key isn't valid yet, and we have
 2976|       |   * --allow-non-selfsigned-uid set, then force it valid. */
 2977|     15|  if (!pk->flags.valid && opt.allow_non_selfsigned_uid)
  ------------------
  |  Branch (2977:7): [True: 15, False: 0]
  |  Branch (2977:27): [True: 0, False: 15]
  ------------------
 2978|      0|    {
 2979|      0|      if (opt.verbose)
  ------------------
  |  Branch (2979:11): [True: 0, False: 0]
  ------------------
 2980|      0|	log_info (_("Invalid key %s made valid by"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2981|      0|		    " --allow-non-selfsigned-uid\n"), keystr_from_pk (pk));
 2982|      0|      pk->flags.valid = 1;
 2983|      0|    }
 2984|       |
 2985|       |  /* The key STILL isn't valid, so try and find an ultimately
 2986|       |   * trusted signature. */
 2987|     15|  if (!pk->flags.valid)
  ------------------
  |  Branch (2987:7): [True: 15, False: 0]
  ------------------
 2988|     15|    {
 2989|     15|      uidnode = NULL;
 2990|       |
 2991|     86|      for (k = keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY;
  ------------------
  |  Branch (2991:26): [True: 77, False: 9]
  |  Branch (2991:31): [True: 71, False: 6]
  ------------------
 2992|     71|	   k = k->next)
 2993|     71|	{
 2994|     71|	  if (k->pkt->pkttype == PKT_USER_ID)
  ------------------
  |  Branch (2994:8): [True: 9, False: 62]
  ------------------
 2995|      9|	    uidnode = k;
 2996|     62|	  else if (k->pkt->pkttype == PKT_SIGNATURE && uidnode)
  ------------------
  |  Branch (2996:13): [True: 47, False: 15]
  |  Branch (2996:49): [True: 37, False: 10]
  ------------------
 2997|     37|	    {
 2998|     37|	      PKT_signature *sig = k->pkt->pkt.signature;
 2999|       |
 3000|     37|	      if (sig->keyid[0] != kid[0] || sig->keyid[1] != kid[1])
  ------------------
  |  Branch (3000:12): [True: 37, False: 0]
  |  Branch (3000:39): [True: 0, False: 0]
  ------------------
 3001|     37|		{
 3002|     37|		  PKT_public_key *ultimate_pk;
 3003|       |
 3004|     37|		  ultimate_pk = xmalloc_clear (sizeof (*ultimate_pk));
  ------------------
  |  |  116|     37|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
 3005|       |
 3006|       |		  /* We don't want to use the full get_pubkey to avoid
 3007|       |		   * infinite recursion in certain cases.  There is no
 3008|       |		   * reason to check that an ultimately trusted key is
 3009|       |		   * still valid - if it has been revoked the user
 3010|       |		   * should also remove the ultimate trust flag.  */
 3011|     37|		  if (get_pubkey_fast (ctrl, ultimate_pk, sig->keyid) == 0
  ------------------
  |  Branch (3011:9): [True: 0, False: 37]
  ------------------
 3012|     37|		      && check_key_signature2 (ctrl,
  ------------------
  |  Branch (3012:12): [True: 0, False: 0]
  ------------------
 3013|      0|                                               keyblock, k, ultimate_pk,
 3014|      0|					       NULL, NULL, NULL, NULL) == 0
 3015|     37|		      && get_ownertrust (ctrl, ultimate_pk) == TRUST_ULTIMATE)
  ------------------
  |  |   32|      0|#define TRUST_ULTIMATE	  6  /* u: ultimately trusted */
  ------------------
  |  Branch (3015:12): [True: 0, False: 0]
  ------------------
 3016|      0|		    {
 3017|      0|		      free_public_key (ultimate_pk);
 3018|      0|		      pk->flags.valid = 1;
 3019|      0|		      break;
 3020|      0|		    }
 3021|       |
 3022|     37|		  free_public_key (ultimate_pk);
 3023|     37|		}
 3024|     37|	    }
 3025|     71|	}
 3026|     15|    }
 3027|       |
 3028|       |  /* Record the highest selfsig version so we know if this is a v3 key
 3029|       |   * through and through, or a v3 key with a v4 selfsig somewhere.
 3030|       |   * This is useful in a few places to know if the key must be treated
 3031|       |   * as PGP2-style or OpenPGP-style.  Note that a selfsig revocation
 3032|       |   * with a higher version number will also raise this value.  This is
 3033|       |   * okay since such a revocation must be issued by the user (i.e. it
 3034|       |   * cannot be issued by someone else to modify the key behavior.) */
 3035|       |
 3036|     15|  pk->selfsigversion = sigversion;
 3037|       |
 3038|       |  /* Now that we had a look at all user IDs we can now get some
 3039|       |   * information from those user IDs.  */
 3040|       |
 3041|     15|  if (!key_usage)
  ------------------
  |  Branch (3041:7): [True: 15, False: 0]
  ------------------
 3042|     15|    {
 3043|       |      /* Find the latest user ID with key flags set. */
 3044|     15|      uiddate = 0; /* Helper to find the latest user ID.  */
 3045|     86|      for (k = keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY;
  ------------------
  |  Branch (3045:26): [True: 77, False: 9]
  |  Branch (3045:31): [True: 71, False: 6]
  ------------------
 3046|     71|	   k = k->next)
 3047|     71|	{
 3048|     71|	  if (k->pkt->pkttype == PKT_USER_ID)
  ------------------
  |  Branch (3048:8): [True: 9, False: 62]
  ------------------
 3049|      9|	    {
 3050|      9|	      PKT_user_id *uid = k->pkt->pkt.user_id;
 3051|       |
 3052|      9|	      if (uid->help_key_usage
  ------------------
  |  Branch (3052:12): [True: 0, False: 9]
  ------------------
 3053|      9|                  && (uid->created > uiddate || (!uid->created && !uiddate)))
  ------------------
  |  Branch (3053:23): [True: 0, False: 0]
  |  Branch (3053:50): [True: 0, False: 0]
  |  Branch (3053:67): [True: 0, False: 0]
  ------------------
 3054|      0|		{
 3055|      0|		  key_usage = uid->help_key_usage;
 3056|      0|		  uiddate = uid->created;
 3057|      0|		}
 3058|      9|	    }
 3059|     71|	}
 3060|     15|    }
 3061|       |
 3062|     15|  if (!key_usage)
  ------------------
  |  Branch (3062:7): [True: 15, False: 0]
  ------------------
 3063|     15|    {
 3064|       |      /* No key flags at all: get it from the algo.  */
 3065|     15|      key_usage = openpgp_pk_algo_usage (pk->pubkey_algo);
 3066|     15|    }
 3067|      0|  else
 3068|      0|    {
 3069|       |      /* Check that the usage matches the usage as given by the algo.  */
 3070|      0|      int x = openpgp_pk_algo_usage (pk->pubkey_algo);
 3071|      0|      if (x) /* Mask it down to the actual allowed usage.  */
  ------------------
  |  Branch (3071:11): [True: 0, False: 0]
  ------------------
 3072|      0|	key_usage &= x;
 3073|      0|    }
 3074|       |
 3075|       |  /* Whatever happens, it's a primary key, so it can certify. */
 3076|     15|  pk->pubkey_usage = key_usage | PUBKEY_USAGE_CERT;
  ------------------
  |  |   51|     15|#define PUBKEY_USAGE_CERT    GCRY_PK_USAGE_CERT  /* Also good to certify keys.*/
  ------------------
 3077|       |
 3078|     15|  if (!key_expire_seen)
  ------------------
  |  Branch (3078:7): [True: 15, False: 0]
  ------------------
 3079|     15|    {
 3080|       |      /* Find the latest valid user ID with a key expiration set.
 3081|       |       * This may be a different one than from usage computation above
 3082|       |       * because some user IDs may have no expiration date set.  */
 3083|     15|      uiddate = 0;
 3084|     86|      for (k = keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY;
  ------------------
  |  Branch (3084:26): [True: 77, False: 9]
  |  Branch (3084:31): [True: 71, False: 6]
  ------------------
 3085|     71|	   k = k->next)
 3086|     71|	{
 3087|     71|	  if (k->pkt->pkttype == PKT_USER_ID)
  ------------------
  |  Branch (3087:8): [True: 9, False: 62]
  ------------------
 3088|      9|	    {
 3089|      9|	      PKT_user_id *uid = k->pkt->pkt.user_id;
 3090|      9|	      if (uid->help_key_expire
  ------------------
  |  Branch (3090:12): [True: 0, False: 9]
  ------------------
 3091|      9|                  && (uid->created > uiddate || (!uid->created && !uiddate)))
  ------------------
  |  Branch (3091:23): [True: 0, False: 0]
  |  Branch (3091:50): [True: 0, False: 0]
  |  Branch (3091:67): [True: 0, False: 0]
  ------------------
 3092|      0|		{
 3093|      0|		  key_expire = uid->help_key_expire;
 3094|      0|		  uiddate = uid->created;
 3095|      0|		}
 3096|      9|	    }
 3097|     71|	}
 3098|     15|    }
 3099|       |
 3100|       |  /* Currently only the not anymore supported v3 keys have a maximum
 3101|       |   * expiration date, but future key versions may get this feature again. */
 3102|     15|  if (key_expire == 0
  ------------------
  |  Branch (3102:7): [True: 15, False: 0]
  ------------------
 3103|     15|      || (pk->max_expiredate && key_expire > pk->max_expiredate))
  ------------------
  |  Branch (3103:11): [True: 0, False: 0]
  |  Branch (3103:33): [True: 0, False: 0]
  ------------------
 3104|     15|    key_expire = pk->max_expiredate;
 3105|       |
 3106|     15|  pk->has_expired = key_expire >= curtime ? 0 : key_expire;
  ------------------
  |  Branch (3106:21): [True: 0, False: 15]
  ------------------
 3107|     15|  pk->expiredate = key_expire;
 3108|       |
 3109|       |  /* Fixme: we should see how to get rid of the expiretime fields but
 3110|       |   * this needs changes at other places too.  */
 3111|       |
 3112|       |  /* And now find the real primary user ID and delete all others.  */
 3113|     15|  uiddate = uiddate2 = 0;
 3114|     15|  uidnode = uidnode2 = NULL;
 3115|     86|  for (k = keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY; k = k->next)
  ------------------
  |  Branch (3115:22): [True: 77, False: 9]
  |  Branch (3115:27): [True: 71, False: 6]
  ------------------
 3116|     71|    {
 3117|     71|      if (k->pkt->pkttype == PKT_USER_ID && !k->pkt->pkt.user_id->attrib_data)
  ------------------
  |  Branch (3117:11): [True: 9, False: 62]
  |  Branch (3117:45): [True: 9, False: 0]
  ------------------
 3118|      9|	{
 3119|      9|	  PKT_user_id *uid = k->pkt->pkt.user_id;
 3120|      9|	  if (uid->flags.primary)
  ------------------
  |  Branch (3120:8): [True: 0, False: 9]
  ------------------
 3121|      0|	    {
 3122|      0|	      if (uid->created > uiddate)
  ------------------
  |  Branch (3122:12): [True: 0, False: 0]
  ------------------
 3123|      0|		{
 3124|      0|		  uiddate = uid->created;
 3125|      0|		  uidnode = k;
 3126|      0|		}
 3127|      0|	      else if (uid->created == uiddate && uidnode)
  ------------------
  |  Branch (3127:17): [True: 0, False: 0]
  |  Branch (3127:44): [True: 0, False: 0]
  ------------------
 3128|      0|		{
 3129|       |		  /* The dates are equal, so we need to do a different
 3130|       |		   * (and arbitrary) comparison.  This should rarely,
 3131|       |		   * if ever, happen.  It's good to try and guarantee
 3132|       |		   * that two different GnuPG users with two different
 3133|       |		   * keyrings at least pick the same primary.  */
 3134|      0|		  if (cmp_user_ids (uid, uidnode->pkt->pkt.user_id) > 0)
  ------------------
  |  Branch (3134:9): [True: 0, False: 0]
  ------------------
 3135|      0|		    uidnode = k;
 3136|      0|		}
 3137|      0|	    }
 3138|      9|	  else
 3139|      9|	    {
 3140|      9|	      if (uid->created > uiddate2)
  ------------------
  |  Branch (3140:12): [True: 0, False: 9]
  ------------------
 3141|      0|		{
 3142|      0|		  uiddate2 = uid->created;
 3143|      0|		  uidnode2 = k;
 3144|      0|		}
 3145|      9|	      else if (uid->created == uiddate2 && uidnode2)
  ------------------
  |  Branch (3145:17): [True: 9, False: 0]
  |  Branch (3145:45): [True: 0, False: 9]
  ------------------
 3146|      0|		{
 3147|      0|		  if (cmp_user_ids (uid, uidnode2->pkt->pkt.user_id) > 0)
  ------------------
  |  Branch (3147:9): [True: 0, False: 0]
  ------------------
 3148|      0|		    uidnode2 = k;
 3149|      0|		}
 3150|      9|	    }
 3151|      9|	}
 3152|     71|    }
 3153|     15|  if (uidnode)
  ------------------
  |  Branch (3153:7): [True: 0, False: 15]
  ------------------
 3154|      0|    {
 3155|      0|      for (k = keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY;
  ------------------
  |  Branch (3155:26): [True: 0, False: 0]
  |  Branch (3155:31): [True: 0, False: 0]
  ------------------
 3156|      0|	   k = k->next)
 3157|      0|	{
 3158|      0|	  if (k->pkt->pkttype == PKT_USER_ID &&
  ------------------
  |  Branch (3158:8): [True: 0, False: 0]
  ------------------
 3159|      0|	      !k->pkt->pkt.user_id->attrib_data)
  ------------------
  |  Branch (3159:8): [True: 0, False: 0]
  ------------------
 3160|      0|	    {
 3161|      0|	      PKT_user_id *uid = k->pkt->pkt.user_id;
 3162|      0|	      if (k != uidnode)
  ------------------
  |  Branch (3162:12): [True: 0, False: 0]
  ------------------
 3163|      0|		uid->flags.primary = 0;
 3164|      0|	    }
 3165|      0|	}
 3166|      0|    }
 3167|     15|  else if (uidnode2)
  ------------------
  |  Branch (3167:12): [True: 0, False: 15]
  ------------------
 3168|      0|    {
 3169|       |      /* None is flagged primary - use the latest user ID we have,
 3170|       |       * and disambiguate with the arbitrary packet comparison. */
 3171|      0|      uidnode2->pkt->pkt.user_id->flags.primary = 1;
 3172|      0|    }
 3173|     15|  else
 3174|     15|    {
 3175|       |      /* None of our uids were self-signed, so pick the one that
 3176|       |       * sorts first to be the primary.  This is the best we can do
 3177|       |       * here since there are no self sigs to date the uids. */
 3178|       |
 3179|     15|      uidnode = NULL;
 3180|       |
 3181|     86|      for (k = keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY;
  ------------------
  |  Branch (3181:26): [True: 77, False: 9]
  |  Branch (3181:31): [True: 71, False: 6]
  ------------------
 3182|     71|	   k = k->next)
 3183|     71|	{
 3184|     71|	  if (k->pkt->pkttype == PKT_USER_ID
  ------------------
  |  Branch (3184:8): [True: 9, False: 62]
  ------------------
 3185|     71|	      && !k->pkt->pkt.user_id->attrib_data)
  ------------------
  |  Branch (3185:11): [True: 9, False: 0]
  ------------------
 3186|      9|	    {
 3187|      9|	      if (!uidnode)
  ------------------
  |  Branch (3187:12): [True: 9, False: 0]
  ------------------
 3188|      9|		{
 3189|      9|		  uidnode = k;
 3190|      9|		  uidnode->pkt->pkt.user_id->flags.primary = 1;
 3191|      9|		  continue;
 3192|      9|		}
 3193|      0|	      else
 3194|      0|		{
 3195|      0|		  if (cmp_user_ids (k->pkt->pkt.user_id,
  ------------------
  |  Branch (3195:9): [True: 0, False: 0]
  ------------------
 3196|      0|				    uidnode->pkt->pkt.user_id) > 0)
 3197|      0|		    {
 3198|      0|		      uidnode->pkt->pkt.user_id->flags.primary = 0;
 3199|      0|		      uidnode = k;
 3200|      0|		      uidnode->pkt->pkt.user_id->flags.primary = 1;
 3201|      0|		    }
 3202|      0|		  else
 3203|      0|                    {
 3204|       |                      /* just to be safe: */
 3205|      0|                      k->pkt->pkt.user_id->flags.primary = 0;
 3206|      0|                    }
 3207|      0|		}
 3208|      9|	    }
 3209|     71|	}
 3210|     15|    }
 3211|     15|}
getkey.c:parse_key_usage:
 2422|      6|{
 2423|      6|  int key_usage = 0;
 2424|      6|  const byte *p;
 2425|      6|  size_t n;
 2426|      6|  byte flags;
 2427|       |
 2428|      6|  p = parse_sig_subpkt (sig, 1, SIGSUBPKT_KEY_FLAGS, &n);
 2429|      6|  if (p && n)
  ------------------
  |  Branch (2429:7): [True: 6, False: 0]
  |  Branch (2429:12): [True: 6, False: 0]
  ------------------
 2430|      6|    {
 2431|       |      /* First octet of the keyflags.  */
 2432|      6|      flags = *p;
 2433|       |
 2434|      6|      if (flags & 1)
  ------------------
  |  Branch (2434:11): [True: 0, False: 6]
  ------------------
 2435|      0|	{
 2436|      0|	  key_usage |= PUBKEY_USAGE_CERT;
  ------------------
  |  |   51|      0|#define PUBKEY_USAGE_CERT    GCRY_PK_USAGE_CERT  /* Also good to certify keys.*/
  ------------------
 2437|      0|	  flags &= ~1;
 2438|      0|	}
 2439|       |
 2440|      6|      if (flags & 2)
  ------------------
  |  Branch (2440:11): [True: 0, False: 6]
  ------------------
 2441|      0|	{
 2442|      0|	  key_usage |= PUBKEY_USAGE_SIG;
  ------------------
  |  |   49|      0|#define PUBKEY_USAGE_SIG     GCRY_PK_USAGE_SIGN  /* Good for signatures. */
  ------------------
 2443|      0|	  flags &= ~2;
 2444|      0|	}
 2445|       |
 2446|       |      /* We do not distinguish between encrypting communications and
 2447|       |         encrypting storage. */
 2448|      6|      if (flags & (0x04 | 0x08))
  ------------------
  |  Branch (2448:11): [True: 6, False: 0]
  ------------------
 2449|      6|	{
 2450|      6|	  key_usage |= PUBKEY_USAGE_ENC;
  ------------------
  |  |   50|      6|#define PUBKEY_USAGE_ENC     GCRY_PK_USAGE_ENCR  /* Good for encryption. */
  ------------------
 2451|      6|	  flags &= ~(0x04 | 0x08);
 2452|      6|	}
 2453|       |
 2454|      6|      if (flags & 0x20)
  ------------------
  |  Branch (2454:11): [True: 0, False: 6]
  ------------------
 2455|      0|	{
 2456|      0|	  key_usage |= PUBKEY_USAGE_AUTH;
  ------------------
  |  |   52|      0|#define PUBKEY_USAGE_AUTH    GCRY_PK_USAGE_AUTH  /* Good for authentication. */
  ------------------
 2457|      0|	  flags &= ~0x20;
 2458|      0|	}
 2459|       |
 2460|      6|      if ((flags & 0x80))
  ------------------
  |  Branch (2460:11): [True: 0, False: 6]
  ------------------
 2461|      0|	{
 2462|      0|	  key_usage |= PUBKEY_USAGE_GROUP;
  ------------------
  |  |   61|      0|#define PUBKEY_USAGE_GROUP   512                 /* Group flag.  */
  ------------------
 2463|      0|	  flags &= ~0x80;
 2464|      0|	}
 2465|       |
 2466|      6|      if (flags)
  ------------------
  |  Branch (2466:11): [True: 0, False: 6]
  ------------------
 2467|      0|	key_usage |= PUBKEY_USAGE_UNKNOWN;
  ------------------
  |  |   53|      0|#define PUBKEY_USAGE_UNKNOWN GCRY_PK_USAGE_UNKN  /* Unknown usage flag. */
  ------------------
 2468|       |
 2469|      6|      n--;
 2470|      6|      p++;
 2471|      6|      if (n)
  ------------------
  |  Branch (2471:11): [True: 0, False: 6]
  ------------------
 2472|      0|        {
 2473|      0|          flags = *p;
 2474|      0|          if ((flags & 0x04))
  ------------------
  |  Branch (2474:15): [True: 0, False: 0]
  ------------------
 2475|      0|            key_usage |= PUBKEY_USAGE_RENC;
  ------------------
  |  |   59|      0|#define PUBKEY_USAGE_RENC    512                 /* Restricted encryption.  */
  ------------------
 2476|      0|          if ((flags & 0x08))
  ------------------
  |  Branch (2476:15): [True: 0, False: 0]
  ------------------
 2477|      0|            key_usage |= PUBKEY_USAGE_TIME;
  ------------------
  |  |   60|      0|#define PUBKEY_USAGE_TIME    1024                /* Timestamp use.  */
  ------------------
 2478|      0|        }
 2479|       |
 2480|      6|      if (!key_usage)
  ------------------
  |  Branch (2480:11): [True: 0, False: 6]
  ------------------
 2481|      0|	key_usage |= PUBKEY_USAGE_NONE;
  ------------------
  |  |   54|      0|#define PUBKEY_USAGE_NONE    256                 /* No usage given. */
  ------------------
 2482|       |
 2483|      6|    }
 2484|      0|  else if (p) /* Key flags of length zero.  */
  ------------------
  |  Branch (2484:12): [True: 0, False: 0]
  ------------------
 2485|      0|    key_usage |= PUBKEY_USAGE_NONE;
  ------------------
  |  |   54|      0|#define PUBKEY_USAGE_NONE    256                 /* No usage given. */
  ------------------
 2486|       |
 2487|       |  /* We set PUBKEY_USAGE_UNKNOWN to indicate that this key has a
 2488|       |     capability that we do not handle.  This serves to distinguish
 2489|       |     between a zero key usage which we handle as the default
 2490|       |     capabilities for that algorithm, and a usage that we do not
 2491|       |     handle.  Likewise we use PUBKEY_USAGE_NONE to indicate that
 2492|       |     key_flags have been given but they do not specify any usage.  */
 2493|       |
 2494|      6|  return key_usage;
 2495|      6|}
getkey.c:merge_selfsigs_subkey:
 3257|      6|{
 3258|      6|  PKT_public_key *mainpk = NULL, *subpk = NULL;
 3259|      6|  PKT_signature *sig;
 3260|      6|  KBNODE k;
 3261|      6|  u32 mainkid[2];
 3262|      6|  u32 sigdate = 0;
 3263|      6|  KBNODE signode;
 3264|      6|  u32 curtime = make_timestamp ();
 3265|      6|  unsigned int key_usage = 0;
 3266|      6|  u32 keytimestamp = 0;
 3267|      6|  u32 key_expire = 0;
 3268|      6|  const byte *p;
 3269|       |
 3270|      6|  if (subnode->pkt->pkttype != PKT_PUBLIC_SUBKEY)
  ------------------
  |  Branch (3270:7): [True: 0, False: 6]
  ------------------
 3271|      0|    BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 3272|      6|  mainpk = keyblock->pkt->pkt.public_key;
 3273|      6|  if (mainpk->version < 4)
  ------------------
  |  Branch (3273:7): [True: 0, False: 6]
  ------------------
 3274|      0|    return;/* (actually this should never happen) */
 3275|      6|  keyid_from_pk (mainpk, mainkid);
 3276|      6|  subpk = subnode->pkt->pkt.public_key;
 3277|      6|  keytimestamp = subpk->timestamp;
 3278|       |
 3279|      6|  subpk->flags.valid = 0;
 3280|      6|  subpk->flags.exact = 0;
 3281|      6|  subpk->main_keyid[0] = mainpk->main_keyid[0];
 3282|      6|  subpk->main_keyid[1] = mainpk->main_keyid[1];
 3283|       |
 3284|       |  /* Find the latest key binding self-signature.  */
 3285|      6|  signode = NULL;
 3286|      6|  sigdate = 0; /* Helper to find the latest signature.  */
 3287|     48|  for (k = subnode->next; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY;
  ------------------
  |  Branch (3287:27): [True: 42, False: 6]
  |  Branch (3287:32): [True: 42, False: 0]
  ------------------
 3288|     42|       k = k->next)
 3289|     42|    {
 3290|     42|      if (k->pkt->pkttype == PKT_SIGNATURE)
  ------------------
  |  Branch (3290:11): [True: 36, False: 6]
  ------------------
 3291|     36|	{
 3292|     36|	  sig = k->pkt->pkt.signature;
 3293|     36|	  if (sig->keyid[0] == mainkid[0] && sig->keyid[1] == mainkid[1])
  ------------------
  |  Branch (3293:8): [True: 14, False: 22]
  |  Branch (3293:39): [True: 12, False: 2]
  ------------------
 3294|     12|	    {
 3295|     12|	      if (check_key_signature (ctrl, keyblock, k, NULL))
  ------------------
  |  Branch (3295:12): [True: 0, False: 12]
  ------------------
 3296|      0|		; /* Signature did not verify.  */
 3297|     12|	      else if (IS_SUBKEY_REV (sig))
  ------------------
  |  |   47|     12|#define IS_SUBKEY_REV(s) ((s)->sig_class == 0x28)
  |  |  ------------------
  |  |  |  Branch (47:26): [True: 0, False: 12]
  |  |  ------------------
  ------------------
 3298|      0|		{
 3299|       |		  /* Note that this means that the date on a
 3300|       |		   * revocation sig does not matter - even if the
 3301|       |		   * binding sig is dated after the revocation sig,
 3302|       |		   * the subkey is still marked as revoked.  This
 3303|       |		   * seems ok, as it is just as easy to make new
 3304|       |		   * subkeys rather than re-sign old ones as the
 3305|       |		   * problem is in the distribution.  Plus, PGP (7)
 3306|       |		   * does this the same way.  */
 3307|      0|		  subpk->flags.revoked = 1;
 3308|      0|		  sig_to_revoke_info (sig, &subpk->revoked);
 3309|       |		  /* Although we could stop now, we continue to
 3310|       |		   * figure out other information like the old expiration
 3311|       |		   * time.  */
 3312|      0|		}
 3313|     12|	      else if (IS_SUBKEY_SIG (sig) && sig->timestamp >= sigdate)
  ------------------
  |  |   43|     24|#define IS_SUBKEY_SIG(s) ((s)->sig_class == 0x18)
  |  |  ------------------
  |  |  |  Branch (43:26): [True: 6, False: 6]
  |  |  ------------------
  ------------------
  |  Branch (3313:40): [True: 6, False: 0]
  ------------------
 3314|      6|		{
 3315|      6|		  if (sig->flags.expired)
  ------------------
  |  Branch (3315:9): [True: 0, False: 6]
  ------------------
 3316|      0|		    ; /* Signature has expired - ignore it.  */
 3317|      6|		  else
 3318|      6|		    {
 3319|      6|		      sigdate = sig->timestamp;
 3320|      6|		      signode = k;
 3321|      6|		      signode->pkt->pkt.signature->flags.chosen_selfsig = 0;
 3322|      6|		    }
 3323|      6|		}
 3324|     12|	    }
 3325|     36|	}
 3326|     42|    }
 3327|       |
 3328|       |  /* No valid key binding.  */
 3329|      6|  if (!signode)
  ------------------
  |  Branch (3329:7): [True: 0, False: 6]
  ------------------
 3330|      0|    return;
 3331|       |
 3332|      6|  sig = signode->pkt->pkt.signature;
 3333|      6|  sig->flags.chosen_selfsig = 1; /* So we know which selfsig we chose later.  */
 3334|       |
 3335|      6|  key_usage = parse_key_usage (sig);
 3336|      6|  if (!key_usage)
  ------------------
  |  Branch (3336:7): [True: 0, False: 6]
  ------------------
 3337|      0|    {
 3338|       |      /* No key flags at all: get it from the algo.  */
 3339|      0|      key_usage = openpgp_pk_algo_usage (subpk->pubkey_algo);
 3340|      0|    }
 3341|      6|  else
 3342|      6|    {
 3343|       |      /* Check that the usage matches the usage as given by the algo.  */
 3344|      6|      int x = openpgp_pk_algo_usage (subpk->pubkey_algo);
 3345|      6|      if (x) /* Mask it down to the actual allowed usage.  */
  ------------------
  |  Branch (3345:11): [True: 6, False: 0]
  ------------------
 3346|      6|	key_usage &= x;
 3347|      6|    }
 3348|       |
 3349|      6|  subpk->pubkey_usage = key_usage;
 3350|       |
 3351|      6|  p = parse_sig_subpkt (sig, 1, SIGSUBPKT_KEY_EXPIRE, NULL);
 3352|      6|  if (p && buf32_to_u32 (p))
  ------------------
  |  Branch (3352:7): [True: 0, False: 6]
  |  Branch (3352:12): [True: 0, False: 0]
  ------------------
 3353|      0|    key_expire = keytimestamp + buf32_to_u32 (p);
 3354|      6|  else
 3355|      6|    key_expire = 0;
 3356|       |
 3357|      6|  subpk->has_expired = key_expire >= curtime ? 0 : key_expire;
  ------------------
  |  Branch (3357:24): [True: 0, False: 6]
  ------------------
 3358|      6|  subpk->expiredate = key_expire;
 3359|       |
 3360|       |  /* Algo doesn't exist.  */
 3361|      6|  if (openpgp_pk_test_algo (subpk->pubkey_algo))
  ------------------
  |  Branch (3361:7): [True: 0, False: 6]
  ------------------
 3362|      0|    return;
 3363|       |
 3364|      6|  subpk->flags.valid = 1;
 3365|       |
 3366|       |  /* Find the most recent 0x19 embedded signature on our self-sig. */
 3367|      6|  if (!subpk->flags.backsig)
  ------------------
  |  Branch (3367:7): [True: 6, False: 0]
  ------------------
 3368|      6|    {
 3369|      6|      int seq = 0;
 3370|      6|      size_t n;
 3371|      6|      PKT_signature *backsig = NULL;
 3372|       |
 3373|      6|      sigdate = 0;
 3374|       |
 3375|       |      /* We do this while() since there may be other embedded
 3376|       |       * signatures in the future.  We only want 0x19 here. */
 3377|       |
 3378|      6|      while ((p = enum_sig_subpkt (sig, 1, SIGSUBPKT_SIGNATURE,
  ------------------
  |  Branch (3378:14): [True: 0, False: 6]
  ------------------
 3379|      6|                                   &n, &seq, NULL)))
 3380|      0|        if (n > 3
  ------------------
  |  Branch (3380:13): [True: 0, False: 0]
  ------------------
 3381|      0|            && ((p[0] == 3 && p[2] == 0x19) || (p[0] == 4 && p[1] == 0x19)
  ------------------
  |  Branch (3381:18): [True: 0, False: 0]
  |  Branch (3381:31): [True: 0, False: 0]
  |  Branch (3381:49): [True: 0, False: 0]
  |  Branch (3381:62): [True: 0, False: 0]
  ------------------
 3382|      0|                || (p[0] == 5 && p[1] == 0x19)))
  ------------------
  |  Branch (3382:21): [True: 0, False: 0]
  |  Branch (3382:34): [True: 0, False: 0]
  ------------------
 3383|      0|          {
 3384|      0|	    PKT_signature *tempsig = buf_to_sig (p, n);
 3385|      0|	    if (tempsig)
  ------------------
  |  Branch (3385:10): [True: 0, False: 0]
  ------------------
 3386|      0|	      {
 3387|      0|		if (tempsig->timestamp > sigdate)
  ------------------
  |  Branch (3387:7): [True: 0, False: 0]
  ------------------
 3388|      0|		  {
 3389|      0|		    if (backsig)
  ------------------
  |  Branch (3389:11): [True: 0, False: 0]
  ------------------
 3390|      0|		      free_seckey_enc (backsig);
 3391|       |
 3392|      0|		    backsig = tempsig;
 3393|      0|		    sigdate = backsig->timestamp;
 3394|      0|		  }
 3395|      0|		else
 3396|      0|		  free_seckey_enc (tempsig);
 3397|      0|	      }
 3398|      0|	  }
 3399|       |
 3400|      6|      seq = 0;
 3401|       |
 3402|       |      /* It is safe to have this in the unhashed area since the 0x19
 3403|       |       * is located on the selfsig for convenience, not security. */
 3404|      6|      while ((p = enum_sig_subpkt (sig, 0, SIGSUBPKT_SIGNATURE,
  ------------------
  |  Branch (3404:14): [True: 0, False: 6]
  ------------------
 3405|      6|				   &n, &seq, NULL)))
 3406|      0|        if (n > 3
  ------------------
  |  Branch (3406:13): [True: 0, False: 0]
  ------------------
 3407|      0|            && ((p[0] == 3 && p[2] == 0x19) || (p[0] == 4 && p[1] == 0x19)
  ------------------
  |  Branch (3407:18): [True: 0, False: 0]
  |  Branch (3407:31): [True: 0, False: 0]
  |  Branch (3407:49): [True: 0, False: 0]
  |  Branch (3407:62): [True: 0, False: 0]
  ------------------
 3408|      0|                 || (p[0] == 5 && p[1] == 0x19)))
  ------------------
  |  Branch (3408:22): [True: 0, False: 0]
  |  Branch (3408:35): [True: 0, False: 0]
  ------------------
 3409|      0|          {
 3410|      0|	    PKT_signature *tempsig = buf_to_sig (p, n);
 3411|      0|	    if (tempsig)
  ------------------
  |  Branch (3411:10): [True: 0, False: 0]
  ------------------
 3412|      0|	      {
 3413|      0|		if (tempsig->timestamp > sigdate)
  ------------------
  |  Branch (3413:7): [True: 0, False: 0]
  ------------------
 3414|      0|		  {
 3415|      0|		    if (backsig)
  ------------------
  |  Branch (3415:11): [True: 0, False: 0]
  ------------------
 3416|      0|		      free_seckey_enc (backsig);
 3417|       |
 3418|      0|		    backsig = tempsig;
 3419|      0|		    sigdate = backsig->timestamp;
 3420|      0|		  }
 3421|      0|		else
 3422|      0|		  free_seckey_enc (tempsig);
 3423|      0|	      }
 3424|      0|	  }
 3425|       |
 3426|      6|      if (backsig)
  ------------------
  |  Branch (3426:11): [True: 0, False: 6]
  ------------------
 3427|      0|	{
 3428|       |	  /* At this point, backsig contains the most recent 0x19 sig.
 3429|       |	   * Let's see if it is good. */
 3430|       |
 3431|       |	  /* 2==valid, 1==invalid, 0==didn't check */
 3432|      0|	  if (check_backsig (mainpk, subpk, backsig) == 0)
  ------------------
  |  Branch (3432:8): [True: 0, False: 0]
  ------------------
 3433|      0|	    subpk->flags.backsig = 2;
 3434|      0|	  else
 3435|      0|	    subpk->flags.backsig = 1;
 3436|       |
 3437|      0|	  free_seckey_enc (backsig);
 3438|      0|	}
 3439|      6|    }
 3440|      6|}
getkey.c:finish_lookup:
 3602|      4|{
 3603|      4|  kbnode_t k;
 3604|       |
 3605|       |  /* If WANT_EXACT is set, the key or subkey that actually matched the
 3606|       |     low-level search criteria.  */
 3607|      4|  kbnode_t foundk = NULL;
 3608|       |  /* The user id (if any) that matched the low-level search criteria.  */
 3609|      4|  PKT_user_id *foundu = NULL;
 3610|       |
 3611|      4|  u32 latest_date;
 3612|      4|  kbnode_t latest_key;
 3613|      4|  PKT_public_key *pk;
 3614|      4|  int req_prim;
 3615|      4|  u32 curtime = make_timestamp ();
 3616|       |
 3617|      4|  if (r_flags)
  ------------------
  |  Branch (3617:7): [True: 4, False: 0]
  ------------------
 3618|      4|    *r_flags = 0;
 3619|       |
 3620|      4|#define USAGE_MASK  (PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC|PUBKEY_USAGE_CERT)
 3621|      4|  req_usage &= USAGE_MASK;
  ------------------
  |  | 3620|      4|#define USAGE_MASK  (PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC|PUBKEY_USAGE_CERT)
  |  |  ------------------
  |  |  |  |   49|      4|#define PUBKEY_USAGE_SIG     GCRY_PK_USAGE_SIGN  /* Good for signatures. */
  |  |  ------------------
  |  |               #define USAGE_MASK  (PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC|PUBKEY_USAGE_CERT)
  |  |  ------------------
  |  |  |  |   50|      4|#define PUBKEY_USAGE_ENC     GCRY_PK_USAGE_ENCR  /* Good for encryption. */
  |  |  ------------------
  |  |               #define USAGE_MASK  (PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC|PUBKEY_USAGE_CERT)
  |  |  ------------------
  |  |  |  |   51|      4|#define PUBKEY_USAGE_CERT    GCRY_PK_USAGE_CERT  /* Also good to certify keys.*/
  |  |  ------------------
  ------------------
 3622|       |
 3623|       |  /* Request the primary if we're certifying another key, and also if
 3624|       |   * signing data while --pgp7 is on since pgp 7 do
 3625|       |   * not understand signatures made by a signing subkey.  PGP 8 does. */
 3626|      4|  req_prim = ((req_usage & PUBKEY_USAGE_CERT)
  ------------------
  |  |   51|      4|#define PUBKEY_USAGE_CERT    GCRY_PK_USAGE_CERT  /* Also good to certify keys.*/
  ------------------
  |  Branch (3626:15): [True: 0, False: 4]
  ------------------
 3627|      4|              || (PGP7 && (req_usage & PUBKEY_USAGE_SIG)));
  ------------------
  |  |  375|      8|#define PGP7    (opt.compliance==CO_PGP7)
  |  |  ------------------
  |  |  |  Branch (375:17): [True: 0, False: 4]
  |  |  ------------------
  ------------------
                            || (PGP7 && (req_usage & PUBKEY_USAGE_SIG)));
  ------------------
  |  |   49|      0|#define PUBKEY_USAGE_SIG     GCRY_PK_USAGE_SIGN  /* Good for signatures. */
  ------------------
  |  Branch (3627:27): [True: 0, False: 0]
  ------------------
 3628|       |
 3629|       |
 3630|      4|  log_assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY);
 3631|       |
 3632|       |  /* For an exact match mark the primary or subkey that matched the
 3633|       |     low-level search criteria.  */
 3634|      4|  if (want_exact)
  ------------------
  |  Branch (3634:7): [True: 4, False: 0]
  ------------------
 3635|      4|    {
 3636|      4|      for (k = keyblock; k; k = k->next)
  ------------------
  |  Branch (3636:26): [True: 4, False: 0]
  ------------------
 3637|      4|	{
 3638|      4|	  if ((k->flag & 1))
  ------------------
  |  Branch (3638:8): [True: 4, False: 0]
  ------------------
 3639|      4|	    {
 3640|      4|	      log_assert (k->pkt->pkttype == PKT_PUBLIC_KEY
 3641|      4|                          || k->pkt->pkttype == PKT_PUBLIC_SUBKEY);
 3642|      0|	      foundk = k;
 3643|      4|              pk = k->pkt->pkt.public_key;
 3644|      4|              pk->flags.exact = 1;
 3645|      4|	      break;
 3646|      4|	    }
 3647|      4|	}
 3648|      4|    }
 3649|       |
 3650|       |  /* Get the user id that matched that low-level search criteria.  */
 3651|     39|  for (k = keyblock; k; k = k->next)
  ------------------
  |  Branch (3651:22): [True: 35, False: 4]
  ------------------
 3652|     35|    {
 3653|     35|      if ((k->flag & 2))
  ------------------
  |  Branch (3653:11): [True: 0, False: 35]
  ------------------
 3654|      0|	{
 3655|      0|	  log_assert (k->pkt->pkttype == PKT_USER_ID);
 3656|      0|	  foundu = k->pkt->pkt.user_id;
 3657|      0|	  break;
 3658|      0|	}
 3659|     35|    }
 3660|       |
 3661|      4|  if (DBG_LOOKUP)
  ------------------
  |  |  357|      4|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      4|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 4]
  |  |  ------------------
  ------------------
 3662|      0|    log_debug ("finish_lookup: checking key %08lX (%s)(req_usage=%x)\n",
 3663|      0|	       (ulong) keyid_from_pk (keyblock->pkt->pkt.public_key, NULL),
 3664|      0|	       foundk ? "one" : "all", req_usage);
  ------------------
  |  Branch (3664:9): [True: 0, False: 0]
  ------------------
 3665|       |
 3666|      4|  if (!req_usage)
  ------------------
  |  Branch (3666:7): [True: 4, False: 0]
  ------------------
 3667|      4|    {
 3668|      4|      latest_key = foundk ? foundk : keyblock;
  ------------------
  |  Branch (3668:20): [True: 4, False: 0]
  ------------------
 3669|      4|      goto found;
 3670|      4|    }
 3671|       |
 3672|      0|  latest_date = 0;
 3673|      0|  latest_key = NULL;
 3674|       |  /* Set LATEST_KEY to the latest (the one with the most recent
 3675|       |   * timestamp) good (valid, not revoked, not expired, etc.) subkey.
 3676|       |   *
 3677|       |   * Don't bother if we are only looking for a primary key or we need
 3678|       |   * an exact match and the exact match is not a subkey.  */
 3679|      0|  if (req_prim || (foundk && foundk->pkt->pkttype != PKT_PUBLIC_SUBKEY))
  ------------------
  |  Branch (3679:7): [True: 0, False: 0]
  |  Branch (3679:20): [True: 0, False: 0]
  |  Branch (3679:30): [True: 0, False: 0]
  ------------------
 3680|      0|    ;
 3681|      0|  else
 3682|      0|    {
 3683|      0|      kbnode_t nextk;
 3684|      0|      int n_subkeys = 0;
 3685|      0|      int n_revoked_or_expired = 0;
 3686|      0|      int last_secret_key_avail = 0;
 3687|       |
 3688|       |      /* Either start a loop or check just this one subkey.  */
 3689|      0|      for (k = foundk ? foundk : keyblock; k; k = nextk)
  ------------------
  |  Branch (3689:16): [True: 0, False: 0]
  |  Branch (3689:44): [True: 0, False: 0]
  ------------------
 3690|      0|	{
 3691|      0|	  if (foundk)
  ------------------
  |  Branch (3691:8): [True: 0, False: 0]
  ------------------
 3692|      0|            {
 3693|       |              /* If FOUNDK is not NULL, then only consider that exact
 3694|       |                 key, i.e., don't iterate.  */
 3695|      0|              nextk = NULL;
 3696|      0|            }
 3697|      0|	  else
 3698|      0|	    nextk = k->next;
 3699|       |
 3700|      0|	  if (k->pkt->pkttype != PKT_PUBLIC_SUBKEY)
  ------------------
  |  Branch (3700:8): [True: 0, False: 0]
  ------------------
 3701|      0|	    continue;
 3702|       |
 3703|      0|	  pk = k->pkt->pkt.public_key;
 3704|      0|	  if (DBG_LOOKUP)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3705|      0|	    log_debug ("\tchecking subkey %08lX\n",
 3706|      0|		       (ulong) keyid_from_pk (pk, NULL));
 3707|       |
 3708|      0|	  if (!pk->flags.valid)
  ------------------
  |  Branch (3708:8): [True: 0, False: 0]
  ------------------
 3709|      0|	    {
 3710|      0|	      if (DBG_LOOKUP)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3711|      0|		log_debug ("\tsubkey not valid\n");
 3712|      0|	      continue;
 3713|      0|	    }
 3714|      0|	  if (!((pk->pubkey_usage & USAGE_MASK) & req_usage))
  ------------------
  |  | 3620|      0|#define USAGE_MASK  (PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC|PUBKEY_USAGE_CERT)
  |  |  ------------------
  |  |  |  |   49|      0|#define PUBKEY_USAGE_SIG     GCRY_PK_USAGE_SIGN  /* Good for signatures. */
  |  |  ------------------
  |  |               #define USAGE_MASK  (PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC|PUBKEY_USAGE_CERT)
  |  |  ------------------
  |  |  |  |   50|      0|#define PUBKEY_USAGE_ENC     GCRY_PK_USAGE_ENCR  /* Good for encryption. */
  |  |  ------------------
  |  |               #define USAGE_MASK  (PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC|PUBKEY_USAGE_CERT)
  |  |  ------------------
  |  |  |  |   51|      0|#define PUBKEY_USAGE_CERT    GCRY_PK_USAGE_CERT  /* Also good to certify keys.*/
  |  |  ------------------
  ------------------
  |  Branch (3714:8): [True: 0, False: 0]
  ------------------
 3715|      0|	    {
 3716|      0|	      if (DBG_LOOKUP)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3717|      0|		log_debug ("\tusage does not match: want=%x have=%x\n",
 3718|      0|			   req_usage, pk->pubkey_usage);
 3719|      0|	      continue;
 3720|      0|	    }
 3721|       |
 3722|      0|          n_subkeys++;
 3723|      0|	  if (pk->flags.revoked)
  ------------------
  |  Branch (3723:8): [True: 0, False: 0]
  ------------------
 3724|      0|	    {
 3725|      0|	      if (DBG_LOOKUP)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3726|      0|		log_debug ("\tsubkey has been revoked\n");
 3727|      0|              n_revoked_or_expired++;
 3728|      0|	      continue;
 3729|      0|	    }
 3730|      0|	  if (pk->has_expired)
  ------------------
  |  Branch (3730:8): [True: 0, False: 0]
  ------------------
 3731|      0|	    {
 3732|      0|	      if (DBG_LOOKUP)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3733|      0|		log_debug ("\tsubkey has expired\n");
 3734|      0|              n_revoked_or_expired++;
 3735|      0|	      continue;
 3736|      0|	    }
 3737|      0|	  if (pk->timestamp > curtime && !opt.ignore_valid_from)
  ------------------
  |  Branch (3737:8): [True: 0, False: 0]
  |  Branch (3737:35): [True: 0, False: 0]
  ------------------
 3738|      0|	    {
 3739|      0|	      if (DBG_LOOKUP)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3740|      0|		log_debug ("\tsubkey not yet valid\n");
 3741|      0|	      continue;
 3742|      0|	    }
 3743|       |
 3744|      0|          if (want_secret)
  ------------------
  |  Branch (3744:15): [True: 0, False: 0]
  ------------------
 3745|      0|            {
 3746|      0|              int secret_key_avail = agent_probe_secret_key (NULL, pk);
 3747|       |
 3748|      0|              if (!secret_key_avail)
  ------------------
  |  Branch (3748:19): [True: 0, False: 0]
  ------------------
 3749|      0|                {
 3750|      0|                  if (DBG_LOOKUP)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3751|      0|                    log_debug ("\tno secret key\n");
 3752|      0|                  continue;
 3753|      0|                }
 3754|       |
 3755|      0|              if (secret_key_avail > last_secret_key_avail)
  ------------------
  |  Branch (3755:19): [True: 0, False: 0]
  ------------------
 3756|      0|                {
 3757|       |                  /* Use this key.  */
 3758|      0|                  last_secret_key_avail = secret_key_avail;
 3759|      0|                  latest_date = 0;
 3760|      0|                }
 3761|      0|            }
 3762|       |
 3763|      0|	  if (DBG_LOOKUP)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3764|      0|	    log_debug ("\tsubkey might be fine\n");
 3765|       |	  /* In case a key has a timestamp of 0 set, we make sure
 3766|       |	     that it is used.  A better change would be to compare
 3767|       |	     ">=" but that might also change the selected keys and
 3768|       |	     is as such a more intrusive change.  */
 3769|      0|	  if (pk->timestamp > latest_date || (!pk->timestamp && !latest_date))
  ------------------
  |  Branch (3769:8): [True: 0, False: 0]
  |  Branch (3769:40): [True: 0, False: 0]
  |  Branch (3769:58): [True: 0, False: 0]
  ------------------
 3770|      0|	    {
 3771|      0|	      latest_date = pk->timestamp;
 3772|      0|	      latest_key = k;
 3773|      0|	    }
 3774|      0|	}
 3775|      0|      if (n_subkeys == n_revoked_or_expired && r_flags)
  ------------------
  |  Branch (3775:11): [True: 0, False: 0]
  |  Branch (3775:48): [True: 0, False: 0]
  ------------------
 3776|      0|        *r_flags |= LOOKUP_ALL_SUBKEYS_EXPIRED;
  ------------------
  |  |   54|      0|#define LOOKUP_ALL_SUBKEYS_EXPIRED (1<<1)  /* or revoked */
  ------------------
 3777|      0|    }
 3778|       |
 3779|       |  /* Check if the primary key is ok (valid, not revoke, not expire,
 3780|       |   * matches requested usage) if:
 3781|       |   *
 3782|       |   *   - we didn't find an appropriate subkey and we're not doing an
 3783|       |   *     exact search,
 3784|       |   *
 3785|       |   *   - we're doing an exact match and the exact match was the
 3786|       |   *     primary key, or,
 3787|       |   *
 3788|       |   *   - we're just considering the primary key.  */
 3789|      0|  if ((!latest_key && !want_exact) || foundk == keyblock || req_prim)
  ------------------
  |  Branch (3789:8): [True: 0, False: 0]
  |  Branch (3789:23): [True: 0, False: 0]
  |  Branch (3789:39): [True: 0, False: 0]
  |  Branch (3789:61): [True: 0, False: 0]
  ------------------
 3790|      0|    {
 3791|      0|      if (DBG_LOOKUP && !foundk && !req_prim)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (3791:25): [True: 0, False: 0]
  |  Branch (3791:36): [True: 0, False: 0]
  ------------------
 3792|      0|	log_debug ("\tno suitable subkeys found - trying primary\n");
 3793|      0|      pk = keyblock->pkt->pkt.public_key;
 3794|      0|      if (!pk->flags.valid)
  ------------------
  |  Branch (3794:11): [True: 0, False: 0]
  ------------------
 3795|      0|	{
 3796|      0|	  if (DBG_LOOKUP)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3797|      0|	    log_debug ("\tprimary key not valid\n");
 3798|      0|	}
 3799|      0|      else if (!((pk->pubkey_usage & USAGE_MASK) & req_usage))
  ------------------
  |  | 3620|      0|#define USAGE_MASK  (PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC|PUBKEY_USAGE_CERT)
  |  |  ------------------
  |  |  |  |   49|      0|#define PUBKEY_USAGE_SIG     GCRY_PK_USAGE_SIGN  /* Good for signatures. */
  |  |  ------------------
  |  |               #define USAGE_MASK  (PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC|PUBKEY_USAGE_CERT)
  |  |  ------------------
  |  |  |  |   50|      0|#define PUBKEY_USAGE_ENC     GCRY_PK_USAGE_ENCR  /* Good for encryption. */
  |  |  ------------------
  |  |               #define USAGE_MASK  (PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC|PUBKEY_USAGE_CERT)
  |  |  ------------------
  |  |  |  |   51|      0|#define PUBKEY_USAGE_CERT    GCRY_PK_USAGE_CERT  /* Also good to certify keys.*/
  |  |  ------------------
  ------------------
  |  Branch (3799:16): [True: 0, False: 0]
  ------------------
 3800|      0|	{
 3801|      0|	  if (DBG_LOOKUP)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3802|      0|	    log_debug ("\tprimary key usage does not match: "
 3803|      0|		       "want=%x have=%x\n", req_usage, pk->pubkey_usage);
 3804|      0|	}
 3805|      0|      else if (pk->flags.revoked)
  ------------------
  |  Branch (3805:16): [True: 0, False: 0]
  ------------------
 3806|      0|	{
 3807|      0|	  if (DBG_LOOKUP)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3808|      0|	    log_debug ("\tprimary key has been revoked\n");
 3809|      0|	}
 3810|      0|      else if (pk->has_expired)
  ------------------
  |  Branch (3810:16): [True: 0, False: 0]
  ------------------
 3811|      0|	{
 3812|      0|	  if (DBG_LOOKUP)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3813|      0|	    log_debug ("\tprimary key has expired\n");
 3814|      0|	}
 3815|      0|      else /* Okay.  */
 3816|      0|	{
 3817|      0|	  if (DBG_LOOKUP)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3818|      0|	    log_debug ("\tprimary key may be used\n");
 3819|      0|	  latest_key = keyblock;
 3820|      0|	}
 3821|      0|    }
 3822|       |
 3823|      0|  if (!latest_key)
  ------------------
  |  Branch (3823:7): [True: 0, False: 0]
  ------------------
 3824|      0|    {
 3825|      0|      if (DBG_LOOKUP)
  ------------------
  |  |  357|      0|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      0|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3826|      0|	log_debug ("\tno suitable key found -  giving up\n");
 3827|      0|      if (r_flags)
  ------------------
  |  Branch (3827:11): [True: 0, False: 0]
  ------------------
 3828|      0|        *r_flags |= LOOKUP_NOT_SELECTED;
  ------------------
  |  |   53|      0|#define LOOKUP_NOT_SELECTED        (1<<0)
  ------------------
 3829|      0|      return NULL; /* Not found.  */
 3830|      0|    }
 3831|       |
 3832|      4| found:
 3833|      4|  if (DBG_LOOKUP)
  ------------------
  |  |  357|      4|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|      4|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 4]
  |  |  ------------------
  ------------------
 3834|      0|    log_debug ("\tusing key %08lX\n",
 3835|      0|	       (ulong) keyid_from_pk (latest_key->pkt->pkt.public_key, NULL));
 3836|       |
 3837|      4|  if (latest_key)
  ------------------
  |  Branch (3837:7): [True: 4, False: 0]
  ------------------
 3838|      4|    {
 3839|      4|      pk = latest_key->pkt->pkt.public_key;
 3840|      4|      free_user_id (pk->user_id);
 3841|      4|      pk->user_id = scopy_user_id (foundu);
 3842|      4|    }
 3843|       |
 3844|      4|  if (latest_key != keyblock && opt.verbose)
  ------------------
  |  Branch (3844:7): [True: 0, False: 4]
  |  Branch (3844:33): [True: 0, False: 0]
  ------------------
 3845|      0|    {
 3846|      0|      char *tempkeystr =
 3847|      0|	xstrdup (keystr_from_pk (latest_key->pkt->pkt.public_key));
  ------------------
  |  |  112|      0|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
 3848|      0|      log_info (_("using subkey %s instead of primary key %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3849|      0|		tempkeystr, keystr_from_pk (keyblock->pkt->pkt.public_key));
 3850|      0|      xfree (tempkeystr);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 3851|      0|    }
 3852|       |
 3853|      4|  cache_put_keyblock (keyblock);
 3854|       |
 3855|      4|  return latest_key ? latest_key : keyblock; /* Found.  */
  ------------------
  |  Branch (3855:10): [True: 4, False: 0]
  ------------------
 3856|      0|}
getkey.c:print_status_key_considered:
 3862|      4|{
 3863|      4|  char hexfpr[2*MAX_FINGERPRINT_LEN + 1];
 3864|      4|  kbnode_t node;
 3865|      4|  char flagbuf[20];
 3866|       |
 3867|      4|  if (!is_status_enabled ())
  ------------------
  |  Branch (3867:7): [True: 4, False: 0]
  ------------------
 3868|      4|    return;
 3869|       |
 3870|      0|  for (node=keyblock; node; node = node->next)
  ------------------
  |  Branch (3870:23): [True: 0, False: 0]
  ------------------
 3871|      0|    if (node->pkt->pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (3871:9): [True: 0, False: 0]
  ------------------
 3872|      0|        || node->pkt->pkttype == PKT_SECRET_KEY)
  ------------------
  |  Branch (3872:12): [True: 0, False: 0]
  ------------------
 3873|      0|      break;
 3874|      0|  if (!node)
  ------------------
  |  Branch (3874:7): [True: 0, False: 0]
  ------------------
 3875|      0|    {
 3876|      0|      log_error ("%s: keyblock w/o primary key\n", __func__);
 3877|      0|      return;
 3878|      0|    }
 3879|       |
 3880|      0|  hexfingerprint (node->pkt->pkt.public_key, hexfpr, sizeof hexfpr);
 3881|      0|  snprintf (flagbuf, sizeof flagbuf, " %u", flags);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
 3882|      0|  write_status_strings (STATUS_KEY_CONSIDERED, hexfpr, flagbuf, NULL);
 3883|      0|}
getkey.c:lookup:
 3907|  1.62k|{
 3908|  1.62k|  int rc;
 3909|  1.62k|  int no_suitable_key = 0;
 3910|  1.62k|  KBNODE keyblock = NULL;
 3911|  1.62k|  KBNODE found_key = NULL;
 3912|  1.62k|  unsigned int infoflags;
 3913|       |
 3914|  1.62k|  log_assert (ret_found_key == NULL || ret_keyblock != NULL);
 3915|  1.62k|  if (ret_keyblock)
  ------------------
  |  Branch (3915:7): [True: 1.62k, False: 0]
  ------------------
 3916|  1.62k|    *ret_keyblock = NULL;
 3917|       |
 3918|  1.62k|  for (;;)
 3919|  1.62k|    {
 3920|  1.62k|      rc = keydb_search (ctx->kr_handle, ctx->items, ctx->nitems, NULL);
 3921|  1.62k|      if (rc)
  ------------------
  |  Branch (3921:11): [True: 1.62k, False: 4]
  ------------------
 3922|  1.62k|        break;
 3923|       |
 3924|       |      /* If we are iterating over the entire database, then we need to
 3925|       |       * change from KEYDB_SEARCH_MODE_FIRST, which does an implicit
 3926|       |       * reset, to KEYDB_SEARCH_MODE_NEXT, which gets the next record.  */
 3927|      4|      if (ctx->nitems && ctx->items->mode == KEYDB_SEARCH_MODE_FIRST)
  ------------------
  |  Branch (3927:11): [True: 4, False: 0]
  |  Branch (3927:26): [True: 0, False: 4]
  ------------------
 3928|      0|	ctx->items->mode = KEYDB_SEARCH_MODE_NEXT;
 3929|       |
 3930|      4|      rc = keydb_get_keyblock (ctx->kr_handle, &keyblock);
 3931|      4|      if (rc)
  ------------------
  |  Branch (3931:11): [True: 0, False: 4]
  ------------------
 3932|      0|	{
 3933|      0|	  log_error ("keydb_get_keyblock failed: %s\n", gpg_strerror (rc));
 3934|      0|	  goto skip;
 3935|      0|	}
 3936|       |
 3937|      4|      if (want_secret)
  ------------------
  |  Branch (3937:11): [True: 0, False: 4]
  ------------------
 3938|      0|	{
 3939|      0|	  rc = agent_probe_any_secret_key (ctrl, keyblock);
 3940|      0|	  if (gpg_err_code(rc) == GPG_ERR_NO_SECKEY)
  ------------------
  |  Branch (3940:8): [True: 0, False: 0]
  ------------------
 3941|      0|	    goto skip; /* No secret key available.  */
 3942|      0|	  if (rc)
  ------------------
  |  Branch (3942:8): [True: 0, False: 0]
  ------------------
 3943|      0|	    goto found; /* Unexpected error.  */
 3944|      0|	}
 3945|       |
 3946|       |      /* Warning: node flag bits 0 and 1 should be preserved by
 3947|       |       * merge_selfsigs.  */
 3948|      4|      merge_selfsigs (ctrl, keyblock);
 3949|      4|      found_key = finish_lookup (keyblock, ctx->req_usage, ctx->exact,
 3950|      4|                                 want_secret, &infoflags);
 3951|      4|      print_status_key_considered (keyblock, infoflags);
 3952|      4|      if (found_key)
  ------------------
  |  Branch (3952:11): [True: 4, False: 0]
  ------------------
 3953|      4|	{
 3954|      4|	  no_suitable_key = 0;
 3955|      4|	  goto found;
 3956|      4|	}
 3957|      0|      else
 3958|      0|        {
 3959|      0|          no_suitable_key = 1;
 3960|      0|        }
 3961|       |
 3962|      0|    skip:
 3963|       |      /* Release resources and continue search. */
 3964|      0|      release_kbnode (keyblock);
 3965|      0|      keyblock = NULL;
 3966|       |      /* The keyblock cache ignores the current "file position".
 3967|       |       * Thus, if we request the next result and the cache matches
 3968|       |       * (and it will since it is what we just looked for), we'll get
 3969|       |       * the same entry back!  We can avoid this infinite loop by
 3970|       |       * disabling the cache.  */
 3971|      0|      keydb_disable_caching (ctx->kr_handle);
 3972|      0|    }
 3973|       |
 3974|  1.62k| found:
 3975|  1.62k|  if (rc && gpg_err_code (rc) != GPG_ERR_NOT_FOUND)
  ------------------
  |  Branch (3975:7): [True: 1.62k, False: 4]
  |  Branch (3975:13): [True: 0, False: 1.62k]
  ------------------
 3976|      0|    log_error ("keydb_search failed: %s\n", gpg_strerror (rc));
 3977|       |
 3978|  1.62k|  if (!rc)
  ------------------
  |  Branch (3978:7): [True: 4, False: 1.62k]
  ------------------
 3979|      4|    {
 3980|      4|      if (ret_keyblock)
  ------------------
  |  Branch (3980:11): [True: 4, False: 0]
  ------------------
 3981|      4|        {
 3982|      4|          *ret_keyblock = keyblock; /* Return the keyblock.  */
 3983|      4|          keyblock = NULL;
 3984|      4|        }
 3985|      4|    }
 3986|  1.62k|  else if (gpg_err_code (rc) == GPG_ERR_NOT_FOUND && no_suitable_key)
  ------------------
  |  Branch (3986:12): [True: 1.62k, False: 0]
  |  Branch (3986:54): [True: 0, False: 1.62k]
  ------------------
 3987|      0|    rc = want_secret? GPG_ERR_UNUSABLE_SECKEY : GPG_ERR_UNUSABLE_PUBKEY;
  ------------------
  |  Branch (3987:10): [True: 0, False: 0]
  ------------------
 3988|  1.62k|  else if (gpg_err_code (rc) == GPG_ERR_NOT_FOUND)
  ------------------
  |  Branch (3988:12): [True: 1.62k, False: 0]
  ------------------
 3989|  1.62k|    rc = want_secret? GPG_ERR_NO_SECKEY : GPG_ERR_NO_PUBKEY;
  ------------------
  |  Branch (3989:10): [True: 0, False: 1.62k]
  ------------------
 3990|       |
 3991|  1.62k|  release_kbnode (keyblock);
 3992|       |
 3993|  1.62k|  if (ret_found_key)
  ------------------
  |  Branch (3993:7): [True: 1.62k, False: 0]
  ------------------
 3994|  1.62k|    {
 3995|  1.62k|      if (! rc)
  ------------------
  |  Branch (3995:11): [True: 4, False: 1.62k]
  ------------------
 3996|      4|	*ret_found_key = found_key;
 3997|  1.62k|      else
 3998|  1.62k|	*ret_found_key = NULL;
 3999|  1.62k|    }
 4000|       |
 4001|  1.62k|  return rc;
 4002|  1.62k|}
getkey.c:user_id_not_found_utf8:
  248|      3|{
  249|      3|  static char *text;
  250|       |
  251|      3|  if (!text)
  ------------------
  |  Branch (251:7): [True: 1, False: 2]
  ------------------
  252|      1|    text = native_to_utf8 (_("[User ID not found]"));
  ------------------
  |  |   28|      1|#  define _(a) gettext (a)
  ------------------
  253|      3|  return text;
  254|      3|}
getkey.c:get_user_id_byfpr:
 4207|     11|{
 4208|     11|  char *name;
 4209|       |
 4210|     11|  name = cache_get_uid_byfpr (fpr, fprlen, rn);
 4211|     11|  if (!name)
  ------------------
  |  Branch (4211:7): [True: 4, False: 7]
  ------------------
 4212|      4|    {
 4213|       |      /* Get it so that the cache will be filled.  */
 4214|      4|      if (!get_pubkey_byfprint (ctrl, NULL, NULL, fpr, fprlen))
  ------------------
  |  Branch (4214:11): [True: 4, False: 0]
  ------------------
 4215|      4|        name = cache_get_uid_byfpr (fpr, fprlen, rn);
 4216|      4|    }
 4217|       |
 4218|     11|  if (!name)
  ------------------
  |  Branch (4218:7): [True: 3, False: 8]
  ------------------
 4219|      3|    {
 4220|      3|      name = xstrdup (user_id_not_found_utf8 ());
  ------------------
  |  |  112|      3|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
 4221|      3|      *rn = strlen (name);
 4222|      3|    }
 4223|       |
 4224|     11|  return name;
 4225|     11|}

import_new_stats_handle:
  330|     53|{
  331|     53|  return xmalloc_clear ( sizeof (struct import_stats_s) );
  ------------------
  |  |  116|     53|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
  332|     53|}
import_release_stats_handle:
  337|     53|{
  338|     53|  xfree (p);
  ------------------
  |  |  104|     53|#define xfree(a)         gcry_free ((a))
  ------------------
  339|     53|}
import_keys:
  609|     53|{
  610|     53|  import_keys_internal (ctrl, NULL, fnames, nnames, stats_handle,
  611|     53|                        NULL, NULL, options, NULL, NULL, origin, url);
  612|     53|}
import_print_stats:
  837|     53|{
  838|     53|  if (!opt.quiet)
  ------------------
  |  Branch (838:7): [True: 53, False: 0]
  ------------------
  839|     53|    {
  840|     53|      log_info(_("Total number processed: %lu\n"),
  ------------------
  |  |   28|     53|#  define _(a) gettext (a)
  ------------------
  841|     53|               stats->count + stats->v3keys);
  842|     53|      if (stats->v3keys)
  ------------------
  |  Branch (842:11): [True: 0, False: 53]
  ------------------
  843|      0|        log_info(_("    skipped PGP-2 keys: %lu\n"), stats->v3keys);
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  844|     53|      if (stats->skipped_new_keys )
  ------------------
  |  Branch (844:11): [True: 0, False: 53]
  ------------------
  845|      0|        log_info(_("      skipped new keys: %lu\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  846|      0|                 stats->skipped_new_keys );
  847|     53|      if (stats->no_user_id )
  ------------------
  |  Branch (847:11): [True: 10, False: 43]
  ------------------
  848|     10|        log_info(_("          w/o user IDs: %lu\n"), stats->no_user_id );
  ------------------
  |  |   28|     10|#  define _(a) gettext (a)
  ------------------
  849|     53|      if (stats->imported)
  ------------------
  |  Branch (849:11): [True: 2, False: 51]
  ------------------
  850|      2|        {
  851|      2|          log_info(_("              imported: %lu"), stats->imported );
  ------------------
  |  |   28|      2|#  define _(a) gettext (a)
  ------------------
  852|      2|          log_printf ("\n");
  853|      2|        }
  854|     53|      if (stats->unchanged )
  ------------------
  |  Branch (854:11): [True: 0, False: 53]
  ------------------
  855|      0|        log_info(_("             unchanged: %lu\n"), stats->unchanged );
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  856|     53|      if (stats->n_uids )
  ------------------
  |  Branch (856:11): [True: 0, False: 53]
  ------------------
  857|      0|        log_info(_("          new user IDs: %lu\n"), stats->n_uids );
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  858|     53|      if (stats->n_subk )
  ------------------
  |  Branch (858:11): [True: 0, False: 53]
  ------------------
  859|      0|        log_info(_("           new subkeys: %lu\n"), stats->n_subk );
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  860|     53|      if (stats->n_sigs )
  ------------------
  |  Branch (860:11): [True: 2, False: 51]
  ------------------
  861|      2|        log_info(_("        new signatures: %lu\n"), stats->n_sigs );
  ------------------
  |  |   28|      2|#  define _(a) gettext (a)
  ------------------
  862|     53|      if (stats->n_revoc )
  ------------------
  |  Branch (862:11): [True: 0, False: 53]
  ------------------
  863|      0|        log_info(_("   new key revocations: %lu\n"), stats->n_revoc );
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  864|     53|      if (stats->secret_read )
  ------------------
  |  Branch (864:11): [True: 5, False: 48]
  ------------------
  865|      5|        log_info(_("      secret keys read: %lu\n"), stats->secret_read );
  ------------------
  |  |   28|      5|#  define _(a) gettext (a)
  ------------------
  866|     53|      if (stats->secret_imported )
  ------------------
  |  Branch (866:11): [True: 0, False: 53]
  ------------------
  867|      0|        log_info(_("  secret keys imported: %lu\n"), stats->secret_imported );
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  868|     53|      if (stats->secret_dups )
  ------------------
  |  Branch (868:11): [True: 0, False: 53]
  ------------------
  869|      0|        log_info(_(" secret keys unchanged: %lu\n"), stats->secret_dups );
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  870|     53|      if (stats->not_imported )
  ------------------
  |  Branch (870:11): [True: 0, False: 53]
  ------------------
  871|      0|        log_info(_("          not imported: %lu\n"), stats->not_imported );
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  872|     53|      if (stats->n_sigs_cleaned)
  ------------------
  |  Branch (872:11): [True: 1, False: 52]
  ------------------
  873|      1|        log_info(_("    signatures cleaned: %lu\n"),stats->n_sigs_cleaned);
  ------------------
  |  |   28|      1|#  define _(a) gettext (a)
  ------------------
  874|     53|      if (stats->n_uids_cleaned)
  ------------------
  |  Branch (874:11): [True: 0, False: 53]
  ------------------
  875|      0|        log_info(_("      user IDs cleaned: %lu\n"),stats->n_uids_cleaned);
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  876|     53|    }
  877|       |
  878|     53|  if (is_status_enabled ())
  ------------------
  |  Branch (878:7): [True: 0, False: 53]
  ------------------
  879|      0|    {
  880|      0|      char buf[15*20];
  881|       |
  882|      0|      snprintf (buf, sizeof buf,
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  883|      0|                "%lu %lu %lu 0 %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu",
  884|      0|		stats->count + stats->v3keys,
  885|      0|		stats->no_user_id,
  886|      0|		stats->imported,
  887|      0|		stats->unchanged,
  888|      0|		stats->n_uids,
  889|      0|		stats->n_subk,
  890|      0|		stats->n_sigs,
  891|      0|		stats->n_revoc,
  892|      0|		stats->secret_read,
  893|      0|		stats->secret_imported,
  894|      0|		stats->secret_dups,
  895|      0|		stats->skipped_new_keys,
  896|      0|                stats->not_imported,
  897|      0|                stats->v3keys );
  898|      0|      write_status_text (STATUS_IMPORT_RES, buf);
  899|      0|    }
  900|     53|}
import.c:import_keys_internal:
  535|     53|{
  536|     53|  int i;
  537|     53|  gpg_error_t err = 0;
  538|     53|  struct import_stats_s *stats = stats_handle;
  539|       |
  540|     53|  if (!stats)
  ------------------
  |  Branch (540:7): [True: 53, False: 0]
  ------------------
  541|     53|    stats = import_new_stats_handle ();
  542|       |
  543|     53|  if (inp)
  ------------------
  |  Branch (543:7): [True: 0, False: 53]
  ------------------
  544|      0|    {
  545|      0|      err = import (ctrl, inp, "[stream]", stats, fpr, fpr_len, options,
  546|      0|                    screener, screener_arg, origin, url);
  547|      0|    }
  548|     53|  else
  549|     53|    {
  550|     53|      if (!fnames && !nnames)
  ------------------
  |  Branch (550:11): [True: 0, False: 53]
  |  Branch (550:22): [True: 0, False: 0]
  ------------------
  551|      0|        nnames = 1;  /* Ohh what a ugly hack to jump into the loop */
  552|       |
  553|    106|      for (i=0; i < nnames; i++)
  ------------------
  |  Branch (553:17): [True: 53, False: 53]
  ------------------
  554|     53|        {
  555|     53|          const char *fname = fnames? fnames[i] : NULL;
  ------------------
  |  Branch (555:31): [True: 53, False: 0]
  ------------------
  556|     53|          IOBUF inp2 = iobuf_open(fname);
  557|       |
  558|     53|          if (!fname)
  ------------------
  |  Branch (558:15): [True: 0, False: 53]
  ------------------
  559|      0|            fname = "[stdin]";
  560|     53|          if (inp2 && is_secured_file (iobuf_get_fd (inp2)))
  ------------------
  |  Branch (560:15): [True: 53, False: 0]
  |  Branch (560:23): [True: 0, False: 53]
  ------------------
  561|      0|            {
  562|      0|              iobuf_close (inp2);
  563|      0|              inp2 = NULL;
  564|      0|              gpg_err_set_errno (EPERM);
  565|      0|            }
  566|     53|          if (!inp2)
  ------------------
  |  Branch (566:15): [True: 0, False: 53]
  ------------------
  567|      0|            log_error (_("can't open '%s': %s\n"), fname, strerror (errno));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  568|     53|          else
  569|     53|            {
  570|     53|              err = import (ctrl, inp2, fname, stats, fpr, fpr_len, options,
  571|     53|                           screener, screener_arg, origin, url);
  572|     53|              iobuf_close (inp2);
  573|       |              /* Must invalidate that ugly cache to actually close it. */
  574|     53|              iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)fname);
  575|     53|              if (err)
  ------------------
  |  Branch (575:19): [True: 23, False: 30]
  ------------------
  576|     23|                log_error ("import from '%s' failed: %s\n",
  577|     23|                           fname, gpg_strerror (err) );
  578|     53|            }
  579|     53|          if (!fname)
  ------------------
  |  Branch (579:15): [True: 0, False: 53]
  ------------------
  580|      0|            break;
  581|     53|	}
  582|     53|    }
  583|       |
  584|     53|  if (!stats_handle)
  ------------------
  |  Branch (584:7): [True: 53, False: 0]
  ------------------
  585|     53|    {
  586|     53|      if ((options & (IMPORT_SHOW | IMPORT_DRY_RUN))
  ------------------
  |  |  386|     53|#define IMPORT_SHOW                      (1<<3)
  ------------------
                    if ((options & (IMPORT_SHOW | IMPORT_DRY_RUN))
  ------------------
  |  |  395|     53|#define IMPORT_DRY_RUN                   (1<<12)
  ------------------
  |  Branch (586:11): [True: 53, False: 0]
  ------------------
  587|     53|          != (IMPORT_SHOW | IMPORT_DRY_RUN))
  ------------------
  |  |  386|     53|#define IMPORT_SHOW                      (1<<3)
  ------------------
                        != (IMPORT_SHOW | IMPORT_DRY_RUN))
  ------------------
  |  |  395|     53|#define IMPORT_DRY_RUN                   (1<<12)
  ------------------
  588|     53|        import_print_stats (stats);
  589|     53|      import_release_stats_handle (stats);
  590|     53|    }
  591|       |
  592|       |  /* If no fast import and the trustdb is dirty (i.e. we added a key
  593|       |     or userID that had something other than a selfsig, a signature
  594|       |     that was other than a selfsig, or any revocation), then
  595|       |     update/check the trustdb if the user specified by setting
  596|       |     interactive or by not setting no-auto-check-trustdb */
  597|       |
  598|     53|  if (!(options & IMPORT_FAST))
  ------------------
  |  |  385|     53|#define IMPORT_FAST                      (1<<2)
  ------------------
  |  Branch (598:7): [True: 53, False: 0]
  ------------------
  599|     53|    check_or_update_trustdb (ctrl);
  600|       |
  601|     53|  return err;
  602|     53|}
import.c:import:
  648|     53|{
  649|     53|  PACKET *pending_pkt = NULL;
  650|     53|  kbnode_t keyblock = NULL;  /* Need to initialize because gcc can't
  651|       |                                grasp the return semantics of
  652|       |                                read_block. */
  653|     53|  kbnode_t secattic = NULL;  /* Kludge for PGP desktop percularity */
  654|     53|  int rc = 0;
  655|     53|  int v3keys;
  656|       |
  657|     53|  getkey_disable_caches ();
  658|       |
  659|     53|  if (!opt.no_armor) /* Armored reading is not disabled.  */
  ------------------
  |  Branch (659:7): [True: 53, False: 0]
  ------------------
  660|     53|    {
  661|     53|      armor_filter_context_t *afx;
  662|       |
  663|     53|      afx = new_armor_context ();
  664|     53|      afx->only_keyblocks = 1;
  665|     53|      push_armor_filter (afx, inp);
  666|     53|      release_armor_context (afx);
  667|     53|    }
  668|       |
  669|  1.08k|  while (!(rc = read_block (inp, options, &pending_pkt, &keyblock, &v3keys)))
  ------------------
  |  Branch (669:10): [True: 1.03k, False: 53]
  ------------------
  670|  1.03k|    {
  671|  1.03k|      stats->v3keys += v3keys;
  672|  1.03k|      if (keyblock->pkt->pkttype == PKT_PUBLIC_KEY)
  ------------------
  |  Branch (672:11): [True: 717, False: 313]
  ------------------
  673|    717|        {
  674|    717|          rc = import_one (ctrl, keyblock,
  675|    717|                           stats, fpr, fpr_len, options, 0, 0,
  676|    717|                           screener, screener_arg, origin, url, NULL);
  677|    717|          if (secattic)
  ------------------
  |  Branch (677:15): [True: 0, False: 717]
  ------------------
  678|      0|            {
  679|      0|              byte tmpfpr[MAX_FINGERPRINT_LEN];
  680|      0|              size_t tmpfprlen;
  681|       |
  682|      0|              if (!rc && !(opt.dry_run || (options & IMPORT_DRY_RUN)))
  ------------------
  |  |  395|      0|#define IMPORT_DRY_RUN                   (1<<12)
  ------------------
  |  Branch (682:19): [True: 0, False: 0]
  |  Branch (682:28): [True: 0, False: 0]
  |  Branch (682:43): [True: 0, False: 0]
  ------------------
  683|      0|                {
  684|       |                  /* Kudge for PGP desktop - see below.  */
  685|      0|                  fingerprint_from_pk (keyblock->pkt->pkt.public_key,
  686|      0|                                       tmpfpr, &tmpfprlen);
  687|      0|                  rc = import_matching_seckeys (ctrl, secattic,
  688|      0|                                                tmpfpr, tmpfprlen,
  689|      0|                                                stats, opt.batch);
  690|      0|                }
  691|      0|              release_kbnode (secattic);
  692|      0|              secattic = NULL;
  693|      0|            }
  694|    717|        }
  695|    313|      else if (keyblock->pkt->pkttype == PKT_SECRET_KEY)
  ------------------
  |  Branch (695:16): [True: 268, False: 45]
  ------------------
  696|    268|        {
  697|    268|          release_kbnode (secattic);
  698|    268|          secattic = NULL;
  699|    268|          rc = import_secret_one (ctrl, keyblock, stats,
  700|    268|                                  opt.batch, options, 0,
  701|    268|                                  screener, screener_arg, &secattic);
  702|    268|          keyblock = NULL;  /* Ownership was transferred.  */
  703|    268|          if (secattic)
  ------------------
  |  Branch (703:15): [True: 172, False: 96]
  ------------------
  704|    172|            {
  705|    172|              if (gpg_err_code (rc) == GPG_ERR_NO_PUBKEY)
  ------------------
  |  Branch (705:19): [True: 172, False: 0]
  ------------------
  706|    172|                rc = 0; /* Try import after the next pubkey.  */
  707|       |
  708|       |              /* The attic is a workaround for the peculiar PGP
  709|       |               * Desktop method of exporting a secret key: The
  710|       |               * exported file is the concatenation of two armored
  711|       |               * keyblocks; first the private one and then the public
  712|       |               * one.  The strange thing is that the secret one has no
  713|       |               * binding signatures at all and thus we have not
  714|       |               * imported it.  The attic stores that secret keys and
  715|       |               * we try to import it once after the very next public
  716|       |               * keyblock.  */
  717|    172|            }
  718|    268|        }
  719|     45|      else if (keyblock->pkt->pkttype == PKT_SIGNATURE
  ------------------
  |  Branch (719:16): [True: 45, False: 0]
  ------------------
  720|     45|               && IS_KEY_REV (keyblock->pkt->pkt.signature) )
  ------------------
  |  |   45|     45|#define IS_KEY_REV(s)    ((s)->sig_class == 0x20)
  |  |  ------------------
  |  |  |  Branch (45:26): [True: 45, False: 0]
  |  |  ------------------
  ------------------
  721|     45|        {
  722|     45|          release_kbnode (secattic);
  723|     45|          secattic = NULL;
  724|     45|          rc = import_revoke_cert (ctrl, keyblock, options, stats);
  725|     45|        }
  726|      0|      else
  727|      0|        {
  728|      0|          release_kbnode (secattic);
  729|      0|          secattic = NULL;
  730|      0|          log_info (_("skipping block of type %d\n"), keyblock->pkt->pkttype);
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  731|      0|	}
  732|  1.03k|      release_kbnode (keyblock);
  733|       |
  734|       |      /* fixme: we should increment the not imported counter but
  735|       |         this does only make sense if we keep on going despite of
  736|       |         errors.  For now we do this only if the imported key is too
  737|       |         large. */
  738|  1.03k|      if (gpg_err_code (rc) == GPG_ERR_TOO_LARGE
  ------------------
  |  Branch (738:11): [True: 0, False: 1.03k]
  ------------------
  739|  1.03k|            && gpg_err_source (rc) == GPG_ERR_SOURCE_KEYBOX)
  ------------------
  |  Branch (739:16): [True: 0, False: 0]
  ------------------
  740|      0|        {
  741|      0|          stats->not_imported++;
  742|      0|        }
  743|  1.03k|      else if (rc)
  ------------------
  |  Branch (743:16): [True: 0, False: 1.03k]
  ------------------
  744|      0|        break;
  745|       |
  746|  1.03k|      if (!(++stats->count % 100) && !opt.quiet)
  ------------------
  |  Branch (746:11): [True: 4, False: 1.02k]
  |  Branch (746:38): [True: 4, False: 0]
  ------------------
  747|      4|        log_info (_("%lu keys processed so far\n"), stats->count );
  ------------------
  |  |   28|      4|#  define _(a) gettext (a)
  ------------------
  748|       |
  749|  1.03k|      if (origin == KEYORG_WKD && stats->count >= 5)
  ------------------
  |  Branch (749:11): [True: 0, False: 1.03k]
  |  Branch (749:35): [True: 0, False: 0]
  ------------------
  750|      0|        {
  751|       |          /* We limit the number of keys _received_ from the WKD to 5.
  752|       |           * In fact there should be only one key but some sites want
  753|       |           * to store a few expired keys there also.  gpg's key
  754|       |           * selection will later figure out which key to use.  Note
  755|       |           * that for WKD we always return the fingerprint of the
  756|       |           * first imported key.  */
  757|      0|          log_info ("import from WKD stopped after %d keys\n", 5);
  758|      0|          break;
  759|      0|        }
  760|  1.03k|    }
  761|     53|  stats->v3keys += v3keys;
  762|     53|  if (rc == -1)
  ------------------
  |  Branch (762:7): [True: 30, False: 23]
  ------------------
  763|     30|    rc = 0;
  764|     23|  else if (rc && gpg_err_code (rc) != GPG_ERR_INV_KEYRING)
  ------------------
  |  Branch (764:12): [True: 23, False: 0]
  |  Branch (764:18): [True: 2, False: 21]
  ------------------
  765|      2|    log_error (_("error reading '%s': %s\n"), fname, gpg_strerror (rc));
  ------------------
  |  |   28|      2|#  define _(a) gettext (a)
  ------------------
  766|       |
  767|     53|  release_kbnode (secattic);
  768|       |
  769|       |  /* When read_block loop was stopped by error, we have PENDING_PKT left.  */
  770|     53|  if (pending_pkt)
  ------------------
  |  Branch (770:7): [True: 0, False: 53]
  ------------------
  771|      0|    {
  772|      0|      free_packet (pending_pkt, NULL);
  773|      0|      xfree (pending_pkt);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  774|      0|    }
  775|     53|  return rc;
  776|     53|}
import.c:import_matching_seckeys:
 3005|    172|{
 3006|    172|  gpg_error_t err;
 3007|    172|  kbnode_t pub_keyblock = NULL;
 3008|    172|  kbnode_t node;
 3009|    172|  struct { byte fpr[MAX_FINGERPRINT_LEN]; size_t fprlen; } *fprlist = NULL;
 3010|    172|  size_t n, nfprlist;
 3011|    172|  byte fpr[MAX_FINGERPRINT_LEN];
 3012|    172|  size_t fprlen;
 3013|    172|  PKT_public_key *pk;
 3014|       |
 3015|       |  /* Get the entire public key block from our keystore and put all its
 3016|       |   * fingerprints into an array.  */
 3017|    172|  err = get_pubkey_byfprint (ctrl, NULL, &pub_keyblock, mainfpr, mainfprlen);
 3018|    172|  if (err)
  ------------------
  |  Branch (3018:7): [True: 172, False: 0]
  ------------------
 3019|    172|    goto leave;
 3020|      0|  log_assert (pub_keyblock && pub_keyblock->pkt->pkttype == PKT_PUBLIC_KEY);
 3021|      0|  pk = pub_keyblock->pkt->pkt.public_key;
 3022|       |
 3023|      0|  for (nfprlist = 0, node = pub_keyblock; node; node = node->next)
  ------------------
  |  Branch (3023:43): [True: 0, False: 0]
  ------------------
 3024|      0|    if (node->pkt->pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (3024:9): [True: 0, False: 0]
  ------------------
 3025|      0|        || node->pkt->pkttype == PKT_PUBLIC_SUBKEY)
  ------------------
  |  Branch (3025:12): [True: 0, False: 0]
  ------------------
 3026|      0|      nfprlist++;
 3027|      0|  log_assert (nfprlist);
 3028|      0|  fprlist = xtrycalloc (nfprlist, sizeof *fprlist);
  ------------------
  |  |   99|      0|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
 3029|      0|  if (!fprlist)
  ------------------
  |  Branch (3029:7): [True: 0, False: 0]
  ------------------
 3030|      0|    {
 3031|      0|      err = gpg_error_from_syserror ();
 3032|      0|      goto leave;
 3033|      0|    }
 3034|      0|  for (n = 0, node = pub_keyblock; node; node = node->next)
  ------------------
  |  Branch (3034:36): [True: 0, False: 0]
  ------------------
 3035|      0|    if (node->pkt->pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (3035:9): [True: 0, False: 0]
  ------------------
 3036|      0|        || node->pkt->pkttype == PKT_PUBLIC_SUBKEY)
  ------------------
  |  Branch (3036:12): [True: 0, False: 0]
  ------------------
 3037|      0|      {
 3038|      0|        fingerprint_from_pk (node->pkt->pkt.public_key,
 3039|      0|                             fprlist[n].fpr, &fprlist[n].fprlen);
 3040|      0|        n++;
 3041|      0|      }
 3042|      0|  log_assert (n == nfprlist);
 3043|       |
 3044|       |  /* for (n=0; n < nfprlist; n++) */
 3045|       |  /*   log_printhex (fprlist[n].fpr, fprlist[n].fprlen, "pubkey %zu:", n); */
 3046|       |
 3047|       |  /* Mark all secret keys which have a matching public key part in
 3048|       |   * PUB_KEYBLOCK.  */
 3049|      0|  for (node = seckeys; node; node = node->next)
  ------------------
  |  Branch (3049:24): [True: 0, False: 0]
  ------------------
 3050|      0|    {
 3051|      0|      if (node->pkt->pkttype != PKT_SECRET_KEY
  ------------------
  |  Branch (3051:11): [True: 0, False: 0]
  ------------------
 3052|      0|          && node->pkt->pkttype != PKT_SECRET_SUBKEY)
  ------------------
  |  Branch (3052:14): [True: 0, False: 0]
  ------------------
 3053|      0|        continue; /* Should not happen.  */
 3054|      0|      fingerprint_from_pk (node->pkt->pkt.public_key, fpr, &fprlen);
 3055|      0|      node->flag &= ~NODE_TRANSFER_SECKEY;
  ------------------
  |  |   79|      0|#define NODE_TRANSFER_SECKEY 16
  ------------------
 3056|      0|      for (n=0; n < nfprlist; n++)
  ------------------
  |  Branch (3056:17): [True: 0, False: 0]
  ------------------
 3057|      0|        if (fprlist[n].fprlen == fprlen && !memcmp (fprlist[n].fpr,fpr,fprlen))
  ------------------
  |  Branch (3057:13): [True: 0, False: 0]
  |  Branch (3057:44): [True: 0, False: 0]
  ------------------
 3058|      0|          {
 3059|      0|            node->flag |= NODE_TRANSFER_SECKEY;
  ------------------
  |  |   79|      0|#define NODE_TRANSFER_SECKEY 16
  ------------------
 3060|       |            /* log_debug ("found matching seckey\n"); */
 3061|      0|            break;
 3062|      0|          }
 3063|      0|    }
 3064|       |
 3065|       |  /* Transfer all marked keys.  */
 3066|      0|  err = do_transfer (ctrl, seckeys, pk, stats, batch, 1);
 3067|       |
 3068|    172| leave:
 3069|    172|  xfree (fprlist);
  ------------------
  |  |  104|    172|#define xfree(a)         gcry_free ((a))
  ------------------
 3070|    172|  release_kbnode (pub_keyblock);
 3071|    172|  return err;
 3072|      0|}
import.c:import_revoke_cert:
 3499|    385|{
 3500|    385|  PKT_public_key *pk = NULL;
 3501|    385|  kbnode_t onode;
 3502|    385|  kbnode_t keyblock = NULL;
 3503|    385|  KEYDB_HANDLE hd = NULL;
 3504|    385|  u32 keyid[2];
 3505|    385|  int rc = 0;
 3506|    385|  int sigrc = 0;
 3507|    385|  int silent;
 3508|       |
 3509|       |  /* No error output for --show-keys.  */
 3510|    385|  silent = (options & (IMPORT_SHOW | IMPORT_DRY_RUN));
  ------------------
  |  |  386|    385|#define IMPORT_SHOW                      (1<<3)
  ------------------
                silent = (options & (IMPORT_SHOW | IMPORT_DRY_RUN));
  ------------------
  |  |  395|    385|#define IMPORT_DRY_RUN                   (1<<12)
  ------------------
 3511|       |
 3512|    385|  log_assert (node->pkt->pkttype == PKT_SIGNATURE );
 3513|      0|  log_assert (IS_KEY_REV (node->pkt->pkt.signature));
 3514|       |
 3515|       |  /* FIXME: We can do better here by using the issuer fingerprint if
 3516|       |   * available.  We should also make use of get_keyblock_byfprint_fast.  */
 3517|       |
 3518|      0|  keyid[0] = node->pkt->pkt.signature->keyid[0];
 3519|    385|  keyid[1] = node->pkt->pkt.signature->keyid[1];
 3520|       |
 3521|    385|  pk = xmalloc_clear( sizeof *pk );
  ------------------
  |  |  116|    385|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
 3522|    385|  rc = get_pubkey (ctrl, pk, keyid );
 3523|    385|  if (gpg_err_code (rc) == GPG_ERR_NO_PUBKEY )
  ------------------
  |  Branch (3523:7): [True: 385, False: 0]
  ------------------
 3524|    385|    {
 3525|    385|      if (!silent)
  ------------------
  |  Branch (3525:11): [True: 385, False: 0]
  ------------------
 3526|    385|        log_error (_("key %s: no public key -"
  ------------------
  |  |   28|    385|#  define _(a) gettext (a)
  ------------------
 3527|    385|                     " can't apply revocation certificate\n"), keystr(keyid));
 3528|    385|      rc = 0;
 3529|    385|      goto leave;
 3530|    385|    }
 3531|      0|  else if (rc )
  ------------------
  |  Branch (3531:12): [True: 0, False: 0]
  ------------------
 3532|      0|    {
 3533|      0|      log_error (_("key %s: public key not found: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3534|      0|                 keystr(keyid), gpg_strerror (rc));
 3535|      0|      goto leave;
 3536|      0|    }
 3537|       |
 3538|       |  /* Read the original keyblock. */
 3539|      0|  hd = keydb_new (ctrl);
 3540|      0|  if (!hd)
  ------------------
  |  Branch (3540:7): [True: 0, False: 0]
  ------------------
 3541|      0|    {
 3542|      0|      rc = gpg_error_from_syserror ();
 3543|      0|      goto leave;
 3544|      0|    }
 3545|       |
 3546|      0|  {
 3547|      0|    byte afp[MAX_FINGERPRINT_LEN];
 3548|      0|    size_t an;
 3549|       |
 3550|      0|    fingerprint_from_pk (pk, afp, &an);
 3551|      0|    rc = keydb_search_fpr (hd, afp, an);
 3552|      0|  }
 3553|      0|  if (rc)
  ------------------
  |  Branch (3553:7): [True: 0, False: 0]
  ------------------
 3554|      0|    {
 3555|      0|      log_error (_("key %s: can't locate original keyblock: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3556|      0|                 keystr(keyid), gpg_strerror (rc));
 3557|      0|      goto leave;
 3558|      0|    }
 3559|      0|  rc = keydb_get_keyblock (hd, &keyblock );
 3560|      0|  if (rc)
  ------------------
  |  Branch (3560:7): [True: 0, False: 0]
  ------------------
 3561|      0|    {
 3562|      0|      log_error (_("key %s: can't read original keyblock: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3563|      0|                 keystr(keyid), gpg_strerror (rc));
 3564|      0|      goto leave;
 3565|      0|    }
 3566|       |
 3567|       |  /* it is okay, that node is not in keyblock because
 3568|       |   * check_key_signature works fine for sig_class 0x20 (KEY_REV) in
 3569|       |   * this special case.  SIGRC is only used for IMPORT_SHOW.  */
 3570|      0|  rc = check_key_signature (ctrl, keyblock, node, NULL);
 3571|      0|  switch (gpg_err_code (rc))
 3572|      0|    {
 3573|      0|    case 0:                       sigrc = '!'; break;
  ------------------
  |  Branch (3573:5): [True: 0, False: 0]
  ------------------
 3574|      0|    case GPG_ERR_BAD_SIGNATURE:   sigrc = '-'; break;
  ------------------
  |  Branch (3574:5): [True: 0, False: 0]
  ------------------
 3575|      0|    case GPG_ERR_NO_PUBKEY:       sigrc = '?'; break;
  ------------------
  |  Branch (3575:5): [True: 0, False: 0]
  ------------------
 3576|      0|    case GPG_ERR_UNUSABLE_PUBKEY: sigrc = '?'; break;
  ------------------
  |  Branch (3576:5): [True: 0, False: 0]
  ------------------
 3577|      0|    default:                      sigrc = '%'; break;
  ------------------
  |  Branch (3577:5): [True: 0, False: 0]
  ------------------
 3578|      0|    }
 3579|      0|  if (rc )
  ------------------
  |  Branch (3579:7): [True: 0, False: 0]
  ------------------
 3580|      0|    {
 3581|      0|      if (!silent)
  ------------------
  |  Branch (3581:11): [True: 0, False: 0]
  ------------------
 3582|      0|        log_error (_("key %s: invalid revocation certificate"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3583|      0|                     ": %s - rejected\n"), keystr(keyid), gpg_strerror (rc));
 3584|      0|      goto leave;
 3585|      0|    }
 3586|       |
 3587|       |  /* check whether we already have this */
 3588|      0|  for(onode=keyblock->next; onode; onode=onode->next ) {
  ------------------
  |  Branch (3588:29): [True: 0, False: 0]
  ------------------
 3589|      0|    if (onode->pkt->pkttype == PKT_USER_ID )
  ------------------
  |  Branch (3589:9): [True: 0, False: 0]
  ------------------
 3590|      0|      break;
 3591|      0|    else if (onode->pkt->pkttype == PKT_SIGNATURE
  ------------------
  |  Branch (3591:14): [True: 0, False: 0]
  ------------------
 3592|      0|             && !cmp_signatures(node->pkt->pkt.signature,
  ------------------
  |  Branch (3592:17): [True: 0, False: 0]
  ------------------
 3593|      0|                                onode->pkt->pkt.signature))
 3594|      0|      {
 3595|      0|        rc = 0;
 3596|      0|        goto leave; /* yes, we already know about it */
 3597|      0|      }
 3598|      0|  }
 3599|       |
 3600|       |  /* insert it */
 3601|      0|  insert_kbnode( keyblock, clone_kbnode(node), 0 );
 3602|       |
 3603|       |  /* and write the keyblock back unless in dry run mode.  */
 3604|      0|  if (!(opt.dry_run || (options & IMPORT_DRY_RUN)))
  ------------------
  |  |  395|      0|#define IMPORT_DRY_RUN                   (1<<12)
  ------------------
  |  Branch (3604:9): [True: 0, False: 0]
  |  Branch (3604:24): [True: 0, False: 0]
  ------------------
 3605|      0|    {
 3606|      0|      rc = keydb_update_keyblock (ctrl, hd, keyblock );
 3607|      0|      if (rc)
  ------------------
  |  Branch (3607:11): [True: 0, False: 0]
  ------------------
 3608|      0|        log_error (_("error writing keyring '%s': %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3609|      0|                   keydb_get_resource_name (hd), gpg_strerror (rc) );
 3610|      0|      keydb_release (hd);
 3611|      0|      hd = NULL;
 3612|       |
 3613|       |      /* we are ready */
 3614|      0|      if (!opt.quiet )
  ------------------
  |  Branch (3614:11): [True: 0, False: 0]
  ------------------
 3615|      0|        {
 3616|      0|          char *p=get_user_id_native (ctrl, keyid);
 3617|      0|          log_info( _("key %s: \"%s\" revocation certificate imported\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3618|      0|                    keystr(keyid),p);
 3619|      0|          xfree(p);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 3620|      0|        }
 3621|       |
 3622|       |      /* If the key we just revoked was ultimately trusted, remove its
 3623|       |       * ultimate trust.  This doesn't stop the user from putting the
 3624|       |       * ultimate trust back, but is a reasonable solution for now. */
 3625|      0|      if (get_ownertrust (ctrl, pk) == TRUST_ULTIMATE)
  ------------------
  |  |   32|      0|#define TRUST_ULTIMATE	  6  /* u: ultimately trusted */
  ------------------
  |  Branch (3625:11): [True: 0, False: 0]
  ------------------
 3626|      0|        clear_ownertrusts (ctrl, pk);
 3627|       |
 3628|      0|      revalidation_mark (ctrl);
 3629|      0|    }
 3630|      0|  stats->n_revoc++;
 3631|       |
 3632|    385| leave:
 3633|    385|  if ((options & IMPORT_SHOW))
  ------------------
  |  |  386|    385|#define IMPORT_SHOW                      (1<<3)
  ------------------
  |  Branch (3633:7): [True: 0, False: 385]
  ------------------
 3634|      0|    list_standalone_revocation (ctrl, node->pkt->pkt.signature, sigrc);
 3635|       |
 3636|    385|  keydb_release (hd);
 3637|    385|  release_kbnode( keyblock );
 3638|    385|  free_public_key( pk );
 3639|    385|  return rc;
 3640|      0|}
import.c:read_block:
  935|  1.08k|{
  936|  1.08k|  int rc;
  937|  1.08k|  struct parse_packet_ctx_s parsectx;
  938|  1.08k|  PACKET *pkt;
  939|  1.08k|  kbnode_t root = NULL;
  940|  1.08k|  kbnode_t lastnode = NULL;
  941|  1.08k|  int in_cert, in_v3key, skip_sigs;
  942|  1.08k|  u32 keyid[2];
  943|  1.08k|  int got_keyid = 0;
  944|  1.08k|  unsigned int dropped_nonselfsigs = 0;
  945|       |
  946|  1.08k|  *r_v3keys = 0;
  947|       |
  948|  1.08k|  if (*pending_pkt)
  ------------------
  |  Branch (948:7): [True: 887, False: 196]
  ------------------
  949|    887|    {
  950|    887|      root = lastnode = new_kbnode( *pending_pkt );
  951|    887|      *pending_pkt = NULL;
  952|    887|      log_assert (root->pkt->pkttype == PKT_PUBLIC_KEY
  953|    887|                  || root->pkt->pkttype == PKT_SECRET_KEY);
  954|      0|      in_cert = 1;
  955|    887|      keyid_from_pk (root->pkt->pkt.public_key, keyid);
  956|    887|      got_keyid = 1;
  957|    887|    }
  958|    196|  else
  959|    196|    in_cert = 0;
  960|       |
  961|  1.08k|  pkt = xmalloc (sizeof *pkt);
  ------------------
  |  |  107|  1.08k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  962|  1.08k|  init_packet (pkt);
  ------------------
  |  |  581|  1.08k|#define init_packet(a) do { (a)->pkttype = 0;		\
  |  |  582|  1.08k|			    (a)->pkt.generic = NULL;	\
  |  |  583|  1.08k|		       } while(0)
  |  |  ------------------
  |  |  |  Branch (583:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
  963|  1.08k|  init_parse_packet (&parsectx, a);
  ------------------
  |  |  666|  1.08k|#define init_parse_packet(a,i) do { \
  |  |  667|  1.08k|    (a)->inp = (i);                 \
  |  |  668|  1.08k|    (a)->last_pkt.pkttype = 0;      \
  |  |  669|  1.08k|    (a)->last_pkt.pkt.generic= NULL;\
  |  |  670|  1.08k|    (a)->free_last_pkt = 0;         \
  |  |  671|  1.08k|    (a)->skip_meta = 0;             \
  |  |  672|  1.08k|    (a)->n_parsed_packets = 0;      \
  |  |  673|  1.08k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (673:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
  964|  1.08k|  if (!(options & IMPORT_RESTORE))
  ------------------
  |  |  393|  1.08k|#define IMPORT_RESTORE                   (1<<10)
  ------------------
  |  Branch (964:7): [True: 1.08k, False: 0]
  ------------------
  965|  1.08k|    parsectx.skip_meta = 1;
  966|  1.08k|  in_v3key = 0;
  967|  1.08k|  skip_sigs = 0;
  968|  6.98k|  while ((rc=parse_packet (&parsectx, pkt)) != -1)
  ------------------
  |  |  697|  6.98k|	     dbg_parse_packet( (a), (b), __FILE__, __LINE__ )
  ------------------
  |  Branch (968:10): [True: 6.85k, False: 128]
  ------------------
  969|  6.85k|    {
  970|  6.85k|      if (rc && (gpg_err_code (rc) == GPG_ERR_LEGACY_KEY
  ------------------
  |  Branch (970:11): [True: 52, False: 6.80k]
  |  Branch (970:18): [True: 0, False: 52]
  ------------------
  971|     52|                 && (pkt->pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (971:22): [True: 0, False: 0]
  ------------------
  972|      0|                     || pkt->pkttype == PKT_SECRET_KEY)))
  ------------------
  |  Branch (972:25): [True: 0, False: 0]
  ------------------
  973|      0|        {
  974|      0|          in_v3key = 1;
  975|      0|          ++*r_v3keys;
  976|      0|          free_packet (pkt, &parsectx);
  977|      0|          init_packet (pkt);
  ------------------
  |  |  581|      0|#define init_packet(a) do { (a)->pkttype = 0;		\
  |  |  582|      0|			    (a)->pkt.generic = NULL;	\
  |  |  583|      0|		       } while(0)
  |  |  ------------------
  |  |  |  Branch (583:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
  978|      0|          continue;
  979|      0|        }
  980|  6.85k|      else if (rc ) /* (ignore errors) */
  ------------------
  |  Branch (980:16): [True: 52, False: 6.80k]
  ------------------
  981|     52|        {
  982|     52|          skip_sigs = 0;
  983|     52|          if (gpg_err_code (rc) == GPG_ERR_UNKNOWN_PACKET)
  ------------------
  |  Branch (983:15): [True: 31, False: 21]
  ------------------
  984|     31|            ; /* Do not show a diagnostic.  */
  985|     21|          else if (gpg_err_code (rc) == GPG_ERR_INV_PACKET
  ------------------
  |  Branch (985:20): [True: 20, False: 1]
  ------------------
  986|     21|                   && (pkt->pkttype == PKT_USER_ID
  ------------------
  |  Branch (986:24): [True: 0, False: 20]
  ------------------
  987|     20|                       || pkt->pkttype == PKT_ATTRIBUTE))
  ------------------
  |  Branch (987:27): [True: 0, False: 20]
  ------------------
  988|      0|            {
  989|       |              /* This indicates a too large user id or attribute
  990|       |               * packet.  We skip this packet and all following
  991|       |               * signatures.  Sure, this won't allow to repair a
  992|       |               * garbled keyring in case one of the signatures belong
  993|       |               * to another user id.  However, this better mitigates
  994|       |               * DoS using inserted user ids.  */
  995|      0|              skip_sigs = 1;
  996|      0|            }
  997|     21|          else if (gpg_err_code (rc) == GPG_ERR_INV_PACKET
  ------------------
  |  Branch (997:20): [True: 20, False: 1]
  ------------------
  998|     21|                   && (pkt->pkttype == PKT_OLD_COMMENT
  ------------------
  |  Branch (998:24): [True: 0, False: 20]
  ------------------
  999|     20|                       || pkt->pkttype == PKT_COMMENT))
  ------------------
  |  Branch (999:27): [True: 0, False: 20]
  ------------------
 1000|      0|            ; /* Ignore too large comment packets.  */
 1001|     21|          else
 1002|     21|            {
 1003|     21|              log_error("read_block: read error: %s\n", gpg_strerror (rc) );
 1004|     21|              rc = GPG_ERR_INV_KEYRING;
 1005|     21|              goto ready;
 1006|     21|            }
 1007|     31|          free_packet (pkt, &parsectx);
 1008|     31|          init_packet(pkt);
  ------------------
  |  |  581|     31|#define init_packet(a) do { (a)->pkttype = 0;		\
  |  |  582|     31|			    (a)->pkt.generic = NULL;	\
  |  |  583|     31|		       } while(0)
  |  |  ------------------
  |  |  |  Branch (583:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1009|     31|          continue;
 1010|     52|	}
 1011|       |
 1012|  6.80k|      if (skip_sigs)
  ------------------
  |  Branch (1012:11): [True: 0, False: 6.80k]
  ------------------
 1013|      0|        {
 1014|      0|          if (pkt->pkttype == PKT_SIGNATURE)
  ------------------
  |  Branch (1014:15): [True: 0, False: 0]
  ------------------
 1015|      0|            {
 1016|      0|              free_packet (pkt, &parsectx);
 1017|      0|              init_packet (pkt);
  ------------------
  |  |  581|      0|#define init_packet(a) do { (a)->pkttype = 0;		\
  |  |  582|      0|			    (a)->pkt.generic = NULL;	\
  |  |  583|      0|		       } while(0)
  |  |  ------------------
  |  |  |  Branch (583:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1018|      0|              continue;
 1019|      0|            }
 1020|      0|          skip_sigs = 0;
 1021|      0|        }
 1022|       |
 1023|  6.80k|      if (in_v3key && !(pkt->pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (1023:11): [True: 0, False: 6.80k]
  |  Branch (1023:25): [True: 0, False: 0]
  ------------------
 1024|      0|                        || pkt->pkttype == PKT_SECRET_KEY))
  ------------------
  |  Branch (1024:28): [True: 0, False: 0]
  ------------------
 1025|      0|        {
 1026|      0|          free_packet (pkt, &parsectx);
 1027|      0|          init_packet(pkt);
  ------------------
  |  |  581|      0|#define init_packet(a) do { (a)->pkttype = 0;		\
  |  |  582|      0|			    (a)->pkt.generic = NULL;	\
  |  |  583|      0|		       } while(0)
  |  |  ------------------
  |  |  |  Branch (583:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1028|      0|          continue;
 1029|      0|        }
 1030|  6.80k|      in_v3key = 0;
 1031|       |
 1032|  6.80k|      if (!root && pkt->pkttype == PKT_SIGNATURE
  ------------------
  |  Branch (1032:11): [True: 2.33k, False: 4.47k]
  |  Branch (1032:20): [True: 262, False: 2.07k]
  ------------------
 1033|  6.80k|          && IS_KEY_REV (pkt->pkt.signature) )
  ------------------
  |  |   45|    262|#define IS_KEY_REV(s)    ((s)->sig_class == 0x20)
  |  |  ------------------
  |  |  |  Branch (45:26): [True: 45, False: 217]
  |  |  ------------------
  ------------------
 1034|     45|        {
 1035|       |          /* This is a revocation certificate which is handled in a
 1036|       |           * special way.  */
 1037|     45|          root = new_kbnode( pkt );
 1038|     45|          pkt = NULL;
 1039|     45|          goto ready;
 1040|     45|        }
 1041|       |
 1042|       |      /* Make a linked list of all packets.  */
 1043|  6.76k|      switch (pkt->pkttype)
 1044|  6.76k|        {
 1045|      2|        case PKT_COMPRESSED:
  ------------------
  |  Branch (1045:9): [True: 2, False: 6.76k]
  ------------------
 1046|      2|          if (check_compress_algo (pkt->pkt.compressed->algorithm))
  ------------------
  |  Branch (1046:15): [True: 2, False: 0]
  ------------------
 1047|      2|            {
 1048|      2|              rc = GPG_ERR_COMPR_ALGO;
 1049|      2|              goto ready;
 1050|      2|            }
 1051|      0|          else
 1052|      0|            {
 1053|      0|              compress_filter_context_t *cfx = xmalloc_clear( sizeof *cfx );
  ------------------
  |  |  116|      0|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
 1054|      0|              pkt->pkt.compressed->buf = NULL;
 1055|      0|              if (push_compress_filter2 (a, cfx,
  ------------------
  |  Branch (1055:19): [True: 0, False: 0]
  ------------------
 1056|      0|                                         pkt->pkt.compressed->algorithm, 1))
 1057|      0|                xfree (cfx); /* e.g. in case of compression_algo NONE.  */
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1058|      0|            }
 1059|      0|          free_packet (pkt, &parsectx);
 1060|      0|          init_packet(pkt);
  ------------------
  |  |  581|      0|#define init_packet(a) do { (a)->pkttype = 0;		\
  |  |  582|      0|			    (a)->pkt.generic = NULL;	\
  |  |  583|      0|		       } while(0)
  |  |  ------------------
  |  |  |  Branch (583:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1061|      0|          break;
 1062|       |
 1063|      0|        case PKT_RING_TRUST:
  ------------------
  |  Branch (1063:9): [True: 0, False: 6.76k]
  ------------------
 1064|       |          /* Skip those packets unless we are in restore mode.  */
 1065|      0|          if ((opt.import_options & IMPORT_RESTORE))
  ------------------
  |  |  393|      0|#define IMPORT_RESTORE                   (1<<10)
  ------------------
  |  Branch (1065:15): [True: 0, False: 0]
  ------------------
 1066|      0|            goto x_default;
 1067|      0|          free_packet (pkt, &parsectx);
 1068|      0|          init_packet(pkt);
  ------------------
  |  |  581|      0|#define init_packet(a) do { (a)->pkttype = 0;		\
  |  |  582|      0|			    (a)->pkt.generic = NULL;	\
  |  |  583|      0|		       } while(0)
  |  |  ------------------
  |  |  |  Branch (583:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1069|      0|          break;
 1070|       |
 1071|  1.72k|        case PKT_SIGNATURE:
  ------------------
  |  Branch (1071:9): [True: 1.72k, False: 5.03k]
  ------------------
 1072|  1.72k|          if (!in_cert)
  ------------------
  |  Branch (1072:15): [True: 217, False: 1.50k]
  ------------------
 1073|    217|            goto x_default;
 1074|  1.50k|          if (!(options & IMPORT_SELF_SIGS_ONLY))
  ------------------
  |  |  396|  1.50k|#define IMPORT_SELF_SIGS_ONLY            (1<<14)
  ------------------
  |  Branch (1074:15): [True: 1.50k, False: 0]
  ------------------
 1075|  1.50k|            goto x_default;
 1076|      0|          log_assert (got_keyid);
 1077|      0|	  if (pkt->pkt.signature->keyid[0] == keyid[0]
  ------------------
  |  Branch (1077:8): [True: 0, False: 0]
  ------------------
 1078|      0|              && pkt->pkt.signature->keyid[1] == keyid[1])
  ------------------
  |  Branch (1078:18): [True: 0, False: 0]
  ------------------
 1079|      0|	    { /* This is likely a self-signature.  We import this one.
 1080|       |               * Eventually we should use the ISSUER_FPR to compare
 1081|       |               * self-signatures, but that will work only for v5 keys
 1082|       |               * which are currently not even deployed.
 1083|       |               * Note that we do not do any crypto verify here because
 1084|       |               * that would defeat this very mitigation of DoS by
 1085|       |               * importing a key with a huge amount of faked
 1086|       |               * key-signatures.  A verification will be done later in
 1087|       |               * the processing anyway.  Here we want a cheap an early
 1088|       |               * way to drop non-self-signatures.  */
 1089|      0|              goto x_default;
 1090|      0|            }
 1091|       |          /* Skip this signature.  */
 1092|      0|          dropped_nonselfsigs++;
 1093|      0|          free_packet (pkt, &parsectx);
 1094|      0|          init_packet(pkt);
  ------------------
  |  |  581|      0|#define init_packet(a) do { (a)->pkttype = 0;		\
  |  |  582|      0|			    (a)->pkt.generic = NULL;	\
  |  |  583|      0|		       } while(0)
  |  |  ------------------
  |  |  |  Branch (583:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1095|      0|          break;
 1096|       |
 1097|    726|        case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (1097:9): [True: 726, False: 6.03k]
  ------------------
 1098|    997|        case PKT_SECRET_KEY:
  ------------------
  |  Branch (1098:9): [True: 271, False: 6.49k]
  ------------------
 1099|    997|          if (!got_keyid)
  ------------------
  |  Branch (1099:15): [True: 110, False: 887]
  ------------------
 1100|    110|            {
 1101|    110|              keyid_from_pk (pkt->pkt.public_key, keyid);
 1102|    110|              got_keyid = 1;
 1103|    110|            }
 1104|    997|          if (in_cert) /* Store this packet.  */
  ------------------
  |  Branch (1104:15): [True: 887, False: 110]
  ------------------
 1105|    887|            {
 1106|    887|              *pending_pkt = pkt;
 1107|    887|              pkt = NULL;
 1108|    887|              goto ready;
 1109|    887|            }
 1110|    110|          in_cert = 1;
 1111|    110|          goto x_default;
 1112|       |
 1113|  4.03k|        default:
  ------------------
  |  Branch (1113:9): [True: 4.03k, False: 2.72k]
  ------------------
 1114|  5.87k|        x_default:
 1115|  5.87k|          if (in_cert && valid_keyblock_packet (pkt->pkttype))
  ------------------
  |  Branch (1115:15): [True: 3.69k, False: 2.18k]
  |  Branch (1115:26): [True: 3.32k, False: 370]
  ------------------
 1116|  3.32k|            {
 1117|  3.32k|              if (!root )
  ------------------
  |  Branch (1117:19): [True: 110, False: 3.21k]
  ------------------
 1118|    110|                root = lastnode = new_kbnode (pkt);
 1119|  3.21k|              else
 1120|  3.21k|                {
 1121|  3.21k|                  lastnode->next = new_kbnode (pkt);
 1122|  3.21k|                  lastnode = lastnode->next;
 1123|  3.21k|                }
 1124|  3.32k|              pkt = xmalloc (sizeof *pkt);
  ------------------
  |  |  107|  3.32k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 1125|  3.32k|            }
 1126|  2.55k|          else
 1127|  2.55k|            free_packet (pkt, &parsectx);
 1128|  5.87k|          init_packet(pkt);
  ------------------
  |  |  581|  5.87k|#define init_packet(a) do { (a)->pkttype = 0;		\
  |  |  582|  5.87k|			    (a)->pkt.generic = NULL;	\
  |  |  583|  5.87k|		       } while(0)
  |  |  ------------------
  |  |  |  Branch (583:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1129|  5.87k|          break;
 1130|  6.76k|        }
 1131|  6.76k|    }
 1132|       |
 1133|  1.08k| ready:
 1134|  1.08k|  if (rc == -1 && root )
  ------------------
  |  Branch (1134:7): [True: 128, False: 955]
  |  Branch (1134:19): [True: 98, False: 30]
  ------------------
 1135|     98|    rc = 0;
 1136|       |
 1137|  1.08k|  if (rc )
  ------------------
  |  Branch (1137:7): [True: 53, False: 1.03k]
  ------------------
 1138|     53|    release_kbnode( root );
 1139|  1.03k|  else
 1140|  1.03k|    *ret_root = root;
 1141|  1.08k|  free_packet (pkt, &parsectx);
 1142|  1.08k|  deinit_parse_packet (&parsectx);
  ------------------
  |  |  675|  1.08k|#define deinit_parse_packet(a) do { \
  |  |  676|  1.08k|    if ((a)->free_last_pkt)         \
  |  |  ------------------
  |  |  |  Branch (676:9): [True: 0, False: 1.08k]
  |  |  ------------------
  |  |  677|  1.08k|      free_packet (NULL, (a));      \
  |  |  678|  1.08k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (678:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1143|  1.08k|  xfree( pkt );
  ------------------
  |  |  104|  1.08k|#define xfree(a)         gcry_free ((a))
  ------------------
 1144|  1.08k|  if (!rc && dropped_nonselfsigs && opt.verbose)
  ------------------
  |  Branch (1144:7): [True: 1.03k, False: 53]
  |  Branch (1144:14): [True: 0, False: 1.03k]
  |  Branch (1144:37): [True: 0, False: 0]
  ------------------
 1145|      0|    log_info ("key %s: number of dropped non-self-signatures: %u\n",
 1146|      0|              keystr (keyid), dropped_nonselfsigs);
 1147|       |
 1148|  1.08k|  return rc;
 1149|  1.08k|}
import.c:valid_keyblock_packet:
  906|  3.69k|{
  907|  3.69k|  switch (pkttype)
  908|  3.69k|    {
  909|     73|    case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (909:5): [True: 73, False: 3.62k]
  ------------------
  910|     77|    case PKT_PUBLIC_SUBKEY:
  ------------------
  |  Branch (910:5): [True: 4, False: 3.68k]
  ------------------
  911|    114|    case PKT_SECRET_KEY:
  ------------------
  |  Branch (911:5): [True: 37, False: 3.65k]
  ------------------
  912|    536|    case PKT_SECRET_SUBKEY:
  ------------------
  |  Branch (912:5): [True: 422, False: 3.27k]
  ------------------
  913|  2.04k|    case PKT_SIGNATURE:
  ------------------
  |  Branch (913:5): [True: 1.50k, False: 2.18k]
  ------------------
  914|  3.32k|    case PKT_USER_ID:
  ------------------
  |  Branch (914:5): [True: 1.27k, False: 2.41k]
  ------------------
  915|  3.32k|    case PKT_ATTRIBUTE:
  ------------------
  |  Branch (915:5): [True: 0, False: 3.69k]
  ------------------
  916|  3.32k|    case PKT_RING_TRUST:
  ------------------
  |  Branch (916:5): [True: 0, False: 3.69k]
  ------------------
  917|  3.32k|      return 1;
  918|    370|    default:
  ------------------
  |  Branch (918:5): [True: 370, False: 3.32k]
  ------------------
  919|    370|      return 0;
  920|  3.69k|    }
  921|  3.69k|}
import.c:import_one:
 2472|    889|{
 2473|    889|  gpg_error_t err;
 2474|    889|  kbnode_t otherrevsigs = NULL;
 2475|    889|  kbnode_t node;
 2476|       |
 2477|    889|  err = import_one_real (ctrl, keyblock, stats, fpr, fpr_len, options,
 2478|    889|                         from_sk, silent, screener, screener_arg,
 2479|    889|                         origin, url, r_valid, &otherrevsigs);
 2480|    889|  if (gpg_err_code (err) == GPG_ERR_TOO_LARGE
  ------------------
  |  Branch (2480:7): [True: 0, False: 889]
  ------------------
 2481|    889|      && gpg_err_source (err) == GPG_ERR_SOURCE_KEYBOX
  ------------------
  |  Branch (2481:10): [True: 0, False: 0]
  ------------------
 2482|    889|      && ((options & (IMPORT_SELF_SIGS_ONLY | IMPORT_CLEAN))
  ------------------
  |  |  396|      0|#define IMPORT_SELF_SIGS_ONLY            (1<<14)
  ------------------
                    && ((options & (IMPORT_SELF_SIGS_ONLY | IMPORT_CLEAN))
  ------------------
  |  |  389|      0|#define IMPORT_CLEAN                     (1<<6)
  ------------------
  |  Branch (2482:10): [True: 0, False: 0]
  ------------------
 2483|      0|          != (IMPORT_SELF_SIGS_ONLY | IMPORT_CLEAN)))
  ------------------
  |  |  396|      0|#define IMPORT_SELF_SIGS_ONLY            (1<<14)
  ------------------
                        != (IMPORT_SELF_SIGS_ONLY | IMPORT_CLEAN)))
  ------------------
  |  |  389|      0|#define IMPORT_CLEAN                     (1<<6)
  ------------------
 2484|      0|    {
 2485|       |      /* We hit the maximum image length.  Ask the wrapper to do
 2486|       |       * everything again but this time with some extra options.  */
 2487|      0|      u32 keyid[2];
 2488|       |
 2489|      0|      keyid_from_pk (keyblock->pkt->pkt.public_key, keyid);
 2490|      0|      log_info ("key %s: keyblock too large, retrying with self-sigs-only\n",
 2491|      0|                keystr (keyid));
 2492|      0|      options |= IMPORT_SELF_SIGS_ONLY | IMPORT_CLEAN;
  ------------------
  |  |  396|      0|#define IMPORT_SELF_SIGS_ONLY            (1<<14)
  ------------------
                    options |= IMPORT_SELF_SIGS_ONLY | IMPORT_CLEAN;
  ------------------
  |  |  389|      0|#define IMPORT_CLEAN                     (1<<6)
  ------------------
 2493|      0|      err = import_one_real (ctrl, keyblock, stats, fpr, fpr_len, options,
 2494|      0|                             from_sk, silent, screener, screener_arg,
 2495|      0|                             origin, url, r_valid, &otherrevsigs);
 2496|      0|    }
 2497|       |
 2498|       |  /* Finally try to import other revocation certificates.  For example
 2499|       |   * those of a former key appended to the current key.  */
 2500|    889|  if (!err)
  ------------------
  |  Branch (2500:7): [True: 889, False: 0]
  ------------------
 2501|    889|    {
 2502|  1.22k|      for (node = otherrevsigs; node; node = node->next)
  ------------------
  |  Branch (2502:33): [True: 340, False: 889]
  ------------------
 2503|    340|        import_revoke_cert (ctrl, node, options, stats);
 2504|    889|    }
 2505|    889|  release_kbnode (otherrevsigs);
 2506|    889|  return err;
 2507|    889|}
import.c:import_one_real:
 1942|    889|{
 1943|    889|  gpg_error_t err = 0;
 1944|    889|  PKT_public_key *pk;
 1945|    889|  kbnode_t node, uidnode;
 1946|    889|  kbnode_t keyblock_orig = NULL;
 1947|    889|  byte fpr2[MAX_FINGERPRINT_LEN];
 1948|    889|  size_t fpr2len;
 1949|    889|  u32 keyid[2];
 1950|    889|  int new_key = 0;
 1951|    889|  int mod_key = 0;
 1952|    889|  int same_key = 0;
 1953|    889|  int non_self = 0;
 1954|    889|  size_t an;
 1955|    889|  char pkstrbuf[PUBKEY_STRING_SIZE];
 1956|    889|  int merge_keys_done = 0;
 1957|    889|  int any_filter = 0;
 1958|    889|  KEYDB_HANDLE hd = NULL;
 1959|       |
 1960|    889|  if (r_valid)
  ------------------
  |  Branch (1960:7): [True: 172, False: 717]
  ------------------
 1961|    172|    *r_valid = 0;
 1962|       |
 1963|       |  /* If show-only is active we don't won't any extra output.  */
 1964|    889|  if ((options & (IMPORT_SHOW | IMPORT_DRY_RUN)))
  ------------------
  |  |  386|    889|#define IMPORT_SHOW                      (1<<3)
  ------------------
                if ((options & (IMPORT_SHOW | IMPORT_DRY_RUN)))
  ------------------
  |  |  395|    889|#define IMPORT_DRY_RUN                   (1<<12)
  ------------------
  |  Branch (1964:7): [True: 0, False: 889]
  ------------------
 1965|      0|    silent = 1;
 1966|       |
 1967|       |  /* Get the key and print some info about it. */
 1968|    889|  node = find_kbnode( keyblock, PKT_PUBLIC_KEY );
 1969|    889|  if (!node )
  ------------------
  |  Branch (1969:7): [True: 0, False: 889]
  ------------------
 1970|      0|    BUG();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1971|       |
 1972|    889|  pk = node->pkt->pkt.public_key;
 1973|       |
 1974|    889|  fingerprint_from_pk (pk, fpr2, &fpr2len);
 1975|  11.5k|  for (an = fpr2len; an < MAX_FINGERPRINT_LEN; an++)
  ------------------
  |  |   49|  11.5k|#define MAX_FINGERPRINT_LEN 32
  ------------------
  |  Branch (1975:22): [True: 10.6k, False: 889]
  ------------------
 1976|  10.6k|    fpr2[an] = 0;
 1977|    889|  keyid_from_pk( pk, keyid );
 1978|    889|  uidnode = find_next_kbnode( keyblock, PKT_USER_ID );
 1979|       |
 1980|    889|  if (opt.verbose && !opt.interactive && !silent && !from_sk)
  ------------------
  |  Branch (1980:7): [True: 0, False: 889]
  |  Branch (1980:22): [True: 0, False: 0]
  |  Branch (1980:42): [True: 0, False: 0]
  |  Branch (1980:53): [True: 0, False: 0]
  ------------------
 1981|      0|    {
 1982|       |      /* Note that we do not print this info in FROM_SK mode
 1983|       |       * because import_secret_one already printed that.  */
 1984|      0|      log_info ("pub  %s/%s %s  ",
 1985|      0|                pubkey_string (pk, pkstrbuf, sizeof pkstrbuf),
 1986|      0|                keystr_from_pk(pk), datestr_from_pk(pk) );
 1987|      0|      if (uidnode)
  ------------------
  |  Branch (1987:11): [True: 0, False: 0]
  ------------------
 1988|      0|        print_utf8_buffer (log_get_stream (),
 1989|      0|                           uidnode->pkt->pkt.user_id->name,
 1990|      0|                           uidnode->pkt->pkt.user_id->len );
 1991|      0|      log_printf ("\n");
 1992|      0|    }
 1993|       |
 1994|       |
 1995|    889|  if (!uidnode)
  ------------------
  |  Branch (1995:7): [True: 131, False: 758]
  ------------------
 1996|    131|    {
 1997|    131|      if (!silent)
  ------------------
  |  Branch (1997:11): [True: 131, False: 0]
  ------------------
 1998|    131|        log_error( _("key %s: no user ID\n"), keystr_from_pk(pk));
  ------------------
  |  |   28|    131|#  define _(a) gettext (a)
  ------------------
 1999|    131|      return 0;
 2000|    131|    }
 2001|       |
 2002|    758|  if (screener && screener (keyblock, screener_arg))
  ------------------
  |  Branch (2002:7): [True: 0, False: 758]
  |  Branch (2002:19): [True: 0, False: 0]
  ------------------
 2003|      0|    {
 2004|      0|      log_error (_("key %s: %s\n"), keystr_from_pk (pk),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2005|      0|                 _("rejected by import screener"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2006|      0|      return 0;
 2007|      0|    }
 2008|       |
 2009|    758|  if (opt.interactive && !silent)
  ------------------
  |  Branch (2009:7): [True: 0, False: 758]
  |  Branch (2009:26): [True: 0, False: 0]
  ------------------
 2010|      0|    {
 2011|      0|      if (is_status_enabled())
  ------------------
  |  Branch (2011:11): [True: 0, False: 0]
  ------------------
 2012|      0|        print_import_check (pk, uidnode->pkt->pkt.user_id);
 2013|      0|      merge_keys_and_selfsig (ctrl, keyblock);
 2014|      0|      tty_printf ("\n");
 2015|      0|      show_basic_key_info (ctrl, keyblock, from_sk);
 2016|      0|      tty_printf ("\n");
 2017|      0|      if (!cpr_get_answer_is_yes ("import.okay",
  ------------------
  |  Branch (2017:11): [True: 0, False: 0]
  ------------------
 2018|      0|                                  "Do you want to import this key? (y/N) "))
 2019|      0|        return 0;
 2020|      0|    }
 2021|       |
 2022|       |  /* Remove all non-self-sigs if requested.  Note that this is a NOP if
 2023|       |   * that option has been globally set but we may also be called
 2024|       |   * latter with the already parsed keyblock and a locally changed
 2025|       |   * option.  This is why we need to remove them here as well.  */
 2026|    758|  if ((options & IMPORT_SELF_SIGS_ONLY))
  ------------------
  |  |  396|    758|#define IMPORT_SELF_SIGS_ONLY            (1<<14)
  ------------------
  |  Branch (2026:7): [True: 0, False: 758]
  ------------------
 2027|      0|    remove_all_non_self_sigs (&keyblock, keyid);
 2028|       |
 2029|       |  /* Remove or collapse the user ids.  */
 2030|    758|  if ((options & IMPORT_COLLAPSE_UIDS))
  ------------------
  |  |  397|    758|#define IMPORT_COLLAPSE_UIDS             (1<<15)
  ------------------
  |  Branch (2030:7): [True: 0, False: 758]
  ------------------
 2031|      0|    collapse_uids (&keyblock);
 2032|       |
 2033|    758|  if ((options & IMPORT_COLLAPSE_SUBKEYS))
  ------------------
  |  |  398|    758|#define IMPORT_COLLAPSE_SUBKEYS          (1<<16)
  ------------------
  |  Branch (2033:7): [True: 0, False: 758]
  ------------------
 2034|      0|    collapse_subkeys (&keyblock);
 2035|       |
 2036|       |  /* Clean the key that we're about to import, to cut down on things
 2037|       |     that we have to clean later.  This has no practical impact on the
 2038|       |     end result, but does result in less logging which might confuse
 2039|       |     the user. */
 2040|    758|  if ((options & IMPORT_CLEAN))
  ------------------
  |  |  389|    758|#define IMPORT_CLEAN                     (1<<6)
  ------------------
  |  Branch (2040:7): [True: 0, False: 758]
  ------------------
 2041|      0|    {
 2042|      0|      merge_keys_and_selfsig (ctrl, keyblock);
 2043|      0|      clean_all_uids (ctrl, keyblock,
 2044|      0|                      opt.verbose, (options&IMPORT_MINIMAL), NULL, NULL);
  ------------------
  |  |  388|      0|#define IMPORT_MINIMAL                   (1<<5)
  ------------------
 2045|      0|      clean_all_subkeys (ctrl, keyblock, opt.verbose, KEY_CLEAN_NONE,
  ------------------
  |  |   27|      0|#define KEY_CLEAN_NONE      0
  ------------------
 2046|      0|                         NULL, NULL);
 2047|      0|    }
 2048|       |
 2049|    758|  clear_kbnode_flags( keyblock );
 2050|       |
 2051|    758|  if ((options&IMPORT_REPAIR_PKS_SUBKEY_BUG)
  ------------------
  |  |  384|    758|#define IMPORT_REPAIR_PKS_SUBKEY_BUG     (1<<1)
  ------------------
  |  Branch (2051:7): [True: 0, False: 758]
  ------------------
 2052|    758|      && fix_pks_corruption (ctrl, keyblock)
  ------------------
  |  Branch (2052:10): [True: 0, False: 0]
  ------------------
 2053|    758|      && opt.verbose)
  ------------------
  |  Branch (2053:10): [True: 0, False: 0]
  ------------------
 2054|      0|    log_info (_("key %s: PKS subkey corruption repaired\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2055|      0|              keystr_from_pk(pk));
 2056|       |
 2057|    758|  if ((options & IMPORT_REPAIR_KEYS))
  ------------------
  |  |  394|    758|#define IMPORT_REPAIR_KEYS               (1<<11)
  ------------------
  |  Branch (2057:7): [True: 758, False: 0]
  ------------------
 2058|    758|    key_check_all_keysigs (ctrl, 1, keyblock, 0, 0);
 2059|       |
 2060|    758|  if (chk_self_sigs (ctrl, keyblock, keyid, &non_self))
  ------------------
  |  Branch (2060:7): [True: 0, False: 758]
  ------------------
 2061|      0|    return 0;  /* Invalid keyblock - error already printed.  */
 2062|       |
 2063|       |  /* If we allow such a thing, mark unsigned uids as valid */
 2064|    758|  if (opt.allow_non_selfsigned_uid)
  ------------------
  |  Branch (2064:7): [True: 0, False: 758]
  ------------------
 2065|      0|    {
 2066|      0|      for (node=keyblock; node; node = node->next )
  ------------------
  |  Branch (2066:27): [True: 0, False: 0]
  ------------------
 2067|      0|        if (node->pkt->pkttype == PKT_USER_ID
  ------------------
  |  Branch (2067:13): [True: 0, False: 0]
  ------------------
 2068|      0|            && !(node->flag & NODE_GOOD_SELFSIG)
  ------------------
  |  |   70|      0|#define NODE_GOOD_SELFSIG  1
  ------------------
  |  Branch (2068:16): [True: 0, False: 0]
  ------------------
 2069|      0|            && !(node->flag & NODE_BAD_SELFSIG) )
  ------------------
  |  |   73|      0|#define NODE_BAD_SELFSIG   2
  ------------------
  |  Branch (2069:16): [True: 0, False: 0]
  ------------------
 2070|      0|          {
 2071|      0|            char *user=utf8_to_native(node->pkt->pkt.user_id->name,
 2072|      0|                                      node->pkt->pkt.user_id->len,0);
 2073|       |            /* Fake a good signature status for the user id.  */
 2074|      0|            node->flag |= NODE_GOOD_SELFSIG;
  ------------------
  |  |   70|      0|#define NODE_GOOD_SELFSIG  1
  ------------------
 2075|      0|            log_info( _("key %s: accepted non self-signed user ID \"%s\"\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2076|      0|                      keystr_from_pk(pk),user);
 2077|      0|            xfree(user);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2078|      0|	  }
 2079|      0|    }
 2080|       |
 2081|       |  /* Delete invalid parts and bail out if there are no user ids left.  */
 2082|    758|  if (!delete_inv_parts (ctrl, keyblock, keyid, options, otherrevsigs))
  ------------------
  |  Branch (2082:7): [True: 747, False: 11]
  ------------------
 2083|    747|    {
 2084|    747|      if (!silent)
  ------------------
  |  Branch (2084:11): [True: 747, False: 0]
  ------------------
 2085|    747|        {
 2086|    747|          log_error ( _("key %s: no valid user IDs\n"), keystr_from_pk(pk));
  ------------------
  |  |   28|    747|#  define _(a) gettext (a)
  ------------------
 2087|    747|          if (!opt.quiet)
  ------------------
  |  Branch (2087:15): [True: 747, False: 0]
  ------------------
 2088|    747|            log_info(_("this may be caused by a missing self-signature\n"));
  ------------------
  |  |   28|    747|#  define _(a) gettext (a)
  ------------------
 2089|    747|        }
 2090|    747|      stats->no_user_id++;
 2091|    747|      return 0;
 2092|    747|    }
 2093|       |
 2094|       |  /* Get rid of deleted nodes.  */
 2095|     11|  commit_kbnode (&keyblock);
 2096|       |
 2097|       |  /* Apply import filter.  */
 2098|     11|  if (import_filter.keep_uid)
  ------------------
  |  Branch (2098:7): [True: 0, False: 11]
  ------------------
 2099|      0|    {
 2100|      0|      apply_keep_uid_filter (ctrl, keyblock, import_filter.keep_uid);
 2101|      0|      commit_kbnode (&keyblock);
 2102|      0|      any_filter = 1;
 2103|      0|    }
 2104|     11|  if (import_filter.drop_sig)
  ------------------
  |  Branch (2104:7): [True: 0, False: 11]
  ------------------
 2105|      0|    {
 2106|      0|      apply_drop_sig_filter (ctrl, keyblock, import_filter.drop_sig);
 2107|      0|      commit_kbnode (&keyblock);
 2108|      0|      any_filter = 1;
 2109|      0|    }
 2110|       |
 2111|       |  /* If we ran any filter we need to check that at least one user id
 2112|       |   * is left in the keyring.  Note that we do not use log_error in
 2113|       |   * this case. */
 2114|     11|  if (any_filter && !any_uid_left (keyblock))
  ------------------
  |  Branch (2114:7): [True: 0, False: 11]
  |  Branch (2114:21): [True: 0, False: 0]
  ------------------
 2115|      0|    {
 2116|      0|      if (!opt.quiet )
  ------------------
  |  Branch (2116:11): [True: 0, False: 0]
  ------------------
 2117|      0|        log_info ( _("key %s: no valid user IDs\n"), keystr_from_pk (pk));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2118|      0|      stats->no_user_id++;
 2119|      0|      return 0;
 2120|      0|    }
 2121|       |
 2122|       |  /* The keyblock is valid and ready for real import.  */
 2123|     11|  if (r_valid)
  ------------------
  |  Branch (2123:7): [True: 0, False: 11]
  ------------------
 2124|      0|    *r_valid = 1;
 2125|       |
 2126|       |  /* Show the key in the form it is merged or inserted.  We skip this
 2127|       |   * if "import-export" is also active without --armor or the output
 2128|       |   * file has explicily been given. */
 2129|     11|  if ((options & IMPORT_SHOW)
  ------------------
  |  |  386|     11|#define IMPORT_SHOW                      (1<<3)
  ------------------
  |  Branch (2129:7): [True: 0, False: 11]
  ------------------
 2130|     11|      && !((options & IMPORT_EXPORT) && !opt.armor && !opt.outfile))
  ------------------
  |  |  392|      0|#define IMPORT_EXPORT                    (1<<9)
  ------------------
  |  Branch (2130:12): [True: 0, False: 0]
  |  Branch (2130:41): [True: 0, False: 0]
  |  Branch (2130:55): [True: 0, False: 0]
  ------------------
 2131|      0|    {
 2132|      0|      merge_keys_and_selfsig (ctrl, keyblock);
 2133|      0|      merge_keys_done = 1;
 2134|       |      /* Note that we do not want to show the validity because the key
 2135|       |       * has not yet imported.  */
 2136|      0|      list_keyblock_direct (ctrl, keyblock, from_sk, 0,
 2137|      0|                            opt.fingerprint || opt.with_fingerprint, 1);
  ------------------
  |  Branch (2137:29): [True: 0, False: 0]
  |  Branch (2137:48): [True: 0, False: 0]
  ------------------
 2138|      0|      es_fflush (es_stdout);
 2139|      0|    }
 2140|       |
 2141|       |  /* Write the keyblock to the output and do not actually import.  */
 2142|     11|  if ((options & IMPORT_EXPORT))
  ------------------
  |  |  392|     11|#define IMPORT_EXPORT                    (1<<9)
  ------------------
  |  Branch (2142:7): [True: 0, False: 11]
  ------------------
 2143|      0|    {
 2144|      0|      if (!merge_keys_done)
  ------------------
  |  Branch (2144:11): [True: 0, False: 0]
  ------------------
 2145|      0|        {
 2146|      0|          merge_keys_and_selfsig (ctrl, keyblock);
 2147|      0|          merge_keys_done = 1;
 2148|      0|        }
 2149|      0|      err = write_keyblock_to_output (keyblock, opt.armor, opt.export_options);
 2150|      0|      goto leave;
 2151|      0|    }
 2152|       |
 2153|     11|  if (opt.dry_run || (options & IMPORT_DRY_RUN))
  ------------------
  |  |  395|     11|#define IMPORT_DRY_RUN                   (1<<12)
  ------------------
  |  Branch (2153:7): [True: 0, False: 11]
  |  Branch (2153:22): [True: 0, False: 11]
  ------------------
 2154|      0|    goto leave;
 2155|       |
 2156|       |  /* Do we have this key already in one of our pubrings ? */
 2157|     11|  err = get_keyblock_byfprint_fast (ctrl, &keyblock_orig, &hd,
 2158|     11|                                    fpr2, fpr2len, 1/*locked*/);
 2159|     11|  if ((err
  ------------------
  |  Branch (2159:8): [True: 2, False: 9]
  ------------------
 2160|     11|       && gpg_err_code (err) != GPG_ERR_NO_PUBKEY
  ------------------
  |  Branch (2160:11): [True: 0, False: 2]
  ------------------
 2161|     11|       && gpg_err_code (err) != GPG_ERR_UNUSABLE_PUBKEY)
  ------------------
  |  Branch (2161:11): [True: 0, False: 0]
  ------------------
 2162|     11|      || !hd)
  ------------------
  |  Branch (2162:10): [True: 0, False: 11]
  ------------------
 2163|      0|    {
 2164|       |      /* The !hd above is to catch a misbehaving function which
 2165|       |       * returns NO_PUBKEY for failing to allocate a handle.  */
 2166|      0|      if (!silent)
  ------------------
  |  Branch (2166:11): [True: 0, False: 0]
  ------------------
 2167|      0|        log_error (_("key %s: public key not found: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2168|      0|                   keystr(keyid), gpg_strerror (err));
 2169|      0|    }
 2170|     11|  else if (err && (opt.import_options&IMPORT_MERGE_ONLY) )
  ------------------
  |  |  387|      2|#define IMPORT_MERGE_ONLY                (1<<4)
  ------------------
  |  Branch (2170:12): [True: 2, False: 9]
  |  Branch (2170:19): [True: 0, False: 2]
  ------------------
 2171|      0|    {
 2172|      0|      if (opt.verbose && !silent )
  ------------------
  |  Branch (2172:11): [True: 0, False: 0]
  |  Branch (2172:26): [True: 0, False: 0]
  ------------------
 2173|      0|        log_info( _("key %s: new key - skipped\n"), keystr(keyid));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2174|      0|      err = 0;
 2175|      0|      stats->skipped_new_keys++;
 2176|      0|    }
 2177|     11|  else if (err)  /* Insert this key. */
  ------------------
  |  Branch (2177:12): [True: 2, False: 9]
  ------------------
 2178|      2|    {
 2179|       |      /* Note: ERR can only be NO_PUBKEY or UNUSABLE_PUBKEY.  */
 2180|      2|      int n_sigs_cleaned, n_uids_cleaned;
 2181|       |
 2182|      2|      err = keydb_locate_writable (hd);
 2183|      2|      if (err)
  ------------------
  |  Branch (2183:11): [True: 0, False: 2]
  ------------------
 2184|      0|        {
 2185|      0|          log_error (_("no writable keyring found: %s\n"), gpg_strerror (err));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2186|      0|          err = gpg_error (GPG_ERR_GENERAL);
 2187|      0|          goto leave;
 2188|      0|	}
 2189|      2|      if (opt.verbose > 1 )
  ------------------
  |  Branch (2189:11): [True: 0, False: 2]
  ------------------
 2190|      0|        log_info (_("writing to '%s'\n"), keydb_get_resource_name (hd) );
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2191|       |
 2192|      2|      if ((options & IMPORT_CLEAN))
  ------------------
  |  |  389|      2|#define IMPORT_CLEAN                     (1<<6)
  ------------------
  |  Branch (2192:11): [True: 0, False: 2]
  ------------------
 2193|      0|        {
 2194|      0|          merge_keys_and_selfsig (ctrl, keyblock);
 2195|      0|          clean_all_uids (ctrl, keyblock, opt.verbose, (options&IMPORT_MINIMAL),
  ------------------
  |  |  388|      0|#define IMPORT_MINIMAL                   (1<<5)
  ------------------
 2196|      0|                          &n_uids_cleaned,&n_sigs_cleaned);
 2197|      0|          clean_all_subkeys (ctrl, keyblock, opt.verbose, KEY_CLEAN_NONE,
  ------------------
  |  |   27|      0|#define KEY_CLEAN_NONE      0
  ------------------
 2198|      0|                             NULL, NULL);
 2199|      0|        }
 2200|       |
 2201|       |      /* Unless we are in restore mode apply meta data to the
 2202|       |       * keyblock.  Note that this will never change the first packet
 2203|       |       * and thus the address of KEYBLOCK won't change.  */
 2204|      2|      if ( !(options & IMPORT_RESTORE) )
  ------------------
  |  |  393|      2|#define IMPORT_RESTORE                   (1<<10)
  ------------------
  |  Branch (2204:12): [True: 2, False: 0]
  ------------------
 2205|      2|        {
 2206|      2|          err = insert_key_origin (keyblock, origin, url);
 2207|      2|          if (err)
  ------------------
  |  Branch (2207:15): [True: 0, False: 2]
  ------------------
 2208|      0|            {
 2209|      0|              log_error ("insert_key_origin failed: %s\n", gpg_strerror (err));
 2210|      0|              err = gpg_error (GPG_ERR_GENERAL);
 2211|      0|              goto leave;
 2212|      0|            }
 2213|      2|        }
 2214|       |
 2215|      2|      err = keydb_insert_keyblock (hd, keyblock );
 2216|      2|      if (err)
  ------------------
  |  Branch (2216:11): [True: 0, False: 2]
  ------------------
 2217|      0|        log_error (_("error writing keyring '%s': %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2218|      0|                   keydb_get_resource_name (hd), gpg_strerror (err));
 2219|      2|      else if (!(opt.import_options & IMPORT_KEEP_OWNERTTRUST))
  ------------------
  |  |  391|      2|#define IMPORT_KEEP_OWNERTTRUST          (1<<8)
  ------------------
  |  Branch (2219:16): [True: 2, False: 0]
  ------------------
 2220|      2|        {
 2221|       |          /* This should not be possible since we delete the
 2222|       |             ownertrust when a key is deleted, but it can happen if
 2223|       |             the keyring and trustdb are out of sync.  It can also
 2224|       |             be made to happen with the trusted-key command and by
 2225|       |             importing and locally exported key. */
 2226|       |
 2227|      2|          clear_ownertrusts (ctrl, pk);
 2228|      2|          if (non_self)
  ------------------
  |  Branch (2228:15): [True: 2, False: 0]
  ------------------
 2229|      2|            revalidation_mark (ctrl);
 2230|      2|        }
 2231|       |
 2232|       |      /* Release the handle and thus unlock the keyring asap.  */
 2233|      2|      keydb_release (hd);
 2234|      2|      hd = NULL;
 2235|       |
 2236|       |      /* We are ready.  */
 2237|      2|      if (!err && !opt.quiet && !silent)
  ------------------
  |  Branch (2237:11): [True: 2, False: 0]
  |  Branch (2237:19): [True: 2, False: 0]
  |  Branch (2237:33): [True: 2, False: 0]
  ------------------
 2238|      2|        {
 2239|      2|          char *p = get_user_id_byfpr_native (ctrl, fpr2, fpr2len);
 2240|      2|          log_info (_("key %s: public key \"%s\" imported\n"),
  ------------------
  |  |   28|      2|#  define _(a) gettext (a)
  ------------------
 2241|      2|                    keystr(keyid), p);
 2242|      2|          xfree(p);
  ------------------
  |  |  104|      2|#define xfree(a)         gcry_free ((a))
  ------------------
 2243|      2|        }
 2244|      2|      if (!err && is_status_enabled())
  ------------------
  |  Branch (2244:11): [True: 2, False: 0]
  |  Branch (2244:19): [True: 0, False: 2]
  ------------------
 2245|      0|        {
 2246|      0|          char *us = get_long_user_id_string (ctrl, keyid);
 2247|      0|          write_status_text( STATUS_IMPORTED, us );
 2248|      0|          xfree(us);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2249|      0|          print_import_ok (pk, 1);
 2250|      0|        }
 2251|      2|      if (!err)
  ------------------
  |  Branch (2251:11): [True: 2, False: 0]
  ------------------
 2252|      2|        {
 2253|      2|          stats->imported++;
 2254|      2|          new_key = 1;
 2255|      2|        }
 2256|      2|    }
 2257|      9|  else /* Key already exists - merge.  */
 2258|      9|    {
 2259|      9|      int n_uids, n_sigs, n_subk, n_sigs_cleaned, n_uids_cleaned;
 2260|      9|      u32 curtime = make_timestamp ();
 2261|       |
 2262|       |      /* Compare the original against the new key; just to be sure nothing
 2263|       |       * weird is going on */
 2264|      9|      if (cmp_public_keys (keyblock_orig->pkt->pkt.public_key, pk))
  ------------------
  |  Branch (2264:11): [True: 0, False: 9]
  ------------------
 2265|      0|        {
 2266|      0|          if (!silent)
  ------------------
  |  Branch (2266:15): [True: 0, False: 0]
  ------------------
 2267|      0|            log_error( _("key %s: doesn't match our copy\n"),keystr(keyid));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2268|      0|          goto leave;
 2269|      0|        }
 2270|       |
 2271|       |      /* Make sure the original direct key sigs are all sane.  */
 2272|      9|      n_sigs_cleaned = fix_bad_direct_key_sigs (ctrl, keyblock_orig, keyid);
 2273|      9|      if (n_sigs_cleaned)
  ------------------
  |  Branch (2273:11): [True: 2, False: 7]
  ------------------
 2274|      2|        commit_kbnode (&keyblock_orig);
 2275|       |
 2276|       |      /* Try to merge KEYBLOCK into KEYBLOCK_ORIG.  */
 2277|      9|      clear_kbnode_flags( keyblock_orig );
 2278|      9|      clear_kbnode_flags( keyblock );
 2279|      9|      n_uids = n_sigs = n_subk = n_uids_cleaned = 0;
 2280|      9|      err = merge_blocks (ctrl, options, keyblock_orig, keyblock, keyid,
 2281|      9|                          curtime, origin, url,
 2282|      9|                          &n_uids, &n_sigs, &n_subk );
 2283|      9|      if (err)
  ------------------
  |  Branch (2283:11): [True: 0, False: 9]
  ------------------
 2284|      0|        goto leave;
 2285|       |
 2286|       |      /* Clean the final keyblock again if requested.  we can't do
 2287|       |       * this if only self-signatures are imported; see bug #4628.  */
 2288|      9|      if ((options & IMPORT_CLEAN)
  ------------------
  |  |  389|      9|#define IMPORT_CLEAN                     (1<<6)
  ------------------
  |  Branch (2288:11): [True: 0, False: 9]
  ------------------
 2289|      9|          && !(options & IMPORT_SELF_SIGS_ONLY))
  ------------------
  |  |  396|      0|#define IMPORT_SELF_SIGS_ONLY            (1<<14)
  ------------------
  |  Branch (2289:14): [True: 0, False: 0]
  ------------------
 2290|      0|        {
 2291|      0|          merge_keys_and_selfsig (ctrl, keyblock_orig);
 2292|      0|          clean_all_uids (ctrl, keyblock_orig, opt.verbose,
 2293|      0|                          (options&IMPORT_MINIMAL),
  ------------------
  |  |  388|      0|#define IMPORT_MINIMAL                   (1<<5)
  ------------------
 2294|      0|                          &n_uids_cleaned,&n_sigs_cleaned);
 2295|      0|          clean_all_subkeys (ctrl, keyblock_orig, opt.verbose, KEY_CLEAN_NONE,
  ------------------
  |  |   27|      0|#define KEY_CLEAN_NONE      0
  ------------------
 2296|      0|                             NULL, NULL);
 2297|      0|        }
 2298|       |
 2299|      9|      if (n_uids || n_sigs || n_subk || n_sigs_cleaned || n_uids_cleaned)
  ------------------
  |  Branch (2299:11): [True: 0, False: 9]
  |  Branch (2299:21): [True: 9, False: 0]
  |  Branch (2299:31): [True: 0, False: 0]
  |  Branch (2299:41): [True: 0, False: 0]
  |  Branch (2299:59): [True: 0, False: 0]
  ------------------
 2300|      9|        {
 2301|       |          /* Unless we are in restore mode apply meta data to the
 2302|       |           * keyblock.  Note that this will never change the first packet
 2303|       |           * and thus the address of KEYBLOCK won't change.  */
 2304|      9|          if ( !(options & IMPORT_RESTORE) )
  ------------------
  |  |  393|      9|#define IMPORT_RESTORE                   (1<<10)
  ------------------
  |  Branch (2304:16): [True: 9, False: 0]
  ------------------
 2305|      9|            {
 2306|      9|              err = update_key_origin (keyblock_orig, curtime, origin, url);
 2307|      9|              if (err)
  ------------------
  |  Branch (2307:19): [True: 0, False: 9]
  ------------------
 2308|      0|                {
 2309|      0|                  log_error ("update_key_origin failed: %s\n",
 2310|      0|                             gpg_strerror (err));
 2311|      0|                  goto leave;
 2312|      0|                }
 2313|      9|            }
 2314|       |
 2315|      9|          mod_key = 1;
 2316|       |          /* KEYBLOCK_ORIG has been updated; write */
 2317|      9|          err = keydb_update_keyblock (ctrl, hd, keyblock_orig);
 2318|      9|          if (err)
  ------------------
  |  Branch (2318:15): [True: 0, False: 9]
  ------------------
 2319|      0|            log_error (_("error writing keyring '%s': %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2320|      0|                       keydb_get_resource_name (hd), gpg_strerror (err));
 2321|      9|          else if (non_self)
  ------------------
  |  Branch (2321:20): [True: 9, False: 0]
  ------------------
 2322|      9|            revalidation_mark (ctrl);
 2323|       |
 2324|       |          /* Release the handle and thus unlock the keyring asap.  */
 2325|      9|          keydb_release (hd);
 2326|      9|          hd = NULL;
 2327|       |
 2328|       |          /* We are ready.  Print and update stats if we got no error.
 2329|       |           * An error here comes from writing the keyblock and thus
 2330|       |           * very likely means that no update happened.  */
 2331|      9|          if (!err && !opt.quiet && !silent)
  ------------------
  |  Branch (2331:15): [True: 9, False: 0]
  |  Branch (2331:23): [True: 9, False: 0]
  |  Branch (2331:37): [True: 9, False: 0]
  ------------------
 2332|      9|            {
 2333|      9|              char *p = get_user_id_byfpr_native (ctrl, fpr2, fpr2len);
 2334|      9|              if (n_uids == 1 )
  ------------------
  |  Branch (2334:19): [True: 0, False: 9]
  ------------------
 2335|      0|                log_info( _("key %s: \"%s\" 1 new user ID\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2336|      0|                          keystr(keyid),p);
 2337|      9|              else if (n_uids )
  ------------------
  |  Branch (2337:24): [True: 0, False: 9]
  ------------------
 2338|      0|                log_info( _("key %s: \"%s\" %d new user IDs\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2339|      0|                          keystr(keyid),p,n_uids);
 2340|      9|              if (n_sigs == 1 )
  ------------------
  |  Branch (2340:19): [True: 7, False: 2]
  ------------------
 2341|      7|                log_info( _("key %s: \"%s\" 1 new signature\n"),
  ------------------
  |  |   28|      7|#  define _(a) gettext (a)
  ------------------
 2342|      7|                          keystr(keyid), p);
 2343|      2|              else if (n_sigs )
  ------------------
  |  Branch (2343:24): [True: 2, False: 0]
  ------------------
 2344|      2|                log_info( _("key %s: \"%s\" %d new signatures\n"),
  ------------------
  |  |   28|      2|#  define _(a) gettext (a)
  ------------------
 2345|      2|                          keystr(keyid), p, n_sigs );
 2346|      9|              if (n_subk == 1 )
  ------------------
  |  Branch (2346:19): [True: 0, False: 9]
  ------------------
 2347|      0|                log_info( _("key %s: \"%s\" 1 new subkey\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2348|      0|                          keystr(keyid), p);
 2349|      9|              else if (n_subk )
  ------------------
  |  Branch (2349:24): [True: 0, False: 9]
  ------------------
 2350|      0|                log_info( _("key %s: \"%s\" %d new subkeys\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2351|      0|                          keystr(keyid), p, n_subk );
 2352|      9|              if (n_sigs_cleaned==1)
  ------------------
  |  Branch (2352:19): [True: 1, False: 8]
  ------------------
 2353|      1|                log_info(_("key %s: \"%s\" %d signature cleaned\n"),
  ------------------
  |  |   28|      1|#  define _(a) gettext (a)
  ------------------
 2354|      1|                         keystr(keyid),p,n_sigs_cleaned);
 2355|      8|              else if (n_sigs_cleaned)
  ------------------
  |  Branch (2355:24): [True: 1, False: 7]
  ------------------
 2356|      1|                log_info(_("key %s: \"%s\" %d signatures cleaned\n"),
  ------------------
  |  |   28|      1|#  define _(a) gettext (a)
  ------------------
 2357|      1|                         keystr(keyid),p,n_sigs_cleaned);
 2358|      9|              if (n_uids_cleaned==1)
  ------------------
  |  Branch (2358:19): [True: 0, False: 9]
  ------------------
 2359|      0|                log_info(_("key %s: \"%s\" %d user ID cleaned\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2360|      0|                         keystr(keyid),p,n_uids_cleaned);
 2361|      9|              else if (n_uids_cleaned)
  ------------------
  |  Branch (2361:24): [True: 0, False: 9]
  ------------------
 2362|      0|                log_info(_("key %s: \"%s\" %d user IDs cleaned\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2363|      0|                         keystr(keyid),p,n_uids_cleaned);
 2364|      9|              xfree(p);
  ------------------
  |  |  104|      9|#define xfree(a)         gcry_free ((a))
  ------------------
 2365|      9|            }
 2366|       |
 2367|      9|          if (!err)
  ------------------
  |  Branch (2367:15): [True: 9, False: 0]
  ------------------
 2368|      9|            {
 2369|      9|              stats->n_uids +=n_uids;
 2370|      9|              stats->n_sigs +=n_sigs;
 2371|      9|              stats->n_subk +=n_subk;
 2372|      9|              stats->n_sigs_cleaned +=n_sigs_cleaned;
 2373|      9|              stats->n_uids_cleaned +=n_uids_cleaned;
 2374|       |
 2375|      9|              if (is_status_enabled () && !silent)
  ------------------
  |  Branch (2375:19): [True: 0, False: 9]
  |  Branch (2375:43): [True: 0, False: 0]
  ------------------
 2376|      0|                print_import_ok (pk, ((n_uids?2:0)|(n_sigs?4:0)|(n_subk?8:0)));
  ------------------
  |  Branch (2376:40): [True: 0, False: 0]
  |  Branch (2376:53): [True: 0, False: 0]
  |  Branch (2376:66): [True: 0, False: 0]
  ------------------
 2377|      9|            }
 2378|      9|	}
 2379|      0|      else
 2380|      0|        {
 2381|       |          /* Release the handle and thus unlock the keyring asap.  */
 2382|      0|          keydb_release (hd);
 2383|      0|          hd = NULL;
 2384|       |
 2385|       |          /* FIXME: We do not track the time we last checked a key for
 2386|       |           * updates.  To do this we would need to rewrite even the
 2387|       |           * keys which have no changes.  Adding this would be useful
 2388|       |           * for the automatic update of expired keys via the WKD in
 2389|       |           * case the WKD still carries the expired key.  See
 2390|       |           * get_best_pubkey_byname.  */
 2391|      0|          same_key = 1;
 2392|      0|          if (is_status_enabled ())
  ------------------
  |  Branch (2392:15): [True: 0, False: 0]
  ------------------
 2393|      0|            print_import_ok (pk, 0);
 2394|       |
 2395|      0|          if (!opt.quiet && !silent)
  ------------------
  |  Branch (2395:15): [True: 0, False: 0]
  |  Branch (2395:29): [True: 0, False: 0]
  ------------------
 2396|      0|            {
 2397|      0|              char *p = get_user_id_byfpr_native (ctrl, fpr2, fpr2len);
 2398|      0|              log_info( _("key %s: \"%s\" not changed\n"),keystr(keyid),p);
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2399|      0|              xfree(p);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2400|      0|            }
 2401|       |
 2402|      0|          stats->unchanged++;
 2403|      0|        }
 2404|      9|    }
 2405|       |
 2406|     11| leave:
 2407|     11|  keydb_release (hd);
 2408|     11|  if (mod_key || new_key || same_key)
  ------------------
  |  Branch (2408:7): [True: 9, False: 2]
  |  Branch (2408:18): [True: 2, False: 0]
  |  Branch (2408:29): [True: 0, False: 0]
  ------------------
 2409|     11|    {
 2410|       |      /* A little explanation for this: we fill in the fingerprint
 2411|       |         when importing keys as it can be useful to know the
 2412|       |         fingerprint in certain keyserver-related cases (a keyserver
 2413|       |         asked for a particular name, but the key doesn't have that
 2414|       |         name).  However, in cases where we're importing more than
 2415|       |         one key at a time, we cannot know which key to fingerprint.
 2416|       |         In these cases, rather than guessing, we do not
 2417|       |         fingerprinting at all, and we must hope the user ID on the
 2418|       |         keys are useful.  Note that we need to do this for new
 2419|       |         keys, merged keys and even for unchanged keys.  This is
 2420|       |         required because for example the --auto-key-locate feature
 2421|       |         may import an already imported key and needs to know the
 2422|       |         fingerprint of the key in all cases.  */
 2423|     11|      if (fpr)
  ------------------
  |  Branch (2423:11): [True: 0, False: 11]
  ------------------
 2424|      0|        {
 2425|       |          /* Note that we need to compare against 0 here because
 2426|       |             COUNT gets only incremented after returning from this
 2427|       |             function.  */
 2428|      0|          if (!stats->count)
  ------------------
  |  Branch (2428:15): [True: 0, False: 0]
  ------------------
 2429|      0|            {
 2430|      0|              xfree (*fpr);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2431|      0|              *fpr = fingerprint_from_pk (pk, NULL, fpr_len);
 2432|      0|            }
 2433|      0|          else if (origin != KEYORG_WKD)
  ------------------
  |  Branch (2433:20): [True: 0, False: 0]
  ------------------
 2434|      0|            {
 2435|      0|              xfree (*fpr);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2436|      0|              *fpr = NULL;
 2437|      0|            }
 2438|      0|        }
 2439|     11|    }
 2440|       |
 2441|       |  /* Now that the key is definitely incorporated into the keydb, we
 2442|       |     need to check if a designated revocation is present or if the
 2443|       |     prefs are not rational so we can warn the user. */
 2444|       |
 2445|     11|  if (mod_key)
  ------------------
  |  Branch (2445:7): [True: 9, False: 2]
  ------------------
 2446|      9|    {
 2447|      9|      revocation_present (ctrl, keyblock_orig);
 2448|      9|      if (!from_sk && have_secret_key_with_kid (ctrl, keyid))
  ------------------
  |  Branch (2448:11): [True: 9, False: 0]
  |  Branch (2448:23): [True: 9, False: 0]
  ------------------
 2449|      9|        check_prefs (ctrl, keyblock_orig);
 2450|      9|    }
 2451|      2|  else if (new_key)
  ------------------
  |  Branch (2451:12): [True: 2, False: 0]
  ------------------
 2452|      2|    {
 2453|      2|      revocation_present (ctrl, keyblock);
 2454|      2|      if (!from_sk && have_secret_key_with_kid (ctrl, keyid))
  ------------------
  |  Branch (2454:11): [True: 2, False: 0]
  |  Branch (2454:23): [True: 2, False: 0]
  ------------------
 2455|      2|        check_prefs (ctrl, keyblock);
 2456|      2|    }
 2457|       |
 2458|     11|  release_kbnode( keyblock_orig );
 2459|       |
 2460|     11|  return err;
 2461|     11|}
import.c:insert_key_origin:
 1818|      2|{
 1819|      2|  gpg_error_t err;
 1820|      2|  kbnode_t node;
 1821|      2|  u32 curtime = make_timestamp ();
 1822|       |
 1823|     13|  for (node = keyblock; node; node = node->next)
  ------------------
  |  Branch (1823:25): [True: 11, False: 2]
  ------------------
 1824|     11|    {
 1825|     11|      if (is_deleted_kbnode (node))
  ------------------
  |  |   70|     11|#define is_deleted_kbnode(a)  ((a)->private_flag & 1)
  |  |  ------------------
  |  |  |  Branch (70:31): [True: 0, False: 11]
  |  |  ------------------
  ------------------
 1826|      0|        ;
 1827|     11|      else if (node->pkt->pkttype == PKT_PUBLIC_KEY)
  ------------------
  |  Branch (1827:16): [True: 2, False: 9]
  ------------------
 1828|      2|        {
 1829|      2|          err = insert_key_origin_pk (node->pkt->pkt.public_key, curtime,
 1830|      2|                                      origin, url);
 1831|      2|          if (err)
  ------------------
  |  Branch (1831:15): [True: 0, False: 2]
  ------------------
 1832|      0|            return err;
 1833|      2|        }
 1834|      9|      else if (node->pkt->pkttype == PKT_USER_ID)
  ------------------
  |  Branch (1834:16): [True: 2, False: 7]
  ------------------
 1835|      2|        {
 1836|      2|          err = insert_key_origin_uid (node->pkt->pkt.user_id, curtime,
 1837|      2|                                       origin, url);
 1838|      2|          if (err)
  ------------------
  |  Branch (1838:15): [True: 0, False: 2]
  ------------------
 1839|      0|            return err;
 1840|      2|        }
 1841|     11|    }
 1842|       |
 1843|      2|  return 0;
 1844|      2|}
import.c:insert_key_origin_pk:
 1716|      2|{
 1717|      2|  if (origin == KEYORG_WKD || origin == KEYORG_DANE)
  ------------------
  |  Branch (1717:7): [True: 0, False: 2]
  |  Branch (1717:31): [True: 0, False: 2]
  ------------------
 1718|      0|    {
 1719|       |      /* For WKD and DANE we insert origin information also for the
 1720|       |       * key but we don't record the URL because we have have no use
 1721|       |       * for that: An update using a keyserver has higher precedence
 1722|       |       * and will thus update this origin info.  For refresh using WKD
 1723|       |       * or DANE we need to go via the User ID anyway.  Recall that we
 1724|       |       * are only inserting a new key. */
 1725|      0|      pk->keyorg = origin;
 1726|      0|      pk->keyupdate = curtime;
 1727|      0|    }
 1728|      2|  else if (origin == KEYORG_KS && url)
  ------------------
  |  Branch (1728:12): [True: 0, False: 2]
  |  Branch (1728:35): [True: 0, False: 0]
  ------------------
 1729|      0|    {
 1730|       |      /* If the key was retrieved from a keyserver using a fingerprint
 1731|       |       * request we add the meta information.  Note that the use of a
 1732|       |       * fingerprint needs to be enforced by the caller of the import
 1733|       |       * function.  This is commonly triggered by verifying a modern
 1734|       |       * signature which has an Issuer Fingerprint signature
 1735|       |       * subpacket.  */
 1736|      0|      pk->keyorg = origin;
 1737|      0|      pk->keyupdate = curtime;
 1738|      0|      xfree (pk->updateurl);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1739|      0|      pk->updateurl = xtrystrdup (url);
  ------------------
  |  |  103|      0|#define xtrystrdup(a)    gcry_strdup ((a))
  ------------------
 1740|      0|      if (!pk->updateurl)
  ------------------
  |  Branch (1740:11): [True: 0, False: 0]
  ------------------
 1741|      0|        return gpg_error_from_syserror ();
 1742|      0|    }
 1743|      2|  else if (origin == KEYORG_FILE)
  ------------------
  |  Branch (1743:12): [True: 0, False: 2]
  ------------------
 1744|      0|    {
 1745|      0|      pk->keyorg = origin;
 1746|      0|      pk->keyupdate = curtime;
 1747|      0|    }
 1748|      2|  else if (origin == KEYORG_URL)
  ------------------
  |  Branch (1748:12): [True: 0, False: 2]
  ------------------
 1749|      0|    {
 1750|      0|      pk->keyorg = origin;
 1751|      0|      pk->keyupdate = curtime;
 1752|      0|      if (url)
  ------------------
  |  Branch (1752:11): [True: 0, False: 0]
  ------------------
 1753|      0|        {
 1754|      0|          xfree (pk->updateurl);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1755|      0|          pk->updateurl = xtrystrdup (url);
  ------------------
  |  |  103|      0|#define xtrystrdup(a)    gcry_strdup ((a))
  ------------------
 1756|      0|          if (!pk->updateurl)
  ------------------
  |  Branch (1756:15): [True: 0, False: 0]
  ------------------
 1757|      0|            return gpg_error_from_syserror ();
 1758|      0|        }
 1759|      0|    }
 1760|       |
 1761|      2|  return 0;
 1762|      2|}
import.c:insert_key_origin_uid:
 1770|      2|{
 1771|      2|  if (origin == KEYORG_WKD || origin == KEYORG_DANE)
  ------------------
  |  Branch (1771:7): [True: 0, False: 2]
  |  Branch (1771:31): [True: 0, False: 2]
  ------------------
 1772|      0|    {
 1773|       |      /* We insert origin information on a UID only when we received
 1774|       |       * them via the Web Key Directory or a DANE record.  The key we
 1775|       |       * receive here from the WKD has been filtered to contain only
 1776|       |       * the user ID as looked up in the WKD.  For a DANE origin we
 1777|       |       * this should also be the case.  Thus we will see here only one
 1778|       |       * user id.  */
 1779|      0|      uid->keyorg = origin;
 1780|      0|      uid->keyupdate = curtime;
 1781|      0|      if (url)
  ------------------
  |  Branch (1781:11): [True: 0, False: 0]
  ------------------
 1782|      0|        {
 1783|      0|          xfree (uid->updateurl);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1784|      0|          uid->updateurl = xtrystrdup (url);
  ------------------
  |  |  103|      0|#define xtrystrdup(a)    gcry_strdup ((a))
  ------------------
 1785|      0|          if (!uid->updateurl)
  ------------------
  |  Branch (1785:15): [True: 0, False: 0]
  ------------------
 1786|      0|            return gpg_error_from_syserror ();
 1787|      0|        }
 1788|      0|    }
 1789|      2|  else if (origin == KEYORG_KS && url)
  ------------------
  |  Branch (1789:12): [True: 0, False: 2]
  |  Branch (1789:35): [True: 0, False: 0]
  ------------------
 1790|      0|    {
 1791|       |      /* If the key was retrieved from a keyserver using a fingerprint
 1792|       |       * request we mark that also in the user ID.  However we do not
 1793|       |       * store the keyserver URL in the UID.  A later update (merge)
 1794|       |       * from a more trusted source will replace this info.  */
 1795|      0|      uid->keyorg = origin;
 1796|      0|      uid->keyupdate = curtime;
 1797|      0|    }
 1798|      2|  else if (origin == KEYORG_FILE)
  ------------------
  |  Branch (1798:12): [True: 0, False: 2]
  ------------------
 1799|      0|    {
 1800|      0|      uid->keyorg = origin;
 1801|      0|      uid->keyupdate = curtime;
 1802|      0|    }
 1803|      2|  else if (origin == KEYORG_URL)
  ------------------
  |  Branch (1803:12): [True: 0, False: 2]
  ------------------
 1804|      0|    {
 1805|      0|      uid->keyorg = origin;
 1806|      0|      uid->keyupdate = curtime;
 1807|      0|    }
 1808|       |
 1809|      2|  return 0;
 1810|      2|}
import.c:fix_bad_direct_key_sigs:
 1234|      9|{
 1235|      9|  gpg_error_t err;
 1236|      9|  kbnode_t node;
 1237|      9|  int count = 0;
 1238|       |
 1239|     20|  for (node = keyblock->next; node; node=node->next)
  ------------------
  |  Branch (1239:31): [True: 20, False: 0]
  ------------------
 1240|     20|    {
 1241|     20|      if (node->pkt->pkttype == PKT_USER_ID)
  ------------------
  |  Branch (1241:11): [True: 9, False: 11]
  ------------------
 1242|      9|        break;
 1243|     11|      if (node->pkt->pkttype == PKT_SIGNATURE
  ------------------
  |  Branch (1243:11): [True: 9, False: 2]
  ------------------
 1244|     11|          && IS_KEY_SIG (node->pkt->pkt.signature))
  ------------------
  |  |   40|      9|#define IS_KEY_SIG(s)    ((s)->sig_class == 0x1f)
  |  |  ------------------
  |  |  |  Branch (40:26): [True: 3, False: 6]
  |  |  ------------------
  ------------------
 1245|      3|        {
 1246|      3|          err = check_key_signature (ctrl, keyblock, node, NULL);
 1247|      3|          if (err && gpg_err_code (err) != GPG_ERR_PUBKEY_ALGO )
  ------------------
  |  Branch (1247:15): [True: 3, False: 0]
  |  Branch (1247:22): [True: 3, False: 0]
  ------------------
 1248|      3|            {
 1249|       |              /* If we don't know the error, we can't decide; this is
 1250|       |                 not a problem because cmp_signature can't compare the
 1251|       |                 signature either.  */
 1252|      3|              log_info ("key %s: invalid direct key signature removed\n",
 1253|      3|                        keystr (keyid));
 1254|      3|              delete_kbnode (node);
 1255|      3|              count++;
 1256|      3|            }
 1257|      3|        }
 1258|     11|    }
 1259|       |
 1260|      9|  return count;
 1261|      9|}
import.c:merge_blocks:
 4408|      9|{
 4409|      9|  kbnode_t onode, node;
 4410|      9|  int rc, found;
 4411|       |
 4412|       |  /* 1st: handle revocation certificates */
 4413|     17|  for (node=keyblock->next; node; node=node->next )
  ------------------
  |  Branch (4413:29): [True: 17, False: 0]
  ------------------
 4414|     17|    {
 4415|     17|      if (node->pkt->pkttype == PKT_USER_ID )
  ------------------
  |  Branch (4415:11): [True: 9, False: 8]
  ------------------
 4416|      9|        break;
 4417|      8|      else if (node->pkt->pkttype == PKT_SIGNATURE
  ------------------
  |  Branch (4417:16): [True: 6, False: 2]
  ------------------
 4418|      8|               && IS_KEY_REV (node->pkt->pkt.signature))
  ------------------
  |  |   45|      6|#define IS_KEY_REV(s)    ((s)->sig_class == 0x20)
  |  |  ------------------
  |  |  |  Branch (45:26): [True: 0, False: 6]
  |  |  ------------------
  ------------------
 4419|      0|        {
 4420|       |          /* check whether we already have this */
 4421|      0|          found = 0;
 4422|      0|          for (onode=keyblock_orig->next; onode; onode=onode->next)
  ------------------
  |  Branch (4422:43): [True: 0, False: 0]
  ------------------
 4423|      0|            {
 4424|      0|              if (onode->pkt->pkttype == PKT_USER_ID )
  ------------------
  |  Branch (4424:19): [True: 0, False: 0]
  ------------------
 4425|      0|                break;
 4426|      0|              else if (onode->pkt->pkttype == PKT_SIGNATURE
  ------------------
  |  Branch (4426:24): [True: 0, False: 0]
  ------------------
 4427|      0|                       && IS_KEY_REV (onode->pkt->pkt.signature)
  ------------------
  |  |   45|      0|#define IS_KEY_REV(s)    ((s)->sig_class == 0x20)
  |  |  ------------------
  |  |  |  Branch (45:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 4428|      0|                       && !cmp_signatures(onode->pkt->pkt.signature,
  ------------------
  |  Branch (4428:27): [True: 0, False: 0]
  ------------------
 4429|      0|                                          node->pkt->pkt.signature))
 4430|      0|                {
 4431|      0|                  found = 1;
 4432|      0|                  break;
 4433|      0|                }
 4434|      0|	    }
 4435|      0|          if (!found)
  ------------------
  |  Branch (4435:15): [True: 0, False: 0]
  ------------------
 4436|      0|            {
 4437|      0|              kbnode_t n2 = clone_kbnode(node);
 4438|      0|              insert_kbnode( keyblock_orig, n2, 0 );
 4439|      0|              n2->flag |= NODE_FLAG_A;
  ------------------
  |  |   77|      0|#define NODE_FLAG_A  8
  ------------------
 4440|      0|              ++*n_sigs;
 4441|      0|              if(!opt.quiet)
  ------------------
  |  Branch (4441:18): [True: 0, False: 0]
  ------------------
 4442|      0|                {
 4443|      0|                  char *p = get_user_id_native (ctrl, keyid);
 4444|      0|                  log_info(_("key %s: \"%s\" revocation"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 4445|      0|                             " certificate added\n"), keystr(keyid),p);
 4446|      0|                  xfree(p);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 4447|      0|                }
 4448|      0|	    }
 4449|      0|	}
 4450|     17|    }
 4451|       |
 4452|       |  /* 2nd: merge in any direct key (0x1F) sigs */
 4453|     17|  for(node=keyblock->next; node; node=node->next)
  ------------------
  |  Branch (4453:28): [True: 17, False: 0]
  ------------------
 4454|     17|    {
 4455|     17|      if (node->pkt->pkttype == PKT_USER_ID )
  ------------------
  |  Branch (4455:11): [True: 9, False: 8]
  ------------------
 4456|      9|        break;
 4457|      8|      else if (node->pkt->pkttype == PKT_SIGNATURE
  ------------------
  |  Branch (4457:16): [True: 6, False: 2]
  ------------------
 4458|      8|               && IS_KEY_SIG (node->pkt->pkt.signature))
  ------------------
  |  |   40|      6|#define IS_KEY_SIG(s)    ((s)->sig_class == 0x1f)
  |  |  ------------------
  |  |  |  Branch (40:26): [True: 4, False: 2]
  |  |  ------------------
  ------------------
 4459|      4|        {
 4460|       |          /* check whether we already have this */
 4461|      4|          found = 0;
 4462|     22|          for (onode=keyblock_orig->next; onode; onode=onode->next)
  ------------------
  |  Branch (4462:43): [True: 22, False: 0]
  ------------------
 4463|     22|            {
 4464|     22|              if (onode->pkt->pkttype == PKT_USER_ID)
  ------------------
  |  Branch (4464:19): [True: 4, False: 18]
  ------------------
 4465|      4|                break;
 4466|     18|              else if (onode->pkt->pkttype == PKT_SIGNATURE
  ------------------
  |  Branch (4466:24): [True: 14, False: 4]
  ------------------
 4467|     18|                       && IS_KEY_SIG (onode->pkt->pkt.signature)
  ------------------
  |  |   40|     32|#define IS_KEY_SIG(s)    ((s)->sig_class == 0x1f)
  |  |  ------------------
  |  |  |  Branch (40:26): [True: 2, False: 12]
  |  |  ------------------
  ------------------
 4468|     18|                       && !cmp_signatures(onode->pkt->pkt.signature,
  ------------------
  |  Branch (4468:27): [True: 0, False: 2]
  ------------------
 4469|      2|                                          node->pkt->pkt.signature))
 4470|      0|                {
 4471|      0|                  found = 1;
 4472|      0|                  break;
 4473|      0|		}
 4474|     22|	    }
 4475|      4|          if (!found )
  ------------------
  |  Branch (4475:15): [True: 4, False: 0]
  ------------------
 4476|      4|            {
 4477|      4|              kbnode_t n2 = clone_kbnode(node);
 4478|      4|              insert_kbnode( keyblock_orig, n2, 0 );
 4479|      4|              n2->flag |= NODE_FLAG_A;
  ------------------
  |  |   77|      4|#define NODE_FLAG_A  8
  ------------------
 4480|      4|              ++*n_sigs;
 4481|      4|              if(!opt.quiet)
  ------------------
  |  Branch (4481:18): [True: 4, False: 0]
  ------------------
 4482|      4|                log_info( _("key %s: direct key signature added\n"),
  ------------------
  |  |   28|      4|#  define _(a) gettext (a)
  ------------------
 4483|      4|                          keystr(keyid));
 4484|      4|            }
 4485|      4|	}
 4486|     17|    }
 4487|       |
 4488|       |  /* 3rd: try to merge new certificates in */
 4489|     69|  for (onode=keyblock_orig->next; onode; onode=onode->next)
  ------------------
  |  Branch (4489:35): [True: 60, False: 9]
  ------------------
 4490|     60|    {
 4491|     60|      if (!(onode->flag & NODE_FLAG_A) && onode->pkt->pkttype == PKT_USER_ID)
  ------------------
  |  |   77|     60|#define NODE_FLAG_A  8
  ------------------
  |  Branch (4491:11): [True: 49, False: 11]
  |  Branch (4491:43): [True: 9, False: 40]
  ------------------
 4492|      9|        {
 4493|       |          /* find the user id in the imported keyblock */
 4494|     17|          for (node=keyblock->next; node; node=node->next)
  ------------------
  |  Branch (4494:37): [True: 17, False: 0]
  ------------------
 4495|     17|            if (node->pkt->pkttype == PKT_USER_ID
  ------------------
  |  Branch (4495:17): [True: 9, False: 8]
  ------------------
 4496|     17|                && !cmp_user_ids( onode->pkt->pkt.user_id,
  ------------------
  |  Branch (4496:20): [True: 9, False: 0]
  ------------------
 4497|      9|                                  node->pkt->pkt.user_id ) )
 4498|      9|              break;
 4499|      9|          if (node ) /* found: merge */
  ------------------
  |  Branch (4499:15): [True: 9, False: 0]
  ------------------
 4500|      9|            {
 4501|      9|              rc = merge_sigs (onode, node, n_sigs);
 4502|      9|              if (rc )
  ------------------
  |  Branch (4502:19): [True: 0, False: 9]
  ------------------
 4503|      0|                return rc;
 4504|      9|	    }
 4505|      9|	}
 4506|     60|    }
 4507|       |
 4508|       |  /* 4th: add new user-ids */
 4509|     37|  for (node=keyblock->next; node; node=node->next)
  ------------------
  |  Branch (4509:29): [True: 28, False: 9]
  ------------------
 4510|     28|    {
 4511|     28|      if (node->pkt->pkttype == PKT_USER_ID)
  ------------------
  |  Branch (4511:11): [True: 9, False: 19]
  ------------------
 4512|      9|        {
 4513|       |          /* do we have this in the original keyblock */
 4514|     21|          for (onode=keyblock_orig->next; onode; onode=onode->next )
  ------------------
  |  Branch (4514:43): [True: 21, False: 0]
  ------------------
 4515|     21|            if (onode->pkt->pkttype == PKT_USER_ID
  ------------------
  |  Branch (4515:17): [True: 9, False: 12]
  ------------------
 4516|     21|                && !cmp_user_ids( onode->pkt->pkt.user_id,
  ------------------
  |  Branch (4516:20): [True: 9, False: 0]
  ------------------
 4517|      9|                                  node->pkt->pkt.user_id ) )
 4518|      9|              break;
 4519|      9|          if (!onode ) /* this is a new user id: append */
  ------------------
  |  Branch (4519:15): [True: 0, False: 9]
  ------------------
 4520|      0|            {
 4521|      0|              rc = append_new_uid (options, keyblock_orig, node,
 4522|      0|                                   curtime, origin, url, n_sigs);
 4523|      0|              if (rc )
  ------------------
  |  Branch (4523:19): [True: 0, False: 0]
  ------------------
 4524|      0|                return rc;
 4525|      0|              ++*n_uids;
 4526|      0|	    }
 4527|      9|	}
 4528|     28|    }
 4529|       |
 4530|       |  /* 5th: add new subkeys */
 4531|     37|  for (node=keyblock->next; node; node=node->next)
  ------------------
  |  Branch (4531:29): [True: 28, False: 9]
  ------------------
 4532|     28|    {
 4533|     28|      onode = NULL;
 4534|     28|      if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY)
  ------------------
  |  Branch (4534:11): [True: 2, False: 26]
  ------------------
 4535|      2|        {
 4536|       |          /* do we have this in the original keyblock? */
 4537|      7|          for(onode=keyblock_orig->next; onode; onode=onode->next)
  ------------------
  |  Branch (4537:42): [True: 7, False: 0]
  ------------------
 4538|      7|            if (onode->pkt->pkttype == PKT_PUBLIC_SUBKEY
  ------------------
  |  Branch (4538:17): [True: 2, False: 5]
  ------------------
 4539|      7|                && !cmp_public_keys( onode->pkt->pkt.public_key,
  ------------------
  |  Branch (4539:20): [True: 2, False: 0]
  ------------------
 4540|      2|                                     node->pkt->pkt.public_key))
 4541|      2|              break;
 4542|      2|          if (!onode ) /* This is a new subkey: append.  */
  ------------------
  |  Branch (4542:15): [True: 0, False: 2]
  ------------------
 4543|      0|            {
 4544|      0|              rc = append_key (keyblock_orig, node, n_sigs);
 4545|      0|              if (rc)
  ------------------
  |  Branch (4545:19): [True: 0, False: 0]
  ------------------
 4546|      0|                return rc;
 4547|      0|              ++*n_subk;
 4548|      0|	    }
 4549|      2|	}
 4550|     26|      else if (node->pkt->pkttype == PKT_SECRET_SUBKEY)
  ------------------
  |  Branch (4550:16): [True: 0, False: 26]
  ------------------
 4551|      0|        {
 4552|       |          /* do we have this in the original keyblock? */
 4553|      0|          for (onode=keyblock_orig->next; onode; onode=onode->next )
  ------------------
  |  Branch (4553:43): [True: 0, False: 0]
  ------------------
 4554|      0|            if (onode->pkt->pkttype == PKT_SECRET_SUBKEY
  ------------------
  |  Branch (4554:17): [True: 0, False: 0]
  ------------------
 4555|      0|                && !cmp_public_keys (onode->pkt->pkt.public_key,
  ------------------
  |  Branch (4555:20): [True: 0, False: 0]
  ------------------
 4556|      0|                                     node->pkt->pkt.public_key) )
 4557|      0|              break;
 4558|      0|          if (!onode ) /* This is a new subkey: append.  */
  ------------------
  |  Branch (4558:15): [True: 0, False: 0]
  ------------------
 4559|      0|            {
 4560|      0|              rc = append_key (keyblock_orig, node, n_sigs);
 4561|      0|              if (rc )
  ------------------
  |  Branch (4561:19): [True: 0, False: 0]
  ------------------
 4562|      0|                return rc;
 4563|      0|              ++*n_subk;
 4564|      0|	    }
 4565|      0|	}
 4566|     28|    }
 4567|       |
 4568|       |  /* 6th: merge subkey certificates */
 4569|     73|  for (onode=keyblock_orig->next; onode; onode=onode->next)
  ------------------
  |  Branch (4569:35): [True: 64, False: 9]
  ------------------
 4570|     64|    {
 4571|     64|      if (!(onode->flag & NODE_FLAG_A)
  ------------------
  |  |   77|     64|#define NODE_FLAG_A  8
  ------------------
  |  Branch (4571:11): [True: 49, False: 15]
  ------------------
 4572|     64|          && (onode->pkt->pkttype == PKT_PUBLIC_SUBKEY
  ------------------
  |  Branch (4572:15): [True: 2, False: 47]
  ------------------
 4573|     49|              || onode->pkt->pkttype == PKT_SECRET_SUBKEY))
  ------------------
  |  Branch (4573:18): [True: 0, False: 47]
  ------------------
 4574|      2|        {
 4575|       |          /* find the subkey in the imported keyblock */
 4576|      2|          for(node=keyblock->next; node; node=node->next)
  ------------------
  |  Branch (4576:36): [True: 2, False: 0]
  ------------------
 4577|      2|            {
 4578|      2|              if ((node->pkt->pkttype == PKT_PUBLIC_SUBKEY
  ------------------
  |  Branch (4578:20): [True: 2, False: 0]
  ------------------
 4579|      2|                   || node->pkt->pkttype == PKT_SECRET_SUBKEY)
  ------------------
  |  Branch (4579:23): [True: 0, False: 0]
  ------------------
 4580|      2|                  && !cmp_public_keys( onode->pkt->pkt.public_key,
  ------------------
  |  Branch (4580:22): [True: 2, False: 0]
  ------------------
 4581|      2|                                       node->pkt->pkt.public_key ) )
 4582|      2|                break;
 4583|      2|	    }
 4584|      2|          if (node) /* Found: merge.  */
  ------------------
  |  Branch (4584:15): [True: 2, False: 0]
  ------------------
 4585|      2|            {
 4586|      2|              rc = merge_keysigs( onode, node, n_sigs);
 4587|      2|              if (rc )
  ------------------
  |  Branch (4587:19): [True: 0, False: 2]
  ------------------
 4588|      0|                return rc;
 4589|      2|	    }
 4590|      2|	}
 4591|     64|    }
 4592|       |
 4593|      9|  return 0;
 4594|      9|}
import.c:merge_sigs:
 4669|      9|{
 4670|      9|  kbnode_t n, n2;
 4671|      9|  int found = 0;
 4672|       |
 4673|      9|  log_assert (dst->pkt->pkttype == PKT_USER_ID);
 4674|      0|  log_assert (src->pkt->pkttype == PKT_USER_ID);
 4675|       |
 4676|     20|  for (n=src->next; n && n->pkt->pkttype != PKT_USER_ID; n = n->next)
  ------------------
  |  Branch (4676:21): [True: 11, False: 9]
  |  Branch (4676:26): [True: 11, False: 0]
  ------------------
 4677|     11|    {
 4678|     11|      if (n->pkt->pkttype != PKT_SIGNATURE )
  ------------------
  |  Branch (4678:11): [True: 0, False: 11]
  ------------------
 4679|      0|        continue;
 4680|     11|      if (IS_SUBKEY_SIG (n->pkt->pkt.signature)
  ------------------
  |  |   43|     22|#define IS_SUBKEY_SIG(s) ((s)->sig_class == 0x18)
  |  |  ------------------
  |  |  |  Branch (43:26): [True: 0, False: 11]
  |  |  ------------------
  ------------------
 4681|     11|          || IS_SUBKEY_REV (n->pkt->pkt.signature) )
  ------------------
  |  |   47|     11|#define IS_SUBKEY_REV(s) ((s)->sig_class == 0x28)
  |  |  ------------------
  |  |  |  Branch (47:26): [True: 2, False: 9]
  |  |  ------------------
  ------------------
 4682|      2|        continue; /* skip signatures which are only valid on subkeys */
 4683|       |
 4684|      9|      found = 0;
 4685|     37|      for (n2=dst->next; n2 && n2->pkt->pkttype != PKT_USER_ID; n2 = n2->next)
  ------------------
  |  Branch (4685:26): [True: 30, False: 7]
  |  Branch (4685:32): [True: 30, False: 0]
  ------------------
 4686|     30|        if (!cmp_signatures(n->pkt->pkt.signature,n2->pkt->pkt.signature))
  ------------------
  |  Branch (4686:13): [True: 2, False: 28]
  ------------------
 4687|      2|          {
 4688|      2|            found++;
 4689|      2|            break;
 4690|      2|          }
 4691|      9|      if (!found )
  ------------------
  |  Branch (4691:11): [True: 7, False: 2]
  ------------------
 4692|      7|        {
 4693|       |          /* This signature is new or newer, append N to DST.
 4694|       |           * We add a clone to the original keyblock, because this
 4695|       |           * one is released first */
 4696|      7|          n2 = clone_kbnode(n);
 4697|      7|          insert_kbnode( dst, n2, PKT_SIGNATURE );
 4698|      7|          n2->flag |= NODE_FLAG_A;
  ------------------
  |  |   77|      7|#define NODE_FLAG_A  8
  ------------------
 4699|      7|          n->flag |= NODE_FLAG_A;
  ------------------
  |  |   77|      7|#define NODE_FLAG_A  8
  ------------------
 4700|      7|          ++*n_sigs;
 4701|      7|	}
 4702|      9|    }
 4703|       |
 4704|      9|  return 0;
 4705|      9|}
import.c:merge_keysigs:
 4713|      2|{
 4714|      2|  kbnode_t n, n2;
 4715|      2|  int found = 0;
 4716|       |
 4717|      2|  log_assert (dst->pkt->pkttype == PKT_PUBLIC_SUBKEY
 4718|      2|              || dst->pkt->pkttype == PKT_SECRET_SUBKEY);
 4719|       |
 4720|     14|  for (n=src->next; n ; n = n->next)
  ------------------
  |  Branch (4720:21): [True: 12, False: 2]
  ------------------
 4721|     12|    {
 4722|     12|      if (n->pkt->pkttype == PKT_PUBLIC_SUBKEY
  ------------------
  |  Branch (4722:11): [True: 0, False: 12]
  ------------------
 4723|     12|          || n->pkt->pkttype == PKT_PUBLIC_KEY )
  ------------------
  |  Branch (4723:14): [True: 0, False: 12]
  ------------------
 4724|      0|        break;
 4725|     12|      if (n->pkt->pkttype != PKT_SIGNATURE )
  ------------------
  |  Branch (4725:11): [True: 2, False: 10]
  ------------------
 4726|      2|        continue;
 4727|       |
 4728|     10|      found = 0;
 4729|     58|      for (n2=dst->next; n2; n2 = n2->next)
  ------------------
  |  Branch (4729:26): [True: 54, False: 4]
  ------------------
 4730|     54|        {
 4731|     54|          if (n2->pkt->pkttype == PKT_PUBLIC_SUBKEY
  ------------------
  |  Branch (4731:15): [True: 0, False: 54]
  ------------------
 4732|     54|              || n2->pkt->pkttype == PKT_PUBLIC_KEY )
  ------------------
  |  Branch (4732:18): [True: 0, False: 54]
  ------------------
 4733|      0|            break;
 4734|     54|          if (n2->pkt->pkttype == PKT_SIGNATURE
  ------------------
  |  Branch (4734:15): [True: 46, False: 8]
  ------------------
 4735|     54|              && (n->pkt->pkt.signature->keyid[0]
  ------------------
  |  Branch (4735:18): [True: 18, False: 28]
  ------------------
 4736|     46|                  == n2->pkt->pkt.signature->keyid[0])
 4737|     54|              && (n->pkt->pkt.signature->keyid[1]
  ------------------
  |  Branch (4737:18): [True: 18, False: 0]
  ------------------
 4738|     18|                  == n2->pkt->pkt.signature->keyid[1])
 4739|     54|              && (n->pkt->pkt.signature->timestamp
  ------------------
  |  Branch (4739:18): [True: 16, False: 2]
  ------------------
 4740|     18|                  <= n2->pkt->pkt.signature->timestamp)
 4741|     54|              && (n->pkt->pkt.signature->sig_class
  ------------------
  |  Branch (4741:18): [True: 6, False: 10]
  ------------------
 4742|     16|                  == n2->pkt->pkt.signature->sig_class))
 4743|      6|            {
 4744|      6|              found++;
 4745|      6|              break;
 4746|      6|	    }
 4747|     54|	}
 4748|     10|      if (!found )
  ------------------
  |  Branch (4748:11): [True: 4, False: 6]
  ------------------
 4749|      4|        {
 4750|       |          /* This signature is new or newer, append N to DST.
 4751|       |           * We add a clone to the original keyblock, because this
 4752|       |           * one is released first */
 4753|      4|          n2 = clone_kbnode(n);
 4754|      4|          insert_kbnode( dst, n2, PKT_SIGNATURE );
 4755|      4|          n2->flag |= NODE_FLAG_A;
  ------------------
  |  |   77|      4|#define NODE_FLAG_A  8
  ------------------
 4756|      4|          n->flag |= NODE_FLAG_A;
  ------------------
  |  |   77|      4|#define NODE_FLAG_A  8
  ------------------
 4757|      4|          ++*n_sigs;
 4758|      4|	}
 4759|     10|    }
 4760|       |
 4761|      2|  return 0;
 4762|      2|}
import.c:update_key_origin:
 1852|      9|{
 1853|      9|  PKT_public_key *pk;
 1854|       |
 1855|      9|  log_assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY);
 1856|      0|  pk = keyblock->pkt->pkt.public_key;
 1857|       |
 1858|      9|  if (pk->keyupdate > curtime)
  ------------------
  |  Branch (1858:7): [True: 0, False: 9]
  ------------------
 1859|      0|    ; /* Don't do it for a time warp.  */
 1860|      9|  else if (origin == KEYORG_WKD || origin == KEYORG_DANE)
  ------------------
  |  Branch (1860:12): [True: 0, False: 9]
  |  Branch (1860:36): [True: 0, False: 9]
  ------------------
 1861|      0|    {
 1862|       |      /* We only update the origin info if they either have never been
 1863|       |       * set or are the origin was the same as the new one.  If this
 1864|       |       * is WKD we also update the UID to show from which user id this
 1865|       |       * was updated.  */
 1866|      0|      if (!pk->keyorg || pk->keyorg == KEYORG_WKD || pk->keyorg == KEYORG_DANE)
  ------------------
  |  Branch (1866:11): [True: 0, False: 0]
  |  Branch (1866:26): [True: 0, False: 0]
  |  Branch (1866:54): [True: 0, False: 0]
  ------------------
 1867|      0|        {
 1868|      0|          pk->keyorg = origin;
 1869|      0|          pk->keyupdate = curtime;
 1870|      0|          xfree (pk->updateurl);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1871|      0|          pk->updateurl = NULL;
 1872|      0|          if (origin == KEYORG_WKD && url)
  ------------------
  |  Branch (1872:15): [True: 0, False: 0]
  |  Branch (1872:39): [True: 0, False: 0]
  ------------------
 1873|      0|            {
 1874|      0|              pk->updateurl = xtrystrdup (url);
  ------------------
  |  |  103|      0|#define xtrystrdup(a)    gcry_strdup ((a))
  ------------------
 1875|      0|              if (!pk->updateurl)
  ------------------
  |  Branch (1875:19): [True: 0, False: 0]
  ------------------
 1876|      0|                return gpg_error_from_syserror ();
 1877|      0|            }
 1878|      0|        }
 1879|      0|    }
 1880|      9|  else if (origin == KEYORG_KS)
  ------------------
  |  Branch (1880:12): [True: 0, False: 9]
  ------------------
 1881|      0|    {
 1882|       |      /* All updates from a keyserver are considered to have the
 1883|       |       * freshed key.  Thus we always set the new key origin.  */
 1884|      0|      pk->keyorg = origin;
 1885|      0|      pk->keyupdate = curtime;
 1886|      0|      xfree (pk->updateurl);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1887|      0|      pk->updateurl = NULL;
 1888|      0|      if (url)
  ------------------
  |  Branch (1888:11): [True: 0, False: 0]
  ------------------
 1889|      0|        {
 1890|      0|          pk->updateurl = xtrystrdup (url);
  ------------------
  |  |  103|      0|#define xtrystrdup(a)    gcry_strdup ((a))
  ------------------
 1891|      0|          if (!pk->updateurl)
  ------------------
  |  Branch (1891:15): [True: 0, False: 0]
  ------------------
 1892|      0|            return gpg_error_from_syserror ();
 1893|      0|        }
 1894|      0|    }
 1895|      9|  else if (origin == KEYORG_FILE)
  ------------------
  |  Branch (1895:12): [True: 0, False: 9]
  ------------------
 1896|      0|    {
 1897|       |      /* Updates from a file are considered to be fresh.  */
 1898|      0|      pk->keyorg = origin;
 1899|      0|      pk->keyupdate = curtime;
 1900|      0|      xfree (pk->updateurl);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1901|      0|      pk->updateurl = NULL;
 1902|      0|    }
 1903|      9|  else if (origin == KEYORG_URL)
  ------------------
  |  Branch (1903:12): [True: 0, False: 9]
  ------------------
 1904|      0|    {
 1905|       |      /* Updates from a URL are considered to be fresh.  */
 1906|      0|      pk->keyorg = origin;
 1907|      0|      pk->keyupdate = curtime;
 1908|      0|      xfree (pk->updateurl);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1909|      0|      pk->updateurl = NULL;
 1910|      0|      if (url)
  ------------------
  |  Branch (1910:11): [True: 0, False: 0]
  ------------------
 1911|      0|        {
 1912|      0|          pk->updateurl = xtrystrdup (url);
  ------------------
  |  |  103|      0|#define xtrystrdup(a)    gcry_strdup ((a))
  ------------------
 1913|      0|          if (!pk->updateurl)
  ------------------
  |  Branch (1913:15): [True: 0, False: 0]
  ------------------
 1914|      0|            return gpg_error_from_syserror ();
 1915|      0|        }
 1916|      0|    }
 1917|       |
 1918|      9|  return 0;
 1919|      9|}
import.c:revocation_present:
 4309|     11|{
 4310|     11|  kbnode_t onode, inode;
 4311|     11|  PKT_public_key *pk = keyblock->pkt->pkt.public_key;
 4312|       |
 4313|     31|  for(onode=keyblock->next;onode;onode=onode->next)
  ------------------
  |  Branch (4313:28): [True: 31, False: 0]
  ------------------
 4314|     31|    {
 4315|       |      /* If we reach user IDs, we're done. */
 4316|     31|      if(onode->pkt->pkttype==PKT_USER_ID)
  ------------------
  |  Branch (4316:10): [True: 11, False: 20]
  ------------------
 4317|     11|	break;
 4318|       |
 4319|     20|      if (onode->pkt->pkttype == PKT_SIGNATURE
  ------------------
  |  Branch (4319:11): [True: 17, False: 3]
  ------------------
 4320|     20|          && IS_KEY_SIG (onode->pkt->pkt.signature)
  ------------------
  |  |   40|     37|#define IS_KEY_SIG(s)    ((s)->sig_class == 0x1f)
  |  |  ------------------
  |  |  |  Branch (40:26): [True: 10, False: 7]
  |  |  ------------------
  ------------------
 4321|     20|          && onode->pkt->pkt.signature->revkey)
  ------------------
  |  Branch (4321:14): [True: 0, False: 10]
  ------------------
 4322|      0|	{
 4323|      0|	  int idx;
 4324|      0|	  PKT_signature *sig=onode->pkt->pkt.signature;
 4325|       |
 4326|      0|	  for(idx=0;idx<sig->numrevkeys;idx++)
  ------------------
  |  Branch (4326:14): [True: 0, False: 0]
  ------------------
 4327|      0|	    {
 4328|      0|	      u32 keyid[2];
 4329|       |
 4330|      0|	      keyid_from_fingerprint (ctrl, sig->revkey[idx].fpr,
 4331|      0|                                      sig->revkey[idx].fprlen, keyid);
 4332|       |
 4333|      0|	      for(inode=keyblock->next;inode;inode=inode->next)
  ------------------
  |  Branch (4333:33): [True: 0, False: 0]
  ------------------
 4334|      0|		{
 4335|       |		  /* If we reach user IDs, we're done. */
 4336|      0|		  if(inode->pkt->pkttype==PKT_USER_ID)
  ------------------
  |  Branch (4336:8): [True: 0, False: 0]
  ------------------
 4337|      0|		    break;
 4338|       |
 4339|      0|		  if (inode->pkt->pkttype == PKT_SIGNATURE
  ------------------
  |  Branch (4339:9): [True: 0, False: 0]
  ------------------
 4340|      0|                      && IS_KEY_REV (inode->pkt->pkt.signature)
  ------------------
  |  |   45|      0|#define IS_KEY_REV(s)    ((s)->sig_class == 0x20)
  |  |  ------------------
  |  |  |  Branch (45:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 4341|      0|                      && inode->pkt->pkt.signature->keyid[0]==keyid[0]
  ------------------
  |  Branch (4341:26): [True: 0, False: 0]
  ------------------
 4342|      0|                      && inode->pkt->pkt.signature->keyid[1]==keyid[1])
  ------------------
  |  Branch (4342:26): [True: 0, False: 0]
  ------------------
 4343|      0|		    {
 4344|       |		      /* Okay, we have a revocation key, and a
 4345|       |                       * revocation issued by it.  Do we have the key
 4346|       |                       * itself?  */
 4347|      0|                      gpg_error_t err;
 4348|       |
 4349|      0|		      err = get_pubkey_byfprint_fast (ctrl, NULL,
 4350|      0|                                                      sig->revkey[idx].fpr,
 4351|      0|                                                      sig->revkey[idx].fprlen);
 4352|      0|		      if (gpg_err_code (err) == GPG_ERR_NO_PUBKEY
  ------------------
  |  Branch (4352:13): [True: 0, False: 0]
  ------------------
 4353|      0|                          || gpg_err_code (err) == GPG_ERR_UNUSABLE_PUBKEY)
  ------------------
  |  Branch (4353:30): [True: 0, False: 0]
  ------------------
 4354|      0|			{
 4355|      0|			  char *tempkeystr = xstrdup (keystr_from_pk (pk));
  ------------------
  |  |  112|      0|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
 4356|       |
 4357|       |			  /* No, so try and get it */
 4358|      0|			  if ((opt.keyserver_options.options
  ------------------
  |  Branch (4358:10): [True: 0, False: 0]
  ------------------
 4359|      0|                               & KEYSERVER_AUTO_KEY_RETRIEVE)
  ------------------
  |  |  443|      0|#define KEYSERVER_AUTO_KEY_RETRIEVE      (1<<3)
  ------------------
 4360|      0|                              && keyserver_any_configured (ctrl))
  ------------------
  |  Branch (4360:34): [True: 0, False: 0]
  ------------------
 4361|      0|			    {
 4362|      0|			      log_info(_("WARNING: key %s may be revoked:"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 4363|      0|					 " fetching revocation key %s\n"),
 4364|      0|				       tempkeystr,keystr(keyid));
 4365|      0|			      keyserver_import_fprint (ctrl,
 4366|      0|                                                       sig->revkey[idx].fpr,
 4367|      0|                                                       sig->revkey[idx].fprlen,
 4368|      0|                                                       opt.keyserver, 0);
 4369|       |
 4370|       |			      /* Do we have it now? */
 4371|      0|			      err = get_pubkey_byfprint_fast (ctrl, NULL,
 4372|      0|						     sig->revkey[idx].fpr,
 4373|      0|                                                     sig->revkey[idx].fprlen);
 4374|      0|			    }
 4375|       |
 4376|      0|			  if (gpg_err_code (err) == GPG_ERR_NO_PUBKEY
  ------------------
  |  Branch (4376:10): [True: 0, False: 0]
  ------------------
 4377|      0|                              || gpg_err_code (err) == GPG_ERR_UNUSABLE_PUBKEY)
  ------------------
  |  Branch (4377:34): [True: 0, False: 0]
  ------------------
 4378|      0|			    log_info(_("WARNING: key %s may be revoked:"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 4379|      0|				       " revocation key %s not present.\n"),
 4380|      0|				     tempkeystr,keystr(keyid));
 4381|       |
 4382|      0|			  xfree(tempkeystr);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 4383|      0|			}
 4384|      0|		    }
 4385|      0|		}
 4386|      0|	    }
 4387|      0|	}
 4388|     20|    }
 4389|     11|}
import.c:check_prefs:
 1307|     11|{
 1308|     11|  kbnode_t node;
 1309|     11|  PKT_public_key *pk;
 1310|     11|  int problem=0;
 1311|       |
 1312|     11|  merge_keys_and_selfsig (ctrl, keyblock);
 1313|     11|  pk=keyblock->pkt->pkt.public_key;
 1314|       |
 1315|     95|  for(node=keyblock;node;node=node->next)
  ------------------
  |  Branch (1315:21): [True: 84, False: 11]
  ------------------
 1316|     84|    {
 1317|     84|      if(node->pkt->pkttype==PKT_USER_ID
  ------------------
  |  Branch (1317:10): [True: 11, False: 73]
  ------------------
 1318|     84|	 && node->pkt->pkt.user_id->created
  ------------------
  |  Branch (1318:6): [True: 0, False: 11]
  ------------------
 1319|     84|	 && node->pkt->pkt.user_id->prefs)
  ------------------
  |  Branch (1319:6): [True: 0, False: 0]
  ------------------
 1320|      0|	{
 1321|      0|	  PKT_user_id *uid = node->pkt->pkt.user_id;
 1322|      0|	  prefitem_t *prefs = uid->prefs;
 1323|      0|	  char *user = utf8_to_native(uid->name,strlen(uid->name),0);
 1324|       |
 1325|      0|	  for(;prefs->type;prefs++)
  ------------------
  |  Branch (1325:9): [True: 0, False: 0]
  ------------------
 1326|      0|	    {
 1327|      0|	      char num[10]; /* prefs->value is a byte, so we're over
 1328|       |			       safe here */
 1329|       |
 1330|      0|	      sprintf(num,"%u",prefs->value);
 1331|       |
 1332|      0|	      if(prefs->type==PREFTYPE_SYM)
  ------------------
  |  Branch (1332:11): [True: 0, False: 0]
  ------------------
 1333|      0|		{
 1334|      0|		  if (openpgp_cipher_test_algo (prefs->value))
  ------------------
  |  Branch (1334:9): [True: 0, False: 0]
  ------------------
 1335|      0|		    {
 1336|      0|		      const char *algo =
 1337|      0|                        (openpgp_cipher_test_algo (prefs->value)
  ------------------
  |  Branch (1337:26): [True: 0, False: 0]
  ------------------
 1338|      0|                         ? num
 1339|      0|                         : openpgp_cipher_algo_name (prefs->value));
 1340|      0|		      if(!problem)
  ------------------
  |  Branch (1340:12): [True: 0, False: 0]
  ------------------
 1341|      0|			check_prefs_warning(pk);
 1342|      0|		      log_info(_("         \"%s\": preference for cipher"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1343|      0|				 " algorithm %s\n"), user, algo);
 1344|      0|		      problem=1;
 1345|      0|		    }
 1346|      0|		}
 1347|      0|	      else if(prefs->type==PREFTYPE_AEAD)
  ------------------
  |  Branch (1347:16): [True: 0, False: 0]
  ------------------
 1348|      0|		{
 1349|      0|		  if (openpgp_aead_test_algo (prefs->value))
  ------------------
  |  Branch (1349:9): [True: 0, False: 0]
  ------------------
 1350|      0|		    {
 1351|       |                      /* FIXME: The test below is wrong.  We should
 1352|       |                       * check if ...algo_name yields a "?" and
 1353|       |                       * only in that case use NUM.  */
 1354|      0|		      const char *algo =
 1355|      0|                        (openpgp_aead_test_algo (prefs->value)
  ------------------
  |  Branch (1355:26): [True: 0, False: 0]
  ------------------
 1356|      0|                         ? num
 1357|      0|                         : openpgp_aead_algo_name (prefs->value));
 1358|      0|		      if(!problem)
  ------------------
  |  Branch (1358:12): [True: 0, False: 0]
  ------------------
 1359|      0|			check_prefs_warning(pk);
 1360|      0|		      log_info(_("         \"%s\": preference for AEAD"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1361|      0|				 " algorithm %s\n"), user, algo);
 1362|      0|		      problem=1;
 1363|      0|		    }
 1364|      0|		}
 1365|      0|	      else if(prefs->type==PREFTYPE_HASH)
  ------------------
  |  Branch (1365:16): [True: 0, False: 0]
  ------------------
 1366|      0|		{
 1367|      0|		  if(openpgp_md_test_algo(prefs->value))
  ------------------
  |  Branch (1367:8): [True: 0, False: 0]
  ------------------
 1368|      0|		    {
 1369|      0|		      const char *algo =
 1370|      0|                        (gcry_md_test_algo (prefs->value)
 1371|      0|                         ? num
 1372|      0|                         : gcry_md_algo_name (prefs->value));
 1373|      0|		      if(!problem)
  ------------------
  |  Branch (1373:12): [True: 0, False: 0]
  ------------------
 1374|      0|			check_prefs_warning(pk);
 1375|      0|		      log_info(_("         \"%s\": preference for digest"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1376|      0|				 " algorithm %s\n"), user, algo);
 1377|      0|		      problem=1;
 1378|      0|		    }
 1379|      0|		}
 1380|      0|	      else if(prefs->type==PREFTYPE_ZIP)
  ------------------
  |  Branch (1380:16): [True: 0, False: 0]
  ------------------
 1381|      0|		{
 1382|      0|		  if(check_compress_algo (prefs->value))
  ------------------
  |  Branch (1382:8): [True: 0, False: 0]
  ------------------
 1383|      0|		    {
 1384|      0|		      const char *algo=compress_algo_to_string(prefs->value);
 1385|      0|		      if(!problem)
  ------------------
  |  Branch (1385:12): [True: 0, False: 0]
  ------------------
 1386|      0|			check_prefs_warning(pk);
 1387|      0|		      log_info(_("         \"%s\": preference for compression"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1388|      0|				 " algorithm %s\n"),user,algo?algo:num);
  ------------------
  |  Branch (1388:30): [True: 0, False: 0]
  ------------------
 1389|      0|		      problem=1;
 1390|      0|		    }
 1391|      0|		}
 1392|      0|	    }
 1393|       |
 1394|      0|	  xfree(user);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1395|      0|	}
 1396|     84|    }
 1397|       |
 1398|     11|  if(problem)
  ------------------
  |  Branch (1398:6): [True: 0, False: 11]
  ------------------
 1399|      0|    {
 1400|      0|      log_info(_("it is strongly suggested that you update"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1401|      0|		 " your preferences and\n"));
 1402|      0|      log_info(_("re-distribute this key to avoid potential algorithm"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1403|      0|		 " mismatch problems\n"));
 1404|       |
 1405|      0|      if(!opt.batch)
  ------------------
  |  Branch (1405:10): [True: 0, False: 0]
  ------------------
 1406|      0|	{
 1407|      0|	  strlist_t sl = NULL;
 1408|      0|          strlist_t locusr = NULL;
 1409|      0|	  size_t fprlen=0;
 1410|      0|	  byte fpr[MAX_FINGERPRINT_LEN], *p;
 1411|      0|	  char username[(MAX_FINGERPRINT_LEN*2)+1];
 1412|      0|	  unsigned int i;
 1413|       |
 1414|      0|	  p = fingerprint_from_pk (pk,fpr,&fprlen);
 1415|      0|	  for(i=0;i<fprlen;i++,p++)
  ------------------
  |  Branch (1415:12): [True: 0, False: 0]
  ------------------
 1416|      0|	    sprintf(username+2*i,"%02X",*p);
 1417|      0|	  add_to_strlist(&locusr,username);
 1418|       |
 1419|      0|	  append_to_strlist(&sl,"updpref");
 1420|      0|	  append_to_strlist(&sl,"save");
 1421|       |
 1422|      0|	  keyedit_menu (ctrl, username, locusr, sl, 1, 1 );
 1423|      0|	  free_strlist(sl);
 1424|      0|	  free_strlist(locusr);
 1425|      0|	}
 1426|      0|      else if(!opt.quiet)
  ------------------
  |  Branch (1426:15): [True: 0, False: 0]
  ------------------
 1427|      0|	log_info(_("you can update your preferences with:"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1428|      0|		   " gpg --edit-key %s updpref save\n"),keystr_from_pk(pk));
 1429|      0|    }
 1430|     11|}
import.c:import_secret_one:
 3091|    268|{
 3092|    268|  PKT_public_key *pk;
 3093|    268|  struct seckey_info *ski;
 3094|    268|  kbnode_t node, uidnode;
 3095|    268|  u32 keyid[2];
 3096|    268|  gpg_error_t err = 0;
 3097|    268|  int nr_prev;
 3098|    268|  kbnode_t pub_keyblock;
 3099|    268|  kbnode_t attic = NULL;
 3100|    268|  byte fpr[MAX_FINGERPRINT_LEN];
 3101|    268|  size_t fprlen;
 3102|    268|  char pkstrbuf[PUBKEY_STRING_SIZE];
 3103|       |
 3104|       |  /* Get the key and print some info about it */
 3105|    268|  node = find_kbnode (keyblock, PKT_SECRET_KEY);
 3106|    268|  if (!node)
  ------------------
  |  Branch (3106:7): [True: 0, False: 268]
  ------------------
 3107|      0|    BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 3108|       |
 3109|    268|  pk = node->pkt->pkt.public_key;
 3110|       |
 3111|    268|  fingerprint_from_pk (pk, fpr, &fprlen);
 3112|    268|  keyid_from_pk (pk, keyid);
 3113|    268|  uidnode = find_next_kbnode (keyblock, PKT_USER_ID);
 3114|       |
 3115|    268|  if (screener && screener (keyblock, screener_arg))
  ------------------
  |  Branch (3115:7): [True: 0, False: 268]
  |  Branch (3115:19): [True: 0, False: 0]
  ------------------
 3116|      0|    {
 3117|      0|      log_error (_("secret key %s: %s\n"), keystr_from_pk (pk),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3118|      0|                 _("rejected by import screener"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3119|      0|      release_kbnode (keyblock);
 3120|      0|      return 0;
 3121|      0|    }
 3122|       |
 3123|    268|  if (opt.verbose && !for_migration)
  ------------------
  |  Branch (3123:7): [True: 0, False: 268]
  |  Branch (3123:22): [True: 0, False: 0]
  ------------------
 3124|      0|    {
 3125|      0|      log_info ("sec  %s/%s %s  ",
 3126|      0|                pubkey_string (pk, pkstrbuf, sizeof pkstrbuf),
 3127|      0|                keystr_from_pk (pk), datestr_from_pk (pk));
 3128|      0|      if (uidnode)
  ------------------
  |  Branch (3128:11): [True: 0, False: 0]
  ------------------
 3129|      0|        print_utf8_buffer (log_get_stream (), uidnode->pkt->pkt.user_id->name,
 3130|      0|                           uidnode->pkt->pkt.user_id->len);
 3131|      0|      log_printf ("\n");
 3132|      0|    }
 3133|    268|  stats->secret_read++;
 3134|       |
 3135|    268|  if ((options & IMPORT_NO_SECKEY))
  ------------------
  |  |  390|    268|#define IMPORT_NO_SECKEY                 (1<<7)
  ------------------
  |  Branch (3135:7): [True: 0, False: 268]
  ------------------
 3136|      0|    {
 3137|      0|      if (!for_migration)
  ------------------
  |  Branch (3137:11): [True: 0, False: 0]
  ------------------
 3138|      0|        log_error (_("importing secret keys not allowed\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3139|      0|      release_kbnode (keyblock);
 3140|      0|      return 0;
 3141|      0|    }
 3142|       |
 3143|    268|  if (!uidnode)
  ------------------
  |  Branch (3143:7): [True: 67, False: 201]
  ------------------
 3144|     67|    {
 3145|     67|      if (!for_migration)
  ------------------
  |  Branch (3145:11): [True: 67, False: 0]
  ------------------
 3146|     67|        log_error( _("key %s: no user ID\n"), keystr_from_pk (pk));
  ------------------
  |  |   28|     67|#  define _(a) gettext (a)
  ------------------
 3147|     67|      release_kbnode (keyblock);
 3148|     67|      return 0;
 3149|     67|    }
 3150|       |
 3151|    201|  ski = pk->seckey_info;
 3152|    201|  if (!ski)
  ------------------
  |  Branch (3152:7): [True: 29, False: 172]
  ------------------
 3153|     29|    {
 3154|       |      /* Actually an internal error.  */
 3155|     29|      log_error ("key %s: secret key info missing\n", keystr_from_pk (pk));
 3156|     29|      release_kbnode (keyblock);
 3157|     29|      return 0;
 3158|     29|    }
 3159|       |
 3160|       |  /* A quick check to not import keys with an invalid protection
 3161|       |     cipher algorithm (only checks the primary key, though).  */
 3162|    172|  if (ski->algo > 110)
  ------------------
  |  Branch (3162:7): [True: 0, False: 172]
  ------------------
 3163|      0|    {
 3164|      0|      if (!for_migration)
  ------------------
  |  Branch (3164:11): [True: 0, False: 0]
  ------------------
 3165|      0|        log_error (_("key %s: secret key with invalid cipher %d"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3166|      0|                     " - skipped\n"), keystr_from_pk (pk), ski->algo);
 3167|      0|      release_kbnode (keyblock);
 3168|      0|      return 0;
 3169|      0|    }
 3170|       |
 3171|       |#ifdef ENABLE_SELINUX_HACKS
 3172|       |  if (1)
 3173|       |    {
 3174|       |      /* We don't allow importing secret keys because that may be used
 3175|       |         to put a secret key into the keyring and the user might later
 3176|       |         be tricked into signing stuff with that key.  */
 3177|       |      log_error (_("importing secret keys not allowed\n"));
 3178|       |      release_kbnode (keyblock);
 3179|       |      return 0;
 3180|       |    }
 3181|       |#endif
 3182|       |
 3183|    172|  clear_kbnode_flags (keyblock);
 3184|       |
 3185|    172|  nr_prev = stats->skipped_new_keys;
 3186|       |
 3187|       |  /* Make a public key out of the key. */
 3188|    172|  pub_keyblock = sec_to_pub_keyblock (keyblock);
 3189|    172|  if (!pub_keyblock)
  ------------------
  |  Branch (3189:7): [True: 0, False: 172]
  ------------------
 3190|      0|    {
 3191|      0|      err = gpg_error_from_syserror ();
 3192|      0|      log_error ("key %s: failed to create public key from secret key\n",
 3193|      0|                 keystr_from_pk (pk));
 3194|      0|    }
 3195|    172|  else
 3196|    172|    {
 3197|    172|      int valid;
 3198|       |
 3199|       |      /* Note that this outputs an IMPORT_OK status message for the
 3200|       |	 public key block, and below we will output another one for
 3201|       |	 the secret keys.  FIXME?  */
 3202|    172|      import_one (ctrl, pub_keyblock, stats,
 3203|    172|		  NULL, NULL, options, 1, for_migration,
 3204|    172|                  screener, screener_arg, 0, NULL, &valid);
 3205|       |
 3206|       |      /* The secret keyblock may not have nodes which are deleted in
 3207|       |       * the public keyblock.  Otherwise we would import just the
 3208|       |       * secret key without having the public key.  That would be
 3209|       |       * surprising and clutters our private-keys-v1.d.  */
 3210|    172|      err = resync_sec_with_pub_keyblock (&keyblock, pub_keyblock, &attic);
 3211|    172|      if (err)
  ------------------
  |  Branch (3211:11): [True: 0, False: 172]
  ------------------
 3212|      0|        goto leave;
 3213|       |
 3214|    172|      if (!valid)
  ------------------
  |  Branch (3214:11): [True: 172, False: 0]
  ------------------
 3215|    172|        {
 3216|       |          /* If the block was not valid the primary key is left in the
 3217|       |           * original keyblock because we require that for the first
 3218|       |           * node.   Move it to ATTIC.  */
 3219|    172|          if (keyblock && keyblock->pkt->pkttype == PKT_SECRET_KEY)
  ------------------
  |  Branch (3219:15): [True: 172, False: 0]
  |  Branch (3219:27): [True: 172, False: 0]
  ------------------
 3220|    172|            {
 3221|    172|              node = keyblock;
 3222|    172|              keyblock = node->next;
 3223|    172|              node->next = NULL;
 3224|    172|              if (attic)
  ------------------
  |  Branch (3224:19): [True: 141, False: 31]
  ------------------
 3225|    141|                {
 3226|    141|                  node->next = attic;
 3227|    141|                  attic = node;
 3228|    141|                }
 3229|     31|              else
 3230|     31|                attic = node;
 3231|    172|            }
 3232|       |
 3233|       |          /* Try to import the secret key iff we have a public key.  */
 3234|    172|          if (attic && !(opt.dry_run || (options & IMPORT_DRY_RUN)))
  ------------------
  |  |  395|    172|#define IMPORT_DRY_RUN                   (1<<12)
  ------------------
  |  Branch (3234:15): [True: 172, False: 0]
  |  Branch (3234:26): [True: 0, False: 172]
  |  Branch (3234:41): [True: 0, False: 172]
  ------------------
 3235|    172|            err = import_matching_seckeys (ctrl, attic, fpr, fprlen,
 3236|    172|                                           stats, batch);
 3237|      0|          else
 3238|      0|            err = gpg_error (GPG_ERR_NO_SECKEY);
 3239|    172|          goto leave;
 3240|    172|        }
 3241|       |
 3242|       |      /* log_debug ("attic is:\n"); */
 3243|       |      /* dump_kbnode (attic); */
 3244|       |
 3245|       |      /* Proceed with the valid parts of PUBKEYBLOCK. */
 3246|       |
 3247|       |      /* At least we cancel the secret key import when the public key
 3248|       |	 import was skipped due to MERGE_ONLY option and a new
 3249|       |	 key.  */
 3250|      0|      if (!(opt.dry_run || (options & IMPORT_DRY_RUN))
  ------------------
  |  |  395|      0|#define IMPORT_DRY_RUN                   (1<<12)
  ------------------
  |  Branch (3250:13): [True: 0, False: 0]
  |  Branch (3250:28): [True: 0, False: 0]
  ------------------
 3251|      0|          && stats->skipped_new_keys <= nr_prev)
  ------------------
  |  Branch (3251:14): [True: 0, False: 0]
  ------------------
 3252|      0|	{
 3253|       |          /* Read the keyblock again to get the effects of a merge for
 3254|       |           * the public key.  */
 3255|      0|          err = get_pubkey_byfprint (ctrl, NULL, &node, fpr, fprlen);
 3256|      0|          if (err || !node)
  ------------------
  |  Branch (3256:15): [True: 0, False: 0]
  |  Branch (3256:22): [True: 0, False: 0]
  ------------------
 3257|      0|            log_error ("key %s: failed to re-lookup public key: %s\n",
 3258|      0|                       keystr_from_pk (pk), gpg_strerror (err));
 3259|      0|          else
 3260|      0|            {
 3261|      0|              err = do_transfer (ctrl, keyblock, pk, stats, batch, 0);
 3262|      0|              if (!err)
  ------------------
  |  Branch (3262:19): [True: 0, False: 0]
  ------------------
 3263|      0|                check_prefs (ctrl, node);
 3264|      0|              release_kbnode (node);
 3265|       |
 3266|      0|              if (!err && attic)
  ------------------
  |  Branch (3266:19): [True: 0, False: 0]
  |  Branch (3266:27): [True: 0, False: 0]
  ------------------
 3267|      0|                {
 3268|       |                  /* Try to import invalid subkeys.  This can be the
 3269|       |                   * case if the primary secret key was imported due
 3270|       |                   * to --allow-non-selfsigned-uid.  */
 3271|      0|                  err = import_matching_seckeys (ctrl, attic, fpr, fprlen,
 3272|      0|                                                 stats, batch);
 3273|      0|                }
 3274|       |
 3275|      0|            }
 3276|      0|        }
 3277|      0|    }
 3278|       |
 3279|    172| leave:
 3280|    172|  release_kbnode (keyblock);
 3281|    172|  release_kbnode (pub_keyblock);
 3282|    172|  if (r_secattic)
  ------------------
  |  Branch (3282:7): [True: 172, False: 0]
  ------------------
 3283|    172|    *r_secattic = attic;
 3284|      0|  else
 3285|      0|    release_kbnode (attic);
 3286|    172|  return err;
 3287|    172|}
import.c:sec_to_pub_keyblock:
 2830|    172|{
 2831|    172|  kbnode_t pub_keyblock = NULL;
 2832|    172|  kbnode_t ctx = NULL;
 2833|    172|  kbnode_t secnode, pubnode;
 2834|    172|  kbnode_t lastnode = NULL;
 2835|    172|  unsigned int tag = 0;
 2836|       |
 2837|       |  /* Set a tag to all nodes.  */
 2838|    657|  for (secnode = sec_keyblock; secnode; secnode = secnode->next)
  ------------------
  |  Branch (2838:32): [True: 485, False: 172]
  ------------------
 2839|    485|    secnode->tag = ++tag;
 2840|       |
 2841|       |  /* Copy.  */
 2842|    657|  while ((secnode = walk_kbnode (sec_keyblock, &ctx, 0)))
  ------------------
  |  Branch (2842:10): [True: 485, False: 172]
  ------------------
 2843|    485|    {
 2844|    485|      if (secnode->pkt->pkttype == PKT_SECRET_KEY
  ------------------
  |  Branch (2844:11): [True: 172, False: 313]
  ------------------
 2845|    485|          || secnode->pkt->pkttype == PKT_SECRET_SUBKEY)
  ------------------
  |  Branch (2845:14): [True: 141, False: 172]
  ------------------
 2846|    313|	{
 2847|       |	  /* Make a public key.  */
 2848|    313|	  PACKET *pkt;
 2849|    313|          PKT_public_key *pk;
 2850|       |
 2851|    313|	  pkt = xtrycalloc (1, sizeof *pkt);
  ------------------
  |  |   99|    313|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
 2852|    313|          pk = pkt? copy_public_key (NULL, secnode->pkt->pkt.public_key): NULL;
  ------------------
  |  Branch (2852:16): [True: 313, False: 0]
  ------------------
 2853|    313|          if (!pk)
  ------------------
  |  Branch (2853:15): [True: 0, False: 313]
  ------------------
 2854|      0|            {
 2855|      0|              xfree (pkt);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2856|      0|	      release_kbnode (pub_keyblock);
 2857|      0|              return NULL;
 2858|      0|            }
 2859|    313|	  if (secnode->pkt->pkttype == PKT_SECRET_KEY)
  ------------------
  |  Branch (2859:8): [True: 172, False: 141]
  ------------------
 2860|    172|	    pkt->pkttype = PKT_PUBLIC_KEY;
 2861|    141|	  else
 2862|    141|	    pkt->pkttype = PKT_PUBLIC_SUBKEY;
 2863|    313|	  pkt->pkt.public_key = pk;
 2864|       |
 2865|    313|	  pubnode = new_kbnode (pkt);
 2866|    313|	}
 2867|    172|      else
 2868|    172|	{
 2869|    172|	  pubnode = clone_kbnode (secnode);
 2870|    172|	}
 2871|    485|      pubnode->tag = secnode->tag;
 2872|       |
 2873|    485|      if (!pub_keyblock)
  ------------------
  |  Branch (2873:11): [True: 172, False: 313]
  ------------------
 2874|    172|        pub_keyblock = lastnode = pubnode;
 2875|    313|      else
 2876|    313|        {
 2877|    313|          lastnode->next = pubnode;
 2878|    313|          lastnode = pubnode;
 2879|    313|        }
 2880|    485|    }
 2881|       |
 2882|    172|  return pub_keyblock;
 2883|    172|}
import.c:resync_sec_with_pub_keyblock:
 2891|    172|{
 2892|    172|  kbnode_t sec_keyblock = *r_keyblock;
 2893|    172|  kbnode_t node, prevnode;
 2894|    172|  unsigned int *taglist;
 2895|    172|  unsigned int ntaglist, n;
 2896|    172|  kbnode_t attic = NULL;
 2897|    172|  kbnode_t *attic_head = &attic;
 2898|       |
 2899|       |  /* Collect all tags in an array for faster searching.  */
 2900|    344|  for (ntaglist = 0, node = pub_keyblock; node; node = node->next)
  ------------------
  |  Branch (2900:43): [True: 172, False: 172]
  ------------------
 2901|    172|    ntaglist++;
 2902|    172|  taglist = xtrycalloc (ntaglist, sizeof *taglist);
  ------------------
  |  |   99|    172|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
 2903|    172|  if (!taglist)
  ------------------
  |  Branch (2903:7): [True: 0, False: 172]
  ------------------
 2904|      0|    return gpg_error_from_syserror ();
 2905|    344|  for (ntaglist = 0, node = pub_keyblock; node; node = node->next)
  ------------------
  |  Branch (2905:43): [True: 172, False: 172]
  ------------------
 2906|    172|    taglist[ntaglist++] = node->tag;
 2907|       |
 2908|       |  /* Walks over the secret keyblock and delete all nodes which are not
 2909|       |   * in the tag list.  Those nodes have been deleted in the
 2910|       |   * pub_keyblock.  Sequential search is a bit lazy and could be
 2911|       |   * optimized by sorting and bsearch; however secret keyrings are
 2912|       |   * short and there are easier ways to DoS the import.  */
 2913|    313| again:
 2914|    939|  for (prevnode=NULL, node=sec_keyblock; node; prevnode=node, node=node->next)
  ------------------
  |  Branch (2914:42): [True: 767, False: 172]
  ------------------
 2915|    767|    {
 2916|  1.22k|      for (n=0; n < ntaglist; n++)
  ------------------
  |  Branch (2916:17): [True: 767, False: 454]
  ------------------
 2917|    767|        if (taglist[n] == node->tag)
  ------------------
  |  Branch (2917:13): [True: 313, False: 454]
  ------------------
 2918|    313|          break;
 2919|    767|      if (n == ntaglist)  /* Not in public keyblock.  */
  ------------------
  |  Branch (2919:11): [True: 454, False: 313]
  ------------------
 2920|    454|        {
 2921|    454|          if (node->pkt->pkttype == PKT_SECRET_KEY
  ------------------
  |  Branch (2921:15): [True: 0, False: 454]
  ------------------
 2922|    454|              || node->pkt->pkttype == PKT_SECRET_SUBKEY)
  ------------------
  |  Branch (2922:18): [True: 141, False: 313]
  ------------------
 2923|    141|            {
 2924|    141|              if (!prevnode)
  ------------------
  |  Branch (2924:19): [True: 0, False: 141]
  ------------------
 2925|      0|                sec_keyblock = node->next;
 2926|    141|              else
 2927|    141|                prevnode->next = node->next;
 2928|    141|              node->next = NULL;
 2929|    141|              *attic_head = node;
 2930|    141|              attic_head = &node->next;
 2931|    141|              goto again;  /* That's lame; I know.  */
 2932|    141|            }
 2933|    313|          else
 2934|    313|            delete_kbnode (node);
 2935|    454|        }
 2936|    767|    }
 2937|       |
 2938|    172|  xfree (taglist);
  ------------------
  |  |  104|    172|#define xfree(a)         gcry_free ((a))
  ------------------
 2939|       |
 2940|       |  /* Commit the as deleted marked nodes and return the possibly
 2941|       |   * modified keyblock and a list of removed secret key nodes.  */
 2942|    172|  commit_kbnode (&sec_keyblock);
 2943|    172|  *r_keyblock = sec_keyblock;
 2944|    172|  *r_removedsecs = attic;
 2945|    172|  return 0;
 2946|    313|}
import.c:chk_self_sigs:
 3659|    758|{
 3660|    758|  kbnode_t knode = NULL;   /* The node of the current subkey.  */
 3661|    758|  PKT_public_key *subpk = NULL; /* and its packet. */
 3662|    758|  kbnode_t bsnode = NULL;  /* Subkey binding signature node.  */
 3663|    758|  u32 bsdate = 0;          /* Timestamp of that node.   */
 3664|    758|  kbnode_t rsnode = NULL;  /* Subkey recocation signature node.  */
 3665|    758|  u32 rsdate = 0;          /* Timestamp of that node.  */
 3666|    758|  PKT_signature *sig;
 3667|    758|  int rc;
 3668|    758|  kbnode_t n;
 3669|       |
 3670|  3.61k|  for (n=keyblock; (n = find_next_kbnode (n, 0)); )
  ------------------
  |  Branch (3670:20): [True: 2.86k, False: 758]
  ------------------
 3671|  2.86k|    {
 3672|  2.86k|      if (n->pkt->pkttype == PKT_PUBLIC_SUBKEY)
  ------------------
  |  Branch (3672:11): [True: 144, False: 2.71k]
  ------------------
 3673|    144|	{
 3674|    144|	  knode = n;
 3675|    144|          subpk = knode->pkt->pkt.public_key;
 3676|    144|	  bsdate = 0;
 3677|    144|	  rsdate = 0;
 3678|    144|	  bsnode = NULL;
 3679|    144|	  rsnode = NULL;
 3680|    144|	  continue;
 3681|    144|	}
 3682|       |
 3683|  2.71k|      if ( n->pkt->pkttype != PKT_SIGNATURE )
  ------------------
  |  Branch (3683:12): [True: 1.25k, False: 1.46k]
  ------------------
 3684|  1.25k|        continue;
 3685|       |
 3686|  1.46k|      sig = n->pkt->pkt.signature;
 3687|  1.46k|      if ( keyid[0] != sig->keyid[0] || keyid[1] != sig->keyid[1] )
  ------------------
  |  Branch (3687:12): [True: 888, False: 574]
  |  Branch (3687:41): [True: 175, False: 399]
  ------------------
 3688|  1.06k|        {
 3689|  1.06k|          *non_self = 1;
 3690|  1.06k|          continue;
 3691|  1.06k|        }
 3692|       |
 3693|       |      /* This just caches the sigs for later use.  That way we
 3694|       |         import a fully-cached key which speeds things up. */
 3695|    399|      if (!opt.no_sig_cache)
  ------------------
  |  Branch (3695:11): [True: 399, False: 0]
  ------------------
 3696|    399|        check_key_signature (ctrl, keyblock, n, NULL);
 3697|       |
 3698|    399|      if ( IS_UID_SIG(sig) || IS_UID_REV(sig) )
  ------------------
  |  |   41|    798|#define IS_UID_SIG(s)    (((s)->sig_class & ~3) == 0x10)
  |  |  ------------------
  |  |  |  Branch (41:26): [True: 11, False: 388]
  |  |  ------------------
  ------------------
                    if ( IS_UID_SIG(sig) || IS_UID_REV(sig) )
  ------------------
  |  |   46|    388|#define IS_UID_REV(s)    ((s)->sig_class == 0x30)
  |  |  ------------------
  |  |  |  Branch (46:26): [True: 0, False: 388]
  |  |  ------------------
  ------------------
 3699|     11|        {
 3700|     11|          kbnode_t unode = find_prev_kbnode( keyblock, n, PKT_USER_ID );
 3701|     11|          if ( !unode )
  ------------------
  |  Branch (3701:16): [True: 0, False: 11]
  ------------------
 3702|      0|            {
 3703|      0|              log_error( _("key %s: no user ID for signature\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3704|      0|                         keystr(keyid));
 3705|      0|              return -1;  /* The complete keyblock is invalid.  */
 3706|      0|            }
 3707|       |
 3708|       |          /* If it hasn't been marked valid yet, keep trying.  */
 3709|     11|          if (!(unode->flag & NODE_GOOD_SELFSIG))
  ------------------
  |  |   70|     11|#define NODE_GOOD_SELFSIG  1
  ------------------
  |  Branch (3709:15): [True: 11, False: 0]
  ------------------
 3710|     11|            {
 3711|     11|              rc = check_key_signature (ctrl, keyblock, n, NULL);
 3712|     11|              if ( rc )
  ------------------
  |  Branch (3712:20): [True: 0, False: 11]
  ------------------
 3713|      0|                {
 3714|      0|                  if ( opt.verbose )
  ------------------
  |  Branch (3714:24): [True: 0, False: 0]
  ------------------
 3715|      0|                    {
 3716|      0|                      char *p = utf8_to_native
 3717|      0|                        (unode->pkt->pkt.user_id->name,
 3718|      0|                         strlen (unode->pkt->pkt.user_id->name),0);
 3719|      0|                      log_info (gpg_err_code(rc) == GPG_ERR_PUBKEY_ALGO ?
  ------------------
  |  Branch (3719:33): [True: 0, False: 0]
  ------------------
 3720|      0|                                _("key %s: unsupported public key "
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3721|      0|                                  "algorithm on user ID \"%s\"\n"):
 3722|      0|                                _("key %s: invalid self-signature "
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3723|      0|                                  "on user ID \"%s\"\n"),
 3724|      0|                                keystr (keyid),p);
 3725|      0|                      xfree (p);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 3726|      0|                    }
 3727|      0|                }
 3728|     11|              else
 3729|     11|                unode->flag |= NODE_GOOD_SELFSIG;
  ------------------
  |  |   70|     11|#define NODE_GOOD_SELFSIG  1
  ------------------
 3730|     11|            }
 3731|     11|        }
 3732|    388|      else if (IS_KEY_SIG (sig))
  ------------------
  |  |   40|    388|#define IS_KEY_SIG(s)    ((s)->sig_class == 0x1f)
  |  |  ------------------
  |  |  |  Branch (40:26): [True: 0, False: 388]
  |  |  ------------------
  ------------------
 3733|      0|        {
 3734|      0|          rc = check_key_signature (ctrl, keyblock, n, NULL);
 3735|      0|          if ( rc )
  ------------------
  |  Branch (3735:16): [True: 0, False: 0]
  ------------------
 3736|      0|            {
 3737|      0|              if (opt.verbose)
  ------------------
  |  Branch (3737:19): [True: 0, False: 0]
  ------------------
 3738|      0|                log_info (gpg_err_code (rc) == GPG_ERR_PUBKEY_ALGO ?
  ------------------
  |  Branch (3738:27): [True: 0, False: 0]
  ------------------
 3739|      0|                          _("key %s: unsupported public key algorithm\n"):
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3740|      0|                          _("key %s: invalid direct key signature\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3741|      0|                          keystr (keyid));
 3742|      0|              n->flag |= NODE_DELETION_MARK;
  ------------------
  |  |   75|      0|#define NODE_DELETION_MARK 4
  ------------------
 3743|      0|            }
 3744|      0|        }
 3745|    388|      else if ( IS_SUBKEY_SIG (sig) )
  ------------------
  |  |   43|    388|#define IS_SUBKEY_SIG(s) ((s)->sig_class == 0x18)
  |  |  ------------------
  |  |  |  Branch (43:26): [True: 3, False: 385]
  |  |  ------------------
  ------------------
 3746|      3|        {
 3747|       |          /* Note that this works based solely on the timestamps like
 3748|       |             the rest of gpg.  If the standard gets revocation
 3749|       |             targets, this may need to be revised.  */
 3750|       |
 3751|      3|          if ( !knode )
  ------------------
  |  Branch (3751:16): [True: 0, False: 3]
  ------------------
 3752|      0|            {
 3753|      0|              if (opt.verbose)
  ------------------
  |  Branch (3753:19): [True: 0, False: 0]
  ------------------
 3754|      0|                log_info (_("key %s: no subkey for key binding\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3755|      0|                          keystr (keyid));
 3756|      0|              n->flag |= NODE_DELETION_MARK;
  ------------------
  |  |   75|      0|#define NODE_DELETION_MARK 4
  ------------------
 3757|      0|            }
 3758|      3|          else
 3759|      3|            {
 3760|      3|              rc = check_key_signature (ctrl, keyblock, n, NULL);
 3761|      3|              if ( rc )
  ------------------
  |  Branch (3761:20): [True: 0, False: 3]
  ------------------
 3762|      0|                {
 3763|      0|                  if (opt.verbose)
  ------------------
  |  Branch (3763:23): [True: 0, False: 0]
  ------------------
 3764|      0|                    {
 3765|      0|                      keyid_from_pk (subpk, NULL);
 3766|      0|                      log_info (gpg_err_code (rc) == GPG_ERR_PUBKEY_ALGO ?
  ------------------
  |  Branch (3766:33): [True: 0, False: 0]
  ------------------
 3767|      0|                                _("key %s: unsupported public key"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3768|      0|                                  " algorithm\n"):
 3769|      0|                                _("key %s: invalid subkey binding\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3770|      0|                                keystr_with_sub (keyid, subpk->keyid));
 3771|      0|                    }
 3772|      0|                  n->flag |= NODE_DELETION_MARK;
  ------------------
  |  |   75|      0|#define NODE_DELETION_MARK 4
  ------------------
 3773|      0|                }
 3774|      3|              else
 3775|      3|                {
 3776|       |                  /* It's valid, so is it newer? */
 3777|      3|                  if (sig->timestamp >= bsdate)
  ------------------
  |  Branch (3777:23): [True: 3, False: 0]
  ------------------
 3778|      3|                    {
 3779|      3|                      knode->flag |= NODE_GOOD_SELFSIG; /* Subkey is valid.  */
  ------------------
  |  |   70|      3|#define NODE_GOOD_SELFSIG  1
  ------------------
 3780|      3|                      if (bsnode)
  ------------------
  |  Branch (3780:27): [True: 0, False: 3]
  ------------------
 3781|      0|                        {
 3782|       |                          /* Delete the last binding sig since this
 3783|       |                             one is newer */
 3784|      0|                          bsnode->flag |= NODE_DELETION_MARK;
  ------------------
  |  |   75|      0|#define NODE_DELETION_MARK 4
  ------------------
 3785|      0|                          if (opt.verbose)
  ------------------
  |  Branch (3785:31): [True: 0, False: 0]
  ------------------
 3786|      0|                            {
 3787|      0|                              keyid_from_pk (subpk, NULL);
 3788|      0|                              log_info (_("key %s: removed multiple subkey"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3789|      0|                                          " binding\n"),
 3790|      0|                                        keystr_with_sub (keyid, subpk->keyid));
 3791|      0|                            }
 3792|      0|                        }
 3793|       |
 3794|      3|                      bsnode = n;
 3795|      3|                      bsdate = sig->timestamp;
 3796|      3|                    }
 3797|      0|                  else
 3798|      0|                    n->flag |= NODE_DELETION_MARK; /* older */
  ------------------
  |  |   75|      0|#define NODE_DELETION_MARK 4
  ------------------
 3799|      3|                }
 3800|      3|            }
 3801|      3|        }
 3802|    385|      else if ( IS_SUBKEY_REV (sig) )
  ------------------
  |  |   47|    385|#define IS_SUBKEY_REV(s) ((s)->sig_class == 0x28)
  |  |  ------------------
  |  |  |  Branch (47:26): [True: 253, False: 132]
  |  |  ------------------
  ------------------
 3803|    253|        {
 3804|       |          /* We don't actually mark the subkey as revoked right now,
 3805|       |             so just check that the revocation sig is the most recent
 3806|       |             valid one.  Note that we don't care if the binding sig is
 3807|       |             newer than the revocation sig.  See the comment in
 3808|       |             getkey.c:merge_selfsigs_subkey for more.  */
 3809|    253|          if ( !knode )
  ------------------
  |  Branch (3809:16): [True: 253, False: 0]
  ------------------
 3810|    253|            {
 3811|    253|              if (opt.verbose)
  ------------------
  |  Branch (3811:19): [True: 0, False: 253]
  ------------------
 3812|      0|                log_info (_("key %s: no subkey for key revocation\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3813|      0|                          keystr(keyid));
 3814|    253|              n->flag |= NODE_DELETION_MARK;
  ------------------
  |  |   75|    253|#define NODE_DELETION_MARK 4
  ------------------
 3815|    253|            }
 3816|      0|          else
 3817|      0|            {
 3818|      0|              rc = check_key_signature (ctrl, keyblock, n, NULL);
 3819|      0|              if ( rc )
  ------------------
  |  Branch (3819:20): [True: 0, False: 0]
  ------------------
 3820|      0|                {
 3821|      0|                  if(opt.verbose)
  ------------------
  |  Branch (3821:22): [True: 0, False: 0]
  ------------------
 3822|      0|                    log_info (gpg_err_code (rc) == GPG_ERR_PUBKEY_ALGO ?
  ------------------
  |  Branch (3822:31): [True: 0, False: 0]
  ------------------
 3823|      0|                              _("key %s: unsupported public"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3824|      0|                                " key algorithm\n"):
 3825|      0|                              _("key %s: invalid subkey revocation\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3826|      0|                              keystr(keyid));
 3827|      0|                  n->flag |= NODE_DELETION_MARK;
  ------------------
  |  |   75|      0|#define NODE_DELETION_MARK 4
  ------------------
 3828|      0|                }
 3829|      0|              else
 3830|      0|                {
 3831|       |                  /* It's valid, so is it newer? */
 3832|      0|                  if (sig->timestamp >= rsdate)
  ------------------
  |  Branch (3832:23): [True: 0, False: 0]
  ------------------
 3833|      0|                    {
 3834|      0|                      if (rsnode)
  ------------------
  |  Branch (3834:27): [True: 0, False: 0]
  ------------------
 3835|      0|                        {
 3836|       |                          /* Delete the last revocation sig since
 3837|       |                             this one is newer.  */
 3838|      0|                          rsnode->flag |= NODE_DELETION_MARK;
  ------------------
  |  |   75|      0|#define NODE_DELETION_MARK 4
  ------------------
 3839|      0|                          if (opt.verbose)
  ------------------
  |  Branch (3839:31): [True: 0, False: 0]
  ------------------
 3840|      0|                            log_info (_("key %s: removed multiple subkey"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3841|      0|                                        " revocation\n"),keystr(keyid));
 3842|      0|                        }
 3843|       |
 3844|      0|                      rsnode = n;
 3845|      0|                      rsdate = sig->timestamp;
 3846|      0|                    }
 3847|      0|                  else
 3848|      0|                    n->flag |= NODE_DELETION_MARK; /* older */
  ------------------
  |  |   75|      0|#define NODE_DELETION_MARK 4
  ------------------
 3849|      0|                }
 3850|      0|            }
 3851|    253|        }
 3852|    399|    }
 3853|       |
 3854|    758|  return 0;
 3855|    758|}
import.c:delete_inv_parts:
 3870|    758|{
 3871|    758|  kbnode_t node;
 3872|    758|  int nvalid=0, uid_seen=0, subkey_seen=0;
 3873|    758|  PKT_public_key *pk;
 3874|       |
 3875|  2.99k|  for (node=keyblock->next; node; node = node->next )
  ------------------
  |  Branch (3875:29): [True: 2.24k, False: 758]
  ------------------
 3876|  2.24k|    {
 3877|  2.24k|      if (node->pkt->pkttype == PKT_USER_ID)
  ------------------
  |  Branch (3877:11): [True: 1.24k, False: 994]
  ------------------
 3878|  1.24k|        {
 3879|  1.24k|          uid_seen = 1;
 3880|  1.24k|          if ((node->flag & NODE_BAD_SELFSIG)
  ------------------
  |  |   73|  1.24k|#define NODE_BAD_SELFSIG   2
  ------------------
  |  Branch (3880:15): [True: 0, False: 1.24k]
  ------------------
 3881|  1.24k|              || !(node->flag & NODE_GOOD_SELFSIG))
  ------------------
  |  |   70|  1.24k|#define NODE_GOOD_SELFSIG  1
  ------------------
  |  Branch (3881:18): [True: 1.23k, False: 11]
  ------------------
 3882|  1.23k|            {
 3883|  1.23k|              if (opt.verbose )
  ------------------
  |  Branch (3883:19): [True: 0, False: 1.23k]
  ------------------
 3884|      0|                {
 3885|      0|                  char *p=utf8_to_native(node->pkt->pkt.user_id->name,
 3886|      0|                                         node->pkt->pkt.user_id->len,0);
 3887|      0|                  log_info( _("key %s: skipped user ID \"%s\"\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3888|      0|                            keystr(keyid),p);
 3889|      0|                  xfree(p);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 3890|      0|                }
 3891|  1.23k|              delete_kbnode( node ); /* the user-id */
 3892|       |              /* and all following packets up to the next user-id */
 3893|  1.84k|              while (node->next
  ------------------
  |  Branch (3893:22): [True: 1.24k, False: 606]
  ------------------
 3894|  1.84k|                     && node->next->pkt->pkttype != PKT_USER_ID
  ------------------
  |  Branch (3894:25): [True: 753, False: 488]
  ------------------
 3895|  1.84k|                     && node->next->pkt->pkttype != PKT_PUBLIC_SUBKEY
  ------------------
  |  Branch (3895:25): [True: 612, False: 141]
  ------------------
 3896|  1.84k|                     && node->next->pkt->pkttype != PKT_SECRET_SUBKEY ){
  ------------------
  |  Branch (3896:25): [True: 612, False: 0]
  ------------------
 3897|    612|                delete_kbnode( node->next );
 3898|    612|                node = node->next;
 3899|    612|              }
 3900|  1.23k|	    }
 3901|     11|          else
 3902|     11|            nvalid++;
 3903|  1.24k|	}
 3904|    994|      else if (   node->pkt->pkttype == PKT_PUBLIC_SUBKEY
  ------------------
  |  Branch (3904:19): [True: 144, False: 850]
  ------------------
 3905|    994|               || node->pkt->pkttype == PKT_SECRET_SUBKEY )
  ------------------
  |  Branch (3905:19): [True: 8, False: 842]
  ------------------
 3906|    152|        {
 3907|    152|          if ((node->flag & NODE_BAD_SELFSIG)
  ------------------
  |  |   73|    152|#define NODE_BAD_SELFSIG   2
  ------------------
  |  Branch (3907:15): [True: 0, False: 152]
  ------------------
 3908|    152|              || !(node->flag & NODE_GOOD_SELFSIG))
  ------------------
  |  |   70|    152|#define NODE_GOOD_SELFSIG  1
  ------------------
  |  Branch (3908:18): [True: 149, False: 3]
  ------------------
 3909|    149|            {
 3910|    149|              if (opt.verbose )
  ------------------
  |  Branch (3910:19): [True: 0, False: 149]
  ------------------
 3911|      0|                {
 3912|      0|                  pk = node->pkt->pkt.public_key;
 3913|      0|                  keyid_from_pk (pk, NULL);
 3914|      0|                  log_info (_("key %s: skipped subkey\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3915|      0|                            keystr_with_sub (keyid, pk->keyid));
 3916|      0|                }
 3917|       |
 3918|    149|              delete_kbnode( node ); /* the subkey */
 3919|       |              /* and all following signature packets */
 3920|    157|              while (node->next
  ------------------
  |  Branch (3920:22): [True: 8, False: 149]
  ------------------
 3921|    157|                     && node->next->pkt->pkttype == PKT_SIGNATURE ) {
  ------------------
  |  Branch (3921:25): [True: 8, False: 0]
  ------------------
 3922|      8|                delete_kbnode( node->next );
 3923|      8|                node = node->next;
 3924|      8|              }
 3925|    149|	    }
 3926|      3|          else
 3927|      3|            subkey_seen = 1;
 3928|    152|	}
 3929|    842|      else if (node->pkt->pkttype == PKT_SIGNATURE
  ------------------
  |  Branch (3929:16): [True: 842, False: 0]
  ------------------
 3930|    842|               && openpgp_pk_test_algo (node->pkt->pkt.signature->pubkey_algo)
  ------------------
  |  Branch (3930:19): [True: 25, False: 817]
  ------------------
 3931|    842|               && node->pkt->pkt.signature->pubkey_algo != PUBKEY_ALGO_RSA )
  ------------------
  |  Branch (3931:19): [True: 25, False: 0]
  ------------------
 3932|     25|        {
 3933|     25|          delete_kbnode( node ); /* build_packet() can't handle this */
 3934|     25|        }
 3935|    817|      else if (node->pkt->pkttype == PKT_SIGNATURE
  ------------------
  |  Branch (3935:16): [True: 817, False: 0]
  ------------------
 3936|    817|               && !node->pkt->pkt.signature->flags.exportable
  ------------------
  |  Branch (3936:19): [True: 128, False: 689]
  ------------------
 3937|    817|               && !(options&IMPORT_LOCAL_SIGS)
  ------------------
  |  |  383|    128|#define IMPORT_LOCAL_SIGS                (1<<0)
  ------------------
  |  Branch (3937:19): [True: 128, False: 0]
  ------------------
 3938|    817|               && !have_secret_key_with_kid (ctrl,
  ------------------
  |  Branch (3938:19): [True: 128, False: 0]
  ------------------
 3939|    128|                                             node->pkt->pkt.signature->keyid))
 3940|    128|        {
 3941|       |          /* here we violate the rfc a bit by still allowing
 3942|       |           * to import non-exportable signature when we have the
 3943|       |           * the secret key used to create this signature - it
 3944|       |           * seems that this makes sense */
 3945|    128|          if(opt.verbose)
  ------------------
  |  Branch (3945:14): [True: 0, False: 128]
  ------------------
 3946|      0|            log_info( _("key %s: non exportable signature"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3947|      0|                        " (class 0x%02X) - skipped\n"),
 3948|      0|                      keystr(keyid), node->pkt->pkt.signature->sig_class );
 3949|    128|          delete_kbnode( node );
 3950|    128|        }
 3951|    689|      else if (node->pkt->pkttype == PKT_SIGNATURE
  ------------------
  |  Branch (3951:16): [True: 689, False: 0]
  ------------------
 3952|    689|               && IS_KEY_REV (node->pkt->pkt.signature))
  ------------------
  |  |   45|    689|#define IS_KEY_REV(s)    ((s)->sig_class == 0x20)
  |  |  ------------------
  |  |  |  Branch (45:26): [True: 341, False: 348]
  |  |  ------------------
  ------------------
 3953|    341|        {
 3954|    341|          if (uid_seen )
  ------------------
  |  Branch (3954:15): [True: 0, False: 341]
  ------------------
 3955|      0|            {
 3956|      0|              if(opt.verbose)
  ------------------
  |  Branch (3956:18): [True: 0, False: 0]
  ------------------
 3957|      0|                log_info( _("key %s: revocation certificate"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3958|      0|                            " at wrong place - skipped\n"),keystr(keyid));
 3959|      0|              if (r_otherrevsigs)
  ------------------
  |  Branch (3959:19): [True: 0, False: 0]
  ------------------
 3960|      0|                {
 3961|      0|                  PACKET *pkt;
 3962|       |
 3963|      0|                  pkt = xcalloc (1, sizeof *pkt);
  ------------------
  |  |  109|      0|#define xcalloc(a,b)     gcry_xcalloc ((a),(b))
  ------------------
 3964|      0|                  pkt->pkttype = PKT_SIGNATURE;
 3965|      0|                  pkt->pkt.signature = copy_signature
 3966|      0|                    (NULL, node->pkt->pkt.signature);
 3967|      0|                  *r_otherrevsigs = new_kbnode2 (*r_otherrevsigs, pkt);
 3968|      0|                }
 3969|      0|              delete_kbnode( node );
 3970|      0|            }
 3971|    341|          else
 3972|    341|            {
 3973|       |	      /* If the revocation cert is from a different key than
 3974|       |                 the one we're working on don't check it - it's
 3975|       |                 probably from a revocation key and won't be
 3976|       |                 verifiable with this key anyway. */
 3977|       |
 3978|    341|	      if(node->pkt->pkt.signature->keyid[0]==keyid[0]
  ------------------
  |  Branch (3978:11): [True: 129, False: 212]
  ------------------
 3979|    341|                 && node->pkt->pkt.signature->keyid[1]==keyid[1])
  ------------------
  |  Branch (3979:21): [True: 1, False: 128]
  ------------------
 3980|      1|		{
 3981|      1|		  int rc = check_key_signature (ctrl, keyblock, node, NULL);
 3982|      1|		  if (rc )
  ------------------
  |  Branch (3982:9): [True: 1, False: 0]
  ------------------
 3983|      1|		    {
 3984|      1|		      if(opt.verbose)
  ------------------
  |  Branch (3984:12): [True: 0, False: 1]
  ------------------
 3985|      0|			log_info( _("key %s: invalid revocation"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 3986|      0|				    " certificate: %s - skipped\n"),
 3987|      0|				  keystr(keyid), gpg_strerror (rc));
 3988|      1|		      delete_kbnode( node );
 3989|      1|		    }
 3990|      1|		}
 3991|    340|              else if (r_otherrevsigs)
  ------------------
  |  Branch (3991:24): [True: 340, False: 0]
  ------------------
 3992|    340|                {
 3993|    340|                  PACKET *pkt;
 3994|       |
 3995|    340|                  pkt = xcalloc (1, sizeof *pkt);
  ------------------
  |  |  109|    340|#define xcalloc(a,b)     gcry_xcalloc ((a),(b))
  ------------------
 3996|    340|                  pkt->pkttype = PKT_SIGNATURE;
 3997|    340|                  pkt->pkt.signature = copy_signature
 3998|    340|                    (NULL, node->pkt->pkt.signature);
 3999|    340|                  *r_otherrevsigs = new_kbnode2 (*r_otherrevsigs, pkt);
 4000|    340|                }
 4001|    341|	    }
 4002|    341|	}
 4003|    348|      else if (node->pkt->pkttype == PKT_SIGNATURE
  ------------------
  |  Branch (4003:16): [True: 348, False: 0]
  ------------------
 4004|    348|               && (IS_SUBKEY_SIG (node->pkt->pkt.signature)
  ------------------
  |  |   43|    696|#define IS_SUBKEY_SIG(s) ((s)->sig_class == 0x18)
  |  |  ------------------
  |  |  |  Branch (43:26): [True: 195, False: 153]
  |  |  ------------------
  ------------------
 4005|    348|                   || IS_SUBKEY_REV (node->pkt->pkt.signature))
  ------------------
  |  |   47|    153|#define IS_SUBKEY_REV(s) ((s)->sig_class == 0x28)
  |  |  ------------------
  |  |  |  Branch (47:26): [True: 3, False: 150]
  |  |  ------------------
  ------------------
 4006|    348|               && !subkey_seen )
  ------------------
  |  Branch (4006:19): [True: 192, False: 6]
  ------------------
 4007|    192|        {
 4008|    192|          if(opt.verbose)
  ------------------
  |  Branch (4008:14): [True: 0, False: 192]
  ------------------
 4009|      0|            log_info( _("key %s: subkey signature"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 4010|      0|                        " in wrong place - skipped\n"), keystr(keyid));
 4011|    192|          delete_kbnode( node );
 4012|    192|        }
 4013|    156|      else if (node->pkt->pkttype == PKT_SIGNATURE
  ------------------
  |  Branch (4013:16): [True: 156, False: 0]
  ------------------
 4014|    156|               && !IS_CERT(node->pkt->pkt.signature))
  ------------------
  |  |   32|    156|#define IS_CERT(s)       (IS_KEY_SIG(s)       \
  |  |  ------------------
  |  |  |  |   40|    312|#define IS_KEY_SIG(s)    ((s)->sig_class == 0x1f)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (40:26): [True: 6, False: 150]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   33|    156|                          || IS_UID_SIG(s)    \
  |  |  ------------------
  |  |  |  |   41|    306|#define IS_UID_SIG(s)    (((s)->sig_class & ~3) == 0x10)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (41:26): [True: 11, False: 139]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   34|    156|                          || IS_SUBKEY_SIG(s) \
  |  |  ------------------
  |  |  |  |   43|    295|#define IS_SUBKEY_SIG(s) ((s)->sig_class == 0x18)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:26): [True: 3, False: 136]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   35|    156|                          || IS_KEY_REV(s)    \
  |  |  ------------------
  |  |  |  |   45|    292|#define IS_KEY_REV(s)    ((s)->sig_class == 0x20)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:26): [True: 0, False: 136]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   36|    156|                          || IS_UID_REV(s)    \
  |  |  ------------------
  |  |  |  |   46|    292|#define IS_UID_REV(s)    ((s)->sig_class == 0x30)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (46:26): [True: 0, False: 136]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|    156|                          || IS_SUBKEY_REV(s) \
  |  |  ------------------
  |  |  |  |   47|    292|#define IS_SUBKEY_REV(s) ((s)->sig_class == 0x28)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (47:26): [True: 3, False: 133]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|    156|                          || IS_ATTST_SIGS(s) )
  |  |  ------------------
  |  |  |  |   42|    133|#define IS_ATTST_SIGS(s) ((s)->sig_class == 0x16)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (42:26): [True: 0, False: 133]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4015|    133|        {
 4016|    133|          if(opt.verbose)
  ------------------
  |  Branch (4016:14): [True: 0, False: 133]
  ------------------
 4017|      0|            log_info(_("key %s: unexpected signature class (0x%02X) -"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 4018|      0|                       " skipped\n"),keystr(keyid),
 4019|      0|                     node->pkt->pkt.signature->sig_class);
 4020|    133|          delete_kbnode(node);
 4021|    133|	  }
 4022|     23|      else if ((node->flag & NODE_DELETION_MARK))
  ------------------
  |  |   75|     23|#define NODE_DELETION_MARK 4
  ------------------
  |  Branch (4022:16): [True: 0, False: 23]
  ------------------
 4023|      0|        delete_kbnode( node );
 4024|  2.24k|    }
 4025|       |
 4026|       |  /* note: because keyblock is the public key, it is never marked
 4027|       |   * for deletion and so keyblock cannot change */
 4028|    758|  commit_kbnode( &keyblock );
 4029|    758|  return nvalid;
 4030|    758|}

new_kbnode:
   94|  5.08k|{
   95|  5.08k|    KBNODE n = alloc_node();
   96|  5.08k|    n->pkt = pkt;
   97|  5.08k|    return n;
   98|  5.08k|}
new_kbnode2:
  105|    340|{
  106|    340|  kbnode_t n;
  107|       |
  108|    340|  n = new_kbnode (pkt);
  109|    340|  n->next = list;
  110|    340|  return n;
  111|    340|}
clone_kbnode:
  116|    187|{
  117|    187|    KBNODE n = alloc_node();
  118|       |
  119|    187|    n->pkt = node->pkt;
  120|    187|    n->private_flag = node->private_flag | 2; /* mark cloned */
  121|    187|    return n;
  122|    187|}
release_kbnode:
  127|  6.64k|{
  128|  6.64k|    KBNODE n2;
  129|       |
  130|  9.25k|    while( n ) {
  ------------------
  |  Branch (130:12): [True: 2.61k, False: 6.64k]
  ------------------
  131|  2.61k|	n2 = n->next;
  132|  2.61k|	if( !is_cloned_kbnode(n) ) {
  ------------------
  |  |   71|  2.61k|#define is_cloned_kbnode(a)   ((a)->private_flag & 2)
  ------------------
  |  Branch (132:6): [True: 2.60k, False: 15]
  ------------------
  133|  2.60k|            free_packet (n->pkt, NULL);
  134|  2.60k|            xfree( n->pkt );
  ------------------
  |  |  104|  2.60k|#define xfree(a)         gcry_free ((a))
  ------------------
  135|  2.60k|	}
  136|  2.61k|	free_node( n );
  137|  2.61k|	n = n2;
  138|  2.61k|    }
  139|  6.64k|}
delete_kbnode:
  148|  2.79k|{
  149|  2.79k|    node->private_flag |= 1;
  150|  2.79k|}
insert_kbnode:
  172|     15|{
  173|     15|    if( !pkttype ) {
  ------------------
  |  Branch (173:9): [True: 4, False: 11]
  ------------------
  174|      4|	node->next = root->next;
  175|      4|	root->next = node;
  176|      4|    }
  177|     11|    else {
  178|     11|	KBNODE n1;
  179|       |
  180|     51|	for(n1=root; n1->next;	n1 = n1->next)
  ------------------
  |  Branch (180:15): [True: 44, False: 7]
  ------------------
  181|     44|	    if( pkttype != n1->next->pkt->pkttype ) {
  ------------------
  |  Branch (181:10): [True: 4, False: 40]
  ------------------
  182|      4|		node->next = n1->next;
  183|      4|		n1->next = node;
  184|      4|		return;
  185|      4|	    }
  186|       |	/* no such packet, append */
  187|      7|	node->next = NULL;
  188|      7|	n1->next = node;
  189|      7|    }
  190|     15|}
find_prev_kbnode:
  199|    153|{
  200|    153|    KBNODE n1;
  201|       |
  202|  43.5k|    for (n1=NULL; root && root != node; root = root->next ) {
  ------------------
  |  Branch (202:19): [True: 43.5k, False: 0]
  |  Branch (202:27): [True: 43.4k, False: 153]
  ------------------
  203|  43.4k|        if (!pkttype ||root->pkt->pkttype == pkttype)
  ------------------
  |  Branch (203:13): [True: 0, False: 43.4k]
  |  Branch (203:24): [True: 25, False: 43.3k]
  ------------------
  204|     25|            n1 = root;
  205|  43.4k|    }
  206|    153|    return n1;
  207|    153|}
find_next_kbnode:
  219|  4.77k|{
  220|  5.68k|    for( node=node->next ; node; node = node->next ) {
  ------------------
  |  Branch (220:28): [True: 4.73k, False: 956]
  ------------------
  221|  4.73k|	if( !pkttype )
  ------------------
  |  Branch (221:6): [True: 2.86k, False: 1.87k]
  ------------------
  222|  2.86k|	    return node;
  223|  1.87k|	else if( pkttype == PKT_USER_ID
  ------------------
  |  Branch (223:11): [True: 1.87k, False: 0]
  ------------------
  224|  1.87k|		 && (	node->pkt->pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (224:9): [True: 0, False: 1.87k]
  ------------------
  225|  1.87k|		     || node->pkt->pkttype == PKT_SECRET_KEY ) )
  ------------------
  |  Branch (225:11): [True: 0, False: 1.87k]
  ------------------
  226|      0|	    return NULL;
  227|  1.87k|	else if( pkttype == PKT_SIGNATURE
  ------------------
  |  Branch (227:11): [True: 0, False: 1.87k]
  ------------------
  228|  1.87k|		 && (	node->pkt->pkttype == PKT_USER_ID
  ------------------
  |  Branch (228:9): [True: 0, False: 0]
  ------------------
  229|      0|		     || node->pkt->pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (229:11): [True: 0, False: 0]
  ------------------
  230|      0|		     || node->pkt->pkttype == PKT_SECRET_KEY ) )
  ------------------
  |  Branch (230:11): [True: 0, False: 0]
  ------------------
  231|      0|	    return NULL;
  232|  1.87k|	else if( node->pkt->pkttype == pkttype )
  ------------------
  |  Branch (232:11): [True: 959, False: 912]
  ------------------
  233|    959|	    return node;
  234|  4.73k|    }
  235|    956|    return NULL;
  236|  4.77k|}
find_kbnode:
  241|  1.15k|{
  242|  1.15k|    for( ; node; node = node->next ) {
  ------------------
  |  Branch (242:12): [True: 1.15k, False: 0]
  ------------------
  243|  1.15k|	if( node->pkt->pkttype == pkttype )
  ------------------
  |  Branch (243:6): [True: 1.15k, False: 0]
  ------------------
  244|  1.15k|	    return node;
  245|  1.15k|    }
  246|      0|    return NULL;
  247|  1.15k|}
walk_kbnode:
  259|    752|{
  260|    752|    KBNODE n;
  261|       |
  262|    752|    do {
  263|    752|	if( !*context ) {
  ------------------
  |  Branch (263:6): [True: 183, False: 569]
  ------------------
  264|    183|	    *context = root;
  265|    183|	    n = root;
  266|    183|	}
  267|    569|	else {
  268|    569|	    n = (*context)->next;
  269|    569|	    *context = n;
  270|    569|	}
  271|    752|    } while( !all && n && is_deleted_kbnode(n) );
  ------------------
  |  |   70|    569|#define is_deleted_kbnode(a)  ((a)->private_flag & 1)
  |  |  ------------------
  |  |  |  Branch (70:31): [True: 0, False: 569]
  |  |  ------------------
  ------------------
  |  Branch (271:14): [True: 752, False: 0]
  |  Branch (271:22): [True: 569, False: 183]
  ------------------
  272|       |
  273|    752|    return n;
  274|    752|}
clear_kbnode_flags:
  278|    948|{
  279|  5.18k|    for( ; n; n = n->next ) {
  ------------------
  |  Branch (279:12): [True: 4.23k, False: 948]
  ------------------
  280|  4.23k|	n->flag = 0;
  281|  4.23k|    }
  282|    948|}
commit_kbnode:
  293|    943|{
  294|    943|    KBNODE n, nl;
  295|    943|    int changed = 0;
  296|       |
  297|  4.97k|    for( n = *root, nl=NULL; n; n = nl->next ) {
  ------------------
  |  Branch (297:30): [True: 4.02k, False: 943]
  ------------------
  298|  4.02k|	if( is_deleted_kbnode(n) ) {
  ------------------
  |  |   70|  4.02k|#define is_deleted_kbnode(a)  ((a)->private_flag & 1)
  |  |  ------------------
  |  |  |  Branch (70:31): [True: 2.65k, False: 1.37k]
  |  |  ------------------
  ------------------
  299|  2.65k|	    if( n == *root )
  ------------------
  |  Branch (299:10): [True: 0, False: 2.65k]
  ------------------
  300|      0|		*root = nl = n->next;
  301|  2.65k|	    else
  302|  2.65k|		nl->next = n->next;
  303|  2.65k|	    if( !is_cloned_kbnode(n) ) {
  ------------------
  |  |   71|  2.65k|#define is_cloned_kbnode(a)   ((a)->private_flag & 2)
  ------------------
  |  Branch (303:10): [True: 2.48k, False: 172]
  ------------------
  304|  2.48k|                free_packet (n->pkt, NULL);
  305|  2.48k|		xfree( n->pkt );
  ------------------
  |  |  104|  2.48k|#define xfree(a)         gcry_free ((a))
  ------------------
  306|  2.48k|	    }
  307|  2.65k|	    free_node( n );
  308|  2.65k|	    changed = 1;
  309|  2.65k|	}
  310|  1.37k|	else
  311|  1.37k|	    nl = n;
  312|  4.02k|    }
  313|    943|    return changed;
  314|    943|}
kbnode.c:alloc_node:
   53|  5.27k|{
   54|  5.27k|  kbnode_t n;
   55|       |
   56|  5.27k|  n = unused_nodes;
   57|  5.27k|  if (n)
  ------------------
  |  Branch (57:7): [True: 4.66k, False: 608]
  ------------------
   58|  4.66k|    unused_nodes = n->next;
   59|    608|  else
   60|    608|    {
   61|    608|      if (!cleanup_registered)
  ------------------
  |  Branch (61:11): [True: 1, False: 607]
  ------------------
   62|      1|        {
   63|      1|          cleanup_registered = 1;
   64|      1|          register_mem_cleanup_func (release_unused_nodes);
   65|      1|        }
   66|    608|      n = xmalloc (sizeof *n);
  ------------------
  |  |  107|    608|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
   67|    608|    }
   68|  5.27k|  n->next = NULL;
   69|  5.27k|  n->pkt = NULL;
   70|  5.27k|  n->flag = 0;
   71|  5.27k|  n->tag = 0;
   72|  5.27k|  n->private_flag=0;
   73|  5.27k|  return n;
   74|  5.27k|}
kbnode.c:free_node:
   78|  5.27k|{
   79|  5.27k|  if (n)
  ------------------
  |  Branch (79:7): [True: 5.27k, False: 0]
  ------------------
   80|  5.27k|    {
   81|  5.27k|#if USE_UNUSED_NODES
   82|  5.27k|      n->next = unused_nodes;
   83|  5.27k|      unused_nodes = n;
   84|       |#else
   85|       |      xfree (n);
   86|       |#endif
   87|  5.27k|    }
   88|  5.27k|}

key_check_all_keysigs:
  248|    758|{
  249|    758|  gpg_error_t err;
  250|    758|  PKT_public_key *pk;
  251|    758|  KBNODE n, n_next, *n_prevp, n2;
  252|    758|  char *pending_desc = NULL;
  253|    758|  PKT_public_key *issuer;
  254|    758|  KBNODE last_printed_component;
  255|    758|  KBNODE current_component = NULL;
  256|    758|  int dups = 0;
  257|    758|  int missing_issuer = 0;
  258|    758|  int reordered = 0;
  259|    758|  int bad_signature = 0;
  260|    758|  int missing_selfsig = 0;
  261|    758|  int modified = 0;
  262|    758|  PKT_signature *sig;
  263|       |
  264|    758|  (void)missing_selfsig;
  265|    758|  log_assert (kb->pkt->pkttype == PKT_PUBLIC_KEY);
  266|      0|  pk = kb->pkt->pkt.public_key;
  267|       |
  268|       |  /* First we look for duplicates.  */
  269|    758|  if (remove_duplicate_sigs (kb, &dups, &modified))
  ------------------
  |  Branch (269:7): [True: 0, False: 758]
  ------------------
  270|      0|    goto leave;  /* Error */
  271|       |
  272|       |  /* Now make sure the sigs occur after the component (aka block)
  273|       |   * (public key, subkey, user id) that they sign.  */
  274|    758|  issuer = NULL;
  275|    758|  last_printed_component = NULL;
  276|    758|  for (n_prevp = &kb, n = kb;
  277|  4.37k|       n;
  ------------------
  |  Branch (277:8): [True: 3.62k, False: 758]
  ------------------
  278|       |       /* If we moved n, then n_prevp is need valid.  */
  279|  3.62k|       n_prevp = (n->next == n_next ? &n->next : n_prevp), n = n_next)
  ------------------
  |  Branch (279:19): [True: 3.61k, False: 6]
  ------------------
  280|  3.62k|    {
  281|  3.62k|      PACKET *p;
  282|  3.62k|      int processed_current_component;
  283|  3.62k|      int rc;
  284|  3.62k|      int dump_sig_params = 0;
  285|       |
  286|  3.62k|      n_next = n->next;
  287|       |
  288|  3.62k|      if (is_deleted_kbnode (n))
  ------------------
  |  |   70|  3.62k|#define is_deleted_kbnode(a)  ((a)->private_flag & 1)
  |  |  ------------------
  |  |  |  Branch (70:31): [True: 0, False: 3.62k]
  |  |  ------------------
  ------------------
  289|      0|        continue;
  290|       |
  291|  3.62k|      p = n->pkt;
  292|       |
  293|  3.62k|      if (issuer && issuer != pk)
  ------------------
  |  Branch (293:11): [True: 731, False: 2.89k]
  |  Branch (293:21): [True: 0, False: 731]
  ------------------
  294|      0|        {
  295|      0|          free_public_key (issuer);
  296|      0|          issuer = NULL;
  297|      0|        }
  298|       |
  299|  3.62k|      xfree (pending_desc);
  ------------------
  |  |  104|  3.62k|#define xfree(a)         gcry_free ((a))
  ------------------
  300|  3.62k|      pending_desc = NULL;
  301|       |
  302|  3.62k|      switch (p->pkttype)
  303|  3.62k|        {
  304|    758|        case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (304:9): [True: 758, False: 2.86k]
  ------------------
  305|    758|          log_assert (p->pkt.public_key == pk);
  306|    758|          if (only_selected && ! (n->flag & NODFLG_SELKEY))
  ------------------
  |  |   33|      0|#define NODFLG_SELKEY (1<<9)	/* Indicate the selected key.  */
  ------------------
  |  Branch (306:15): [True: 0, False: 758]
  |  Branch (306:32): [True: 0, False: 0]
  ------------------
  307|      0|            {
  308|      0|              current_component = NULL;
  309|      0|              break;
  310|      0|            }
  311|       |
  312|    758|          if (DBG_PACKET)
  ------------------
  |  |  348|    758|#define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
  |  |  ------------------
  |  |  |  |  331|    758|#define DBG_PACKET_VALUE  1	/* debug packet reading/writing */
  |  |  ------------------
  |  |  |  Branch (348:20): [True: 0, False: 758]
  |  |  ------------------
  ------------------
  313|      0|            log_debug ("public key %s: timestamp: %s (%lld)\n",
  314|      0|                       pk_keyid_str (pk),
  315|      0|                       isotimestamp (pk->timestamp),
  316|      0|                       (long long) pk->timestamp);
  317|    758|          current_component = n;
  318|    758|          break;
  319|    144|        case PKT_PUBLIC_SUBKEY:
  ------------------
  |  Branch (319:9): [True: 144, False: 3.47k]
  ------------------
  320|    144|          if (only_selected && ! (n->flag & NODFLG_SELKEY))
  ------------------
  |  |   33|      0|#define NODFLG_SELKEY (1<<9)	/* Indicate the selected key.  */
  ------------------
  |  Branch (320:15): [True: 0, False: 144]
  |  Branch (320:32): [True: 0, False: 0]
  ------------------
  321|      0|            {
  322|      0|              current_component = NULL;
  323|      0|              break;
  324|      0|            }
  325|       |
  326|    144|          if (DBG_PACKET)
  ------------------
  |  |  348|    144|#define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
  |  |  ------------------
  |  |  |  |  331|    144|#define DBG_PACKET_VALUE  1	/* debug packet reading/writing */
  |  |  ------------------
  |  |  |  Branch (348:20): [True: 0, False: 144]
  |  |  ------------------
  ------------------
  327|      0|            log_debug ("subkey %s: timestamp: %s (%lld)\n",
  328|      0|                       pk_keyid_str (p->pkt.public_key),
  329|      0|                       isotimestamp (p->pkt.public_key->timestamp),
  330|      0|                       (long long) p->pkt.public_key->timestamp);
  331|    144|          current_component = n;
  332|    144|          break;
  333|  1.24k|        case PKT_USER_ID:
  ------------------
  |  Branch (333:9): [True: 1.24k, False: 2.37k]
  ------------------
  334|  1.24k|          if (only_selected && ! (n->flag & NODFLG_SELUID))
  ------------------
  |  |   32|      0|#define NODFLG_SELUID (1<<8)	/* Indicate the selected userid. */
  ------------------
  |  Branch (334:15): [True: 0, False: 1.24k]
  |  Branch (334:32): [True: 0, False: 0]
  ------------------
  335|      0|            {
  336|      0|              current_component = NULL;
  337|      0|              break;
  338|      0|            }
  339|       |
  340|  1.24k|          if (DBG_PACKET)
  ------------------
  |  |  348|  1.24k|#define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
  |  |  ------------------
  |  |  |  |  331|  1.24k|#define DBG_PACKET_VALUE  1	/* debug packet reading/writing */
  |  |  ------------------
  |  |  |  Branch (348:20): [True: 0, False: 1.24k]
  |  |  ------------------
  ------------------
  341|      0|            log_debug ("user id: %s\n",
  342|      0|                       p->pkt.user_id->attrib_data
  ------------------
  |  Branch (342:24): [True: 0, False: 0]
  ------------------
  343|      0|                       ? "[ photo id ]"
  344|      0|                       : p->pkt.user_id->name);
  345|  1.24k|          current_component = n;
  346|  1.24k|          break;
  347|  1.46k|        case PKT_SIGNATURE:
  ------------------
  |  Branch (347:9): [True: 1.46k, False: 2.15k]
  ------------------
  348|  1.46k|          if (! current_component)
  ------------------
  |  Branch (348:15): [True: 0, False: 1.46k]
  ------------------
  349|       |            /* The current component is not selected, don't check the
  350|       |               sigs under it.  */
  351|      0|            break;
  352|       |
  353|  1.46k|          sig = n->pkt->pkt.signature;
  354|       |
  355|  1.46k|          pending_desc = xasprintf ("  sig: class: 0x%x, issuer: %s,"
  356|  1.46k|                                    " timestamp: %s (%lld), digest: %02x %02x",
  357|  1.46k|                                    sig->sig_class,
  358|  1.46k|                                    keystr (sig->keyid),
  359|  1.46k|                                    isotimestamp (sig->timestamp),
  360|  1.46k|                                    (long long) sig->timestamp,
  361|  1.46k|                                    sig->digest_start[0], sig->digest_start[1]);
  362|       |
  363|       |
  364|  1.46k|          if (keyid_cmp (pk_keyid (pk), sig->keyid) == 0)
  ------------------
  |  Branch (364:15): [True: 402, False: 1.06k]
  ------------------
  365|    402|            issuer = pk;
  366|  1.06k|          else /* Issuer is a different key.  */
  367|  1.06k|            {
  368|  1.06k|              if (only_selfsigs)
  ------------------
  |  Branch (368:19): [True: 0, False: 1.06k]
  ------------------
  369|      0|                continue;
  370|       |
  371|  1.06k|              issuer = xtrycalloc (1, sizeof *issuer);
  ------------------
  |  |   99|  1.06k|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  372|  1.06k|              if (!issuer)
  ------------------
  |  Branch (372:19): [True: 0, False: 1.06k]
  ------------------
  373|      0|                err = gpg_error_from_syserror ();
  374|  1.06k|              else
  375|  1.06k|                err = get_pubkey (ctrl, issuer, sig->keyid);
  376|  1.06k|              if (err)
  ------------------
  |  Branch (376:19): [True: 1.06k, False: 0]
  ------------------
  377|  1.06k|                {
  378|  1.06k|                  xfree (issuer);
  ------------------
  |  |  104|  1.06k|#define xfree(a)         gcry_free ((a))
  ------------------
  379|  1.06k|                  issuer = NULL;
  380|  1.06k|                  if (DBG_PACKET)
  ------------------
  |  |  348|  1.06k|#define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
  |  |  ------------------
  |  |  |  |  331|  1.06k|#define DBG_PACKET_VALUE  1	/* debug packet reading/writing */
  |  |  ------------------
  |  |  |  Branch (348:20): [True: 0, False: 1.06k]
  |  |  ------------------
  ------------------
  381|      0|                    {
  382|      0|                      if (pending_desc)
  ------------------
  |  Branch (382:27): [True: 0, False: 0]
  ------------------
  383|      0|                        log_debug ("%s", pending_desc);
  384|      0|                      log_debug ("    Can't check signature allegedly"
  385|      0|                                 " issued by %s: %s\n",
  386|      0|                                 keystr (sig->keyid), gpg_strerror (err));
  387|      0|                    }
  388|  1.06k|                  missing_issuer ++;
  389|  1.06k|                  break;
  390|  1.06k|                }
  391|  1.06k|            }
  392|       |
  393|    402|          if ((err = openpgp_pk_test_algo (sig->pubkey_algo)))
  ------------------
  |  Branch (393:15): [True: 106, False: 296]
  ------------------
  394|    106|            {
  395|    106|              if (DBG_PACKET && pending_desc)
  ------------------
  |  |  348|    212|#define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
  |  |  ------------------
  |  |  |  |  331|    106|#define DBG_PACKET_VALUE  1	/* debug packet reading/writing */
  |  |  ------------------
  |  |  |  Branch (348:20): [True: 0, False: 106]
  |  |  ------------------
  ------------------
  |  Branch (395:33): [True: 0, False: 0]
  ------------------
  396|      0|                log_debug ("%s", pending_desc);
  397|    106|              log_info (_("can't check signature with unsupported"
  ------------------
  |  |   28|    106|#  define _(a) gettext (a)
  ------------------
  398|    106|                          " public-key algorithm (%d): %s.\n"),
  399|    106|                          sig->pubkey_algo, gpg_strerror (err));
  400|    106|              break;
  401|    106|            }
  402|    296|          if ((err = openpgp_md_test_algo (sig->digest_algo)))
  ------------------
  |  Branch (402:15): [True: 19, False: 277]
  ------------------
  403|     19|            {
  404|     19|              if (DBG_PACKET && pending_desc)
  ------------------
  |  |  348|     38|#define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
  |  |  ------------------
  |  |  |  |  331|     19|#define DBG_PACKET_VALUE  1	/* debug packet reading/writing */
  |  |  ------------------
  |  |  |  Branch (348:20): [True: 0, False: 19]
  |  |  ------------------
  ------------------
  |  Branch (404:33): [True: 0, False: 0]
  ------------------
  405|      0|                log_debug ("%s", pending_desc);
  406|     19|              log_info (_("can't check signature with unsupported"
  ------------------
  |  |   28|     19|#  define _(a) gettext (a)
  ------------------
  407|     19|                          " message-digest algorithm %d: %s.\n"),
  408|     19|                          sig->digest_algo, gpg_strerror (err));
  409|     19|              break;
  410|     19|            }
  411|       |
  412|       |          /* We iterate over the keyblock.  Most likely, the matching
  413|       |             component is the current component so always try that
  414|       |             first.  */
  415|    277|          processed_current_component = 0;
  416|    277|          for (n2 = current_component;
  417|   126k|               n2;
  ------------------
  |  Branch (417:16): [True: 126k, False: 260]
  ------------------
  418|   126k|               n2 = (processed_current_component ? n2->next : kb),
  ------------------
  |  Branch (418:22): [True: 126k, False: 266]
  ------------------
  419|   126k|                 processed_current_component = 1)
  420|   126k|            if (is_deleted_kbnode (n2))
  ------------------
  |  |   70|   126k|#define is_deleted_kbnode(a)  ((a)->private_flag & 1)
  |  |  ------------------
  |  |  |  Branch (70:31): [True: 0, False: 126k]
  |  |  ------------------
  ------------------
  421|      0|              continue;
  422|   126k|            else if (processed_current_component && n2 == current_component)
  ------------------
  |  Branch (422:22): [True: 126k, False: 277]
  |  Branch (422:53): [True: 263, False: 125k]
  ------------------
  423|       |              /* Don't process it twice.  */
  424|    263|              continue;
  425|   126k|            else
  426|   126k|              {
  427|   126k|                err = check_signature_over_key_or_uid (ctrl,
  428|   126k|                                                       issuer, sig, kb, n2->pkt,
  429|   126k|                                                       NULL, NULL);
  430|   126k|                if (! err)
  ------------------
  |  Branch (430:21): [True: 17, False: 126k]
  ------------------
  431|     17|                  break;
  432|   126k|              }
  433|       |
  434|       |          /* n/sig is a signature and n2 is the component (public key,
  435|       |             subkey or user id) that it signs, if any.
  436|       |             current_component is that component that it appears to
  437|       |             apply to (according to the ordering).  */
  438|       |
  439|    277|          if (current_component == n2)
  ------------------
  |  Branch (439:15): [True: 11, False: 266]
  ------------------
  440|     11|            {
  441|     11|              if (DBG_PACKET)
  ------------------
  |  |  348|     11|#define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
  |  |  ------------------
  |  |  |  |  331|     11|#define DBG_PACKET_VALUE  1	/* debug packet reading/writing */
  |  |  ------------------
  |  |  |  Branch (348:20): [True: 0, False: 11]
  |  |  ------------------
  ------------------
  442|      0|                {
  443|      0|                  log_debug ("%s", pending_desc);
  444|      0|                  log_debug ("    Good signature over last key or uid!\n");
  445|      0|                }
  446|       |
  447|     11|              rc = 0;
  448|     11|            }
  449|    266|          else if (n2)
  ------------------
  |  Branch (449:20): [True: 6, False: 260]
  ------------------
  450|      6|            {
  451|      6|              log_assert (n2->pkt->pkttype == PKT_USER_ID
  452|      6|                          || n2->pkt->pkttype == PKT_PUBLIC_KEY
  453|      6|                          || n2->pkt->pkttype == PKT_PUBLIC_SUBKEY);
  454|       |
  455|      6|              if (DBG_PACKET)
  ------------------
  |  |  348|      6|#define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
  |  |  ------------------
  |  |  |  |  331|      6|#define DBG_PACKET_VALUE  1	/* debug packet reading/writing */
  |  |  ------------------
  |  |  |  Branch (348:20): [True: 0, False: 6]
  |  |  ------------------
  ------------------
  456|      0|                {
  457|      0|                  log_debug ("%s", pending_desc);
  458|      0|                  log_debug ("    Good signature out of order!"
  459|      0|                             "  (Over %s (%d) '%s')\n",
  460|      0|                             n2->pkt->pkttype == PKT_USER_ID
  ------------------
  |  Branch (460:30): [True: 0, False: 0]
  ------------------
  461|      0|                             ? "user id"
  462|      0|                             : n2->pkt->pkttype == PKT_PUBLIC_SUBKEY
  ------------------
  |  Branch (462:32): [True: 0, False: 0]
  ------------------
  463|      0|                             ? "subkey"
  464|      0|                             : "primary key",
  465|      0|                             n2->pkt->pkttype,
  466|      0|                             n2->pkt->pkttype == PKT_USER_ID
  ------------------
  |  Branch (466:30): [True: 0, False: 0]
  ------------------
  467|      0|                             ? n2->pkt->pkt.user_id->name
  468|      0|                             : pk_keyid_str (n2->pkt->pkt.public_key));
  469|      0|                }
  470|       |
  471|       |              /* Reorder the packets: move the signature n to be just
  472|       |                 after n2.  */
  473|       |
  474|       |              /* Unlink the signature.  */
  475|      6|              log_assert (n_prevp);
  476|      0|              *n_prevp = n->next;
  477|       |
  478|       |              /* Insert the sig immediately after the component.  */
  479|      6|              n->next = n2->next;
  480|      6|              n2->next = n;
  481|       |
  482|      6|              reordered ++;
  483|      6|              modified = 1;
  484|       |
  485|      6|              rc = 0;
  486|      6|            }
  487|    260|          else
  488|    260|            {
  489|    260|              if (DBG_PACKET)
  ------------------
  |  |  348|    260|#define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
  |  |  ------------------
  |  |  |  |  331|    260|#define DBG_PACKET_VALUE  1	/* debug packet reading/writing */
  |  |  ------------------
  |  |  |  Branch (348:20): [True: 0, False: 260]
  |  |  ------------------
  ------------------
  490|      0|                {
  491|      0|                  log_debug ("%s", pending_desc);
  492|      0|                  log_debug ("    Bad signature.\n");
  493|      0|                }
  494|       |
  495|    260|              if (DBG_PACKET)
  ------------------
  |  |  348|    260|#define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
  |  |  ------------------
  |  |  |  |  331|    260|#define DBG_PACKET_VALUE  1	/* debug packet reading/writing */
  |  |  ------------------
  |  |  |  Branch (348:20): [True: 0, False: 260]
  |  |  ------------------
  ------------------
  496|      0|                dump_sig_params = 1;
  497|       |
  498|    260|              bad_signature ++;
  499|       |
  500|    260|              rc = GPG_ERR_BAD_SIGNATURE;
  501|    260|            }
  502|       |
  503|       |          /* We don't cache the result here, because we haven't
  504|       |             completely checked that the signature is legitimate.  For
  505|       |             instance, if we have a revocation certificate on Alice's
  506|       |             key signed by Bob, the signature may be good, but we
  507|       |             haven't checked that Bob is a designated revoker.  */
  508|       |          /* cache_sig_result (sig, rc); */
  509|       |
  510|      0|          {
  511|    277|            int has_selfsig = 0;
  512|    277|            if (! rc && issuer == pk)
  ------------------
  |  Branch (512:17): [True: 17, False: 260]
  |  Branch (512:25): [True: 17, False: 0]
  ------------------
  513|     17|              {
  514|     17|                if (n2->pkt->pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (514:21): [True: 0, False: 17]
  ------------------
  515|     17|                    && (/* Direct key signature.  */
  516|      0|                        sig->sig_class == 0x1f
  ------------------
  |  Branch (516:25): [True: 0, False: 0]
  ------------------
  517|       |                        /* Key revocation signature.  */
  518|      0|                        || sig->sig_class == 0x20))
  ------------------
  |  Branch (518:28): [True: 0, False: 0]
  ------------------
  519|      0|                  has_selfsig = 1;
  520|     17|                if (n2->pkt->pkttype == PKT_PUBLIC_SUBKEY
  ------------------
  |  Branch (520:21): [True: 3, False: 14]
  ------------------
  521|     17|                    && (/* Subkey binding sig.  */
  522|      3|                        sig->sig_class == 0x18
  ------------------
  |  Branch (522:25): [True: 3, False: 0]
  ------------------
  523|       |                        /* Subkey revocation sig.  */
  524|      3|                        || sig->sig_class == 0x28))
  ------------------
  |  Branch (524:28): [True: 0, False: 0]
  ------------------
  525|      3|                  has_selfsig = 1;
  526|     17|                if (n2->pkt->pkttype == PKT_USER_ID
  ------------------
  |  Branch (526:21): [True: 14, False: 3]
  ------------------
  527|     17|                    && (/* Certification sigs.  */
  528|     14|                        sig->sig_class == 0x10
  ------------------
  |  Branch (528:25): [True: 8, False: 6]
  ------------------
  529|     14|                        || sig->sig_class == 0x11
  ------------------
  |  Branch (529:28): [True: 0, False: 6]
  ------------------
  530|     14|                        || sig->sig_class == 0x12
  ------------------
  |  Branch (530:28): [True: 0, False: 6]
  ------------------
  531|     14|                        || sig->sig_class == 0x13
  ------------------
  |  Branch (531:28): [True: 6, False: 0]
  ------------------
  532|       |                        /* Certification revocation sig.  */
  533|     14|                        || sig->sig_class == 0x30))
  ------------------
  |  Branch (533:28): [True: 0, False: 0]
  ------------------
  534|     14|                  has_selfsig = 1;
  535|     17|              }
  536|       |
  537|    277|            if (DBG_PACKET
  ------------------
  |  |  348|    554|#define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
  |  |  ------------------
  |  |  |  |  331|    277|#define DBG_PACKET_VALUE  1	/* debug packet reading/writing */
  |  |  ------------------
  |  |  |  Branch (348:20): [True: 0, False: 277]
  |  |  ------------------
  ------------------
  538|    277|                && ((n2 && n2 != last_printed_component)
  ------------------
  |  Branch (538:22): [True: 0, False: 0]
  |  Branch (538:28): [True: 0, False: 0]
  ------------------
  539|      0|                    || (! n2 && last_printed_component != current_component)))
  ------------------
  |  Branch (539:25): [True: 0, False: 0]
  |  Branch (539:33): [True: 0, False: 0]
  ------------------
  540|      0|              {
  541|      0|                int is_reordered = n2 && n2 != current_component;
  ------------------
  |  Branch (541:36): [True: 0, False: 0]
  |  Branch (541:42): [True: 0, False: 0]
  ------------------
  542|      0|                if (n2)
  ------------------
  |  Branch (542:21): [True: 0, False: 0]
  ------------------
  543|      0|                  last_printed_component = n2;
  544|      0|                else
  545|      0|                  last_printed_component = current_component;
  546|       |
  547|      0|                if (!modified)
  ------------------
  |  Branch (547:21): [True: 0, False: 0]
  ------------------
  548|      0|                  ;
  549|      0|                else if (last_printed_component->pkt->pkttype == PKT_USER_ID)
  ------------------
  |  Branch (549:26): [True: 0, False: 0]
  ------------------
  550|      0|                  {
  551|      0|                    log_debug ("uid  ");
  552|      0|                    print_utf8_buffer (log_get_stream (),
  553|      0|                                       last_printed_component
  554|      0|                                       ->pkt->pkt.user_id->name,
  555|      0|                                       last_printed_component
  556|      0|                                       ->pkt->pkt.user_id->len);
  557|      0|                    log_flush ();
  558|      0|                  }
  559|      0|                else if (last_printed_component->pkt->pkttype
  ------------------
  |  Branch (559:26): [True: 0, False: 0]
  ------------------
  560|      0|                         == PKT_PUBLIC_KEY)
  561|      0|                  log_debug ("pub  %s\n",
  562|      0|                             pk_keyid_str (last_printed_component
  563|      0|                                             ->pkt->pkt.public_key));
  564|      0|                else
  565|      0|                  log_debug ("sub  %s\n",
  566|      0|                             pk_keyid_str (last_printed_component
  567|      0|                                           ->pkt->pkt.public_key));
  568|       |
  569|      0|                if (modified)
  ------------------
  |  Branch (569:21): [True: 0, False: 0]
  ------------------
  570|      0|                  {
  571|      0|                    if (is_reordered)
  ------------------
  |  Branch (571:25): [True: 0, False: 0]
  ------------------
  572|      0|                      log_debug ("%s\n", _(" (reordered signatures follow)"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  573|      0|                  }
  574|      0|              }
  575|       |
  576|    277|            if (DBG_PACKET && modified)
  ------------------
  |  |  348|    554|#define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
  |  |  ------------------
  |  |  |  |  331|    277|#define DBG_PACKET_VALUE  1	/* debug packet reading/writing */
  |  |  ------------------
  |  |  |  Branch (348:20): [True: 0, False: 277]
  |  |  ------------------
  ------------------
  |  Branch (576:31): [True: 0, False: 0]
  ------------------
  577|      0|              keyedit_print_one_sig (ctrl, log_get_stream (),
  578|      0|                                     rc, kb, n, NULL, NULL, NULL,
  579|      0|				     has_selfsig, 0, only_selfsigs);
  580|    277|          }
  581|       |
  582|    277|          if (dump_sig_params)
  ------------------
  |  Branch (582:15): [True: 0, False: 277]
  ------------------
  583|      0|            {
  584|      0|              int i;
  585|       |
  586|      0|              for (i = 0; i < pubkey_get_nsig (sig->pubkey_algo); i ++)
  ------------------
  |  Branch (586:27): [True: 0, False: 0]
  ------------------
  587|      0|                {
  588|      0|                  char buffer[1024];
  589|      0|                  size_t len;
  590|      0|                  char *printable;
  591|      0|                  if (gcry_mpi_get_flag (sig->data[i], GCRYMPI_FLAG_OPAQUE))
  ------------------
  |  Branch (591:23): [True: 0, False: 0]
  ------------------
  592|      0|                    {
  593|      0|                      const byte *sigdata;
  594|      0|                      unsigned int nbits;
  595|       |
  596|      0|                      sigdata = gcry_mpi_get_opaque (sig->data[i], &nbits);
  597|      0|                      len = (nbits+7)/8;
  598|      0|                      memcpy (buffer, sigdata, len);
  599|      0|                    }
  600|      0|                  else
  601|      0|                    gcry_mpi_print (GCRYMPI_FMT_USG,
  602|      0|                                    buffer, sizeof (buffer), &len,
  603|      0|                                    sig->data[i]);
  604|      0|                  printable = bin2hex (buffer, len, NULL);
  605|      0|                  log_debug ("        %d: %s\n", i, printable);
  606|      0|                  xfree (printable);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  607|      0|                }
  608|      0|            }
  609|    277|          break;
  610|      8|        default:
  ------------------
  |  Branch (610:9): [True: 8, False: 3.61k]
  ------------------
  611|      8|          if (DBG_PACKET)
  ------------------
  |  |  348|      8|#define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
  |  |  ------------------
  |  |  |  |  331|      8|#define DBG_PACKET_VALUE  1	/* debug packet reading/writing */
  |  |  ------------------
  |  |  |  Branch (348:20): [True: 0, False: 8]
  |  |  ------------------
  ------------------
  612|      0|            log_debug ("unhandled packet: %d\n", p->pkttype);
  613|      8|          break;
  614|  3.62k|        }
  615|  3.62k|    }
  616|       |
  617|    758|  xfree (pending_desc);
  ------------------
  |  |  104|    758|#define xfree(a)         gcry_free ((a))
  ------------------
  618|    758|  pending_desc = NULL;
  619|       |
  620|    758|  if (issuer != pk)
  ------------------
  |  Branch (620:7): [True: 740, False: 18]
  ------------------
  621|    740|    free_public_key (issuer);
  622|    758|  issuer = NULL;
  623|       |
  624|       |  /* If we reordered signatures we need to de-duplicate again because
  625|       |   * a signature can now be a duplicate in another block.  */
  626|    758|  if (reordered)
  ------------------
  |  Branch (626:7): [True: 3, False: 755]
  ------------------
  627|      3|    {
  628|      3|      if (remove_duplicate_sigs (kb, &dups, &modified))
  ------------------
  |  Branch (628:11): [True: 0, False: 3]
  ------------------
  629|      0|        goto leave;
  630|      3|    }
  631|       |
  632|       |  /* Identify keys / uids that don't have a self-sig.  */
  633|    758|  {
  634|    758|    int has_selfsig = 0;
  635|    758|    PACKET *p;
  636|       |
  637|    758|    current_component = NULL;
  638|  4.37k|    for (n = kb; n; n = n->next)
  ------------------
  |  Branch (638:18): [True: 3.61k, False: 758]
  ------------------
  639|  3.61k|      {
  640|  3.61k|        if (is_deleted_kbnode (n))
  ------------------
  |  |   70|  3.61k|#define is_deleted_kbnode(a)  ((a)->private_flag & 1)
  |  |  ------------------
  |  |  |  Branch (70:31): [True: 0, False: 3.61k]
  |  |  ------------------
  ------------------
  641|      0|          continue;
  642|       |
  643|  3.61k|        p = n->pkt;
  644|       |
  645|  3.61k|        switch (p->pkttype)
  646|  3.61k|          {
  647|    758|          case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (647:11): [True: 758, False: 2.86k]
  ------------------
  648|    902|          case PKT_PUBLIC_SUBKEY:
  ------------------
  |  Branch (648:11): [True: 144, False: 3.47k]
  ------------------
  649|  2.14k|          case PKT_USER_ID:
  ------------------
  |  Branch (649:11): [True: 1.24k, False: 2.37k]
  ------------------
  650|  2.14k|            if (current_component && ! has_selfsig)
  ------------------
  |  Branch (650:17): [True: 1.39k, False: 758]
  |  Branch (650:38): [True: 1.39k, False: 0]
  ------------------
  651|  1.39k|              missing_selfsig ++;
  652|  2.14k|            current_component = n;
  653|  2.14k|            has_selfsig = 0;
  654|  2.14k|            break;
  655|       |
  656|  1.46k|          case PKT_SIGNATURE:
  ------------------
  |  Branch (656:11): [True: 1.46k, False: 2.15k]
  ------------------
  657|  1.46k|            if (! current_component || has_selfsig)
  ------------------
  |  Branch (657:17): [True: 8, False: 1.45k]
  |  Branch (657:40): [True: 0, False: 1.45k]
  ------------------
  658|      8|              break;
  659|       |
  660|  1.45k|            sig = n->pkt->pkt.signature;
  661|       |
  662|  1.45k|            if (! (sig->flags.checked && sig->flags.valid))
  ------------------
  |  Branch (662:20): [True: 0, False: 1.45k]
  |  Branch (662:42): [True: 0, False: 0]
  ------------------
  663|  1.45k|              break;
  664|       |
  665|      0|            if (keyid_cmp (pk_keyid (pk), sig->keyid) != 0)
  ------------------
  |  Branch (665:17): [True: 0, False: 0]
  ------------------
  666|       |              /* Different issuer, couldn't be a self-sig.  */
  667|      0|              break;
  668|       |
  669|      0|            if (current_component->pkt->pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (669:17): [True: 0, False: 0]
  ------------------
  670|      0|                && (/* Direct key signature.  */
  671|      0|                    sig->sig_class == 0x1f
  ------------------
  |  Branch (671:21): [True: 0, False: 0]
  ------------------
  672|       |                    /* Key revocation signature.  */
  673|      0|                    || sig->sig_class == 0x20))
  ------------------
  |  Branch (673:24): [True: 0, False: 0]
  ------------------
  674|      0|              has_selfsig = 1;
  675|      0|            if (current_component->pkt->pkttype == PKT_PUBLIC_SUBKEY
  ------------------
  |  Branch (675:17): [True: 0, False: 0]
  ------------------
  676|      0|                && (/* Subkey binding sig.  */
  677|      0|                    sig->sig_class == 0x18
  ------------------
  |  Branch (677:21): [True: 0, False: 0]
  ------------------
  678|       |                    /* Subkey revocation sig.  */
  679|      0|                    || sig->sig_class == 0x28))
  ------------------
  |  Branch (679:24): [True: 0, False: 0]
  ------------------
  680|      0|              has_selfsig = 1;
  681|      0|            if (current_component->pkt->pkttype == PKT_USER_ID
  ------------------
  |  Branch (681:17): [True: 0, False: 0]
  ------------------
  682|      0|                && (/* Certification sigs.  */
  683|      0|                    sig->sig_class == 0x10
  ------------------
  |  Branch (683:21): [True: 0, False: 0]
  ------------------
  684|      0|                    || sig->sig_class == 0x11
  ------------------
  |  Branch (684:24): [True: 0, False: 0]
  ------------------
  685|      0|                    || sig->sig_class == 0x12
  ------------------
  |  Branch (685:24): [True: 0, False: 0]
  ------------------
  686|      0|                    || sig->sig_class == 0x13
  ------------------
  |  Branch (686:24): [True: 0, False: 0]
  ------------------
  687|       |                    /* Certification revocation sig.  */
  688|      0|                    || sig->sig_class == 0x30))
  ------------------
  |  Branch (688:24): [True: 0, False: 0]
  ------------------
  689|      0|              has_selfsig = 1;
  690|       |
  691|      0|            break;
  692|       |
  693|      8|          default:
  ------------------
  |  Branch (693:11): [True: 8, False: 3.61k]
  ------------------
  694|      8|            if (current_component && ! has_selfsig)
  ------------------
  |  Branch (694:17): [True: 8, False: 0]
  |  Branch (694:38): [True: 8, False: 0]
  ------------------
  695|      8|              missing_selfsig ++;
  696|      8|            current_component = NULL;
  697|  3.61k|          }
  698|  3.61k|      }
  699|    758|  }
  700|       |
  701|       |
  702|    758| leave:
  703|    758|  if (!opt.quiet)
  ------------------
  |  Branch (703:7): [True: 758, False: 0]
  ------------------
  704|    758|    {
  705|    758|      char prefix[100];
  706|    758|      char *p;
  707|       |
  708|       |      /* To avoid string changes in 2.2 we strip the LF here. */
  709|    758|      snprintf (prefix, sizeof prefix, _("key %s:\n"), pk_keyid_str (pk));
  ------------------
  |  |   84|    758|#define snprintf gpgrt_snprintf
  ------------------
                    snprintf (prefix, sizeof prefix, _("key %s:\n"), pk_keyid_str (pk));
  ------------------
  |  |   28|    758|#  define _(a) gettext (a)
  ------------------
  710|    758|      p = strrchr (prefix, '\n');
  711|    758|      if (p)
  ------------------
  |  Branch (711:11): [True: 758, False: 0]
  ------------------
  712|    758|        *p = 0;
  713|       |
  714|    758|      if (dups)
  ------------------
  |  Branch (714:11): [True: 33, False: 725]
  ------------------
  715|     33|        {
  716|     33|          p = xtryasprintf
  717|     33|            (ngettext ("%d duplicate signature removed\n",
  718|     33|                       "%d duplicate signatures removed\n", dups), dups);
  719|     33|          print_info (mode, prefix, p);
  720|     33|          xfree (p);
  ------------------
  |  |  104|     33|#define xfree(a)         gcry_free ((a))
  ------------------
  721|     33|        }
  722|       |
  723|    758|      if (missing_issuer)
  ------------------
  |  Branch (723:11): [True: 581, False: 177]
  ------------------
  724|    581|        {
  725|    581|          p = xtryasprintf
  726|    581|            (ngettext ("%d signature not checked due to a missing key\n",
  727|    581|                       "%d signatures not checked due to missing keys\n",
  728|    581|                       missing_issuer), missing_issuer);
  729|    581|          print_info (mode, prefix, p);
  730|    581|          xfree (p);
  ------------------
  |  |  104|    581|#define xfree(a)         gcry_free ((a))
  ------------------
  731|    581|        }
  732|    758|      if (bad_signature)
  ------------------
  |  Branch (732:11): [True: 7, False: 751]
  ------------------
  733|      7|        {
  734|      7|          p = xtryasprintf (ngettext ("%d bad signature\n",
  735|      7|                                      "%d bad signatures\n",
  736|      7|                                      bad_signature), bad_signature);
  737|      7|          print_info (mode, prefix, p);
  738|      7|          xfree (p);
  ------------------
  |  |  104|      7|#define xfree(a)         gcry_free ((a))
  ------------------
  739|      7|        }
  740|       |
  741|    758|      if (reordered)
  ------------------
  |  Branch (741:11): [True: 3, False: 755]
  ------------------
  742|      3|        {
  743|      3|          p = xtryasprintf (ngettext ("%d signature reordered\n",
  744|      3|                                      "%d signatures reordered\n",
  745|      3|                                      reordered), reordered);
  746|      3|          print_info (mode, prefix, p);
  747|      3|          xfree (p);
  ------------------
  |  |  104|      3|#define xfree(a)         gcry_free ((a))
  ------------------
  748|      3|        }
  749|       |
  750|    758|      if (only_selfsigs && (bad_signature || reordered))
  ------------------
  |  Branch (750:11): [True: 0, False: 758]
  |  Branch (750:29): [True: 0, False: 0]
  |  Branch (750:46): [True: 0, False: 0]
  ------------------
  751|      0|        {
  752|      0|          p = xtryasprintf
  753|      0|            (_("Warning: errors found and only checked self-signatures,"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  754|      0|               " run '%s' to check all signatures.\n"), "check");
  755|      0|          print_info (mode, prefix, p);
  756|      0|          xfree (p);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  757|      0|        }
  758|    758|    }
  759|       |
  760|    758|  return modified;
  761|    758|}
key-check.c:remove_duplicate_sigs:
  106|    761|{
  107|    761|  gpg_error_t err;
  108|    761|  kbnode_t n;
  109|    761|  int nsigs;
  110|    761|  kbnode_t *sigs;  /* Allocated array with the signature packet.  */
  111|    761|  int i;
  112|    761|  int last_i;
  113|    761|  int block;
  114|    761|  PKT_signature *sig;
  115|       |
  116|       |  /* Count the sigs.  */
  117|  4.43k|  for (nsigs = 0, n = kb; n; n = n->next)
  ------------------
  |  Branch (117:27): [True: 3.67k, False: 761]
  ------------------
  118|  3.67k|    {
  119|  3.67k|      if (is_deleted_kbnode (n))
  ------------------
  |  |   70|  3.67k|#define is_deleted_kbnode(a)  ((a)->private_flag & 1)
  |  |  ------------------
  |  |  |  Branch (70:31): [True: 0, False: 3.67k]
  |  |  ------------------
  ------------------
  120|      0|        continue;
  121|  3.67k|      else if (n->pkt->pkttype == PKT_SIGNATURE)
  ------------------
  |  Branch (121:16): [True: 1.51k, False: 2.16k]
  ------------------
  122|  1.51k|        nsigs ++;
  123|  3.67k|    }
  124|       |
  125|    761|  if (!nsigs)
  ------------------
  |  Branch (125:7): [True: 172, False: 589]
  ------------------
  126|    172|    return 0; /* No signatures at all.  */
  127|       |
  128|       |  /* Add them all to the SIGS array.  */
  129|    589|  sigs = xtrycalloc (nsigs, sizeof *sigs);
  ------------------
  |  |   99|    589|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  130|    589|  if (!sigs)
  ------------------
  |  Branch (130:7): [True: 0, False: 589]
  ------------------
  131|      0|    {
  132|      0|      err = gpg_error_from_syserror ();
  133|      0|      log_error (_("error allocating memory: %s\n"), gpg_strerror (err));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  134|      0|      return err;
  135|      0|    }
  136|       |
  137|    589|  block = 0;
  138|    589|  i = 0;
  139|  3.78k|  for (n = kb; n; n = n->next)
  ------------------
  |  Branch (139:16): [True: 3.19k, False: 589]
  ------------------
  140|  3.19k|    {
  141|  3.19k|      if (is_deleted_kbnode (n))
  ------------------
  |  |   70|  3.19k|#define is_deleted_kbnode(a)  ((a)->private_flag & 1)
  |  |  ------------------
  |  |  |  Branch (70:31): [True: 0, False: 3.19k]
  |  |  ------------------
  ------------------
  142|      0|        continue;
  143|       |
  144|  3.19k|      if (n->pkt->pkttype != PKT_SIGNATURE)
  ------------------
  |  Branch (144:11): [True: 1.68k, False: 1.51k]
  ------------------
  145|  1.68k|        {
  146|  1.68k|          switch (n->pkt->pkttype)
  147|  1.68k|            {
  148|      6|            case PKT_PUBLIC_SUBKEY:
  ------------------
  |  Branch (148:13): [True: 6, False: 1.67k]
  ------------------
  149|     14|            case PKT_SECRET_SUBKEY:
  ------------------
  |  Branch (149:13): [True: 8, False: 1.67k]
  ------------------
  150|  1.09k|            case PKT_USER_ID:
  ------------------
  |  Branch (150:13): [True: 1.07k, False: 603]
  ------------------
  151|  1.09k|            case PKT_ATTRIBUTE:
  ------------------
  |  Branch (151:13): [True: 0, False: 1.68k]
  ------------------
  152|       |              /* Bump the block number so that we only consider
  153|       |               * signatures below the same object as duplicates.  */
  154|  1.09k|              block++;
  155|  1.09k|              break;
  156|    589|            default:
  ------------------
  |  Branch (156:13): [True: 589, False: 1.09k]
  ------------------
  157|    589|              break;
  158|  1.68k|            }
  159|  1.68k|          continue;
  160|  1.68k|        }
  161|  1.51k|      sig = n->pkt->pkt.signature;
  162|  1.51k|      sig->help_counter = block;
  163|  1.51k|      sigs[i++] = n;
  164|  1.51k|    }
  165|    589|  log_assert (i == nsigs);
  166|       |
  167|      0|  qsort (sigs, nsigs, sizeof (sigs[0]), sig_comparison);
  168|       |
  169|    589|  last_i = 0;
  170|  1.51k|  for (i = 1; i < nsigs; i ++)
  ------------------
  |  Branch (170:15): [True: 922, False: 589]
  ------------------
  171|    922|    {
  172|    922|      log_assert (sigs[last_i]);
  173|      0|      log_assert (sigs[last_i]->pkt->pkttype == PKT_SIGNATURE);
  174|      0|      log_assert (sigs[i]);
  175|      0|      log_assert (sigs[i]->pkt->pkttype == PKT_SIGNATURE);
  176|       |
  177|    922|      if (sig_comparison (&sigs[last_i], &sigs[i]) == 0)
  ------------------
  |  Branch (177:11): [True: 34, False: 888]
  ------------------
  178|     34|        {
  179|       |          /* They are the same.  Kill the latter.  */
  180|     34|          if (DBG_PACKET)
  ------------------
  |  |  348|     34|#define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
  |  |  ------------------
  |  |  |  |  331|     34|#define DBG_PACKET_VALUE  1	/* debug packet reading/writing */
  |  |  ------------------
  |  |  |  Branch (348:20): [True: 0, False: 34]
  |  |  ------------------
  ------------------
  181|      0|            {
  182|      0|              sig = sigs[i]->pkt->pkt.signature;
  183|       |
  184|      0|              log_debug ("Signature appears multiple times, "
  185|      0|                         "deleting duplicate:\n");
  186|      0|              log_debug ("  sig: class 0x%x, issuer: %s,"
  187|      0|                         " timestamp: %s (%lld), digest: %02x %02x\n",
  188|      0|                         sig->sig_class, keystr (sig->keyid),
  189|      0|                         isotimestamp (sig->timestamp),
  190|      0|                         (long long) sig->timestamp,
  191|      0|                         sig->digest_start[0], sig->digest_start[1]);
  192|      0|            }
  193|       |
  194|       |          /* Remove sigs[i] from the keyblock.  */
  195|     34|          {
  196|     34|            kbnode_t z, *prevp;
  197|     34|            int to_kill = last_i;
  198|     34|            last_i = i;
  199|       |
  200|    100|            for (prevp = &kb, z = kb; z; prevp = &z->next, z = z->next)
  ------------------
  |  Branch (200:39): [True: 100, False: 0]
  ------------------
  201|    100|              if (z == sigs[to_kill])
  ------------------
  |  Branch (201:19): [True: 34, False: 66]
  ------------------
  202|     34|                break;
  203|       |
  204|     34|            *prevp = sigs[to_kill]->next;
  205|       |
  206|     34|            sigs[to_kill]->next = NULL;
  207|     34|            release_kbnode (sigs[to_kill]);
  208|     34|            sigs[to_kill] = NULL;
  209|       |
  210|     34|            ++*dups;
  211|     34|            *modified = 1;
  212|     34|          }
  213|     34|        }
  214|    888|      else
  215|    888|        last_i = i;
  216|    922|    }
  217|       |
  218|    589|  xfree (sigs);
  ------------------
  |  |  104|    589|#define xfree(a)         gcry_free ((a))
  ------------------
  219|    589|  return 0;
  220|    589|}
key-check.c:sig_comparison:
   60|  3.58k|{
   61|  3.58k|  const KBNODE an = *(const KBNODE *) av;
   62|  3.58k|  const KBNODE bn = *(const KBNODE *) bv;
   63|  3.58k|  const PKT_signature *a;
   64|  3.58k|  const PKT_signature *b;
   65|  3.58k|  int ndataa;
   66|  3.58k|  int ndatab;
   67|  3.58k|  int i;
   68|       |
   69|  3.58k|  log_assert (an->pkt->pkttype == PKT_SIGNATURE);
   70|      0|  log_assert (bn->pkt->pkttype == PKT_SIGNATURE);
   71|       |
   72|      0|  a = an->pkt->pkt.signature;
   73|  3.58k|  b = bn->pkt->pkt.signature;
   74|       |
   75|       |  /* Signatures with a different help counter are not identical for
   76|       |   * our purpose.  */
   77|  3.58k|  if (a->help_counter < b->help_counter)
  ------------------
  |  Branch (77:7): [True: 2.49k, False: 1.08k]
  ------------------
   78|  2.49k|    return -1;
   79|  1.08k|  if (a->help_counter > b->help_counter)
  ------------------
  |  Branch (79:7): [True: 0, False: 1.08k]
  ------------------
   80|      0|    return 1;
   81|       |
   82|  1.08k|  if (a->digest_algo < b->digest_algo)
  ------------------
  |  Branch (82:7): [True: 769, False: 314]
  ------------------
   83|    769|    return -1;
   84|    314|  if (a->digest_algo > b->digest_algo)
  ------------------
  |  Branch (84:7): [True: 246, False: 68]
  ------------------
   85|    246|    return 1;
   86|       |
   87|     68|  ndataa = pubkey_get_nsig (a->pubkey_algo);
   88|     68|  ndatab = pubkey_get_nsig (b->pubkey_algo);
   89|     68|  if (ndataa != ndatab)
  ------------------
  |  Branch (89:7): [True: 0, False: 68]
  ------------------
   90|      0|    return (ndataa < ndatab)? -1 : 1;
  ------------------
  |  Branch (90:12): [True: 0, False: 0]
  ------------------
   91|       |
   92|     68|  for (i = 0; i < ndataa; i ++)
  ------------------
  |  Branch (92:15): [True: 0, False: 68]
  ------------------
   93|      0|    {
   94|      0|      int c = gcry_mpi_cmp (a->data[i], b->data[i]);
   95|      0|      if (c != 0)
  ------------------
  |  Branch (95:11): [True: 0, False: 0]
  ------------------
   96|      0|        return c;
   97|      0|    }
   98|       |
   99|       |  /* Okay, they are equal.  */
  100|     68|  return 0;
  101|     68|}
key-check.c:print_info:
   41|    624|{
   42|    624|  char *p;
   43|       |
   44|    624|  if (!text)
  ------------------
  |  Branch (44:7): [True: 0, False: 624]
  ------------------
   45|      0|    text = "";
   46|    624|  else if ((p = strchr (text,'\n')))
  ------------------
  |  Branch (46:12): [True: 624, False: 0]
  ------------------
   47|    624|    *p = 0; /* Strip LF.  */
   48|       |
   49|    624|   if (mode > 0)
  ------------------
  |  Branch (49:8): [True: 624, False: 0]
  ------------------
   50|    624|     log_info ("%s %s\n", prefix, text);
   51|      0|   else
   52|      0|     tty_fprintf (mode? NULL:es_stdout, "%s %s\n", prefix, text);
  ------------------
  |  Branch (52:19): [True: 0, False: 0]
  ------------------
   53|    624|}

keydb_add_resource:
  561|      1|{
  562|       |  /* The file named by the URL (i.e., without the prototype).  */
  563|      1|  const char *resname = url;
  564|       |
  565|      1|  char *filename = NULL;
  566|      1|  int create;
  567|      1|  int read_only = !!(flags&KEYDB_RESOURCE_FLAG_READONLY);
  ------------------
  |  |  213|      1|#define KEYDB_RESOURCE_FLAG_READONLY 8  /* Open in read only mode.  */
  ------------------
  568|      1|  int is_default = !!(flags&KEYDB_RESOURCE_FLAG_DEFAULT);
  ------------------
  |  |  212|      1|#define KEYDB_RESOURCE_FLAG_DEFAULT  4  /* The default one.  */
  ------------------
  569|      1|  int is_gpgvdef = !!(flags&KEYDB_RESOURCE_FLAG_GPGVDEF);
  ------------------
  |  |  214|      1|#define KEYDB_RESOURCE_FLAG_GPGVDEF 16  /* Default file for gpgv.  */
  ------------------
  570|      1|  gpg_error_t err = 0;
  571|      1|  KeydbResourceType rt = KEYDB_RESOURCE_TYPE_NONE;
  572|      1|  void *token;
  573|       |
  574|       |  /* Create the resource if it is the first registered one.  */
  575|      1|  create = (!read_only && !any_registered);
  ------------------
  |  Branch (575:13): [True: 1, False: 0]
  |  Branch (575:27): [True: 1, False: 0]
  ------------------
  576|       |
  577|      1|  if (strlen (resname) > 11 && !strncmp( resname, "gnupg-ring:", 11) )
  ------------------
  |  Branch (577:7): [True: 0, False: 1]
  |  Branch (577:32): [True: 0, False: 0]
  ------------------
  578|      0|    {
  579|      0|      rt = KEYDB_RESOURCE_TYPE_KEYRING;
  580|      0|      resname += 11;
  581|      0|    }
  582|      1|  else if (strlen (resname) > 10 && !strncmp (resname, "gnupg-kbx:", 10) )
  ------------------
  |  Branch (582:12): [True: 1, False: 0]
  |  Branch (582:37): [True: 0, False: 1]
  ------------------
  583|      0|    {
  584|      0|      rt = KEYDB_RESOURCE_TYPE_KEYBOX;
  585|      0|      resname += 10;
  586|      0|    }
  587|      1|#if !defined(HAVE_DRIVE_LETTERS) && !defined(__riscos__)
  588|      1|  else if (strchr (resname, ':'))
  ------------------
  |  Branch (588:12): [True: 0, False: 1]
  ------------------
  589|      0|    {
  590|      0|      log_error ("invalid key resource URL '%s'\n", url );
  591|      0|      err = gpg_error (GPG_ERR_GENERAL);
  592|      0|      goto leave;
  593|      0|    }
  594|      1|#endif /* !HAVE_DRIVE_LETTERS && !__riscos__ */
  595|       |
  596|      1|  if (*resname != DIRSEP_C
  ------------------
  |  |  886|      1|#define DIRSEP_C '/'
  ------------------
  |  Branch (596:7): [True: 1, False: 0]
  ------------------
  597|       |#ifdef HAVE_W32_SYSTEM
  598|       |      && *resname != '/'  /* Fixme: does not handle drive letters.  */
  599|       |#endif
  600|      1|        )
  601|      1|    {
  602|       |      /* Do tilde expansion etc. */
  603|      1|      if (strchr (resname, DIRSEP_C)
  ------------------
  |  |  886|      1|#define DIRSEP_C '/'
  ------------------
  |  Branch (603:11): [True: 0, False: 1]
  ------------------
  604|       |#ifdef HAVE_W32_SYSTEM
  605|       |          || strchr (resname, '/')  /* Windows also accepts this.  */
  606|       |#endif
  607|      1|          )
  608|      0|        filename = make_filename (resname, NULL);
  609|      1|      else
  610|      1|        filename = make_filename (gnupg_homedir (), resname, NULL);
  611|      1|    }
  612|      0|  else
  613|      0|    filename = xstrdup (resname);
  ------------------
  |  |  112|      0|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
  614|       |
  615|       |  /* See whether we can determine the filetype.  */
  616|      1|  if (rt == KEYDB_RESOURCE_TYPE_NONE)
  ------------------
  |  Branch (616:7): [True: 1, False: 0]
  ------------------
  617|      1|    {
  618|      1|      int found, openpgp_flag;
  619|      1|      int pass = 0;
  620|      1|      size_t filenamelen;
  621|       |
  622|      2|    check_again:
  623|      2|      filenamelen = strlen (filename);
  624|      2|      rt = rt_from_file (filename, &found, &openpgp_flag);
  625|      2|      if (found)
  ------------------
  |  Branch (625:11): [True: 0, False: 2]
  ------------------
  626|      0|        {
  627|       |          /* The file exists and we have the resource type in RT.
  628|       |
  629|       |             Now let us check whether in addition to the "pubring.gpg"
  630|       |             a "pubring.kbx with openpgp keys exists.  This is so that
  631|       |             GPG 2.1 will use an existing "pubring.kbx" by default iff
  632|       |             that file has been created or used by 2.1.  This check is
  633|       |             needed because after creation or use of the kbx file with
  634|       |             2.1 an older version of gpg may have created a new
  635|       |             pubring.gpg for its own use.  */
  636|      0|          if (!pass && is_default && rt == KEYDB_RESOURCE_TYPE_KEYRING
  ------------------
  |  Branch (636:15): [True: 0, False: 0]
  |  Branch (636:24): [True: 0, False: 0]
  |  Branch (636:38): [True: 0, False: 0]
  ------------------
  637|      0|              && filenamelen > 4 && !strcmp (filename+filenamelen-4, ".gpg"))
  ------------------
  |  Branch (637:18): [True: 0, False: 0]
  |  Branch (637:37): [True: 0, False: 0]
  ------------------
  638|      0|            {
  639|      0|              strcpy (filename+filenamelen-4, ".kbx");
  640|      0|              if ((rt_from_file (filename, &found, &openpgp_flag)
  ------------------
  |  Branch (640:19): [True: 0, False: 0]
  ------------------
  641|      0|                   == KEYDB_RESOURCE_TYPE_KEYBOX) && found && openpgp_flag)
  ------------------
  |  Branch (641:54): [True: 0, False: 0]
  |  Branch (641:63): [True: 0, False: 0]
  ------------------
  642|      0|                rt = KEYDB_RESOURCE_TYPE_KEYBOX;
  643|      0|              else /* Restore filename */
  644|      0|                strcpy (filename+filenamelen-4, ".gpg");
  645|      0|            }
  646|      0|	}
  647|      2|      else if (!pass && is_gpgvdef
  ------------------
  |  Branch (647:16): [True: 1, False: 1]
  |  Branch (647:25): [True: 0, False: 1]
  ------------------
  648|      2|               && filenamelen > 4 && !strcmp (filename+filenamelen-4, ".kbx"))
  ------------------
  |  Branch (648:19): [True: 0, False: 0]
  |  Branch (648:38): [True: 0, False: 0]
  ------------------
  649|      0|        {
  650|       |          /* Not found but gpgv's default "trustedkeys.kbx" file has
  651|       |             been requested.  We did not found it so now check whether
  652|       |             a "trustedkeys.gpg" file exists and use that instead.  */
  653|      0|          KeydbResourceType rttmp;
  654|       |
  655|      0|          strcpy (filename+filenamelen-4, ".gpg");
  656|      0|          rttmp = rt_from_file (filename, &found, &openpgp_flag);
  657|      0|          if (found
  ------------------
  |  Branch (657:15): [True: 0, False: 0]
  ------------------
  658|      0|              && ((rttmp == KEYDB_RESOURCE_TYPE_KEYBOX && openpgp_flag)
  ------------------
  |  Branch (658:20): [True: 0, False: 0]
  |  Branch (658:59): [True: 0, False: 0]
  ------------------
  659|      0|                  || (rttmp == KEYDB_RESOURCE_TYPE_KEYRING)))
  ------------------
  |  Branch (659:22): [True: 0, False: 0]
  ------------------
  660|      0|            rt = rttmp;
  661|      0|          else /* Restore filename */
  662|      0|            strcpy (filename+filenamelen-4, ".kbx");
  663|      0|        }
  664|      2|      else if (!pass
  ------------------
  |  Branch (664:16): [True: 1, False: 1]
  ------------------
  665|      2|               && is_default && create
  ------------------
  |  Branch (665:19): [True: 1, False: 0]
  |  Branch (665:33): [True: 1, False: 0]
  ------------------
  666|      2|               && filenamelen > 4 && !strcmp (filename+filenamelen-4, ".gpg"))
  ------------------
  |  Branch (666:19): [True: 1, False: 0]
  |  Branch (666:38): [True: 1, False: 0]
  ------------------
  667|      1|        {
  668|       |          /* The file does not exist, the default resource has been
  669|       |             requested, the file shall be created, and the file has a
  670|       |             ".gpg" suffix.  Change the suffix to ".kbx" and try once
  671|       |             more.  This way we achieve that we open an existing
  672|       |             ".gpg" keyring, but create a new keybox file with an
  673|       |             ".kbx" suffix.  */
  674|      1|          strcpy (filename+filenamelen-4, ".kbx");
  675|      1|          pass++;
  676|      1|          goto check_again;
  677|      1|        }
  678|      1|      else /* No file yet: create keybox. */
  679|      1|        rt = KEYDB_RESOURCE_TYPE_KEYBOX;
  680|      2|    }
  681|       |
  682|      1|  switch (rt)
  683|      1|    {
  684|      0|    case KEYDB_RESOURCE_TYPE_NONE:
  ------------------
  |  Branch (684:5): [True: 0, False: 1]
  ------------------
  685|      0|      log_error ("unknown type of key resource '%s'\n", url );
  686|      0|      err = gpg_error (GPG_ERR_GENERAL);
  687|      0|      goto leave;
  688|       |
  689|      0|    case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (689:5): [True: 0, False: 1]
  ------------------
  690|      0|      err = maybe_create_keyring_or_box (filename, 0, create);
  691|      0|      if (err)
  ------------------
  |  Branch (691:11): [True: 0, False: 0]
  ------------------
  692|      0|        goto leave;
  693|       |
  694|      0|      if (keyring_register_filename (filename, read_only, &token))
  ------------------
  |  Branch (694:11): [True: 0, False: 0]
  ------------------
  695|      0|        {
  696|      0|          if (used_resources >= MAX_KEYDB_RESOURCES)
  ------------------
  |  |   36|      0|#define MAX_KEYDB_RESOURCES 40
  ------------------
  |  Branch (696:15): [True: 0, False: 0]
  ------------------
  697|      0|            err = gpg_error (GPG_ERR_RESOURCE_LIMIT);
  698|      0|          else
  699|      0|            {
  700|      0|              if ((flags & KEYDB_RESOURCE_FLAG_PRIMARY))
  ------------------
  |  |  211|      0|#define KEYDB_RESOURCE_FLAG_PRIMARY  2  /* The primary resource.  */
  ------------------
  |  Branch (700:19): [True: 0, False: 0]
  ------------------
  701|      0|                primary_keydb = token;
  702|      0|              all_resources[used_resources].type = rt;
  703|      0|              all_resources[used_resources].u.kr = NULL; /* Not used here */
  704|      0|              all_resources[used_resources].token = token;
  705|      0|              used_resources++;
  706|      0|            }
  707|      0|        }
  708|      0|      else
  709|      0|        {
  710|       |          /* This keyring was already registered, so ignore it.
  711|       |             However, we can still mark it as primary even if it was
  712|       |             already registered.  */
  713|      0|          if ((flags & KEYDB_RESOURCE_FLAG_PRIMARY))
  ------------------
  |  |  211|      0|#define KEYDB_RESOURCE_FLAG_PRIMARY  2  /* The primary resource.  */
  ------------------
  |  Branch (713:15): [True: 0, False: 0]
  ------------------
  714|      0|            primary_keydb = token;
  715|      0|        }
  716|      0|      break;
  717|       |
  718|      1|    case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (718:5): [True: 1, False: 0]
  ------------------
  719|      1|      {
  720|      1|        err = maybe_create_keyring_or_box (filename, 1, create);
  721|      1|        if (err)
  ------------------
  |  Branch (721:13): [True: 0, False: 1]
  ------------------
  722|      0|          goto leave;
  723|       |
  724|      1|        err = keybox_register_file (filename, 0, &token);
  725|      1|        if (!err)
  ------------------
  |  Branch (725:13): [True: 1, False: 0]
  ------------------
  726|      1|          {
  727|      1|            if (used_resources >= MAX_KEYDB_RESOURCES)
  ------------------
  |  |   36|      1|#define MAX_KEYDB_RESOURCES 40
  ------------------
  |  Branch (727:17): [True: 0, False: 1]
  ------------------
  728|      0|              err = gpg_error (GPG_ERR_RESOURCE_LIMIT);
  729|      1|            else
  730|      1|              {
  731|      1|                KEYBOX_HANDLE kbxhd;
  732|       |
  733|      1|                if ((flags & KEYDB_RESOURCE_FLAG_PRIMARY))
  ------------------
  |  |  211|      1|#define KEYDB_RESOURCE_FLAG_PRIMARY  2  /* The primary resource.  */
  ------------------
  |  Branch (733:21): [True: 0, False: 1]
  ------------------
  734|      0|                  primary_keydb = token;
  735|      1|                all_resources[used_resources].type = rt;
  736|      1|                all_resources[used_resources].u.kb = NULL; /* Not used here */
  737|      1|                all_resources[used_resources].token = token;
  738|       |
  739|       |                /* Do a compress run if needed and no other user is
  740|       |                 * currently using the keybox. */
  741|      1|                kbxhd = keybox_new_openpgp (token, 0);
  742|      1|                if (kbxhd)
  ------------------
  |  Branch (742:21): [True: 1, False: 0]
  ------------------
  743|      1|                  {
  744|      1|                    if (!keybox_lock (kbxhd, 1, 0))
  ------------------
  |  Branch (744:25): [True: 1, False: 0]
  ------------------
  745|      1|                      {
  746|      1|                        keybox_compress (kbxhd);
  747|      1|                        keybox_lock (kbxhd, 0, 0);
  748|      1|                      }
  749|       |
  750|      1|                    keybox_release (kbxhd);
  751|      1|                  }
  752|       |
  753|      1|                used_resources++;
  754|      1|              }
  755|      1|          }
  756|      0|        else if (gpg_err_code (err) == GPG_ERR_EEXIST)
  ------------------
  |  Branch (756:18): [True: 0, False: 0]
  ------------------
  757|      0|          {
  758|       |            /* Already registered.  We will mark it as the primary key
  759|       |               if requested.  */
  760|      0|            if ((flags & KEYDB_RESOURCE_FLAG_PRIMARY))
  ------------------
  |  |  211|      0|#define KEYDB_RESOURCE_FLAG_PRIMARY  2  /* The primary resource.  */
  ------------------
  |  Branch (760:17): [True: 0, False: 0]
  ------------------
  761|      0|              primary_keydb = token;
  762|      0|          }
  763|      1|      }
  764|      0|      break;
  765|       |
  766|      0|      default:
  ------------------
  |  Branch (766:7): [True: 0, False: 1]
  ------------------
  767|      0|	log_error ("resource type of '%s' not supported\n", url);
  768|      0|	err = gpg_error (GPG_ERR_GENERAL);
  769|      0|	goto leave;
  770|      1|    }
  771|       |
  772|       |  /* fixme: check directory permissions and print a warning */
  773|       |
  774|      1| leave:
  775|      1|  if (err)
  ------------------
  |  Branch (775:7): [True: 0, False: 1]
  ------------------
  776|      0|    {
  777|      0|      log_error (_("keyblock resource '%s': %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  778|      0|                 filename, gpg_strerror (err));
  779|      0|      write_status_error ("add_keyblock_resource", err);
  780|      0|    }
  781|      1|  else
  782|      1|    any_registered = 1;
  783|      1|  xfree (filename);
  ------------------
  |  |  104|      1|#define xfree(a)         gcry_free ((a))
  ------------------
  784|      1|  return err;
  785|      1|}
internal_keydb_init:
  818|    379|{
  819|    379|  gpg_error_t err = 0;
  820|    379|  int i, j;
  821|    379|  int die = 0;
  822|    379|  int reterrno;
  823|       |
  824|    379|  log_assert (!hd->use_keyboxd);
  825|      0|  hd->found = -1;
  826|    379|  hd->saved_found = -1;
  827|    379|  hd->is_reset = 1;
  828|       |
  829|    379|  log_assert (used_resources <= MAX_KEYDB_RESOURCES);
  830|    758|  for (i=j=0; ! die && i < used_resources; i++)
  ------------------
  |  Branch (830:15): [True: 758, False: 0]
  |  Branch (830:24): [True: 379, False: 379]
  ------------------
  831|    379|    {
  832|    379|      switch (all_resources[i].type)
  ------------------
  |  Branch (832:15): [True: 0, False: 379]
  ------------------
  833|    379|        {
  834|      0|        case KEYDB_RESOURCE_TYPE_NONE: /* ignore */
  ------------------
  |  Branch (834:9): [True: 0, False: 379]
  ------------------
  835|      0|          break;
  836|      0|        case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (836:9): [True: 0, False: 379]
  ------------------
  837|      0|          hd->active[j].type   = all_resources[i].type;
  838|      0|          hd->active[j].token  = all_resources[i].token;
  839|      0|          hd->active[j].u.kr = keyring_new (all_resources[i].token);
  840|      0|          if (!hd->active[j].u.kr)
  ------------------
  |  Branch (840:15): [True: 0, False: 0]
  ------------------
  841|      0|            {
  842|      0|              reterrno = errno;
  843|      0|              die = 1;
  844|      0|            }
  845|      0|          j++;
  846|      0|          break;
  847|    379|        case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (847:9): [True: 379, False: 0]
  ------------------
  848|    379|          hd->active[j].type   = all_resources[i].type;
  849|    379|          hd->active[j].token  = all_resources[i].token;
  850|    379|          hd->active[j].u.kb   = keybox_new_openpgp (all_resources[i].token, 0);
  851|    379|          if (!hd->active[j].u.kb)
  ------------------
  |  Branch (851:15): [True: 0, False: 379]
  ------------------
  852|      0|            {
  853|      0|              reterrno = errno;
  854|      0|              die = 1;
  855|      0|            }
  856|    379|          j++;
  857|    379|          break;
  858|    379|        }
  859|    379|    }
  860|    379|  hd->used = j;
  861|       |
  862|    379|  active_handles++;
  863|    379|  keydb_stats.handles++;
  864|       |
  865|    379|  if (die)
  ------------------
  |  Branch (865:7): [True: 0, False: 379]
  ------------------
  866|      0|    err = gpg_error_from_errno (reterrno);
  867|       |
  868|    379|   return err;
  869|    379|}
internal_keydb_deinit:
  876|    379|{
  877|    379|  int i;
  878|       |
  879|    379|  log_assert (!hd->use_keyboxd);
  880|       |
  881|      0|  log_assert (active_handles > 0);
  882|      0|  active_handles--;
  883|       |
  884|    379|  hd->keep_lock = 0;
  885|    379|  unlock_all (hd);
  886|    758|  for (i=0; i < hd->used; i++)
  ------------------
  |  Branch (886:13): [True: 379, False: 379]
  ------------------
  887|    379|    {
  888|    379|      switch (hd->active[i].type)
  ------------------
  |  Branch (888:15): [True: 0, False: 379]
  ------------------
  889|    379|        {
  890|      0|        case KEYDB_RESOURCE_TYPE_NONE:
  ------------------
  |  Branch (890:9): [True: 0, False: 379]
  ------------------
  891|      0|          break;
  892|      0|        case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (892:9): [True: 0, False: 379]
  ------------------
  893|      0|          keyring_release (hd->active[i].u.kr);
  894|      0|          break;
  895|    379|        case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (895:9): [True: 379, False: 0]
  ------------------
  896|    379|          keybox_release (hd->active[i].u.kb);
  897|    379|          break;
  898|    379|        }
  899|    379|    }
  900|       |
  901|    379|  keyblock_cache_clear (hd);
  902|    379|}
internal_keydb_lock:
  909|     11|{
  910|     11|  gpg_error_t err;
  911|       |
  912|     11|  log_assert (!hd->use_keyboxd);
  913|       |
  914|      0|  err = lock_all (hd);
  915|     11|  if (!err)
  ------------------
  |  Branch (915:7): [True: 11, False: 0]
  ------------------
  916|     11|    hd->keep_lock = 1;
  917|       |
  918|     11|  return err;
  919|     11|}
keydb_disable_caching:
  927|     11|{
  928|     11|  if (hd && !hd->use_keyboxd)
  ------------------
  |  Branch (928:7): [True: 11, False: 0]
  |  Branch (928:13): [True: 11, False: 0]
  ------------------
  929|     11|    hd->no_caching = 1;
  930|     11|}
keydb_parse_keyblock:
 1141|     24|{
 1142|     24|  gpg_error_t err;
 1143|     24|  struct parse_packet_ctx_s parsectx;
 1144|     24|  PACKET *pkt;
 1145|     24|  kbnode_t keyblock = NULL;
 1146|     24|  kbnode_t node, *tail;
 1147|     24|  int in_cert, save_mode;
 1148|     24|  int pk_count, uid_count;
 1149|       |
 1150|     24|  *r_keyblock = NULL;
 1151|       |
 1152|     24|  pkt = xtrymalloc (sizeof *pkt);
  ------------------
  |  |   97|     24|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
 1153|     24|  if (!pkt)
  ------------------
  |  Branch (1153:7): [True: 0, False: 24]
  ------------------
 1154|      0|    return gpg_error_from_syserror ();
 1155|     24|  init_packet (pkt);
  ------------------
  |  |  581|     24|#define init_packet(a) do { (a)->pkttype = 0;		\
  |  |  582|     24|			    (a)->pkt.generic = NULL;	\
  |  |  583|     24|		       } while(0)
  |  |  ------------------
  |  |  |  Branch (583:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1156|     24|  init_parse_packet (&parsectx, iobuf);
  ------------------
  |  |  666|     24|#define init_parse_packet(a,i) do { \
  |  |  667|     24|    (a)->inp = (i);                 \
  |  |  668|     24|    (a)->last_pkt.pkttype = 0;      \
  |  |  669|     24|    (a)->last_pkt.pkt.generic= NULL;\
  |  |  670|     24|    (a)->free_last_pkt = 0;         \
  |  |  671|     24|    (a)->skip_meta = 0;             \
  |  |  672|     24|    (a)->n_parsed_packets = 0;      \
  |  |  673|     24|  } while (0)
  |  |  ------------------
  |  |  |  Branch (673:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1157|     24|  save_mode = set_packet_list_mode (0);
 1158|     24|  in_cert = 0;
 1159|     24|  tail = NULL;
 1160|     24|  pk_count = uid_count = 0;
 1161|    204|  while ((err = parse_packet (&parsectx, pkt)) != -1)
  ------------------
  |  |  697|    204|	     dbg_parse_packet( (a), (b), __FILE__, __LINE__ )
  ------------------
  |  Branch (1161:10): [True: 180, False: 24]
  ------------------
 1162|    180|    {
 1163|    180|      if (gpg_err_code (err) == GPG_ERR_UNKNOWN_PACKET)
  ------------------
  |  Branch (1163:11): [True: 0, False: 180]
  ------------------
 1164|      0|        {
 1165|      0|          free_packet (pkt, &parsectx);
 1166|      0|          init_packet (pkt);
  ------------------
  |  |  581|      0|#define init_packet(a) do { (a)->pkttype = 0;		\
  |  |  582|      0|			    (a)->pkt.generic = NULL;	\
  |  |  583|      0|		       } while(0)
  |  |  ------------------
  |  |  |  Branch (583:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1167|      0|          continue;
 1168|      0|	}
 1169|    180|      if (err)
  ------------------
  |  Branch (1169:11): [True: 0, False: 180]
  ------------------
 1170|      0|        {
 1171|      0|          es_fflush (es_stdout);
 1172|      0|          log_error ("parse_keyblock_image: read error: %s\n",
 1173|      0|                     gpg_strerror (err));
 1174|      0|          if (gpg_err_code (err) == GPG_ERR_INV_PACKET)
  ------------------
  |  Branch (1174:15): [True: 0, False: 0]
  ------------------
 1175|      0|            {
 1176|      0|              free_packet (pkt, &parsectx);
 1177|      0|              init_packet (pkt);
  ------------------
  |  |  581|      0|#define init_packet(a) do { (a)->pkttype = 0;		\
  |  |  582|      0|			    (a)->pkt.generic = NULL;	\
  |  |  583|      0|		       } while(0)
  |  |  ------------------
  |  |  |  Branch (583:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1178|      0|              continue;
 1179|      0|            }
 1180|      0|          err = gpg_error (GPG_ERR_INV_KEYRING);
 1181|      0|          break;
 1182|      0|        }
 1183|       |
 1184|       |      /* Filter allowed packets.  */
 1185|    180|      switch (pkt->pkttype)
 1186|    180|        {
 1187|     24|        case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (1187:9): [True: 24, False: 156]
  ------------------
 1188|     32|        case PKT_PUBLIC_SUBKEY:
  ------------------
  |  Branch (1188:9): [True: 8, False: 172]
  ------------------
 1189|     32|        case PKT_SECRET_KEY:
  ------------------
  |  Branch (1189:9): [True: 0, False: 180]
  ------------------
 1190|     32|        case PKT_SECRET_SUBKEY:
  ------------------
  |  Branch (1190:9): [True: 0, False: 180]
  ------------------
 1191|     56|        case PKT_USER_ID:
  ------------------
  |  Branch (1191:9): [True: 24, False: 156]
  ------------------
 1192|     56|        case PKT_ATTRIBUTE:
  ------------------
  |  Branch (1192:9): [True: 0, False: 180]
  ------------------
 1193|    180|        case PKT_SIGNATURE:
  ------------------
  |  Branch (1193:9): [True: 124, False: 56]
  ------------------
 1194|    180|        case PKT_RING_TRUST:
  ------------------
  |  Branch (1194:9): [True: 0, False: 180]
  ------------------
 1195|    180|          break; /* Allowed per RFC.  */
 1196|       |
 1197|      0|        default:
  ------------------
  |  Branch (1197:9): [True: 0, False: 180]
  ------------------
 1198|      0|          log_info ("skipped packet of type %d in keybox\n", (int)pkt->pkttype);
 1199|      0|          free_packet(pkt, &parsectx);
 1200|      0|          init_packet(pkt);
  ------------------
  |  |  581|      0|#define init_packet(a) do { (a)->pkttype = 0;		\
  |  |  582|      0|			    (a)->pkt.generic = NULL;	\
  |  |  583|      0|		       } while(0)
  |  |  ------------------
  |  |  |  Branch (583:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1201|      0|          continue;
 1202|    180|        }
 1203|       |
 1204|       |      /* Other sanity checks.  */
 1205|    180|      if (!in_cert && pkt->pkttype != PKT_PUBLIC_KEY)
  ------------------
  |  Branch (1205:11): [True: 24, False: 156]
  |  Branch (1205:23): [True: 0, False: 24]
  ------------------
 1206|      0|        {
 1207|      0|          log_error ("parse_keyblock_image: first packet in a keybox blob "
 1208|      0|                     "is not a public key packet\n");
 1209|      0|          err = gpg_error (GPG_ERR_INV_KEYRING);
 1210|      0|          break;
 1211|      0|        }
 1212|    180|      if (in_cert && (pkt->pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (1212:11): [True: 156, False: 24]
  |  Branch (1212:23): [True: 0, False: 156]
  ------------------
 1213|    156|                      || pkt->pkttype == PKT_SECRET_KEY))
  ------------------
  |  Branch (1213:26): [True: 0, False: 156]
  ------------------
 1214|      0|        {
 1215|      0|          log_error ("parse_keyblock_image: "
 1216|      0|                     "multiple keyblocks in a keybox blob\n");
 1217|      0|          err = gpg_error (GPG_ERR_INV_KEYRING);
 1218|      0|          break;
 1219|      0|        }
 1220|    180|      in_cert = 1;
 1221|       |
 1222|    180|      node = new_kbnode (pkt);
 1223|       |
 1224|    180|      switch (pkt->pkttype)
 1225|    180|        {
 1226|     24|        case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (1226:9): [True: 24, False: 156]
  ------------------
 1227|     32|        case PKT_PUBLIC_SUBKEY:
  ------------------
  |  Branch (1227:9): [True: 8, False: 172]
  ------------------
 1228|     32|        case PKT_SECRET_KEY:
  ------------------
  |  Branch (1228:9): [True: 0, False: 180]
  ------------------
 1229|     32|        case PKT_SECRET_SUBKEY:
  ------------------
  |  Branch (1229:9): [True: 0, False: 180]
  ------------------
 1230|     32|          if (++pk_count == pk_no)
  ------------------
  |  Branch (1230:15): [True: 24, False: 8]
  ------------------
 1231|     24|            node->flag |= 1;
 1232|     32|          break;
 1233|       |
 1234|     24|        case PKT_USER_ID:
  ------------------
  |  Branch (1234:9): [True: 24, False: 156]
  ------------------
 1235|     24|          if (++uid_count == uid_no)
  ------------------
  |  Branch (1235:15): [True: 0, False: 24]
  ------------------
 1236|      0|            node->flag |= 2;
 1237|     24|          break;
 1238|       |
 1239|    124|        default:
  ------------------
  |  Branch (1239:9): [True: 124, False: 56]
  ------------------
 1240|    124|          break;
 1241|    180|        }
 1242|       |
 1243|    180|      if (!keyblock)
  ------------------
  |  Branch (1243:11): [True: 24, False: 156]
  ------------------
 1244|     24|        keyblock = node;
 1245|    156|      else
 1246|    156|        *tail = node;
 1247|    180|      tail = &node->next;
 1248|    180|      pkt = xtrymalloc (sizeof *pkt);
  ------------------
  |  |   97|    180|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
 1249|    180|      if (!pkt)
  ------------------
  |  Branch (1249:11): [True: 0, False: 180]
  ------------------
 1250|      0|        {
 1251|      0|          err = gpg_error_from_syserror ();
 1252|      0|          break;
 1253|      0|        }
 1254|    180|      init_packet (pkt);
  ------------------
  |  |  581|    180|#define init_packet(a) do { (a)->pkttype = 0;		\
  |  |  582|    180|			    (a)->pkt.generic = NULL;	\
  |  |  583|    180|		       } while(0)
  |  |  ------------------
  |  |  |  Branch (583:18): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1255|    180|    }
 1256|     24|  set_packet_list_mode (save_mode);
 1257|       |
 1258|     24|  if (err == -1 && keyblock)
  ------------------
  |  Branch (1258:7): [True: 24, False: 0]
  |  Branch (1258:20): [True: 24, False: 0]
  ------------------
 1259|     24|    err = 0; /* Got the entire keyblock.  */
 1260|       |
 1261|     24|  if (err)
  ------------------
  |  Branch (1261:7): [True: 0, False: 24]
  ------------------
 1262|      0|    release_kbnode (keyblock);
 1263|     24|  else
 1264|     24|    {
 1265|     24|      *r_keyblock = keyblock;
 1266|     24|      keydb_stats.parse_keyblocks++;
 1267|     24|    }
 1268|     24|  free_packet (pkt, &parsectx);
 1269|     24|  deinit_parse_packet (&parsectx);
  ------------------
  |  |  675|     24|#define deinit_parse_packet(a) do { \
  |  |  676|     24|    if ((a)->free_last_pkt)         \
  |  |  ------------------
  |  |  |  Branch (676:9): [True: 0, False: 24]
  |  |  ------------------
  |  |  677|     24|      free_packet (NULL, (a));      \
  |  |  678|     24|  } while (0)
  |  |  ------------------
  |  |  |  Branch (678:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1270|     24|  xfree (pkt);
  ------------------
  |  |  104|     24|#define xfree(a)         gcry_free ((a))
  ------------------
 1271|     24|  return err;
 1272|     24|}
internal_keydb_get_keyblock:
 1287|     24|{
 1288|     24|  gpg_error_t err = 0;
 1289|       |
 1290|     24|  log_assert (!hd->use_keyboxd);
 1291|       |
 1292|     24|  if (hd->keyblock_cache.state == KEYBLOCK_CACHE_FILLED)
  ------------------
  |  Branch (1292:7): [True: 0, False: 24]
  ------------------
 1293|      0|    {
 1294|      0|      err = iobuf_seek (hd->keyblock_cache.iobuf, 0);
 1295|      0|      if (err)
  ------------------
  |  Branch (1295:11): [True: 0, False: 0]
  ------------------
 1296|      0|	{
 1297|      0|	  log_error ("keydb_get_keyblock: failed to rewind iobuf for cache\n");
 1298|      0|	  keyblock_cache_clear (hd);
 1299|      0|	}
 1300|      0|      else
 1301|      0|	{
 1302|      0|	  err = keydb_parse_keyblock (hd->keyblock_cache.iobuf,
 1303|      0|				      hd->keyblock_cache.pk_no,
 1304|      0|				      hd->keyblock_cache.uid_no,
 1305|      0|				      ret_kb);
 1306|      0|	  if (err)
  ------------------
  |  Branch (1306:8): [True: 0, False: 0]
  ------------------
 1307|      0|	    keyblock_cache_clear (hd);
 1308|      0|	  if (DBG_CLOCK)
  ------------------
  |  |  356|      0|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|      0|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1309|      0|	    log_clock ("%s leave (cached mode)", __func__);
 1310|      0|	  return err;
 1311|      0|	}
 1312|      0|    }
 1313|       |
 1314|     24|  if (hd->found < 0 || hd->found >= hd->used)
  ------------------
  |  Branch (1314:7): [True: 0, False: 24]
  |  Branch (1314:24): [True: 0, False: 24]
  ------------------
 1315|      0|    return gpg_error (GPG_ERR_VALUE_NOT_FOUND);
 1316|       |
 1317|     24|  switch (hd->active[hd->found].type)
  ------------------
  |  Branch (1317:11): [True: 0, False: 24]
  ------------------
 1318|     24|    {
 1319|      0|    case KEYDB_RESOURCE_TYPE_NONE:
  ------------------
  |  Branch (1319:5): [True: 0, False: 24]
  ------------------
 1320|      0|      err = gpg_error (GPG_ERR_GENERAL); /* oops */
 1321|      0|      break;
 1322|      0|    case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (1322:5): [True: 0, False: 24]
  ------------------
 1323|      0|      err = keyring_get_keyblock (hd->active[hd->found].u.kr, ret_kb);
 1324|      0|      break;
 1325|     24|    case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (1325:5): [True: 24, False: 0]
  ------------------
 1326|     24|      {
 1327|     24|        iobuf_t iobuf;
 1328|     24|        int pk_no, uid_no;
 1329|       |
 1330|     24|        err = keybox_get_keyblock (hd->active[hd->found].u.kb,
 1331|     24|                                   &iobuf, &pk_no, &uid_no);
 1332|     24|        if (!err)
  ------------------
  |  Branch (1332:13): [True: 24, False: 0]
  ------------------
 1333|     24|          {
 1334|     24|            err = keydb_parse_keyblock (iobuf, pk_no, uid_no, ret_kb);
 1335|     24|            if (!err && hd->keyblock_cache.state == KEYBLOCK_CACHE_PREPARED)
  ------------------
  |  Branch (1335:17): [True: 24, False: 0]
  |  Branch (1335:25): [True: 4, False: 20]
  ------------------
 1336|      4|              {
 1337|      4|                hd->keyblock_cache.state     = KEYBLOCK_CACHE_FILLED;
 1338|      4|                hd->keyblock_cache.iobuf     = iobuf;
 1339|      4|                hd->keyblock_cache.pk_no     = pk_no;
 1340|      4|                hd->keyblock_cache.uid_no    = uid_no;
 1341|      4|              }
 1342|     20|            else
 1343|     20|              {
 1344|     20|                iobuf_close (iobuf);
 1345|     20|              }
 1346|     24|          }
 1347|     24|      }
 1348|     24|      break;
 1349|     24|    }
 1350|       |
 1351|     24|  if (hd->keyblock_cache.state != KEYBLOCK_CACHE_FILLED)
  ------------------
  |  Branch (1351:7): [True: 20, False: 4]
  ------------------
 1352|     20|    keyblock_cache_clear (hd);
 1353|       |
 1354|     24|  if (!err)
  ------------------
  |  Branch (1354:7): [True: 24, False: 0]
  ------------------
 1355|     24|    keydb_stats.get_keyblocks++;
 1356|       |
 1357|     24|  return err;
 1358|     24|}
internal_keydb_update_keyblock:
 1379|      9|{
 1380|      9|  gpg_error_t err;
 1381|      9|  PKT_public_key *pk;
 1382|      9|  KEYDB_SEARCH_DESC desc;
 1383|      9|  size_t len;
 1384|       |
 1385|      9|  log_assert (!hd->use_keyboxd);
 1386|      0|  pk = kb->pkt->pkt.public_key;
 1387|       |
 1388|      9|  kid_not_found_flush ();
 1389|      9|  keyblock_cache_clear (hd);
 1390|       |
 1391|      9|  if (opt.dry_run)
  ------------------
  |  Branch (1391:7): [True: 0, False: 9]
  ------------------
 1392|      0|    return 0;
 1393|       |
 1394|      9|  err = lock_all (hd);
 1395|      9|  if (err)
  ------------------
  |  Branch (1395:7): [True: 0, False: 9]
  ------------------
 1396|      0|    return err;
 1397|       |
 1398|       |#ifdef USE_TOFU
 1399|       |  tofu_notice_key_changed (ctrl, kb);
 1400|       |#endif
 1401|       |
 1402|      9|  memset (&desc, 0, sizeof (desc));
 1403|      9|  fingerprint_from_pk (pk, desc.u.fpr, &len);
 1404|      9|  if (len == 20 || len == 32)
  ------------------
  |  Branch (1404:7): [True: 9, False: 0]
  |  Branch (1404:20): [True: 0, False: 0]
  ------------------
 1405|      9|    {
 1406|      9|      desc.mode = KEYDB_SEARCH_MODE_FPR;
 1407|      9|      desc.fprlen = len;
 1408|      9|    }
 1409|      0|  else
 1410|      0|    log_bug ("%s: Unsupported key length: %zu\n", __func__, len);
 1411|       |
 1412|      9|  keydb_search_reset (hd);
 1413|      9|  err = keydb_search (hd, &desc, 1, NULL);
 1414|      9|  if (err)
  ------------------
  |  Branch (1414:7): [True: 0, False: 9]
  ------------------
 1415|      0|    return gpg_error (GPG_ERR_VALUE_NOT_FOUND);
 1416|      9|  log_assert (hd->found >= 0 && hd->found < hd->used);
 1417|       |
 1418|      0|  switch (hd->active[hd->found].type)
  ------------------
  |  Branch (1418:11): [True: 0, False: 9]
  ------------------
 1419|      9|    {
 1420|      0|    case KEYDB_RESOURCE_TYPE_NONE:
  ------------------
  |  Branch (1420:5): [True: 0, False: 9]
  ------------------
 1421|      0|      err = gpg_error (GPG_ERR_GENERAL); /* oops */
 1422|      0|      break;
 1423|      0|    case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (1423:5): [True: 0, False: 9]
  ------------------
 1424|      0|      err = keyring_update_keyblock (hd->active[hd->found].u.kr, kb);
 1425|      0|      break;
 1426|      9|    case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (1426:5): [True: 9, False: 0]
  ------------------
 1427|      9|      {
 1428|      9|        iobuf_t iobuf;
 1429|       |
 1430|      9|        err = build_keyblock_image (kb, &iobuf);
 1431|      9|        if (!err)
  ------------------
  |  Branch (1431:13): [True: 9, False: 0]
  ------------------
 1432|      9|          {
 1433|      9|            keydb_stats.build_keyblocks++;
 1434|      9|            err = keybox_update_keyblock (hd->active[hd->found].u.kb,
 1435|      9|                                          iobuf_get_temp_buffer (iobuf),
  ------------------
  |  |  637|      9|#define iobuf_get_temp_buffer(a) ( (a)->d.buf )
  ------------------
 1436|      9|                                          iobuf_get_temp_length (iobuf));
  ------------------
  |  |  638|      9|#define iobuf_get_temp_length(a) ( (a)->d.len )
  ------------------
 1437|      9|            iobuf_close (iobuf);
 1438|      9|          }
 1439|      9|      }
 1440|      9|      break;
 1441|      9|    }
 1442|       |
 1443|      9|  unlock_all (hd);
 1444|      9|  if (!err)
  ------------------
  |  Branch (1444:7): [True: 9, False: 0]
  ------------------
 1445|      9|    keydb_stats.update_keyblocks++;
 1446|      9|  return err;
 1447|      9|}
internal_keydb_insert_keyblock:
 1463|      2|{
 1464|      2|  gpg_error_t err;
 1465|      2|  int idx;
 1466|       |
 1467|      2|  log_assert (!hd->use_keyboxd);
 1468|       |
 1469|      0|  kid_not_found_flush ();
 1470|      2|  keyblock_cache_clear (hd);
 1471|       |
 1472|      2|  if (opt.dry_run)
  ------------------
  |  Branch (1472:7): [True: 0, False: 2]
  ------------------
 1473|      0|    return 0;
 1474|       |
 1475|      2|  if (hd->found >= 0 && hd->found < hd->used)
  ------------------
  |  Branch (1475:7): [True: 0, False: 2]
  |  Branch (1475:25): [True: 0, False: 0]
  ------------------
 1476|      0|    idx = hd->found;
 1477|      2|  else if (hd->current >= 0 && hd->current < hd->used)
  ------------------
  |  Branch (1477:12): [True: 2, False: 0]
  |  Branch (1477:32): [True: 2, False: 0]
  ------------------
 1478|      2|    idx = hd->current;
 1479|      0|  else
 1480|      0|    return gpg_error (GPG_ERR_GENERAL);
 1481|       |
 1482|      2|  err = lock_all (hd);
 1483|      2|  if (err)
  ------------------
  |  Branch (1483:7): [True: 0, False: 2]
  ------------------
 1484|      0|    return err;
 1485|       |
 1486|      2|  switch (hd->active[idx].type)
  ------------------
  |  Branch (1486:11): [True: 0, False: 2]
  ------------------
 1487|      2|    {
 1488|      0|    case KEYDB_RESOURCE_TYPE_NONE:
  ------------------
  |  Branch (1488:5): [True: 0, False: 2]
  ------------------
 1489|      0|      err = gpg_error (GPG_ERR_GENERAL); /* oops */
 1490|      0|      break;
 1491|      0|    case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (1491:5): [True: 0, False: 2]
  ------------------
 1492|      0|      err = keyring_insert_keyblock (hd->active[idx].u.kr, kb);
 1493|      0|      break;
 1494|      2|    case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (1494:5): [True: 2, False: 0]
  ------------------
 1495|      2|      { /* We need to turn our kbnode_t list of packets into a proper
 1496|       |           keyblock first.  This is required by the OpenPGP key parser
 1497|       |           included in the keybox code.  Eventually we can change this
 1498|       |           kludge to have the caller pass the image.  */
 1499|      2|        iobuf_t iobuf;
 1500|       |
 1501|      2|        err = build_keyblock_image (kb, &iobuf);
 1502|      2|        if (!err)
  ------------------
  |  Branch (1502:13): [True: 2, False: 0]
  ------------------
 1503|      2|          {
 1504|      2|            keydb_stats.build_keyblocks++;
 1505|      2|            err = keybox_insert_keyblock (hd->active[idx].u.kb,
 1506|      2|                                          iobuf_get_temp_buffer (iobuf),
  ------------------
  |  |  637|      2|#define iobuf_get_temp_buffer(a) ( (a)->d.buf )
  ------------------
 1507|      2|                                          iobuf_get_temp_length (iobuf));
  ------------------
  |  |  638|      2|#define iobuf_get_temp_length(a) ( (a)->d.len )
  ------------------
 1508|      2|            iobuf_close (iobuf);
 1509|      2|          }
 1510|      2|      }
 1511|      2|      break;
 1512|      2|    }
 1513|       |
 1514|      2|  unlock_all (hd);
 1515|      2|  if (!err)
  ------------------
  |  Branch (1515:7): [True: 2, False: 0]
  ------------------
 1516|      2|    keydb_stats.insert_keyblocks++;
 1517|      2|  return err;
 1518|      2|}
keydb_locate_writable:
 1578|      2|{
 1579|      2|  gpg_error_t rc;
 1580|       |
 1581|      2|  if (!hd)
  ------------------
  |  Branch (1581:7): [True: 0, False: 2]
  ------------------
 1582|      0|    return GPG_ERR_INV_ARG;
 1583|       |
 1584|      2|  if (hd->use_keyboxd)
  ------------------
  |  Branch (1584:7): [True: 0, False: 2]
  ------------------
 1585|      0|    return 0;  /* No need for this here.  */
 1586|       |
 1587|      2|  rc = keydb_search_reset (hd); /* this does reset hd->current */
 1588|      2|  if (rc)
  ------------------
  |  Branch (1588:7): [True: 0, False: 2]
  ------------------
 1589|      0|    return rc;
 1590|       |
 1591|       |  /* If we have a primary set, try that one first */
 1592|      2|  if (primary_keydb)
  ------------------
  |  Branch (1592:7): [True: 0, False: 2]
  ------------------
 1593|      0|    {
 1594|      0|      for ( ; hd->current >= 0 && hd->current < hd->used; hd->current++)
  ------------------
  |  Branch (1594:15): [True: 0, False: 0]
  |  Branch (1594:35): [True: 0, False: 0]
  ------------------
 1595|      0|	{
 1596|      0|	  if(hd->active[hd->current].token == primary_keydb)
  ------------------
  |  Branch (1596:7): [True: 0, False: 0]
  ------------------
 1597|      0|	    {
 1598|      0|	      if(keyring_is_writable (hd->active[hd->current].token))
  ------------------
  |  Branch (1598:11): [True: 0, False: 0]
  ------------------
 1599|      0|		return 0;
 1600|      0|	      else
 1601|      0|		break;
 1602|      0|	    }
 1603|      0|	}
 1604|       |
 1605|      0|      rc = keydb_search_reset (hd); /* this does reset hd->current */
 1606|      0|      if (rc)
  ------------------
  |  Branch (1606:11): [True: 0, False: 0]
  ------------------
 1607|      0|	return rc;
 1608|      0|    }
 1609|       |
 1610|      2|  for ( ; hd->current >= 0 && hd->current < hd->used; hd->current++)
  ------------------
  |  Branch (1610:11): [True: 2, False: 0]
  |  Branch (1610:31): [True: 2, False: 0]
  ------------------
 1611|      2|    {
 1612|      2|      switch (hd->active[hd->current].type)
  ------------------
  |  Branch (1612:15): [True: 0, False: 2]
  ------------------
 1613|      2|        {
 1614|      0|        case KEYDB_RESOURCE_TYPE_NONE:
  ------------------
  |  Branch (1614:9): [True: 0, False: 2]
  ------------------
 1615|      0|          BUG();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1616|      0|          break;
 1617|      0|        case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (1617:9): [True: 0, False: 2]
  ------------------
 1618|      0|          if (keyring_is_writable (hd->active[hd->current].token))
  ------------------
  |  Branch (1618:15): [True: 0, False: 0]
  ------------------
 1619|      0|            return 0; /* found (hd->current is set to it) */
 1620|      0|          break;
 1621|      2|        case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (1621:9): [True: 2, False: 0]
  ------------------
 1622|      2|          if (keybox_is_writable (hd->active[hd->current].token))
  ------------------
  |  Branch (1622:15): [True: 2, False: 0]
  ------------------
 1623|      2|            return 0; /* found (hd->current is set to it) */
 1624|      0|          break;
 1625|      2|        }
 1626|      2|    }
 1627|       |
 1628|      0|  return gpg_error (GPG_ERR_NOT_FOUND);
 1629|      2|}
keydb_rebuild_caches:
 1635|      2|{
 1636|      2|  int i, rc;
 1637|       |
 1638|      2|  if (opt.use_keyboxd)
  ------------------
  |  Branch (1638:7): [True: 0, False: 2]
  ------------------
 1639|      0|    return;  /* No need for this here.  */
 1640|       |
 1641|      4|  for (i=0; i < used_resources; i++)
  ------------------
  |  Branch (1641:13): [True: 2, False: 2]
  ------------------
 1642|      2|    {
 1643|      2|      if (!keyring_is_writable (all_resources[i].token))
  ------------------
  |  Branch (1643:11): [True: 2, False: 0]
  ------------------
 1644|      2|        continue;
 1645|      0|      switch (all_resources[i].type)
  ------------------
  |  Branch (1645:15): [True: 0, False: 0]
  ------------------
 1646|      0|        {
 1647|      0|        case KEYDB_RESOURCE_TYPE_NONE: /* ignore */
  ------------------
  |  Branch (1647:9): [True: 0, False: 0]
  ------------------
 1648|      0|          break;
 1649|      0|        case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (1649:9): [True: 0, False: 0]
  ------------------
 1650|      0|          rc = keyring_rebuild_cache (ctrl, all_resources[i].token,noisy);
 1651|      0|          if (rc)
  ------------------
  |  Branch (1651:15): [True: 0, False: 0]
  ------------------
 1652|      0|            log_error (_("failed to rebuild keyring cache: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1653|      0|                       gpg_strerror (rc));
 1654|      0|          break;
 1655|      0|        case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (1655:9): [True: 0, False: 0]
  ------------------
 1656|       |          /* N/A.  */
 1657|      0|          break;
 1658|      0|        }
 1659|      0|    }
 1660|      2|}
internal_keydb_search_reset:
 1682|  1.44k|{
 1683|  1.44k|  gpg_error_t rc = 0;
 1684|  1.44k|  int i;
 1685|       |
 1686|  1.44k|  log_assert (!hd->use_keyboxd);
 1687|       |
 1688|      0|  keyblock_cache_clear (hd);
 1689|       |
 1690|  1.44k|  hd->skipped_long_blobs = 0;
 1691|  1.44k|  hd->current = 0;
 1692|  1.44k|  hd->found = -1;
 1693|       |  /* Now reset all resources.  */
 1694|  2.89k|  for (i=0; !rc && i < hd->used; i++)
  ------------------
  |  Branch (1694:13): [True: 2.89k, False: 0]
  |  Branch (1694:20): [True: 1.44k, False: 1.44k]
  ------------------
 1695|  1.44k|    {
 1696|  1.44k|      switch (hd->active[i].type)
  ------------------
  |  Branch (1696:15): [True: 0, False: 1.44k]
  ------------------
 1697|  1.44k|        {
 1698|      0|        case KEYDB_RESOURCE_TYPE_NONE:
  ------------------
  |  Branch (1698:9): [True: 0, False: 1.44k]
  ------------------
 1699|      0|          break;
 1700|      0|        case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (1700:9): [True: 0, False: 1.44k]
  ------------------
 1701|      0|          rc = keyring_search_reset (hd->active[i].u.kr);
 1702|      0|          break;
 1703|  1.44k|        case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (1703:9): [True: 1.44k, False: 0]
  ------------------
 1704|  1.44k|          rc = keybox_search_reset (hd->active[i].u.kb);
 1705|  1.44k|          break;
 1706|  1.44k|        }
 1707|  1.44k|    }
 1708|  1.44k|  hd->is_reset = 1;
 1709|  1.44k|  if (!rc)
  ------------------
  |  Branch (1709:7): [True: 1.44k, False: 0]
  ------------------
 1710|  1.44k|    keydb_stats.search_resets++;
 1711|  1.44k|  return rc;
 1712|  1.44k|}
internal_keydb_search:
 1737|  1.82k|{
 1738|  1.82k|  gpg_error_t rc;
 1739|  1.82k|  int was_reset = hd->is_reset;
 1740|       |  /* If an entry is already in the cache, then don't add it again.  */
 1741|  1.82k|  int already_in_cache = 0;
 1742|  1.82k|  int fprlen;
 1743|       |
 1744|  1.82k|  log_assert (!hd->use_keyboxd);
 1745|       |
 1746|  1.82k|  if (!any_registered)
  ------------------
  |  Branch (1746:7): [True: 0, False: 1.82k]
  ------------------
 1747|      0|    {
 1748|      0|      write_status_error ("keydb_search", gpg_error (GPG_ERR_KEYRING_OPEN));
 1749|      0|      return gpg_error (GPG_ERR_NOT_FOUND);
 1750|      0|    }
 1751|       |
 1752|  1.82k|  if (ndesc == 1 && desc[0].mode == KEYDB_SEARCH_MODE_LONG_KID
  ------------------
  |  Branch (1752:7): [True: 1.82k, False: 0]
  |  Branch (1752:21): [True: 1.62k, False: 197]
  ------------------
 1753|  1.82k|      && (already_in_cache = kid_not_found_p (desc[0].u.kid)) == 1 )
  ------------------
  |  Branch (1753:10): [True: 1.52k, False: 99]
  ------------------
 1754|  1.52k|    {
 1755|  1.52k|      if (DBG_CLOCK)
  ------------------
  |  |  356|  1.52k|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|  1.52k|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 1.52k]
  |  |  ------------------
  ------------------
 1756|      0|        log_clock ("%s leave (not found, cached)", __func__);
 1757|  1.52k|      keydb_stats.notfound_cached++;
 1758|  1.52k|      return gpg_error (GPG_ERR_NOT_FOUND);
 1759|  1.52k|    }
 1760|       |
 1761|       |  /* NB: If one of the exact search modes below is used in a loop to
 1762|       |     walk over all keys (with the same fingerprint) the caching must
 1763|       |     have been disabled for the handle.  */
 1764|    296|  if (desc[0].mode == KEYDB_SEARCH_MODE_FPR)
  ------------------
  |  Branch (1764:7): [True: 196, False: 100]
  ------------------
 1765|    196|    fprlen = desc[0].fprlen;
 1766|    100|  else
 1767|    100|    fprlen = 0;
 1768|       |
 1769|    296|  if (!hd->no_caching
  ------------------
  |  Branch (1769:7): [True: 276, False: 20]
  ------------------
 1770|    296|      && ndesc == 1
  ------------------
  |  Branch (1770:10): [True: 276, False: 0]
  ------------------
 1771|    296|      && fprlen
  ------------------
  |  Branch (1771:10): [True: 176, False: 100]
  ------------------
 1772|    296|      && hd->keyblock_cache.state == KEYBLOCK_CACHE_FILLED
  ------------------
  |  Branch (1772:10): [True: 0, False: 176]
  ------------------
 1773|    296|      && hd->keyblock_cache.fprlen == fprlen
  ------------------
  |  Branch (1773:10): [True: 0, False: 0]
  ------------------
 1774|    296|      && !memcmp (hd->keyblock_cache.fpr, desc[0].u.fpr, fprlen)
  ------------------
  |  Branch (1774:10): [True: 0, False: 0]
  ------------------
 1775|       |      /* Make sure the current file position occurs before the cached
 1776|       |         result to avoid an infinite loop.  */
 1777|    296|      && (hd->current < hd->keyblock_cache.resource
  ------------------
  |  Branch (1777:11): [True: 0, False: 0]
  ------------------
 1778|      0|          || (hd->current == hd->keyblock_cache.resource
  ------------------
  |  Branch (1778:15): [True: 0, False: 0]
  ------------------
 1779|      0|              && (keybox_offset (hd->active[hd->current].u.kb)
  ------------------
  |  Branch (1779:18): [True: 0, False: 0]
  ------------------
 1780|      0|                  <= hd->keyblock_cache.offset))))
 1781|      0|    {
 1782|       |      /* (DESCINDEX is already set).  */
 1783|      0|      if (DBG_CLOCK)
  ------------------
  |  |  356|      0|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|      0|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1784|      0|        log_clock ("%s leave (cached)", __func__);
 1785|       |
 1786|      0|      hd->current = hd->keyblock_cache.resource;
 1787|       |      /* HD->KEYBLOCK_CACHE.OFFSET is the last byte in the record.
 1788|       |         Seek just beyond that.  */
 1789|      0|      keybox_seek (hd->active[hd->current].u.kb, hd->keyblock_cache.offset + 1);
 1790|      0|      keydb_stats.found_cached++;
 1791|      0|      return 0;
 1792|      0|    }
 1793|       |
 1794|    296|  rc = -1;
 1795|    592|  while ((rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF)
  ------------------
  |  Branch (1795:11): [True: 559, False: 33]
  |  Branch (1795:23): [True: 0, False: 33]
  ------------------
 1796|    592|         && hd->current >= 0 && hd->current < hd->used)
  ------------------
  |  Branch (1796:13): [True: 559, False: 0]
  |  Branch (1796:33): [True: 296, False: 263]
  ------------------
 1797|    296|    {
 1798|    296|      if (DBG_LOOKUP)
  ------------------
  |  |  357|    296|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|    296|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 296]
  |  |  ------------------
  ------------------
 1799|      0|        log_debug ("%s: searching %s (resource %d of %d)\n",
 1800|      0|                   __func__,
 1801|      0|                   hd->active[hd->current].type == KEYDB_RESOURCE_TYPE_KEYRING
  ------------------
  |  Branch (1801:20): [True: 0, False: 0]
  ------------------
 1802|      0|                   ? "keyring"
 1803|      0|                   : (hd->active[hd->current].type == KEYDB_RESOURCE_TYPE_KEYBOX
  ------------------
  |  Branch (1803:23): [True: 0, False: 0]
  ------------------
 1804|      0|                      ? "keybox" : "unknown type"),
 1805|      0|                   hd->current, hd->used);
 1806|       |
 1807|    296|       switch (hd->active[hd->current].type)
  ------------------
  |  Branch (1807:16): [True: 0, False: 296]
  ------------------
 1808|    296|        {
 1809|      0|        case KEYDB_RESOURCE_TYPE_NONE:
  ------------------
  |  Branch (1809:9): [True: 0, False: 296]
  ------------------
 1810|      0|          BUG(); /* we should never see it here */
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1811|      0|          break;
 1812|      0|        case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (1812:9): [True: 0, False: 296]
  ------------------
 1813|      0|          rc = keyring_search (hd->active[hd->current].u.kr, desc,
 1814|      0|                               ndesc, descindex, 1);
 1815|      0|          break;
 1816|    296|        case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (1816:9): [True: 296, False: 0]
  ------------------
 1817|    296|          do
 1818|    296|            rc = keybox_search (hd->active[hd->current].u.kb, desc,
 1819|    296|                                ndesc, KEYBOX_BLOBTYPE_PGP,
 1820|    296|                                descindex, &hd->skipped_long_blobs);
 1821|    296|          while (rc == GPG_ERR_LEGACY_KEY);
  ------------------
  |  Branch (1821:18): [True: 0, False: 296]
  ------------------
 1822|    296|          break;
 1823|    296|        }
 1824|       |
 1825|    296|      if (DBG_LOOKUP)
  ------------------
  |  |  357|    296|#define DBG_LOOKUP  (opt.debug & DBG_LOOKUP_VALUE)
  |  |  ------------------
  |  |  |  |  344|    296|#define DBG_LOOKUP_VALUE  8192	/* debug the key lookup */
  |  |  ------------------
  |  |  |  Branch (357:21): [True: 0, False: 296]
  |  |  ------------------
  ------------------
 1826|      0|        log_debug ("%s: searched %s (resource %d of %d) => %s\n",
 1827|      0|                   __func__,
 1828|      0|                   hd->active[hd->current].type == KEYDB_RESOURCE_TYPE_KEYRING
  ------------------
  |  Branch (1828:20): [True: 0, False: 0]
  ------------------
 1829|      0|                   ? "keyring"
 1830|      0|                   : (hd->active[hd->current].type == KEYDB_RESOURCE_TYPE_KEYBOX
  ------------------
  |  Branch (1830:23): [True: 0, False: 0]
  ------------------
 1831|      0|                      ? "keybox" : "unknown type"),
 1832|      0|                   hd->current, hd->used,
 1833|      0|                   rc == -1 ? "EOF" : gpg_strerror (rc));
  ------------------
  |  Branch (1833:20): [True: 0, False: 0]
  ------------------
 1834|       |
 1835|    296|      if (rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF)
  ------------------
  |  Branch (1835:11): [True: 263, False: 33]
  |  Branch (1835:23): [True: 0, False: 33]
  ------------------
 1836|    263|        {
 1837|       |          /* EOF -> switch to next resource */
 1838|    263|          hd->current++;
 1839|    263|        }
 1840|     33|      else if (!rc)
  ------------------
  |  Branch (1840:16): [True: 33, False: 0]
  ------------------
 1841|     33|        hd->found = hd->current;
 1842|    296|    }
 1843|    296|  hd->is_reset = 0;
 1844|       |
 1845|    296|  rc = ((rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF)
  ------------------
  |  Branch (1845:10): [True: 263, False: 33]
  |  Branch (1845:22): [True: 0, False: 33]
  ------------------
 1846|    296|        ? gpg_error (GPG_ERR_NOT_FOUND)
 1847|    296|        : rc);
 1848|       |
 1849|    296|  keyblock_cache_clear (hd);
 1850|    296|  if (!hd->no_caching
  ------------------
  |  Branch (1850:7): [True: 276, False: 20]
  ------------------
 1851|    296|      && !rc
  ------------------
  |  Branch (1851:10): [True: 15, False: 261]
  ------------------
 1852|    296|      && ndesc == 1
  ------------------
  |  Branch (1852:10): [True: 15, False: 0]
  ------------------
 1853|    296|      && fprlen
  ------------------
  |  Branch (1853:10): [True: 4, False: 11]
  ------------------
 1854|    296|      && hd->active[hd->current].type == KEYDB_RESOURCE_TYPE_KEYBOX)
  ------------------
  |  Branch (1854:10): [True: 4, False: 0]
  ------------------
 1855|      4|    {
 1856|      4|      hd->keyblock_cache.state = KEYBLOCK_CACHE_PREPARED;
 1857|      4|      hd->keyblock_cache.resource = hd->current;
 1858|       |      /* The current offset is at the start of the next record.  Since
 1859|       |         a record is at least 1 byte, we just use offset - 1, which is
 1860|       |         within the record.  */
 1861|      4|      hd->keyblock_cache.offset
 1862|      4|        = keybox_offset (hd->active[hd->current].u.kb) - 1;
 1863|      4|      memcpy (hd->keyblock_cache.fpr, desc[0].u.fpr, fprlen);
 1864|      4|      hd->keyblock_cache.fprlen = fprlen;
 1865|      4|    }
 1866|       |
 1867|    296|  if (gpg_err_code (rc) == GPG_ERR_NOT_FOUND
  ------------------
  |  Branch (1867:7): [True: 263, False: 33]
  ------------------
 1868|    296|      && ndesc == 1
  ------------------
  |  Branch (1868:10): [True: 263, False: 0]
  ------------------
 1869|    296|      && desc[0].mode == KEYDB_SEARCH_MODE_LONG_KID
  ------------------
  |  Branch (1869:10): [True: 88, False: 175]
  ------------------
 1870|    296|      && was_reset
  ------------------
  |  Branch (1870:10): [True: 88, False: 0]
  ------------------
 1871|    296|      && !already_in_cache)
  ------------------
  |  Branch (1871:10): [True: 88, False: 0]
  ------------------
 1872|     88|    kid_not_found_insert (desc[0].u.kid);
 1873|       |
 1874|    296|  if (!rc)
  ------------------
  |  Branch (1874:7): [True: 33, False: 263]
  ------------------
 1875|     33|    keydb_stats.found++;
 1876|    263|  else
 1877|    263|    keydb_stats.notfound++;
 1878|    296|  return rc;
 1879|    296|}
keydb_search_first:
 1889|      1|{
 1890|      1|  gpg_error_t err;
 1891|      1|  KEYDB_SEARCH_DESC desc;
 1892|       |
 1893|      1|  err = keydb_search_reset (hd);
 1894|      1|  if (err)
  ------------------
  |  Branch (1894:7): [True: 0, False: 1]
  ------------------
 1895|      0|    return err;
 1896|       |
 1897|      1|  memset (&desc, 0, sizeof desc);
 1898|      1|  desc.mode = KEYDB_SEARCH_MODE_FIRST;
 1899|      1|  return keydb_search (hd, &desc, 1, NULL);
 1900|      1|}
keydb_search_kid:
 1926|     37|{
 1927|     37|  KEYDB_SEARCH_DESC desc;
 1928|       |
 1929|     37|  memset (&desc, 0, sizeof desc);
 1930|     37|  desc.mode = KEYDB_SEARCH_MODE_LONG_KID;
 1931|     37|  desc.u.kid[0] = kid[0];
 1932|     37|  desc.u.kid[1] = kid[1];
 1933|     37|  return keydb_search (hd, &desc, 1, NULL);
 1934|     37|}
keydb_search_fpr:
 1945|     11|{
 1946|     11|  KEYDB_SEARCH_DESC desc;
 1947|       |
 1948|     11|  memset (&desc, 0, sizeof desc);
 1949|     11|  desc.mode = KEYDB_SEARCH_MODE_FPR;
 1950|     11|  memcpy (desc.u.fpr, fpr, fprlen);
 1951|     11|  desc.fprlen = fprlen;
 1952|     11|  return keydb_search (hd, &desc, 1, NULL);
 1953|     11|}
keydb.c:rt_from_file:
  418|      2|{
  419|      2|  u32 magic;
  420|      2|  unsigned char verbuf[4];
  421|      2|  estream_t fp;
  422|      2|  KeydbResourceType rt = KEYDB_RESOURCE_TYPE_NONE;
  423|       |
  424|      2|  *r_found = *r_openpgp = 0;
  425|      2|  fp = es_fopen (filename, "rb");
  426|      2|  if (fp)
  ------------------
  |  Branch (426:7): [True: 0, False: 2]
  ------------------
  427|      0|    {
  428|      0|      *r_found = 1;
  429|       |
  430|      0|      if (es_fread (&magic, 4, 1, fp) == 1 )
  ------------------
  |  Branch (430:11): [True: 0, False: 0]
  ------------------
  431|      0|        {
  432|      0|          if (magic == 0x13579ace || magic == 0xce9a5713)
  ------------------
  |  Branch (432:15): [True: 0, False: 0]
  |  Branch (432:38): [True: 0, False: 0]
  ------------------
  433|      0|            ; /* GDBM magic - not anymore supported. */
  434|      0|          else if (es_fread (&verbuf, 4, 1, fp) == 1
  ------------------
  |  Branch (434:20): [True: 0, False: 0]
  ------------------
  435|      0|                   && verbuf[0] == 1
  ------------------
  |  Branch (435:23): [True: 0, False: 0]
  ------------------
  436|      0|                   && es_fread (&magic, 4, 1, fp) == 1
  ------------------
  |  Branch (436:23): [True: 0, False: 0]
  ------------------
  437|      0|                   && !memcmp (&magic, "KBXf", 4))
  ------------------
  |  Branch (437:23): [True: 0, False: 0]
  ------------------
  438|      0|            {
  439|      0|              if ((verbuf[3] & 0x02))
  ------------------
  |  Branch (439:19): [True: 0, False: 0]
  ------------------
  440|      0|                *r_openpgp = 1;
  441|      0|              rt = KEYDB_RESOURCE_TYPE_KEYBOX;
  442|      0|            }
  443|      0|          else
  444|      0|            rt = KEYDB_RESOURCE_TYPE_KEYRING;
  445|      0|        }
  446|      0|      else /* Maybe empty: assume keyring. */
  447|      0|        rt = KEYDB_RESOURCE_TYPE_KEYRING;
  448|       |
  449|      0|      es_fclose (fp);
  450|      0|    }
  451|       |
  452|      2|  return rt;
  453|      2|}
keydb.c:maybe_create_keyring_or_box:
  214|      1|{
  215|      1|  gpg_err_code_t ec;
  216|      1|  dotlock_t lockhd = NULL;
  217|      1|  IOBUF iobuf;
  218|      1|  int rc;
  219|      1|  mode_t oldmask;
  220|      1|  char *last_slash_in_filename;
  221|      1|  char *bak_fname = NULL;
  222|      1|  char *tmp_fname = NULL;
  223|      1|  int save_slash;
  224|       |
  225|       |  /* A quick test whether the filename already exists. */
  226|      1|  if (!gnupg_access (filename, F_OK))
  ------------------
  |  Branch (226:7): [True: 0, False: 1]
  ------------------
  227|      0|    return !gnupg_access (filename, R_OK)? 0 : gpg_error (GPG_ERR_EACCES);
  ------------------
  |  Branch (227:12): [True: 0, False: 0]
  ------------------
  228|       |
  229|       |  /* If we don't want to create a new file at all, there is no need to
  230|       |     go any further - bail out right here.  */
  231|      1|  if (!force_create)
  ------------------
  |  Branch (231:7): [True: 0, False: 1]
  ------------------
  232|      0|    return gpg_error (GPG_ERR_ENOENT);
  233|       |
  234|       |  /* First of all we try to create the home directory.  Note, that we
  235|       |     don't do any locking here because any sane application of gpg
  236|       |     would create the home directory by itself and not rely on gpg's
  237|       |     tricky auto-creation which is anyway only done for certain home
  238|       |     directory name pattern. */
  239|      1|  last_slash_in_filename = strrchr (filename, DIRSEP_C);
  ------------------
  |  |  886|      1|#define DIRSEP_C '/'
  ------------------
  240|       |#if HAVE_W32_SYSTEM
  241|       |  {
  242|       |    /* Windows may either have a slash or a backslash.  Take care of it.  */
  243|       |    char *p = strrchr (filename, '/');
  244|       |    if (!last_slash_in_filename || p > last_slash_in_filename)
  245|       |      last_slash_in_filename = p;
  246|       |  }
  247|       |#endif /*HAVE_W32_SYSTEM*/
  248|      1|  if (!last_slash_in_filename)
  ------------------
  |  Branch (248:7): [True: 0, False: 1]
  ------------------
  249|      0|    return gpg_error (GPG_ERR_ENOENT);  /* No slash at all - should
  250|       |                                           not happen though.  */
  251|      1|  save_slash = *last_slash_in_filename;
  252|      1|  *last_slash_in_filename = 0;
  253|      1|  if (gnupg_access(filename, F_OK))
  ------------------
  |  Branch (253:7): [True: 0, False: 1]
  ------------------
  254|      0|    {
  255|      0|      static int tried;
  256|       |
  257|      0|      if (!tried)
  ------------------
  |  Branch (257:11): [True: 0, False: 0]
  ------------------
  258|      0|        {
  259|      0|          tried = 1;
  260|      0|          try_make_homedir (filename);
  261|      0|        }
  262|      0|      if ((ec = gnupg_access (filename, F_OK)))
  ------------------
  |  Branch (262:11): [True: 0, False: 0]
  ------------------
  263|      0|        {
  264|      0|          rc = gpg_error (ec);
  265|      0|          *last_slash_in_filename = save_slash;
  266|      0|          goto leave;
  267|      0|        }
  268|      0|    }
  269|      1|  *last_slash_in_filename = save_slash;
  270|       |
  271|       |  /* To avoid races with other instances of gpg trying to create or
  272|       |     update the keyring (it is removed during an update for a short
  273|       |     time), we do the next stuff in a locked state. */
  274|      1|  lockhd = dotlock_create (filename, 0);
  275|      1|  if (!lockhd)
  ------------------
  |  Branch (275:7): [True: 0, False: 1]
  ------------------
  276|      0|    {
  277|      0|      rc = gpg_error_from_syserror ();
  278|       |      /* A reason for this to fail is that the directory is not
  279|       |         writable. However, this whole locking stuff does not make
  280|       |         sense if this is the case. An empty non-writable directory
  281|       |         with no keyring is not really useful at all. */
  282|      0|      if (opt.verbose)
  ------------------
  |  Branch (282:11): [True: 0, False: 0]
  ------------------
  283|      0|        log_info ("can't allocate lock for '%s': %s\n",
  284|      0|                  filename, gpg_strerror (rc));
  285|       |
  286|      0|      if (!force_create)
  ------------------
  |  Branch (286:11): [True: 0, False: 0]
  ------------------
  287|      0|        return gpg_error (GPG_ERR_ENOENT);  /* Won't happen.  */
  288|      0|      else
  289|      0|        return rc;
  290|      0|    }
  291|       |
  292|      1|  if ( dotlock_take (lockhd, -1) )
  ------------------
  |  Branch (292:8): [True: 0, False: 1]
  ------------------
  293|      0|    {
  294|      0|      rc = gpg_error_from_syserror ();
  295|       |      /* This is something bad.  Probably a stale lockfile.  */
  296|      0|      log_info ("can't lock '%s': %s\n", filename, gpg_strerror (rc));
  297|      0|      goto leave;
  298|      0|    }
  299|       |
  300|       |  /* Now the real test while we are locked. */
  301|       |
  302|       |  /* Gpg either uses pubring.gpg or pubring.kbx and thus different
  303|       |   * lock files.  Now, when one gpg process is updating a pubring.gpg
  304|       |   * and thus holding the corresponding lock, a second gpg process may
  305|       |   * get to here at the time between the two rename operation used by
  306|       |   * the first process to update pubring.gpg.  The lock taken above
  307|       |   * may not protect the second process if it tries to create a
  308|       |   * pubring.kbx file which would be protected by a different lock
  309|       |   * file.
  310|       |   *
  311|       |   * We can detect this case by checking that the two temporary files
  312|       |   * used by the update code exist at the same time.  In that case we
  313|       |   * do not create a new file but act as if FORCE_CREATE has not been
  314|       |   * given.  Obviously there is a race between our two checks but the
  315|       |   * worst thing is that we won't create a new file, which is better
  316|       |   * than to accidentally creating one.  */
  317|      1|  rc = keybox_tmp_names (filename, is_box, &bak_fname, &tmp_fname);
  318|      1|  if (rc)
  ------------------
  |  Branch (318:7): [True: 0, False: 1]
  ------------------
  319|      0|    goto leave;
  320|       |
  321|      1|  if (!gnupg_access (filename, F_OK))
  ------------------
  |  Branch (321:7): [True: 0, False: 1]
  ------------------
  322|      0|    {
  323|      0|      rc = 0;  /* Okay, we may access the file now.  */
  324|      0|      goto leave;
  325|      0|    }
  326|      1|  if (!gnupg_access (bak_fname, F_OK) && !gnupg_access (tmp_fname, F_OK))
  ------------------
  |  Branch (326:7): [True: 0, False: 1]
  |  Branch (326:42): [True: 0, False: 0]
  ------------------
  327|      0|    {
  328|       |      /* Very likely another process is updating a pubring.gpg and we
  329|       |         should not create a pubring.kbx.  */
  330|      0|      rc = gpg_error (GPG_ERR_ENOENT);
  331|      0|      goto leave;
  332|      0|    }
  333|       |
  334|       |
  335|       |  /* The file does not yet exist, create it now. */
  336|      1|  oldmask = umask (077);
  337|      1|  if (is_secured_filename (filename))
  ------------------
  |  Branch (337:7): [True: 0, False: 1]
  ------------------
  338|      0|    {
  339|      0|      iobuf = NULL;
  340|      0|      gpg_err_set_errno (EPERM);
  341|      0|    }
  342|      1|  else
  343|      1|    iobuf = iobuf_create (filename, 0);
  344|      1|  umask (oldmask);
  345|      1|  if (!iobuf)
  ------------------
  |  Branch (345:7): [True: 0, False: 1]
  ------------------
  346|      0|    {
  347|      0|      rc = gpg_error_from_syserror ();
  348|      0|      if (is_box)
  ------------------
  |  Branch (348:11): [True: 0, False: 0]
  ------------------
  349|      0|        log_error (_("error creating keybox '%s': %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  350|      0|                   filename, gpg_strerror (rc));
  351|      0|      else
  352|      0|        log_error (_("error creating keyring '%s': %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  353|      0|                   filename, gpg_strerror (rc));
  354|      0|      goto leave;
  355|      0|    }
  356|       |
  357|      1|  iobuf_close (iobuf);
  358|       |  /* Must invalidate that ugly cache */
  359|      1|  iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, filename);
  360|       |
  361|       |  /* Make sure that at least one record is in a new keybox file, so
  362|       |     that the detection magic will work the next time it is used.  */
  363|      1|  if (is_box)
  ------------------
  |  Branch (363:7): [True: 1, False: 0]
  ------------------
  364|      1|    {
  365|      1|      estream_t fp = es_fopen (filename, "wb");
  366|      1|      if (!fp)
  ------------------
  |  Branch (366:11): [True: 0, False: 1]
  ------------------
  367|      0|        rc = gpg_error_from_syserror ();
  368|      1|      else
  369|      1|        {
  370|      1|          rc = _keybox_write_header_blob (fp, 1);
  371|      1|          es_fclose (fp);
  372|      1|        }
  373|      1|      if (rc)
  ------------------
  |  Branch (373:11): [True: 0, False: 1]
  ------------------
  374|      0|        {
  375|      0|          if (is_box)
  ------------------
  |  Branch (375:15): [True: 0, False: 0]
  ------------------
  376|      0|            log_error (_("error creating keybox '%s': %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  377|      0|                       filename, gpg_strerror (rc));
  378|      0|          else
  379|      0|            log_error (_("error creating keyring '%s': %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  380|      0|                       filename, gpg_strerror (rc));
  381|      0|          goto leave;
  382|      0|        }
  383|      1|    }
  384|       |
  385|      1|  if (!opt.quiet)
  ------------------
  |  Branch (385:7): [True: 1, False: 0]
  ------------------
  386|      1|    {
  387|      1|      if (is_box)
  ------------------
  |  Branch (387:11): [True: 1, False: 0]
  ------------------
  388|      1|        log_info (_("keybox '%s' created\n"), filename);
  ------------------
  |  |   28|      1|#  define _(a) gettext (a)
  ------------------
  389|      0|      else
  390|      0|        log_info (_("keyring '%s' created\n"), filename);
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  391|      1|    }
  392|       |
  393|      1|  rc = 0;
  394|       |
  395|      1| leave:
  396|      1|  if (lockhd)
  ------------------
  |  Branch (396:7): [True: 1, False: 0]
  ------------------
  397|      1|    {
  398|      1|      dotlock_release (lockhd);
  399|      1|      dotlock_destroy (lockhd);
  400|      1|    }
  401|      1|  xfree (bak_fname);
  ------------------
  |  |  104|      1|#define xfree(a)         gcry_free ((a))
  ------------------
  402|      1|  xfree (tmp_fname);
  ------------------
  |  |  104|      1|#define xfree(a)         gcry_free ((a))
  ------------------
  403|      1|  return rc;
  404|      1|}
keydb.c:keyblock_cache_clear:
  195|  2.15k|{
  196|  2.15k|  hd->keyblock_cache.state = KEYBLOCK_CACHE_EMPTY;
  197|  2.15k|  iobuf_close (hd->keyblock_cache.iobuf);
  198|  2.15k|  hd->keyblock_cache.iobuf = NULL;
  199|  2.15k|  hd->keyblock_cache.resource = -1;
  200|  2.15k|  hd->keyblock_cache.offset = -1;
  201|  2.15k|}
keydb.c:lock_all:
  980|     22|{
  981|     22|  int i, rc = 0;
  982|       |
  983|       |  /* Fixme: This locking scheme may lead to a deadlock if the resources
  984|       |     are not added in the same order by all processes.  We are
  985|       |     currently only allowing one resource so it is not a problem.
  986|       |     [Oops: Who claimed the latter]
  987|       |
  988|       |     To fix this we need to use a lock file to protect lock_all.  */
  989|       |
  990|     44|  for (i=0; !rc && i < hd->used; i++)
  ------------------
  |  Branch (990:13): [True: 44, False: 0]
  |  Branch (990:20): [True: 22, False: 22]
  ------------------
  991|     22|    {
  992|     22|      switch (hd->active[i].type)
  ------------------
  |  Branch (992:15): [True: 0, False: 22]
  ------------------
  993|     22|        {
  994|      0|        case KEYDB_RESOURCE_TYPE_NONE:
  ------------------
  |  Branch (994:9): [True: 0, False: 22]
  ------------------
  995|      0|          break;
  996|      0|        case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (996:9): [True: 0, False: 22]
  ------------------
  997|      0|          rc = keyring_lock (hd->active[i].u.kr, 1);
  998|      0|          break;
  999|     22|        case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (999:9): [True: 22, False: 0]
  ------------------
 1000|     22|          rc = keybox_lock (hd->active[i].u.kb, 1, -1);
 1001|     22|          break;
 1002|     22|        }
 1003|     22|    }
 1004|       |
 1005|     22|  if (rc)
  ------------------
  |  Branch (1005:7): [True: 0, False: 22]
  ------------------
 1006|      0|    {
 1007|       |      /* Revert the already taken locks.  */
 1008|      0|      for (i--; i >= 0; i--)
  ------------------
  |  Branch (1008:17): [True: 0, False: 0]
  ------------------
 1009|      0|        {
 1010|      0|          switch (hd->active[i].type)
  ------------------
  |  Branch (1010:19): [True: 0, False: 0]
  ------------------
 1011|      0|            {
 1012|      0|            case KEYDB_RESOURCE_TYPE_NONE:
  ------------------
  |  Branch (1012:13): [True: 0, False: 0]
  ------------------
 1013|      0|              break;
 1014|      0|            case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (1014:13): [True: 0, False: 0]
  ------------------
 1015|      0|              keyring_lock (hd->active[i].u.kr, 0);
 1016|      0|              break;
 1017|      0|            case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (1017:13): [True: 0, False: 0]
  ------------------
 1018|      0|              keybox_lock (hd->active[i].u.kb, 0, 0);
 1019|      0|              break;
 1020|      0|            }
 1021|      0|        }
 1022|      0|    }
 1023|     22|  else
 1024|     22|    {
 1025|     22|      hd->locked = 1;
 1026|     22|      keydb_stats.locks++;
 1027|     22|    }
 1028|       |
 1029|     22|  return rc;
 1030|     22|}
keydb.c:unlock_all:
 1035|    390|{
 1036|    390|  int i;
 1037|       |
 1038|    390|  if (!hd->locked || hd->keep_lock)
  ------------------
  |  Branch (1038:7): [True: 368, False: 22]
  |  Branch (1038:22): [True: 11, False: 11]
  ------------------
 1039|    379|    return;
 1040|       |
 1041|     22|  for (i=hd->used-1; i >= 0; i--)
  ------------------
  |  Branch (1041:22): [True: 11, False: 11]
  ------------------
 1042|     11|    {
 1043|     11|      switch (hd->active[i].type)
  ------------------
  |  Branch (1043:15): [True: 0, False: 11]
  ------------------
 1044|     11|        {
 1045|      0|        case KEYDB_RESOURCE_TYPE_NONE:
  ------------------
  |  Branch (1045:9): [True: 0, False: 11]
  ------------------
 1046|      0|          break;
 1047|      0|        case KEYDB_RESOURCE_TYPE_KEYRING:
  ------------------
  |  Branch (1047:9): [True: 0, False: 11]
  ------------------
 1048|      0|          keyring_lock (hd->active[i].u.kr, 0);
 1049|      0|          break;
 1050|     11|        case KEYDB_RESOURCE_TYPE_KEYBOX:
  ------------------
  |  Branch (1050:9): [True: 11, False: 0]
  ------------------
 1051|     11|          keybox_lock (hd->active[i].u.kb, 0, 0);
 1052|     11|          break;
 1053|     11|        }
 1054|     11|    }
 1055|     11|  hd->locked = 0;
 1056|     11|}
keydb.c:kid_not_found_flush:
  167|     11|{
  168|     11|  struct kid_not_found_cache_bucket *k, *knext;
  169|     11|  int i;
  170|       |
  171|     11|  if (DBG_CACHE)
  ------------------
  |  |  352|     11|#define DBG_CACHE  (opt.debug & DBG_CACHE_VALUE)
  |  |  ------------------
  |  |  |  |  338|     11|#define DBG_CACHE_VALUE   64	/* debug the caching */
  |  |  ------------------
  |  |  |  Branch (352:20): [True: 0, False: 11]
  |  |  ------------------
  ------------------
  172|      0|    log_debug ("keydb: kid_not_found_flush\n");
  173|       |
  174|     11|  if (!kid_not_found_stats.count)
  ------------------
  |  Branch (174:7): [True: 0, False: 11]
  ------------------
  175|      0|    return;
  176|       |
  177|  2.82k|  for (i=0; i < DIM(kid_not_found_cache); i++)
  ------------------
  |  |   47|  2.82k|#define DIM(v)		     (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (177:13): [True: 2.81k, False: 11]
  ------------------
  178|  2.81k|    {
  179|  2.89k|      for (k = kid_not_found_cache[i]; k; k = knext)
  ------------------
  |  Branch (179:40): [True: 81, False: 2.81k]
  ------------------
  180|     81|        {
  181|     81|          knext = k->next;
  182|     81|          xfree (k);
  ------------------
  |  |  104|     81|#define xfree(a)         gcry_free ((a))
  ------------------
  183|     81|        }
  184|  2.81k|      kid_not_found_cache[i] = NULL;
  185|  2.81k|    }
  186|     11|  if (kid_not_found_stats.count > kid_not_found_stats.peak)
  ------------------
  |  Branch (186:7): [True: 1, False: 10]
  ------------------
  187|      1|    kid_not_found_stats.peak = kid_not_found_stats.count;
  188|     11|  kid_not_found_stats.count = 0;
  189|     11|  kid_not_found_stats.flushes++;
  190|     11|}
keydb.c:kid_not_found_p:
  123|  1.62k|{
  124|  1.62k|  struct kid_not_found_cache_bucket *k;
  125|       |
  126|  8.98k|  for (k = kid_not_found_cache[kid[0] % KID_NOT_FOUND_CACHE_BUCKETS]; k; k = k->next)
  ------------------
  |  |   70|  1.62k|#define KID_NOT_FOUND_CACHE_BUCKETS 256
  ------------------
  |  Branch (126:71): [True: 8.88k, False: 99]
  ------------------
  127|  8.88k|    if (k->kid[0] == kid[0] && k->kid[1] == kid[1])
  ------------------
  |  Branch (127:9): [True: 3.91k, False: 4.97k]
  |  Branch (127:32): [True: 1.52k, False: 2.38k]
  ------------------
  128|  1.52k|      {
  129|  1.52k|        if (DBG_CACHE)
  ------------------
  |  |  352|  1.52k|#define DBG_CACHE  (opt.debug & DBG_CACHE_VALUE)
  |  |  ------------------
  |  |  |  |  338|  1.52k|#define DBG_CACHE_VALUE   64	/* debug the caching */
  |  |  ------------------
  |  |  |  Branch (352:20): [True: 0, False: 1.52k]
  |  |  ------------------
  ------------------
  130|      0|          log_debug ("keydb: kid_not_found_p (%08lx%08lx) => not in DB\n",
  131|      0|                     (ulong)kid[0], (ulong)kid[1]);
  132|  1.52k|        return 1;
  133|  1.52k|      }
  134|       |
  135|     99|  if (DBG_CACHE)
  ------------------
  |  |  352|     99|#define DBG_CACHE  (opt.debug & DBG_CACHE_VALUE)
  |  |  ------------------
  |  |  |  |  338|     99|#define DBG_CACHE_VALUE   64	/* debug the caching */
  |  |  ------------------
  |  |  |  Branch (352:20): [True: 0, False: 99]
  |  |  ------------------
  ------------------
  136|      0|    log_debug ("keydb: kid_not_found_p (%08lx%08lx) => indeterminate\n",
  137|      0|               (ulong)kid[0], (ulong)kid[1]);
  138|     99|  return 0;
  139|  1.62k|}
keydb.c:kid_not_found_insert:
  149|     88|{
  150|     88|  struct kid_not_found_cache_bucket *k;
  151|       |
  152|     88|  if (DBG_CACHE)
  ------------------
  |  |  352|     88|#define DBG_CACHE  (opt.debug & DBG_CACHE_VALUE)
  |  |  ------------------
  |  |  |  |  338|     88|#define DBG_CACHE_VALUE   64	/* debug the caching */
  |  |  ------------------
  |  |  |  Branch (352:20): [True: 0, False: 88]
  |  |  ------------------
  ------------------
  153|      0|    log_debug ("keydb: kid_not_found_insert (%08lx%08lx)\n",
  154|      0|               (ulong)kid[0], (ulong)kid[1]);
  155|     88|  k = xmalloc (sizeof *k);
  ------------------
  |  |  107|     88|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  156|     88|  k->kid[0] = kid[0];
  157|     88|  k->kid[1] = kid[1];
  158|     88|  k->next = kid_not_found_cache[kid[0] % KID_NOT_FOUND_CACHE_BUCKETS];
  ------------------
  |  |   70|     88|#define KID_NOT_FOUND_CACHE_BUCKETS 256
  ------------------
  159|     88|  kid_not_found_cache[kid[0] % KID_NOT_FOUND_CACHE_BUCKETS] = k;
  ------------------
  |  |   70|     88|#define KID_NOT_FOUND_CACHE_BUCKETS 256
  ------------------
  160|     88|  kid_not_found_stats.count++;
  161|     88|}

sig-check.c:keyid_cmp:
  502|     11|{
  503|     11|  if (a[0] < b[0])
  ------------------
  |  Branch (503:7): [True: 0, False: 11]
  ------------------
  504|      0|    return -1;
  505|     11|  if (a[0] > b[0])
  ------------------
  |  Branch (505:7): [True: 0, False: 11]
  ------------------
  506|      0|    return 1;
  507|     11|  if (a[1] < b[1])
  ------------------
  |  Branch (507:7): [True: 0, False: 11]
  ------------------
  508|      0|    return -1;
  509|     11|  if (a[1] > b[1])
  ------------------
  |  Branch (509:7): [True: 0, False: 11]
  ------------------
  510|      0|    return 1;
  511|     11|  return 0;
  512|     11|}
key-check.c:keyid_cmp:
  502|  1.46k|{
  503|  1.46k|  if (a[0] < b[0])
  ------------------
  |  Branch (503:7): [True: 210, False: 1.25k]
  ------------------
  504|    210|    return -1;
  505|  1.25k|  if (a[0] > b[0])
  ------------------
  |  Branch (505:7): [True: 678, False: 577]
  ------------------
  506|    678|    return 1;
  507|    577|  if (a[1] < b[1])
  ------------------
  |  Branch (507:7): [True: 69, False: 508]
  ------------------
  508|     69|    return -1;
  509|    508|  if (a[1] > b[1])
  ------------------
  |  Branch (509:7): [True: 106, False: 402]
  ------------------
  510|    106|    return 1;
  511|    402|  return 0;
  512|    508|}

hash_public_key:
  146|  1.17k|{
  147|  1.17k|  unsigned int n;
  148|  1.17k|  unsigned int nn[PUBKEY_MAX_NPKEY];
  149|  1.17k|  byte *pp[PUBKEY_MAX_NPKEY];
  150|  1.17k|  int i;
  151|  1.17k|  unsigned int nbits;
  152|  1.17k|  size_t nbytes;
  153|  1.17k|  int npkey = pubkey_get_npkey (pk->pubkey_algo);
  154|  1.17k|  int is_v5 = pk->version == 5;
  155|       |
  156|  1.17k|  n = is_v5? 10 : 6;
  ------------------
  |  Branch (156:7): [True: 33, False: 1.14k]
  ------------------
  157|       |  /* FIXME: We can avoid the extra malloc by calling only the first
  158|       |     mpi_print here which computes the required length and calling the
  159|       |     real mpi_print only at the end.  The speed advantage would only be
  160|       |     for ECC (opaque MPIs) or if we could implement an mpi_print
  161|       |     variant with a callback handler to do the hashing.  */
  162|  1.17k|  if (npkey==0 && pk->pkey[0]
  ------------------
  |  Branch (162:7): [True: 918, False: 259]
  |  Branch (162:19): [True: 918, False: 0]
  ------------------
  163|  1.17k|      && gcry_mpi_get_flag (pk->pkey[0], GCRYMPI_FLAG_OPAQUE))
  ------------------
  |  Branch (163:10): [True: 918, False: 0]
  ------------------
  164|    918|    {
  165|    918|      pp[0] = gcry_mpi_get_opaque (pk->pkey[0], &nbits);
  166|    918|      nn[0] = (nbits+7)/8;
  167|    918|      n+=nn[0];
  168|    918|    }
  169|    259|  else
  170|    259|    {
  171|    777|      for (i=0; i < npkey; i++ )
  ------------------
  |  Branch (171:17): [True: 518, False: 259]
  ------------------
  172|    518|        {
  173|    518|          if (!pk->pkey[i])
  ------------------
  |  Branch (173:15): [True: 0, False: 518]
  ------------------
  174|      0|            {
  175|       |              /* This case may only happen if the parsing of the MPI
  176|       |                 failed but the key was anyway created.  May happen
  177|       |                 during "gpg KEYFILE".  */
  178|      0|              pp[i] = NULL;
  179|      0|              nn[i] = 0;
  180|      0|            }
  181|    518|          else if (gcry_mpi_get_flag (pk->pkey[i], GCRYMPI_FLAG_OPAQUE))
  ------------------
  |  Branch (181:20): [True: 162, False: 356]
  ------------------
  182|    162|            {
  183|    162|              const char *p;
  184|    162|              int is_sos = 0;
  185|       |
  186|    162|              if (gcry_mpi_get_flag (pk->pkey[i], GCRYMPI_FLAG_USER2))
  ------------------
  |  Branch (186:19): [True: 81, False: 81]
  ------------------
  187|     81|                is_sos = 2;
  188|       |
  189|    162|              p = gcry_mpi_get_opaque (pk->pkey[i], &nbits);
  190|    162|              pp[i] = xmalloc ((nbits+7)/8 + is_sos);
  ------------------
  |  |  107|    162|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  191|    162|              if (p)
  ------------------
  |  Branch (191:19): [True: 162, False: 0]
  ------------------
  192|    162|                memcpy (pp[i] + is_sos, p, (nbits+7)/8);
  193|      0|              else
  194|      0|                pp[i] = NULL;
  195|    162|              if (is_sos)
  ------------------
  |  Branch (195:19): [True: 81, False: 81]
  ------------------
  196|     81|                {
  197|     81|                  if (*p)
  ------------------
  |  Branch (197:23): [True: 81, False: 0]
  ------------------
  198|     81|                    {
  199|     81|                      nbits = ((nbits + 7) / 8) * 8;
  200|       |
  201|     81|                      if (nbits >= 8 && !(*p & 0x80))
  ------------------
  |  Branch (201:27): [True: 81, False: 0]
  |  Branch (201:41): [True: 81, False: 0]
  ------------------
  202|     81|                        if (--nbits >= 7 && !(*p & 0x40))
  ------------------
  |  Branch (202:29): [True: 81, False: 0]
  |  Branch (202:45): [True: 64, False: 17]
  ------------------
  203|     64|                          if (--nbits >= 6 && !(*p & 0x20))
  ------------------
  |  Branch (203:31): [True: 64, False: 0]
  |  Branch (203:47): [True: 64, False: 0]
  ------------------
  204|     64|                            if (--nbits >= 5 && !(*p & 0x10))
  ------------------
  |  Branch (204:33): [True: 64, False: 0]
  |  Branch (204:49): [True: 64, False: 0]
  ------------------
  205|     64|                              if (--nbits >= 4 && !(*p & 0x08))
  ------------------
  |  Branch (205:35): [True: 64, False: 0]
  |  Branch (205:51): [True: 64, False: 0]
  ------------------
  206|     64|                                if (--nbits >= 3 && !(*p & 0x04))
  ------------------
  |  Branch (206:37): [True: 64, False: 0]
  |  Branch (206:53): [True: 0, False: 64]
  ------------------
  207|      0|                                  if (--nbits >= 2 && !(*p & 0x02))
  ------------------
  |  Branch (207:39): [True: 0, False: 0]
  |  Branch (207:55): [True: 0, False: 0]
  ------------------
  208|      0|                                    if (--nbits >= 1 && !(*p & 0x01))
  ------------------
  |  Branch (208:41): [True: 0, False: 0]
  |  Branch (208:57): [True: 0, False: 0]
  ------------------
  209|      0|                                      --nbits;
  210|     81|                    }
  211|       |
  212|     81|                  pp[i][0] = (nbits >> 8);
  213|     81|                  pp[i][1] = nbits;
  214|     81|                }
  215|    162|              nn[i] = (nbits+7)/8 + is_sos;
  216|    162|              n += nn[i];
  217|    162|            }
  218|    356|          else
  219|    356|            {
  220|    356|              if (gcry_mpi_print (GCRYMPI_FMT_PGP, NULL, 0,
  ------------------
  |  Branch (220:19): [True: 0, False: 356]
  ------------------
  221|    356|                                  &nbytes, pk->pkey[i]))
  222|      0|                BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  223|    356|              pp[i] = xmalloc (nbytes);
  ------------------
  |  |  107|    356|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  224|    356|              if (gcry_mpi_print (GCRYMPI_FMT_PGP, pp[i], nbytes,
  ------------------
  |  Branch (224:19): [True: 0, False: 356]
  ------------------
  225|    356|                                  &nbytes, pk->pkey[i]))
  226|      0|                BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  227|    356|              nn[i] = nbytes;
  228|    356|              n += nn[i];
  229|    356|            }
  230|    518|        }
  231|    259|    }
  232|       |
  233|  1.17k|  if (is_v5)
  ------------------
  |  Branch (233:7): [True: 33, False: 1.14k]
  ------------------
  234|     33|    {
  235|     33|      gcry_md_putc ( md, 0x9a );     /* ctb */
  236|     33|      gcry_md_putc ( md, n >> 24 );  /* 4 byte length header */
  237|     33|      gcry_md_putc ( md, n >> 16 );
  238|     33|      gcry_md_putc ( md, n >>  8 );
  239|     33|      gcry_md_putc ( md, n       );
  240|     33|      gcry_md_putc ( md, pk->version );
  241|     33|    }
  242|  1.14k|  else
  243|  1.14k|    {
  244|  1.14k|      gcry_md_putc ( md, 0x99 );     /* ctb */
  245|  1.14k|      gcry_md_putc ( md, n >> 8 );   /* 2 byte length header */
  246|  1.14k|      gcry_md_putc ( md, n );
  247|  1.14k|      gcry_md_putc ( md, pk->version );
  248|  1.14k|    }
  249|  1.17k|  gcry_md_putc ( md, pk->timestamp >> 24 );
  250|  1.17k|  gcry_md_putc ( md, pk->timestamp >> 16 );
  251|  1.17k|  gcry_md_putc ( md, pk->timestamp >>  8 );
  252|  1.17k|  gcry_md_putc ( md, pk->timestamp       );
  253|       |
  254|  1.17k|  gcry_md_putc ( md, pk->pubkey_algo );
  255|       |
  256|  1.17k|  if (is_v5)
  ------------------
  |  Branch (256:7): [True: 33, False: 1.14k]
  ------------------
  257|     33|    {
  258|     33|      n -= 10;
  259|     33|      gcry_md_putc ( md, n >> 24 );
  260|     33|      gcry_md_putc ( md, n >> 16 );
  261|     33|      gcry_md_putc ( md, n >>  8 );
  262|     33|      gcry_md_putc ( md, n       );
  263|     33|    }
  264|       |
  265|  1.17k|  if(npkey==0 && pk->pkey[0]
  ------------------
  |  Branch (265:6): [True: 918, False: 259]
  |  Branch (265:18): [True: 918, False: 0]
  ------------------
  266|  1.17k|     && gcry_mpi_get_flag (pk->pkey[0], GCRYMPI_FLAG_OPAQUE))
  ------------------
  |  Branch (266:9): [True: 918, False: 0]
  ------------------
  267|    918|    {
  268|    918|      if (pp[0])
  ------------------
  |  Branch (268:11): [True: 792, False: 126]
  ------------------
  269|    792|        gcry_md_write (md, pp[0], nn[0]);
  270|    918|    }
  271|    259|  else
  272|    259|    {
  273|    777|      for(i=0; i < npkey; i++ )
  ------------------
  |  Branch (273:16): [True: 518, False: 259]
  ------------------
  274|    518|        {
  275|    518|          if (pp[i])
  ------------------
  |  Branch (275:15): [True: 518, False: 0]
  ------------------
  276|    518|            gcry_md_write ( md, pp[i], nn[i] );
  277|    518|          xfree(pp[i]);
  ------------------
  |  |  104|    518|#define xfree(a)         gcry_free ((a))
  ------------------
  278|    518|        }
  279|    259|    }
  280|  1.17k|}
pk_keyid:
  314|  2.23k|{
  315|  2.23k|  keyid_from_pk (pk, NULL);
  316|       |
  317|       |  /* Uncomment this for help tracking down bugs related to keyid or
  318|       |     main_keyid not being set correctly.  */
  319|       |#if 0
  320|       |  if (! (pk->main_keyid[0] || pk->main_keyid[1]))
  321|       |    log_bug ("pk->main_keyid not set!\n");
  322|       |  if (keyid_cmp (pk->keyid, pk->main_keyid) == 0
  323|       |      && ! pk->flags.primary)
  324|       |    log_bug ("keyid and main_keyid are the same, but primary flag not set!\n");
  325|       |  if (keyid_cmp (pk->keyid, pk->main_keyid) != 0
  326|       |      && pk->flags.primary)
  327|       |    log_bug ("keyid and main_keyid are different, but primary flag set!\n");
  328|       |#endif
  329|       |
  330|  2.23k|  return pk->keyid;
  331|  2.23k|}
format_keyid:
  359|  3.73k|{
  360|  3.73k|  if (! buffer)
  ------------------
  |  Branch (360:7): [True: 0, False: 3.73k]
  ------------------
  361|      0|    {
  362|      0|      len = KEYID_STR_SIZE;
  ------------------
  |  |   41|      0|#define KEYID_STR_SIZE 19
  ------------------
  363|      0|      buffer = xtrymalloc (len);
  ------------------
  |  |   97|      0|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  364|      0|      if (!buffer)
  ------------------
  |  Branch (364:11): [True: 0, False: 0]
  ------------------
  365|      0|        return NULL;
  366|      0|    }
  367|       |
  368|  3.73k|  if (format == KF_DEFAULT)
  ------------------
  |  Branch (368:7): [True: 0, False: 3.73k]
  ------------------
  369|      0|    format = opt.keyid_format;
  370|  3.73k|  if (format == KF_DEFAULT)
  ------------------
  |  Branch (370:7): [True: 0, False: 3.73k]
  ------------------
  371|      0|    format = KF_NONE;
  372|       |
  373|  3.73k|  switch (format)
  374|  3.73k|    {
  375|      0|    case KF_NONE:
  ------------------
  |  Branch (375:5): [True: 0, False: 3.73k]
  ------------------
  376|      0|      if (len)
  ------------------
  |  Branch (376:11): [True: 0, False: 0]
  ------------------
  377|      0|        *buffer = 0;
  378|      0|      break;
  379|       |
  380|      0|    case KF_SHORT:
  ------------------
  |  Branch (380:5): [True: 0, False: 3.73k]
  ------------------
  381|      0|      snprintf (buffer, len, "%08lX", (ulong)keyid[1]);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  382|      0|      break;
  383|       |
  384|  3.73k|    case KF_LONG:
  ------------------
  |  Branch (384:5): [True: 3.73k, False: 0]
  ------------------
  385|  3.73k|      snprintf (buffer, len, "%08lX%08lX", (ulong)keyid[0], (ulong)keyid[1]);
  ------------------
  |  |   84|  3.73k|#define snprintf gpgrt_snprintf
  ------------------
  386|  3.73k|      break;
  387|       |
  388|      0|    case KF_0xSHORT:
  ------------------
  |  Branch (388:5): [True: 0, False: 3.73k]
  ------------------
  389|      0|      snprintf (buffer, len, "0x%08lX", (ulong)keyid[1]);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  390|      0|      break;
  391|       |
  392|      0|    case KF_0xLONG:
  ------------------
  |  Branch (392:5): [True: 0, False: 3.73k]
  ------------------
  393|      0|      snprintf (buffer, len, "0x%08lX%08lX", (ulong)keyid[0],(ulong)keyid[1]);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  394|      0|      break;
  395|       |
  396|      0|    default:
  ------------------
  |  Branch (396:5): [True: 0, False: 3.73k]
  ------------------
  397|      0|      BUG();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  398|  3.73k|    }
  399|       |
  400|  3.73k|  return buffer;
  401|  3.73k|}
keystr:
  435|  3.73k|{
  436|  3.73k|  static char keyid_str[KEYID_STR_SIZE];
  437|  3.73k|  int format = opt.keyid_format;
  438|       |
  439|  3.73k|  if (format == KF_DEFAULT)
  ------------------
  |  Branch (439:7): [True: 3.73k, False: 0]
  ------------------
  440|  3.73k|    format = KF_NONE;
  441|  3.73k|  if (format == KF_NONE)
  ------------------
  |  Branch (441:7): [True: 3.73k, False: 0]
  ------------------
  442|  3.73k|    format = KF_LONG;
  443|       |
  444|  3.73k|  return format_keyid (keyid, format, keyid_str, sizeof (keyid_str));
  445|  3.73k|}
keystr_from_pk:
  472|  1.10k|{
  473|  1.10k|  keyid_from_pk(pk,NULL);
  474|       |
  475|  1.10k|  return keystr(pk->keyid);
  476|  1.10k|}
pk_keyid_str:
  494|    758|{
  495|    758|  return keystr (pk_keyid (pk));
  496|    758|}
keyid_from_pk:
  572|  5.65k|{
  573|  5.65k|  u32 dummy_keyid[2];
  574|       |
  575|  5.65k|  if (!keyid)
  ------------------
  |  Branch (575:7): [True: 3.33k, False: 2.31k]
  ------------------
  576|  3.33k|    keyid = dummy_keyid;
  577|       |
  578|  5.65k|  if (!pk->fprlen)
  ------------------
  |  Branch (578:7): [True: 1.00k, False: 4.64k]
  ------------------
  579|  1.00k|    compute_fingerprint (pk);
  580|       |
  581|  5.65k|  keyid[0] = pk->keyid[0];
  582|  5.65k|  keyid[1] = pk->keyid[1];
  583|       |
  584|  5.65k|  if (pk->fprlen == 32)
  ------------------
  |  Branch (584:7): [True: 101, False: 5.54k]
  ------------------
  585|    101|    return keyid[0];
  586|  5.54k|  else
  587|  5.54k|    return keyid[1];
  588|  5.65k|}
keyid_from_fingerprint:
  599|     14|{
  600|     14|  u32 dummy_keyid[2];
  601|       |
  602|     14|  if( !keyid )
  ------------------
  |  Branch (602:7): [True: 0, False: 14]
  ------------------
  603|      0|    keyid = dummy_keyid;
  604|       |
  605|     14|  if (fprint_len != 20 && fprint_len != 32)
  ------------------
  |  Branch (605:7): [True: 0, False: 14]
  |  Branch (605:27): [True: 0, False: 0]
  ------------------
  606|      0|    {
  607|       |      /* This is special as we have to lookup the key first.  */
  608|      0|      PKT_public_key pk;
  609|      0|      int rc;
  610|       |
  611|      0|      memset (&pk, 0, sizeof pk);
  612|      0|      rc = get_pubkey_byfprint (ctrl, &pk, NULL, fprint, fprint_len);
  613|      0|      if( rc )
  ------------------
  |  Branch (613:11): [True: 0, False: 0]
  ------------------
  614|      0|        {
  615|      0|          log_printhex (fprint, fprint_len,
  616|      0|                        "Oops: keyid_from_fingerprint: no pubkey; fpr:");
  617|      0|          keyid[0] = 0;
  618|      0|          keyid[1] = 0;
  619|      0|        }
  620|      0|      else
  621|      0|        keyid_from_pk (&pk, keyid);
  622|      0|    }
  623|     14|  else
  624|     14|    {
  625|     14|      const byte *dp = fprint;
  626|     14|      if (fprint_len == 20)  /* v4 key */
  ------------------
  |  Branch (626:11): [True: 14, False: 0]
  ------------------
  627|     14|        {
  628|     14|          keyid[0] = buf32_to_u32 (dp+12);
  629|     14|          keyid[1] = buf32_to_u32 (dp+16);
  630|     14|        }
  631|      0|      else  /* v5 key */
  632|      0|        {
  633|      0|          keyid[0] = buf32_to_u32 (dp);
  634|      0|          keyid[1] = buf32_to_u32 (dp+4);
  635|      0|        }
  636|     14|    }
  637|       |
  638|     14|  return keyid[1];
  639|     14|}
fingerprint_from_pk:
  877|  1.17k|{
  878|  1.17k|  if (!pk->fprlen)
  ------------------
  |  Branch (878:7): [True: 10, False: 1.16k]
  ------------------
  879|     10|    compute_fingerprint (pk);
  880|       |
  881|  1.17k|  if (!array)
  ------------------
  |  Branch (881:7): [True: 0, False: 1.17k]
  ------------------
  882|      0|    array = xmalloc (pk->fprlen);
  ------------------
  |  |  107|      0|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  883|  1.17k|  memcpy (array, pk->fpr, pk->fprlen);
  884|       |
  885|  1.17k|  if (ret_len)
  ------------------
  |  Branch (885:7): [True: 1.17k, False: 0]
  ------------------
  886|  1.17k|    *ret_len = pk->fprlen;
  887|  1.17k|  return array;
  888|  1.17k|}
fpr20_from_pk:
  903|      2|{
  904|      2|  if (!pk->fprlen)
  ------------------
  |  Branch (904:7): [True: 0, False: 2]
  ------------------
  905|      0|    compute_fingerprint (pk);
  906|       |
  907|      2|  if (!array)
  ------------------
  |  Branch (907:7): [True: 0, False: 2]
  ------------------
  908|      0|    array = xmalloc (pk->fprlen);
  ------------------
  |  |  107|      0|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  909|       |
  910|      2|  if (pk->fprlen == 32)         /* v5 fingerprint */
  ------------------
  |  Branch (910:7): [True: 0, False: 2]
  ------------------
  911|      0|    {
  912|      0|      memcpy (array +  0, pk->fpr + 20, 4);
  913|      0|      memcpy (array +  4, pk->fpr + 24, 4);
  914|      0|      memcpy (array +  8, pk->fpr + 28, 4);
  915|      0|      memcpy (array + 12, pk->fpr +  0, 4); /* kid[0] */
  916|      0|      memcpy (array + 16, pk->fpr +  4, 4); /* kid[1] */
  917|      0|    }
  918|      2|  else                          /* v4 fingerprint */
  919|      2|    memcpy (array, pk->fpr, 20);
  920|      2|}
keyid.c:compute_fingerprint:
  538|  1.01k|{
  539|  1.01k|  const byte *dp;
  540|  1.01k|  gcry_md_hd_t md;
  541|  1.01k|  size_t len;
  542|       |
  543|  1.01k|  if (gcry_md_open (&md, pk->version == 5 ? GCRY_MD_SHA256 : GCRY_MD_SHA1, 0))
  ------------------
  |  Branch (543:7): [True: 0, False: 1.01k]
  |  Branch (543:26): [True: 33, False: 980]
  ------------------
  544|      0|    BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  545|  1.01k|  hash_public_key (md, pk);
  546|  1.01k|  gcry_md_final (md);
  547|  1.01k|  dp = gcry_md_read (md, 0);
  548|  1.01k|  len = gcry_md_get_algo_dlen (gcry_md_get_algo (md));
  549|  1.01k|  log_assert (len <= MAX_FINGERPRINT_LEN);
  550|      0|  memcpy (pk->fpr, dp, len);
  551|  1.01k|  pk->fprlen = len;
  552|  1.01k|  if (pk->version == 5)
  ------------------
  |  Branch (552:7): [True: 33, False: 980]
  ------------------
  553|     33|    {
  554|     33|      pk->keyid[0] = buf32_to_u32 (dp);
  555|     33|      pk->keyid[1] = buf32_to_u32 (dp+4);
  556|     33|    }
  557|    980|  else
  558|    980|    {
  559|    980|      pk->keyid[0] = buf32_to_u32 (dp+12);
  560|    980|      pk->keyid[1] = buf32_to_u32 (dp+16);
  561|    980|    }
  562|  1.01k|  gcry_md_close( md);
  563|  1.01k|}

public_key_list:
  146|      1|{
  147|      1|#ifndef NO_TRUST_MODELS
  148|      1|  if (opt.with_colons)
  ------------------
  |  Branch (148:7): [True: 0, False: 1]
  ------------------
  149|      0|    {
  150|      0|      byte trust_model, marginals, completes, cert_depth, min_cert_level;
  151|      0|      ulong created, nextcheck;
  152|       |
  153|      0|      read_trust_options (ctrl, &trust_model, &created, &nextcheck,
  154|      0|			  &marginals, &completes, &cert_depth, &min_cert_level);
  155|       |
  156|      0|      es_fprintf (es_stdout, "tru:");
  157|       |
  158|      0|      if (nextcheck && nextcheck <= make_timestamp ())
  ------------------
  |  Branch (158:11): [True: 0, False: 0]
  |  Branch (158:24): [True: 0, False: 0]
  ------------------
  159|      0|	es_fprintf (es_stdout, "o");
  160|      0|      if (trust_model != opt.trust_model)
  ------------------
  |  Branch (160:11): [True: 0, False: 0]
  ------------------
  161|      0|	es_fprintf (es_stdout, "t");
  162|      0|      if (opt.trust_model == TM_PGP || opt.trust_model == TM_CLASSIC
  ------------------
  |  Branch (162:11): [True: 0, False: 0]
  |  Branch (162:40): [True: 0, False: 0]
  ------------------
  163|      0|	  || opt.trust_model == TM_TOFU_PGP)
  ------------------
  |  Branch (163:7): [True: 0, False: 0]
  ------------------
  164|      0|	{
  165|      0|	  if (marginals != opt.marginals_needed)
  ------------------
  |  Branch (165:8): [True: 0, False: 0]
  ------------------
  166|      0|	    es_fprintf (es_stdout, "m");
  167|      0|	  if (completes != opt.completes_needed)
  ------------------
  |  Branch (167:8): [True: 0, False: 0]
  ------------------
  168|      0|	    es_fprintf (es_stdout, "c");
  169|      0|	  if (cert_depth != opt.max_cert_depth)
  ------------------
  |  Branch (169:8): [True: 0, False: 0]
  ------------------
  170|      0|	    es_fprintf (es_stdout, "d");
  171|      0|	  if (min_cert_level != opt.min_cert_level)
  ------------------
  |  Branch (171:8): [True: 0, False: 0]
  ------------------
  172|      0|	    es_fprintf (es_stdout, "l");
  173|      0|	}
  174|       |
  175|      0|      es_fprintf (es_stdout, ":%d:%lu:%lu", trust_model, created, nextcheck);
  176|       |
  177|       |      /* Only show marginals, completes, and cert_depth in the classic
  178|       |         or PGP trust models since they are not meaningful
  179|       |         otherwise. */
  180|       |
  181|      0|      if (trust_model == TM_PGP || trust_model == TM_CLASSIC)
  ------------------
  |  Branch (181:11): [True: 0, False: 0]
  |  Branch (181:36): [True: 0, False: 0]
  ------------------
  182|      0|	es_fprintf (es_stdout, ":%d:%d:%d", marginals, completes, cert_depth);
  183|      0|      es_fprintf (es_stdout, "\n");
  184|      0|    }
  185|      1|#endif /*!NO_TRUST_MODELS*/
  186|       |
  187|       |  /* We need to do the stale check right here because it might need to
  188|       |     update the keyring while we already have the keyring open.  This
  189|       |     is very bad for W32 because of a sharing violation. For real OSes
  190|       |     it might lead to false results if we are later listing a keyring
  191|       |     which is associated with the inode of a deleted file.  */
  192|      1|  check_trustdb_stale (ctrl);
  193|       |
  194|       |#ifdef USE_TOFU
  195|       |  tofu_begin_batch_update (ctrl);
  196|       |#endif
  197|       |
  198|      1|  if (locate_mode)
  ------------------
  |  Branch (198:7): [True: 0, False: 1]
  ------------------
  199|      0|    locate_one (ctrl, list, no_local);
  200|      1|  else if (!list)
  ------------------
  |  Branch (200:12): [True: 1, False: 0]
  ------------------
  201|      1|    list_all (ctrl, 0, opt.with_secret);
  202|      0|  else
  203|      0|    list_one (ctrl, list, 0, opt.with_secret);
  204|       |
  205|       |#ifdef USE_TOFU
  206|       |  tofu_end_batch_update (ctrl);
  207|       |#endif
  208|      1|}
keylist.c:list_all:
  741|      1|{
  742|      1|  KEYDB_HANDLE hd;
  743|      1|  KBNODE keyblock = NULL;
  744|      1|  int rc = 0;
  745|      1|  int any_secret;
  746|      1|  const char *lastresname, *resname;
  747|      1|  struct keylist_context listctx;
  748|       |
  749|      1|  memset (&listctx, 0, sizeof (listctx));
  750|      1|  if (opt.check_sigs)
  ------------------
  |  Branch (750:7): [True: 0, False: 1]
  ------------------
  751|      0|    listctx.check_sigs = 1;
  752|       |
  753|      1|  hd = keydb_new (ctrl);
  754|      1|  if (!hd)
  ------------------
  |  Branch (754:7): [True: 0, False: 1]
  ------------------
  755|      0|    rc = gpg_error_from_syserror ();
  756|      1|  else
  757|      1|    rc = keydb_search_first (hd);
  758|      1|  if (rc)
  ------------------
  |  Branch (758:7): [True: 1, False: 0]
  ------------------
  759|      1|    {
  760|      1|      if (gpg_err_code (rc) != GPG_ERR_NOT_FOUND)
  ------------------
  |  Branch (760:11): [True: 0, False: 1]
  ------------------
  761|      0|	log_error ("keydb_search_first failed: %s\n", gpg_strerror (rc));
  762|      1|      goto leave;
  763|      1|    }
  764|       |
  765|      0|  lastresname = NULL;
  766|      0|  do
  767|      0|    {
  768|      0|      if (secret)
  ------------------
  |  Branch (768:11): [True: 0, False: 0]
  ------------------
  769|      0|        glo_ctrl.silence_parse_warnings++;
  770|      0|      rc = keydb_get_keyblock (hd, &keyblock);
  771|      0|      if (secret)
  ------------------
  |  Branch (771:11): [True: 0, False: 0]
  ------------------
  772|      0|        glo_ctrl.silence_parse_warnings--;
  773|      0|      if (rc)
  ------------------
  |  Branch (773:11): [True: 0, False: 0]
  ------------------
  774|      0|	{
  775|      0|          if (gpg_err_code (rc) == GPG_ERR_LEGACY_KEY)
  ------------------
  |  Branch (775:15): [True: 0, False: 0]
  ------------------
  776|      0|            continue;  /* Skip legacy keys.  */
  777|      0|	  log_error ("keydb_get_keyblock failed: %s\n", gpg_strerror (rc));
  778|      0|	  goto leave;
  779|      0|	}
  780|       |
  781|      0|      if (secret || mark_secret)
  ------------------
  |  Branch (781:11): [True: 0, False: 0]
  |  Branch (781:21): [True: 0, False: 0]
  ------------------
  782|      0|        any_secret = !agent_probe_any_secret_key (ctrl, keyblock);
  783|      0|      else
  784|      0|        any_secret = 0;
  785|       |
  786|      0|      if (secret && !any_secret)
  ------------------
  |  Branch (786:11): [True: 0, False: 0]
  |  Branch (786:21): [True: 0, False: 0]
  ------------------
  787|      0|        ; /* Secret key listing requested but this isn't one.  */
  788|      0|      else
  789|      0|        {
  790|      0|          if (!opt.with_colons && !(opt.list_options & LIST_SHOW_ONLY_FPR_MBOX))
  ------------------
  |  |  425|      0|#define LIST_SHOW_ONLY_FPR_MBOX          (1<<12)
  ------------------
  |  Branch (790:15): [True: 0, False: 0]
  |  Branch (790:35): [True: 0, False: 0]
  ------------------
  791|      0|            {
  792|      0|              resname = keydb_get_resource_name (hd);
  793|      0|              if (lastresname != resname)
  ------------------
  |  Branch (793:19): [True: 0, False: 0]
  ------------------
  794|      0|                {
  795|      0|                  int i;
  796|       |
  797|      0|                  es_fprintf (es_stdout, "%s\n", resname);
  798|      0|                  for (i = strlen (resname); i; i--)
  ------------------
  |  Branch (798:46): [True: 0, False: 0]
  ------------------
  799|      0|                    es_putc ('-', es_stdout);
  800|      0|                  es_putc ('\n', es_stdout);
  801|      0|                  lastresname = resname;
  802|      0|                }
  803|      0|            }
  804|      0|          merge_keys_and_selfsig (ctrl, keyblock);
  805|      0|          list_keyblock (ctrl, keyblock, secret, any_secret, opt.fingerprint,
  806|      0|                         &listctx);
  807|      0|        }
  808|      0|      release_kbnode (keyblock);
  809|      0|      keyblock = NULL;
  810|      0|    }
  811|      0|  while (!(rc = keydb_search_next (hd)));
  ------------------
  |  Branch (811:10): [True: 0, False: 0]
  ------------------
  812|      0|  es_fflush (es_stdout);
  813|      0|  if (rc && gpg_err_code (rc) != GPG_ERR_NOT_FOUND)
  ------------------
  |  Branch (813:7): [True: 0, False: 0]
  |  Branch (813:13): [True: 0, False: 0]
  ------------------
  814|      0|    log_error ("keydb_search_next failed: %s\n", gpg_strerror (rc));
  815|      0|  if (keydb_get_skipped_counter (hd))
  ------------------
  |  Branch (815:7): [True: 0, False: 0]
  ------------------
  816|      0|    log_info (ngettext("Warning: %lu key skipped due to its large size\n",
  817|      0|                       "Warning: %lu keys skipped due to their large sizes\n",
  818|      0|                       keydb_get_skipped_counter (hd)),
  819|      0|              keydb_get_skipped_counter (hd));
  820|       |
  821|      0|  if (opt.check_sigs && !opt.with_colons)
  ------------------
  |  Branch (821:7): [True: 0, False: 0]
  |  Branch (821:25): [True: 0, False: 0]
  ------------------
  822|      0|    print_signature_stats (&listctx);
  823|       |
  824|      1| leave:
  825|      1|  keylist_context_release (&listctx);
  826|      1|  release_kbnode (keyblock);
  827|      1|  keydb_release (hd);
  828|      1|}
keylist.c:keylist_context_release:
   92|      1|{
   93|      1|  (void)listctx; /* Nothing to release.  */
   94|      1|}

keyring_is_writable:
  228|      2|{
  229|      2|  KR_RESOURCE r = token;
  230|       |
  231|      2|  return r? (r->read_only || !gnupg_access (r->fname, W_OK)) : 0;
  ------------------
  |  Branch (231:10): [True: 2, False: 0]
  |  Branch (231:14): [True: 0, False: 2]
  |  Branch (231:30): [True: 0, False: 2]
  ------------------
  232|      2|}

is_secured_file:
  164|     53|{
  165|       |#ifdef ENABLE_SELINUX_HACKS
  166|       |  struct stat buf;
  167|       |  struct secured_file_item *sf;
  168|       |
  169|       |  if (fd == -1)
  170|       |    return 0; /* No file descriptor so it can't be secured either.  */
  171|       |
  172|       |  /* Note that we print out a error here and claim that a file is
  173|       |     secure if something went wrong. */
  174|       |  if (fstat (fd, &buf))
  175|       |    {
  176|       |      log_error (_("fstat(%d) failed in %s: %s\n"), fd,
  177|       |                 "is_secured_file", strerror (errno));
  178|       |      return 1;
  179|       |    }
  180|       |/*   log_debug ("is_secured_file (%d) i=%lu.%lu\n", fd, */
  181|       |/*              (unsigned long)buf.st_dev, (unsigned long)buf.st_ino); */
  182|       |  for (sf=secured_files; sf; sf = sf->next)
  183|       |    {
  184|       |      if (sf->ino == buf.st_ino && sf->dev == buf.st_dev)
  185|       |        return 1; /* Yes.  */
  186|       |    }
  187|       |#else /*!ENABLE_SELINUX_HACKS*/
  188|     53|  (void)fd;
  189|     53|#endif /*!ENABLE_SELINUX_HACKS*/
  190|     53|  return 0; /* No. */
  191|     53|}
is_secured_filename:
  199|      2|{
  200|       |#ifdef ENABLE_SELINUX_HACKS
  201|       |  struct stat buf;
  202|       |  struct secured_file_item *sf;
  203|       |
  204|       |  if (iobuf_is_pipe_filename (fname) || !*fname)
  205|       |    return 0;
  206|       |
  207|       |  /* Note that we print out a error here and claim that a file is
  208|       |     secure if something went wrong. */
  209|       |  if (gnupg_stat (fname, &buf))
  210|       |    {
  211|       |      if (errno == ENOENT || errno == EPERM || errno == EACCES)
  212|       |        return 0;
  213|       |      log_error (_("fstat of '%s' failed in %s: %s\n"), fname,
  214|       |                 "is_secured_filename", strerror (errno));
  215|       |      return 1;
  216|       |    }
  217|       |/*   log_debug ("is_secured_filename (%s) i=%lu.%lu\n", fname, */
  218|       |/*              (unsigned long)buf.st_dev, (unsigned long)buf.st_ino); */
  219|       |  for (sf=secured_files; sf; sf = sf->next)
  220|       |    {
  221|       |      if (sf->ino == buf.st_ino && sf->dev == buf.st_dev)
  222|       |        return 1; /* Yes.  */
  223|       |    }
  224|       |#else /*!ENABLE_SELINUX_HACKS*/
  225|      2|  (void)fname;
  226|      2|#endif /*!ENABLE_SELINUX_HACKS*/
  227|      2|  return 0; /* No. */
  228|      2|}
openpgp_cipher_blocklen:
  552|    364|{
  553|       |  /* We use the numbers from OpenPGP to be sure that we get the right
  554|       |     block length.  This is so that the packet parsing code works even
  555|       |     for unknown algorithms (for which we assume 8 due to tradition).
  556|       |
  557|       |     NOTE: If you change the returned blocklen above 16, check
  558|       |     the callers because they may use a fixed size buffer of that
  559|       |     size. */
  560|    364|  switch (algo)
  561|    364|    {
  562|      0|    case CIPHER_ALGO_AES:
  ------------------
  |  Branch (562:5): [True: 0, False: 364]
  ------------------
  563|      0|    case CIPHER_ALGO_AES192:
  ------------------
  |  Branch (563:5): [True: 0, False: 364]
  ------------------
  564|      0|    case CIPHER_ALGO_AES256:
  ------------------
  |  Branch (564:5): [True: 0, False: 364]
  ------------------
  565|      0|    case CIPHER_ALGO_TWOFISH:
  ------------------
  |  Branch (565:5): [True: 0, False: 364]
  ------------------
  566|      0|    case CIPHER_ALGO_CAMELLIA128:
  ------------------
  |  Branch (566:5): [True: 0, False: 364]
  ------------------
  567|      0|    case CIPHER_ALGO_CAMELLIA192:
  ------------------
  |  Branch (567:5): [True: 0, False: 364]
  ------------------
  568|      0|    case CIPHER_ALGO_CAMELLIA256:
  ------------------
  |  Branch (568:5): [True: 0, False: 364]
  ------------------
  569|      0|      return 16;
  570|       |
  571|    364|    default:
  ------------------
  |  Branch (571:5): [True: 364, False: 0]
  ------------------
  572|    364|      return 8;
  573|    364|    }
  574|    364|}
openpgp_pk_test_algo:
  701|   127k|{
  702|   127k|  return openpgp_pk_test_algo2 (algo, 0);
  703|   127k|}
openpgp_pk_test_algo2:
  710|   127k|{
  711|   127k|  enum gcry_pk_algos ga = 0;
  712|   127k|  size_t use_buf = use;
  713|       |
  714|   127k|  switch (algo)
  715|   127k|    {
  716|      0|#ifdef GPG_USE_RSA
  717|     69|    case PUBKEY_ALGO_RSA:       ga = GCRY_PK_RSA;   break;
  ------------------
  |  Branch (717:5): [True: 69, False: 127k]
  ------------------
  718|      6|    case PUBKEY_ALGO_RSA_E:     ga = GCRY_PK_RSA_E; break;
  ------------------
  |  Branch (718:5): [True: 6, False: 127k]
  ------------------
  719|      0|    case PUBKEY_ALGO_RSA_S:     ga = GCRY_PK_RSA_S; break;
  ------------------
  |  Branch (719:5): [True: 0, False: 127k]
  ------------------
  720|       |#else
  721|       |    case PUBKEY_ALGO_RSA:       break;
  722|       |    case PUBKEY_ALGO_RSA_E:     break;
  723|       |    case PUBKEY_ALGO_RSA_S:     break;
  724|       |#endif
  725|       |
  726|   126k|    case PUBKEY_ALGO_ELGAMAL_E: ga = GCRY_PK_ELG;   break;
  ------------------
  |  Branch (726:5): [True: 126k, False: 866]
  ------------------
  727|      0|    case PUBKEY_ALGO_DSA:       ga = GCRY_PK_DSA;   break;
  ------------------
  |  Branch (727:5): [True: 0, False: 127k]
  ------------------
  728|       |
  729|      0|#ifdef GPG_USE_ECDH
  730|    514|    case PUBKEY_ALGO_ECDH:      ga = GCRY_PK_ECC;   break;
  ------------------
  |  Branch (730:5): [True: 514, False: 127k]
  ------------------
  731|       |#else
  732|       |    case PUBKEY_ALGO_ECDH:      break;
  733|       |#endif
  734|       |
  735|      0|#ifdef GPG_USE_ECDSA
  736|     40|    case PUBKEY_ALGO_ECDSA:     ga = GCRY_PK_ECC;   break;
  ------------------
  |  Branch (736:5): [True: 40, False: 127k]
  ------------------
  737|       |#else
  738|       |    case PUBKEY_ALGO_ECDSA:     break;
  739|       |#endif
  740|       |
  741|      0|#ifdef GPG_USE_EDDSA
  742|      0|    case PUBKEY_ALGO_EDDSA:     ga = GCRY_PK_ECC;   break;
  ------------------
  |  Branch (742:5): [True: 0, False: 127k]
  ------------------
  743|       |#else
  744|       |    case PUBKEY_ALGO_EDDSA:     break;
  745|       |#endif
  746|       |
  747|      0|    case PUBKEY_ALGO_ELGAMAL:
  ------------------
  |  Branch (747:5): [True: 0, False: 127k]
  ------------------
  748|       |      /* Don't allow type 20 keys unless in rfc2440 mode.  */
  749|      0|      if (RFC2440)
  ------------------
  |  |  373|      0|#define RFC2440 (opt.compliance==CO_RFC2440)
  |  |  ------------------
  |  |  |  Branch (373:17): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  750|      0|        ga = GCRY_PK_ELG;
  751|      0|      break;
  752|       |
  753|    237|    default:
  ------------------
  |  Branch (753:5): [True: 237, False: 127k]
  ------------------
  754|    237|      break;
  755|   127k|    }
  756|   127k|  if (!ga)
  ------------------
  |  Branch (756:7): [True: 237, False: 127k]
  ------------------
  757|    237|    return gpg_error (GPG_ERR_PUBKEY_ALGO);
  758|       |
  759|       |  /* Elgamal in OpenPGP used to support signing and Libgcrypt still
  760|       |   * does.  However, we removed the signing capability from gpg ages
  761|       |   * ago.  This function should reflect this so that errors are thrown
  762|       |   * early and not only when we try to sign using Elgamal.  */
  763|   127k|  if (ga == GCRY_PK_ELG && (use & (PUBKEY_USAGE_CERT | PUBKEY_USAGE_SIG)))
  ------------------
  |  |   51|   126k|#define PUBKEY_USAGE_CERT    GCRY_PK_USAGE_CERT  /* Also good to certify keys.*/
  ------------------
                if (ga == GCRY_PK_ELG && (use & (PUBKEY_USAGE_CERT | PUBKEY_USAGE_SIG)))
  ------------------
  |  |   49|   126k|#define PUBKEY_USAGE_SIG     GCRY_PK_USAGE_SIGN  /* Good for signatures. */
  ------------------
  |  Branch (763:7): [True: 126k, False: 629]
  |  Branch (763:28): [True: 0, False: 126k]
  ------------------
  764|      0|    return gpg_error (GPG_ERR_WRONG_PUBKEY_ALGO);
  765|       |
  766|       |  /* Now check whether Libgcrypt has support for the algorithm.  */
  767|   127k|  return gcry_pk_algo_info (ga, GCRYCTL_TEST_ALGO, NULL, &use_buf);
  768|   127k|}
openpgp_pk_algo_usage:
  773|     21|{
  774|     21|    int use = 0;
  775|       |
  776|       |    /* They are hardwired in gpg 1.0. */
  777|     21|    switch ( algo ) {
  778|     12|      case PUBKEY_ALGO_RSA:
  ------------------
  |  Branch (778:7): [True: 12, False: 9]
  ------------------
  779|     12|          use = (PUBKEY_USAGE_CERT | PUBKEY_USAGE_SIG
  ------------------
  |  |   51|     12|#define PUBKEY_USAGE_CERT    GCRY_PK_USAGE_CERT  /* Also good to certify keys.*/
  ------------------
                        use = (PUBKEY_USAGE_CERT | PUBKEY_USAGE_SIG
  ------------------
  |  |   49|     12|#define PUBKEY_USAGE_SIG     GCRY_PK_USAGE_SIGN  /* Good for signatures. */
  ------------------
  780|     12|                 | PUBKEY_USAGE_ENC | PUBKEY_USAGE_AUTH);
  ------------------
  |  |   50|     12|#define PUBKEY_USAGE_ENC     GCRY_PK_USAGE_ENCR  /* Good for encryption. */
  ------------------
                               | PUBKEY_USAGE_ENC | PUBKEY_USAGE_AUTH);
  ------------------
  |  |   52|     12|#define PUBKEY_USAGE_AUTH    GCRY_PK_USAGE_AUTH  /* Good for authentication. */
  ------------------
  781|     12|          break;
  782|      0|      case PUBKEY_ALGO_RSA_E:
  ------------------
  |  Branch (782:7): [True: 0, False: 21]
  ------------------
  783|      0|      case PUBKEY_ALGO_ECDH:
  ------------------
  |  Branch (783:7): [True: 0, False: 21]
  ------------------
  784|      0|          use = PUBKEY_USAGE_ENC;
  ------------------
  |  |   50|      0|#define PUBKEY_USAGE_ENC     GCRY_PK_USAGE_ENCR  /* Good for encryption. */
  ------------------
  785|      0|          break;
  786|      0|      case PUBKEY_ALGO_RSA_S:
  ------------------
  |  Branch (786:7): [True: 0, False: 21]
  ------------------
  787|      0|          use = PUBKEY_USAGE_CERT | PUBKEY_USAGE_SIG;
  ------------------
  |  |   51|      0|#define PUBKEY_USAGE_CERT    GCRY_PK_USAGE_CERT  /* Also good to certify keys.*/
  ------------------
                        use = PUBKEY_USAGE_CERT | PUBKEY_USAGE_SIG;
  ------------------
  |  |   49|      0|#define PUBKEY_USAGE_SIG     GCRY_PK_USAGE_SIGN  /* Good for signatures. */
  ------------------
  788|      0|          break;
  789|      0|      case PUBKEY_ALGO_ELGAMAL:
  ------------------
  |  Branch (789:7): [True: 0, False: 21]
  ------------------
  790|      0|          if (RFC2440)
  ------------------
  |  |  373|      0|#define RFC2440 (opt.compliance==CO_RFC2440)
  |  |  ------------------
  |  |  |  Branch (373:17): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  791|      0|             use = PUBKEY_USAGE_ENC;
  ------------------
  |  |   50|      0|#define PUBKEY_USAGE_ENC     GCRY_PK_USAGE_ENCR  /* Good for encryption. */
  ------------------
  792|      0|          break;
  793|      0|      case PUBKEY_ALGO_ELGAMAL_E:
  ------------------
  |  Branch (793:7): [True: 0, False: 21]
  ------------------
  794|      0|          use = PUBKEY_USAGE_ENC;
  ------------------
  |  |   50|      0|#define PUBKEY_USAGE_ENC     GCRY_PK_USAGE_ENCR  /* Good for encryption. */
  ------------------
  795|      0|          break;
  796|      0|      case PUBKEY_ALGO_DSA:
  ------------------
  |  Branch (796:7): [True: 0, False: 21]
  ------------------
  797|      0|          use = PUBKEY_USAGE_CERT | PUBKEY_USAGE_SIG | PUBKEY_USAGE_AUTH;
  ------------------
  |  |   51|      0|#define PUBKEY_USAGE_CERT    GCRY_PK_USAGE_CERT  /* Also good to certify keys.*/
  ------------------
                        use = PUBKEY_USAGE_CERT | PUBKEY_USAGE_SIG | PUBKEY_USAGE_AUTH;
  ------------------
  |  |   49|      0|#define PUBKEY_USAGE_SIG     GCRY_PK_USAGE_SIGN  /* Good for signatures. */
  ------------------
                        use = PUBKEY_USAGE_CERT | PUBKEY_USAGE_SIG | PUBKEY_USAGE_AUTH;
  ------------------
  |  |   52|      0|#define PUBKEY_USAGE_AUTH    GCRY_PK_USAGE_AUTH  /* Good for authentication. */
  ------------------
  798|      0|          break;
  799|      9|      case PUBKEY_ALGO_ECDSA:
  ------------------
  |  Branch (799:7): [True: 9, False: 12]
  ------------------
  800|      9|      case PUBKEY_ALGO_EDDSA:
  ------------------
  |  Branch (800:7): [True: 0, False: 21]
  ------------------
  801|      9|          use = PUBKEY_USAGE_CERT | PUBKEY_USAGE_SIG | PUBKEY_USAGE_AUTH;
  ------------------
  |  |   51|      9|#define PUBKEY_USAGE_CERT    GCRY_PK_USAGE_CERT  /* Also good to certify keys.*/
  ------------------
                        use = PUBKEY_USAGE_CERT | PUBKEY_USAGE_SIG | PUBKEY_USAGE_AUTH;
  ------------------
  |  |   49|      9|#define PUBKEY_USAGE_SIG     GCRY_PK_USAGE_SIGN  /* Good for signatures. */
  ------------------
                        use = PUBKEY_USAGE_CERT | PUBKEY_USAGE_SIG | PUBKEY_USAGE_AUTH;
  ------------------
  |  |   52|      9|#define PUBKEY_USAGE_AUTH    GCRY_PK_USAGE_AUTH  /* Good for authentication. */
  ------------------
  802|      9|      default:
  ------------------
  |  Branch (802:7): [True: 0, False: 21]
  ------------------
  803|      9|          break;
  804|     21|    }
  805|     21|    return use;
  806|     21|}
map_md_openpgp_to_gcry:
  834|   126k|{
  835|   126k|  switch (algo)
  836|   126k|    {
  837|      0|#ifdef GPG_USE_MD5
  838|  78.0k|    case DIGEST_ALGO_MD5:    return GCRY_MD_MD5;
  ------------------
  |  Branch (838:5): [True: 78.0k, False: 48.8k]
  ------------------
  839|       |#else
  840|       |    case DIGEST_ALGO_MD5:    return 0;
  841|       |#endif
  842|       |
  843|     28|    case DIGEST_ALGO_SHA1:   return GCRY_MD_SHA1;
  ------------------
  |  Branch (843:5): [True: 28, False: 126k]
  ------------------
  844|       |
  845|      0|#ifdef GPG_USE_RMD160
  846|      0|    case DIGEST_ALGO_RMD160: return GCRY_MD_RMD160;
  ------------------
  |  Branch (846:5): [True: 0, False: 126k]
  ------------------
  847|       |#else
  848|       |    case DIGEST_ALGO_RMD160: return 0;
  849|       |#endif
  850|       |
  851|      0|#ifdef GPG_USE_SHA224
  852|      0|    case DIGEST_ALGO_SHA224: return GCRY_MD_SHA224;
  ------------------
  |  Branch (852:5): [True: 0, False: 126k]
  ------------------
  853|       |#else
  854|       |    case DIGEST_ALGO_SHA224: return 0;
  855|       |#endif
  856|       |
  857|    114|    case DIGEST_ALGO_SHA256: return GCRY_MD_SHA256;
  ------------------
  |  Branch (857:5): [True: 114, False: 126k]
  ------------------
  858|       |
  859|      0|#ifdef GPG_USE_SHA384
  860|      0|    case DIGEST_ALGO_SHA384: return GCRY_MD_SHA384;
  ------------------
  |  Branch (860:5): [True: 0, False: 126k]
  ------------------
  861|       |#else
  862|       |    case DIGEST_ALGO_SHA384: return 0;
  863|       |#endif
  864|       |
  865|      0|#ifdef GPG_USE_SHA512
  866|  48.6k|    case DIGEST_ALGO_SHA512: return GCRY_MD_SHA512;
  ------------------
  |  Branch (866:5): [True: 48.6k, False: 78.2k]
  ------------------
  867|       |#else
  868|       |    case DIGEST_ALGO_SHA512: return 0;
  869|       |#endif
  870|     38|    default: return 0;
  ------------------
  |  Branch (870:5): [True: 38, False: 126k]
  ------------------
  871|   126k|    }
  872|   126k|}
openpgp_md_test_algo:
  879|   126k|{
  880|   126k|  enum gcry_md_algos ga;
  881|       |
  882|   126k|  ga = map_md_openpgp_to_gcry (algo);
  883|   126k|  if (!ga)
  ------------------
  |  Branch (883:7): [True: 38, False: 126k]
  ------------------
  884|     38|    return gpg_error (GPG_ERR_DIGEST_ALGO);
  885|       |
  886|   126k|  return gcry_md_test_algo (ga);
  887|   126k|}
check_compress_algo:
 1363|      2|{
 1364|      2|  switch (algo)
 1365|      2|    {
 1366|      0|    case 0: return 0;
  ------------------
  |  Branch (1366:5): [True: 0, False: 2]
  ------------------
 1367|       |#ifdef HAVE_ZIP
 1368|       |    case 1:
 1369|       |    case 2: return 0;
 1370|       |#endif
 1371|       |#ifdef HAVE_BZIP2
 1372|       |    case 3: return 0;
 1373|       |#endif
 1374|      2|    default: return GPG_ERR_COMPR_ALGO;
  ------------------
  |  Branch (1374:5): [True: 2, False: 0]
  ------------------
 1375|      2|    }
 1376|      2|}
pubkey_get_npkey:
 1697|  7.41k|{
 1698|  7.41k|  switch (algo)
 1699|  7.41k|    {
 1700|    324|    case PUBKEY_ALGO_RSA:
  ------------------
  |  Branch (1700:5): [True: 324, False: 7.08k]
  ------------------
 1701|    892|    case PUBKEY_ALGO_RSA_E:
  ------------------
  |  Branch (1701:5): [True: 568, False: 6.84k]
  ------------------
 1702|    892|    case PUBKEY_ALGO_RSA_S:     return 2;
  ------------------
  |  Branch (1702:5): [True: 0, False: 7.41k]
  ------------------
 1703|  1.03k|    case PUBKEY_ALGO_ELGAMAL_E: return 3;
  ------------------
  |  Branch (1703:5): [True: 1.03k, False: 6.38k]
  ------------------
 1704|      0|    case PUBKEY_ALGO_DSA:       return 4;
  ------------------
  |  Branch (1704:5): [True: 0, False: 7.41k]
  ------------------
 1705|    145|    case PUBKEY_ALGO_ECDH:      return 3;
  ------------------
  |  Branch (1705:5): [True: 145, False: 7.26k]
  ------------------
 1706|    221|    case PUBKEY_ALGO_ECDSA:     return 2;
  ------------------
  |  Branch (1706:5): [True: 221, False: 7.19k]
  ------------------
 1707|      0|    case PUBKEY_ALGO_ELGAMAL:   return 3;
  ------------------
  |  Branch (1707:5): [True: 0, False: 7.41k]
  ------------------
 1708|     36|    case PUBKEY_ALGO_EDDSA:     return 2;
  ------------------
  |  Branch (1708:5): [True: 36, False: 7.37k]
  ------------------
 1709|  5.08k|    default: return 0;
  ------------------
  |  Branch (1709:5): [True: 5.08k, False: 2.32k]
  ------------------
 1710|  7.41k|    }
 1711|  7.41k|}
pubkey_get_nskey:
 1717|  1.89k|{
 1718|  1.89k|  switch (algo)
 1719|  1.89k|    {
 1720|    477|    case PUBKEY_ALGO_RSA:
  ------------------
  |  Branch (1720:5): [True: 477, False: 1.41k]
  ------------------
 1721|    762|    case PUBKEY_ALGO_RSA_E:
  ------------------
  |  Branch (1721:5): [True: 285, False: 1.61k]
  ------------------
 1722|    762|    case PUBKEY_ALGO_RSA_S:     return 6;
  ------------------
  |  Branch (1722:5): [True: 0, False: 1.89k]
  ------------------
 1723|      0|    case PUBKEY_ALGO_ELGAMAL_E: return 4;
  ------------------
  |  Branch (1723:5): [True: 0, False: 1.89k]
  ------------------
 1724|      0|    case PUBKEY_ALGO_DSA:       return 5;
  ------------------
  |  Branch (1724:5): [True: 0, False: 1.89k]
  ------------------
 1725|     18|    case PUBKEY_ALGO_ECDH:      return 4;
  ------------------
  |  Branch (1725:5): [True: 18, False: 1.87k]
  ------------------
 1726|     97|    case PUBKEY_ALGO_ECDSA:     return 3;
  ------------------
  |  Branch (1726:5): [True: 97, False: 1.79k]
  ------------------
 1727|      0|    case PUBKEY_ALGO_ELGAMAL:   return 4;
  ------------------
  |  Branch (1727:5): [True: 0, False: 1.89k]
  ------------------
 1728|     34|    case PUBKEY_ALGO_EDDSA:     return 3;
  ------------------
  |  Branch (1728:5): [True: 34, False: 1.86k]
  ------------------
 1729|    984|    default: return 0;
  ------------------
  |  Branch (1729:5): [True: 984, False: 911]
  ------------------
 1730|  1.89k|    }
 1731|  1.89k|}
pubkey_get_nsig:
 1736|  4.69k|{
 1737|  4.69k|  switch (algo)
 1738|  4.69k|    {
 1739|     98|    case PUBKEY_ALGO_RSA:
  ------------------
  |  Branch (1739:5): [True: 98, False: 4.59k]
  ------------------
 1740|    137|    case PUBKEY_ALGO_RSA_E:
  ------------------
  |  Branch (1740:5): [True: 39, False: 4.65k]
  ------------------
 1741|    137|    case PUBKEY_ALGO_RSA_S:     return 1;
  ------------------
  |  Branch (1741:5): [True: 0, False: 4.69k]
  ------------------
 1742|  2.86k|    case PUBKEY_ALGO_ELGAMAL_E: return 0;
  ------------------
  |  Branch (1742:5): [True: 2.86k, False: 1.83k]
  ------------------
 1743|     84|    case PUBKEY_ALGO_DSA:       return 2;
  ------------------
  |  Branch (1743:5): [True: 84, False: 4.61k]
  ------------------
 1744|    288|    case PUBKEY_ALGO_ECDH:      return 0;
  ------------------
  |  Branch (1744:5): [True: 288, False: 4.40k]
  ------------------
 1745|    230|    case PUBKEY_ALGO_ECDSA:     return 2;
  ------------------
  |  Branch (1745:5): [True: 230, False: 4.46k]
  ------------------
 1746|      0|    case PUBKEY_ALGO_ELGAMAL:   return 2;
  ------------------
  |  Branch (1746:5): [True: 0, False: 4.69k]
  ------------------
 1747|     32|    case PUBKEY_ALGO_EDDSA:     return 2;
  ------------------
  |  Branch (1747:5): [True: 32, False: 4.66k]
  ------------------
 1748|  1.06k|    default: return 0;
  ------------------
  |  Branch (1748:5): [True: 1.06k, False: 3.63k]
  ------------------
 1749|  4.69k|    }
 1750|  4.69k|}
ecdsa_qbits_from_Q:
 1874|     16|{
 1875|     16|  if ((qbits%8) > 3)
  ------------------
  |  Branch (1875:7): [True: 0, False: 16]
  ------------------
 1876|      0|    {
 1877|      0|      log_error (_("ECDSA public key is expected to be in SEC encoding "
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1878|      0|                   "multiple of 8 bits\n"));
 1879|      0|      return 0;
 1880|      0|    }
 1881|     16|  qbits -= qbits%8;
 1882|     16|  qbits /= 2;
 1883|     16|  return qbits;
 1884|     16|}
is_weak_digest:
 1920|    158|{
 1921|    158|  const enum gcry_md_algos galgo = map_md_openpgp_to_gcry (algo);
 1922|    158|  const struct weakhash *weak;
 1923|       |
 1924|    158|  for (weak = opt.weak_digests; weak; weak = weak->next)
  ------------------
  |  Branch (1924:33): [True: 0, False: 158]
  ------------------
 1925|      0|    if (weak->algo == galgo)
  ------------------
  |  Branch (1925:9): [True: 0, False: 0]
  ------------------
 1926|      0|      return 1;
 1927|    158|  return 0;
 1928|    158|}

cache_put_keyblock:
  557|      4|{
  558|      4|  uid_item_t ui = NULL;
  559|      4|  kbnode_t k;
  560|       |
  561|      5| restart:
  562|     40|  for (k = keyblock; k; k = k->next)
  ------------------
  |  Branch (562:22): [True: 36, False: 4]
  ------------------
  563|     36|    {
  564|     36|      if (k->pkt->pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (564:11): [True: 5, False: 31]
  ------------------
  565|     36|	  || k->pkt->pkttype == PKT_PUBLIC_SUBKEY)
  ------------------
  |  Branch (565:7): [True: 3, False: 28]
  ------------------
  566|      8|	{
  567|      8|          if (!ui)
  ------------------
  |  Branch (567:15): [True: 7, False: 1]
  ------------------
  568|      7|            {
  569|       |              /* Initially we just test for an entry to avoid the need
  570|       |               * to create a user id item for a put.  Only if we miss
  571|       |               * key in the cache we create a user id and restart.  */
  572|      7|              if (!key_table_get (k->pkt->pkt.public_key, NULL))
  ------------------
  |  Branch (572:19): [True: 7, False: 0]
  ------------------
  573|      7|                {
  574|      7|                  const char *uid;
  575|      7|                  size_t uidlen;
  576|       |
  577|      7|                  uid = primary_uid_from_keyblock (keyblock, &uidlen);
  578|      7|                  if (uid)
  ------------------
  |  Branch (578:23): [True: 1, False: 6]
  ------------------
  579|      1|                    {
  580|      1|                      ui = uid_table_put (uid, uidlen);
  581|      1|                      if (!ui)
  ------------------
  |  Branch (581:27): [True: 0, False: 1]
  ------------------
  582|      0|                        {
  583|      0|                          log_info ("Note: failed to cache a user id: %s\n",
  584|      0|                                    gpg_strerror (gpg_error_from_syserror ()));
  585|      0|                          goto leave;
  586|      0|                        }
  587|      1|                      goto restart;
  588|      1|                    }
  589|      7|                }
  590|      7|            }
  591|      1|          else /* With a UID we use the update cache mode.  */
  592|      1|            {
  593|      1|              if (!key_table_put (k->pkt->pkt.public_key, ui))
  ------------------
  |  Branch (593:19): [True: 0, False: 1]
  ------------------
  594|      0|                {
  595|      0|                  log_info ("Note: failed to cache a key: %s\n",
  596|      0|                            gpg_strerror (gpg_error_from_syserror ()));
  597|      0|                  goto leave;
  598|      0|                }
  599|      1|            }
  600|      8|        }
  601|     36|    }
  602|       |
  603|      4| leave:
  604|      4|  uid_item_unref (ui);
  605|      4|}
cache_get_uid_byfpr:
  653|     15|{
  654|     15|  char *p;
  655|     15|  unsigned int hash;
  656|     15|  u32 keyid[2];
  657|     15|  key_item_t ki;
  658|       |
  659|     15|  if (r_length)
  ------------------
  |  Branch (659:7): [True: 15, False: 0]
  ------------------
  660|     15|    *r_length = 0;
  661|       |
  662|     15|  if (!key_table)
  ------------------
  |  Branch (662:7): [True: 1, False: 14]
  ------------------
  663|      1|    return NULL;
  664|       |
  665|     14|  keyid_from_fingerprint (NULL, fpr, fprlen, keyid);
  666|     14|  hash = key_table_hasher (keyid);
  667|     14|  for (ki = key_table[hash]; ki; ki = ki->next)
  ------------------
  |  Branch (667:30): [True: 8, False: 6]
  ------------------
  668|      8|    if (ki->fprlen == fprlen && !memcmp (ki->fpr, fpr, fprlen))
  ------------------
  |  Branch (668:9): [True: 8, False: 0]
  |  Branch (668:33): [True: 8, False: 0]
  ------------------
  669|      8|      break; /* Found */
  670|       |
  671|     14|  if (!ki)
  ------------------
  |  Branch (671:7): [True: 6, False: 8]
  ------------------
  672|      6|    return NULL; /* Not found.  */
  673|       |
  674|      8|  if (!ki->ui)
  ------------------
  |  Branch (674:7): [True: 0, False: 8]
  ------------------
  675|      0|    p = NULL;  /* No user id known for key.  */
  676|      8|  else
  677|      8|    {
  678|      8|      p = xtrymalloc (ki->ui->namelen + 1);
  ------------------
  |  |   97|      8|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  679|      8|      if (p)
  ------------------
  |  Branch (679:11): [True: 8, False: 0]
  ------------------
  680|      8|        {
  681|      8|          memcpy (p, ki->ui->name, ki->ui->namelen + 1);
  682|      8|          if (r_length)
  ------------------
  |  Branch (682:15): [True: 8, False: 0]
  ------------------
  683|      8|            *r_length = ki->ui->namelen;
  684|      8|          ki->usecount++;
  685|      8|        }
  686|      8|    }
  687|       |
  688|      8|  return p;
  689|     14|}
objcache.c:key_table_get:
  343|      7|{
  344|      7|  unsigned int hash;
  345|      7|  key_item_t ki, ki2;
  346|       |
  347|      7|  if (!key_table)
  ------------------
  |  Branch (347:7): [True: 1, False: 6]
  ------------------
  348|      1|    key_table_init ();
  349|       |
  350|      7|  if (pk)
  ------------------
  |  Branch (350:7): [True: 7, False: 0]
  ------------------
  351|      7|    {
  352|      7|      byte fpr[MAX_FINGERPRINT_LEN];
  353|      7|      size_t fprlen;
  354|      7|      u32 tmpkeyid[2];
  355|       |
  356|      7|      fingerprint_from_pk (pk, fpr, &fprlen);
  357|      7|      keyid_from_pk (pk, tmpkeyid);
  358|      7|      hash = key_table_hasher (tmpkeyid);
  359|      7|      for (ki = key_table[hash]; ki; ki = ki->next)
  ------------------
  |  Branch (359:34): [True: 0, False: 7]
  ------------------
  360|      0|        if (ki->fprlen == fprlen && !memcmp (ki->fpr, fpr, fprlen))
  ------------------
  |  Branch (360:13): [True: 0, False: 0]
  |  Branch (360:37): [True: 0, False: 0]
  ------------------
  361|      0|          return ki; /* Found */
  362|      7|    }
  363|      0|  else if (keyid)
  ------------------
  |  Branch (363:12): [True: 0, False: 0]
  ------------------
  364|      0|    {
  365|      0|      hash = key_table_hasher (keyid);
  366|      0|      for (ki = key_table[hash]; ki; ki = ki->next)
  ------------------
  |  Branch (366:34): [True: 0, False: 0]
  ------------------
  367|      0|        if (ki->keyid[0] == keyid[0] && ki->keyid[1] == keyid[1])
  ------------------
  |  Branch (367:13): [True: 0, False: 0]
  |  Branch (367:41): [True: 0, False: 0]
  ------------------
  368|      0|          {
  369|       |            /* Found.  We need to check for dups.  */
  370|      0|            for (ki2 = ki->next; ki2; ki2 = ki2->next)
  ------------------
  |  Branch (370:34): [True: 0, False: 0]
  ------------------
  371|      0|              if (ki2->keyid[0] == keyid[0] && ki2->keyid[1] == keyid[1])
  ------------------
  |  Branch (371:19): [True: 0, False: 0]
  |  Branch (371:48): [True: 0, False: 0]
  ------------------
  372|      0|                return NULL;  /* Duplicated keyid - return NULL.  */
  373|       |
  374|       |            /* This is the only one - return it.  */
  375|      0|            return ki;
  376|      0|          }
  377|      0|    }
  378|      7|  return NULL;
  379|      7|}
objcache.c:key_table_init:
  317|      1|{
  318|      1|  if (key_table)
  ------------------
  |  Branch (318:7): [True: 0, False: 1]
  ------------------
  319|      0|    return;
  320|      1|  key_table_size = NO_OF_KEY_ITEM_BUCKETS;
  ------------------
  |  |   38|      1|#define NO_OF_KEY_ITEM_BUCKETS    383
  ------------------
  321|      1|  key_table_max  = MAX_KEY_ITEMS_PER_BUCKET;
  ------------------
  |  |   39|      1|#define MAX_KEY_ITEMS_PER_BUCKET  20
  ------------------
  322|      1|  key_table = xcalloc (key_table_size, sizeof *key_table);
  ------------------
  |  |  109|      1|#define xcalloc(a,b)     gcry_xcalloc ((a),(b))
  ------------------
  323|      1|}
objcache.c:primary_uid_from_keyblock:
  536|      7|{
  537|      7|  kbnode_t k;
  538|       |
  539|     72|  for (k = keyblock; k; k = k->next)
  ------------------
  |  Branch (539:22): [True: 66, False: 6]
  ------------------
  540|     66|    {
  541|     66|      if (k->pkt->pkttype == PKT_USER_ID
  ------------------
  |  Branch (541:11): [True: 7, False: 59]
  ------------------
  542|     66|	  && !k->pkt->pkt.user_id->attrib_data
  ------------------
  |  Branch (542:7): [True: 7, False: 0]
  ------------------
  543|     66|	  && k->pkt->pkt.user_id->flags.primary)
  ------------------
  |  Branch (543:7): [True: 1, False: 6]
  ------------------
  544|      1|	{
  545|      1|	  *uidlen = k->pkt->pkt.user_id->len;
  546|      1|	  return k->pkt->pkt.user_id->name;
  547|      1|	}
  548|     66|    }
  549|      6|  return NULL;
  550|      7|}
objcache.c:uid_table_put:
  216|      1|{
  217|      1|  unsigned int hash;
  218|      1|  uid_item_t ui;
  219|      1|  unsigned int count;
  220|       |
  221|      1|  if (!uid_table)
  ------------------
  |  Branch (221:7): [True: 1, False: 0]
  ------------------
  222|      1|    uid_table_init ();
  223|       |
  224|      1|  hash = uid_table_hasher (name, namelen);
  225|      1|  for (ui = uid_table[hash], count = 0; ui; ui = ui->next, count++)
  ------------------
  |  Branch (225:41): [True: 0, False: 1]
  ------------------
  226|      0|    if (ui->namelen == namelen && !memcmp (ui->name, name, namelen))
  ------------------
  |  Branch (226:9): [True: 0, False: 0]
  |  Branch (226:35): [True: 0, False: 0]
  ------------------
  227|      0|      return uid_item_ref (ui);  /* Found.  */
  228|       |
  229|       |  /* If the bucket is full remove all unrefed items.  */
  230|      1|  if (count >= uid_table_max)
  ------------------
  |  Branch (230:7): [True: 0, False: 1]
  ------------------
  231|      0|    {
  232|      0|      uid_item_t ui_next, ui_prev, list_head, drop_head;
  233|       |
  234|       |      /* No syscalls from here .. */
  235|      0|      list_head = uid_table[hash];
  236|      0|      drop_head = NULL;
  237|      0|      while (list_head && !list_head->refcount)
  ------------------
  |  Branch (237:14): [True: 0, False: 0]
  |  Branch (237:27): [True: 0, False: 0]
  ------------------
  238|      0|        {
  239|      0|          ui = list_head;
  240|      0|          list_head = ui->next;
  241|      0|          ui->next = drop_head;
  242|      0|          drop_head = ui;
  243|      0|        }
  244|      0|      if ((ui_prev = list_head))
  ------------------
  |  Branch (244:11): [True: 0, False: 0]
  ------------------
  245|      0|        for (ui = ui_prev->next; ui; ui = ui_next)
  ------------------
  |  Branch (245:34): [True: 0, False: 0]
  ------------------
  246|      0|          {
  247|      0|            ui_next = ui->next;
  248|      0|            if (!ui->refcount)
  ------------------
  |  Branch (248:17): [True: 0, False: 0]
  ------------------
  249|      0|              {
  250|      0|                ui->next = drop_head;
  251|      0|                drop_head = ui;
  252|      0|                ui_prev->next = ui_next;
  253|      0|              }
  254|      0|            else
  255|      0|              ui_prev = ui;
  256|      0|          }
  257|      0|      uid_table[hash] = list_head;
  258|       |      /* ... to here */
  259|       |
  260|      0|      for (ui = drop_head; ui; ui = ui_next)
  ------------------
  |  Branch (260:28): [True: 0, False: 0]
  ------------------
  261|      0|        {
  262|      0|          ui_next = ui->next;
  263|      0|          xfree (ui);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  264|      0|          uid_table_dropped++;
  265|      0|        }
  266|      0|    }
  267|       |
  268|      1|  count = uid_table_added + uid_table_dropped;
  269|      1|  ui = xtrycalloc (1, sizeof *ui + namelen);
  ------------------
  |  |   99|      1|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  270|      1|  if (!ui)
  ------------------
  |  Branch (270:7): [True: 0, False: 1]
  ------------------
  271|      0|    return NULL;  /* Out of core.  */
  272|      1|  if (count != uid_table_added + uid_table_dropped)
  ------------------
  |  Branch (272:7): [True: 0, False: 1]
  ------------------
  273|      0|    {
  274|       |      /* During the malloc another thread added an item.  Thus we need
  275|       |       * to check again.  */
  276|      0|      uid_item_t ui_new = ui;
  277|      0|      for (ui = uid_table[hash]; ui; ui = ui->next)
  ------------------
  |  Branch (277:34): [True: 0, False: 0]
  ------------------
  278|      0|        if (ui->namelen == namelen && !memcmp (ui->name, name, namelen))
  ------------------
  |  Branch (278:13): [True: 0, False: 0]
  |  Branch (278:39): [True: 0, False: 0]
  ------------------
  279|      0|          {
  280|       |            /* Found.  */
  281|      0|            xfree (ui_new);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  282|      0|            return uid_item_ref (ui);
  283|      0|          }
  284|      0|      ui = ui_new;
  285|      0|    }
  286|       |
  287|      1|  memcpy (ui->name, name, namelen);
  288|      1|  ui->name[namelen] = 0; /* Extra Nul so we can use it as a string.  */
  289|      1|  ui->namelen = namelen;
  290|      1|  ui->refcount = 1;
  291|      1|  ui->next = uid_table[hash];
  292|      1|  uid_table[hash] = ui;
  293|      1|  uid_table_added++;
  294|      1|  return ui;
  295|      1|}
objcache.c:uid_table_init:
  177|      1|{
  178|      1|  if (uid_table)
  ------------------
  |  Branch (178:7): [True: 0, False: 1]
  ------------------
  179|      0|    return;
  180|      1|  uid_table_size = NO_OF_UID_ITEM_BUCKETS;
  ------------------
  |  |   35|      1|#define NO_OF_UID_ITEM_BUCKETS    107
  ------------------
  181|      1|  uid_table_max = MAX_UID_ITEMS_PER_BUCKET;
  ------------------
  |  |   36|      1|#define MAX_UID_ITEMS_PER_BUCKET  20
  ------------------
  182|      1|  uid_table = xcalloc (uid_table_size, sizeof *uid_table);
  ------------------
  |  |  109|      1|#define xcalloc(a,b)     gcry_xcalloc ((a),(b))
  ------------------
  183|      1|}
objcache.c:uid_table_hasher:
  154|      1|{
  155|      1|  const unsigned char *s = (const unsigned char*)name;
  156|      1|  unsigned int hashval = 0;
  157|      1|  unsigned int carry;
  158|       |
  159|     23|  for (; namelen; namelen--, s++)
  ------------------
  |  Branch (159:10): [True: 22, False: 1]
  ------------------
  160|     22|    {
  161|     22|      hashval = (hashval << 4) + *s;
  162|     22|      if ((carry = (hashval & 0xf0000000)))
  ------------------
  |  Branch (162:11): [True: 14, False: 8]
  ------------------
  163|     14|        {
  164|     14|          hashval ^= (carry >> 24);
  165|     14|          hashval ^= carry;
  166|     14|        }
  167|     22|    }
  168|       |
  169|      1|  return hashval % uid_table_size;
  170|      1|}
objcache.c:uid_item_ref:
  188|      1|{
  189|      1|  if (ui)
  ------------------
  |  Branch (189:7): [True: 1, False: 0]
  ------------------
  190|      1|    ui->refcount++;
  191|      1|  return ui;
  192|      1|}
objcache.c:key_table_put:
  404|      1|{
  405|      1|  unsigned int hash;
  406|      1|  key_item_t ki;
  407|      1|  u32 keyid[2];
  408|      1|  byte fpr[MAX_FINGERPRINT_LEN];
  409|      1|  size_t fprlen;
  410|      1|  unsigned int count, n;
  411|       |
  412|      1|  if (!key_table)
  ------------------
  |  Branch (412:7): [True: 0, False: 1]
  ------------------
  413|      0|    key_table_init ();
  414|       |
  415|      1|  fingerprint_from_pk (pk, fpr, &fprlen);
  416|      1|  keyid_from_pk (pk, keyid);
  417|      1|  hash = key_table_hasher (keyid);
  418|      1|  for (ki = key_table[hash], count=0; ki; ki = ki->next, count++)
  ------------------
  |  Branch (418:39): [True: 0, False: 1]
  ------------------
  419|      0|    if (ki->fprlen == fprlen && !memcmp (ki->fpr, fpr, fprlen))
  ------------------
  |  Branch (419:9): [True: 0, False: 0]
  |  Branch (419:33): [True: 0, False: 0]
  ------------------
  420|      0|      return ki;  /* Found  */
  421|       |
  422|       |  /* If the bucket is full remove a couple of items. */
  423|      1|  if (count >= key_table_max)
  ------------------
  |  Branch (423:7): [True: 0, False: 1]
  ------------------
  424|      0|    {
  425|      0|      key_item_t list_head, *list_tailp, ki_next;
  426|      0|      key_item_t *array;
  427|      0|      int narray, idx;
  428|       |
  429|       |      /* Unlink from the global list so that other threads don't
  430|       |       * disturb us.  If another thread adds or removes something only
  431|       |       * one will be the winner.  Bad luck for the drooped cache items
  432|       |       * but after all it is just a cache.  */
  433|      0|      list_head = key_table[hash];
  434|      0|      key_table[hash] = NULL;
  435|       |
  436|       |      /* Put all items into an array for sorting.  */
  437|      0|      array = xtrycalloc (count, sizeof *array);
  ------------------
  |  |   99|      0|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  438|      0|      if (!array)
  ------------------
  |  Branch (438:11): [True: 0, False: 0]
  ------------------
  439|      0|        {
  440|       |          /* That's bad; give up all  items of the bucket.  */
  441|      0|          log_info ("Note: malloc failed while purging from the key_tabe: %s\n",
  442|      0|                    gpg_strerror (gpg_error_from_syserror ()));
  443|      0|          goto leave_drop;
  444|      0|        }
  445|      0|      narray = 0;
  446|      0|      for (ki = list_head; ki; ki = ki_next)
  ------------------
  |  Branch (446:28): [True: 0, False: 0]
  ------------------
  447|      0|        {
  448|      0|          ki_next = ki->next;
  449|      0|          array[narray++] = ki;
  450|      0|          ki->next = NULL;
  451|      0|        }
  452|      0|      log_assert (narray == count);
  453|       |
  454|       |      /* Sort the array and put half of it onto a new list.  */
  455|      0|      qsort (array, narray, sizeof *array, compare_key_items);
  456|      0|      list_head = NULL;
  457|      0|      list_tailp = &list_head;
  458|      0|      for (idx=0; idx < narray/2; idx++)
  ------------------
  |  Branch (458:19): [True: 0, False: 0]
  ------------------
  459|      0|        {
  460|      0|          *list_tailp = array[idx];
  461|      0|          list_tailp = &array[idx]->next;
  462|      0|        }
  463|       |
  464|       |      /* Put the new list into the bucket.  */
  465|      0|      ki = key_table[hash];
  466|      0|      key_table[hash] = list_head;
  467|      0|      list_head = ki;
  468|       |
  469|       |      /* Free the remaining items and the array.  */
  470|      0|      for (; idx < narray; idx++)
  ------------------
  |  Branch (470:14): [True: 0, False: 0]
  ------------------
  471|      0|        {
  472|      0|          key_item_free (array[idx]);
  473|      0|          key_table_dropped++;
  474|      0|        }
  475|      0|      xfree (array);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  476|       |
  477|      0|    leave_drop:
  478|       |      /* Free any items added in the meantime by other threads.  This
  479|       |       * is also used in case of a malloc problem (which won't update
  480|       |       * the counters, though). */
  481|      0|      for ( ; list_head; list_head = ki_next)
  ------------------
  |  Branch (481:15): [True: 0, False: 0]
  ------------------
  482|      0|        {
  483|      0|          ki_next = list_head->next;
  484|      0|          key_item_free (list_head);
  485|      0|        }
  486|      0|    }
  487|       |
  488|       |  /* Add an item to the bucket.  We allocate a whole block of items
  489|       |   * for cache performance reasons.  */
  490|      1|  if (!key_item_attic)
  ------------------
  |  Branch (490:7): [True: 1, False: 0]
  ------------------
  491|      1|    {
  492|      1|      key_item_t kiblock;
  493|      1|      int kiblocksize = 256;
  494|       |
  495|      1|      kiblock = xtrymalloc (kiblocksize * sizeof *kiblock);
  ------------------
  |  |   97|      1|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  496|      1|      if (!kiblock)
  ------------------
  |  Branch (496:11): [True: 0, False: 1]
  ------------------
  497|      0|        return NULL;  /* Out of core.  */
  498|    257|      for (n = 0; n < kiblocksize; n++)
  ------------------
  |  Branch (498:19): [True: 256, False: 1]
  ------------------
  499|    256|        {
  500|    256|          ki = kiblock + n;
  501|    256|          ki->next = key_item_attic;
  502|    256|          key_item_attic = ki;
  503|    256|        }
  504|       |
  505|       |      /* During the malloc another thread may have changed the bucket.
  506|       |       * Thus we need to check again.  */
  507|      1|      for (ki = key_table[hash]; ki; ki = ki->next)
  ------------------
  |  Branch (507:34): [True: 0, False: 1]
  ------------------
  508|      0|        if (ki->fprlen == fprlen && !memcmp (ki->fpr, fpr, fprlen))
  ------------------
  |  Branch (508:13): [True: 0, False: 0]
  |  Branch (508:37): [True: 0, False: 0]
  ------------------
  509|      0|          return ki;  /* Found  */
  510|      1|    }
  511|       |
  512|       |  /* We now know that there is an item in the attic.  */
  513|      1|  ki = key_item_attic;
  514|      1|  key_item_attic = ki->next;
  515|      1|  ki->next = NULL;
  516|       |
  517|      1|  memcpy (ki->fpr, fpr, fprlen);
  518|      1|  ki->fprlen = fprlen;
  519|      1|  ki->keyid[0] = keyid[0];
  520|      1|  ki->keyid[1] = keyid[1];
  521|      1|  ki->ui = uid_item_ref (ui);
  522|      1|  ki->usecount = 0;
  523|      1|  ki->next = key_table[hash];
  524|      1|  key_table[hash] = ki;
  525|      1|  key_table_added++;
  526|      1|  return ki;
  527|      1|}
objcache.c:uid_item_unref:
  196|      4|{
  197|      4|  if (!uid)
  ------------------
  |  Branch (197:7): [True: 3, False: 1]
  ------------------
  198|      3|    return;
  199|      1|  if (!uid->refcount)
  ------------------
  |  Branch (199:7): [True: 0, False: 1]
  ------------------
  200|      0|    log_fatal ("too many unrefs for uid_item\n");
  201|       |
  202|      1|  uid->refcount--;
  203|       |  /* We do not release the item here because that would require that
  204|       |   * we locate the head of the list which has this item.  This will
  205|       |   * take too long and thus the item is removed when we need to purge
  206|       |   * some items for the list during uid_item_put.  */
  207|      1|}
objcache.c:key_table_hasher:
  303|     22|{
  304|       |  /* A fingerprint could be used directly as a hash value.  However,
  305|       |   * we use the keyid here because it is used in encrypted packets and
  306|       |   * older signatures to identify a key.  Since v4 keys the keyid is
  307|       |   * anyway a part of the fingerprint so it quickly extracted from a
  308|       |   * fingerprint.  Note that v3 keys are not supported by gpg.  */
  309|     22|  return keyid[0] % key_table_size;
  310|     22|}

set_packet_list_mode:
  291|     48|{
  292|     48|  int old = list_mode;
  293|     48|  list_mode = mode;
  294|       |
  295|       |  /* We use stdout only if invoked by the --list-packets command
  296|       |     but switch to stderr in all other cases.  This breaks the
  297|       |     previous behaviour but that seems to be more of a bug than
  298|       |     intentional.  I don't believe that any application makes use of
  299|       |     this long standing annoying way of printing to stdout except when
  300|       |     doing a --list-packets. If this assumption fails, it will be easy
  301|       |     to add an option for the listing stream.  Note that we initialize
  302|       |     it only once; mainly because there is code which switches
  303|       |     opt.list_mode back to 1 and we want to have all output to the
  304|       |     same stream.  The MPI_PRINT_MODE will be enabled if the
  305|       |     corresponding debug flag is set or if we are in --list-packets
  306|       |     and --verbose is given.
  307|       |
  308|       |     Using stderr is not actually very clean because it bypasses the
  309|       |     logging code but it is a special thing anyway.  I am not sure
  310|       |     whether using log_stream() would be better.  Perhaps we should
  311|       |     enable the list mode only with a special option. */
  312|     48|  if (!listfp)
  ------------------
  |  Branch (312:7): [True: 1, False: 47]
  ------------------
  313|      1|    {
  314|      1|      if (opt.list_packets)
  ------------------
  |  Branch (314:11): [True: 0, False: 1]
  ------------------
  315|      0|        {
  316|      0|          listfp = es_stdout;
  317|      0|          if (opt.verbose)
  ------------------
  |  Branch (317:15): [True: 0, False: 0]
  ------------------
  318|      0|            mpi_print_mode = 1;
  319|      0|        }
  320|      1|      else
  321|      1|        listfp = es_stderr;
  322|       |
  323|      1|      if (DBG_MPI)
  ------------------
  |  |  349|      1|#define DBG_MPI    (opt.debug & DBG_MPI_VALUE)
  |  |  ------------------
  |  |  |  |  332|      1|#define DBG_MPI_VALUE	  2	/* debug mpi details */
  |  |  ------------------
  |  |  |  Branch (349:20): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  324|      0|        mpi_print_mode = 1;
  325|      1|    }
  326|     48|  return old;
  327|     48|}
dbg_parse_packet:
  368|  7.19k|{
  369|  7.19k|  int skip, rc;
  370|       |
  371|  7.19k|  do
  372|  7.47k|    {
  373|  7.47k|      rc = parse (ctx, pkt, 0, NULL, &skip, NULL, 0, "parse", dbg_f, dbg_l);
  374|  7.47k|    }
  375|  7.47k|  while (skip && ! rc);
  ------------------
  |  Branch (375:10): [True: 281, False: 7.19k]
  |  Branch (375:18): [True: 281, False: 0]
  ------------------
  376|  7.19k|  return rc;
  377|  7.19k|}
parse_one_sig_subpkt:
 1739|    668|{
 1740|    668|  switch (type)
 1741|    668|    {
 1742|    157|    case SIGSUBPKT_REV_KEY:
  ------------------
  |  Branch (1742:5): [True: 157, False: 511]
  ------------------
 1743|    157|      if (n < 22)
  ------------------
  |  Branch (1743:11): [True: 0, False: 157]
  ------------------
 1744|      0|	break;
 1745|    157|      return 0;
 1746|     76|    case SIGSUBPKT_SIG_CREATED:
  ------------------
  |  Branch (1746:5): [True: 76, False: 592]
  ------------------
 1747|     77|    case SIGSUBPKT_SIG_EXPIRE:
  ------------------
  |  Branch (1747:5): [True: 1, False: 667]
  ------------------
 1748|     77|    case SIGSUBPKT_KEY_EXPIRE:
  ------------------
  |  Branch (1748:5): [True: 0, False: 668]
  ------------------
 1749|     77|      if (n < 4)
  ------------------
  |  Branch (1749:11): [True: 1, False: 76]
  ------------------
 1750|      1|	break;
 1751|     76|      return 0;
 1752|      6|    case SIGSUBPKT_KEY_FLAGS:
  ------------------
  |  Branch (1752:5): [True: 6, False: 662]
  ------------------
 1753|      6|    case SIGSUBPKT_KS_FLAGS:
  ------------------
  |  Branch (1753:5): [True: 0, False: 668]
  ------------------
 1754|      6|    case SIGSUBPKT_PREF_SYM:
  ------------------
  |  Branch (1754:5): [True: 0, False: 668]
  ------------------
 1755|      6|    case SIGSUBPKT_PREF_AEAD:
  ------------------
  |  Branch (1755:5): [True: 0, False: 668]
  ------------------
 1756|      6|    case SIGSUBPKT_PREF_HASH:
  ------------------
  |  Branch (1756:5): [True: 0, False: 668]
  ------------------
 1757|      6|    case SIGSUBPKT_PREF_COMPR:
  ------------------
  |  Branch (1757:5): [True: 0, False: 668]
  ------------------
 1758|      6|    case SIGSUBPKT_POLICY:
  ------------------
  |  Branch (1758:5): [True: 0, False: 668]
  ------------------
 1759|      6|    case SIGSUBPKT_PREF_KS:
  ------------------
  |  Branch (1759:5): [True: 0, False: 668]
  ------------------
 1760|      6|    case SIGSUBPKT_FEATURES:
  ------------------
  |  Branch (1760:5): [True: 0, False: 668]
  ------------------
 1761|      6|    case SIGSUBPKT_REGEXP:
  ------------------
  |  Branch (1761:5): [True: 0, False: 668]
  ------------------
 1762|      6|    case SIGSUBPKT_ATTST_SIGS:
  ------------------
  |  Branch (1762:5): [True: 0, False: 668]
  ------------------
 1763|      6|      return 0;
 1764|      0|    case SIGSUBPKT_SIGNATURE:
  ------------------
  |  Branch (1764:5): [True: 0, False: 668]
  ------------------
 1765|    131|    case SIGSUBPKT_EXPORTABLE:
  ------------------
  |  Branch (1765:5): [True: 131, False: 537]
  ------------------
 1766|    131|    case SIGSUBPKT_REVOCABLE:
  ------------------
  |  Branch (1766:5): [True: 0, False: 668]
  ------------------
 1767|    131|    case SIGSUBPKT_REVOC_REASON:
  ------------------
  |  Branch (1767:5): [True: 0, False: 668]
  ------------------
 1768|    131|      if (!n)
  ------------------
  |  Branch (1768:11): [True: 0, False: 131]
  ------------------
 1769|      0|	break;
 1770|    131|      return 0;
 1771|     34|    case SIGSUBPKT_ISSUER:	/* issuer key ID */
  ------------------
  |  Branch (1771:5): [True: 34, False: 634]
  ------------------
 1772|     34|      if (n < 8)
  ------------------
  |  Branch (1772:11): [True: 0, False: 34]
  ------------------
 1773|      0|	break;
 1774|     34|      return 0;
 1775|    170|    case SIGSUBPKT_ISSUER_FPR:	/* issuer key fingerprint */
  ------------------
  |  Branch (1775:5): [True: 170, False: 498]
  ------------------
 1776|    170|      if (n < 21)
  ------------------
  |  Branch (1776:11): [True: 0, False: 170]
  ------------------
 1777|      0|	break;
 1778|    170|      return 0;
 1779|      0|    case SIGSUBPKT_NOTATION:
  ------------------
  |  Branch (1779:5): [True: 0, False: 668]
  ------------------
 1780|       |      /* minimum length needed, and the subpacket must be well-formed
 1781|       |         where the name length and value length all fit inside the
 1782|       |         packet. */
 1783|      0|      if (n < 8
  ------------------
  |  Branch (1783:11): [True: 0, False: 0]
  ------------------
 1784|      0|	  || 8 + ((buffer[4] << 8) | buffer[5]) +
  ------------------
  |  Branch (1784:7): [True: 0, False: 0]
  ------------------
 1785|      0|	  ((buffer[6] << 8) | buffer[7]) != n)
 1786|      0|	break;
 1787|      0|      return 0;
 1788|      0|    case SIGSUBPKT_PRIMARY_UID:
  ------------------
  |  Branch (1788:5): [True: 0, False: 668]
  ------------------
 1789|      0|      if (n != 1)
  ------------------
  |  Branch (1789:11): [True: 0, False: 0]
  ------------------
 1790|      0|	break;
 1791|      0|      return 0;
 1792|      0|    case SIGSUBPKT_TRUST:
  ------------------
  |  Branch (1792:5): [True: 0, False: 668]
  ------------------
 1793|      0|      if (n != 2)
  ------------------
  |  Branch (1793:11): [True: 0, False: 0]
  ------------------
 1794|      0|	break;
 1795|      0|      return 0;
 1796|     93|    case SIGSUBPKT_KEY_BLOCK:
  ------------------
  |  Branch (1796:5): [True: 93, False: 575]
  ------------------
 1797|     93|      if (n && buffer[0])
  ------------------
  |  Branch (1797:11): [True: 0, False: 93]
  |  Branch (1797:16): [True: 0, False: 0]
  ------------------
 1798|      0|        return -1; /* Unknown version - ignore.  */
 1799|     93|      if (n < 50)
  ------------------
  |  Branch (1799:11): [True: 93, False: 0]
  ------------------
 1800|     93|	break;  /* Definitely too short to carry a key block.  */
 1801|      0|      return 0;
 1802|      0|    default:
  ------------------
  |  Branch (1802:5): [True: 0, False: 668]
  ------------------
 1803|      0|      return 0;
 1804|    668|    }
 1805|     94|  return -2;
 1806|    668|}
enum_sig_subpkt:
 1885|  7.55k|{
 1886|  7.55k|  const byte *buffer;
 1887|  7.55k|  int buflen;
 1888|  7.55k|  int type;
 1889|  7.55k|  int critical_dummy;
 1890|  7.55k|  int offset;
 1891|  7.55k|  size_t n;
 1892|  7.55k|  const subpktarea_t *pktbuf = want_hashed? sig->hashed : sig->unhashed;
  ------------------
  |  Branch (1892:32): [True: 6.43k, False: 1.12k]
  ------------------
 1893|  7.55k|  int seq = 0;
 1894|  7.55k|  int reqseq = start ? *start : 0;
  ------------------
  |  Branch (1894:16): [True: 228, False: 7.32k]
  ------------------
 1895|       |
 1896|  7.55k|  if (!critical)
  ------------------
  |  Branch (1896:7): [True: 7.55k, False: 0]
  ------------------
 1897|  7.55k|    critical = &critical_dummy;
 1898|       |
 1899|  7.55k|  if (!pktbuf || reqseq == -1)
  ------------------
  |  Branch (1899:7): [True: 2.23k, False: 5.31k]
  |  Branch (1899:18): [True: 0, False: 5.31k]
  ------------------
 1900|  2.23k|    {
 1901|  2.23k|      static char dummy[] = "x";
 1902|       |      /* Return a value different from NULL to indicate that
 1903|       |       * there is no critical bit we do not understand.  */
 1904|  2.23k|      return reqtype ==	SIGSUBPKT_TEST_CRITICAL ? dummy : NULL;
  ------------------
  |  Branch (1904:14): [True: 140, False: 2.09k]
  ------------------
 1905|  2.23k|    }
 1906|  5.31k|  buffer = pktbuf->data;
 1907|  5.31k|  buflen = pktbuf->len;
 1908|  19.4k|  while (buflen)
  ------------------
  |  Branch (1908:10): [True: 18.4k, False: 971]
  ------------------
 1909|  18.4k|    {
 1910|  18.4k|      n = *buffer++;
 1911|  18.4k|      buflen--;
 1912|  18.4k|      if (n == 255) /* 4 byte length header.  */
  ------------------
  |  Branch (1912:11): [True: 1.74k, False: 16.7k]
  ------------------
 1913|  1.74k|	{
 1914|  1.74k|	  if (buflen < 4)
  ------------------
  |  Branch (1914:8): [True: 84, False: 1.65k]
  ------------------
 1915|     84|	    goto too_short;
 1916|  1.65k|	  n = buf32_to_size_t (buffer);
 1917|  1.65k|	  buffer += 4;
 1918|  1.65k|	  buflen -= 4;
 1919|  1.65k|	}
 1920|  16.7k|      else if (n >= 192) /* 4 byte special encoded length header.  */
  ------------------
  |  Branch (1920:16): [True: 1.13k, False: 15.6k]
  ------------------
 1921|  1.13k|	{
 1922|  1.13k|	  if (buflen < 2)
  ------------------
  |  Branch (1922:8): [True: 0, False: 1.13k]
  ------------------
 1923|      0|	    goto too_short;
 1924|  1.13k|	  n = ((n - 192) << 8) + *buffer + 192;
 1925|  1.13k|	  buffer++;
 1926|  1.13k|	  buflen--;
 1927|  1.13k|	}
 1928|  18.3k|      if (buflen < n)
  ------------------
  |  Branch (1928:11): [True: 3.30k, False: 15.0k]
  ------------------
 1929|  3.30k|	goto too_short;
 1930|  15.0k|      if (!buflen)
  ------------------
  |  Branch (1930:11): [True: 130, False: 14.9k]
  ------------------
 1931|    130|        goto no_type_byte;
 1932|  14.9k|      type = *buffer;
 1933|  14.9k|      if (type & 0x80)
  ------------------
  |  Branch (1933:11): [True: 4.44k, False: 10.5k]
  ------------------
 1934|  4.44k|	{
 1935|  4.44k|	  type &= 0x7f;
 1936|  4.44k|	  *critical = 1;
 1937|  4.44k|	}
 1938|  10.5k|      else
 1939|  10.5k|	*critical = 0;
 1940|  14.9k|      if (!(++seq > reqseq))
  ------------------
  |  Branch (1940:11): [True: 720, False: 14.2k]
  ------------------
 1941|    720|	;
 1942|  14.2k|      else if (reqtype == SIGSUBPKT_TEST_CRITICAL)
  ------------------
  |  Branch (1942:16): [True: 1.28k, False: 12.9k]
  ------------------
 1943|  1.28k|	{
 1944|  1.28k|	  if (*critical)
  ------------------
  |  Branch (1944:8): [True: 328, False: 958]
  ------------------
 1945|    328|	    {
 1946|    328|	      if (n - 1 > buflen + 1)
  ------------------
  |  Branch (1946:12): [True: 12, False: 316]
  ------------------
 1947|     12|		goto too_short;
 1948|    316|	      if (!can_handle_critical (buffer + 1, n - 1, type))
  ------------------
  |  Branch (1948:12): [True: 93, False: 223]
  ------------------
 1949|     93|		{
 1950|     93|		  if (opt.verbose && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (1950:9): [True: 0, False: 93]
  |  Branch (1950:24): [True: 0, False: 0]
  ------------------
 1951|      0|		    log_info (_("subpacket of type %d has "
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1952|      0|				"critical bit set\n"), type);
 1953|     93|		  if (start)
  ------------------
  |  Branch (1953:9): [True: 0, False: 93]
  ------------------
 1954|      0|		    *start = seq;
 1955|     93|		  return NULL;	/* This is an error.  */
 1956|     93|		}
 1957|    316|	    }
 1958|  1.28k|	}
 1959|  12.9k|      else if (reqtype < 0) /* List packets.  */
  ------------------
  |  Branch (1959:16): [True: 0, False: 12.9k]
  ------------------
 1960|      0|	dump_sig_subpkt (reqtype == SIGSUBPKT_LIST_HASHED,
 1961|      0|			 type, *critical, buffer, buflen, n, sig->digest_algo);
 1962|  12.9k|      else if (type == reqtype) /* Found.  */
  ------------------
  |  Branch (1962:16): [True: 725, False: 12.2k]
  ------------------
 1963|    725|	{
 1964|    725|	  buffer++;
 1965|    725|	  n--;
 1966|    725|	  if (n > buflen)
  ------------------
  |  Branch (1966:8): [True: 57, False: 668]
  ------------------
 1967|     57|	    goto too_short;
 1968|    668|	  if (ret_n)
  ------------------
  |  Branch (1968:8): [True: 333, False: 335]
  ------------------
 1969|    333|	    *ret_n = n;
 1970|    668|	  offset = parse_one_sig_subpkt (buffer, n, type);
 1971|    668|	  switch (offset)
 1972|    668|	    {
 1973|     94|	    case -2:
  ------------------
  |  Branch (1973:6): [True: 94, False: 574]
  ------------------
 1974|     94|	      log_error ("subpacket of type %d too short\n", type);
 1975|     94|	      return NULL;
 1976|      0|	    case -1:
  ------------------
  |  Branch (1976:6): [True: 0, False: 668]
  ------------------
 1977|      0|	      return NULL;
 1978|    574|	    default:
  ------------------
  |  Branch (1978:6): [True: 574, False: 94]
  ------------------
 1979|    574|	      break;
 1980|    668|	    }
 1981|    574|	  if (start)
  ------------------
  |  Branch (1981:8): [True: 157, False: 417]
  ------------------
 1982|    157|	    *start = seq;
 1983|    574|	  return buffer + offset;
 1984|    668|	}
 1985|  14.1k|      buffer += n;
 1986|  14.1k|      buflen -= n;
 1987|  14.1k|    }
 1988|    971|  if (reqtype == SIGSUBPKT_TEST_CRITICAL)
  ------------------
  |  Branch (1988:7): [True: 143, False: 828]
  ------------------
 1989|       |    /* Returning NULL means we found a subpacket with the critical bit
 1990|       |       set that we don't grok.  We've iterated over all the subpackets
 1991|       |       and haven't found such a packet so we need to return a non-NULL
 1992|       |       value.  */
 1993|    143|    return buffer;
 1994|       |
 1995|       |  /* Critical bit we don't understand. */
 1996|    828|  if (start)
  ------------------
  |  Branch (1996:7): [True: 12, False: 816]
  ------------------
 1997|     12|    *start = -1;
 1998|    828|  return NULL;	/* End of packets; not found.  */
 1999|       |
 2000|  3.45k| too_short:
 2001|  3.45k|  if (opt.debug && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (2001:7): [True: 0, False: 3.45k]
  |  Branch (2001:20): [True: 0, False: 0]
  ------------------
 2002|      0|    {
 2003|      0|      es_fflush (es_stdout);
 2004|      0|      log_printhex (pktbuf->data, pktbuf->len > 16? 16 : pktbuf->len,
  ------------------
  |  Branch (2004:35): [True: 0, False: 0]
  ------------------
 2005|      0|                    "buffer shorter than subpacket (%zu/%d/%zu); dump:",
 2006|      0|                    pktbuf->len, buflen, n);
 2007|      0|    }
 2008|       |
 2009|  3.45k|  if (start)
  ------------------
  |  Branch (2009:7): [True: 49, False: 3.40k]
  ------------------
 2010|     49|    *start = -1;
 2011|  3.45k|  return NULL;
 2012|       |
 2013|    130| no_type_byte:
 2014|    130|  if (opt.verbose && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (2014:7): [True: 0, False: 130]
  |  Branch (2014:22): [True: 0, False: 0]
  ------------------
 2015|      0|    log_info ("type octet missing in subpacket\n");
 2016|    130|  if (start)
  ------------------
  |  Branch (2016:7): [True: 10, False: 120]
  ------------------
 2017|     10|    *start = -1;
 2018|    130|  return NULL;
 2019|    971|}
parse_sig_subpkt:
 2025|  7.32k|{
 2026|  7.32k|  return enum_sig_subpkt (sig, want_hashed, reqtype, ret_n, NULL, NULL);
 2027|  7.32k|}
parse_sig_subpkt2:
 2032|    918|{
 2033|    918|  const byte *p;
 2034|       |
 2035|    918|  p = parse_sig_subpkt (sig, 1, reqtype, NULL);
 2036|    918|  if (!p)
  ------------------
  |  Branch (2036:7): [True: 909, False: 9]
  ------------------
 2037|    909|    p = parse_sig_subpkt (sig, 0, reqtype, NULL);
 2038|    918|  return p;
 2039|    918|}
parse_revkeys:
 2045|     59|{
 2046|     59|  const byte *revkey;
 2047|     59|  int seq = 0;
 2048|     59|  size_t len;
 2049|       |
 2050|     59|  if (sig->sig_class != 0x1F)
  ------------------
  |  Branch (2050:7): [True: 0, False: 59]
  ------------------
 2051|      0|    return;
 2052|       |
 2053|    216|  while ((revkey = enum_sig_subpkt (sig, 1, SIGSUBPKT_REV_KEY,
  ------------------
  |  Branch (2053:10): [True: 157, False: 59]
  ------------------
 2054|    216|                                    &len, &seq, NULL)))
 2055|    157|    {
 2056|       |      /* Consider only valid packets.  They must have a length of
 2057|       |       * either 2+20 or 2+32 octets and bit 7 of the class octet must
 2058|       |       * be set.  */
 2059|    157|      if ((len == 22 || len == 34)
  ------------------
  |  Branch (2059:12): [True: 101, False: 56]
  |  Branch (2059:25): [True: 55, False: 1]
  ------------------
 2060|    157|          && (revkey[0] & 0x80))
  ------------------
  |  Branch (2060:14): [True: 0, False: 156]
  ------------------
 2061|      0|	{
 2062|      0|	  sig->revkey = xrealloc (sig->revkey,
  ------------------
  |  |  111|      0|#define xrealloc(a,b)    gcry_xrealloc ((a),(b))
  ------------------
 2063|      0|				  sizeof (struct revocation_key) *
 2064|      0|				  (sig->numrevkeys + 1));
 2065|       |
 2066|      0|	  sig->revkey[sig->numrevkeys].class = revkey[0];
 2067|      0|	  sig->revkey[sig->numrevkeys].algid = revkey[1];
 2068|      0|          len -= 2;
 2069|      0|	  sig->revkey[sig->numrevkeys].fprlen = len;
 2070|      0|	  memcpy (sig->revkey[sig->numrevkeys].fpr, revkey+2, len);
 2071|      0|	  memset (sig->revkey[sig->numrevkeys].fpr+len, 0,
 2072|      0|                  sizeof (sig->revkey[sig->numrevkeys].fpr) - len);
 2073|      0|	  sig->numrevkeys++;
 2074|      0|	}
 2075|    157|    }
 2076|     59|}
parse_signature:
 2082|  1.92k|{
 2083|  1.92k|  int md5_len = 0;
 2084|  1.92k|  unsigned n;
 2085|  1.92k|  int is_v4or5 = 0;
 2086|  1.92k|  int rc = 0;
 2087|  1.92k|  int i, ndata;
 2088|       |
 2089|  1.92k|  if (pktlen < 16)
  ------------------
  |  Branch (2089:7): [True: 35, False: 1.89k]
  ------------------
 2090|     35|    {
 2091|     35|      log_error ("packet(%d) too short\n", pkttype);
 2092|     35|      if (list_mode)
  ------------------
  |  Branch (2092:11): [True: 0, False: 35]
  ------------------
 2093|      0|        es_fputs (":signature packet: [too short]\n", listfp);
 2094|     35|      goto leave;
 2095|     35|    }
 2096|  1.89k|  sig->version = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  1.89k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  1.89k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 1.89k]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 1.89k]
  |  |  |  |  ------------------
  |  |  |  |  501|  1.89k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2097|  1.89k|  pktlen--;
 2098|  1.89k|  if (sig->version == 4 || sig->version == 5)
  ------------------
  |  Branch (2098:7): [True: 221, False: 1.67k]
  |  Branch (2098:28): [True: 291, False: 1.38k]
  ------------------
 2099|    512|    is_v4or5 = 1;
 2100|  1.38k|  else if (sig->version != 2 && sig->version != 3)
  ------------------
  |  Branch (2100:12): [True: 1.01k, False: 368]
  |  Branch (2100:33): [True: 0, False: 1.01k]
  ------------------
 2101|      0|    {
 2102|      0|      log_error ("packet(%d) with unknown version %d\n",
 2103|      0|		 pkttype, sig->version);
 2104|      0|      if (list_mode)
  ------------------
  |  Branch (2104:11): [True: 0, False: 0]
  ------------------
 2105|      0|        es_fputs (":signature packet: [unknown version]\n", listfp);
 2106|      0|      rc = gpg_error (GPG_ERR_INV_PACKET);
 2107|      0|      goto leave;
 2108|      0|    }
 2109|       |
 2110|  1.89k|  if (!is_v4or5)
  ------------------
  |  Branch (2110:7): [True: 1.38k, False: 512]
  ------------------
 2111|  1.38k|    {
 2112|  1.38k|      if (pktlen == 0)
  ------------------
  |  Branch (2112:11): [True: 0, False: 1.38k]
  ------------------
 2113|      0|	goto underflow;
 2114|  1.38k|      md5_len = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  1.38k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  1.38k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 1.38k]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 1.38k]
  |  |  |  |  ------------------
  |  |  |  |  501|  1.38k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2115|  1.38k|      pktlen--;
 2116|  1.38k|    }
 2117|  1.89k|  if (pktlen == 0)
  ------------------
  |  Branch (2117:7): [True: 0, False: 1.89k]
  ------------------
 2118|      0|    goto underflow;
 2119|  1.89k|  sig->sig_class = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  1.89k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  1.89k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 1.89k]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 1.89k]
  |  |  |  |  ------------------
  |  |  |  |  501|  1.89k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2120|  1.89k|  pktlen--;
 2121|  1.89k|  if (!is_v4or5)
  ------------------
  |  Branch (2121:7): [True: 1.38k, False: 512]
  ------------------
 2122|  1.38k|    {
 2123|  1.38k|      if (pktlen < 12)
  ------------------
  |  Branch (2123:11): [True: 0, False: 1.38k]
  ------------------
 2124|      0|	goto underflow;
 2125|  1.38k|      sig->timestamp = read_32 (inp);
 2126|  1.38k|      pktlen -= 4;
 2127|  1.38k|      sig->keyid[0] = read_32 (inp);
 2128|  1.38k|      pktlen -= 4;
 2129|  1.38k|      sig->keyid[1] = read_32 (inp);
 2130|  1.38k|      pktlen -= 4;
 2131|  1.38k|    }
 2132|  1.89k|  if (pktlen < 2)
  ------------------
  |  Branch (2132:7): [True: 0, False: 1.89k]
  ------------------
 2133|      0|    goto underflow;
 2134|  1.89k|  sig->pubkey_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  1.89k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  1.89k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 1.89k]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 1.89k]
  |  |  |  |  ------------------
  |  |  |  |  501|  1.89k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2135|  1.89k|  pktlen--;
 2136|  1.89k|  sig->digest_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  1.89k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  1.89k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 1.89k]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 1.89k]
  |  |  |  |  ------------------
  |  |  |  |  501|  1.89k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2137|  1.89k|  pktlen--;
 2138|  1.89k|  sig->flags.exportable = 1;
 2139|  1.89k|  sig->flags.revocable = 1;
 2140|  1.89k|  if (is_v4or5) /* Read subpackets.  */
  ------------------
  |  Branch (2140:7): [True: 512, False: 1.38k]
  ------------------
 2141|    512|    {
 2142|    512|      if (pktlen < 2)
  ------------------
  |  Branch (2142:11): [True: 0, False: 512]
  ------------------
 2143|      0|	goto underflow;
 2144|    512|      n = read_16 (inp);
 2145|    512|      pktlen -= 2;  /* Length of hashed data. */
 2146|    512|      if (pktlen < n)
  ------------------
  |  Branch (2146:11): [True: 0, False: 512]
  ------------------
 2147|      0|	goto underflow;
 2148|    512|      if (n > 10000)
  ------------------
  |  Branch (2148:11): [True: 0, False: 512]
  ------------------
 2149|      0|	{
 2150|      0|	  log_error ("signature packet: hashed data too long\n");
 2151|      0|          if (list_mode)
  ------------------
  |  Branch (2151:15): [True: 0, False: 0]
  ------------------
 2152|      0|            es_fputs (":signature packet: [hashed data too long]\n", listfp);
 2153|      0|	  rc = GPG_ERR_INV_PACKET;
 2154|      0|	  goto leave;
 2155|      0|	}
 2156|    512|      if (n)
  ------------------
  |  Branch (2156:11): [True: 381, False: 131]
  ------------------
 2157|    381|	{
 2158|    381|	  sig->hashed = xmalloc (sizeof (*sig->hashed) + n - 1);
  ------------------
  |  |  107|    381|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 2159|    381|	  sig->hashed->size = n;
 2160|    381|	  sig->hashed->len = n;
 2161|    381|	  if (iobuf_read (inp, sig->hashed->data, n) != n)
  ------------------
  |  Branch (2161:8): [True: 16, False: 365]
  ------------------
 2162|     16|	    {
 2163|     16|	      log_error ("premature eof while reading "
 2164|     16|			 "hashed signature data\n");
 2165|     16|              if (list_mode)
  ------------------
  |  Branch (2165:19): [True: 0, False: 16]
  ------------------
 2166|      0|                es_fputs (":signature packet: [premature eof]\n", listfp);
 2167|     16|	      rc = -1;
 2168|     16|	      goto leave;
 2169|     16|	    }
 2170|    365|	  pktlen -= n;
 2171|    365|	}
 2172|    496|      if (pktlen < 2)
  ------------------
  |  Branch (2172:11): [True: 0, False: 496]
  ------------------
 2173|      0|	goto underflow;
 2174|    496|      n = read_16 (inp);
 2175|    496|      pktlen -= 2;  /* Length of unhashed data.  */
 2176|    496|      if (pktlen < n)
  ------------------
  |  Branch (2176:11): [True: 0, False: 496]
  ------------------
 2177|      0|	goto underflow;
 2178|    496|      if (n > 10000)
  ------------------
  |  Branch (2178:11): [True: 0, False: 496]
  ------------------
 2179|      0|	{
 2180|      0|	  log_error ("signature packet: unhashed data too long\n");
 2181|      0|          if (list_mode)
  ------------------
  |  Branch (2181:15): [True: 0, False: 0]
  ------------------
 2182|      0|            es_fputs (":signature packet: [unhashed data too long]\n", listfp);
 2183|      0|	  rc = GPG_ERR_INV_PACKET;
 2184|      0|	  goto leave;
 2185|      0|	}
 2186|    496|      if (n)
  ------------------
  |  Branch (2186:11): [True: 228, False: 268]
  ------------------
 2187|    228|	{
 2188|    228|	  sig->unhashed = xmalloc (sizeof (*sig->unhashed) + n - 1);
  ------------------
  |  |  107|    228|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 2189|    228|	  sig->unhashed->size = n;
 2190|    228|	  sig->unhashed->len = n;
 2191|    228|	  if (iobuf_read (inp, sig->unhashed->data, n) != n)
  ------------------
  |  Branch (2191:8): [True: 16, False: 212]
  ------------------
 2192|     16|	    {
 2193|     16|	      log_error ("premature eof while reading "
 2194|     16|			 "unhashed signature data\n");
 2195|     16|              if (list_mode)
  ------------------
  |  Branch (2195:19): [True: 0, False: 16]
  ------------------
 2196|      0|                es_fputs (":signature packet: [premature eof]\n", listfp);
 2197|     16|	      rc = -1;
 2198|     16|	      goto leave;
 2199|     16|	    }
 2200|    212|	  pktlen -= n;
 2201|    212|	}
 2202|    496|    }
 2203|       |
 2204|  1.86k|  if (pktlen < 2)
  ------------------
  |  Branch (2204:7): [True: 0, False: 1.86k]
  ------------------
 2205|      0|    goto underflow;
 2206|  1.86k|  sig->digest_start[0] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  1.86k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  1.86k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 1.86k]
  |  |  |  |  |  Branch (500:24): [True: 35, False: 1.82k]
  |  |  |  |  ------------------
  |  |  |  |  501|  1.86k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2207|  1.86k|  pktlen--;
 2208|  1.86k|  sig->digest_start[1] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  1.86k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  1.86k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 1.86k]
  |  |  |  |  |  Branch (500:24): [True: 4, False: 1.85k]
  |  |  |  |  ------------------
  |  |  |  |  501|  1.86k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2209|  1.86k|  pktlen--;
 2210|       |
 2211|  1.86k|  if (is_v4or5 && sig->pubkey_algo)  /* Extract required information.  */
  ------------------
  |  Branch (2211:7): [True: 480, False: 1.38k]
  |  Branch (2211:19): [True: 480, False: 0]
  ------------------
 2212|    480|    {
 2213|    480|      const byte *p;
 2214|    480|      size_t len;
 2215|       |
 2216|       |      /* Set sig->flags.unknown_critical if there is a critical bit
 2217|       |       * set for packets which we do not understand.  */
 2218|    480|      if (!parse_sig_subpkt (sig, 1, SIGSUBPKT_TEST_CRITICAL, NULL)
  ------------------
  |  Branch (2218:11): [True: 273, False: 207]
  ------------------
 2219|    480|	  || !parse_sig_subpkt (sig, 0, SIGSUBPKT_TEST_CRITICAL, NULL))
  ------------------
  |  Branch (2219:7): [True: 131, False: 76]
  ------------------
 2220|    404|	sig->flags.unknown_critical = 1;
 2221|       |
 2222|    480|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_SIG_CREATED, NULL);
 2223|    480|      if (p)
  ------------------
  |  Branch (2223:11): [True: 76, False: 404]
  ------------------
 2224|     76|	sig->timestamp = buf32_to_u32 (p);
 2225|    404|      else if (!(sig->pubkey_algo >= 100 && sig->pubkey_algo <= 110)
  ------------------
  |  Branch (2225:18): [True: 55, False: 349]
  |  Branch (2225:45): [True: 0, False: 55]
  ------------------
 2226|    404|	       && opt.verbose > 1 && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (2226:12): [True: 0, False: 404]
  |  Branch (2226:31): [True: 0, False: 0]
  ------------------
 2227|      0|        log_info ("signature packet without timestamp\n");
 2228|       |
 2229|       |      /* Set the key id.  We first try the issuer fingerprint and if
 2230|       |       * it is a v4 signature the fallback to the issuer.  Note that
 2231|       |       * only the issuer packet is also searched in the unhashed area.  */
 2232|    480|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_ISSUER_FPR, &len);
 2233|    480|      if (p && len == 21 && p[0] == 4)
  ------------------
  |  Branch (2233:11): [True: 170, False: 310]
  |  Branch (2233:16): [True: 42, False: 128]
  |  Branch (2233:29): [True: 42, False: 0]
  ------------------
 2234|     42|        {
 2235|     42|          sig->keyid[0] = buf32_to_u32 (p + 1 + 12);
 2236|     42|	  sig->keyid[1] = buf32_to_u32 (p + 1 + 16);
 2237|     42|	}
 2238|    438|      else if (p && len == 33 && p[0] == 5)
  ------------------
  |  Branch (2238:16): [True: 128, False: 310]
  |  Branch (2238:21): [True: 128, False: 0]
  |  Branch (2238:34): [True: 0, False: 128]
  ------------------
 2239|      0|        {
 2240|      0|          sig->keyid[0] = buf32_to_u32 (p + 1 );
 2241|      0|	  sig->keyid[1] = buf32_to_u32 (p + 1 + 4);
 2242|      0|	}
 2243|    438|      else if ((p = parse_sig_subpkt2 (sig, SIGSUBPKT_ISSUER)))
  ------------------
  |  Branch (2243:16): [True: 34, False: 404]
  ------------------
 2244|     34|        {
 2245|     34|          sig->keyid[0] = buf32_to_u32 (p);
 2246|     34|	  sig->keyid[1] = buf32_to_u32 (p + 4);
 2247|     34|	}
 2248|    404|      else if (!(sig->pubkey_algo >= 100 && sig->pubkey_algo <= 110)
  ------------------
  |  Branch (2248:18): [True: 55, False: 349]
  |  Branch (2248:45): [True: 0, False: 55]
  ------------------
 2249|    404|	       && opt.verbose > 1 && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (2249:12): [True: 0, False: 404]
  |  Branch (2249:31): [True: 0, False: 0]
  ------------------
 2250|      0|	log_info ("signature packet without keyid\n");
 2251|       |
 2252|    480|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_SIG_EXPIRE, NULL);
 2253|    480|      if (p && buf32_to_u32 (p))
  ------------------
  |  Branch (2253:11): [True: 0, False: 480]
  |  Branch (2253:16): [True: 0, False: 0]
  ------------------
 2254|      0|	sig->expiredate = sig->timestamp + buf32_to_u32 (p);
 2255|    480|      if (sig->expiredate && sig->expiredate <= make_timestamp ())
  ------------------
  |  Branch (2255:11): [True: 0, False: 480]
  |  Branch (2255:30): [True: 0, False: 0]
  ------------------
 2256|      0|	sig->flags.expired = 1;
 2257|       |
 2258|    480|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_POLICY, NULL);
 2259|    480|      if (p)
  ------------------
  |  Branch (2259:11): [True: 0, False: 480]
  ------------------
 2260|      0|	sig->flags.policy_url = 1;
 2261|       |
 2262|    480|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_PREF_KS, NULL);
 2263|    480|      if (p)
  ------------------
  |  Branch (2263:11): [True: 0, False: 480]
  ------------------
 2264|      0|	sig->flags.pref_ks = 1;
 2265|       |
 2266|    480|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_SIGNERS_UID, &len);
 2267|    480|      if (p && len)
  ------------------
  |  Branch (2267:11): [True: 0, False: 480]
  |  Branch (2267:16): [True: 0, False: 0]
  ------------------
 2268|      0|        {
 2269|      0|          char *mbox;
 2270|       |
 2271|      0|          sig->signers_uid = try_make_printable_string (p, len, 0);
 2272|      0|          if (!sig->signers_uid)
  ------------------
  |  Branch (2272:15): [True: 0, False: 0]
  ------------------
 2273|      0|            {
 2274|      0|              rc = gpg_error_from_syserror ();
 2275|      0|              goto leave;
 2276|      0|            }
 2277|      0|          mbox = mailbox_from_userid (sig->signers_uid, 0);
 2278|      0|          if (mbox)
  ------------------
  |  Branch (2278:15): [True: 0, False: 0]
  ------------------
 2279|      0|            {
 2280|      0|              xfree (sig->signers_uid);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2281|      0|              sig->signers_uid = mbox;
 2282|      0|            }
 2283|      0|        }
 2284|       |
 2285|    480|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_KEY_BLOCK, NULL);
 2286|    480|      if (p)
  ------------------
  |  Branch (2286:11): [True: 0, False: 480]
  ------------------
 2287|      0|        sig->flags.key_block = 1;
 2288|       |
 2289|    480|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_NOTATION, NULL);
 2290|    480|      if (p)
  ------------------
  |  Branch (2290:11): [True: 0, False: 480]
  ------------------
 2291|      0|	sig->flags.notation = 1;
 2292|       |
 2293|    480|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_REVOCABLE, NULL);
 2294|    480|      if (p && *p == 0)
  ------------------
  |  Branch (2294:11): [True: 0, False: 480]
  |  Branch (2294:16): [True: 0, False: 0]
  ------------------
 2295|      0|	sig->flags.revocable = 0;
 2296|       |
 2297|    480|      p = parse_sig_subpkt (sig, 1, SIGSUBPKT_TRUST, &len);
 2298|    480|      if (p && len == 2)
  ------------------
  |  Branch (2298:11): [True: 0, False: 480]
  |  Branch (2298:16): [True: 0, False: 0]
  ------------------
 2299|      0|	{
 2300|      0|	  sig->trust_depth = p[0];
 2301|      0|	  sig->trust_value = p[1];
 2302|       |
 2303|       |	  /* Only look for a regexp if there is also a trust
 2304|       |	     subpacket. */
 2305|      0|	  sig->trust_regexp =
 2306|      0|	    parse_sig_subpkt (sig, 1, SIGSUBPKT_REGEXP, &len);
 2307|       |
 2308|       |	  /* If the regular expression is of 0 length, there is no
 2309|       |	     regular expression. */
 2310|      0|	  if (len == 0)
  ------------------
  |  Branch (2310:8): [True: 0, False: 0]
  ------------------
 2311|      0|	    sig->trust_regexp = NULL;
 2312|      0|	}
 2313|       |
 2314|       |      /* We accept the exportable subpacket from either the hashed or
 2315|       |         unhashed areas as older versions of gpg put it in the
 2316|       |         unhashed area.  In theory, anyway, we should never see this
 2317|       |         packet off of a local keyring. */
 2318|       |
 2319|    480|      p = parse_sig_subpkt2 (sig, SIGSUBPKT_EXPORTABLE);
 2320|    480|      if (p && *p == 0)
  ------------------
  |  Branch (2320:11): [True: 131, False: 349]
  |  Branch (2320:16): [True: 131, False: 0]
  ------------------
 2321|    131|	sig->flags.exportable = 0;
 2322|       |
 2323|       |      /* Find all revocation keys.  */
 2324|    480|      if (sig->sig_class == 0x1F)
  ------------------
  |  Branch (2324:11): [True: 59, False: 421]
  ------------------
 2325|     59|	parse_revkeys (sig);
 2326|    480|    }
 2327|       |
 2328|  1.86k|  if (list_mode)
  ------------------
  |  Branch (2328:7): [True: 0, False: 1.86k]
  ------------------
 2329|      0|    {
 2330|      0|      es_fprintf (listfp, ":signature packet: algo %d, keyid %08lX%08lX\n"
 2331|      0|                  "\tversion %d, created %lu, md5len %d, sigclass 0x%02x\n"
 2332|      0|                  "\tdigest algo %d, begin of digest %02x %02x\n",
 2333|      0|                  sig->pubkey_algo,
 2334|      0|                  (ulong) sig->keyid[0], (ulong) sig->keyid[1],
 2335|      0|                  sig->version, (ulong) sig->timestamp, md5_len, sig->sig_class,
 2336|      0|                  sig->digest_algo, sig->digest_start[0], sig->digest_start[1]);
 2337|      0|      if (is_v4or5)
  ------------------
  |  Branch (2337:11): [True: 0, False: 0]
  ------------------
 2338|      0|	{
 2339|      0|	  parse_sig_subpkt (sig, 1, SIGSUBPKT_LIST_HASHED, NULL);
 2340|      0|	  parse_sig_subpkt (sig, 0, SIGSUBPKT_LIST_UNHASHED, NULL);
 2341|      0|	}
 2342|      0|    }
 2343|       |
 2344|  1.86k|  ndata = pubkey_get_nsig (sig->pubkey_algo);
 2345|  1.86k|  if (!ndata)
  ------------------
  |  Branch (2345:7): [True: 1.67k, False: 183]
  ------------------
 2346|  1.67k|    {
 2347|  1.67k|      if (list_mode)
  ------------------
  |  Branch (2347:11): [True: 0, False: 1.67k]
  ------------------
 2348|      0|	es_fprintf (listfp, "\tunknown algorithm %d\n", sig->pubkey_algo);
 2349|  1.67k|      unknown_pubkey_warning (sig->pubkey_algo);
 2350|       |
 2351|       |      /* We store the plain material in data[0], so that we are able
 2352|       |       * to write it back with build_packet().  */
 2353|  1.67k|      if (pktlen > (5 * MAX_EXTERN_MPI_BITS / 8))
  ------------------
  |  |   42|  1.67k|#define MAX_EXTERN_MPI_BITS 16384
  ------------------
  |  Branch (2353:11): [True: 0, False: 1.67k]
  ------------------
 2354|      0|	{
 2355|       |	  /* We include a limit to avoid too trivial DoS attacks by
 2356|       |	     having gpg allocate too much memory.  */
 2357|      0|	  log_error ("signature packet: too much data\n");
 2358|      0|	  rc = GPG_ERR_INV_PACKET;
 2359|      0|	}
 2360|  1.67k|      else
 2361|  1.67k|	{
 2362|  1.67k|          void *tmpp;
 2363|       |
 2364|  1.67k|          tmpp = read_rest (inp, pktlen);
 2365|  1.67k|	  sig->data[0] = gcry_mpi_set_opaque (NULL, tmpp, tmpp? pktlen * 8 : 0);
  ------------------
  |  Branch (2365:52): [True: 1.44k, False: 233]
  ------------------
 2366|  1.67k|	  pktlen = 0;
 2367|  1.67k|	}
 2368|  1.67k|    }
 2369|    183|  else
 2370|    183|    {
 2371|    491|      for (i = 0; i < ndata; i++)
  ------------------
  |  Branch (2371:19): [True: 308, False: 183]
  ------------------
 2372|    308|	{
 2373|    308|	  n = pktlen;
 2374|    308|          if (sig->pubkey_algo == PUBKEY_ALGO_ECDSA
  ------------------
  |  Branch (2374:15): [True: 166, False: 142]
  ------------------
 2375|    308|              || sig->pubkey_algo == PUBKEY_ALGO_EDDSA)
  ------------------
  |  Branch (2375:18): [True: 0, False: 142]
  ------------------
 2376|    166|            sig->data[i] = sos_read (inp, &n, 0);
 2377|    142|          else
 2378|    142|            sig->data[i] = mpi_read (inp, &n, 0);
 2379|    308|	  pktlen -= n;
 2380|    308|	  if (list_mode)
  ------------------
  |  Branch (2380:8): [True: 0, False: 308]
  ------------------
 2381|      0|	    {
 2382|      0|	      es_fprintf (listfp, "\tdata: ");
 2383|      0|	      mpi_print (listfp, sig->data[i], mpi_print_mode);
 2384|      0|	      es_putc ('\n', listfp);
 2385|      0|	    }
 2386|    308|	  if (!sig->data[i])
  ------------------
  |  Branch (2386:8): [True: 2, False: 306]
  ------------------
 2387|      2|	    rc = GPG_ERR_INV_PACKET;
 2388|    308|	}
 2389|    183|    }
 2390|       |
 2391|  1.92k| leave:
 2392|  1.92k|  iobuf_skip_rest (inp, pktlen, 0);
 2393|  1.92k|  return rc;
 2394|       |
 2395|      0| underflow:
 2396|      0|  log_error ("packet(%d) too short\n", pkttype);
 2397|      0|  if (list_mode)
  ------------------
  |  Branch (2397:7): [True: 0, False: 0]
  ------------------
 2398|      0|    es_fputs (":signature packet: [too short]\n", listfp);
 2399|       |
 2400|      0|  iobuf_skip_rest (inp, pktlen, 0);
 2401|       |
 2402|      0|  return GPG_ERR_INV_PACKET;
 2403|  1.86k|}
parse_attribute_subpkts:
 3018|     57|{
 3019|     57|  size_t n;
 3020|     57|  int count = 0;
 3021|     57|  struct user_attribute *attribs = NULL;
 3022|     57|  const byte *buffer = uid->attrib_data;
 3023|     57|  int buflen = uid->attrib_len;
 3024|     57|  byte type;
 3025|       |
 3026|     57|  xfree (uid->attribs);
  ------------------
  |  |  104|     57|#define xfree(a)         gcry_free ((a))
  ------------------
 3027|       |
 3028|    165|  while (buflen)
  ------------------
  |  Branch (3028:10): [True: 111, False: 54]
  ------------------
 3029|    111|    {
 3030|    111|      n = *buffer++;
 3031|    111|      buflen--;
 3032|    111|      if (n == 255)  /* 4 byte length header.  */
  ------------------
  |  Branch (3032:11): [True: 0, False: 111]
  ------------------
 3033|      0|	{
 3034|      0|	  if (buflen < 4)
  ------------------
  |  Branch (3034:8): [True: 0, False: 0]
  ------------------
 3035|      0|	    goto too_short;
 3036|      0|	  n = buf32_to_size_t (buffer);
 3037|      0|	  buffer += 4;
 3038|      0|	  buflen -= 4;
 3039|      0|	}
 3040|    111|      else if (n >= 192)  /* 2 byte special encoded length header.  */
  ------------------
  |  Branch (3040:16): [True: 2, False: 109]
  ------------------
 3041|      2|	{
 3042|      2|	  if (buflen < 2)
  ------------------
  |  Branch (3042:8): [True: 0, False: 2]
  ------------------
 3043|      0|	    goto too_short;
 3044|      2|	  n = ((n - 192) << 8) + *buffer + 192;
 3045|      2|	  buffer++;
 3046|      2|	  buflen--;
 3047|      2|	}
 3048|    111|      if (buflen < n)
  ------------------
  |  Branch (3048:11): [True: 2, False: 109]
  ------------------
 3049|      2|	goto too_short;
 3050|       |
 3051|    109|      if (!n)
  ------------------
  |  Branch (3051:11): [True: 1, False: 108]
  ------------------
 3052|      1|        {
 3053|       |          /* Too short to encode the subpacket type.  */
 3054|      1|          if (opt.verbose)
  ------------------
  |  Branch (3054:15): [True: 0, False: 1]
  ------------------
 3055|      0|            log_info ("attribute subpacket too short\n");
 3056|      1|          break;
 3057|      1|        }
 3058|       |
 3059|    108|      attribs = xrealloc (attribs,
  ------------------
  |  |  111|    108|#define xrealloc(a,b)    gcry_xrealloc ((a),(b))
  ------------------
 3060|    108|                          (count + 1) * sizeof (struct user_attribute));
 3061|    108|      memset (&attribs[count], 0, sizeof (struct user_attribute));
 3062|       |
 3063|    108|      type = *buffer;
 3064|    108|      buffer++;
 3065|    108|      buflen--;
 3066|    108|      n--;
 3067|       |
 3068|    108|      attribs[count].type = type;
 3069|    108|      attribs[count].data = buffer;
 3070|    108|      attribs[count].len = n;
 3071|    108|      buffer += n;
 3072|    108|      buflen -= n;
 3073|    108|      count++;
 3074|    108|    }
 3075|       |
 3076|     55|  uid->attribs = attribs;
 3077|     55|  uid->numattribs = count;
 3078|     55|  return count;
 3079|       |
 3080|      2| too_short:
 3081|      2|  if (opt.verbose && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (3081:7): [True: 0, False: 2]
  |  Branch (3081:22): [True: 0, False: 0]
  ------------------
 3082|      0|    log_info ("buffer shorter than attribute subpacket\n");
 3083|      2|  uid->attribs = attribs;
 3084|      2|  uid->numattribs = count;
 3085|      2|  return count;
 3086|     57|}
make_attribute_uidname:
 3139|     57|{
 3140|     57|  log_assert (max_namelen > 70);
 3141|     57|  if (uid->numattribs <= 0)
  ------------------
  |  Branch (3141:7): [True: 3, False: 54]
  ------------------
 3142|      3|    sprintf (uid->name, "[bad attribute packet of size %lu]",
 3143|      3|	     uid->attrib_len);
 3144|     54|  else if (uid->numattribs > 1)
  ------------------
  |  Branch (3144:12): [True: 54, False: 0]
  ------------------
 3145|     54|    sprintf (uid->name, "[%d attributes of size %lu]",
 3146|     54|	     uid->numattribs, uid->attrib_len);
 3147|      0|  else
 3148|      0|    {
 3149|       |      /* Only one attribute, so list it as the "user id" */
 3150|       |
 3151|      0|      if (uid->attribs->type == ATTRIB_IMAGE)
  ------------------
  |  |  263|      0|#define ATTRIB_IMAGE 1
  ------------------
  |  Branch (3151:11): [True: 0, False: 0]
  ------------------
 3152|      0|	{
 3153|      0|	  u32 len;
 3154|      0|	  byte type;
 3155|       |
 3156|      0|	  if (parse_image_header (uid->attribs, &type, &len))
  ------------------
  |  Branch (3156:8): [True: 0, False: 0]
  ------------------
 3157|      0|	    sprintf (uid->name, "[%.20s image of size %lu]",
 3158|      0|		     image_type_to_string (type, 1), (ulong) len);
 3159|      0|	  else
 3160|      0|	    sprintf (uid->name, "[invalid image]");
 3161|      0|	}
 3162|      0|      else
 3163|      0|	sprintf (uid->name, "[unknown attribute of size %lu]",
 3164|      0|		 (ulong) uid->attribs->len);
 3165|      0|    }
 3166|       |
 3167|     57|  uid->len = strlen (uid->name);
 3168|     57|}
parse-packet.c:parse:
  631|  7.47k|{
  632|  7.47k|  int rc = 0;
  633|  7.47k|  iobuf_t inp;
  634|  7.47k|  int c, ctb, pkttype, lenbytes;
  635|  7.47k|  unsigned long pktlen;
  636|  7.47k|  byte hdr[8];
  637|  7.47k|  int hdrlen;
  638|  7.47k|  int new_ctb = 0, partial = 0;
  639|  7.47k|  int with_uid = (onlykeypkts == 2);
  640|  7.47k|  off_t pos;
  641|       |
  642|  7.47k|  *skip = 0;
  643|  7.47k|  inp = ctx->inp;
  644|       |
  645|  7.74k| again:
  646|  7.74k|  log_assert (!pkt->pkt.generic);
  647|  7.74k|  if (retpos || list_mode)
  ------------------
  |  Branch (647:7): [True: 0, False: 7.74k]
  |  Branch (647:17): [True: 0, False: 7.74k]
  ------------------
  648|      0|    {
  649|      0|      pos = iobuf_tell (inp);
  650|      0|      if (retpos)
  ------------------
  |  Branch (650:11): [True: 0, False: 0]
  ------------------
  651|      0|        *retpos = pos;
  652|      0|    }
  653|  7.74k|  else
  654|  7.74k|    pos = 0; /* (silence compiler warning) */
  655|       |
  656|       |  /* The first byte of a packet is the so-called tag.  The highest bit
  657|       |     must be set.  */
  658|  7.74k|  if ((ctb = iobuf_get (inp)) == -1)
  ------------------
  |  |  500|  7.74k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 7.74k]
  |  |  |  Branch (500:24): [True: 532, False: 7.21k]
  |  |  ------------------
  |  |  501|  7.74k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (658:7): [True: 120, False: 7.62k]
  ------------------
  659|    120|    {
  660|    120|      rc = -1;
  661|    120|      goto leave;
  662|    120|    }
  663|  7.62k|  hdrlen = 0;
  664|  7.62k|  hdr[hdrlen++] = ctb;
  665|       |
  666|  7.62k|  if (!(ctb & 0x80))
  ------------------
  |  Branch (666:7): [True: 11, False: 7.61k]
  ------------------
  667|     11|    {
  668|     11|      log_error ("%s: invalid packet (ctb=%02x)\n", iobuf_where (inp), ctb);
  ------------------
  |  |  630|     11|#define iobuf_where(a)	"[don't know]"
  ------------------
  669|     11|      rc = gpg_error (GPG_ERR_INV_PACKET);
  670|     11|      goto leave;
  671|     11|    }
  672|       |
  673|       |  /* Immediately following the header is the length.  There are two
  674|       |     formats: the old format and the new format.  If bit 6 (where the
  675|       |     least significant bit is bit 0) is set in the tag, then we are
  676|       |     dealing with a new format packet.  Otherwise, it is an old format
  677|       |     packet.  */
  678|  7.61k|  pktlen = 0;
  679|  7.61k|  new_ctb = !!(ctb & 0x40);
  680|  7.61k|  if (new_ctb)
  ------------------
  |  Branch (680:7): [True: 2.51k, False: 5.09k]
  ------------------
  681|  2.51k|    {
  682|       |      /* Get the packet's type.  This is encoded in the 6 least
  683|       |	 significant bits of the tag.  */
  684|  2.51k|      pkttype = ctb & 0x3f;
  685|       |
  686|       |      /* Extract the packet's length.  New format packets have 4 ways
  687|       |	 to encode the packet length.  The value of the first byte
  688|       |	 determines the encoding and partially determines the length.
  689|       |	 See section 4.2.2 of RFC 4880 for details.  */
  690|  2.51k|      if ((c = iobuf_get (inp)) == -1)
  ------------------
  |  |  500|  2.51k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 2.51k]
  |  |  |  Branch (500:24): [True: 2, False: 2.51k]
  |  |  ------------------
  |  |  501|  2.51k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (690:11): [True: 0, False: 2.51k]
  ------------------
  691|      0|	{
  692|      0|	  log_error ("%s: 1st length byte missing\n", iobuf_where (inp));
  ------------------
  |  |  630|      0|#define iobuf_where(a)	"[don't know]"
  ------------------
  693|      0|	  rc = gpg_error (GPG_ERR_INV_PACKET);
  694|      0|	  goto leave;
  695|      0|	}
  696|       |
  697|       |
  698|  2.51k|      hdr[hdrlen++] = c;
  699|  2.51k|      if (c < 192)
  ------------------
  |  Branch (699:11): [True: 2.39k, False: 123]
  ------------------
  700|  2.39k|        pktlen = c;
  701|    123|      else if (c < 224)
  ------------------
  |  Branch (701:16): [True: 13, False: 110]
  ------------------
  702|     13|        {
  703|     13|          pktlen = (c - 192) * 256;
  704|     13|          if ((c = iobuf_get (inp)) == -1)
  ------------------
  |  |  500|     13|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 13]
  |  |  |  Branch (500:24): [True: 2, False: 11]
  |  |  ------------------
  |  |  501|     13|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (704:15): [True: 0, False: 13]
  ------------------
  705|      0|            {
  706|      0|              log_error ("%s: 2nd length byte missing\n",
  707|      0|                         iobuf_where (inp));
  ------------------
  |  |  630|      0|#define iobuf_where(a)	"[don't know]"
  ------------------
  708|      0|              rc = gpg_error (GPG_ERR_INV_PACKET);
  709|      0|              goto leave;
  710|      0|            }
  711|     13|          hdr[hdrlen++] = c;
  712|     13|          pktlen += c + 192;
  713|     13|        }
  714|    110|      else if (c == 255)
  ------------------
  |  Branch (714:16): [True: 108, False: 2]
  ------------------
  715|    108|        {
  716|    108|	  int i;
  717|    108|	  char value[4];
  718|       |
  719|    540|	  for (i = 0; i < 4; i ++)
  ------------------
  |  Branch (719:16): [True: 432, False: 108]
  ------------------
  720|    432|            {
  721|    432|              if ((c = iobuf_get (inp)) == -1)
  ------------------
  |  |  500|    432|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 432]
  |  |  |  Branch (500:24): [True: 0, False: 432]
  |  |  ------------------
  |  |  501|    432|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (721:19): [True: 0, False: 432]
  ------------------
  722|      0|                {
  723|      0|                  log_error ("%s: 4 byte length invalid\n", iobuf_where (inp));
  ------------------
  |  |  630|      0|#define iobuf_where(a)	"[don't know]"
  ------------------
  724|      0|                  rc = gpg_error (GPG_ERR_INV_PACKET);
  725|      0|                  goto leave;
  726|      0|                }
  727|    432|              value[i] = hdr[hdrlen++] = c;
  728|    432|            }
  729|       |
  730|    108|	  pktlen = buf32_to_ulong (value);
  731|    108|        }
  732|      2|      else /* Partial body length.  */
  733|      2|        {
  734|      2|          switch (pkttype)
  735|      2|            {
  736|      1|            case PKT_PLAINTEXT:
  ------------------
  |  Branch (736:13): [True: 1, False: 1]
  ------------------
  737|      2|            case PKT_ENCRYPTED:
  ------------------
  |  Branch (737:13): [True: 1, False: 1]
  ------------------
  738|      2|            case PKT_ENCRYPTED_MDC:
  ------------------
  |  Branch (738:13): [True: 0, False: 2]
  ------------------
  739|      2|            case PKT_ENCRYPTED_AEAD:
  ------------------
  |  Branch (739:13): [True: 0, False: 2]
  ------------------
  740|      2|            case PKT_COMPRESSED:
  ------------------
  |  Branch (740:13): [True: 0, False: 2]
  ------------------
  741|      2|              iobuf_set_partial_body_length_mode (inp, c & 0xff);
  742|      2|              pktlen = 0;	/* To indicate partial length.  */
  743|      2|              partial = 1;
  744|      2|              break;
  745|       |
  746|      0|            default:
  ------------------
  |  Branch (746:13): [True: 0, False: 2]
  ------------------
  747|      0|              log_error ("%s: partial length invalid for"
  748|      0|                         " packet type %d\n", iobuf_where (inp), pkttype);
  ------------------
  |  |  630|      0|#define iobuf_where(a)	"[don't know]"
  ------------------
  749|      0|              rc = gpg_error (GPG_ERR_INV_PACKET);
  750|      0|              goto leave;
  751|      2|            }
  752|      2|        }
  753|       |
  754|  2.51k|    }
  755|  5.09k|  else
  756|       |    /* This is an old format packet.  */
  757|  5.09k|    {
  758|       |      /* Extract the packet's type.  This is encoded in bits 2-5.  */
  759|  5.09k|      pkttype = (ctb >> 2) & 0xf;
  760|       |
  761|       |      /* The type of length encoding is encoded in bits 0-1 of the
  762|       |	 tag.  */
  763|  5.09k|      lenbytes = ((ctb & 3) == 3) ? 0 : (1 << (ctb & 3));
  ------------------
  |  Branch (763:18): [True: 33, False: 5.06k]
  ------------------
  764|  5.09k|      if (!lenbytes)
  ------------------
  |  Branch (764:11): [True: 33, False: 5.06k]
  ------------------
  765|     33|	{
  766|     33|	  pktlen = 0;	/* Don't know the value.  */
  767|       |	  /* This isn't really partial, but we can treat it the same
  768|       |	     in a "read until the end" sort of way.  */
  769|     33|	  partial = 1;
  770|     33|	  if (pkttype != PKT_ENCRYPTED && pkttype != PKT_PLAINTEXT
  ------------------
  |  Branch (770:8): [True: 33, False: 0]
  |  Branch (770:36): [True: 1, False: 32]
  ------------------
  771|     33|	      && pkttype != PKT_COMPRESSED)
  ------------------
  |  Branch (771:11): [True: 1, False: 0]
  ------------------
  772|      1|	    {
  773|      1|	      log_error ("%s: indeterminate length for invalid"
  774|      1|			 " packet type %d\n", iobuf_where (inp), pkttype);
  ------------------
  |  |  630|      1|#define iobuf_where(a)	"[don't know]"
  ------------------
  775|      1|	      rc = gpg_error (GPG_ERR_INV_PACKET);
  776|      1|	      goto leave;
  777|      1|	    }
  778|     33|	}
  779|  5.06k|      else
  780|  5.06k|	{
  781|  10.2k|	  for (; lenbytes; lenbytes--)
  ------------------
  |  Branch (781:11): [True: 5.20k, False: 5.06k]
  ------------------
  782|  5.20k|	    {
  783|  5.20k|	      pktlen <<= 8;
  784|  5.20k|	      c = iobuf_get (inp);
  ------------------
  |  |  500|  5.20k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 5.20k]
  |  |  |  Branch (500:24): [True: 1, False: 5.19k]
  |  |  ------------------
  |  |  501|  5.20k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  785|  5.20k|	      if (c == -1)
  ------------------
  |  Branch (785:12): [True: 1, False: 5.19k]
  ------------------
  786|      1|		{
  787|      1|		  log_error ("%s: length invalid\n", iobuf_where (inp));
  ------------------
  |  |  630|      1|#define iobuf_where(a)	"[don't know]"
  ------------------
  788|      1|		  rc = gpg_error (GPG_ERR_INV_PACKET);
  789|      1|		  goto leave;
  790|      1|		}
  791|  5.19k|	      pktlen |= hdr[hdrlen++] = c;
  792|  5.19k|	    }
  793|  5.06k|	}
  794|  5.09k|    }
  795|       |
  796|       |  /* Sometimes the decompressing layer enters an error state in which
  797|       |     it simply outputs 0xff for every byte read.  If we have a stream
  798|       |     of 0xff bytes, then it will be detected as a new format packet
  799|       |     with type 63 and a 4-byte encoded length that is 4G-1.  Since
  800|       |     packets with type 63 are private and we use them as a control
  801|       |     packet, which won't be 4 GB, we reject such packets as
  802|       |     invalid.  */
  803|  7.60k|  if (pkttype == 63 && pktlen == 0xFFFFFFFF)
  ------------------
  |  Branch (803:7): [True: 0, False: 7.60k]
  |  Branch (803:24): [True: 0, False: 0]
  ------------------
  804|      0|    {
  805|       |      /* With some probability this is caused by a problem in the
  806|       |       * the uncompressing layer - in some error cases it just loops
  807|       |       * and spits out 0xff bytes. */
  808|      0|      log_error ("%s: garbled packet detected\n", iobuf_where (inp));
  ------------------
  |  |  630|      0|#define iobuf_where(a)	"[don't know]"
  ------------------
  809|      0|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  810|      0|      rc = gpg_error (GPG_ERR_INV_PACKET);
  811|      0|      goto leave;
  812|       |#else
  813|       |      g10_exit (2);
  814|       |#endif
  815|      0|    }
  816|       |
  817|  7.60k|  if (out && pkttype)
  ------------------
  |  Branch (817:7): [True: 0, False: 7.60k]
  |  Branch (817:14): [True: 0, False: 0]
  ------------------
  818|      0|    {
  819|       |      /* This type of copying won't work if the packet uses a partial
  820|       |	 body length.  (In other words, this only works if HDR is
  821|       |	 actually the length.)  Currently, no callers require this
  822|       |	 functionality so we just log this as an error.  */
  823|      0|      if (partial)
  ------------------
  |  Branch (823:11): [True: 0, False: 0]
  ------------------
  824|      0|	{
  825|      0|	  log_error ("parse: Can't copy partial packet.  Aborting.\n");
  826|      0|	  rc = gpg_error (GPG_ERR_INV_PACKET);
  827|      0|	  goto leave;
  828|      0|	}
  829|       |
  830|      0|      rc = iobuf_write (out, hdr, hdrlen);
  831|      0|      if (!rc)
  ------------------
  |  Branch (831:11): [True: 0, False: 0]
  ------------------
  832|      0|	rc = copy_packet (inp, out, pkttype, pktlen, partial);
  833|      0|      goto leave;
  834|      0|    }
  835|       |
  836|  7.60k|  if (with_uid && pkttype == PKT_USER_ID)
  ------------------
  |  Branch (836:7): [True: 0, False: 7.60k]
  |  Branch (836:19): [True: 0, False: 0]
  ------------------
  837|       |    /* If ONLYKEYPKTS is set to 2, then we never skip user id packets,
  838|       |       even if DO_SKIP is set.  */
  839|      0|    ;
  840|  7.60k|  else if (do_skip
  ------------------
  |  Branch (840:12): [True: 0, False: 7.60k]
  ------------------
  841|       |	   /* type==0 is not allowed.  This is an invalid packet.  */
  842|  7.60k|	   || !pkttype
  ------------------
  |  Branch (842:8): [True: 281, False: 7.32k]
  ------------------
  843|       |	   /* When ONLYKEYPKTS is set, we don't skip keys.  */
  844|  7.60k|	   || (onlykeypkts && pkttype != PKT_PUBLIC_SUBKEY
  ------------------
  |  Branch (844:9): [True: 0, False: 7.32k]
  |  Branch (844:24): [True: 0, False: 0]
  ------------------
  845|  7.32k|	       && pkttype != PKT_PUBLIC_KEY
  ------------------
  |  Branch (845:12): [True: 0, False: 0]
  ------------------
  846|  7.32k|	       && pkttype != PKT_SECRET_SUBKEY && pkttype != PKT_SECRET_KEY))
  ------------------
  |  Branch (846:12): [True: 0, False: 0]
  |  Branch (846:44): [True: 0, False: 0]
  ------------------
  847|    281|    {
  848|    281|      iobuf_skip_rest (inp, pktlen, partial);
  849|    281|      *skip = 1;
  850|    281|      rc = 0;
  851|    281|      goto leave;
  852|    281|    }
  853|       |
  854|  7.32k|  if (DBG_PACKET)
  ------------------
  |  |  348|  7.32k|#define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
  |  |  ------------------
  |  |  |  |  331|  7.32k|#define DBG_PACKET_VALUE  1	/* debug packet reading/writing */
  |  |  ------------------
  |  |  |  Branch (348:20): [True: 0, False: 7.32k]
  |  |  ------------------
  ------------------
  855|      0|    {
  856|      0|#if DEBUG_PARSE_PACKET
  857|      0|      log_debug ("parse_packet(iob=%d): type=%d length=%lu%s (%s.%s.%d)\n",
  858|      0|		 iobuf_id (inp), pkttype, pktlen, new_ctb ? " (new_ctb)" : "",
  ------------------
  |  |  635|      0|#define iobuf_id(a)	((a)->no)
  ------------------
  |  Branch (858:37): [True: 0, False: 0]
  ------------------
  859|      0|		 dbg_w, dbg_f, dbg_l);
  860|       |#else
  861|       |      log_debug ("parse_packet(iob=%d): type=%d length=%lu%s\n",
  862|       |		 iobuf_id (inp), pkttype, pktlen,
  863|       |		 new_ctb ? " (new_ctb)" : "");
  864|       |#endif
  865|      0|    }
  866|       |
  867|  7.32k|  if (list_mode)
  ------------------
  |  Branch (867:7): [True: 0, False: 7.32k]
  ------------------
  868|      0|    es_fprintf (listfp, "# off=%lu ctb=%02x tag=%d hlen=%d plen=%lu%s%s\n",
  869|      0|                (unsigned long)pos, ctb, pkttype, hdrlen, pktlen,
  870|      0|                partial? (new_ctb ? " partial" : " indeterminate") :"",
  ------------------
  |  Branch (870:17): [True: 0, False: 0]
  |  Branch (870:27): [True: 0, False: 0]
  ------------------
  871|      0|                new_ctb? " new-ctb":"");
  ------------------
  |  Branch (871:17): [True: 0, False: 0]
  ------------------
  872|       |
  873|       |  /* Count it.  */
  874|  7.32k|  ctx->n_parsed_packets++;
  875|       |
  876|  7.32k|  pkt->pkttype = pkttype;
  877|  7.32k|  rc = GPG_ERR_UNKNOWN_PACKET;	/* default error */
  878|  7.32k|  switch (pkttype)
  879|  7.32k|    {
  880|    752|    case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (880:5): [True: 752, False: 6.57k]
  ------------------
  881|    765|    case PKT_PUBLIC_SUBKEY:
  ------------------
  |  Branch (881:5): [True: 13, False: 7.31k]
  ------------------
  882|  1.03k|    case PKT_SECRET_KEY:
  ------------------
  |  Branch (882:5): [True: 272, False: 7.05k]
  ------------------
  883|  1.46k|    case PKT_SECRET_SUBKEY:
  ------------------
  |  Branch (883:5): [True: 423, False: 6.90k]
  ------------------
  884|  1.46k|      pkt->pkt.public_key = xmalloc_clear (sizeof *pkt->pkt.public_key);
  ------------------
  |  |  116|  1.46k|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
  885|  1.46k|      rc = parse_key (inp, pkttype, pktlen, hdr, hdrlen, pkt);
  886|  1.46k|      break;
  887|    834|    case PKT_SYMKEY_ENC:
  ------------------
  |  Branch (887:5): [True: 834, False: 6.49k]
  ------------------
  888|    834|      rc = parse_symkeyenc (inp, pkttype, pktlen, pkt);
  889|    834|      break;
  890|      0|    case PKT_PUBKEY_ENC:
  ------------------
  |  Branch (890:5): [True: 0, False: 7.32k]
  ------------------
  891|      0|      rc = parse_pubkeyenc (inp, pkttype, pktlen, pkt);
  892|      0|      break;
  893|  1.92k|    case PKT_SIGNATURE:
  ------------------
  |  Branch (893:5): [True: 1.92k, False: 5.40k]
  ------------------
  894|  1.92k|      pkt->pkt.signature = xmalloc_clear (sizeof *pkt->pkt.signature);
  ------------------
  |  |  116|  1.92k|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
  895|  1.92k|      rc = parse_signature (inp, pkttype, pktlen, pkt->pkt.signature);
  896|  1.92k|      break;
  897|     32|    case PKT_ONEPASS_SIG:
  ------------------
  |  Branch (897:5): [True: 32, False: 7.29k]
  ------------------
  898|     32|      pkt->pkt.onepass_sig = xmalloc_clear (sizeof *pkt->pkt.onepass_sig);
  ------------------
  |  |  116|     32|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
  899|     32|      rc = parse_onepass_sig (inp, pkttype, pktlen, pkt->pkt.onepass_sig);
  900|     32|      break;
  901|  1.58k|    case PKT_USER_ID:
  ------------------
  |  Branch (901:5): [True: 1.58k, False: 5.74k]
  ------------------
  902|  1.58k|      rc = parse_user_id (inp, pkttype, pktlen, pkt);
  903|  1.58k|      break;
  904|     57|    case PKT_ATTRIBUTE:
  ------------------
  |  Branch (904:5): [True: 57, False: 7.27k]
  ------------------
  905|     57|      pkt->pkttype = pkttype = PKT_USER_ID;	/* we store it in the userID */
  906|     57|      rc = parse_attribute (inp, pkttype, pktlen, pkt);
  907|     57|      break;
  908|    373|    case PKT_OLD_COMMENT:
  ------------------
  |  Branch (908:5): [True: 373, False: 6.95k]
  ------------------
  909|  1.06k|    case PKT_COMMENT:
  ------------------
  |  Branch (909:5): [True: 692, False: 6.63k]
  ------------------
  910|  1.06k|      rc = parse_comment (inp, pkttype, pktlen, pkt);
  911|  1.06k|      break;
  912|    270|    case PKT_RING_TRUST:
  ------------------
  |  Branch (912:5): [True: 270, False: 7.05k]
  ------------------
  913|    270|      {
  914|    270|        rc = parse_ring_trust (ctx, pktlen);
  915|    270|        if (!rc)
  ------------------
  |  Branch (915:13): [True: 270, False: 0]
  ------------------
  916|    270|          goto again; /* Directly read the next packet.  */
  917|    270|      }
  918|      0|      break;
  919|     34|    case PKT_PLAINTEXT:
  ------------------
  |  Branch (919:5): [True: 34, False: 7.29k]
  ------------------
  920|     34|      rc = parse_plaintext (inp, pkttype, pktlen, pkt, new_ctb, partial);
  921|     34|      break;
  922|      2|    case PKT_COMPRESSED:
  ------------------
  |  Branch (922:5): [True: 2, False: 7.32k]
  ------------------
  923|      2|      rc = parse_compressed (inp, pkttype, pktlen, pkt, new_ctb);
  924|      2|      break;
  925|      1|    case PKT_ENCRYPTED:
  ------------------
  |  Branch (925:5): [True: 1, False: 7.32k]
  ------------------
  926|      1|    case PKT_ENCRYPTED_MDC:
  ------------------
  |  Branch (926:5): [True: 0, False: 7.32k]
  ------------------
  927|      1|      rc = parse_encrypted (inp, pkttype, pktlen, pkt, new_ctb, partial);
  928|      1|      break;
  929|      0|    case PKT_MDC:
  ------------------
  |  Branch (929:5): [True: 0, False: 7.32k]
  ------------------
  930|      0|      rc = parse_mdc (inp, pkttype, pktlen, pkt, new_ctb);
  931|      0|      break;
  932|     32|    case PKT_ENCRYPTED_AEAD:
  ------------------
  |  Branch (932:5): [True: 32, False: 7.29k]
  ------------------
  933|     32|      rc = parse_encrypted_aead (inp, pkttype, pktlen, pkt, partial);
  934|     32|      break;
  935|      0|    case PKT_GPG_CONTROL:
  ------------------
  |  Branch (935:5): [True: 0, False: 7.32k]
  ------------------
  936|      0|      rc = parse_gpg_control (inp, pkttype, pktlen, pkt, partial);
  937|      0|      break;
  938|      0|    case PKT_MARKER:
  ------------------
  |  Branch (938:5): [True: 0, False: 7.32k]
  ------------------
  939|      0|      rc = parse_marker (inp, pkttype, pktlen);
  940|      0|      break;
  941|     31|    default:
  ------------------
  |  Branch (941:5): [True: 31, False: 7.29k]
  ------------------
  942|       |      /* Unknown packet.  Skip it.  */
  943|     31|      skip_packet (inp, pkttype, pktlen, partial);
  944|     31|      break;
  945|  7.32k|    }
  946|       |
  947|       |  /* Store a shallow copy of certain packets in the context.  */
  948|  7.05k|  free_packet (NULL, ctx);
  949|  7.05k|  if (!rc && (pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (949:7): [True: 6.98k, False: 70]
  |  Branch (949:15): [True: 750, False: 6.23k]
  ------------------
  950|  6.98k|              || pkttype == PKT_SECRET_KEY
  ------------------
  |  Branch (950:18): [True: 271, False: 5.96k]
  ------------------
  951|  6.98k|              || pkttype == PKT_USER_ID
  ------------------
  |  Branch (951:18): [True: 1.63k, False: 4.32k]
  ------------------
  952|  6.98k|              || pkttype == PKT_ATTRIBUTE
  ------------------
  |  Branch (952:18): [True: 0, False: 4.32k]
  ------------------
  953|  6.98k|              || pkttype == PKT_SIGNATURE))
  ------------------
  |  Branch (953:18): [True: 1.89k, False: 2.43k]
  ------------------
  954|  4.55k|    {
  955|  4.55k|      ctx->last_pkt = *pkt;
  956|  4.55k|    }
  957|       |
  958|  7.47k| leave:
  959|       |  /* FIXME: We leak in case of an error (see the xmalloc's above).  */
  960|  7.47k|  if (!rc && iobuf_error (inp))
  ------------------
  |  |  454|  7.26k|#define iobuf_error(a)	      ((a)->error)
  |  |  ------------------
  |  |  |  Branch (454:30): [True: 1, False: 7.26k]
  |  |  ------------------
  ------------------
  |  Branch (960:7): [True: 7.26k, False: 203]
  ------------------
  961|      1|    rc = GPG_ERR_INV_KEYRING;
  962|       |
  963|       |  /* FIXME: We use only the error code for now to avoid problems with
  964|       |     callers which have not been checked to always use gpg_err_code()
  965|       |     when comparing error codes.  */
  966|  7.47k|  return rc == -1? -1 : gpg_err_code (rc);
  ------------------
  |  Branch (966:10): [True: 152, False: 7.32k]
  ------------------
  967|  7.05k|}
parse-packet.c:parse_key:
 2462|  1.46k|{
 2463|  1.46k|  gpg_error_t err = 0;
 2464|  1.46k|  int i, version, algorithm;
 2465|  1.46k|  unsigned long timestamp, expiredate, max_expiredate;
 2466|  1.46k|  int npkey, nskey;
 2467|  1.46k|  u32 keyid[2];
 2468|  1.46k|  PKT_public_key *pk;
 2469|  1.46k|  int is_v5;
 2470|  1.46k|  unsigned int pkbytes; /* For v5 keys: Number of bytes in the public
 2471|       |                         * key material.  For v4 keys: 0.  */
 2472|       |
 2473|  1.46k|  (void) hdr;
 2474|       |
 2475|  1.46k|  pk = pkt->pkt.public_key; /* PK has been cleared. */
 2476|       |
 2477|  1.46k|  version = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  1.46k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  1.46k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 1.46k]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 1.46k]
  |  |  |  |  ------------------
  |  |  |  |  501|  1.46k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2478|  1.46k|  pktlen--;
 2479|  1.46k|  if (pkttype == PKT_PUBLIC_SUBKEY && version == '#')
  ------------------
  |  Branch (2479:7): [True: 13, False: 1.44k]
  |  Branch (2479:39): [True: 0, False: 13]
  ------------------
 2480|      0|    {
 2481|       |      /* Early versions of G10 used the old PGP comments packets;
 2482|       |       * luckily all those comments are started by a hash.  */
 2483|      0|      if (list_mode)
  ------------------
  |  Branch (2483:11): [True: 0, False: 0]
  ------------------
 2484|      0|	{
 2485|      0|	  es_fprintf (listfp, ":rfc1991 comment packet: \"");
 2486|      0|	  for (; pktlen; pktlen--)
  ------------------
  |  Branch (2486:11): [True: 0, False: 0]
  ------------------
 2487|      0|	    {
 2488|      0|	      int c;
 2489|      0|	      c = iobuf_get (inp);
  ------------------
  |  |  500|      0|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 0]
  |  |  |  Branch (500:24): [True: 0, False: 0]
  |  |  ------------------
  |  |  501|      0|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
 2490|      0|              if (c == -1)
  ------------------
  |  Branch (2490:19): [True: 0, False: 0]
  ------------------
 2491|      0|                break; /* Ooops: shorter than indicated.  */
 2492|      0|	      if (c >= ' ' && c <= 'z')
  ------------------
  |  Branch (2492:12): [True: 0, False: 0]
  |  Branch (2492:24): [True: 0, False: 0]
  ------------------
 2493|      0|		es_putc (c, listfp);
 2494|      0|	      else
 2495|      0|		es_fprintf (listfp, "\\x%02x", c);
 2496|      0|	    }
 2497|      0|	  es_fprintf (listfp, "\"\n");
 2498|      0|	}
 2499|      0|      iobuf_skip_rest (inp, pktlen, 0);
 2500|      0|      return 0;
 2501|      0|    }
 2502|  1.46k|  else if (version == 4)
  ------------------
  |  Branch (2502:12): [True: 1.42k, False: 34]
  ------------------
 2503|  1.42k|    is_v5 = 0;
 2504|     34|  else if (version == 5)
  ------------------
  |  Branch (2504:12): [True: 33, False: 1]
  ------------------
 2505|     33|    is_v5 = 1;
 2506|      1|  else if (version == 2 || version == 3)
  ------------------
  |  Branch (2506:12): [True: 0, False: 1]
  |  Branch (2506:28): [True: 0, False: 1]
  ------------------
 2507|      0|    {
 2508|       |      /* Not anymore supported since 2.1.  Use an older gpg version
 2509|       |       * (i.e. gpg 1.4) to parse v3 packets.  */
 2510|      0|      if (opt.verbose > 1 && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (2510:11): [True: 0, False: 0]
  |  Branch (2510:30): [True: 0, False: 0]
  ------------------
 2511|      0|        log_info ("packet(%d) with obsolete version %d\n", pkttype, version);
 2512|      0|      if (list_mode)
  ------------------
  |  Branch (2512:11): [True: 0, False: 0]
  ------------------
 2513|      0|        es_fprintf (listfp, ":key packet: [obsolete version %d]\n", version);
 2514|      0|      pk->version = version;
 2515|      0|      err = gpg_error (GPG_ERR_LEGACY_KEY);
 2516|      0|      goto leave;
 2517|      0|    }
 2518|      1|  else
 2519|      1|    {
 2520|      1|      log_error ("packet(%d) with unknown version %d\n", pkttype, version);
 2521|      1|      if (list_mode)
  ------------------
  |  Branch (2521:11): [True: 0, False: 1]
  ------------------
 2522|      0|        es_fputs (":key packet: [unknown version]\n", listfp);
 2523|      1|      err = gpg_error (GPG_ERR_INV_PACKET);
 2524|      1|      goto leave;
 2525|      1|    }
 2526|       |
 2527|  1.45k|  if (pktlen < (is_v5? 15:11))
  ------------------
  |  Branch (2527:7): [True: 0, False: 1.45k]
  |  Branch (2527:17): [True: 33, False: 1.42k]
  ------------------
 2528|      0|    {
 2529|      0|      log_error ("packet(%d) too short\n", pkttype);
 2530|      0|      if (list_mode)
  ------------------
  |  Branch (2530:11): [True: 0, False: 0]
  ------------------
 2531|      0|        es_fputs (":key packet: [too short]\n", listfp);
 2532|      0|      err = gpg_error (GPG_ERR_INV_PACKET);
 2533|      0|      goto leave;
 2534|      0|    }
 2535|  1.45k|  else if (pktlen > MAX_KEY_PACKET_LENGTH)
  ------------------
  |  |   37|  1.45k|#define MAX_KEY_PACKET_LENGTH     (256 * 1024)
  ------------------
  |  Branch (2535:12): [True: 0, False: 1.45k]
  ------------------
 2536|      0|    {
 2537|      0|      log_error ("packet(%d) too large\n", pkttype);
 2538|      0|      if (list_mode)
  ------------------
  |  Branch (2538:11): [True: 0, False: 0]
  ------------------
 2539|      0|        es_fputs (":key packet: [too large]\n", listfp);
 2540|      0|      err = gpg_error (GPG_ERR_INV_PACKET);
 2541|      0|      goto leave;
 2542|      0|    }
 2543|       |
 2544|  1.45k|  timestamp = read_32 (inp);
 2545|  1.45k|  pktlen -= 4;
 2546|  1.45k|  expiredate = 0;		/* have to get it from the selfsignature */
 2547|  1.45k|  max_expiredate = 0;
 2548|  1.45k|  algorithm = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  1.45k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  1.45k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 1.45k]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 1.45k]
  |  |  |  |  ------------------
  |  |  |  |  501|  1.45k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2549|  1.45k|  pktlen--;
 2550|  1.45k|  if (is_v5)
  ------------------
  |  Branch (2550:7): [True: 33, False: 1.42k]
  ------------------
 2551|     33|    {
 2552|     33|      pkbytes = read_32 (inp);
 2553|     33|      pktlen -= 4;
 2554|     33|    }
 2555|  1.42k|  else
 2556|  1.42k|    pkbytes = 0;
 2557|       |
 2558|  1.45k|  if (list_mode)
  ------------------
  |  Branch (2558:7): [True: 0, False: 1.45k]
  ------------------
 2559|      0|    {
 2560|      0|      es_fprintf (listfp, ":%s key packet:\n"
 2561|      0|                  "\tversion %d, algo %d, created %lu, expires %lu",
 2562|      0|                  pkttype == PKT_PUBLIC_KEY ? "public" :
  ------------------
  |  Branch (2562:19): [True: 0, False: 0]
  ------------------
 2563|      0|                  pkttype == PKT_SECRET_KEY ? "secret" :
  ------------------
  |  Branch (2563:19): [True: 0, False: 0]
  ------------------
 2564|      0|                  pkttype == PKT_PUBLIC_SUBKEY ? "public sub" :
  ------------------
  |  Branch (2564:19): [True: 0, False: 0]
  ------------------
 2565|      0|                  pkttype == PKT_SECRET_SUBKEY ? "secret sub" : "??",
  ------------------
  |  Branch (2565:19): [True: 0, False: 0]
  ------------------
 2566|      0|                  version, algorithm, timestamp, expiredate);
 2567|      0|      if (is_v5)
  ------------------
  |  Branch (2567:11): [True: 0, False: 0]
  ------------------
 2568|      0|        es_fprintf (listfp, ", pkbytes %u\n", pkbytes);
 2569|      0|      else
 2570|      0|        es_fprintf (listfp, "\n");
 2571|      0|    }
 2572|       |
 2573|  1.45k|  pk->timestamp = timestamp;
 2574|  1.45k|  pk->expiredate = expiredate;
 2575|  1.45k|  pk->max_expiredate = max_expiredate;
 2576|  1.45k|  pk->hdrbytes = hdrlen;
 2577|  1.45k|  pk->version = version;
 2578|  1.45k|  pk->flags.primary = (pkttype == PKT_PUBLIC_KEY || pkttype == PKT_SECRET_KEY);
  ------------------
  |  Branch (2578:24): [True: 752, False: 707]
  |  Branch (2578:53): [True: 272, False: 435]
  ------------------
 2579|  1.45k|  pk->pubkey_algo = algorithm;
 2580|       |
 2581|  1.45k|  nskey = pubkey_get_nskey (algorithm);
 2582|  1.45k|  npkey = pubkey_get_npkey (algorithm);
 2583|  1.45k|  if (!npkey)
  ------------------
  |  Branch (2583:7): [True: 984, False: 475]
  ------------------
 2584|    984|    {
 2585|    984|      if (list_mode)
  ------------------
  |  Branch (2585:11): [True: 0, False: 984]
  ------------------
 2586|      0|	es_fprintf (listfp, "\tunknown algorithm %d\n", algorithm);
 2587|    984|      unknown_pubkey_warning (algorithm);
 2588|    984|    }
 2589|       |
 2590|  1.45k|  if (!npkey)
  ------------------
  |  Branch (2590:7): [True: 984, False: 475]
  ------------------
 2591|    984|    {
 2592|       |      /* Unknown algorithm - put data into an opaque MPI.  */
 2593|    984|      void *tmpp = read_rest (inp, pktlen);
 2594|       |      /* Current gcry_mpi_cmp does not handle a (NULL,n>0) nicely and
 2595|       |       * thus we avoid to create such an MPI.  */
 2596|    984|      pk->pkey[0] = gcry_mpi_set_opaque (NULL, tmpp, tmpp? pktlen * 8 : 0);
  ------------------
  |  Branch (2596:54): [True: 858, False: 126]
  ------------------
 2597|    984|      pktlen = 0;
 2598|    984|      goto leave;
 2599|    984|    }
 2600|    475|  else
 2601|    475|    {
 2602|  1.43k|      for (i = 0; i < npkey; i++)
  ------------------
  |  Branch (2602:19): [True: 958, False: 472]
  ------------------
 2603|    958|        {
 2604|    958|          if (    (algorithm == PUBKEY_ALGO_ECDSA && (i == 0))
  ------------------
  |  Branch (2604:20): [True: 114, False: 844]
  |  Branch (2604:54): [True: 57, False: 57]
  ------------------
 2605|    958|               || (algorithm == PUBKEY_ALGO_EDDSA && (i == 0))
  ------------------
  |  Branch (2605:20): [True: 34, False: 867]
  |  Branch (2605:54): [True: 17, False: 17]
  ------------------
 2606|    958|               || (algorithm == PUBKEY_ALGO_ECDH  && (i == 0 || i == 2)))
  ------------------
  |  Branch (2606:20): [True: 27, False: 857]
  |  Branch (2606:55): [True: 9, False: 18]
  |  Branch (2606:65): [True: 9, False: 9]
  ------------------
 2607|     92|            {
 2608|       |              /* Read the OID (i==0) or the KDF params (i==2).  */
 2609|     92|              size_t n;
 2610|     92|	      err = read_size_body (inp, pktlen, &n, pk->pkey+i);
 2611|     92|              pktlen -= n;
 2612|     92|            }
 2613|    866|          else
 2614|    866|            {
 2615|    866|              unsigned int n = pktlen;
 2616|    866|              if (algorithm == PUBKEY_ALGO_ECDSA
  ------------------
  |  Branch (2616:19): [True: 57, False: 809]
  ------------------
 2617|    866|                  || algorithm == PUBKEY_ALGO_EDDSA
  ------------------
  |  Branch (2617:22): [True: 17, False: 792]
  ------------------
 2618|    866|                  || algorithm == PUBKEY_ALGO_ECDH)
  ------------------
  |  Branch (2618:22): [True: 9, False: 783]
  ------------------
 2619|     83|                pk->pkey[i] = sos_read (inp, &n, 0);
 2620|    783|              else
 2621|    783|                pk->pkey[i] = mpi_read (inp, &n, 0);
 2622|    866|              pktlen -= n;
 2623|    866|              if (!pk->pkey[i])
  ------------------
  |  Branch (2623:19): [True: 3, False: 863]
  ------------------
 2624|      3|                err = gpg_error (GPG_ERR_INV_PACKET);
 2625|    866|            }
 2626|    958|          if (err)
  ------------------
  |  Branch (2626:15): [True: 3, False: 955]
  ------------------
 2627|      3|            goto leave;
 2628|    955|          if (list_mode)
  ------------------
  |  Branch (2628:15): [True: 0, False: 955]
  ------------------
 2629|      0|            {
 2630|      0|              es_fprintf (listfp, "\tpkey[%d]: ", i);
 2631|      0|              mpi_print (listfp, pk->pkey[i], mpi_print_mode);
 2632|      0|              if ((algorithm == PUBKEY_ALGO_ECDSA
  ------------------
  |  Branch (2632:20): [True: 0, False: 0]
  ------------------
 2633|      0|                   || algorithm == PUBKEY_ALGO_EDDSA
  ------------------
  |  Branch (2633:23): [True: 0, False: 0]
  ------------------
 2634|      0|                   || algorithm == PUBKEY_ALGO_ECDH) && i==0)
  ------------------
  |  Branch (2634:23): [True: 0, False: 0]
  |  Branch (2634:57): [True: 0, False: 0]
  ------------------
 2635|      0|                {
 2636|      0|                  char *curve = openpgp_oid_to_str (pk->pkey[0]);
 2637|      0|                  const char *name = openpgp_oid_to_curve (curve, 0);
 2638|      0|                  es_fprintf (listfp, " %s (%s)", name?name:"", curve);
  ------------------
  |  Branch (2638:51): [True: 0, False: 0]
  ------------------
 2639|      0|                  xfree (curve);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2640|      0|                }
 2641|      0|              es_putc ('\n', listfp);
 2642|      0|            }
 2643|    955|        }
 2644|    475|    }
 2645|    472|  if (list_mode)
  ------------------
  |  Branch (2645:7): [True: 0, False: 472]
  ------------------
 2646|      0|    keyid_from_pk (pk, keyid);
 2647|       |
 2648|    472|  if (pkttype == PKT_SECRET_KEY || pkttype == PKT_SECRET_SUBKEY)
  ------------------
  |  Branch (2648:7): [True: 193, False: 279]
  |  Branch (2648:36): [True: 229, False: 50]
  ------------------
 2649|    422|    {
 2650|    422|      struct seckey_info *ski;
 2651|    422|      byte temp[16];
 2652|    422|      size_t snlen = 0;
 2653|    422|      unsigned int skbytes;
 2654|       |
 2655|    422|      if (pktlen < 1)
  ------------------
  |  Branch (2655:11): [True: 0, False: 422]
  ------------------
 2656|      0|        {
 2657|      0|          err = gpg_error (GPG_ERR_INV_PACKET);
 2658|      0|          goto leave;
 2659|      0|        }
 2660|       |
 2661|    422|      pk->seckey_info = ski = xtrycalloc (1, sizeof *ski);
  ------------------
  |  |   99|    422|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
 2662|    422|      if (!pk->seckey_info)
  ------------------
  |  Branch (2662:11): [True: 0, False: 422]
  ------------------
 2663|      0|        {
 2664|      0|          err = gpg_error_from_syserror ();
 2665|      0|          goto leave;
 2666|      0|        }
 2667|       |
 2668|    422|      ski->algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|    422|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|    422|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 422]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 422]
  |  |  |  |  ------------------
  |  |  |  |  501|    422|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2669|    422|      pktlen--;
 2670|       |
 2671|    422|      if (is_v5)
  ------------------
  |  Branch (2671:11): [True: 1, False: 421]
  ------------------
 2672|      1|        {
 2673|      1|          unsigned int protcount = 0;
 2674|       |
 2675|       |          /* Read the one octet count of the following key-protection
 2676|       |           * material.  Only required in case of unknown values. */
 2677|      1|          if (!pktlen)
  ------------------
  |  Branch (2677:15): [True: 0, False: 1]
  ------------------
 2678|      0|            {
 2679|      0|              err = gpg_error (GPG_ERR_INV_PACKET);
 2680|      0|              goto leave;
 2681|      0|            }
 2682|      1|          protcount = iobuf_get_noeof (inp);
  ------------------
  |  |  502|      1|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|      1|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 1]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  501|      1|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2683|      1|          pktlen--;
 2684|      1|          if (list_mode)
  ------------------
  |  Branch (2684:15): [True: 0, False: 1]
  ------------------
 2685|      0|            es_fprintf (listfp, "\tprotbytes: %u\n", protcount);
 2686|      1|        }
 2687|       |
 2688|    422|      if (ski->algo)
  ------------------
  |  Branch (2688:11): [True: 364, False: 58]
  ------------------
 2689|    364|	{
 2690|    364|	  ski->is_protected = 1;
 2691|    364|	  ski->s2k.count = 0;
 2692|    364|	  if (ski->algo == 254 || ski->algo == 255)
  ------------------
  |  Branch (2692:8): [True: 0, False: 364]
  |  Branch (2692:28): [True: 209, False: 155]
  ------------------
 2693|    209|	    {
 2694|    209|              if (pktlen < 3)
  ------------------
  |  Branch (2694:19): [True: 0, False: 209]
  ------------------
 2695|      0|		{
 2696|      0|		  err = gpg_error (GPG_ERR_INV_PACKET);
 2697|      0|		  goto leave;
 2698|      0|		}
 2699|       |
 2700|    209|              ski->sha1chk = (ski->algo == 254);
 2701|    209|	      ski->algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|    209|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|    209|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 209]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 209]
  |  |  |  |  ------------------
  |  |  |  |  501|    209|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2702|    209|	      pktlen--;
 2703|       |	      /* Note that a ski->algo > 110 is illegal, but I'm not
 2704|       |	       * erroring out here as otherwise there would be no way
 2705|       |	       * to delete such a key.  */
 2706|    209|	      ski->s2k.mode = iobuf_get_noeof (inp);
  ------------------
  |  |  502|    209|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|    209|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 209]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 209]
  |  |  |  |  ------------------
  |  |  |  |  501|    209|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2707|    209|	      pktlen--;
 2708|    209|	      ski->s2k.hash_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|    209|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|    209|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 209]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 209]
  |  |  |  |  ------------------
  |  |  |  |  501|    209|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2709|    209|	      pktlen--;
 2710|       |	      /* Check for the special GNU extension.  */
 2711|    209|	      if (ski->s2k.mode == 101)
  ------------------
  |  Branch (2711:12): [True: 0, False: 209]
  ------------------
 2712|      0|		{
 2713|      0|		  for (i = 0; i < 4 && pktlen; i++, pktlen--)
  ------------------
  |  Branch (2713:17): [True: 0, False: 0]
  |  Branch (2713:26): [True: 0, False: 0]
  ------------------
 2714|      0|		    temp[i] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|      0|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|      0|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 0]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  501|      0|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2715|      0|		  if (i < 4 || memcmp (temp, "GNU", 3))
  ------------------
  |  Branch (2715:9): [True: 0, False: 0]
  |  Branch (2715:18): [True: 0, False: 0]
  ------------------
 2716|      0|		    {
 2717|      0|		      if (list_mode)
  ------------------
  |  Branch (2717:13): [True: 0, False: 0]
  ------------------
 2718|      0|			es_fprintf (listfp, "\tunknown S2K %d\n",
 2719|      0|                                    ski->s2k.mode);
 2720|      0|		      err = gpg_error (GPG_ERR_INV_PACKET);
 2721|      0|		      goto leave;
 2722|      0|		    }
 2723|       |		  /* Here we know that it is a GNU extension.  What
 2724|       |		   * follows is the GNU protection mode: All values
 2725|       |		   * have special meanings and they are mapped to MODE
 2726|       |		   * with a base of 1000.  */
 2727|      0|		  ski->s2k.mode = 1000 + temp[3];
 2728|      0|		}
 2729|       |
 2730|       |              /* Read the salt.  */
 2731|    209|	      if (ski->s2k.mode == 3 || ski->s2k.mode == 1)
  ------------------
  |  Branch (2731:12): [True: 205, False: 4]
  |  Branch (2731:34): [True: 0, False: 4]
  ------------------
 2732|    205|		{
 2733|  1.84k|		  for (i = 0; i < 8 && pktlen; i++, pktlen--)
  ------------------
  |  Branch (2733:17): [True: 1.64k, False: 205]
  |  Branch (2733:26): [True: 1.64k, False: 0]
  ------------------
 2734|  1.64k|		    temp[i] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  1.64k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  1.64k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 1.64k]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 1.64k]
  |  |  |  |  ------------------
  |  |  |  |  501|  1.64k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2735|    205|                  if (i < 8)
  ------------------
  |  Branch (2735:23): [True: 0, False: 205]
  ------------------
 2736|      0|                    {
 2737|      0|		      err = gpg_error (GPG_ERR_INV_PACKET);
 2738|      0|		      goto leave;
 2739|      0|                    }
 2740|    205|		  memcpy (ski->s2k.salt, temp, 8);
 2741|    205|		}
 2742|       |
 2743|       |              /* Check the mode.  */
 2744|    209|	      switch (ski->s2k.mode)
 2745|    209|		{
 2746|      4|		case 0:
  ------------------
  |  Branch (2746:3): [True: 4, False: 205]
  ------------------
 2747|      4|		  if (list_mode)
  ------------------
  |  Branch (2747:9): [True: 0, False: 4]
  ------------------
 2748|      0|		    es_fprintf (listfp, "\tsimple S2K");
 2749|      4|		  break;
 2750|      0|		case 1:
  ------------------
  |  Branch (2750:3): [True: 0, False: 209]
  ------------------
 2751|      0|		  if (list_mode)
  ------------------
  |  Branch (2751:9): [True: 0, False: 0]
  ------------------
 2752|      0|		    es_fprintf (listfp, "\tsalted S2K");
 2753|      0|		  break;
 2754|    205|		case 3:
  ------------------
  |  Branch (2754:3): [True: 205, False: 4]
  ------------------
 2755|    205|		  if (list_mode)
  ------------------
  |  Branch (2755:9): [True: 0, False: 205]
  ------------------
 2756|      0|		    es_fprintf (listfp, "\titer+salt S2K");
 2757|    205|		  break;
 2758|      0|		case 1001:
  ------------------
  |  Branch (2758:3): [True: 0, False: 209]
  ------------------
 2759|      0|		  if (list_mode)
  ------------------
  |  Branch (2759:9): [True: 0, False: 0]
  ------------------
 2760|      0|		    es_fprintf (listfp, "\tgnu-dummy");
 2761|      0|		  break;
 2762|      0|		case 1002:
  ------------------
  |  Branch (2762:3): [True: 0, False: 209]
  ------------------
 2763|      0|		  if (list_mode)
  ------------------
  |  Branch (2763:9): [True: 0, False: 0]
  ------------------
 2764|      0|		    es_fprintf (listfp, "\tgnu-divert-to-card");
 2765|      0|		  break;
 2766|      0|		case 1003:
  ------------------
  |  Branch (2766:3): [True: 0, False: 209]
  ------------------
 2767|      0|		  if (list_mode)
  ------------------
  |  Branch (2767:9): [True: 0, False: 0]
  ------------------
 2768|      0|		    es_fprintf (listfp, "\tgnu-mode1003");
 2769|      0|		  break;
 2770|      0|		default:
  ------------------
  |  Branch (2770:3): [True: 0, False: 209]
  ------------------
 2771|      0|		  if (list_mode)
  ------------------
  |  Branch (2771:9): [True: 0, False: 0]
  ------------------
 2772|      0|		    es_fprintf (listfp, "\tunknown %sS2K %d\n",
 2773|      0|                                ski->s2k.mode < 1000 ? "" : "GNU ",
  ------------------
  |  Branch (2773:33): [True: 0, False: 0]
  ------------------
 2774|      0|                                ski->s2k.mode);
 2775|      0|		  err = gpg_error (GPG_ERR_INV_PACKET);
 2776|      0|		  goto leave;
 2777|    209|		}
 2778|       |
 2779|       |              /* Print some info.  */
 2780|    209|	      if (list_mode && ski->s2k.mode != 1003)
  ------------------
  |  Branch (2780:12): [True: 0, False: 209]
  |  Branch (2780:25): [True: 0, False: 0]
  ------------------
 2781|      0|		{
 2782|      0|		  es_fprintf (listfp, ", algo: %d,%s hash: %d",
 2783|      0|                              ski->algo,
 2784|      0|                              ski->sha1chk ? " SHA1 protection,"
  ------------------
  |  Branch (2784:31): [True: 0, False: 0]
  ------------------
 2785|      0|                              : " simple checksum,", ski->s2k.hash_algo);
 2786|      0|		  if (ski->s2k.mode == 1 || ski->s2k.mode == 3)
  ------------------
  |  Branch (2786:9): [True: 0, False: 0]
  |  Branch (2786:31): [True: 0, False: 0]
  ------------------
 2787|      0|		    {
 2788|      0|		      es_fprintf (listfp, ", salt: ");
 2789|      0|                      es_write_hexstring (listfp, ski->s2k.salt, 8, 0, NULL);
 2790|      0|		    }
 2791|      0|                }
 2792|    209|              if (list_mode)
  ------------------
  |  Branch (2792:19): [True: 0, False: 209]
  ------------------
 2793|      0|                es_putc ('\n', listfp);
 2794|       |
 2795|       |              /* Read remaining protection parameters.  */
 2796|    209|	      if (ski->s2k.mode == 3)
  ------------------
  |  Branch (2796:12): [True: 205, False: 4]
  ------------------
 2797|    205|		{
 2798|    205|		  if (pktlen < 1)
  ------------------
  |  Branch (2798:9): [True: 0, False: 205]
  ------------------
 2799|      0|		    {
 2800|      0|		      err = gpg_error (GPG_ERR_INV_PACKET);
 2801|      0|		      goto leave;
 2802|      0|		    }
 2803|    205|		  ski->s2k.count = iobuf_get_noeof (inp);
  ------------------
  |  |  502|    205|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|    205|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 205]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 205]
  |  |  |  |  ------------------
  |  |  |  |  501|    205|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2804|    205|		  pktlen--;
 2805|    205|		  if (list_mode)
  ------------------
  |  Branch (2805:9): [True: 0, False: 205]
  ------------------
 2806|      0|		    es_fprintf (listfp, "\tprotect count: %lu (%lu)\n",
 2807|      0|                                (ulong)S2K_DECODE_COUNT ((ulong)ski->s2k.count),
  ------------------
  |  |  210|      0|#define S2K_DECODE_COUNT(_val) ((16ul + ((_val) & 15)) << (((_val) >> 4) + 6))
  ------------------
 2808|      0|                                (ulong) ski->s2k.count);
 2809|    205|		}
 2810|      4|	      else if (ski->s2k.mode == 1002)
  ------------------
  |  Branch (2810:17): [True: 0, False: 4]
  ------------------
 2811|      0|		{
 2812|       |		  /* Read the serial number. */
 2813|      0|		  if (pktlen < 1)
  ------------------
  |  Branch (2813:9): [True: 0, False: 0]
  ------------------
 2814|      0|		    {
 2815|      0|		      err = gpg_error (GPG_ERR_INV_PACKET);
 2816|      0|		      goto leave;
 2817|      0|		    }
 2818|      0|		  snlen = iobuf_get (inp);
  ------------------
  |  |  500|      0|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 0]
  |  |  |  Branch (500:24): [True: 0, False: 0]
  |  |  ------------------
  |  |  501|      0|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
 2819|      0|		  pktlen--;
 2820|      0|		  if (pktlen < snlen || snlen == (size_t)(-1))
  ------------------
  |  Branch (2820:9): [True: 0, False: 0]
  |  Branch (2820:27): [True: 0, False: 0]
  ------------------
 2821|      0|		    {
 2822|      0|		      err = gpg_error (GPG_ERR_INV_PACKET);
 2823|      0|		      goto leave;
 2824|      0|		    }
 2825|      0|		}
 2826|    209|	    }
 2827|    155|	  else /* Old version; no S2K, so we set mode to 0, hash MD5.  */
 2828|    155|	    {
 2829|       |              /* Note that a ski->algo > 110 is illegal, but I'm not
 2830|       |                 erroring on it here as otherwise there would be no
 2831|       |                 way to delete such a key.  */
 2832|    155|	      ski->s2k.mode = 0;
 2833|    155|	      ski->s2k.hash_algo = DIGEST_ALGO_MD5;
 2834|    155|	      if (list_mode)
  ------------------
  |  Branch (2834:12): [True: 0, False: 155]
  ------------------
 2835|      0|		es_fprintf (listfp, "\tprotect algo: %d  (hash algo: %d)\n",
 2836|      0|                            ski->algo, ski->s2k.hash_algo);
 2837|    155|	    }
 2838|       |
 2839|       |	  /* It is really ugly that we don't know the size
 2840|       |	   * of the IV here in cases we are not aware of the algorithm.
 2841|       |	   * so a
 2842|       |	   *   ski->ivlen = cipher_get_blocksize (ski->algo);
 2843|       |	   * won't work.  The only solution I see is to hardwire it.
 2844|       |	   * NOTE: if you change the ivlen above 16, don't forget to
 2845|       |	   * enlarge temp.
 2846|       |           * FIXME: For v5 keys we can deduce this info!
 2847|       |           */
 2848|    364|	  ski->ivlen = openpgp_cipher_blocklen (ski->algo);
 2849|    364|	  log_assert (ski->ivlen <= sizeof (temp));
 2850|       |
 2851|    364|	  if (ski->s2k.mode == 1001 || ski->s2k.mode == 1003)
  ------------------
  |  Branch (2851:8): [True: 0, False: 364]
  |  Branch (2851:33): [True: 0, False: 364]
  ------------------
 2852|      0|	    ski->ivlen = 0;
 2853|    364|	  else if (ski->s2k.mode == 1002)
  ------------------
  |  Branch (2853:13): [True: 0, False: 364]
  ------------------
 2854|      0|	    ski->ivlen = snlen < 16 ? snlen : 16;
  ------------------
  |  Branch (2854:19): [True: 0, False: 0]
  ------------------
 2855|       |
 2856|    364|	  if (pktlen < ski->ivlen)
  ------------------
  |  Branch (2856:8): [True: 0, False: 364]
  ------------------
 2857|      0|	    {
 2858|      0|              err = gpg_error (GPG_ERR_INV_PACKET);
 2859|      0|	      goto leave;
 2860|      0|	    }
 2861|  3.27k|	  for (i = 0; i < ski->ivlen; i++, pktlen--)
  ------------------
  |  Branch (2861:16): [True: 2.91k, False: 364]
  ------------------
 2862|  2.91k|	    temp[i] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  3.27k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  2.91k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 2.91k]
  |  |  |  |  |  Branch (500:24): [True: 7, False: 2.90k]
  |  |  |  |  ------------------
  |  |  |  |  501|  2.91k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2863|    364|	  if (list_mode && ski->s2k.mode != 1003)
  ------------------
  |  Branch (2863:8): [True: 0, False: 364]
  |  Branch (2863:21): [True: 0, False: 0]
  ------------------
 2864|      0|	    {
 2865|      0|	      es_fprintf (listfp,
 2866|      0|                          ski->s2k.mode == 1002 ? "\tserial-number: "
  ------------------
  |  Branch (2866:27): [True: 0, False: 0]
  ------------------
 2867|      0|                          : "\tprotect IV: ");
 2868|      0|	      for (i = 0; i < ski->ivlen; i++)
  ------------------
  |  Branch (2868:20): [True: 0, False: 0]
  ------------------
 2869|      0|		es_fprintf (listfp, " %02x", temp[i]);
 2870|      0|	      es_putc ('\n', listfp);
 2871|      0|	    }
 2872|    364|	  memcpy (ski->iv, temp, ski->ivlen);
 2873|    364|	}
 2874|       |
 2875|       |      /* Skip count of secret key material.  */
 2876|    422|      if (is_v5)
  ------------------
  |  Branch (2876:11): [True: 1, False: 421]
  ------------------
 2877|      1|        {
 2878|      1|          if (pktlen < 4)
  ------------------
  |  Branch (2878:15): [True: 0, False: 1]
  ------------------
 2879|      0|            {
 2880|      0|              err = gpg_error (GPG_ERR_INV_PACKET);
 2881|      0|              goto leave;
 2882|      0|            }
 2883|      1|          skbytes = read_32 (inp);
 2884|      1|          pktlen -= 4;
 2885|      1|          if (list_mode)
  ------------------
  |  Branch (2885:15): [True: 0, False: 1]
  ------------------
 2886|      0|            es_fprintf (listfp, "\tskbytes: %u\n", skbytes);
 2887|      1|        }
 2888|       |
 2889|       |      /* It does not make sense to read it into secure memory.
 2890|       |       * If the user is so careless, not to protect his secret key,
 2891|       |       * we can assume, that he operates an open system :=(.
 2892|       |       * So we put the key into secure memory when we unprotect it. */
 2893|    422|      if (ski->s2k.mode == 1001 || ski->s2k.mode == 1002)
  ------------------
  |  Branch (2893:11): [True: 0, False: 422]
  |  Branch (2893:36): [True: 0, False: 422]
  ------------------
 2894|      0|	{
 2895|       |	  /* Better set some dummy stuff here.  */
 2896|      0|	  pk->pkey[npkey] = gcry_mpi_set_opaque (NULL,
 2897|      0|						 xstrdup ("dummydata"),
  ------------------
  |  |  112|      0|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
 2898|      0|						 10 * 8);
 2899|      0|	  pktlen = 0;
 2900|      0|	}
 2901|    422|      else if (ski->s2k.mode == 1003)
  ------------------
  |  Branch (2901:16): [True: 0, False: 422]
  ------------------
 2902|      0|	{
 2903|      0|          void *tmpp;
 2904|       |
 2905|      0|	  if (pktlen < 2) /* At least two bytes for parenthesis.  */
  ------------------
  |  Branch (2905:8): [True: 0, False: 0]
  ------------------
 2906|      0|	    {
 2907|      0|              err = gpg_error (GPG_ERR_INV_PACKET);
 2908|      0|	      goto leave;
 2909|      0|	    }
 2910|       |
 2911|      0|          tmpp = read_rest (inp, pktlen);
 2912|      0|          if (list_mode)
  ------------------
  |  Branch (2912:15): [True: 0, False: 0]
  ------------------
 2913|      0|            {
 2914|      0|              if (mpi_print_mode)
  ------------------
  |  Branch (2914:19): [True: 0, False: 0]
  ------------------
 2915|      0|                {
 2916|      0|                  char *tmpsxp = canon_sexp_to_string (tmpp, pktlen);
 2917|      0|                  es_fprintf (listfp, "\tskey[%d]: %s\n", npkey,
 2918|      0|                              tmpsxp? trim_trailing_spaces (tmpsxp)
  ------------------
  |  Branch (2918:31): [True: 0, False: 0]
  ------------------
 2919|      0|                              /*  */: "[invalid S-expression]");
 2920|      0|                  xfree (tmpsxp);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 2921|      0|                }
 2922|      0|              else
 2923|      0|                es_fprintf (listfp, "\tskey[%d]: [s-expression %lu octets]\n",
 2924|      0|                            npkey, pktlen);
 2925|      0|            }
 2926|      0|	  pk->pkey[npkey] = gcry_mpi_set_opaque (NULL,
 2927|      0|						 tmpp, tmpp? pktlen * 8 : 0);
  ------------------
  |  Branch (2927:14): [True: 0, False: 0]
  ------------------
 2928|      0|          pktlen = 0;
 2929|      0|	}
 2930|    422|      else if (ski->is_protected)
  ------------------
  |  Branch (2930:16): [True: 364, False: 58]
  ------------------
 2931|    364|	{
 2932|    364|          void *tmpp;
 2933|       |
 2934|    364|	  if (pktlen < 2) /* At least two bytes for the length.  */
  ------------------
  |  Branch (2934:8): [True: 0, False: 364]
  ------------------
 2935|      0|	    {
 2936|      0|              err = gpg_error (GPG_ERR_INV_PACKET);
 2937|      0|	      goto leave;
 2938|      0|	    }
 2939|       |
 2940|       |	  /* Ugly: The length is encrypted too, so we read all stuff
 2941|       |	   * up to the end of the packet into the first SKEY
 2942|       |	   * element.
 2943|       |           * FIXME: We can do better for v5 keys.  */
 2944|       |
 2945|    364|          tmpp = read_rest (inp, pktlen);
 2946|    364|	  pk->pkey[npkey] = gcry_mpi_set_opaque (NULL,
 2947|    364|						 tmpp, tmpp? pktlen * 8 : 0);
  ------------------
  |  Branch (2947:14): [True: 363, False: 1]
  ------------------
 2948|       |          /* Mark that MPI as protected - we need this information for
 2949|       |           * importing a key.  The OPAQUE flag can't be used because
 2950|       |           * we also store public EdDSA values in opaque MPIs.  */
 2951|    364|          if (pk->pkey[npkey])
  ------------------
  |  Branch (2951:15): [True: 364, False: 0]
  ------------------
 2952|    364|            gcry_mpi_set_flag (pk->pkey[npkey], GCRYMPI_FLAG_USER1);
 2953|    364|	  pktlen = 0;
 2954|    364|	  if (list_mode)
  ------------------
  |  Branch (2954:8): [True: 0, False: 364]
  ------------------
 2955|      0|            es_fprintf (listfp, "\tskey[%d]: [v4 protected]\n", npkey);
 2956|    364|	}
 2957|     58|      else
 2958|     58|	{
 2959|       |          /* Not encrypted.  */
 2960|    116|	  for (i = npkey; i < nskey; i++)
  ------------------
  |  Branch (2960:20): [True: 58, False: 58]
  ------------------
 2961|     58|	    {
 2962|     58|              unsigned int n;
 2963|       |
 2964|     58|              if (pktlen < 2) /* At least two bytes for the length.  */
  ------------------
  |  Branch (2964:19): [True: 0, False: 58]
  ------------------
 2965|      0|                {
 2966|      0|                  err = gpg_error (GPG_ERR_INV_PACKET);
 2967|      0|                  goto leave;
 2968|      0|                }
 2969|     58|              n = pktlen;
 2970|     58|              if (algorithm == PUBKEY_ALGO_ECDSA
  ------------------
  |  Branch (2970:19): [True: 32, False: 26]
  ------------------
 2971|     58|                  || algorithm == PUBKEY_ALGO_EDDSA
  ------------------
  |  Branch (2971:22): [True: 17, False: 9]
  ------------------
 2972|     58|                  || algorithm == PUBKEY_ALGO_ECDH)
  ------------------
  |  Branch (2972:22): [True: 9, False: 0]
  ------------------
 2973|     58|                pk->pkey[i] = sos_read (inp, &n, 0);
 2974|      0|              else
 2975|      0|                pk->pkey[i] = mpi_read (inp, &n, 0);
 2976|     58|              pktlen -= n;
 2977|     58|              if (list_mode)
  ------------------
  |  Branch (2977:19): [True: 0, False: 58]
  ------------------
 2978|      0|                {
 2979|      0|                  es_fprintf (listfp, "\tskey[%d]: ", i);
 2980|      0|                  mpi_print (listfp, pk->pkey[i], mpi_print_mode);
 2981|      0|                  es_putc ('\n', listfp);
 2982|      0|                }
 2983|       |
 2984|     58|	      if (!pk->pkey[i])
  ------------------
  |  Branch (2984:12): [True: 1, False: 57]
  ------------------
 2985|      1|		err = gpg_error (GPG_ERR_INV_PACKET);
 2986|     58|	    }
 2987|     58|	  if (err)
  ------------------
  |  Branch (2987:8): [True: 1, False: 57]
  ------------------
 2988|      1|	    goto leave;
 2989|       |
 2990|     57|	  if (pktlen < 2)
  ------------------
  |  Branch (2990:8): [True: 0, False: 57]
  ------------------
 2991|      0|	    {
 2992|      0|              err = gpg_error (GPG_ERR_INV_PACKET);
 2993|      0|	      goto leave;
 2994|      0|	    }
 2995|     57|	  ski->csum = read_16 (inp);
 2996|     57|	  pktlen -= 2;
 2997|     57|	  if (list_mode)
  ------------------
  |  Branch (2997:8): [True: 0, False: 57]
  ------------------
 2998|      0|            es_fprintf (listfp, "\tchecksum: %04hx\n", ski->csum);
 2999|     57|	}
 3000|    422|    }
 3001|       |
 3002|       |  /* Note that KEYID below has been initialized above in list_mode.  */
 3003|    471|  if (list_mode)
  ------------------
  |  Branch (3003:7): [True: 0, False: 471]
  ------------------
 3004|      0|    es_fprintf (listfp, "\tkeyid: %08lX%08lX\n",
 3005|      0|                (ulong) keyid[0], (ulong) keyid[1]);
 3006|       |
 3007|  1.46k| leave:
 3008|  1.46k|  iobuf_skip_rest (inp, pktlen, 0);
 3009|  1.46k|  return err;
 3010|    471|}
parse-packet.c:read_size_body:
 1117|     92|{
 1118|     92|  char buffer[256];
 1119|     92|  char *tmpbuf;
 1120|     92|  int i, c, nbytes;
 1121|       |
 1122|     92|  *r_nread = 0;
 1123|     92|  *r_data = NULL;
 1124|       |
 1125|     92|  if (!pktlen)
  ------------------
  |  Branch (1125:7): [True: 0, False: 92]
  ------------------
 1126|      0|    return gpg_error (GPG_ERR_INV_PACKET);
 1127|     92|  c = iobuf_readbyte (inp);
 1128|     92|  if (c < 0)
  ------------------
  |  Branch (1128:7): [True: 0, False: 92]
  ------------------
 1129|      0|    return gpg_error (GPG_ERR_INV_PACKET);
 1130|     92|  pktlen--;
 1131|     92|  ++*r_nread;
 1132|     92|  nbytes = c;
 1133|     92|  if (nbytes < 2 || nbytes > 254)
  ------------------
  |  Branch (1133:7): [True: 0, False: 92]
  |  Branch (1133:21): [True: 0, False: 92]
  ------------------
 1134|      0|    return gpg_error (GPG_ERR_INV_PACKET);
 1135|     92|  if (nbytes > pktlen)
  ------------------
  |  Branch (1135:7): [True: 0, False: 92]
  ------------------
 1136|      0|    return gpg_error (GPG_ERR_INV_PACKET);
 1137|       |
 1138|     92|  buffer[0] = nbytes;
 1139|       |
 1140|    800|  for (i = 0; i < nbytes; i++)
  ------------------
  |  Branch (1140:15): [True: 708, False: 92]
  ------------------
 1141|    708|    {
 1142|    708|      c = iobuf_get (inp);
  ------------------
  |  |  500|    708|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 708]
  |  |  |  Branch (500:24): [True: 0, False: 708]
  |  |  ------------------
  |  |  501|    708|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
 1143|    708|      if (c < 0)
  ------------------
  |  Branch (1143:11): [True: 0, False: 708]
  ------------------
 1144|      0|        return gpg_error (GPG_ERR_INV_PACKET);
 1145|    708|      ++*r_nread;
 1146|    708|      buffer[1+i] = c;
 1147|    708|    }
 1148|       |
 1149|     92|  tmpbuf = xtrymalloc (1 + nbytes);
  ------------------
  |  |   97|     92|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
 1150|     92|  if (!tmpbuf)
  ------------------
  |  Branch (1150:7): [True: 0, False: 92]
  ------------------
 1151|      0|    return gpg_error_from_syserror ();
 1152|     92|  memcpy (tmpbuf, buffer, 1 + nbytes);
 1153|     92|  *r_data = gcry_mpi_set_opaque (NULL, tmpbuf, 8 * (1 + nbytes));
 1154|     92|  if (!*r_data)
  ------------------
  |  Branch (1154:7): [True: 0, False: 92]
  ------------------
 1155|      0|    {
 1156|      0|      xfree (tmpbuf);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1157|      0|      return gpg_error_from_syserror ();
 1158|      0|    }
 1159|     92|  return 0;
 1160|     92|}
parse-packet.c:parse_symkeyenc:
 1207|    834|{
 1208|    834|  PKT_symkey_enc *k;
 1209|    834|  int rc = 0;
 1210|    834|  int i, version, s2kmode, cipher_algo, aead_algo, hash_algo, seskeylen, minlen;
 1211|       |
 1212|    834|  if (pktlen < 4)
  ------------------
  |  Branch (1212:7): [True: 0, False: 834]
  ------------------
 1213|      0|    goto too_short;
 1214|    834|  version = iobuf_get_noeof (inp);
  ------------------
  |  |  502|    834|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|    834|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 834]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 834]
  |  |  |  |  ------------------
  |  |  |  |  501|    834|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 1215|    834|  pktlen--;
 1216|    834|  if (version == 4)
  ------------------
  |  Branch (1216:7): [True: 802, False: 32]
  ------------------
 1217|    802|    ;
 1218|     32|  else if (version == 5)
  ------------------
  |  Branch (1218:12): [True: 32, False: 0]
  ------------------
 1219|     32|    ;
 1220|      0|  else
 1221|      0|    {
 1222|      0|      log_error ("packet(%d) with unknown version %d\n", pkttype, version);
 1223|      0|      if (list_mode)
  ------------------
  |  Branch (1223:11): [True: 0, False: 0]
  ------------------
 1224|      0|        es_fprintf (listfp, ":symkey enc packet: [unknown version]\n");
 1225|      0|      rc = gpg_error (GPG_ERR_INV_PACKET);
 1226|      0|      goto leave;
 1227|      0|    }
 1228|    834|  if (pktlen > 200)
  ------------------
  |  Branch (1228:7): [True: 0, False: 834]
  ------------------
 1229|      0|    {				/* (we encode the seskeylen in a byte) */
 1230|      0|      log_error ("packet(%d) too large\n", pkttype);
 1231|      0|      if (list_mode)
  ------------------
  |  Branch (1231:11): [True: 0, False: 0]
  ------------------
 1232|      0|        es_fprintf (listfp, ":symkey enc packet: [too large]\n");
 1233|      0|      rc = gpg_error (GPG_ERR_INV_PACKET);
 1234|      0|      goto leave;
 1235|      0|    }
 1236|    834|  cipher_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|    834|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|    834|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 834]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 834]
  |  |  |  |  ------------------
  |  |  |  |  501|    834|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 1237|    834|  pktlen--;
 1238|    834|  if (version == 5)
  ------------------
  |  Branch (1238:7): [True: 32, False: 802]
  ------------------
 1239|     32|    {
 1240|     32|      aead_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|     32|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|     32|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 32]
  |  |  |  |  |  Branch (500:24): [True: 32, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  501|     32|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 1241|     32|      pktlen--;
 1242|     32|    }
 1243|    802|  else
 1244|    802|    aead_algo = 0;
 1245|    834|  if (pktlen < 2)
  ------------------
  |  Branch (1245:7): [True: 0, False: 834]
  ------------------
 1246|      0|    goto too_short;
 1247|    834|  s2kmode = iobuf_get_noeof (inp);
  ------------------
  |  |  502|    834|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|    834|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 834]
  |  |  |  |  |  Branch (500:24): [True: 4, False: 830]
  |  |  |  |  ------------------
  |  |  |  |  501|    834|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 1248|    834|  pktlen--;
 1249|    834|  hash_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|    834|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|    834|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 834]
  |  |  |  |  |  Branch (500:24): [True: 1, False: 833]
  |  |  |  |  ------------------
  |  |  |  |  501|    834|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 1250|    834|  pktlen--;
 1251|    834|  switch (s2kmode)
 1252|    834|    {
 1253|      0|    case 0: /* Simple S2K.  */
  ------------------
  |  Branch (1253:5): [True: 0, False: 834]
  ------------------
 1254|      0|      minlen = 0;
 1255|      0|      break;
 1256|      0|    case 1: /* Salted S2K.  */
  ------------------
  |  Branch (1256:5): [True: 0, False: 834]
  ------------------
 1257|      0|      minlen = 8;
 1258|      0|      break;
 1259|    674|    case 3: /* Iterated+salted S2K.  */
  ------------------
  |  Branch (1259:5): [True: 674, False: 160]
  ------------------
 1260|    674|      minlen = 9;
 1261|    674|      break;
 1262|    160|    default:
  ------------------
  |  Branch (1262:5): [True: 160, False: 674]
  ------------------
 1263|    160|      log_error ("unknown S2K mode %d\n", s2kmode);
 1264|    160|      if (list_mode)
  ------------------
  |  Branch (1264:11): [True: 0, False: 160]
  ------------------
 1265|      0|        es_fprintf (listfp, ":symkey enc packet: [unknown S2K mode]\n");
 1266|    160|      goto leave;
 1267|    834|    }
 1268|    674|  if (minlen > pktlen)
  ------------------
  |  Branch (1268:7): [True: 0, False: 674]
  ------------------
 1269|      0|    {
 1270|      0|      log_error ("packet with S2K %d too short\n", s2kmode);
 1271|      0|      if (list_mode)
  ------------------
  |  Branch (1271:11): [True: 0, False: 0]
  ------------------
 1272|      0|        es_fprintf (listfp, ":symkey enc packet: [too short]\n");
 1273|      0|      rc = gpg_error (GPG_ERR_INV_PACKET);
 1274|      0|      goto leave;
 1275|      0|    }
 1276|    674|  seskeylen = pktlen - minlen;
 1277|    674|  k = packet->pkt.symkey_enc = xmalloc_clear (sizeof *packet->pkt.symkey_enc
  ------------------
  |  |  116|    674|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
 1278|    674|					      + seskeylen - 1);
 1279|    674|  k->version = version;
 1280|    674|  k->cipher_algo = cipher_algo;
 1281|    674|  k->aead_algo = aead_algo;
 1282|    674|  k->s2k.mode = s2kmode;
 1283|    674|  k->s2k.hash_algo = hash_algo;
 1284|    674|  if (s2kmode == 1 || s2kmode == 3)
  ------------------
  |  Branch (1284:7): [True: 0, False: 674]
  |  Branch (1284:23): [True: 674, False: 0]
  ------------------
 1285|    674|    {
 1286|  6.06k|      for (i = 0; i < 8 && pktlen; i++, pktlen--)
  ------------------
  |  Branch (1286:19): [True: 5.39k, False: 674]
  |  Branch (1286:28): [True: 5.39k, False: 0]
  ------------------
 1287|  5.39k|	k->s2k.salt[i] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  5.39k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  5.39k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 5.39k]
  |  |  |  |  |  Branch (500:24): [True: 8, False: 5.38k]
  |  |  |  |  ------------------
  |  |  |  |  501|  5.39k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 1288|    674|    }
 1289|    674|  if (s2kmode == 3)
  ------------------
  |  Branch (1289:7): [True: 674, False: 0]
  ------------------
 1290|    674|    {
 1291|    674|      k->s2k.count = iobuf_get_noeof (inp);
  ------------------
  |  |  502|    674|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|    674|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 674]
  |  |  |  |  |  Branch (500:24): [True: 1, False: 673]
  |  |  |  |  ------------------
  |  |  |  |  501|    674|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 1292|    674|      pktlen--;
 1293|    674|    }
 1294|    674|  k->seskeylen = seskeylen;
 1295|    674|  if (k->seskeylen)
  ------------------
  |  Branch (1295:7): [True: 273, False: 401]
  ------------------
 1296|    273|    {
 1297|  7.91k|      for (i = 0; i < seskeylen && pktlen; i++, pktlen--)
  ------------------
  |  Branch (1297:19): [True: 7.64k, False: 273]
  |  Branch (1297:36): [True: 7.64k, False: 0]
  ------------------
 1298|  7.64k|	k->seskey[i] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  7.64k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  7.64k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 7.64k]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 7.64k]
  |  |  |  |  ------------------
  |  |  |  |  501|  7.64k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 1299|       |
 1300|       |      /* What we're watching out for here is a session key decryptor
 1301|       |         with no salt.  The RFC says that using salt for this is a
 1302|       |         MUST. */
 1303|    273|      if (s2kmode != 1 && s2kmode != 3)
  ------------------
  |  Branch (1303:11): [True: 273, False: 0]
  |  Branch (1303:27): [True: 0, False: 273]
  ------------------
 1304|      0|	log_info (_("WARNING: potentially insecure symmetrically"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1305|      0|		    " encrypted session key\n"));
 1306|    273|    }
 1307|    674|  log_assert (!pktlen);
 1308|       |
 1309|    674|  if (list_mode)
  ------------------
  |  Branch (1309:7): [True: 0, False: 674]
  ------------------
 1310|      0|    {
 1311|      0|      es_fprintf (listfp,
 1312|      0|                  ":symkey enc packet: version %d, cipher %d, aead %d,"
 1313|      0|                  " s2k %d, hash %d",
 1314|      0|                  version, cipher_algo, aead_algo, s2kmode, hash_algo);
 1315|      0|      if (seskeylen)
  ------------------
  |  Branch (1315:11): [True: 0, False: 0]
  ------------------
 1316|      0|        {
 1317|       |          /* To compute the size of the session key we need to know
 1318|       |           * the size of the AEAD nonce which we may not know.  Thus
 1319|       |           * we show only the size of the entire encrypted session
 1320|       |           * key.  */
 1321|      0|          if (aead_algo)
  ------------------
  |  Branch (1321:15): [True: 0, False: 0]
  ------------------
 1322|      0|            es_fprintf (listfp, ", encrypted seskey %d bytes", seskeylen);
 1323|      0|          else
 1324|      0|            es_fprintf (listfp, ", seskey %d bits", (seskeylen - 1) * 8);
 1325|      0|        }
 1326|      0|      es_fprintf (listfp, "\n");
 1327|      0|      if (s2kmode == 1 || s2kmode == 3)
  ------------------
  |  Branch (1327:11): [True: 0, False: 0]
  |  Branch (1327:27): [True: 0, False: 0]
  ------------------
 1328|      0|	{
 1329|      0|	  es_fprintf (listfp, "\tsalt ");
 1330|      0|          es_write_hexstring (listfp, k->s2k.salt, 8, 0, NULL);
 1331|      0|	  if (s2kmode == 3)
  ------------------
  |  Branch (1331:8): [True: 0, False: 0]
  ------------------
 1332|      0|	    es_fprintf (listfp, ", count %lu (%lu)",
 1333|      0|                        S2K_DECODE_COUNT ((ulong) k->s2k.count),
  ------------------
  |  |  210|      0|#define S2K_DECODE_COUNT(_val) ((16ul + ((_val) & 15)) << (((_val) >> 4) + 6))
  ------------------
 1334|      0|                        (ulong) k->s2k.count);
 1335|      0|	  es_fprintf (listfp, "\n");
 1336|      0|	}
 1337|      0|    }
 1338|       |
 1339|    834| leave:
 1340|    834|  iobuf_skip_rest (inp, pktlen, 0);
 1341|    834|  return rc;
 1342|       |
 1343|      0| too_short:
 1344|      0|  log_error ("packet(%d) too short\n", pkttype);
 1345|      0|  if (list_mode)
  ------------------
  |  Branch (1345:7): [True: 0, False: 0]
  ------------------
 1346|      0|    es_fprintf (listfp, ":symkey enc packet: [too short]\n");
 1347|      0|  rc = gpg_error (GPG_ERR_INV_PACKET);
 1348|      0|  goto leave;
 1349|    674|}
parse-packet.c:parse_onepass_sig:
 2409|     32|{
 2410|     32|  int version;
 2411|     32|  int rc = 0;
 2412|       |
 2413|     32|  if (pktlen < 13)
  ------------------
  |  Branch (2413:7): [True: 0, False: 32]
  ------------------
 2414|      0|    {
 2415|      0|      log_error ("packet(%d) too short\n", pkttype);
 2416|      0|      if (list_mode)
  ------------------
  |  Branch (2416:11): [True: 0, False: 0]
  ------------------
 2417|      0|        es_fputs (":onepass_sig packet: [too short]\n", listfp);
 2418|      0|      rc = gpg_error (GPG_ERR_INV_PACKET);
 2419|      0|      goto leave;
 2420|      0|    }
 2421|     32|  version = iobuf_get_noeof (inp);
  ------------------
  |  |  502|     32|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|     32|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 32]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  501|     32|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2422|     32|  pktlen--;
 2423|     32|  if (version != 3)
  ------------------
  |  Branch (2423:7): [True: 0, False: 32]
  ------------------
 2424|      0|    {
 2425|      0|      log_error ("onepass_sig with unknown version %d\n", version);
 2426|      0|      if (list_mode)
  ------------------
  |  Branch (2426:11): [True: 0, False: 0]
  ------------------
 2427|      0|        es_fputs (":onepass_sig packet: [unknown version]\n", listfp);
 2428|      0|      rc = gpg_error (GPG_ERR_INV_PACKET);
 2429|      0|      goto leave;
 2430|      0|    }
 2431|     32|  ops->sig_class = iobuf_get_noeof (inp);
  ------------------
  |  |  502|     32|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|     32|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 32]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  501|     32|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2432|     32|  pktlen--;
 2433|     32|  ops->digest_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|     32|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|     32|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 32]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  501|     32|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2434|     32|  pktlen--;
 2435|     32|  ops->pubkey_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|     32|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|     32|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 32]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  501|     32|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2436|     32|  pktlen--;
 2437|     32|  ops->keyid[0] = read_32 (inp);
 2438|     32|  pktlen -= 4;
 2439|     32|  ops->keyid[1] = read_32 (inp);
 2440|     32|  pktlen -= 4;
 2441|     32|  ops->last = iobuf_get_noeof (inp);
  ------------------
  |  |  502|     32|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|     32|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 32]
  |  |  |  |  |  Branch (500:24): [True: 22, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  501|     32|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 2442|     32|  pktlen--;
 2443|     32|  if (list_mode)
  ------------------
  |  Branch (2443:7): [True: 0, False: 32]
  ------------------
 2444|      0|    es_fprintf (listfp,
 2445|      0|                ":onepass_sig packet: keyid %08lX%08lX\n"
 2446|      0|                "\tversion %d, sigclass 0x%02x, digest %d, pubkey %d, "
 2447|      0|                "last=%d\n",
 2448|      0|                (ulong) ops->keyid[0], (ulong) ops->keyid[1],
 2449|      0|                version, ops->sig_class,
 2450|      0|                ops->digest_algo, ops->pubkey_algo, ops->last);
 2451|       |
 2452|       |
 2453|     32| leave:
 2454|     32|  iobuf_skip_rest (inp, pktlen, 0);
 2455|     32|  return rc;
 2456|     32|}
parse-packet.c:parse_user_id:
 3091|  1.58k|{
 3092|  1.58k|  byte *p;
 3093|       |
 3094|       |  /* Cap the size of a user ID at 2k: a value absurdly large enough
 3095|       |     that there is no sane user ID string (which is printable text
 3096|       |     as of RFC2440bis) that won't fit in it, but yet small enough to
 3097|       |     avoid allocation problems.  A large pktlen may not be
 3098|       |     allocatable, and a very large pktlen could actually cause our
 3099|       |     allocation to wrap around in xmalloc to a small number. */
 3100|       |
 3101|  1.58k|  if (pktlen > MAX_UID_PACKET_LENGTH)
  ------------------
  |  |   38|  1.58k|#define MAX_UID_PACKET_LENGTH     (  2 * 1024)
  ------------------
  |  Branch (3101:7): [True: 0, False: 1.58k]
  ------------------
 3102|      0|    {
 3103|      0|      log_error ("packet(%d) too large\n", pkttype);
 3104|      0|      if (list_mode)
  ------------------
  |  Branch (3104:11): [True: 0, False: 0]
  ------------------
 3105|      0|        es_fprintf (listfp, ":user ID packet: [too large]\n");
 3106|      0|      iobuf_skip_rest (inp, pktlen, 0);
 3107|      0|      return GPG_ERR_INV_PACKET;
 3108|      0|    }
 3109|       |
 3110|  1.58k|  packet->pkt.user_id = xmalloc_clear (sizeof *packet->pkt.user_id + pktlen);
  ------------------
  |  |  116|  1.58k|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
 3111|  1.58k|  packet->pkt.user_id->len = pktlen;
 3112|  1.58k|  packet->pkt.user_id->ref = 1;
 3113|       |
 3114|  1.58k|  p = packet->pkt.user_id->name;
 3115|  3.72k|  for (; pktlen; pktlen--, p++)
  ------------------
  |  Branch (3115:10): [True: 2.14k, False: 1.58k]
  ------------------
 3116|  2.14k|    *p = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  3.72k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  2.14k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 2.14k]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 2.14k]
  |  |  |  |  ------------------
  |  |  |  |  501|  2.14k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3117|  1.58k|  *p = 0;
 3118|       |
 3119|  1.58k|  if (list_mode)
  ------------------
  |  Branch (3119:7): [True: 0, False: 1.58k]
  ------------------
 3120|      0|    {
 3121|      0|      int n = packet->pkt.user_id->len;
 3122|      0|      es_fprintf (listfp, ":user ID packet: \"");
 3123|       |      /* fixme: Hey why don't we replace this with es_write_sanitized?? */
 3124|      0|      for (p = packet->pkt.user_id->name; n; p++, n--)
  ------------------
  |  Branch (3124:43): [True: 0, False: 0]
  ------------------
 3125|      0|	{
 3126|      0|	  if (*p >= ' ' && *p <= 'z')
  ------------------
  |  Branch (3126:8): [True: 0, False: 0]
  |  Branch (3126:21): [True: 0, False: 0]
  ------------------
 3127|      0|	    es_putc (*p, listfp);
 3128|      0|	  else
 3129|      0|	    es_fprintf (listfp, "\\x%02x", *p);
 3130|      0|	}
 3131|      0|      es_fprintf (listfp, "\"\n");
 3132|      0|    }
 3133|  1.58k|  return 0;
 3134|  1.58k|}
parse-packet.c:parse_attribute:
 3174|     57|{
 3175|     57|  byte *p;
 3176|       |
 3177|     57|  (void) pkttype;
 3178|       |
 3179|       |  /* We better cap the size of an attribute packet to make DoS not too
 3180|       |     easy.  16MB should be more then enough for one attribute packet
 3181|       |     (ie. a photo).  */
 3182|     57|  if (pktlen > MAX_ATTR_PACKET_LENGTH)
  ------------------
  |  |   40|     57|#define MAX_ATTR_PACKET_LENGTH    ( 16 * 1024*1024)
  ------------------
  |  Branch (3182:7): [True: 0, False: 57]
  ------------------
 3183|      0|    {
 3184|      0|      log_error ("packet(%d) too large\n", pkttype);
 3185|      0|      if (list_mode)
  ------------------
  |  Branch (3185:11): [True: 0, False: 0]
  ------------------
 3186|      0|        es_fprintf (listfp, ":attribute packet: [too large]\n");
 3187|      0|      iobuf_skip_rest (inp, pktlen, 0);
 3188|      0|      return GPG_ERR_INV_PACKET;
 3189|      0|    }
 3190|       |
 3191|     57|#define EXTRA_UID_NAME_SPACE 71
 3192|     57|  packet->pkt.user_id = xmalloc_clear (sizeof *packet->pkt.user_id
  ------------------
  |  |  116|     57|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
 3193|     57|				       + EXTRA_UID_NAME_SPACE);
 3194|     57|  packet->pkt.user_id->ref = 1;
 3195|     57|  packet->pkt.user_id->attrib_data = xmalloc (pktlen? pktlen:1);
  ------------------
  |  |  107|    114|#define xmalloc(a)       gcry_xmalloc ((a))
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 56, False: 1]
  |  |  ------------------
  ------------------
 3196|     57|  packet->pkt.user_id->attrib_len = pktlen;
 3197|       |
 3198|     57|  p = packet->pkt.user_id->attrib_data;
 3199|    757|  for (; pktlen; pktlen--, p++)
  ------------------
  |  Branch (3199:10): [True: 700, False: 57]
  ------------------
 3200|    700|    *p = iobuf_get_noeof (inp);
  ------------------
  |  |  502|    757|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|    700|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 700]
  |  |  |  |  |  Branch (500:24): [True: 2, False: 698]
  |  |  |  |  ------------------
  |  |  |  |  501|    700|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3201|       |
 3202|       |  /* Now parse out the individual attribute subpackets.  This is
 3203|       |     somewhat pointless since there is only one currently defined
 3204|       |     attribute type (jpeg), but it is correct by the spec. */
 3205|     57|  parse_attribute_subpkts (packet->pkt.user_id);
 3206|       |
 3207|     57|  make_attribute_uidname (packet->pkt.user_id, EXTRA_UID_NAME_SPACE);
  ------------------
  |  | 3191|     57|#define EXTRA_UID_NAME_SPACE 71
  ------------------
 3208|       |
 3209|     57|  if (list_mode)
  ------------------
  |  Branch (3209:7): [True: 0, False: 57]
  ------------------
 3210|      0|    {
 3211|      0|      es_fprintf (listfp, ":attribute packet: %s\n", packet->pkt.user_id->name);
 3212|      0|    }
 3213|     57|  return 0;
 3214|     57|}
parse-packet.c:parse_comment:
 3219|  1.06k|{
 3220|  1.06k|  byte *p;
 3221|       |
 3222|       |  /* Cap comment packet at a reasonable value to avoid an integer
 3223|       |     overflow in the malloc below.  Comment packets are actually not
 3224|       |     anymore define my OpenPGP and we even stopped to use our
 3225|       |     private comment packet.  */
 3226|  1.06k|  if (pktlen > MAX_COMMENT_PACKET_LENGTH)
  ------------------
  |  |   39|  1.06k|#define MAX_COMMENT_PACKET_LENGTH ( 64 * 1024)
  ------------------
  |  Branch (3226:7): [True: 0, False: 1.06k]
  ------------------
 3227|      0|    {
 3228|      0|      log_error ("packet(%d) too large\n", pkttype);
 3229|      0|      if (list_mode)
  ------------------
  |  Branch (3229:11): [True: 0, False: 0]
  ------------------
 3230|      0|        es_fprintf (listfp, ":%scomment packet: [too large]\n",
 3231|      0|                    pkttype == PKT_OLD_COMMENT ? "OpenPGP draft " : "");
  ------------------
  |  Branch (3231:21): [True: 0, False: 0]
  ------------------
 3232|      0|      iobuf_skip_rest (inp, pktlen, 0);
 3233|      0|      return GPG_ERR_INV_PACKET;
 3234|      0|    }
 3235|  1.06k|  packet->pkt.comment = xmalloc (sizeof *packet->pkt.comment + pktlen - 1);
  ------------------
  |  |  107|  1.06k|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 3236|  1.06k|  packet->pkt.comment->len = pktlen;
 3237|  1.06k|  p = packet->pkt.comment->data;
 3238|  8.16k|  for (; pktlen; pktlen--, p++)
  ------------------
  |  Branch (3238:10): [True: 7.09k, False: 1.06k]
  ------------------
 3239|  7.09k|    *p = iobuf_get_noeof (inp);
  ------------------
  |  |  502|  8.16k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  7.09k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 7.09k]
  |  |  |  |  |  Branch (500:24): [True: 468, False: 6.62k]
  |  |  |  |  ------------------
  |  |  |  |  501|  7.09k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3240|       |
 3241|  1.06k|  if (list_mode)
  ------------------
  |  Branch (3241:7): [True: 0, False: 1.06k]
  ------------------
 3242|      0|    {
 3243|      0|      int n = packet->pkt.comment->len;
 3244|      0|      es_fprintf (listfp, ":%scomment packet: \"", pkttype == PKT_OLD_COMMENT ?
  ------------------
  |  Branch (3244:52): [True: 0, False: 0]
  ------------------
 3245|      0|                  "OpenPGP draft " : "");
 3246|      0|      for (p = packet->pkt.comment->data; n; p++, n--)
  ------------------
  |  Branch (3246:43): [True: 0, False: 0]
  ------------------
 3247|      0|	{
 3248|      0|	  if (*p >= ' ' && *p <= 'z')
  ------------------
  |  Branch (3248:8): [True: 0, False: 0]
  |  Branch (3248:21): [True: 0, False: 0]
  ------------------
 3249|      0|	    es_putc (*p, listfp);
 3250|      0|	  else
 3251|      0|	    es_fprintf (listfp, "\\x%02x", *p);
 3252|      0|	}
 3253|      0|      es_fprintf (listfp, "\"\n");
 3254|      0|    }
 3255|  1.06k|  return 0;
 3256|  1.06k|}
parse-packet.c:parse_ring_trust:
 3265|    270|{
 3266|    270|  gpg_error_t err;
 3267|    270|  iobuf_t inp = ctx->inp;
 3268|    270|  PKT_ring_trust rt = {0};
 3269|    270|  int c;
 3270|    270|  int not_gpg = 0;
 3271|       |
 3272|    270|  if (!pktlen)
  ------------------
  |  Branch (3272:7): [True: 74, False: 196]
  ------------------
 3273|     74|    {
 3274|     74|      if (list_mode)
  ------------------
  |  Branch (3274:11): [True: 0, False: 74]
  ------------------
 3275|      0|	es_fprintf (listfp, ":trust packet: empty\n");
 3276|     74|      err = 0;
 3277|     74|      goto leave;
 3278|     74|    }
 3279|       |
 3280|    196|  c = iobuf_get_noeof (inp);
  ------------------
  |  |  502|    196|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|    196|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 196]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 196]
  |  |  |  |  ------------------
  |  |  |  |  501|    196|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3281|    196|  pktlen--;
 3282|    196|  rt.trustval = c;
 3283|    196|  if (pktlen)
  ------------------
  |  Branch (3283:7): [True: 196, False: 0]
  ------------------
 3284|    196|    {
 3285|    196|      if (!c)
  ------------------
  |  Branch (3285:11): [True: 172, False: 24]
  ------------------
 3286|    172|        {
 3287|    172|          c = iobuf_get_noeof (inp);
  ------------------
  |  |  502|    172|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|    172|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 172]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 172]
  |  |  |  |  ------------------
  |  |  |  |  501|    172|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3288|       |          /* We require that bit 7 of the sigcache is 0 (easier
 3289|       |           * eof handling).  */
 3290|    172|          if (!(c & 0x80))
  ------------------
  |  Branch (3290:15): [True: 172, False: 0]
  ------------------
 3291|    172|            rt.sigcache = c;
 3292|    172|        }
 3293|     24|      else
 3294|     24|        iobuf_get_noeof (inp);  /* Dummy read.  */
  ------------------
  |  |  502|     24|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|     24|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 24]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  |  |  501|     24|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3295|    196|      pktlen--;
 3296|    196|    }
 3297|       |
 3298|       |  /* Next is the optional subtype.  */
 3299|    196|  if (pktlen > 3)
  ------------------
  |  Branch (3299:7): [True: 196, False: 0]
  ------------------
 3300|    196|    {
 3301|    196|      char tmp[4];
 3302|    196|      tmp[0] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|    196|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|    196|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 196]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 196]
  |  |  |  |  ------------------
  |  |  |  |  501|    196|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3303|    196|      tmp[1] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|    196|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|    196|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 196]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 196]
  |  |  |  |  ------------------
  |  |  |  |  501|    196|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3304|    196|      tmp[2] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|    196|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|    196|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 196]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 196]
  |  |  |  |  ------------------
  |  |  |  |  501|    196|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3305|    196|      tmp[3] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|    196|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|    196|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 196]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 196]
  |  |  |  |  ------------------
  |  |  |  |  501|    196|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3306|    196|      pktlen -= 4;
 3307|    196|      if (!memcmp (tmp, "gpg", 3))
  ------------------
  |  Branch (3307:11): [True: 193, False: 3]
  ------------------
 3308|    193|        rt.subtype = tmp[3];
 3309|      3|      else
 3310|      3|        not_gpg = 1;
 3311|    196|    }
 3312|       |  /* If it is a key or uid subtype read the remaining data.  */
 3313|    196|  if ((rt.subtype == RING_TRUST_KEY || rt.subtype == RING_TRUST_UID)
  ------------------
  |  |  517|    392|#define RING_TRUST_KEY 1  /* A KEYORG on a primary key.      */
  ------------------
                if ((rt.subtype == RING_TRUST_KEY || rt.subtype == RING_TRUST_UID)
  ------------------
  |  |  518|    151|#define RING_TRUST_UID 2  /* A KEYORG on a user id.          */
  ------------------
  |  Branch (3313:8): [True: 45, False: 151]
  |  Branch (3313:40): [True: 24, False: 127]
  ------------------
 3314|    196|      && pktlen >= 6 )
  ------------------
  |  Branch (3314:10): [True: 69, False: 0]
  ------------------
 3315|     69|    {
 3316|     69|      int i;
 3317|     69|      unsigned int namelen;
 3318|       |
 3319|     69|      rt.keyorg = iobuf_get_noeof (inp);
  ------------------
  |  |  502|     69|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|     69|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 69]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 69]
  |  |  |  |  ------------------
  |  |  |  |  501|     69|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3320|     69|      pktlen--;
 3321|     69|      rt.keyupdate = read_32 (inp);
 3322|     69|      pktlen -= 4;
 3323|     69|      namelen = iobuf_get_noeof (inp);
  ------------------
  |  |  502|     69|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|     69|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 69]
  |  |  |  |  |  Branch (500:24): [True: 1, False: 68]
  |  |  |  |  ------------------
  |  |  |  |  501|     69|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3324|     69|      pktlen--;
 3325|     69|      if (namelen && pktlen)
  ------------------
  |  Branch (3325:11): [True: 21, False: 48]
  |  Branch (3325:22): [True: 21, False: 0]
  ------------------
 3326|     21|        {
 3327|     21|          rt.url = xtrymalloc (namelen + 1);
  ------------------
  |  |   97|     21|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
 3328|     21|          if (!rt.url)
  ------------------
  |  Branch (3328:15): [True: 0, False: 21]
  ------------------
 3329|      0|            {
 3330|      0|              err = gpg_error_from_syserror ();
 3331|      0|              goto leave;
 3332|      0|            }
 3333|     42|          for (i = 0; pktlen && i < namelen; pktlen--, i++)
  ------------------
  |  Branch (3333:23): [True: 21, False: 21]
  |  Branch (3333:33): [True: 21, False: 0]
  ------------------
 3334|     21|            rt.url[i] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|     42|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|     21|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 21]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 21]
  |  |  |  |  ------------------
  |  |  |  |  501|     21|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3335|     21|          rt.url[i] = 0;
 3336|     21|        }
 3337|     69|    }
 3338|       |
 3339|    196|  if (list_mode)
  ------------------
  |  Branch (3339:7): [True: 0, False: 196]
  ------------------
 3340|      0|    {
 3341|      0|      if (rt.subtype == RING_TRUST_SIG)
  ------------------
  |  |  516|      0|#define RING_TRUST_SIG 0  /* The classical signature cache.  */
  ------------------
  |  Branch (3341:11): [True: 0, False: 0]
  ------------------
 3342|      0|        es_fprintf (listfp, ":trust packet: sig flag=%02x sigcache=%02x\n",
 3343|      0|                    rt.trustval, rt.sigcache);
 3344|      0|      else if (rt.subtype == RING_TRUST_UID || rt.subtype == RING_TRUST_KEY)
  ------------------
  |  |  518|      0|#define RING_TRUST_UID 2  /* A KEYORG on a user id.          */
  ------------------
                    else if (rt.subtype == RING_TRUST_UID || rt.subtype == RING_TRUST_KEY)
  ------------------
  |  |  517|      0|#define RING_TRUST_KEY 1  /* A KEYORG on a primary key.      */
  ------------------
  |  Branch (3344:16): [True: 0, False: 0]
  |  Branch (3344:48): [True: 0, False: 0]
  ------------------
 3345|      0|        {
 3346|      0|          unsigned char *p;
 3347|       |
 3348|      0|          es_fprintf (listfp, ":trust packet: %s upd=%lu src=%d%s",
 3349|      0|                      (rt.subtype == RING_TRUST_UID? "uid" : "key"),
  ------------------
  |  |  518|      0|#define RING_TRUST_UID 2  /* A KEYORG on a user id.          */
  ------------------
  |  Branch (3349:24): [True: 0, False: 0]
  ------------------
 3350|      0|                      (unsigned long)rt.keyupdate,
 3351|      0|                      rt.keyorg,
 3352|      0|                      (rt.url? " url=":""));
  ------------------
  |  Branch (3352:24): [True: 0, False: 0]
  ------------------
 3353|      0|          if (rt.url)
  ------------------
  |  Branch (3353:15): [True: 0, False: 0]
  ------------------
 3354|      0|            {
 3355|      0|              for (p = rt.url; *p; p++)
  ------------------
  |  Branch (3355:32): [True: 0, False: 0]
  ------------------
 3356|      0|                {
 3357|      0|                  if (*p >= ' ' && *p <= 'z')
  ------------------
  |  Branch (3357:23): [True: 0, False: 0]
  |  Branch (3357:36): [True: 0, False: 0]
  ------------------
 3358|      0|                    es_putc (*p, listfp);
 3359|      0|                  else
 3360|      0|                    es_fprintf (listfp, "\\x%02x", *p);
 3361|      0|                }
 3362|      0|            }
 3363|      0|          es_putc ('\n', listfp);
 3364|      0|        }
 3365|      0|      else if (not_gpg)
  ------------------
  |  Branch (3365:16): [True: 0, False: 0]
  ------------------
 3366|      0|        es_fprintf (listfp, ":trust packet: not created by gpg\n");
 3367|      0|      else
 3368|      0|        es_fprintf (listfp, ":trust packet: subtype=%02x\n",
 3369|      0|                    rt.subtype);
 3370|      0|    }
 3371|       |
 3372|       |  /* Now transfer the data to the respective packet.  Do not do this
 3373|       |   * if SKIP_META is set.  */
 3374|    196|  if (!ctx->last_pkt.pkt.generic || ctx->skip_meta)
  ------------------
  |  Branch (3374:7): [True: 22, False: 174]
  |  Branch (3374:37): [True: 2, False: 172]
  ------------------
 3375|     24|    ;
 3376|    172|  else if (rt.subtype == RING_TRUST_SIG
  ------------------
  |  |  516|    344|#define RING_TRUST_SIG 0  /* The classical signature cache.  */
  ------------------
  |  Branch (3376:12): [True: 124, False: 48]
  ------------------
 3377|    172|           && ctx->last_pkt.pkttype == PKT_SIGNATURE)
  ------------------
  |  Branch (3377:15): [True: 124, False: 0]
  ------------------
 3378|    124|    {
 3379|    124|      PKT_signature *sig = ctx->last_pkt.pkt.signature;
 3380|       |
 3381|    124|      if ((rt.sigcache & 1))
  ------------------
  |  Branch (3381:11): [True: 16, False: 108]
  ------------------
 3382|     16|        {
 3383|     16|          sig->flags.checked = 1;
 3384|     16|          sig->flags.valid = !!(rt.sigcache & 2);
 3385|     16|        }
 3386|    124|    }
 3387|     48|  else if (rt.subtype == RING_TRUST_UID
  ------------------
  |  |  518|     96|#define RING_TRUST_UID 2  /* A KEYORG on a user id.          */
  ------------------
  |  Branch (3387:12): [True: 24, False: 24]
  ------------------
 3388|     48|           && (ctx->last_pkt.pkttype == PKT_USER_ID
  ------------------
  |  Branch (3388:16): [True: 24, False: 0]
  ------------------
 3389|     24|               || ctx->last_pkt.pkttype == PKT_ATTRIBUTE))
  ------------------
  |  Branch (3389:19): [True: 0, False: 0]
  ------------------
 3390|     24|    {
 3391|     24|      PKT_user_id *uid = ctx->last_pkt.pkt.user_id;
 3392|       |
 3393|     24|      uid->keyorg = rt.keyorg;
 3394|     24|      uid->keyupdate = rt.keyupdate;
 3395|     24|      uid->updateurl = rt.url;
 3396|     24|      rt.url = NULL;
 3397|     24|    }
 3398|     24|  else if (rt.subtype == RING_TRUST_KEY
  ------------------
  |  |  517|     48|#define RING_TRUST_KEY 1  /* A KEYORG on a primary key.      */
  ------------------
  |  Branch (3398:12): [True: 24, False: 0]
  ------------------
 3399|     24|           && (ctx->last_pkt.pkttype == PKT_PUBLIC_KEY
  ------------------
  |  Branch (3399:16): [True: 24, False: 0]
  ------------------
 3400|     24|               || ctx->last_pkt.pkttype == PKT_SECRET_KEY))
  ------------------
  |  Branch (3400:19): [True: 0, False: 0]
  ------------------
 3401|     24|    {
 3402|     24|      PKT_public_key *pk = ctx->last_pkt.pkt.public_key;
 3403|       |
 3404|     24|      pk->keyorg = rt.keyorg;
 3405|     24|      pk->keyupdate = rt.keyupdate;
 3406|     24|      pk->updateurl = rt.url;
 3407|     24|      rt.url = NULL;
 3408|     24|    }
 3409|       |
 3410|    196|  err = 0;
 3411|       |
 3412|    270| leave:
 3413|    270|  xfree (rt.url);
  ------------------
  |  |  104|    270|#define xfree(a)         gcry_free ((a))
  ------------------
 3414|    270|  free_packet (NULL, ctx); /* This sets ctx->last_pkt to NULL.  */
 3415|    270|  iobuf_skip_rest (inp, pktlen, 0);
 3416|    270|  return err;
 3417|    196|}
parse-packet.c:parse_plaintext:
 3423|     34|{
 3424|     34|  int rc = 0;
 3425|     34|  int mode, namelen;
 3426|     34|  PKT_plaintext *pt;
 3427|     34|  byte *p;
 3428|     34|  int c, i;
 3429|       |
 3430|     34|  if (!partial && pktlen < 6)
  ------------------
  |  Branch (3430:7): [True: 1, False: 33]
  |  Branch (3430:19): [True: 0, False: 1]
  ------------------
 3431|      0|    {
 3432|      0|      log_error ("packet(%d) too short (%lu)\n", pkttype, (ulong) pktlen);
 3433|      0|      if (list_mode)
  ------------------
  |  Branch (3433:11): [True: 0, False: 0]
  ------------------
 3434|      0|        es_fputs (":literal data packet: [too short]\n", listfp);
 3435|      0|      rc = gpg_error (GPG_ERR_INV_PACKET);
 3436|      0|      goto leave;
 3437|      0|    }
 3438|     34|  mode = iobuf_get_noeof (inp);
  ------------------
  |  |  502|     34|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|     34|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 34]
  |  |  |  |  |  Branch (500:24): [True: 1, False: 33]
  |  |  |  |  ------------------
  |  |  |  |  501|     34|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3439|     34|  if (pktlen)
  ------------------
  |  Branch (3439:7): [True: 1, False: 33]
  ------------------
 3440|      1|    pktlen--;
 3441|     34|  namelen = iobuf_get_noeof (inp);
  ------------------
  |  |  502|     34|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|     34|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 34]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 34]
  |  |  |  |  ------------------
  |  |  |  |  501|     34|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3442|     34|  if (pktlen)
  ------------------
  |  Branch (3442:7): [True: 1, False: 33]
  ------------------
 3443|      1|    pktlen--;
 3444|       |  /* Note that namelen will never exceed 255 bytes. */
 3445|     34|  pt = pkt->pkt.plaintext =
 3446|     34|    xmalloc (sizeof *pkt->pkt.plaintext + namelen - 1);
  ------------------
  |  |  107|     34|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 3447|     34|  pt->new_ctb = new_ctb;
 3448|     34|  pt->mode = mode;
 3449|     34|  pt->namelen = namelen;
 3450|     34|  pt->is_partial = partial;
 3451|     34|  if (pktlen)
  ------------------
  |  Branch (3451:7): [True: 1, False: 33]
  ------------------
 3452|      1|    {
 3453|    213|      for (i = 0; pktlen > 4 && i < namelen; pktlen--, i++)
  ------------------
  |  Branch (3453:19): [True: 213, False: 0]
  |  Branch (3453:33): [True: 212, False: 1]
  ------------------
 3454|    212|	pt->name[i] = iobuf_get_noeof (inp);
  ------------------
  |  |  502|    212|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|    212|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 212]
  |  |  |  |  |  Branch (500:24): [True: 1, False: 211]
  |  |  |  |  ------------------
  |  |  |  |  501|    212|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3455|      1|    }
 3456|     33|  else
 3457|     33|    {
 3458|    351|      for (i = 0; i < namelen; i++)
  ------------------
  |  Branch (3458:19): [True: 350, False: 1]
  ------------------
 3459|    350|	if ((c = iobuf_get (inp)) == -1)
  ------------------
  |  |  500|    350|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 350]
  |  |  |  Branch (500:24): [True: 33, False: 317]
  |  |  ------------------
  |  |  501|    350|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (3459:6): [True: 32, False: 318]
  ------------------
 3460|     32|	  break;
 3461|    318|	else
 3462|    318|	  pt->name[i] = c;
 3463|     33|    }
 3464|       |  /* Fill up NAME so that a check with valgrind won't complain about
 3465|       |   * reading from uninitialized memory.  This case may be triggred by
 3466|       |   * corrupted packets.  */
 3467|  4.14k|  for (; i < namelen; i++)
  ------------------
  |  Branch (3467:10): [True: 4.11k, False: 34]
  ------------------
 3468|  4.11k|    pt->name[i] = 0;
 3469|       |
 3470|     34|  pt->timestamp = read_32 (inp);
 3471|     34|  if (pktlen)
  ------------------
  |  Branch (3471:7): [True: 1, False: 33]
  ------------------
 3472|      1|    pktlen -= 4;
 3473|     34|  pt->len = pktlen;
 3474|     34|  pt->buf = inp;
 3475|       |
 3476|     34|  if (list_mode)
  ------------------
  |  Branch (3476:7): [True: 0, False: 34]
  ------------------
 3477|      0|    {
 3478|      0|      es_fprintf (listfp, ":literal data packet:\n"
 3479|      0|                  "\tmode %c (%X), created %lu, name=\"",
 3480|      0|                  mode >= ' ' && mode < 'z' ? mode : '?', mode,
  ------------------
  |  Branch (3480:19): [True: 0, False: 0]
  |  Branch (3480:34): [True: 0, False: 0]
  ------------------
 3481|      0|                  (ulong) pt->timestamp);
 3482|      0|      for (p = pt->name, i = 0; i < namelen; p++, i++)
  ------------------
  |  Branch (3482:33): [True: 0, False: 0]
  ------------------
 3483|      0|	{
 3484|      0|	  if (*p >= ' ' && *p <= 'z')
  ------------------
  |  Branch (3484:8): [True: 0, False: 0]
  |  Branch (3484:21): [True: 0, False: 0]
  ------------------
 3485|      0|	    es_putc (*p, listfp);
 3486|      0|	  else
 3487|      0|	    es_fprintf (listfp, "\\x%02x", *p);
 3488|      0|	}
 3489|      0|      es_fprintf (listfp, "\",\n\traw data: ");
 3490|      0|      if (partial)
  ------------------
  |  Branch (3490:11): [True: 0, False: 0]
  ------------------
 3491|      0|	es_fprintf (listfp, "unknown length\n");
 3492|      0|      else
 3493|      0|	es_fprintf (listfp, "%lu bytes\n", (ulong) pt->len);
 3494|      0|    }
 3495|       |
 3496|     34| leave:
 3497|     34|  return rc;
 3498|     34|}
parse-packet.c:parse_compressed:
 3504|      2|{
 3505|      2|  PKT_compressed *zd;
 3506|       |
 3507|       |  /* PKTLEN is here 0, but data follows (this should be the last
 3508|       |     object in a file or the compress algorithm should know the
 3509|       |     length).  */
 3510|      2|  (void) pkttype;
 3511|      2|  (void) pktlen;
 3512|       |
 3513|      2|  zd = pkt->pkt.compressed = xmalloc (sizeof *pkt->pkt.compressed);
  ------------------
  |  |  107|      2|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 3514|      2|  zd->algorithm = iobuf_get_noeof (inp);
  ------------------
  |  |  502|      2|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|      2|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 2]
  |  |  |  |  |  Branch (500:24): [True: 1, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  501|      2|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3515|      2|  zd->len = 0;			/* not used */
 3516|      2|  zd->new_ctb = new_ctb;
 3517|      2|  zd->buf = inp;
 3518|      2|  if (list_mode)
  ------------------
  |  Branch (3518:7): [True: 0, False: 2]
  ------------------
 3519|      0|    es_fprintf (listfp, ":compressed packet: algo=%d\n", zd->algorithm);
 3520|      2|  return 0;
 3521|      2|}
parse-packet.c:parse_encrypted:
 3527|      1|{
 3528|      1|  int rc = 0;
 3529|      1|  PKT_encrypted *ed;
 3530|      1|  unsigned long orig_pktlen = pktlen;
 3531|       |
 3532|      1|  ed = pkt->pkt.encrypted = xmalloc (sizeof *pkt->pkt.encrypted);
  ------------------
  |  |  107|      1|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
 3533|       |  /* ed->len is set below.  */
 3534|      1|  ed->extralen = 0;  /* Unknown here; only used in build_packet.  */
 3535|      1|  ed->buf = NULL;
 3536|      1|  ed->new_ctb = new_ctb;
 3537|      1|  ed->is_partial = partial;
 3538|      1|  ed->aead_algo = 0;
 3539|      1|  ed->cipher_algo = 0; /* Only used with AEAD.  */
 3540|      1|  ed->chunkbyte = 0;   /* Only used with AEAD.  */
 3541|      1|  if (pkttype == PKT_ENCRYPTED_MDC)
  ------------------
  |  Branch (3541:7): [True: 0, False: 1]
  ------------------
 3542|      0|    {
 3543|       |      /* Fixme: add some pktlen sanity checks.  */
 3544|      0|      int version;
 3545|       |
 3546|      0|      version = iobuf_get_noeof (inp);
  ------------------
  |  |  502|      0|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|      0|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 0]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  501|      0|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3547|      0|      if (orig_pktlen)
  ------------------
  |  Branch (3547:11): [True: 0, False: 0]
  ------------------
 3548|      0|	pktlen--;
 3549|      0|      if (version != 1)
  ------------------
  |  Branch (3549:11): [True: 0, False: 0]
  ------------------
 3550|      0|	{
 3551|      0|	  log_error ("encrypted_mdc packet with unknown version %d\n",
 3552|      0|		     version);
 3553|      0|          if (list_mode)
  ------------------
  |  Branch (3553:15): [True: 0, False: 0]
  ------------------
 3554|      0|            es_fputs (":encrypted data packet: [unknown version]\n", listfp);
 3555|       |	  /*skip_rest(inp, pktlen); should we really do this? */
 3556|      0|	  rc = gpg_error (GPG_ERR_INV_PACKET);
 3557|      0|	  goto leave;
 3558|      0|	}
 3559|      0|      ed->mdc_method = DIGEST_ALGO_SHA1;
 3560|      0|    }
 3561|      1|  else
 3562|      1|    ed->mdc_method = 0;
 3563|       |
 3564|       |  /* A basic sanity check.  We need at least an 8 byte IV plus the 2
 3565|       |     detection bytes.  Note that we don't known the algorithm and thus
 3566|       |     we may only check against the minimum blocksize.  */
 3567|      1|  if (orig_pktlen && pktlen < 10)
  ------------------
  |  Branch (3567:7): [True: 0, False: 1]
  |  Branch (3567:22): [True: 0, False: 0]
  ------------------
 3568|      0|    {
 3569|       |      /* Actually this is blocksize+2.  */
 3570|      0|      log_error ("packet(%d) too short\n", pkttype);
 3571|      0|      if (list_mode)
  ------------------
  |  Branch (3571:11): [True: 0, False: 0]
  ------------------
 3572|      0|        es_fputs (":encrypted data packet: [too short]\n", listfp);
 3573|      0|      rc = GPG_ERR_INV_PACKET;
 3574|      0|      iobuf_skip_rest (inp, pktlen, partial);
 3575|      0|      goto leave;
 3576|      0|    }
 3577|       |
 3578|       |  /* Store the remaining length of the encrypted data (i.e. without
 3579|       |     the MDC version number but with the IV etc.).  This value is
 3580|       |     required during decryption.  */
 3581|      1|  ed->len = pktlen;
 3582|       |
 3583|      1|  if (list_mode)
  ------------------
  |  Branch (3583:7): [True: 0, False: 1]
  ------------------
 3584|      0|    {
 3585|      0|      if (orig_pktlen)
  ------------------
  |  Branch (3585:11): [True: 0, False: 0]
  ------------------
 3586|      0|	es_fprintf (listfp, ":encrypted data packet:\n\tlength: %lu\n",
 3587|      0|                    orig_pktlen);
 3588|      0|      else
 3589|      0|	es_fprintf (listfp, ":encrypted data packet:\n\tlength: unknown\n");
 3590|      0|      if (ed->mdc_method)
  ------------------
  |  Branch (3590:11): [True: 0, False: 0]
  ------------------
 3591|      0|	es_fprintf (listfp, "\tmdc_method: %d\n", ed->mdc_method);
 3592|      0|    }
 3593|       |
 3594|      1|  ed->buf = inp;
 3595|       |
 3596|      1| leave:
 3597|      1|  return rc;
 3598|      1|}
parse-packet.c:parse_encrypted_aead:
 3635|     32|{
 3636|     32|  int rc = 0;
 3637|     32|  PKT_encrypted *ed;
 3638|     32|  unsigned long orig_pktlen = pktlen;
 3639|     32|  int version;
 3640|       |
 3641|     32|  ed = pkt->pkt.encrypted = xtrymalloc (sizeof *pkt->pkt.encrypted);
  ------------------
  |  |   97|     32|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
 3642|     32|  if (!ed)
  ------------------
  |  Branch (3642:7): [True: 0, False: 32]
  ------------------
 3643|      0|    return gpg_error_from_syserror ();
 3644|     32|  ed->len = 0;
 3645|     32|  ed->extralen = 0;  /* (only used in build_packet.)  */
 3646|     32|  ed->buf = NULL;
 3647|     32|  ed->new_ctb = 1;   /* (packet number requires a new CTB anyway.)  */
 3648|     32|  ed->is_partial = partial;
 3649|     32|  ed->mdc_method = 0;
 3650|       |  /* A basic sanity check.  We need one version byte, one algo byte,
 3651|       |   * one aead algo byte, one chunkbyte, at least 15 byte IV.  */
 3652|     32|  if (orig_pktlen && pktlen < 19)
  ------------------
  |  Branch (3652:7): [True: 32, False: 0]
  |  Branch (3652:22): [True: 0, False: 32]
  ------------------
 3653|      0|    {
 3654|      0|      log_error ("packet(%d) too short\n", pkttype);
 3655|      0|      if (list_mode)
  ------------------
  |  Branch (3655:11): [True: 0, False: 0]
  ------------------
 3656|      0|        es_fputs (":aead encrypted packet: [too short]\n", listfp);
 3657|      0|      rc = gpg_error (GPG_ERR_INV_PACKET);
 3658|      0|      iobuf_skip_rest (inp, pktlen, partial);
 3659|      0|      goto leave;
 3660|      0|    }
 3661|       |
 3662|     32|  version = iobuf_get_noeof (inp);
  ------------------
  |  |  502|     32|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|     32|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 32]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  501|     32|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3663|     32|  if (orig_pktlen)
  ------------------
  |  Branch (3663:7): [True: 32, False: 0]
  ------------------
 3664|     32|    pktlen--;
 3665|     32|  if (version != 1)
  ------------------
  |  Branch (3665:7): [True: 0, False: 32]
  ------------------
 3666|      0|    {
 3667|      0|      log_error ("aead encrypted packet with unknown version %d\n",
 3668|      0|                 version);
 3669|      0|      if (list_mode)
  ------------------
  |  Branch (3669:11): [True: 0, False: 0]
  ------------------
 3670|      0|        es_fputs (":aead encrypted packet: [unknown version]\n", listfp);
 3671|       |      /*skip_rest(inp, pktlen); should we really do this? */
 3672|      0|      rc = gpg_error (GPG_ERR_INV_PACKET);
 3673|      0|      goto leave;
 3674|      0|    }
 3675|       |
 3676|     32|  ed->cipher_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|     32|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|     32|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 32]
  |  |  |  |  |  Branch (500:24): [True: 32, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  501|     32|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3677|     32|  if (orig_pktlen)
  ------------------
  |  Branch (3677:7): [True: 32, False: 0]
  ------------------
 3678|     32|    pktlen--;
 3679|     32|  ed->aead_algo = iobuf_get_noeof (inp);
  ------------------
  |  |  502|     32|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|     32|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 32]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  501|     32|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3680|     32|  if (orig_pktlen)
  ------------------
  |  Branch (3680:7): [True: 32, False: 0]
  ------------------
 3681|     32|    pktlen--;
 3682|     32|  ed->chunkbyte = iobuf_get_noeof (inp);
  ------------------
  |  |  502|     32|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|     32|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 32]
  |  |  |  |  |  Branch (500:24): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  501|     32|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
 3683|     32|  if (orig_pktlen)
  ------------------
  |  Branch (3683:7): [True: 32, False: 0]
  ------------------
 3684|     32|    pktlen--;
 3685|       |
 3686|       |  /* Store the remaining length of the encrypted data.  We read the
 3687|       |   * rest during decryption.  */
 3688|     32|  ed->len = pktlen;
 3689|       |
 3690|     32|  if (list_mode)
  ------------------
  |  Branch (3690:7): [True: 0, False: 32]
  ------------------
 3691|      0|    {
 3692|      0|      es_fprintf (listfp, ":aead encrypted packet: cipher=%u aead=%u cb=%u\n",
 3693|      0|                  ed->cipher_algo, ed->aead_algo, ed->chunkbyte);
 3694|      0|      if (orig_pktlen)
  ------------------
  |  Branch (3694:11): [True: 0, False: 0]
  ------------------
 3695|      0|	es_fprintf (listfp, "\tlength: %lu\n", orig_pktlen);
 3696|      0|      else
 3697|      0|	es_fprintf (listfp, "\tlength: unknown\n");
 3698|      0|    }
 3699|       |
 3700|     32|  ed->buf = inp;
 3701|       |
 3702|     32| leave:
 3703|     32|  return rc;
 3704|     32|}
parse-packet.c:skip_packet:
 1045|     31|{
 1046|     31|  if (list_mode)
  ------------------
  |  Branch (1046:7): [True: 0, False: 31]
  ------------------
 1047|      0|    {
 1048|      0|      es_fprintf (listfp, ":unknown packet: type %2d, length %lu\n",
 1049|      0|                  pkttype, pktlen);
 1050|      0|      if (pkttype)
  ------------------
  |  Branch (1050:11): [True: 0, False: 0]
  ------------------
 1051|      0|	{
 1052|      0|	  int c, i = 0;
 1053|      0|	  es_fputs ("dump:", listfp);
 1054|      0|	  if (partial)
  ------------------
  |  Branch (1054:8): [True: 0, False: 0]
  ------------------
 1055|      0|	    {
 1056|      0|	      while ((c = iobuf_get (inp)) != -1)
  ------------------
  |  |  500|      0|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 0]
  |  |  |  Branch (500:24): [True: 0, False: 0]
  |  |  ------------------
  |  |  501|      0|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (1056:15): [True: 0, False: 0]
  ------------------
 1057|      0|		dump_hex_line (c, &i);
 1058|      0|	    }
 1059|      0|	  else
 1060|      0|	    {
 1061|      0|	      for (; pktlen; pktlen--)
  ------------------
  |  Branch (1061:15): [True: 0, False: 0]
  ------------------
 1062|      0|		{
 1063|      0|		  dump_hex_line ((c = iobuf_get (inp)), &i);
  ------------------
  |  |  500|      0|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 0]
  |  |  |  Branch (500:24): [True: 0, False: 0]
  |  |  ------------------
  |  |  501|      0|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
 1064|      0|		  if (c == -1)
  ------------------
  |  Branch (1064:9): [True: 0, False: 0]
  ------------------
 1065|      0|		    break;
 1066|      0|		}
 1067|      0|	    }
 1068|      0|	  es_putc ('\n', listfp);
 1069|      0|	  return;
 1070|      0|	}
 1071|      0|    }
 1072|     31|  iobuf_skip_rest (inp, pktlen, partial);
 1073|     31|}
parse-packet.c:can_handle_critical:
 1834|    316|{
 1835|    316|  switch (type)
 1836|    316|    {
 1837|      0|    case SIGSUBPKT_NOTATION:
  ------------------
  |  Branch (1837:5): [True: 0, False: 316]
  ------------------
 1838|      0|      if (n >= 8)
  ------------------
  |  Branch (1838:11): [True: 0, False: 0]
  ------------------
 1839|      0|	{
 1840|      0|	  size_t notation_len = ((buffer[4] << 8) | buffer[5]);
 1841|      0|	  if (n - 8 >= notation_len)
  ------------------
  |  Branch (1841:8): [True: 0, False: 0]
  ------------------
 1842|      0|	    return can_handle_critical_notation (buffer + 8, notation_len);
 1843|      0|	}
 1844|      0|      return 0;
 1845|      0|    case SIGSUBPKT_SIGNATURE:
  ------------------
  |  Branch (1845:5): [True: 0, False: 316]
  ------------------
 1846|      9|    case SIGSUBPKT_SIG_CREATED:
  ------------------
  |  Branch (1846:5): [True: 9, False: 307]
  ------------------
 1847|      9|    case SIGSUBPKT_SIG_EXPIRE:
  ------------------
  |  Branch (1847:5): [True: 0, False: 316]
  ------------------
 1848|      9|    case SIGSUBPKT_KEY_EXPIRE:
  ------------------
  |  Branch (1848:5): [True: 0, False: 316]
  ------------------
 1849|      9|    case SIGSUBPKT_EXPORTABLE:
  ------------------
  |  Branch (1849:5): [True: 0, False: 316]
  ------------------
 1850|      9|    case SIGSUBPKT_REVOCABLE:
  ------------------
  |  Branch (1850:5): [True: 0, False: 316]
  ------------------
 1851|    166|    case SIGSUBPKT_REV_KEY:
  ------------------
  |  Branch (1851:5): [True: 157, False: 159]
  ------------------
 1852|    175|    case SIGSUBPKT_ISSUER:	/* issuer key ID */
  ------------------
  |  Branch (1852:5): [True: 9, False: 307]
  ------------------
 1853|    175|    case SIGSUBPKT_ISSUER_FPR:	/* issuer fingerprint */
  ------------------
  |  Branch (1853:5): [True: 0, False: 316]
  ------------------
 1854|    187|    case SIGSUBPKT_PREF_SYM:
  ------------------
  |  Branch (1854:5): [True: 12, False: 304]
  ------------------
 1855|    187|    case SIGSUBPKT_PREF_AEAD:
  ------------------
  |  Branch (1855:5): [True: 0, False: 316]
  ------------------
 1856|    196|    case SIGSUBPKT_PREF_HASH:
  ------------------
  |  Branch (1856:5): [True: 9, False: 307]
  ------------------
 1857|    205|    case SIGSUBPKT_PREF_COMPR:
  ------------------
  |  Branch (1857:5): [True: 9, False: 307]
  ------------------
 1858|    214|    case SIGSUBPKT_KEY_FLAGS:
  ------------------
  |  Branch (1858:5): [True: 9, False: 307]
  ------------------
 1859|    214|    case SIGSUBPKT_PRIMARY_UID:
  ------------------
  |  Branch (1859:5): [True: 0, False: 316]
  ------------------
 1860|    223|    case SIGSUBPKT_FEATURES:
  ------------------
  |  Branch (1860:5): [True: 9, False: 307]
  ------------------
 1861|    223|    case SIGSUBPKT_TRUST:
  ------------------
  |  Branch (1861:5): [True: 0, False: 316]
  ------------------
 1862|    223|    case SIGSUBPKT_REGEXP:
  ------------------
  |  Branch (1862:5): [True: 0, False: 316]
  ------------------
 1863|    223|    case SIGSUBPKT_ATTST_SIGS:
  ------------------
  |  Branch (1863:5): [True: 0, False: 316]
  ------------------
 1864|       |      /* Is it enough to show the policy or keyserver? */
 1865|    223|    case SIGSUBPKT_POLICY:
  ------------------
  |  Branch (1865:5): [True: 0, False: 316]
  ------------------
 1866|    223|    case SIGSUBPKT_PREF_KS:
  ------------------
  |  Branch (1866:5): [True: 0, False: 316]
  ------------------
 1867|    223|    case SIGSUBPKT_REVOC_REASON: /* At least we know about it.  */
  ------------------
  |  Branch (1867:5): [True: 0, False: 316]
  ------------------
 1868|    223|      return 1;
 1869|       |
 1870|     93|    case SIGSUBPKT_KEY_BLOCK:
  ------------------
  |  Branch (1870:5): [True: 93, False: 223]
  ------------------
 1871|     93|      if (n && !buffer[0])
  ------------------
  |  Branch (1871:11): [True: 0, False: 93]
  |  Branch (1871:16): [True: 0, False: 0]
  ------------------
 1872|      0|        return 1;
 1873|     93|      else
 1874|     93|        return 0;
 1875|       |
 1876|      0|    default:
  ------------------
  |  Branch (1876:5): [True: 0, False: 316]
  ------------------
 1877|      0|      return 0;
 1878|    316|    }
 1879|    316|}
parse-packet.c:read_32:
  106|  5.80k|{
  107|  5.80k|  unsigned long a;
  108|  5.80k|  a = (unsigned long)iobuf_get_noeof (inp) << 24;
  ------------------
  |  |  502|  5.80k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  5.80k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 5.80k]
  |  |  |  |  |  Branch (500:24): [True: 32, False: 5.77k]
  |  |  |  |  ------------------
  |  |  |  |  501|  5.80k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
  109|  5.80k|  a |= iobuf_get_noeof (inp) << 16;
  ------------------
  |  |  502|  5.80k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  5.80k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 5.80k]
  |  |  |  |  |  Branch (500:24): [True: 1, False: 5.80k]
  |  |  |  |  ------------------
  |  |  |  |  501|  5.80k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
  110|  5.80k|  a |= iobuf_get_noeof (inp) << 8;
  ------------------
  |  |  502|  5.80k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  5.80k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 5.80k]
  |  |  |  |  |  Branch (500:24): [True: 2, False: 5.80k]
  |  |  |  |  ------------------
  |  |  |  |  501|  5.80k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
  111|  5.80k|  a |= iobuf_get_noeof (inp);
  ------------------
  |  |  502|  5.80k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  5.80k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 5.80k]
  |  |  |  |  |  Branch (500:24): [True: 33, False: 5.77k]
  |  |  |  |  ------------------
  |  |  |  |  501|  5.80k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
  112|  5.80k|  return a;
  113|  5.80k|}
parse-packet.c:read_16:
   95|  1.06k|{
   96|  1.06k|  unsigned short a;
   97|  1.06k|  a = (unsigned short)iobuf_get_noeof (inp) << 8;
  ------------------
  |  |  502|  1.06k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  1.06k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 1.06k]
  |  |  |  |  |  Branch (500:24): [True: 16, False: 1.04k]
  |  |  |  |  ------------------
  |  |  |  |  501|  1.06k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
   98|  1.06k|  a |= iobuf_get_noeof (inp);
  ------------------
  |  |  502|  1.06k|#define iobuf_get_noeof(a)    (iobuf_get((a))&0xff)
  |  |  ------------------
  |  |  |  |  500|  1.06k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (500:9): [True: 0, False: 1.06k]
  |  |  |  |  |  Branch (500:24): [True: 16, False: 1.04k]
  |  |  |  |  ------------------
  |  |  |  |  501|  1.06k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  |  |  ------------------
  ------------------
   99|  1.06k|  return a;
  100|  1.06k|}
parse-packet.c:unknown_pubkey_warning:
  334|  2.66k|{
  335|  2.66k|  static byte unknown_pubkey_algos[256];
  336|       |
  337|       |  /* First check whether the algorithm is usable but not suitable for
  338|       |     encryption/signing.  */
  339|  2.66k|  if (pubkey_get_npkey (algo))
  ------------------
  |  Branch (339:7): [True: 1.16k, False: 1.49k]
  ------------------
  340|  1.16k|    {
  341|  1.16k|      if (opt.verbose && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (341:11): [True: 0, False: 1.16k]
  |  Branch (341:26): [True: 0, False: 0]
  ------------------
  342|      0|        {
  343|      0|          if (!pubkey_get_nsig (algo))
  ------------------
  |  Branch (343:15): [True: 0, False: 0]
  ------------------
  344|      0|            log_info ("public key algorithm %s not suitable for %s\n",
  345|      0|                      openpgp_pk_algo_name (algo), "signing");
  346|      0|          if (!pubkey_get_nenc (algo))
  ------------------
  |  Branch (346:15): [True: 0, False: 0]
  ------------------
  347|      0|            log_info ("public key algorithm %s not suitable for %s\n",
  348|      0|                      openpgp_pk_algo_name (algo), "encryption");
  349|      0|        }
  350|  1.16k|    }
  351|  1.49k|  else
  352|  1.49k|    {
  353|  1.49k|      algo &= 0xff;
  354|  1.49k|      if (!unknown_pubkey_algos[algo])
  ------------------
  |  Branch (354:11): [True: 28, False: 1.46k]
  ------------------
  355|     28|        {
  356|     28|          if (opt.verbose && !glo_ctrl.silence_parse_warnings)
  ------------------
  |  Branch (356:15): [True: 0, False: 28]
  |  Branch (356:30): [True: 0, False: 0]
  ------------------
  357|      0|            log_info (_("can't handle public key algorithm %d\n"), algo);
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  358|     28|          unknown_pubkey_algos[algo] = 1;
  359|     28|        }
  360|  1.49k|    }
  361|  2.66k|}
parse-packet.c:read_rest:
 1082|  3.02k|{
 1083|  3.02k|  int c;
 1084|  3.02k|  byte *buf, *p;
 1085|       |
 1086|  3.02k|  buf = xtrymalloc (pktlen);
  ------------------
  |  |   97|  3.02k|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
 1087|  3.02k|  if (!buf)
  ------------------
  |  Branch (1087:7): [True: 198, False: 2.82k]
  ------------------
 1088|    198|    {
 1089|    198|      gpg_error_t err = gpg_error_from_syserror ();
 1090|    198|      log_error ("error reading rest of packet: %s\n", gpg_strerror (err));
 1091|    198|      return NULL;
 1092|    198|    }
 1093|  25.5k|  for (p = buf; pktlen; pktlen--)
  ------------------
  |  Branch (1093:17): [True: 22.8k, False: 2.66k]
  ------------------
 1094|  22.8k|    {
 1095|  22.8k|      c = iobuf_get (inp);
  ------------------
  |  |  500|  22.8k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 22.8k]
  |  |  |  Branch (500:24): [True: 169, False: 22.6k]
  |  |  ------------------
  |  |  501|  22.8k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
 1096|  22.8k|      if (c == -1)
  ------------------
  |  Branch (1096:11): [True: 162, False: 22.6k]
  ------------------
 1097|    162|        {
 1098|    162|          log_error ("premature eof while reading rest of packet\n");
 1099|    162|          xfree (buf);
  ------------------
  |  |  104|    162|#define xfree(a)         gcry_free ((a))
  ------------------
 1100|    162|          return NULL;
 1101|    162|        }
 1102|  22.6k|      *p++ = c;
 1103|  22.6k|    }
 1104|       |
 1105|  2.66k|  return buf;
 1106|  2.82k|}
parse-packet.c:sos_read:
  204|    307|{
  205|    307|  int c, c1, c2, i;
  206|    307|  unsigned int nmax = *ret_nread;
  207|    307|  unsigned int nbits, nbytes;
  208|    307|  size_t nread = 0;
  209|    307|  gcry_mpi_t a = NULL;
  210|    307|  byte *buf = NULL;
  211|    307|  byte *p;
  212|       |
  213|    307|  if (!nmax)
  ------------------
  |  Branch (213:7): [True: 0, False: 307]
  ------------------
  214|      0|    goto overflow;
  215|       |
  216|    307|  if ((c = c1 = iobuf_get (inp)) == -1)
  ------------------
  |  |  500|    307|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 307]
  |  |  |  Branch (500:24): [True: 1, False: 306]
  |  |  ------------------
  |  |  501|    307|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (216:7): [True: 1, False: 306]
  ------------------
  217|      1|    goto leave;
  218|    306|  if (++nread == nmax)
  ------------------
  |  Branch (218:7): [True: 0, False: 306]
  ------------------
  219|      0|    goto overflow;
  220|    306|  nbits = c << 8;
  221|    306|  if ((c = c2 = iobuf_get (inp)) == -1)
  ------------------
  |  |  500|    306|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 306]
  |  |  |  Branch (500:24): [True: 0, False: 306]
  |  |  ------------------
  |  |  501|    306|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (221:7): [True: 0, False: 306]
  ------------------
  222|      0|    goto leave;
  223|    306|  ++nread;
  224|    306|  nbits |= c;
  225|    306|  if (nbits > MAX_EXTERN_MPI_BITS)
  ------------------
  |  |   42|    306|#define MAX_EXTERN_MPI_BITS 16384
  ------------------
  |  Branch (225:7): [True: 1, False: 305]
  ------------------
  226|      1|    {
  227|      1|      log_error ("mpi too large (%u bits)\n", nbits);
  228|      1|      goto leave;
  229|      1|    }
  230|       |
  231|    305|  nbytes = (nbits + 7) / 8;
  232|    305|  buf = secure ? gcry_xmalloc_secure (nbytes) : gcry_xmalloc (nbytes);
  ------------------
  |  Branch (232:9): [True: 0, False: 305]
  ------------------
  233|    305|  p = buf;
  234|  11.3k|  for (i = 0; i < nbytes; i++)
  ------------------
  |  Branch (234:15): [True: 11.0k, False: 305]
  ------------------
  235|  11.0k|    {
  236|  11.0k|      if (nread == nmax)
  ------------------
  |  Branch (236:11): [True: 0, False: 11.0k]
  ------------------
  237|      0|        goto overflow;
  238|       |
  239|  11.0k|      c = iobuf_get (inp);
  ------------------
  |  |  500|  11.0k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 11.0k]
  |  |  |  Branch (500:24): [True: 0, False: 11.0k]
  |  |  ------------------
  |  |  501|  11.0k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  240|  11.0k|      if (c == -1)
  ------------------
  |  Branch (240:11): [True: 0, False: 11.0k]
  ------------------
  241|      0|        goto leave;
  242|       |
  243|  11.0k|      p[i] = c;
  244|  11.0k|      nread ++;
  245|  11.0k|    }
  246|       |
  247|    305|  a = gcry_mpi_set_opaque (NULL, buf, nbits);
  248|    305|  gcry_mpi_set_flag (a, GCRYMPI_FLAG_USER2);
  249|    305|  *ret_nread = nread;
  250|    305|  return a;
  251|       |
  252|      0| overflow:
  253|      0|  log_error ("mpi larger than indicated length (%u bits)\n", 8*nmax);
  254|      2| leave:
  255|      2|  *ret_nread = nread;
  256|      2|  gcry_free(buf);
  257|      2|  return a;
  258|      0|}
parse-packet.c:mpi_read:
  130|    925|{
  131|    925|  int c, c1, c2, i;
  132|    925|  unsigned int nmax = *ret_nread;
  133|    925|  unsigned int nbits, nbytes;
  134|    925|  size_t nread = 0;
  135|    925|  gcry_mpi_t a = NULL;
  136|    925|  byte *buf = NULL;
  137|    925|  byte *p;
  138|       |
  139|    925|  if (!nmax)
  ------------------
  |  Branch (139:7): [True: 0, False: 925]
  ------------------
  140|      0|    goto overflow;
  141|       |
  142|    925|  if ((c = c1 = iobuf_get (inp)) == -1)
  ------------------
  |  |  500|    925|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 925]
  |  |  |  Branch (500:24): [True: 0, False: 925]
  |  |  ------------------
  |  |  501|    925|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (142:7): [True: 0, False: 925]
  ------------------
  143|      0|    goto leave;
  144|    925|  if (++nread == nmax)
  ------------------
  |  Branch (144:7): [True: 0, False: 925]
  ------------------
  145|      0|    goto overflow;
  146|    925|  nbits = c << 8;
  147|    925|  if ((c = c2 = iobuf_get (inp)) == -1)
  ------------------
  |  |  500|    925|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 925]
  |  |  |  Branch (500:24): [True: 0, False: 925]
  |  |  ------------------
  |  |  501|    925|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  |  Branch (147:7): [True: 0, False: 925]
  ------------------
  148|      0|    goto leave;
  149|    925|  ++nread;
  150|    925|  nbits |= c;
  151|    925|  if (nbits > MAX_EXTERN_MPI_BITS)
  ------------------
  |  |   42|    925|#define MAX_EXTERN_MPI_BITS 16384
  ------------------
  |  Branch (151:7): [True: 1, False: 924]
  ------------------
  152|      1|    {
  153|      1|      log_error ("mpi too large (%u bits)\n", nbits);
  154|      1|      goto leave;
  155|      1|    }
  156|       |
  157|    924|  nbytes = (nbits + 7) / 8;
  158|    924|  buf = secure ? gcry_xmalloc_secure (nbytes + 2) : gcry_xmalloc (nbytes + 2);
  ------------------
  |  Branch (158:9): [True: 0, False: 924]
  ------------------
  159|    924|  p = buf;
  160|    924|  p[0] = c1;
  161|    924|  p[1] = c2;
  162|  20.3k|  for (i = 0; i < nbytes; i++)
  ------------------
  |  Branch (162:15): [True: 19.4k, False: 921]
  ------------------
  163|  19.4k|    {
  164|  19.4k|      if (nread == nmax)
  ------------------
  |  Branch (164:11): [True: 1, False: 19.4k]
  ------------------
  165|      1|	goto overflow;
  166|       |
  167|  19.4k|      c = iobuf_get (inp);
  ------------------
  |  |  500|  19.4k|     (	((a)->nofast || (a)->d.start >= (a)->d.len )?  \
  |  |  ------------------
  |  |  |  Branch (500:9): [True: 0, False: 19.4k]
  |  |  |  Branch (500:24): [True: 131, False: 19.3k]
  |  |  ------------------
  |  |  501|  19.4k|	iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
  ------------------
  168|  19.4k|      if (c == -1)
  ------------------
  |  Branch (168:11): [True: 2, False: 19.4k]
  ------------------
  169|      2|	goto leave;
  170|       |
  171|  19.4k|      p[i + 2] = c;
  172|  19.4k|      nread ++;
  173|  19.4k|    }
  174|       |
  175|    921|  if (gcry_mpi_scan (&a, GCRYMPI_FMT_PGP, buf, nread, &nread))
  ------------------
  |  Branch (175:7): [True: 0, False: 921]
  ------------------
  176|      0|    a = NULL;
  177|       |
  178|    921|  *ret_nread = nread;
  179|    921|  gcry_free(buf);
  180|    921|  return a;
  181|       |
  182|      1| overflow:
  183|      1|  log_error ("mpi larger than indicated length (%u bits)\n", 8*nmax);
  184|      4| leave:
  185|      4|  *ret_nread = nread;
  186|      4|  gcry_free(buf);
  187|      4|  return a;
  188|      1|}

pk_verify:
  208|     31|{
  209|     31|  gcry_sexp_t s_sig, s_hash, s_pkey;
  210|     31|  int rc;
  211|       |
  212|       |  /* Make a sexp from pkey.  */
  213|     31|  if (pkalgo == PUBKEY_ALGO_DSA)
  ------------------
  |  Branch (213:7): [True: 0, False: 31]
  ------------------
  214|      0|    {
  215|      0|      rc = gcry_sexp_build (&s_pkey, NULL,
  216|      0|			    "(public-key(dsa(p%m)(q%m)(g%m)(y%m)))",
  217|      0|			    pkey[0], pkey[1], pkey[2], pkey[3]);
  218|      0|    }
  219|     31|  else if (pkalgo == PUBKEY_ALGO_ELGAMAL_E || pkalgo == PUBKEY_ALGO_ELGAMAL)
  ------------------
  |  Branch (219:12): [True: 0, False: 31]
  |  Branch (219:47): [True: 0, False: 31]
  ------------------
  220|      0|    {
  221|      0|      rc = gcry_sexp_build (&s_pkey, NULL,
  222|      0|			    "(public-key(elg(p%m)(g%m)(y%m)))",
  223|      0|			    pkey[0], pkey[1], pkey[2]);
  224|      0|    }
  225|     31|  else if (pkalgo == PUBKEY_ALGO_RSA || pkalgo == PUBKEY_ALGO_RSA_S)
  ------------------
  |  Branch (225:12): [True: 15, False: 16]
  |  Branch (225:41): [True: 0, False: 16]
  ------------------
  226|     15|    {
  227|     15|      rc = gcry_sexp_build (&s_pkey, NULL,
  228|     15|			    "(public-key(rsa(n%m)(e%m)))", pkey[0], pkey[1]);
  229|     15|    }
  230|     16|  else if (pkalgo == PUBKEY_ALGO_ECDSA)
  ------------------
  |  Branch (230:12): [True: 16, False: 0]
  ------------------
  231|     16|    {
  232|     16|      char *curve = openpgp_oid_to_str (pkey[0]);
  233|     16|      if (!curve)
  ------------------
  |  Branch (233:11): [True: 0, False: 16]
  ------------------
  234|      0|        rc = gpg_error_from_syserror ();
  235|     16|      else
  236|     16|        {
  237|     16|          rc = gcry_sexp_build (&s_pkey, NULL,
  238|     16|                                "(public-key(ecdsa(curve %s)(q%m)))",
  239|     16|                                curve, pkey[1]);
  240|     16|          xfree (curve);
  ------------------
  |  |  104|     16|#define xfree(a)         gcry_free ((a))
  ------------------
  241|     16|        }
  242|     16|    }
  243|      0|  else if (pkalgo == PUBKEY_ALGO_EDDSA)
  ------------------
  |  Branch (243:12): [True: 0, False: 0]
  ------------------
  244|      0|    {
  245|      0|      char *curve = openpgp_oid_to_str (pkey[0]);
  246|      0|      if (!curve)
  ------------------
  |  Branch (246:11): [True: 0, False: 0]
  ------------------
  247|      0|        rc = gpg_error_from_syserror ();
  248|      0|      else
  249|      0|        {
  250|      0|          const char *fmt;
  251|       |
  252|      0|          if (openpgp_oid_is_ed25519 (pkey[0]))
  ------------------
  |  Branch (252:15): [True: 0, False: 0]
  ------------------
  253|      0|            fmt = "(public-key(ecc(curve %s)(flags eddsa)(q%m)))";
  254|      0|          else
  255|      0|            fmt = "(public-key(ecc(curve %s)(q%m)))";
  256|       |
  257|      0|          rc = gcry_sexp_build (&s_pkey, NULL, fmt, curve, pkey[1]);
  258|      0|          xfree (curve);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  259|      0|        }
  260|      0|    }
  261|      0|  else
  262|      0|    return GPG_ERR_PUBKEY_ALGO;
  263|       |
  264|     31|  if (rc)
  ------------------
  |  Branch (264:7): [True: 0, False: 31]
  ------------------
  265|      0|    BUG ();  /* gcry_sexp_build should never fail.  */
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  266|       |
  267|       |  /* Put hash into a S-Exp s_hash. */
  268|     31|  if (pkalgo == PUBKEY_ALGO_EDDSA)
  ------------------
  |  Branch (268:7): [True: 0, False: 31]
  ------------------
  269|      0|    {
  270|      0|      const char *fmt;
  271|       |
  272|      0|      if (openpgp_oid_is_ed25519 (pkey[0]))
  ------------------
  |  Branch (272:11): [True: 0, False: 0]
  ------------------
  273|      0|        fmt = "(data(flags eddsa)(hash-algo sha512)(value %m))";
  274|      0|      else
  275|      0|        fmt = "(data(value %m))";
  276|       |
  277|      0|      if (gcry_sexp_build (&s_hash, NULL, fmt, hash))
  ------------------
  |  Branch (277:11): [True: 0, False: 0]
  ------------------
  278|      0|        BUG (); /* gcry_sexp_build should never fail.  */
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  279|      0|    }
  280|     31|  else
  281|     31|    {
  282|     31|      if (gcry_sexp_build (&s_hash, NULL, "%m", hash))
  ------------------
  |  Branch (282:11): [True: 0, False: 31]
  ------------------
  283|      0|        BUG (); /* gcry_sexp_build should never fail.  */
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  284|     31|    }
  285|       |
  286|       |  /* Put data into a S-Exp s_sig. */
  287|     31|  s_sig = NULL;
  288|     31|  if (pkalgo == PUBKEY_ALGO_DSA)
  ------------------
  |  Branch (288:7): [True: 0, False: 31]
  ------------------
  289|      0|    {
  290|      0|      if (!data[0] || !data[1])
  ------------------
  |  Branch (290:11): [True: 0, False: 0]
  |  Branch (290:23): [True: 0, False: 0]
  ------------------
  291|      0|        rc = gpg_error (GPG_ERR_BAD_MPI);
  292|      0|      else
  293|      0|        rc = gcry_sexp_build (&s_sig, NULL,
  294|      0|                              "(sig-val(dsa(r%m)(s%m)))", data[0], data[1]);
  295|      0|    }
  296|     31|  else if (pkalgo == PUBKEY_ALGO_ECDSA)
  ------------------
  |  Branch (296:12): [True: 16, False: 15]
  ------------------
  297|     16|    {
  298|     16|      if (!data[0] || !data[1])
  ------------------
  |  Branch (298:11): [True: 0, False: 16]
  |  Branch (298:23): [True: 0, False: 16]
  ------------------
  299|      0|        rc = gpg_error (GPG_ERR_BAD_MPI);
  300|     16|      else
  301|     16|        rc = gcry_sexp_build (&s_sig, NULL,
  302|     16|                              "(sig-val(ecdsa(r%m)(s%m)))", data[0], data[1]);
  303|     16|    }
  304|     15|  else if (pkalgo == PUBKEY_ALGO_EDDSA)
  ------------------
  |  Branch (304:12): [True: 0, False: 15]
  ------------------
  305|      0|    {
  306|      0|      gcry_mpi_t r = data[0];
  307|      0|      gcry_mpi_t s = data[1];
  308|       |
  309|      0|      if (openpgp_oid_is_ed25519 (pkey[0]))
  ------------------
  |  Branch (309:11): [True: 0, False: 0]
  ------------------
  310|      0|        {
  311|      0|          size_t rlen, slen, n;  /* (bytes) */
  312|      0|          char buf[64];
  313|      0|          unsigned int nbits;
  314|      0|          unsigned int neededfixedlen = 256 / 8;
  315|       |
  316|      0|          log_assert (neededfixedlen <= sizeof buf);
  317|       |
  318|      0|          if (!r || !s)
  ------------------
  |  Branch (318:15): [True: 0, False: 0]
  |  Branch (318:21): [True: 0, False: 0]
  ------------------
  319|      0|            rc = gpg_error (GPG_ERR_BAD_MPI);
  320|      0|          else if ((rlen = (gcry_mpi_get_nbits (r)+7)/8) > neededfixedlen || !rlen)
  ------------------
  |  Branch (320:20): [True: 0, False: 0]
  |  Branch (320:78): [True: 0, False: 0]
  ------------------
  321|      0|            rc = gpg_error (GPG_ERR_BAD_MPI);
  322|      0|          else if ((slen = (gcry_mpi_get_nbits (s)+7)/8) > neededfixedlen || !slen)
  ------------------
  |  Branch (322:20): [True: 0, False: 0]
  |  Branch (322:78): [True: 0, False: 0]
  ------------------
  323|      0|            rc = gpg_error (GPG_ERR_BAD_MPI);
  324|      0|          else
  325|      0|            {
  326|       |              /* We need to fixup the length in case of leading zeroes.
  327|       |               * OpenPGP does not allow leading zeroes and the parser for
  328|       |               * the signature packet has no information on the use curve,
  329|       |               * thus we need to do it here.  We won't do it for opaque
  330|       |               * MPIs under the assumption that they are known to be fine;
  331|       |               * we won't see them here anyway but the check is anyway
  332|       |               * required.  Fixme: A nifty feature for gcry_sexp_build
  333|       |               * would be a format to left pad the value (e.g. "%*M"). */
  334|      0|              rc = 0;
  335|       |
  336|      0|              if (rlen < neededfixedlen
  ------------------
  |  Branch (336:19): [True: 0, False: 0]
  ------------------
  337|      0|                  && !gcry_mpi_get_flag (r, GCRYMPI_FLAG_OPAQUE)
  ------------------
  |  Branch (337:22): [True: 0, False: 0]
  ------------------
  338|      0|                  && !(rc=gcry_mpi_print (GCRYMPI_FMT_USG, buf, sizeof buf, &n, r)))
  ------------------
  |  Branch (338:22): [True: 0, False: 0]
  ------------------
  339|      0|                {
  340|      0|                  log_assert (n < neededfixedlen);
  341|      0|                  memmove (buf + (neededfixedlen - n), buf, n);
  342|      0|                  memset (buf, 0, neededfixedlen - n);
  343|      0|                  r = gcry_mpi_set_opaque_copy (NULL, buf, neededfixedlen * 8);
  344|      0|                }
  345|      0|              else if (rlen < neededfixedlen
  ------------------
  |  Branch (345:24): [True: 0, False: 0]
  ------------------
  346|      0|                       && gcry_mpi_get_flag (r, GCRYMPI_FLAG_OPAQUE))
  ------------------
  |  Branch (346:27): [True: 0, False: 0]
  ------------------
  347|      0|                {
  348|      0|                  const unsigned char *p;
  349|       |
  350|      0|                  p = gcry_mpi_get_opaque (r, &nbits);
  351|      0|                  n = (nbits+7)/8;
  352|      0|                  memcpy (buf + (neededfixedlen - n), p, n);
  353|      0|                  memset (buf, 0, neededfixedlen - n);
  354|      0|                  gcry_mpi_set_opaque_copy (r, buf, neededfixedlen * 8);
  355|      0|                }
  356|      0|              if (slen < neededfixedlen
  ------------------
  |  Branch (356:19): [True: 0, False: 0]
  ------------------
  357|      0|                  && !gcry_mpi_get_flag (s, GCRYMPI_FLAG_OPAQUE)
  ------------------
  |  Branch (357:22): [True: 0, False: 0]
  ------------------
  358|      0|                  && !(rc=gcry_mpi_print (GCRYMPI_FMT_USG, buf, sizeof buf, &n, s)))
  ------------------
  |  Branch (358:22): [True: 0, False: 0]
  ------------------
  359|      0|                {
  360|      0|                  log_assert (n < neededfixedlen);
  361|      0|                  memmove (buf + (neededfixedlen - n), buf, n);
  362|      0|                  memset (buf, 0, neededfixedlen - n);
  363|      0|                  s = gcry_mpi_set_opaque_copy (NULL, buf, neededfixedlen * 8);
  364|      0|                }
  365|      0|              else if (slen < neededfixedlen
  ------------------
  |  Branch (365:24): [True: 0, False: 0]
  ------------------
  366|      0|                       && gcry_mpi_get_flag (s, GCRYMPI_FLAG_OPAQUE))
  ------------------
  |  Branch (366:27): [True: 0, False: 0]
  ------------------
  367|      0|                {
  368|      0|                  const unsigned char *p;
  369|       |
  370|      0|                  p = gcry_mpi_get_opaque (s, &nbits);
  371|      0|                  n = (nbits+7)/8;
  372|      0|                  memcpy (buf + (neededfixedlen - n), p, n);
  373|      0|                  memset (buf, 0, neededfixedlen - n);
  374|      0|                  gcry_mpi_set_opaque_copy (s, buf, neededfixedlen * 8);
  375|      0|                }
  376|      0|            }
  377|      0|        }
  378|      0|      else
  379|      0|        rc = 0;
  380|       |
  381|      0|      if (!rc)
  ------------------
  |  Branch (381:11): [True: 0, False: 0]
  ------------------
  382|      0|        rc = gcry_sexp_build (&s_sig, NULL,
  383|      0|                              "(sig-val(eddsa(r%M)(s%M)))", r, s);
  384|       |
  385|      0|      if (r != data[0])
  ------------------
  |  Branch (385:11): [True: 0, False: 0]
  ------------------
  386|      0|        gcry_mpi_release (r);
  387|      0|      if (s != data[1])
  ------------------
  |  Branch (387:11): [True: 0, False: 0]
  ------------------
  388|      0|        gcry_mpi_release (s);
  389|      0|    }
  390|     15|  else if (pkalgo == PUBKEY_ALGO_ELGAMAL || pkalgo == PUBKEY_ALGO_ELGAMAL_E)
  ------------------
  |  Branch (390:12): [True: 0, False: 15]
  |  Branch (390:45): [True: 0, False: 15]
  ------------------
  391|      0|    {
  392|      0|      if (!data[0] || !data[1])
  ------------------
  |  Branch (392:11): [True: 0, False: 0]
  |  Branch (392:23): [True: 0, False: 0]
  ------------------
  393|      0|        rc = gpg_error (GPG_ERR_BAD_MPI);
  394|      0|      else
  395|      0|        rc = gcry_sexp_build (&s_sig, NULL,
  396|      0|                              "(sig-val(elg(r%m)(s%m)))", data[0], data[1]);
  397|      0|    }
  398|     15|  else if (pkalgo == PUBKEY_ALGO_RSA || pkalgo == PUBKEY_ALGO_RSA_S)
  ------------------
  |  Branch (398:12): [True: 15, False: 0]
  |  Branch (398:41): [True: 0, False: 0]
  ------------------
  399|     15|    {
  400|     15|      if (!data[0])
  ------------------
  |  Branch (400:11): [True: 0, False: 15]
  ------------------
  401|      0|        rc = gpg_error (GPG_ERR_BAD_MPI);
  402|     15|      else
  403|     15|        rc = gcry_sexp_build (&s_sig, NULL, "(sig-val(rsa(s%m)))", data[0]);
  404|     15|    }
  405|      0|  else
  406|      0|    BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  407|       |
  408|     31|  if (!rc)
  ------------------
  |  Branch (408:7): [True: 31, False: 0]
  ------------------
  409|     31|    rc = gcry_pk_verify (s_sig, s_hash, s_pkey);
  410|       |
  411|     31|  gcry_sexp_release (s_sig);
  412|     31|  gcry_sexp_release (s_hash);
  413|     31|  gcry_sexp_release (s_pkey);
  414|     31|  return rc;
  415|     31|}

encode_md_value:
  257|    158|{
  258|    158|  gcry_mpi_t frame;
  259|    158|  size_t mdlen;
  260|       |
  261|    158|  log_assert (hash_algo);
  262|      0|  log_assert (pk);
  263|       |
  264|    158|  if (pk->pubkey_algo == PUBKEY_ALGO_EDDSA)
  ------------------
  |  Branch (264:7): [True: 0, False: 158]
  ------------------
  265|      0|    {
  266|       |      /* EdDSA signs data of arbitrary length.  Thus no special
  267|       |         treatment is required.  */
  268|      0|      frame = gcry_mpi_set_opaque_copy (NULL, gcry_md_read (md, hash_algo),
  269|      0|                                        8*gcry_md_get_algo_dlen (hash_algo));
  270|      0|    }
  271|    158|  else if (pk->pubkey_algo == PUBKEY_ALGO_DSA
  ------------------
  |  Branch (271:12): [True: 0, False: 158]
  ------------------
  272|    158|           || pk->pubkey_algo == PUBKEY_ALGO_ECDSA)
  ------------------
  |  Branch (272:15): [True: 16, False: 142]
  ------------------
  273|     16|    {
  274|       |      /* It's a DSA signature, so find out the size of q.  */
  275|       |
  276|     16|      size_t qbits = gcry_mpi_get_nbits (pk->pkey[1]);
  277|       |
  278|       |      /* pkey[1] is Q for ECDSA, which is an uncompressed point,
  279|       |         i.e.  04 <x> <y>  */
  280|     16|      if (pk->pubkey_algo == PUBKEY_ALGO_ECDSA)
  ------------------
  |  Branch (280:11): [True: 16, False: 0]
  ------------------
  281|     16|        qbits = ecdsa_qbits_from_Q (qbits);
  282|       |
  283|       |      /* Make sure it is a multiple of 8 bits. */
  284|     16|      if ((qbits%8))
  ------------------
  |  Branch (284:11): [True: 0, False: 16]
  ------------------
  285|      0|	{
  286|      0|	  log_error(_("DSA requires the hash length to be a"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  287|      0|		      " multiple of 8 bits\n"));
  288|      0|	  return NULL;
  289|      0|	}
  290|       |
  291|       |      /* Don't allow any q smaller than 160 bits.  This might need a
  292|       |	 revisit as the DSA2 design firms up, but for now, we don't
  293|       |	 want someone to issue signatures from a key with a 16-bit q
  294|       |	 or something like that, which would look correct but allow
  295|       |	 trivial forgeries.  Yes, I know this rules out using MD5 with
  296|       |	 DSA. ;) */
  297|     16|      if (qbits < 160)
  ------------------
  |  Branch (297:11): [True: 0, False: 16]
  ------------------
  298|      0|	{
  299|      0|	  log_error (_("%s key %s uses an unsafe (%zu bit) hash\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  300|      0|                     openpgp_pk_algo_name (pk->pubkey_algo),
  301|      0|                     keystr_from_pk (pk), qbits);
  302|      0|	  return NULL;
  303|      0|	}
  304|       |
  305|       |
  306|       |      /* ECDSA 521 is special has it is larger than the largest hash
  307|       |         we have (SHA-512).  Thus we change the size for further
  308|       |         processing to 512.  */
  309|     16|      if (pk->pubkey_algo == PUBKEY_ALGO_ECDSA && qbits > 512)
  ------------------
  |  Branch (309:11): [True: 16, False: 0]
  |  Branch (309:51): [True: 0, False: 16]
  ------------------
  310|      0|        qbits = 512;
  311|       |
  312|       |      /* Check if we're too short.  Too long is safe as we'll
  313|       |	 automatically left-truncate.  */
  314|     16|      mdlen = gcry_md_get_algo_dlen (hash_algo);
  315|     16|      if (mdlen < qbits/8)
  ------------------
  |  Branch (315:11): [True: 0, False: 16]
  ------------------
  316|      0|	{
  317|      0|	  log_error (_("%s key %s requires a %zu bit or larger hash "
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  318|      0|                       "(hash is %s)\n"),
  319|      0|                     openpgp_pk_algo_name (pk->pubkey_algo),
  320|      0|                     keystr_from_pk (pk), qbits,
  321|      0|                     gcry_md_algo_name (hash_algo));
  322|      0|	  return NULL;
  323|      0|	}
  324|       |
  325|       |     /* Note that we do the truncation by passing QBITS/8 as length to
  326|       |        mpi_scan.  */
  327|     16|      if (gcry_mpi_scan (&frame, GCRYMPI_FMT_USG,
  ------------------
  |  Branch (327:11): [True: 0, False: 16]
  ------------------
  328|     16|                         gcry_md_read (md, hash_algo), qbits/8, NULL))
  329|      0|        BUG();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  330|     16|    }
  331|    142|  else
  332|    142|    {
  333|    142|      gpg_error_t rc;
  334|    142|      byte *asn;
  335|    142|      size_t asnlen;
  336|       |
  337|    142|      rc = gcry_md_algo_info (hash_algo, GCRYCTL_GET_ASNOID, NULL, &asnlen);
  338|    142|      if (rc)
  ------------------
  |  Branch (338:11): [True: 0, False: 142]
  ------------------
  339|      0|        log_fatal ("can't get OID of digest algorithm %d: %s\n",
  340|      0|                   hash_algo, gpg_strerror (rc));
  341|    142|      asn = xtrymalloc (asnlen);
  ------------------
  |  |   97|    142|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  342|    142|      if (!asn)
  ------------------
  |  Branch (342:11): [True: 0, False: 142]
  ------------------
  343|      0|        return NULL;
  344|    142|      if ( gcry_md_algo_info (hash_algo, GCRYCTL_GET_ASNOID, asn, &asnlen) )
  ------------------
  |  Branch (344:12): [True: 0, False: 142]
  ------------------
  345|      0|        BUG();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  346|    142|      frame = do_encode_md (md, hash_algo, gcry_md_get_algo_dlen (hash_algo),
  347|    142|                            gcry_mpi_get_nbits (pk->pkey[0]), asn, asnlen);
  348|    142|      xfree (asn);
  ------------------
  |  |  104|    142|#define xfree(a)         gcry_free ((a))
  ------------------
  349|    142|    }
  350|       |
  351|    158|  return frame;
  352|    158|}
seskey.c:do_encode_md:
  201|    142|{
  202|    142|    size_t nframe = (nbits+7) / 8;
  203|    142|    byte *frame;
  204|    142|    int i,n;
  205|    142|    gcry_mpi_t a;
  206|       |
  207|    142|    if (len + asnlen + 4  > nframe)
  ------------------
  |  Branch (207:9): [True: 127, False: 15]
  ------------------
  208|    127|      {
  209|    127|        log_error ("can't encode a %d bit MD into a %d bits frame, algo=%d\n",
  210|    127|                   (int)(len*8), (int)nbits, algo);
  211|    127|        return NULL;
  212|    127|      }
  213|       |
  214|       |    /* We encode the MD in this way:
  215|       |     *
  216|       |     *	   0  1 PAD(n bytes)   0  ASN(asnlen bytes)  MD(len bytes)
  217|       |     *
  218|       |     * PAD consists of FF bytes.
  219|       |     */
  220|     15|    frame = gcry_md_is_secure (md)? xmalloc_secure (nframe) : xmalloc (nframe);
  ------------------
  |  |  108|      0|#define xmalloc_secure(a)  gcry_xmalloc_secure ((a))
  ------------------
                  frame = gcry_md_is_secure (md)? xmalloc_secure (nframe) : xmalloc (nframe);
  ------------------
  |  |  107|     30|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  |  Branch (220:13): [True: 0, False: 15]
  ------------------
  221|     15|    n = 0;
  222|     15|    frame[n++] = 0;
  223|     15|    frame[n++] = 1; /* block type */
  224|     15|    i = nframe - len - asnlen -3 ;
  225|     15|    log_assert( i > 1 );
  226|      0|    memset( frame+n, 0xff, i ); n += i;
  227|     15|    frame[n++] = 0;
  228|     15|    memcpy( frame+n, asn, asnlen ); n += asnlen;
  229|     15|    memcpy( frame+n, gcry_md_read (md, algo), len ); n += len;
  230|     15|    log_assert( n == nframe );
  231|       |
  232|     15|    if (gcry_mpi_scan( &a, GCRYMPI_FMT_USG, frame, n, &nframe ))
  ------------------
  |  Branch (232:9): [True: 0, False: 15]
  ------------------
  233|      0|	BUG();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  234|     15|    xfree(frame);
  ------------------
  |  |  104|     15|#define xfree(a)         gcry_free ((a))
  ------------------
  235|       |
  236|       |    /* Note that PGP before version 2.3 encoded the MD as:
  237|       |     *
  238|       |     *   0   1   MD(16 bytes)   0   PAD(n bytes)   1
  239|       |     *
  240|       |     * The MD is always 16 bytes here because it's always MD5.  We do
  241|       |     * not support pre-v2.3 signatures, but I'm including this comment
  242|       |     * so the information is easily found in the future.
  243|       |     */
  244|       |
  245|     15|    return a;
  246|     15|}

check_key_signature:
  870|    429|{
  871|    429|  return check_key_signature2 (ctrl, root, node, NULL, NULL,
  872|    429|                               is_selfsig, NULL, NULL);
  873|    429|}
check_signature_over_key_or_uid:
  913|   126k|{
  914|   126k|  int rc;
  915|   126k|  PKT_public_key *pripk = kb->pkt->pkt.public_key;
  916|   126k|  gcry_md_hd_t md;
  917|   126k|  int signer_alloced = 0;
  918|   126k|  int stub_is_selfsig;
  919|       |
  920|   126k|  if (!is_selfsig)
  ------------------
  |  Branch (920:7): [True: 126k, False: 0]
  ------------------
  921|   126k|    is_selfsig = &stub_is_selfsig;
  922|       |
  923|   126k|  rc = openpgp_pk_test_algo (sig->pubkey_algo);
  924|   126k|  if (rc)
  ------------------
  |  Branch (924:7): [True: 0, False: 126k]
  ------------------
  925|      0|    return rc;
  926|   126k|  rc = openpgp_md_test_algo (sig->digest_algo);
  927|   126k|  if (rc)
  ------------------
  |  Branch (927:7): [True: 0, False: 126k]
  ------------------
  928|      0|    return rc;
  929|       |
  930|       |  /* A signature's class indicates the type of packet that it
  931|       |     signs.  */
  932|   126k|  if (IS_BACK_SIG (sig) || IS_KEY_SIG (sig) || IS_KEY_REV (sig))
  ------------------
  |  |   44|   252k|#define IS_BACK_SIG(s)   ((s)->sig_class == 0x19)
  |  |  ------------------
  |  |  |  Branch (44:26): [True: 0, False: 126k]
  |  |  ------------------
  ------------------
                if (IS_BACK_SIG (sig) || IS_KEY_SIG (sig) || IS_KEY_REV (sig))
  ------------------
  |  |   40|   252k|#define IS_KEY_SIG(s)    ((s)->sig_class == 0x1f)
  |  |  ------------------
  |  |  |  Branch (40:26): [True: 0, False: 126k]
  |  |  ------------------
  ------------------
                if (IS_BACK_SIG (sig) || IS_KEY_SIG (sig) || IS_KEY_REV (sig))
  ------------------
  |  |   45|   126k|#define IS_KEY_REV(s)    ((s)->sig_class == 0x20)
  |  |  ------------------
  |  |  |  Branch (45:26): [True: 48.2k, False: 77.8k]
  |  |  ------------------
  ------------------
  933|  48.2k|    {
  934|       |      /* Key revocations can only be over primary keys.  */
  935|  48.2k|      if (packet->pkttype != PKT_PUBLIC_KEY)
  ------------------
  |  Branch (935:11): [True: 48.1k, False: 127]
  ------------------
  936|  48.1k|        return gpg_error (GPG_ERR_SIG_CLASS);
  937|  48.2k|    }
  938|  77.8k|  else if (IS_SUBKEY_SIG (sig) || IS_SUBKEY_REV (sig))
  ------------------
  |  |   43|   155k|#define IS_SUBKEY_SIG(s) ((s)->sig_class == 0x18)
  |  |  ------------------
  |  |  |  Branch (43:26): [True: 12, False: 77.8k]
  |  |  ------------------
  ------------------
                else if (IS_SUBKEY_SIG (sig) || IS_SUBKEY_REV (sig))
  ------------------
  |  |   47|  77.8k|#define IS_SUBKEY_REV(s) ((s)->sig_class == 0x28)
  |  |  ------------------
  |  |  |  Branch (47:26): [True: 77.8k, False: 55]
  |  |  ------------------
  ------------------
  939|  77.8k|    {
  940|  77.8k|      if (packet->pkttype != PKT_PUBLIC_SUBKEY)
  ------------------
  |  Branch (940:11): [True: 77.8k, False: 6]
  ------------------
  941|  77.8k|        return gpg_error (GPG_ERR_SIG_CLASS);
  942|  77.8k|    }
  943|     55|  else if (IS_UID_SIG (sig) || IS_UID_REV (sig))
  ------------------
  |  |   41|    110|#define IS_UID_SIG(s)    (((s)->sig_class & ~3) == 0x10)
  |  |  ------------------
  |  |  |  Branch (41:26): [True: 40, False: 15]
  |  |  ------------------
  ------------------
                else if (IS_UID_SIG (sig) || IS_UID_REV (sig))
  ------------------
  |  |   46|     15|#define IS_UID_REV(s)    ((s)->sig_class == 0x30)
  |  |  ------------------
  |  |  |  Branch (46:26): [True: 0, False: 15]
  |  |  ------------------
  ------------------
  944|     40|    {
  945|     40|      if (packet->pkttype != PKT_USER_ID)
  ------------------
  |  Branch (945:11): [True: 15, False: 25]
  ------------------
  946|     15|        return gpg_error (GPG_ERR_SIG_CLASS);
  947|     40|    }
  948|     15|  else
  949|     15|    return gpg_error (GPG_ERR_SIG_CLASS);
  950|       |
  951|       |  /* PACKET is the right type for SIG.  */
  952|       |
  953|    158|  if (signer)
  ------------------
  |  Branch (953:7): [True: 155, False: 3]
  ------------------
  954|    155|    {
  955|    155|      if (signer->keyid[0] == pripk->keyid[0]
  ------------------
  |  Branch (955:11): [True: 155, False: 0]
  ------------------
  956|    155|          && signer->keyid[1] == pripk->keyid[1])
  ------------------
  |  Branch (956:14): [True: 155, False: 0]
  ------------------
  957|    155|        *is_selfsig = 1;
  958|      0|      else
  959|      0|        *is_selfsig = 0;
  960|    155|    }
  961|      3|  else
  962|      3|    {
  963|       |      /* Get the signer.  If possible, avoid a look up.  */
  964|      3|      if (sig->keyid[0] == pripk->keyid[0]
  ------------------
  |  Branch (964:11): [True: 3, False: 0]
  ------------------
  965|      3|          && sig->keyid[1] == pripk->keyid[1])
  ------------------
  |  Branch (965:14): [True: 3, False: 0]
  ------------------
  966|      3|        {
  967|       |          /* Issued by the primary key.  */
  968|      3|          signer = pripk;
  969|      3|          *is_selfsig = 1;
  970|      3|        }
  971|      0|      else
  972|      0|        {
  973|       |          /* See if one of the subkeys was the signer (although this
  974|       |           * is extremely unlikely).  */
  975|      0|          kbnode_t ctx = NULL;
  976|      0|          kbnode_t n;
  977|       |
  978|      0|          while ((n = walk_kbnode (kb, &ctx, 0)))
  ------------------
  |  Branch (978:18): [True: 0, False: 0]
  ------------------
  979|      0|            {
  980|      0|              PKT_public_key *subk;
  981|       |
  982|      0|              if (n->pkt->pkttype != PKT_PUBLIC_SUBKEY)
  ------------------
  |  Branch (982:19): [True: 0, False: 0]
  ------------------
  983|      0|                continue;
  984|       |
  985|      0|              subk = n->pkt->pkt.public_key;
  986|      0|              if (sig->keyid[0] == subk->keyid[0]
  ------------------
  |  Branch (986:19): [True: 0, False: 0]
  ------------------
  987|      0|                  && sig->keyid[1] == subk->keyid[1])
  ------------------
  |  Branch (987:22): [True: 0, False: 0]
  ------------------
  988|      0|                {
  989|       |                  /* Issued by a subkey.  */
  990|      0|                  signer = subk;
  991|      0|                  break;
  992|      0|                }
  993|      0|            }
  994|       |
  995|      0|          if (! signer)
  ------------------
  |  Branch (995:15): [True: 0, False: 0]
  ------------------
  996|      0|            {
  997|       |              /* Signer by some other key.  */
  998|      0|              *is_selfsig = 0;
  999|      0|              if (ret_pk)
  ------------------
  |  Branch (999:19): [True: 0, False: 0]
  ------------------
 1000|      0|                {
 1001|      0|                  signer = ret_pk;
 1002|       |                  /* FIXME: Using memset here is probematic because it
 1003|       |                   * assumes that there are no allocated fields in
 1004|       |                   * SIGNER.  */
 1005|      0|                  memset (signer, 0, sizeof (*signer));
 1006|      0|                  signer_alloced = 1;
 1007|      0|                }
 1008|      0|              else
 1009|      0|                {
 1010|      0|                  signer = xmalloc_clear (sizeof (*signer));
  ------------------
  |  |  116|      0|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
 1011|      0|                  signer_alloced = 2;
 1012|      0|                }
 1013|       |
 1014|      0|              if (IS_CERT (sig))
  ------------------
  |  |   32|      0|#define IS_CERT(s)       (IS_KEY_SIG(s)       \
  |  |  ------------------
  |  |  |  |   40|      0|#define IS_KEY_SIG(s)    ((s)->sig_class == 0x1f)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (40:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   33|      0|                          || IS_UID_SIG(s)    \
  |  |  ------------------
  |  |  |  |   41|      0|#define IS_UID_SIG(s)    (((s)->sig_class & ~3) == 0x10)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (41:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   34|      0|                          || IS_SUBKEY_SIG(s) \
  |  |  ------------------
  |  |  |  |   43|      0|#define IS_SUBKEY_SIG(s) ((s)->sig_class == 0x18)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   35|      0|                          || IS_KEY_REV(s)    \
  |  |  ------------------
  |  |  |  |   45|      0|#define IS_KEY_REV(s)    ((s)->sig_class == 0x20)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   36|      0|                          || IS_UID_REV(s)    \
  |  |  ------------------
  |  |  |  |   46|      0|#define IS_UID_REV(s)    ((s)->sig_class == 0x30)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (46:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|      0|                          || IS_SUBKEY_REV(s) \
  |  |  ------------------
  |  |  |  |   47|      0|#define IS_SUBKEY_REV(s) ((s)->sig_class == 0x28)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (47:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|      0|                          || IS_ATTST_SIGS(s) )
  |  |  ------------------
  |  |  |  |   42|      0|#define IS_ATTST_SIGS(s) ((s)->sig_class == 0x16)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (42:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1015|      0|                signer->req_usage = PUBKEY_USAGE_CERT;
  ------------------
  |  |   51|      0|#define PUBKEY_USAGE_CERT    GCRY_PK_USAGE_CERT  /* Also good to certify keys.*/
  ------------------
 1016|       |
 1017|      0|              rc = get_pubkey_for_sig (ctrl, signer, sig, NULL);
 1018|      0|              if (rc)
  ------------------
  |  Branch (1018:19): [True: 0, False: 0]
  ------------------
 1019|      0|                {
 1020|      0|                  xfree (signer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1021|      0|                  signer = NULL;
 1022|      0|                  signer_alloced = 0;
 1023|      0|                  goto leave;
 1024|      0|                }
 1025|      0|            }
 1026|      0|        }
 1027|      3|    }
 1028|       |
 1029|       |  /* We checked above that we supported this algo, so an error here is
 1030|       |   * a bug.  */
 1031|    158|  if (gcry_md_open (&md, sig->digest_algo, 0))
  ------------------
  |  Branch (1031:7): [True: 0, False: 158]
  ------------------
 1032|      0|    BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1033|       |
 1034|       |  /* Hash the relevant data.  */
 1035|       |
 1036|    158|  if (IS_KEY_SIG (sig) || IS_KEY_REV (sig))
  ------------------
  |  |   40|    316|#define IS_KEY_SIG(s)    ((s)->sig_class == 0x1f)
  |  |  ------------------
  |  |  |  Branch (40:26): [True: 0, False: 158]
  |  |  ------------------
  ------------------
                if (IS_KEY_SIG (sig) || IS_KEY_REV (sig))
  ------------------
  |  |   45|    158|#define IS_KEY_REV(s)    ((s)->sig_class == 0x20)
  |  |  ------------------
  |  |  |  Branch (45:26): [True: 127, False: 31]
  |  |  ------------------
  ------------------
 1037|    127|    {
 1038|    127|      log_assert (packet->pkttype == PKT_PUBLIC_KEY);
 1039|      0|      hash_public_key (md, packet->pkt.public_key);
 1040|    127|      rc = check_signature_end_simple (signer, sig, md, NULL, 0);
 1041|    127|    }
 1042|     31|  else if (IS_BACK_SIG (sig))
  ------------------
  |  |   44|     31|#define IS_BACK_SIG(s)   ((s)->sig_class == 0x19)
  |  |  ------------------
  |  |  |  Branch (44:26): [True: 0, False: 31]
  |  |  ------------------
  ------------------
 1043|      0|    {
 1044|      0|      log_assert (packet->pkttype == PKT_PUBLIC_KEY);
 1045|      0|      hash_public_key (md, packet->pkt.public_key);
 1046|      0|      hash_public_key (md, signer);
 1047|      0|      rc = check_signature_end_simple (signer, sig, md, NULL, 0);
 1048|      0|    }
 1049|     31|  else if (IS_SUBKEY_SIG (sig) || IS_SUBKEY_REV (sig))
  ------------------
  |  |   43|     62|#define IS_SUBKEY_SIG(s) ((s)->sig_class == 0x18)
  |  |  ------------------
  |  |  |  Branch (43:26): [True: 6, False: 25]
  |  |  ------------------
  ------------------
                else if (IS_SUBKEY_SIG (sig) || IS_SUBKEY_REV (sig))
  ------------------
  |  |   47|     25|#define IS_SUBKEY_REV(s) ((s)->sig_class == 0x28)
  |  |  ------------------
  |  |  |  Branch (47:26): [True: 0, False: 25]
  |  |  ------------------
  ------------------
 1050|      6|    {
 1051|      6|      log_assert (packet->pkttype == PKT_PUBLIC_SUBKEY);
 1052|      0|      hash_public_key (md, pripk);
 1053|      6|      hash_public_key (md, packet->pkt.public_key);
 1054|      6|      rc = check_signature_end_simple (signer, sig, md, NULL, 0);
 1055|      6|    }
 1056|     25|  else if (IS_UID_SIG (sig) || IS_UID_REV (sig))
  ------------------
  |  |   41|     50|#define IS_UID_SIG(s)    (((s)->sig_class & ~3) == 0x10)
  |  |  ------------------
  |  |  |  Branch (41:26): [True: 25, False: 0]
  |  |  ------------------
  ------------------
                else if (IS_UID_SIG (sig) || IS_UID_REV (sig))
  ------------------
  |  |   46|      0|#define IS_UID_REV(s)    ((s)->sig_class == 0x30)
  |  |  ------------------
  |  |  |  Branch (46:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1057|     25|    {
 1058|     25|      log_assert (packet->pkttype == PKT_USER_ID);
 1059|     25|      if (sig->digest_algo == DIGEST_ALGO_SHA1 && !*is_selfsig
  ------------------
  |  Branch (1059:11): [True: 0, False: 25]
  |  Branch (1059:51): [True: 0, False: 0]
  ------------------
 1060|     25|          && !opt.flags.allow_weak_key_signatures)
  ------------------
  |  Branch (1060:14): [True: 0, False: 0]
  ------------------
 1061|      0|        {
 1062|       |          /* If the signature was created using SHA-1 we consider this
 1063|       |           * signature invalid because it makes it possible to mount a
 1064|       |           * chosen-prefix collision.  We don't do this for
 1065|       |           * self-signatures, though.  */
 1066|      0|          print_sha1_keysig_rejected_note ();
 1067|      0|          rc = gpg_error (GPG_ERR_DIGEST_ALGO);
 1068|      0|        }
 1069|     25|      else
 1070|     25|        {
 1071|     25|          hash_public_key (md, pripk);
 1072|     25|          hash_uid_packet (packet->pkt.user_id, md, sig);
 1073|     25|          rc = check_signature_end_simple (signer, sig, md, NULL, 0);
 1074|     25|        }
 1075|     25|    }
 1076|      0|  else
 1077|      0|    {
 1078|       |      /* We should never get here.  (The first if above should have
 1079|       |       * already caught this error.)  */
 1080|      0|      BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1081|      0|    }
 1082|       |
 1083|    158|  gcry_md_close (md);
 1084|       |
 1085|    158| leave:
 1086|    158|  if (! rc && ret_pk && ret_pk != signer)
  ------------------
  |  Branch (1086:7): [True: 31, False: 127]
  |  Branch (1086:15): [True: 0, False: 31]
  |  Branch (1086:25): [True: 0, False: 0]
  ------------------
 1087|      0|    copy_public_key (ret_pk, signer);
 1088|       |
 1089|    158|  if (signer_alloced)
  ------------------
  |  Branch (1089:7): [True: 0, False: 158]
  ------------------
 1090|      0|    {
 1091|       |      /* We looked up SIGNER; it is not a pointer into KB.  */
 1092|      0|      release_public_key_parts (signer);
 1093|       |      /* Free if we also allocated the memory.  */
 1094|      0|      if (signer_alloced == 2)
  ------------------
  |  Branch (1094:11): [True: 0, False: 0]
  ------------------
 1095|      0|        xfree (signer);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1096|      0|    }
 1097|       |
 1098|    158|  return rc;
 1099|    158|}
check_key_signature2:
 1141|    429|{
 1142|    429|  PKT_public_key *pk;
 1143|    429|  PKT_signature *sig;
 1144|    429|  int algo;
 1145|    429|  int rc;
 1146|       |
 1147|    429|  if (is_selfsig)
  ------------------
  |  Branch (1147:7): [True: 0, False: 429]
  ------------------
 1148|      0|    *is_selfsig = 0;
 1149|    429|  if (r_expiredate)
  ------------------
  |  Branch (1149:7): [True: 0, False: 429]
  ------------------
 1150|      0|    *r_expiredate = 0;
 1151|    429|  if (r_expired)
  ------------------
  |  Branch (1151:7): [True: 0, False: 429]
  ------------------
 1152|      0|    *r_expired = 0;
 1153|    429|  log_assert (node->pkt->pkttype == PKT_SIGNATURE);
 1154|      0|  log_assert (root->pkt->pkttype == PKT_PUBLIC_KEY);
 1155|       |
 1156|      0|  pk = root->pkt->pkt.public_key;
 1157|    429|  sig = node->pkt->pkt.signature;
 1158|    429|  algo = sig->digest_algo;
 1159|       |
 1160|       |  /* Check whether we have cached the result of a previous signature
 1161|       |   * check.  Note that we may no longer have the pubkey or hash
 1162|       |   * needed to verify a sig, but can still use the cached value.  A
 1163|       |   * cache refresh detects and clears these cases. */
 1164|    429|  if ( !opt.no_sig_cache )
  ------------------
  |  Branch (1164:8): [True: 429, False: 0]
  ------------------
 1165|    429|    {
 1166|    429|      cache_stats.total++;
 1167|    429|      if (sig->flags.checked) /* Cached status available.  */
  ------------------
  |  Branch (1167:11): [True: 26, False: 403]
  ------------------
 1168|     26|        {
 1169|     26|          cache_stats.cached++;
 1170|     26|          if (is_selfsig)
  ------------------
  |  Branch (1170:15): [True: 0, False: 26]
  ------------------
 1171|      0|            {
 1172|      0|              u32 keyid[2];
 1173|       |
 1174|      0|              keyid_from_pk (pk, keyid);
 1175|      0|              if (keyid[0] == sig->keyid[0] && keyid[1] == sig->keyid[1])
  ------------------
  |  Branch (1175:19): [True: 0, False: 0]
  |  Branch (1175:48): [True: 0, False: 0]
  ------------------
 1176|      0|                *is_selfsig = 1;
 1177|      0|	    }
 1178|       |          /* BUG: This is wrong for non-self-sigs... needs to be the
 1179|       |           * actual pk.  */
 1180|     26|          rc = check_signature_metadata_validity (pk, sig, r_expired, NULL);
 1181|     26|          if (rc)
  ------------------
  |  Branch (1181:15): [True: 0, False: 26]
  ------------------
 1182|      0|            return rc;
 1183|     26|          if (sig->flags.valid)
  ------------------
  |  Branch (1183:15): [True: 26, False: 0]
  ------------------
 1184|     26|            {
 1185|     26|              cache_stats.goodsig++;
 1186|     26|              return 0;
 1187|     26|            }
 1188|      0|          cache_stats.badsig++;
 1189|      0|          return gpg_error (GPG_ERR_BAD_SIGNATURE);
 1190|     26|        }
 1191|    429|    }
 1192|       |
 1193|    403|  rc = openpgp_pk_test_algo(sig->pubkey_algo);
 1194|    403|  if (rc)
  ------------------
  |  Branch (1194:7): [True: 106, False: 297]
  ------------------
 1195|    106|    return rc;
 1196|    297|  rc = openpgp_md_test_algo(algo);
 1197|    297|  if (rc)
  ------------------
  |  Branch (1197:7): [True: 19, False: 278]
  ------------------
 1198|     19|    return rc;
 1199|       |
 1200|    278|  if (IS_KEY_REV (sig))
  ------------------
  |  |   45|    278|#define IS_KEY_REV(s)    ((s)->sig_class == 0x20)
  |  |  ------------------
  |  |  |  Branch (45:26): [True: 128, False: 150]
  |  |  ------------------
  ------------------
 1201|    128|    {
 1202|    128|      u32 keyid[2];
 1203|    128|      keyid_from_pk( pk, keyid );
 1204|       |
 1205|       |      /* Is it a designated revoker? */
 1206|    128|      if (keyid[0] != sig->keyid[0] || keyid[1] != sig->keyid[1])
  ------------------
  |  Branch (1206:11): [True: 0, False: 128]
  |  Branch (1206:40): [True: 0, False: 128]
  ------------------
 1207|      0|        rc = check_revocation_keys (ctrl, pk, sig);
 1208|    128|      else
 1209|    128|        {
 1210|    128|          rc = check_signature_metadata_validity (pk, sig,
 1211|    128|                                                  r_expired, NULL);
 1212|    128|          if (! rc)
  ------------------
  |  Branch (1212:15): [True: 0, False: 128]
  ------------------
 1213|      0|            rc = check_signature_over_key_or_uid (ctrl, pk, sig,
 1214|      0|                                                  root, root->pkt,
 1215|      0|                                                  is_selfsig, ret_pk);
 1216|    128|        }
 1217|    128|    }
 1218|    150|  else if (IS_SUBKEY_REV (sig) || IS_SUBKEY_SIG (sig))
  ------------------
  |  |   47|    300|#define IS_SUBKEY_REV(s) ((s)->sig_class == 0x28)
  |  |  ------------------
  |  |  |  Branch (47:26): [True: 128, False: 22]
  |  |  ------------------
  ------------------
                else if (IS_SUBKEY_REV (sig) || IS_SUBKEY_SIG (sig))
  ------------------
  |  |   43|     22|#define IS_SUBKEY_SIG(s) ((s)->sig_class == 0x18)
  |  |  ------------------
  |  |  |  Branch (43:26): [True: 3, False: 19]
  |  |  ------------------
  ------------------
 1219|    131|    {
 1220|    131|      kbnode_t snode = find_prev_kbnode (root, node, PKT_PUBLIC_SUBKEY);
 1221|       |
 1222|    131|      if (snode)
  ------------------
  |  Branch (1222:11): [True: 3, False: 128]
  ------------------
 1223|      3|        {
 1224|      3|          rc = check_signature_metadata_validity (pk, sig,
 1225|      3|                                                  r_expired, NULL);
 1226|      3|          if (! rc)
  ------------------
  |  Branch (1226:15): [True: 3, False: 0]
  ------------------
 1227|      3|            {
 1228|       |              /* A subkey revocation (0x28) must be a self-sig, but a
 1229|       |               * subkey signature (0x18) needn't be.  */
 1230|      3|              rc = check_signature_over_key_or_uid (ctrl,
 1231|      3|                                                    IS_SUBKEY_SIG (sig)
  ------------------
  |  |   43|      3|#define IS_SUBKEY_SIG(s) ((s)->sig_class == 0x18)
  |  |  ------------------
  |  |  |  Branch (43:26): [True: 3, False: 0]
  |  |  ------------------
  ------------------
 1232|      3|                                                    ? NULL : pk,
 1233|      3|                                                    sig, root, snode->pkt,
 1234|      3|                                                    is_selfsig, ret_pk);
 1235|      3|            }
 1236|      3|        }
 1237|    128|      else
 1238|    128|        {
 1239|    128|          if (opt.verbose)
  ------------------
  |  Branch (1239:15): [True: 0, False: 128]
  ------------------
 1240|      0|            {
 1241|      0|              if (IS_SUBKEY_REV (sig))
  ------------------
  |  |   47|      0|#define IS_SUBKEY_REV(s) ((s)->sig_class == 0x28)
  |  |  ------------------
  |  |  |  Branch (47:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1242|      0|                log_info (_("key %s: no subkey for subkey"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1243|      0|                            " revocation signature\n"), keystr_from_pk(pk));
 1244|      0|              else if (sig->sig_class == 0x18)
  ------------------
  |  Branch (1244:24): [True: 0, False: 0]
  ------------------
 1245|      0|                log_info(_("key %s: no subkey for subkey"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1246|      0|                           " binding signature\n"), keystr_from_pk(pk));
 1247|      0|            }
 1248|    128|          rc = GPG_ERR_SIG_CLASS;
 1249|    128|        }
 1250|    131|    }
 1251|     19|  else if (IS_KEY_SIG (sig)) /* direct key signature */
  ------------------
  |  |   40|     19|#define IS_KEY_SIG(s)    ((s)->sig_class == 0x1f)
  |  |  ------------------
  |  |  |  Branch (40:26): [True: 3, False: 16]
  |  |  ------------------
  ------------------
 1252|      3|      {
 1253|      3|        rc = check_signature_metadata_validity (pk, sig,
 1254|      3|                                                r_expired, NULL);
 1255|      3|        if (! rc)
  ------------------
  |  Branch (1255:13): [True: 0, False: 3]
  ------------------
 1256|      0|          rc = check_signature_over_key_or_uid (ctrl, pk, sig, root, root->pkt,
 1257|      0|                                                is_selfsig, ret_pk);
 1258|      3|      }
 1259|     16|    else if (IS_UID_SIG (sig) || IS_UID_REV (sig))
  ------------------
  |  |   41|     32|#define IS_UID_SIG(s)    (((s)->sig_class & ~3) == 0x10)
  |  |  ------------------
  |  |  |  Branch (41:26): [True: 11, False: 5]
  |  |  ------------------
  ------------------
                  else if (IS_UID_SIG (sig) || IS_UID_REV (sig))
  ------------------
  |  |   46|      5|#define IS_UID_REV(s)    ((s)->sig_class == 0x30)
  |  |  ------------------
  |  |  |  Branch (46:26): [True: 0, False: 5]
  |  |  ------------------
  ------------------
 1260|     11|      {
 1261|     11|	kbnode_t unode = find_prev_kbnode (root, node, PKT_USER_ID);
 1262|       |
 1263|     11|	if (unode)
  ------------------
  |  Branch (1263:6): [True: 11, False: 0]
  ------------------
 1264|     11|          {
 1265|     11|            rc = check_signature_metadata_validity (pk, sig, r_expired, NULL);
 1266|     11|            if (! rc)
  ------------------
  |  Branch (1266:17): [True: 11, False: 0]
  ------------------
 1267|     11|              {
 1268|       |                /* If this is a self-sig, ignore check_pk.  */
 1269|     11|                rc = check_signature_over_key_or_uid
 1270|     11|                  (ctrl,
 1271|     11|                   keyid_cmp (pk_keyid (pk), sig->keyid) == 0 ? pk : check_pk,
  ------------------
  |  Branch (1271:20): [True: 11, False: 0]
  ------------------
 1272|     11|                   sig, root, unode->pkt, NULL, ret_pk);
 1273|     11|              }
 1274|     11|          }
 1275|      0|	else
 1276|      0|	  {
 1277|      0|            if (!opt.quiet)
  ------------------
  |  Branch (1277:17): [True: 0, False: 0]
  ------------------
 1278|      0|	      log_info ("key %s: no user ID for key signature packet"
 1279|      0|			" of class %02x\n",keystr_from_pk(pk),sig->sig_class);
 1280|      0|	    rc = GPG_ERR_SIG_CLASS;
 1281|      0|	  }
 1282|     11|      }
 1283|      5|  else
 1284|      5|    {
 1285|      5|      log_info ("sig issued by %s with class %d (digest: %02x %02x)"
 1286|      5|                " is not valid over a user id or a key id, ignoring.\n",
 1287|      5|                keystr (sig->keyid), sig->sig_class,
 1288|      5|                sig->digest_start[0], sig->digest_start[1]);
 1289|      5|      rc = gpg_error (GPG_ERR_BAD_SIGNATURE);
 1290|      5|    }
 1291|       |
 1292|    278|  cache_sig_result  (sig, rc);
 1293|       |
 1294|    278|  return rc;
 1295|    297|}
sig-check.c:cache_sig_result:
  692|    278|{
  693|    278|  if (!result)
  ------------------
  |  Branch (693:7): [True: 14, False: 264]
  ------------------
  694|     14|    {
  695|     14|      sig->flags.checked = 1;
  696|     14|      sig->flags.valid = 1;
  697|     14|    }
  698|    264|  else if  (gpg_err_code (result) == GPG_ERR_BAD_SIGNATURE)
  ------------------
  |  Branch (698:13): [True: 5, False: 259]
  ------------------
  699|      5|    {
  700|      5|      sig->flags.checked = 1;
  701|      5|      sig->flags.valid = 0;
  702|      5|    }
  703|    259|  else
  704|    259|    {
  705|    259|      sig->flags.checked = 0;
  706|    259|      sig->flags.valid = 0;
  707|    259|    }
  708|    278|}
sig-check.c:check_signature_end_simple:
  508|    158|{
  509|    158|  gcry_mpi_t result = NULL;
  510|    158|  int rc = 0;
  511|       |
  512|    158|  if (!opt.flags.allow_weak_digest_algos)
  ------------------
  |  Branch (512:7): [True: 158, False: 0]
  ------------------
  513|    158|    {
  514|    158|      if (is_weak_digest (sig->digest_algo))
  ------------------
  |  Branch (514:11): [True: 0, False: 158]
  ------------------
  515|      0|        {
  516|      0|          print_digest_rejected_note (sig->digest_algo);
  517|      0|          return GPG_ERR_DIGEST_ALGO;
  518|      0|        }
  519|    158|    }
  520|       |
  521|       |  /* For key signatures check that the key has a cert usage.  We may
  522|       |   * do this only for subkeys because the primary may always issue key
  523|       |   * signature.  The latter may not be reflected in the pubkey_usage
  524|       |   * field because we need to check the key signatures to extract the
  525|       |   * key usage.  */
  526|    158|  if (!pk->flags.primary
  ------------------
  |  Branch (526:7): [True: 0, False: 158]
  ------------------
  527|    158|      && IS_CERT (sig) && !(pk->pubkey_usage & PUBKEY_USAGE_CERT))
  ------------------
  |  |   32|    158|#define IS_CERT(s)       (IS_KEY_SIG(s)       \
  |  |  ------------------
  |  |  |  |   40|      0|#define IS_KEY_SIG(s)    ((s)->sig_class == 0x1f)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (40:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   33|      0|                          || IS_UID_SIG(s)    \
  |  |  ------------------
  |  |  |  |   41|      0|#define IS_UID_SIG(s)    (((s)->sig_class & ~3) == 0x10)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (41:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   34|      0|                          || IS_SUBKEY_SIG(s) \
  |  |  ------------------
  |  |  |  |   43|      0|#define IS_SUBKEY_SIG(s) ((s)->sig_class == 0x18)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   35|      0|                          || IS_KEY_REV(s)    \
  |  |  ------------------
  |  |  |  |   45|      0|#define IS_KEY_REV(s)    ((s)->sig_class == 0x20)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   36|      0|                          || IS_UID_REV(s)    \
  |  |  ------------------
  |  |  |  |   46|      0|#define IS_UID_REV(s)    ((s)->sig_class == 0x30)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (46:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   37|      0|                          || IS_SUBKEY_REV(s) \
  |  |  ------------------
  |  |  |  |   47|      0|#define IS_SUBKEY_REV(s) ((s)->sig_class == 0x28)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (47:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   38|    158|                          || IS_ATTST_SIGS(s) )
  |  |  ------------------
  |  |  |  |   42|      0|#define IS_ATTST_SIGS(s) ((s)->sig_class == 0x16)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (42:26): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                    && IS_CERT (sig) && !(pk->pubkey_usage & PUBKEY_USAGE_CERT))
  ------------------
  |  |   51|      0|#define PUBKEY_USAGE_CERT    GCRY_PK_USAGE_CERT  /* Also good to certify keys.*/
  ------------------
  |  Branch (527:27): [True: 0, False: 0]
  ------------------
  528|      0|    {
  529|      0|      rc = gpg_error (GPG_ERR_WRONG_KEY_USAGE);
  530|      0|      if (!opt.quiet)
  ------------------
  |  Branch (530:11): [True: 0, False: 0]
  ------------------
  531|      0|        log_info (_("bad key signature from key %s: %s (0x%02x, 0x%x)\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  532|      0|                  keystr_from_pk (pk), gpg_strerror (rc),
  533|      0|                  sig->sig_class, pk->pubkey_usage);
  534|      0|      return rc;
  535|      0|    }
  536|       |
  537|       |  /* For data signatures check that the key has sign usage.  */
  538|    158|  if (!IS_BACK_SIG (sig) && IS_SIG (sig)
  ------------------
  |  |   44|    316|#define IS_BACK_SIG(s)   ((s)->sig_class == 0x19)
  ------------------
                if (!IS_BACK_SIG (sig) && IS_SIG (sig)
  ------------------
  |  |   39|    316|#define IS_SIG(s)        (!IS_CERT(s))
  |  |  ------------------
  |  |  |  |   32|    158|#define IS_CERT(s)       (IS_KEY_SIG(s)       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   40|    316|#define IS_KEY_SIG(s)    ((s)->sig_class == 0x1f)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (40:26): [True: 0, False: 158]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   33|    158|                          || IS_UID_SIG(s)    \
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    316|#define IS_UID_SIG(s)    (((s)->sig_class & ~3) == 0x10)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (41:26): [True: 25, False: 133]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   34|    158|                          || IS_SUBKEY_SIG(s) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|    291|#define IS_SUBKEY_SIG(s) ((s)->sig_class == 0x18)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (43:26): [True: 6, False: 127]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   35|    158|                          || IS_KEY_REV(s)    \
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|    285|#define IS_KEY_REV(s)    ((s)->sig_class == 0x20)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (45:26): [True: 127, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   36|    158|                          || IS_UID_REV(s)    \
  |  |  |  |  ------------------
  |  |  |  |  |  |   46|    158|#define IS_UID_REV(s)    ((s)->sig_class == 0x30)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (46:26): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   37|    158|                          || IS_SUBKEY_REV(s) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   47|    158|#define IS_SUBKEY_REV(s) ((s)->sig_class == 0x28)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (47:26): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   38|    158|                          || IS_ATTST_SIGS(s) )
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define IS_ATTST_SIGS(s) ((s)->sig_class == 0x16)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (42:26): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (538:7): [True: 158, False: 0]
  ------------------
  539|    158|      && !(pk->pubkey_usage & PUBKEY_USAGE_SIG))
  ------------------
  |  |   49|      0|#define PUBKEY_USAGE_SIG     GCRY_PK_USAGE_SIGN  /* Good for signatures. */
  ------------------
  |  Branch (539:10): [True: 0, False: 0]
  ------------------
  540|      0|    {
  541|      0|      rc = gpg_error (GPG_ERR_WRONG_KEY_USAGE);
  542|      0|      if (!opt.quiet)
  ------------------
  |  Branch (542:11): [True: 0, False: 0]
  ------------------
  543|      0|        log_info (_("bad data signature from key %s: %s (0x%02x, 0x%x)\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  544|      0|                  keystr_from_pk (pk), gpg_strerror (rc),
  545|      0|                  sig->sig_class, pk->pubkey_usage);
  546|      0|      return rc;
  547|      0|    }
  548|       |
  549|       |  /* Make sure the digest algo is enabled (in case of a detached
  550|       |   * signature).  */
  551|    158|  gcry_md_enable (digest, sig->digest_algo);
  552|       |
  553|       |  /* Complete the digest. */
  554|    158|  if (sig->version >= 4)
  ------------------
  |  Branch (554:7): [True: 31, False: 127]
  ------------------
  555|     31|    gcry_md_putc (digest, sig->version);
  556|       |
  557|    158|  gcry_md_putc( digest, sig->sig_class );
  558|    158|  if (sig->version < 4)
  ------------------
  |  Branch (558:7): [True: 127, False: 31]
  ------------------
  559|    127|    {
  560|    127|      u32 a = sig->timestamp;
  561|    127|      gcry_md_putc (digest, ((a >> 24) & 0xff));
  562|    127|      gcry_md_putc (digest, ((a >> 16) & 0xff));
  563|    127|      gcry_md_putc (digest, ((a >>  8) & 0xff));
  564|    127|      gcry_md_putc (digest, ( a        & 0xff));
  565|    127|    }
  566|     31|  else
  567|     31|    {
  568|     31|      byte buf[10];
  569|     31|      int i;
  570|     31|      size_t n;
  571|       |
  572|     31|      gcry_md_putc (digest, sig->pubkey_algo);
  573|     31|      gcry_md_putc (digest, sig->digest_algo);
  574|     31|      if (sig->hashed)
  ------------------
  |  Branch (574:11): [True: 31, False: 0]
  ------------------
  575|     31|        {
  576|     31|          n = sig->hashed->len;
  577|     31|          gcry_md_putc (digest, (n >> 8) );
  578|     31|          gcry_md_putc (digest,  n       );
  579|     31|          gcry_md_write (digest, sig->hashed->data, n);
  580|     31|          n += 6;
  581|     31|	}
  582|      0|      else
  583|      0|        {
  584|       |	  /* Two octets for the (empty) length of the hashed
  585|       |           * section. */
  586|      0|          gcry_md_putc (digest, 0);
  587|      0|	  gcry_md_putc (digest, 0);
  588|      0|	  n = 6;
  589|      0|	}
  590|       |      /* Hash data from the literal data packet.  */
  591|     31|      if (sig->version >= 5
  ------------------
  |  Branch (591:11): [True: 0, False: 31]
  ------------------
  592|     31|          && (sig->sig_class == 0x00 || sig->sig_class == 0x01))
  ------------------
  |  Branch (592:15): [True: 0, False: 0]
  |  Branch (592:41): [True: 0, False: 0]
  ------------------
  593|      0|        {
  594|       |          /* - One octet content format
  595|       |           * - File name (one octet length followed by the name)
  596|       |           * - Four octet timestamp */
  597|      0|          if (extrahash && extrahashlen)
  ------------------
  |  Branch (597:15): [True: 0, False: 0]
  |  Branch (597:28): [True: 0, False: 0]
  ------------------
  598|      0|            gcry_md_write (digest, extrahash, extrahashlen);
  599|      0|          else /* Detached signature. */
  600|      0|            {
  601|      0|              memset (buf, 0, 6);
  602|      0|              gcry_md_write (digest, buf, 6);
  603|      0|            }
  604|      0|        }
  605|       |      /* Add some magic per Section 5.2.4 of RFC 4880.  */
  606|     31|      i = 0;
  607|     31|      buf[i++] = sig->version;
  608|     31|      buf[i++] = 0xff;
  609|     31|      if (sig->version >= 5)
  ------------------
  |  Branch (609:11): [True: 0, False: 31]
  ------------------
  610|      0|        {
  611|      0|#if SIZEOF_SIZE_T > 4
  612|      0|          buf[i++] = n >> 56;
  613|      0|          buf[i++] = n >> 48;
  614|      0|          buf[i++] = n >> 40;
  615|      0|          buf[i++] = n >> 32;
  616|       |#else
  617|       |          buf[i++] = 0;
  618|       |          buf[i++] = 0;
  619|       |          buf[i++] = 0;
  620|       |          buf[i++] = 0;
  621|       |#endif
  622|      0|        }
  623|     31|      buf[i++] = n >> 24;
  624|     31|      buf[i++] = n >> 16;
  625|     31|      buf[i++] = n >>  8;
  626|     31|      buf[i++] = n;
  627|     31|      gcry_md_write (digest, buf, i);
  628|     31|    }
  629|    158|    gcry_md_final( digest );
  630|       |
  631|       |    /* Convert the digest to an MPI.  */
  632|    158|    result = encode_md_value (pk, digest, sig->digest_algo );
  633|    158|    if (!result)
  ------------------
  |  Branch (633:9): [True: 127, False: 31]
  ------------------
  634|    127|        return GPG_ERR_GENERAL;
  635|       |
  636|       |    /* Verify the signature.  */
  637|     31|    if (DBG_CLOCK && sig->sig_class <= 0x01)
  ------------------
  |  |  356|     62|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|     31|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 31]
  |  |  ------------------
  ------------------
  |  Branch (637:22): [True: 0, False: 0]
  ------------------
  638|      0|      log_clock ("enter pk_verify");
  639|     31|    rc = pk_verify( pk->pubkey_algo, result, sig->data, pk->pkey );
  640|     31|    if (DBG_CLOCK && sig->sig_class <= 0x01)
  ------------------
  |  |  356|     62|#define DBG_CLOCK   (opt.debug & DBG_CLOCK_VALUE)
  |  |  ------------------
  |  |  |  |  343|     31|#define DBG_CLOCK_VALUE   4096
  |  |  ------------------
  |  |  |  Branch (356:21): [True: 0, False: 31]
  |  |  ------------------
  ------------------
  |  Branch (640:22): [True: 0, False: 0]
  ------------------
  641|      0|      log_clock ("leave pk_verify");
  642|     31|    gcry_mpi_release (result);
  643|       |
  644|     31|  if (!rc && sig->flags.unknown_critical)
  ------------------
  |  Branch (644:7): [True: 31, False: 0]
  |  Branch (644:14): [True: 0, False: 31]
  ------------------
  645|      0|    {
  646|      0|      log_info(_("assuming bad signature from key %s"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  647|      0|                 " due to an unknown critical bit\n"),keystr_from_pk(pk));
  648|      0|      rc = GPG_ERR_BAD_SIGNATURE;
  649|      0|    }
  650|       |
  651|     31|  return rc;
  652|    158|}
sig-check.c:hash_uid_packet:
  659|     25|{
  660|     25|  if (uid->attrib_data)
  ------------------
  |  Branch (660:7): [True: 0, False: 25]
  ------------------
  661|      0|    {
  662|      0|      if (sig->version >= 4)
  ------------------
  |  Branch (662:11): [True: 0, False: 0]
  ------------------
  663|      0|        {
  664|      0|          byte buf[5];
  665|      0|          buf[0] = 0xd1;		   /* packet of type 17 */
  666|      0|          buf[1] = uid->attrib_len >> 24;  /* always use 4 length bytes */
  667|      0|          buf[2] = uid->attrib_len >> 16;
  668|      0|          buf[3] = uid->attrib_len >>  8;
  669|      0|          buf[4] = uid->attrib_len;
  670|      0|          gcry_md_write( md, buf, 5 );
  671|      0|	}
  672|      0|      gcry_md_write( md, uid->attrib_data, uid->attrib_len );
  673|      0|    }
  674|     25|  else
  675|     25|    {
  676|     25|      if (sig->version >= 4)
  ------------------
  |  Branch (676:11): [True: 25, False: 0]
  ------------------
  677|     25|        {
  678|     25|          byte buf[5];
  679|     25|          buf[0] = 0xb4;	      /* indicates a userid packet */
  680|     25|          buf[1] = uid->len >> 24;    /* always use 4 length bytes */
  681|     25|          buf[2] = uid->len >> 16;
  682|     25|          buf[3] = uid->len >>  8;
  683|     25|          buf[4] = uid->len;
  684|     25|          gcry_md_write( md, buf, 5 );
  685|     25|	}
  686|     25|      gcry_md_write( md, uid->name, uid->len );
  687|     25|    }
  688|     25|}
sig-check.c:check_signature_metadata_validity:
  365|    171|{
  366|    171|  u32 cur_time;
  367|       |
  368|    171|  if (r_expired)
  ------------------
  |  Branch (368:7): [True: 0, False: 171]
  ------------------
  369|      0|    *r_expired = 0;
  370|    171|  if (r_revoked)
  ------------------
  |  Branch (370:7): [True: 0, False: 171]
  ------------------
  371|      0|    *r_revoked = 0;
  372|       |
  373|    171|  if (pk->timestamp > sig->timestamp )
  ------------------
  |  Branch (373:7): [True: 131, False: 40]
  ------------------
  374|    131|    {
  375|    131|      ulong d = pk->timestamp - sig->timestamp;
  376|    131|      if ( d < 86400 )
  ------------------
  |  Branch (376:12): [True: 0, False: 131]
  ------------------
  377|      0|        {
  378|      0|          log_info (ngettext
  379|      0|                    ("public key %s is %lu second newer than the signature\n",
  380|      0|                     "public key %s is %lu seconds newer than the signature\n",
  381|      0|                     d), keystr_from_pk (pk), d);
  382|      0|        }
  383|    131|      else
  384|    131|        {
  385|    131|          d /= 86400;
  386|    131|          log_info (ngettext
  387|    131|                    ("public key %s is %lu day newer than the signature\n",
  388|    131|                     "public key %s is %lu days newer than the signature\n",
  389|    131|                     d), keystr_from_pk (pk), d);
  390|    131|        }
  391|    131|      if (!opt.ignore_time_conflict)
  ------------------
  |  Branch (391:11): [True: 131, False: 0]
  ------------------
  392|    131|        return GPG_ERR_TIME_CONFLICT; /* pubkey newer than signature.  */
  393|    131|    }
  394|       |
  395|     40|  cur_time = make_timestamp ();
  396|     40|  if (pk->timestamp > cur_time)
  ------------------
  |  Branch (396:7): [True: 0, False: 40]
  ------------------
  397|      0|    {
  398|      0|      ulong d = pk->timestamp - cur_time;
  399|      0|      if (d < 86400)
  ------------------
  |  Branch (399:11): [True: 0, False: 0]
  ------------------
  400|      0|        {
  401|      0|          log_info (ngettext("key %s was created %lu second"
  402|      0|                             " in the future (time warp or clock problem)\n",
  403|      0|                             "key %s was created %lu seconds"
  404|      0|                             " in the future (time warp or clock problem)\n",
  405|      0|                             d), keystr_from_pk (pk), d);
  406|      0|        }
  407|      0|      else
  408|      0|        {
  409|      0|          d /= 86400;
  410|      0|          log_info (ngettext("key %s was created %lu day"
  411|      0|                             " in the future (time warp or clock problem)\n",
  412|      0|                             "key %s was created %lu days"
  413|      0|                             " in the future (time warp or clock problem)\n",
  414|      0|                             d), keystr_from_pk (pk), d);
  415|      0|        }
  416|      0|      if (!opt.ignore_time_conflict)
  ------------------
  |  Branch (416:11): [True: 0, False: 0]
  ------------------
  417|      0|        return GPG_ERR_TIME_CONFLICT;
  418|      0|    }
  419|       |
  420|       |  /* Check whether the key has expired.  We check the has_expired
  421|       |   * flag which is set after a full evaluation of the key (getkey.c)
  422|       |   * as well as a simple compare to the current time in case the
  423|       |   * merge has for whatever reasons not been done.  */
  424|     40|  if (pk->has_expired || (pk->expiredate && pk->expiredate < cur_time))
  ------------------
  |  Branch (424:7): [True: 0, False: 40]
  |  Branch (424:27): [True: 0, False: 40]
  |  Branch (424:45): [True: 0, False: 0]
  ------------------
  425|      0|    {
  426|      0|      char buf[11];
  427|      0|      if (opt.verbose)
  ------------------
  |  Branch (427:11): [True: 0, False: 0]
  ------------------
  428|      0|        log_info (_("Note: signature key %s expired %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  429|      0|                  keystr_from_pk(pk), isotimestamp( pk->expiredate ) );
  430|      0|      snprintf (buf, sizeof buf, "%lu",(ulong)pk->expiredate);
  ------------------
  |  |   84|      0|#define snprintf gpgrt_snprintf
  ------------------
  431|      0|      write_status_text (STATUS_KEYEXPIRED, buf);
  432|      0|      if (r_expired)
  ------------------
  |  Branch (432:11): [True: 0, False: 0]
  ------------------
  433|      0|        *r_expired = 1;
  434|      0|    }
  435|       |
  436|     40|  if (pk->flags.revoked)
  ------------------
  |  Branch (436:7): [True: 0, False: 40]
  ------------------
  437|      0|    {
  438|      0|      if (opt.verbose)
  ------------------
  |  Branch (438:11): [True: 0, False: 0]
  ------------------
  439|      0|        log_info (_("Note: signature key %s has been revoked\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  440|      0|                  keystr_from_pk(pk));
  441|      0|      if (r_revoked)
  ------------------
  |  Branch (441:11): [True: 0, False: 0]
  ------------------
  442|      0|        *r_revoked=1;
  443|      0|    }
  444|       |
  445|     40|  return 0;
  446|     40|}

tdbio_sync:
  429|      6|{
  430|      6|    CACHE_CTRL r;
  431|      6|    int did_lock = 0;
  432|       |
  433|      6|    if( db_fd == -1 )
  ------------------
  |  Branch (433:9): [True: 0, False: 6]
  ------------------
  434|      0|	open_db();
  435|       |#if 0 /* Transactions are not yet used.  */
  436|       |    if( in_transaction )
  437|       |	log_bug("tdbio: syncing while in transaction\n");
  438|       |#endif
  439|       |
  440|      6|    if( !cache_is_dirty )
  ------------------
  |  Branch (440:9): [True: 0, False: 6]
  ------------------
  441|      0|	return 0;
  442|       |
  443|      6|    if (!take_write_lock ())
  ------------------
  |  Branch (443:9): [True: 0, False: 6]
  ------------------
  444|      0|        did_lock = 1;
  445|       |
  446|    157|    for( r = cache_list; r; r = r->next ) {
  ------------------
  |  Branch (446:26): [True: 151, False: 6]
  ------------------
  447|    151|	if( r->flags.used && r->flags.dirty ) {
  ------------------
  |  Branch (447:6): [True: 151, False: 0]
  |  Branch (447:23): [True: 35, False: 116]
  ------------------
  448|     35|	    int rc = write_cache_item( r );
  449|     35|	    if( rc )
  ------------------
  |  Branch (449:10): [True: 0, False: 35]
  ------------------
  450|      0|		return rc;
  451|     35|	}
  452|    151|    }
  453|      6|    cache_is_dirty = 0;
  454|      6|    if (did_lock)
  ------------------
  |  Branch (454:9): [True: 0, False: 6]
  ------------------
  455|      0|        release_write_lock ();
  456|       |
  457|      6|    return 0;
  458|      6|}
tdbio_update_version_record:
  555|      2|{
  556|      2|  TRUSTREC rec;
  557|      2|  int rc;
  558|      2|  int opt_tm;
  559|       |
  560|       |  /* Never store a TOFU trust model in the trustdb.  Use PGP instead.  */
  561|      2|  opt_tm = opt.trust_model;
  562|      2|  if (opt_tm == TM_TOFU || opt_tm == TM_TOFU_PGP)
  ------------------
  |  Branch (562:7): [True: 0, False: 2]
  |  Branch (562:28): [True: 0, False: 2]
  ------------------
  563|      0|    opt_tm = TM_PGP;
  564|       |
  565|      2|  memset (&rec, 0, sizeof rec);
  566|       |
  567|      2|  rc = tdbio_read_record (0, &rec, RECTYPE_VER);
  ------------------
  |  |   36|      2|#define RECTYPE_VER  1
  ------------------
  568|      2|  if (!rc)
  ------------------
  |  Branch (568:7): [True: 2, False: 0]
  ------------------
  569|      2|    {
  570|      2|      rec.r.ver.created     = make_timestamp();
  571|      2|      rec.r.ver.marginals   = opt.marginals_needed;
  572|      2|      rec.r.ver.completes   = opt.completes_needed;
  573|      2|      rec.r.ver.cert_depth  = opt.max_cert_depth;
  574|      2|      rec.r.ver.trust_model = opt_tm;
  575|      2|      rec.r.ver.min_cert_level = opt.min_cert_level;
  576|      2|      rc = tdbio_write_record (ctrl, &rec);
  577|      2|    }
  578|       |
  579|      2|  return rc;
  580|      2|}
tdbio_set_dbname:
  639|      1|{
  640|      1|  char *fname, *p;
  641|      1|  struct stat statbuf;
  642|      1|  static int initialized = 0;
  643|      1|  int save_slash;
  644|       |
  645|      1|  if (!initialized)
  ------------------
  |  Branch (645:7): [True: 1, False: 0]
  ------------------
  646|      1|    {
  647|      1|      atexit (cleanup);
  648|      1|      initialized = 1;
  649|      1|    }
  650|       |
  651|      1|  *r_nofile = 0;
  652|       |
  653|      1|  if (!new_dbname)
  ------------------
  |  Branch (653:7): [True: 1, False: 0]
  ------------------
  654|      1|    {
  655|      1|      fname = make_filename (gnupg_homedir (),
  656|      1|                             "trustdb" EXTSEP_S GPGEXT_GPG, NULL);
  ------------------
  |  |  122|      1|#define GPGEXT_GPG "gpg"
  ------------------
  657|      1|    }
  658|      0|  else if (*new_dbname != DIRSEP_C )
  ------------------
  |  |  886|      0|#define DIRSEP_C '/'
  ------------------
  |  Branch (658:12): [True: 0, False: 0]
  ------------------
  659|      0|    {
  660|      0|      if (strchr (new_dbname, DIRSEP_C))
  ------------------
  |  |  886|      0|#define DIRSEP_C '/'
  ------------------
  |  Branch (660:11): [True: 0, False: 0]
  ------------------
  661|      0|        fname = make_filename (new_dbname, NULL);
  662|      0|      else
  663|      0|        fname = make_filename (gnupg_homedir (), new_dbname, NULL);
  664|      0|    }
  665|      0|  else
  666|      0|    {
  667|      0|      fname = xstrdup (new_dbname);
  ------------------
  |  |  112|      0|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
  668|      0|    }
  669|       |
  670|      1|  xfree (db_name);
  ------------------
  |  |  104|      1|#define xfree(a)         gcry_free ((a))
  ------------------
  671|      1|  db_name = fname;
  672|       |
  673|       |  /* Quick check for (likely) case where there already is a
  674|       |   * trustdb.gpg.  This check is not required in theory, but it helps
  675|       |   * in practice avoiding costly operations of preparing and taking
  676|       |   * the lock.  */
  677|      1|  if (!gnupg_stat (fname, &statbuf) && statbuf.st_size > 0)
  ------------------
  |  Branch (677:7): [True: 0, False: 1]
  |  Branch (677:40): [True: 0, False: 0]
  ------------------
  678|      0|    {
  679|       |      /* OK, we have the valid trustdb.gpg already.  */
  680|      0|      return 0;
  681|      0|    }
  682|      1|  else if (!create)
  ------------------
  |  Branch (682:12): [True: 0, False: 1]
  ------------------
  683|      0|    {
  684|      0|      *r_nofile = 1;
  685|      0|      return 0;
  686|      0|    }
  687|       |
  688|       |  /* Here comes: No valid trustdb.gpg AND CREATE==1 */
  689|       |
  690|       |  /*
  691|       |   * Make sure the directory exists.  This should be done before
  692|       |   * acquiring the lock, which assumes the existence of the directory.
  693|       |   */
  694|      1|  p = strrchr (fname, DIRSEP_C);
  ------------------
  |  |  886|      1|#define DIRSEP_C '/'
  ------------------
  695|       |#if HAVE_W32_SYSTEM
  696|       |  {
  697|       |    /* Windows may either have a slash or a backslash.  Take
  698|       |       care of it.  */
  699|       |    char *pp = strrchr (fname, '/');
  700|       |    if (!p || pp > p)
  701|       |      p = pp;
  702|       |  }
  703|       |#endif /*HAVE_W32_SYSTEM*/
  704|      1|  log_assert (p);
  705|      0|  save_slash = *p;
  706|      1|  *p = 0;
  707|      1|  if (gnupg_access (fname, F_OK))
  ------------------
  |  Branch (707:7): [True: 0, False: 1]
  ------------------
  708|      0|    {
  709|      0|      try_make_homedir (fname);
  710|      0|      if (gnupg_access (fname, F_OK))
  ------------------
  |  Branch (710:11): [True: 0, False: 0]
  ------------------
  711|      0|        log_fatal (_("%s: directory does not exist!\n"), fname);
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  712|      0|    }
  713|      1|  *p = save_slash;
  714|       |
  715|      1|  take_write_lock ();
  716|       |
  717|      1|  if (gnupg_access (fname, R_OK)
  ------------------
  |  Branch (717:7): [True: 1, False: 0]
  ------------------
  718|      1|      || gnupg_stat (fname, &statbuf)
  ------------------
  |  Branch (718:10): [True: 0, False: 0]
  ------------------
  719|      1|      || statbuf.st_size == 0)
  ------------------
  |  Branch (719:10): [True: 0, False: 0]
  ------------------
  720|      1|    {
  721|      1|      estream_t fp;
  722|      1|      TRUSTREC rec;
  723|      1|      int rc;
  724|      1|      mode_t oldmask;
  725|       |
  726|      1|      if (errno && errno != ENOENT)
  ------------------
  |  Branch (726:20): [True: 0, False: 1]
  ------------------
  727|      0|        log_fatal ( _("can't access '%s': %s\n"), fname, strerror (errno));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  728|       |
  729|      1|      oldmask = umask (077);
  730|      1|      if (is_secured_filename (fname))
  ------------------
  |  Branch (730:11): [True: 0, False: 1]
  ------------------
  731|      0|        {
  732|      0|          fp = NULL;
  733|      0|          gpg_err_set_errno (EPERM);
  734|      0|        }
  735|      1|      else
  736|      1|        fp = es_fopen (fname, "wb");
  737|      1|      umask(oldmask);
  738|      1|      if (!fp)
  ------------------
  |  Branch (738:11): [True: 0, False: 1]
  ------------------
  739|      0|        log_fatal (_("can't create '%s': %s\n"), fname, strerror (errno));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  740|      1|      es_fclose (fp);
  741|       |
  742|      1|      db_fd = gnupg_open (db_name, O_RDWR | MY_O_BINARY, 0);
  ------------------
  |  |   48|      1|#define MY_O_BINARY  0
  ------------------
  743|      1|      if (db_fd == -1)
  ------------------
  |  Branch (743:11): [True: 0, False: 1]
  ------------------
  744|      0|        log_fatal (_("can't open '%s': %s\n"), db_name, strerror (errno));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  745|       |
  746|      1|      rc = create_version_record (ctrl);
  747|      1|      if (rc)
  ------------------
  |  Branch (747:11): [True: 0, False: 1]
  ------------------
  748|      0|        log_fatal (_("%s: failed to create version record: %s"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  749|      0|                   fname, gpg_strerror (rc));
  750|       |
  751|       |      /* Read again to check that we are okay. */
  752|      1|      if (tdbio_read_record (0, &rec, RECTYPE_VER))
  ------------------
  |  |   36|      1|#define RECTYPE_VER  1
  ------------------
  |  Branch (752:11): [True: 0, False: 1]
  ------------------
  753|      0|        log_fatal (_("%s: invalid trustdb created\n"), db_name);
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  754|       |
  755|      1|      if (!opt.quiet)
  ------------------
  |  Branch (755:11): [True: 1, False: 0]
  ------------------
  756|      1|        log_info (_("%s: trustdb created\n"), db_name);
  ------------------
  |  |   28|      1|#  define _(a) gettext (a)
  ------------------
  757|      1|    }
  758|       |
  759|      1|  release_write_lock ();
  760|      1|  return 0;
  761|      1|}
tdbio_db_matches_options:
  863|      1|{
  864|      1|  static int yes_no = -1;
  865|       |
  866|      1|  if (yes_no == -1)
  ------------------
  |  Branch (866:7): [True: 1, False: 0]
  ------------------
  867|      1|    {
  868|      1|      TRUSTREC vr;
  869|      1|      int rc;
  870|      1|      int opt_tm, tm;
  871|       |
  872|      1|      rc = tdbio_read_record (0, &vr, RECTYPE_VER);
  ------------------
  |  |   36|      1|#define RECTYPE_VER  1
  ------------------
  873|      1|      if( rc )
  ------------------
  |  Branch (873:11): [True: 0, False: 1]
  ------------------
  874|      0|	log_fatal( _("%s: error reading version record: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  875|      0|		   db_name, gpg_strerror (rc) );
  876|       |
  877|       |      /* Consider tofu and pgp the same.  */
  878|      1|      tm = vr.r.ver.trust_model;
  879|      1|      if (tm == TM_TOFU || tm == TM_TOFU_PGP)
  ------------------
  |  Branch (879:11): [True: 0, False: 1]
  |  Branch (879:28): [True: 0, False: 1]
  ------------------
  880|      0|        tm = TM_PGP;
  881|      1|      opt_tm  = opt.trust_model;
  882|      1|      if (opt_tm == TM_TOFU || opt_tm == TM_TOFU_PGP)
  ------------------
  |  Branch (882:11): [True: 0, False: 1]
  |  Branch (882:32): [True: 0, False: 1]
  ------------------
  883|      0|        opt_tm = TM_PGP;
  884|       |
  885|      1|      yes_no = vr.r.ver.marginals == opt.marginals_needed
  ------------------
  |  Branch (885:16): [True: 1, False: 0]
  ------------------
  886|      1|	&& vr.r.ver.completes == opt.completes_needed
  ------------------
  |  Branch (886:5): [True: 1, False: 0]
  ------------------
  887|      1|	&& vr.r.ver.cert_depth == opt.max_cert_depth
  ------------------
  |  Branch (887:5): [True: 1, False: 0]
  ------------------
  888|      1|	&& tm == opt_tm
  ------------------
  |  Branch (888:5): [True: 1, False: 0]
  ------------------
  889|      1|	&& vr.r.ver.min_cert_level == opt.min_cert_level;
  ------------------
  |  Branch (889:5): [True: 1, False: 0]
  ------------------
  890|      1|    }
  891|       |
  892|      1|  return yes_no;
  893|      1|}
tdbio_read_nextcheck:
  920|      1|{
  921|      1|  TRUSTREC vr;
  922|      1|  int rc;
  923|       |
  924|      1|  rc = tdbio_read_record (0, &vr, RECTYPE_VER);
  ------------------
  |  |   36|      1|#define RECTYPE_VER  1
  ------------------
  925|      1|  if (rc)
  ------------------
  |  Branch (925:7): [True: 0, False: 1]
  ------------------
  926|      0|    log_fatal (_("%s: error reading version record: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  927|      0|               db_name, gpg_strerror (rc));
  928|      1|  return vr.r.ver.nextcheck;
  929|      1|}
tdbio_write_nextcheck:
  940|     13|{
  941|     13|  TRUSTREC vr;
  942|     13|  int rc;
  943|       |
  944|     13|  rc = tdbio_read_record (0, &vr, RECTYPE_VER);
  ------------------
  |  |   36|     13|#define RECTYPE_VER  1
  ------------------
  945|     13|  if (rc)
  ------------------
  |  Branch (945:7): [True: 0, False: 13]
  ------------------
  946|      0|    log_fatal (_("%s: error reading version record: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  947|      0|               db_name, gpg_strerror (rc));
  948|       |
  949|     13|  if (vr.r.ver.nextcheck == stamp)
  ------------------
  |  Branch (949:7): [True: 9, False: 4]
  ------------------
  950|      9|    return 0;
  951|       |
  952|      4|  vr.r.ver.nextcheck = stamp;
  953|      4|  rc = tdbio_write_record (ctrl, &vr);
  954|      4|  if (rc)
  ------------------
  |  Branch (954:7): [True: 0, False: 4]
  ------------------
  955|      0|    log_fatal (_("%s: error writing version record: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  956|      0|               db_name, gpg_strerror (rc));
  957|      4|  return 1;
  958|      4|}
tdbio_read_record:
 1490|    111|{
 1491|    111|  byte readbuf[TRUST_RECORD_LEN];
 1492|    111|  const byte *buf, *p;
 1493|    111|  gpg_error_t err = 0;
 1494|    111|  int n, i;
 1495|       |
 1496|    111|  if (db_fd == -1)
  ------------------
  |  Branch (1496:7): [True: 0, False: 111]
  ------------------
 1497|      0|    open_db ();
 1498|       |
 1499|    111|  buf = get_record_from_cache( recnum );
 1500|    111|  if (!buf)
  ------------------
  |  Branch (1500:7): [True: 3, False: 108]
  ------------------
 1501|      3|    {
 1502|      3|      if (lseek (db_fd, recnum * TRUST_RECORD_LEN, SEEK_SET) == -1)
  ------------------
  |  |   25|      3|#define TRUST_RECORD_LEN 40
  ------------------
  |  Branch (1502:11): [True: 0, False: 3]
  ------------------
 1503|      0|        {
 1504|      0|          err = gpg_error_from_syserror ();
 1505|      0|          log_error (_("trustdb: lseek failed: %s\n"), strerror (errno));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1506|      0|          return err;
 1507|      0|	}
 1508|      3|      n = read (db_fd, readbuf, TRUST_RECORD_LEN);
  ------------------
  |  |   25|      3|#define TRUST_RECORD_LEN 40
  ------------------
 1509|      3|      if (!n)
  ------------------
  |  Branch (1509:11): [True: 3, False: 0]
  ------------------
 1510|      3|        {
 1511|      3|          return gpg_error (GPG_ERR_EOF);
 1512|      3|	}
 1513|      0|      else if (n != TRUST_RECORD_LEN)
  ------------------
  |  |   25|      0|#define TRUST_RECORD_LEN 40
  ------------------
  |  Branch (1513:16): [True: 0, False: 0]
  ------------------
 1514|      0|        {
 1515|      0|          err = gpg_error_from_syserror ();
 1516|      0|          log_error (_("trustdb: read failed (n=%d): %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1517|      0|                     n, strerror(errno));
 1518|      0|          return err;
 1519|      0|	}
 1520|      0|      buf = readbuf;
 1521|      0|    }
 1522|    108|  rec->recnum = recnum;
 1523|    108|  rec->dirty = 0;
 1524|    108|  p = buf;
 1525|    108|  rec->rectype = *p++;
 1526|    108|  if (expected && rec->rectype != expected)
  ------------------
  |  Branch (1526:7): [True: 21, False: 87]
  |  Branch (1526:19): [True: 0, False: 21]
  ------------------
 1527|      0|    {
 1528|      0|      log_error ("%lu: read expected rec type %d, got %d\n",
 1529|      0|                 recnum, expected, rec->rectype);
 1530|      0|      return gpg_error (GPG_ERR_TRUSTDB);
 1531|      0|    }
 1532|    108|  p++;    /* Skip reserved byte.  */
 1533|    108|  switch (rec->rectype)
 1534|    108|    {
 1535|      0|    case 0:  /* unused (free) record */
  ------------------
  |  Branch (1535:5): [True: 0, False: 108]
  ------------------
 1536|      0|      break;
 1537|       |
 1538|     19|    case RECTYPE_VER: /* version record */
  ------------------
  |  |   36|     19|#define RECTYPE_VER  1
  ------------------
  |  Branch (1538:5): [True: 19, False: 89]
  ------------------
 1539|     19|      if (memcmp(buf+1, GPGEXT_GPG, 3))
  ------------------
  |  |  122|     19|#define GPGEXT_GPG "gpg"
  ------------------
  |  Branch (1539:11): [True: 0, False: 19]
  ------------------
 1540|      0|        {
 1541|      0|          log_error (_("%s: not a trustdb file\n"), db_name );
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1542|      0|          err = gpg_error (GPG_ERR_TRUSTDB);
 1543|      0|        }
 1544|     19|      else
 1545|     19|        {
 1546|     19|          p += 2; /* skip "gpg" */
 1547|     19|          rec->r.ver.version  = *p++;
 1548|     19|          rec->r.ver.marginals = *p++;
 1549|     19|          rec->r.ver.completes = *p++;
 1550|     19|          rec->r.ver.cert_depth = *p++;
 1551|     19|          rec->r.ver.trust_model = *p++;
 1552|     19|          rec->r.ver.min_cert_level = *p++;
 1553|     19|          p += 2;
 1554|     19|          rec->r.ver.created  = buf32_to_ulong(p);
 1555|     19|          p += 4;
 1556|     19|          rec->r.ver.nextcheck = buf32_to_ulong(p);
 1557|     19|          p += 4;
 1558|     19|          p += 4;
 1559|     19|          p += 4;
 1560|     19|          rec->r.ver.firstfree = buf32_to_ulong(p);
 1561|     19|          p += 4;
 1562|     19|          p += 4;
 1563|     19|          rec->r.ver.trusthashtbl = buf32_to_ulong(p);
 1564|     19|          if (recnum)
  ------------------
  |  Branch (1564:15): [True: 0, False: 19]
  ------------------
 1565|      0|            {
 1566|      0|              log_error( _("%s: version record with recnum %lu\n"), db_name,
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1567|      0|                         (ulong)recnum );
 1568|      0|              err = gpg_error (GPG_ERR_TRUSTDB);
 1569|      0|            }
 1570|     19|          else if (rec->r.ver.version != 3)
  ------------------
  |  Branch (1570:20): [True: 0, False: 19]
  ------------------
 1571|      0|            {
 1572|      0|              log_error( _("%s: invalid file version %d\n"), db_name,
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1573|      0|                         rec->r.ver.version );
 1574|      0|              err = gpg_error (GPG_ERR_TRUSTDB);
 1575|      0|            }
 1576|     19|        }
 1577|     19|      break;
 1578|       |
 1579|      0|    case RECTYPE_FREE:
  ------------------
  |  |   41|      0|#define RECTYPE_FREE 254
  ------------------
  |  Branch (1579:5): [True: 0, False: 108]
  ------------------
 1580|      0|      rec->r.free.next  = buf32_to_ulong(p);
 1581|      0|      break;
 1582|       |
 1583|     89|    case RECTYPE_HTBL:
  ------------------
  |  |   37|     89|#define RECTYPE_HTBL 10
  ------------------
  |  Branch (1583:5): [True: 89, False: 19]
  ------------------
 1584|    890|      for (i=0; i < ITEMS_PER_HTBL_RECORD; i++)
  ------------------
  |  |   27|    890|#define ITEMS_PER_HTBL_RECORD	((TRUST_RECORD_LEN-2)/4)
  |  |  ------------------
  |  |  |  |   25|    890|#define TRUST_RECORD_LEN 40
  |  |  ------------------
  ------------------
  |  Branch (1584:17): [True: 801, False: 89]
  ------------------
 1585|    801|        {
 1586|    801|          rec->r.htbl.item[i] = buf32_to_ulong(p);
 1587|    801|          p += 4;
 1588|    801|	}
 1589|     89|      break;
 1590|       |
 1591|      0|    case RECTYPE_HLST:
  ------------------
  |  |   38|      0|#define RECTYPE_HLST 11
  ------------------
  |  Branch (1591:5): [True: 0, False: 108]
  ------------------
 1592|      0|      rec->r.hlst.next = buf32_to_ulong(p);
 1593|      0|      p += 4;
 1594|      0|      for (i=0; i < ITEMS_PER_HLST_RECORD; i++)
  ------------------
  |  |   28|      0|#define ITEMS_PER_HLST_RECORD	((TRUST_RECORD_LEN-6)/5)
  |  |  ------------------
  |  |  |  |   25|      0|#define TRUST_RECORD_LEN 40
  |  |  ------------------
  ------------------
  |  Branch (1594:17): [True: 0, False: 0]
  ------------------
 1595|      0|        {
 1596|      0|          rec->r.hlst.rnum[i] = buf32_to_ulong(p);
 1597|      0|          p += 4;
 1598|      0|	}
 1599|      0|      break;
 1600|       |
 1601|      0|    case RECTYPE_TRUST:
  ------------------
  |  |   39|      0|#define RECTYPE_TRUST 12
  ------------------
  |  Branch (1601:5): [True: 0, False: 108]
  ------------------
 1602|      0|      memcpy (rec->r.trust.fingerprint, p, 20);
 1603|      0|      p+=20;
 1604|      0|      rec->r.trust.ownertrust = *p++;
 1605|      0|      rec->r.trust.depth = *p++;
 1606|      0|      rec->r.trust.min_ownertrust = *p++;
 1607|      0|      rec->r.trust.flags = *p++;
 1608|      0|      rec->r.trust.validlist = buf32_to_ulong(p);
 1609|      0|      break;
 1610|       |
 1611|      0|    case RECTYPE_VALID:
  ------------------
  |  |   40|      0|#define RECTYPE_VALID 13
  ------------------
  |  Branch (1611:5): [True: 0, False: 108]
  ------------------
 1612|      0|      memcpy (rec->r.valid.namehash, p, 20);
 1613|      0|      p+=20;
 1614|      0|      rec->r.valid.validity = *p++;
 1615|      0|      rec->r.valid.next = buf32_to_ulong(p);
 1616|      0|      p += 4;
 1617|      0|      rec->r.valid.full_count = *p++;
 1618|      0|      rec->r.valid.marginal_count = *p++;
 1619|      0|      break;
 1620|       |
 1621|      0|    default:
  ------------------
  |  Branch (1621:5): [True: 0, False: 108]
  ------------------
 1622|      0|      log_error ("%s: invalid record type %d at recnum %lu\n",
 1623|      0|                 db_name, rec->rectype, (ulong)recnum);
 1624|      0|      err = gpg_error (GPG_ERR_TRUSTDB);
 1625|      0|      break;
 1626|    108|    }
 1627|       |
 1628|    108|  return err;
 1629|    108|}
tdbio_write_record:
 1639|     37|{
 1640|     37|  byte buf[TRUST_RECORD_LEN];
 1641|     37|  byte *p;
 1642|     37|  int rc = 0;
 1643|     37|  int i;
 1644|     37|  ulong recnum = rec->recnum;
 1645|       |
 1646|     37|  if (db_fd == -1)
  ------------------
  |  Branch (1646:7): [True: 0, False: 37]
  ------------------
 1647|      0|    open_db ();
 1648|       |
 1649|     37|  memset (buf, 0, TRUST_RECORD_LEN);
  ------------------
  |  |   25|     37|#define TRUST_RECORD_LEN 40
  ------------------
 1650|     37|  p = buf;
 1651|     37|  *p++ = rec->rectype; p++;
 1652|       |
 1653|     37|  switch (rec->rectype)
 1654|     37|    {
 1655|      0|    case 0:  /* unused record */
  ------------------
  |  Branch (1655:5): [True: 0, False: 37]
  ------------------
 1656|      0|      break;
 1657|       |
 1658|      8|    case RECTYPE_VER: /* version record */
  ------------------
  |  |   36|      8|#define RECTYPE_VER  1
  ------------------
  |  Branch (1658:5): [True: 8, False: 29]
  ------------------
 1659|      8|      if (recnum)
  ------------------
  |  Branch (1659:11): [True: 0, False: 8]
  ------------------
 1660|      0|        BUG ();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1661|      8|      memcpy(p-1, GPGEXT_GPG, 3 ); p += 2;
  ------------------
  |  |  122|      8|#define GPGEXT_GPG "gpg"
  ------------------
 1662|      8|      *p++ = rec->r.ver.version;
 1663|      8|      *p++ = rec->r.ver.marginals;
 1664|      8|      *p++ = rec->r.ver.completes;
 1665|      8|      *p++ = rec->r.ver.cert_depth;
 1666|      8|      *p++ = rec->r.ver.trust_model;
 1667|      8|      *p++ = rec->r.ver.min_cert_level;
 1668|      8|      p += 2;
 1669|      8|      ulongtobuf(p, rec->r.ver.created); p += 4;
  ------------------
  |  |   35|      8|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|      8|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|      8|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|      8|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|      8|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|      8|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1670|      8|      ulongtobuf(p, rec->r.ver.nextcheck); p += 4;
  ------------------
  |  |   35|      8|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|      8|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|      8|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|      8|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|      8|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|      8|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1671|      8|      p += 4;
 1672|      8|      p += 4;
 1673|      8|      ulongtobuf(p, rec->r.ver.firstfree ); p += 4;
  ------------------
  |  |   35|      8|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|      8|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|      8|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|      8|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|      8|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|      8|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1674|      8|      p += 4;
 1675|      8|      ulongtobuf(p, rec->r.ver.trusthashtbl ); p += 4;
  ------------------
  |  |   35|      8|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|      8|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|      8|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|      8|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|      8|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|      8|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1676|      8|      break;
 1677|       |
 1678|      0|    case RECTYPE_FREE:
  ------------------
  |  |   41|      0|#define RECTYPE_FREE 254
  ------------------
  |  Branch (1678:5): [True: 0, False: 37]
  ------------------
 1679|      0|      ulongtobuf(p, rec->r.free.next); p += 4;
  ------------------
  |  |   35|      0|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|      0|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|      0|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|      0|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|      0|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|      0|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1680|      0|      break;
 1681|       |
 1682|     29|    case RECTYPE_HTBL:
  ------------------
  |  |   37|     29|#define RECTYPE_HTBL 10
  ------------------
  |  Branch (1682:5): [True: 29, False: 8]
  ------------------
 1683|    290|      for (i=0; i < ITEMS_PER_HTBL_RECORD; i++)
  ------------------
  |  |   27|    290|#define ITEMS_PER_HTBL_RECORD	((TRUST_RECORD_LEN-2)/4)
  |  |  ------------------
  |  |  |  |   25|    290|#define TRUST_RECORD_LEN 40
  |  |  ------------------
  ------------------
  |  Branch (1683:17): [True: 261, False: 29]
  ------------------
 1684|    261|        {
 1685|    261|          ulongtobuf( p, rec->r.htbl.item[i]); p += 4;
  ------------------
  |  |   35|    261|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|    261|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|    261|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|    261|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|    261|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|    261|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1686|    261|        }
 1687|     29|      break;
 1688|       |
 1689|      0|    case RECTYPE_HLST:
  ------------------
  |  |   38|      0|#define RECTYPE_HLST 11
  ------------------
  |  Branch (1689:5): [True: 0, False: 37]
  ------------------
 1690|      0|      ulongtobuf( p, rec->r.hlst.next); p += 4;
  ------------------
  |  |   35|      0|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|      0|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|      0|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|      0|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|      0|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|      0|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1691|      0|      for (i=0; i < ITEMS_PER_HLST_RECORD; i++ )
  ------------------
  |  |   28|      0|#define ITEMS_PER_HLST_RECORD	((TRUST_RECORD_LEN-6)/5)
  |  |  ------------------
  |  |  |  |   25|      0|#define TRUST_RECORD_LEN 40
  |  |  ------------------
  ------------------
  |  Branch (1691:17): [True: 0, False: 0]
  ------------------
 1692|      0|        {
 1693|      0|          ulongtobuf( p, rec->r.hlst.rnum[i]); p += 4;
  ------------------
  |  |   35|      0|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|      0|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|      0|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|      0|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|      0|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|      0|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1694|      0|	}
 1695|      0|      break;
 1696|       |
 1697|      0|    case RECTYPE_TRUST:
  ------------------
  |  |   39|      0|#define RECTYPE_TRUST 12
  ------------------
  |  Branch (1697:5): [True: 0, False: 37]
  ------------------
 1698|      0|      memcpy (p, rec->r.trust.fingerprint, 20); p += 20;
 1699|      0|      *p++ = rec->r.trust.ownertrust;
 1700|      0|      *p++ = rec->r.trust.depth;
 1701|      0|      *p++ = rec->r.trust.min_ownertrust;
 1702|      0|      *p++ = rec->r.trust.flags;
 1703|      0|      ulongtobuf( p, rec->r.trust.validlist); p += 4;
  ------------------
  |  |   35|      0|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|      0|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|      0|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|      0|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|      0|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|      0|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1704|      0|      break;
 1705|       |
 1706|      0|    case RECTYPE_VALID:
  ------------------
  |  |   40|      0|#define RECTYPE_VALID 13
  ------------------
  |  Branch (1706:5): [True: 0, False: 37]
  ------------------
 1707|      0|      memcpy (p, rec->r.valid.namehash, 20); p += 20;
 1708|      0|      *p++ = rec->r.valid.validity;
 1709|      0|      ulongtobuf( p, rec->r.valid.next); p += 4;
  ------------------
  |  |   35|      0|#define ulongtobuf( p, a ) do { 			  \
  |  |   36|      0|			    ((byte*)p)[0] = a >> 24;	\
  |  |   37|      0|			    ((byte*)p)[1] = a >> 16;	\
  |  |   38|      0|			    ((byte*)p)[2] = a >>  8;	\
  |  |   39|      0|			    ((byte*)p)[3] = a	   ;	\
  |  |   40|      0|			} while(0)
  |  |  ------------------
  |  |  |  Branch (40:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1710|      0|      *p++ = rec->r.valid.full_count;
 1711|      0|      *p++ = rec->r.valid.marginal_count;
 1712|      0|      break;
 1713|       |
 1714|      0|    default:
  ------------------
  |  Branch (1714:5): [True: 0, False: 37]
  ------------------
 1715|      0|      BUG();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
 1716|     37|    }
 1717|       |
 1718|     37|  rc = put_record_into_cache (recnum, buf);
 1719|     37|  if (rc)
  ------------------
  |  Branch (1719:7): [True: 0, False: 37]
  ------------------
 1720|      0|    ;
 1721|     37|  else if (rec->rectype == RECTYPE_TRUST)
  ------------------
  |  |   39|     37|#define RECTYPE_TRUST 12
  ------------------
  |  Branch (1721:12): [True: 0, False: 37]
  ------------------
 1722|      0|    rc = update_trusthashtbl (ctrl, rec);
 1723|       |
 1724|     37|  return rc;
 1725|     37|}
tdbio_search_trust_byfpr:
 1868|      2|{
 1869|      2|  int rc;
 1870|       |
 1871|       |  /* Locate the trust record using the hash table */
 1872|      2|  rc = lookup_hashtable (get_trusthashrec (ctrl), fingerprint, 20,
 1873|      2|                         cmp_trec_fpr, fingerprint, rec );
 1874|      2|  return rc;
 1875|      2|}
tdbio_search_trust_bypk:
 1886|      2|{
 1887|      2|  byte fingerprint[20];
 1888|       |
 1889|      2|  fpr20_from_pk (pk, fingerprint);
 1890|      2|  return tdbio_search_trust_byfpr (ctrl, fingerprint, rec);
 1891|      2|}
tdbio.c:take_write_lock:
  131|      7|{
  132|      7|  int rc;
  133|       |
  134|      7|  if (!lockhandle)
  ------------------
  |  Branch (134:7): [True: 1, False: 6]
  ------------------
  135|      1|    lockhandle = dotlock_create (db_name, 0);
  136|      7|  if (!lockhandle)
  ------------------
  |  Branch (136:7): [True: 0, False: 7]
  ------------------
  137|      0|    log_fatal ( _("can't create lock for '%s'\n"), db_name );
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  138|       |
  139|      7|  if (!is_locked)
  ------------------
  |  Branch (139:7): [True: 1, False: 6]
  ------------------
  140|      1|    {
  141|      1|      if (dotlock_take (lockhandle, -1) )
  ------------------
  |  Branch (141:11): [True: 0, False: 1]
  ------------------
  142|      0|        log_fatal ( _("can't lock '%s'\n"), db_name );
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  143|      1|      rc = 0;
  144|      1|    }
  145|      6|  else
  146|      6|    rc = 1;
  147|       |
  148|      7|  if (opt.lock_once)
  ------------------
  |  Branch (148:7): [True: 0, False: 7]
  ------------------
  149|      0|    is_locked = 1;
  150|      7|  else
  151|      7|    is_locked++;
  152|      7|  return rc;
  153|      7|}
tdbio.c:write_cache_item:
  210|     35|{
  211|     35|  gpg_error_t err;
  212|     35|  int n;
  213|       |
  214|     35|  if (lseek (db_fd, r->recno * TRUST_RECORD_LEN, SEEK_SET) == -1)
  ------------------
  |  |   25|     35|#define TRUST_RECORD_LEN 40
  ------------------
  |  Branch (214:7): [True: 0, False: 35]
  ------------------
  215|      0|    {
  216|      0|      err = gpg_error_from_syserror ();
  217|      0|      log_error (_("trustdb rec %lu: lseek failed: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  218|      0|                 r->recno, strerror (errno));
  219|      0|      return err;
  220|      0|    }
  221|     35|  n = write (db_fd, r->data, TRUST_RECORD_LEN);
  ------------------
  |  |   25|     35|#define TRUST_RECORD_LEN 40
  ------------------
  222|     35|  if (n != TRUST_RECORD_LEN)
  ------------------
  |  |   25|     35|#define TRUST_RECORD_LEN 40
  ------------------
  |  Branch (222:7): [True: 0, False: 35]
  ------------------
  223|      0|    {
  224|      0|      err = gpg_error_from_syserror ();
  225|      0|      log_error (_("trustdb rec %lu: write failed (n=%d): %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  226|      0|                 r->recno, n, strerror (errno) );
  227|      0|      return err;
  228|      0|    }
  229|     35|  r->flags.dirty = 0;
  230|     35|  return 0;
  231|     35|}
tdbio.c:release_write_lock:
  162|      1|{
  163|      1|  if (opt.lock_once)
  ------------------
  |  Branch (163:7): [True: 0, False: 1]
  ------------------
  164|      0|    return;  /* Don't care; here IS_LOCKED is fixed to 1.  */
  165|       |
  166|      1|  if (!is_locked)
  ------------------
  |  Branch (166:7): [True: 0, False: 1]
  ------------------
  167|      0|    {
  168|      0|      log_error ("Ooops, tdbio:release_write_lock with no lock held\n");
  169|      0|      return;
  170|      0|    }
  171|      1|  if (--is_locked)
  ------------------
  |  Branch (171:7): [True: 1, False: 0]
  ------------------
  172|      1|    return;
  173|       |
  174|      0|  if (dotlock_release (lockhandle))
  ------------------
  |  Branch (174:7): [True: 0, False: 0]
  ------------------
  175|      0|    log_error ("Oops, tdbio:release_write_locked failed\n");
  176|      0|}
tdbio.c:cleanup:
  538|      1|{
  539|      1|  if (is_locked)
  ------------------
  |  Branch (539:7): [True: 1, False: 0]
  ------------------
  540|      1|    {
  541|      1|      if (!dotlock_release (lockhandle))
  ------------------
  |  Branch (541:11): [True: 1, False: 0]
  ------------------
  542|      1|        is_locked = 0;
  543|      1|    }
  544|      1|}
tdbio.c:create_version_record:
  590|      1|{
  591|      1|  TRUSTREC rec;
  592|      1|  int rc;
  593|      1|  int opt_tm;
  594|       |
  595|       |  /* Never store a TOFU trust model in the trustdb.  Use PGP instead.  */
  596|      1|  opt_tm = opt.trust_model;
  597|      1|  if (opt_tm == TM_TOFU || opt_tm == TM_TOFU_PGP)
  ------------------
  |  Branch (597:7): [True: 0, False: 1]
  |  Branch (597:28): [True: 0, False: 1]
  ------------------
  598|      0|    opt_tm = TM_PGP;
  599|       |
  600|      1|  memset (&rec, 0, sizeof rec);
  601|      1|  rec.r.ver.version     = 3;
  602|      1|  rec.r.ver.created     = make_timestamp ();
  603|      1|  rec.r.ver.marginals   = opt.marginals_needed;
  604|      1|  rec.r.ver.completes   = opt.completes_needed;
  605|      1|  rec.r.ver.cert_depth  = opt.max_cert_depth;
  606|      1|  if (opt_tm == TM_PGP || opt_tm == TM_CLASSIC)
  ------------------
  |  Branch (606:7): [True: 0, False: 1]
  |  Branch (606:27): [True: 1, False: 0]
  ------------------
  607|      1|    rec.r.ver.trust_model = opt_tm;
  608|      0|  else
  609|      0|    rec.r.ver.trust_model = TM_PGP;
  610|      1|  rec.r.ver.min_cert_level = opt.min_cert_level;
  611|      1|  rec.rectype = RECTYPE_VER;
  ------------------
  |  |   36|      1|#define RECTYPE_VER  1
  ------------------
  612|      1|  rec.recnum = 0;
  613|      1|  rc = tdbio_write_record (ctrl, &rec);
  614|       |
  615|      1|  if (!rc)
  ------------------
  |  Branch (615:7): [True: 1, False: 0]
  ------------------
  616|      1|    tdbio_sync ();
  617|       |
  618|      1|  if (!rc)
  ------------------
  |  Branch (618:7): [True: 1, False: 0]
  ------------------
  619|      1|    create_hashtable (ctrl, &rec, 0);
  620|       |
  621|      1|  return rc;
  622|      1|}
tdbio.c:create_hashtable:
  818|      1|{
  819|      1|  TRUSTREC rec;
  820|      1|  off_t offset;
  821|      1|  ulong recnum;
  822|      1|  int i, n, rc;
  823|       |
  824|      1|  offset = lseek (db_fd, 0, SEEK_END);
  825|      1|  if (offset == -1)
  ------------------
  |  Branch (825:7): [True: 0, False: 1]
  ------------------
  826|      0|    log_fatal ("trustdb: lseek to end failed: %s\n", strerror(errno));
  827|      1|  recnum = offset / TRUST_RECORD_LEN;
  ------------------
  |  |   25|      1|#define TRUST_RECORD_LEN 40
  ------------------
  828|      1|  log_assert (recnum); /* This is will never be the first record. */
  829|       |
  830|      1|  if (!type)
  ------------------
  |  Branch (830:7): [True: 1, False: 0]
  ------------------
  831|      1|    vr->r.ver.trusthashtbl = recnum;
  832|       |
  833|       |  /* Now write the records making up the hash table. */
  834|      1|  n = (256+ITEMS_PER_HTBL_RECORD-1) / ITEMS_PER_HTBL_RECORD;
  ------------------
  |  |   27|      1|#define ITEMS_PER_HTBL_RECORD	((TRUST_RECORD_LEN-2)/4)
  |  |  ------------------
  |  |  |  |   25|      1|#define TRUST_RECORD_LEN 40
  |  |  ------------------
  ------------------
                n = (256+ITEMS_PER_HTBL_RECORD-1) / ITEMS_PER_HTBL_RECORD;
  ------------------
  |  |   27|      1|#define ITEMS_PER_HTBL_RECORD	((TRUST_RECORD_LEN-2)/4)
  |  |  ------------------
  |  |  |  |   25|      1|#define TRUST_RECORD_LEN 40
  |  |  ------------------
  ------------------
  835|     30|  for (i=0; i < n; i++, recnum++)
  ------------------
  |  Branch (835:13): [True: 29, False: 1]
  ------------------
  836|     29|    {
  837|     29|      memset (&rec, 0, sizeof rec);
  838|     29|      rec.rectype = RECTYPE_HTBL;
  ------------------
  |  |   37|     29|#define RECTYPE_HTBL 10
  ------------------
  839|     29|      rec.recnum = recnum;
  840|     29|      rc = tdbio_write_record (ctrl, &rec);
  841|     29|      if (rc)
  ------------------
  |  Branch (841:11): [True: 0, False: 29]
  ------------------
  842|      0|        log_fatal (_("%s: failed to create hashtable: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  843|      0|                   db_name, gpg_strerror (rc));
  844|     29|    }
  845|       |  /* Update the version record and flush. */
  846|      1|  rc = tdbio_write_record (ctrl, vr);
  847|      1|  if (!rc)
  ------------------
  |  Branch (847:7): [True: 1, False: 0]
  ------------------
  848|      1|    rc = tdbio_sync ();
  849|      1|  if (rc)
  ------------------
  |  Branch (849:7): [True: 0, False: 1]
  ------------------
  850|      0|    log_fatal (_("%s: error updating version record: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  851|      0|               db_name, gpg_strerror (rc));
  852|      1|}
tdbio.c:get_record_from_cache:
  191|    111|{
  192|    111|  CACHE_CTRL r;
  193|       |
  194|  1.98k|  for (r = cache_list; r; r = r->next)
  ------------------
  |  Branch (194:24): [True: 1.97k, False: 3]
  ------------------
  195|  1.97k|    {
  196|  1.97k|      if (r->flags.used && r->recno == recno)
  ------------------
  |  Branch (196:11): [True: 1.97k, False: 0]
  |  Branch (196:28): [True: 108, False: 1.87k]
  ------------------
  197|    108|        return r->data;
  198|  1.97k|    }
  199|      3|  return NULL;
  200|    111|}
tdbio.c:put_record_into_cache:
  242|     37|{
  243|     37|  CACHE_CTRL r, unused;
  244|     37|  int dirty_count = 0;
  245|     37|  int clean_count = 0;
  246|       |
  247|       |  /* See whether we already cached this one.  */
  248|    675|  for (unused = NULL, r = cache_list; r; r = r->next)
  ------------------
  |  Branch (248:39): [True: 645, False: 30]
  ------------------
  249|    645|    {
  250|    645|      if (!r->flags.used)
  ------------------
  |  Branch (250:11): [True: 0, False: 645]
  ------------------
  251|      0|        {
  252|      0|          if (!unused)
  ------------------
  |  Branch (252:15): [True: 0, False: 0]
  ------------------
  253|      0|            unused = r;
  254|      0|	}
  255|    645|      else if (r->recno == recno)
  ------------------
  |  Branch (255:16): [True: 7, False: 638]
  ------------------
  256|      7|        {
  257|      7|          if (!r->flags.dirty)
  ------------------
  |  Branch (257:15): [True: 5, False: 2]
  ------------------
  258|      5|            {
  259|       |              /* Hmmm: should we use a copy and compare? */
  260|      5|              if (memcmp (r->data, data, TRUST_RECORD_LEN))
  ------------------
  |  |   25|      5|#define TRUST_RECORD_LEN 40
  ------------------
  |  Branch (260:19): [True: 5, False: 0]
  ------------------
  261|      5|                {
  262|      5|                  r->flags.dirty = 1;
  263|      5|                  cache_is_dirty = 1;
  264|      5|		}
  265|      5|	    }
  266|      7|          memcpy (r->data, data, TRUST_RECORD_LEN);
  ------------------
  |  |   25|      7|#define TRUST_RECORD_LEN 40
  ------------------
  267|      7|          return 0;
  268|      7|	}
  269|    638|      if (r->flags.used)
  ------------------
  |  Branch (269:11): [True: 638, False: 0]
  ------------------
  270|    638|        {
  271|    638|          if (r->flags.dirty)
  ------------------
  |  Branch (271:15): [True: 435, False: 203]
  ------------------
  272|    435|            dirty_count++;
  273|    203|          else
  274|    203|            clean_count++;
  275|    638|	}
  276|    638|    }
  277|       |
  278|       |  /* Not in the cache: add a new entry. */
  279|     30|  if (unused)
  ------------------
  |  Branch (279:7): [True: 0, False: 30]
  ------------------
  280|      0|    {
  281|       |      /* Reuse this entry. */
  282|      0|      r = unused;
  283|      0|      r->flags.used = 1;
  284|      0|      r->recno = recno;
  285|      0|      memcpy (r->data, data, TRUST_RECORD_LEN);
  ------------------
  |  |   25|      0|#define TRUST_RECORD_LEN 40
  ------------------
  286|      0|      r->flags.dirty = 1;
  287|      0|      cache_is_dirty = 1;
  288|      0|      cache_entries++;
  289|      0|      return 0;
  290|      0|    }
  291|       |
  292|       |  /* See whether we reached the limit. */
  293|     30|  if (cache_entries < MAX_CACHE_ENTRIES_SOFT)
  ------------------
  |  |   72|     30|#define MAX_CACHE_ENTRIES_SOFT	200
  ------------------
  |  Branch (293:7): [True: 30, False: 0]
  ------------------
  294|     30|    {
  295|       |      /* No: Put into cache.  */
  296|     30|      r = xmalloc (sizeof *r);
  ------------------
  |  |  107|     30|#define xmalloc(a)       gcry_xmalloc ((a))
  ------------------
  297|     30|      r->flags.used = 1;
  298|     30|      r->recno = recno;
  299|     30|      memcpy (r->data, data, TRUST_RECORD_LEN);
  ------------------
  |  |   25|     30|#define TRUST_RECORD_LEN 40
  ------------------
  300|     30|      r->flags.dirty = 1;
  301|     30|      r->next = cache_list;
  302|     30|      cache_list = r;
  303|     30|      cache_is_dirty = 1;
  304|     30|      cache_entries++;
  305|     30|      return 0;
  306|     30|    }
  307|       |
  308|       |  /* Cache is full: discard some clean entries.  */
  309|      0|  if (clean_count)
  ------------------
  |  Branch (309:7): [True: 0, False: 0]
  ------------------
  310|      0|    {
  311|      0|      int n;
  312|       |
  313|       |      /* We discard a third of the clean entries.  */
  314|      0|      n = clean_count / 3;
  315|      0|      if (!n)
  ------------------
  |  Branch (315:11): [True: 0, False: 0]
  ------------------
  316|      0|        n = 1;
  317|       |
  318|      0|      for (unused = NULL, r = cache_list; r; r = r->next)
  ------------------
  |  Branch (318:43): [True: 0, False: 0]
  ------------------
  319|      0|        {
  320|      0|          if (r->flags.used && !r->flags.dirty)
  ------------------
  |  Branch (320:15): [True: 0, False: 0]
  |  Branch (320:32): [True: 0, False: 0]
  ------------------
  321|      0|            {
  322|      0|              if (!unused)
  ------------------
  |  Branch (322:19): [True: 0, False: 0]
  ------------------
  323|      0|                unused = r;
  324|      0|              r->flags.used = 0;
  325|      0|              cache_entries--;
  326|      0|              if (!--n)
  ------------------
  |  Branch (326:19): [True: 0, False: 0]
  ------------------
  327|      0|                break;
  328|      0|	    }
  329|      0|	}
  330|       |
  331|       |      /* Now put into the cache.  */
  332|      0|      log_assert (unused);
  333|      0|      r = unused;
  334|      0|      r->flags.used = 1;
  335|      0|      r->recno = recno;
  336|      0|      memcpy (r->data, data, TRUST_RECORD_LEN);
  ------------------
  |  |   25|      0|#define TRUST_RECORD_LEN 40
  ------------------
  337|      0|      r->flags.dirty = 1;
  338|      0|      cache_is_dirty = 1;
  339|      0|      cache_entries++;
  340|      0|      return 0;
  341|      0|    }
  342|       |
  343|       |  /* No clean entries: We have to flush some dirty entries.  */
  344|       |#if 0 /* Transactions are not yet used.  */
  345|       |  if (in_transaction)
  346|       |    {
  347|       |      /* But we can't do this while in a transaction.  Thus we
  348|       |       * increase the cache size instead.  */
  349|       |      if (cache_entries < MAX_CACHE_ENTRIES_HARD)
  350|       |        {
  351|       |          if (opt.debug && !(cache_entries % 100))
  352|       |            log_debug ("increasing tdbio cache size\n");
  353|       |          r = xmalloc (sizeof *r);
  354|       |          r->flags.used = 1;
  355|       |          r->recno = recno;
  356|       |          memcpy (r->data, data, TRUST_RECORD_LEN);
  357|       |          r->flags.dirty = 1;
  358|       |          r->next = cache_list;
  359|       |          cache_list = r;
  360|       |          cache_is_dirty = 1;
  361|       |          cache_entries++;
  362|       |          return 0;
  363|       |	}
  364|       |      /* Hard limit for the cache size reached.  */
  365|       |      log_info (_("trustdb transaction too large\n"));
  366|       |      return GPG_ERR_RESOURCE_LIMIT;
  367|       |    }
  368|       |#endif
  369|       |
  370|      0|  if (dirty_count)
  ------------------
  |  Branch (370:7): [True: 0, False: 0]
  ------------------
  371|      0|    {
  372|      0|      int n;
  373|       |
  374|       |      /* Discard some dirty entries. */
  375|      0|      n = dirty_count / 5;
  376|      0|      if (!n)
  ------------------
  |  Branch (376:11): [True: 0, False: 0]
  ------------------
  377|      0|        n = 1;
  378|       |
  379|      0|      take_write_lock ();
  380|      0|      for (unused = NULL, r = cache_list; r; r = r->next)
  ------------------
  |  Branch (380:43): [True: 0, False: 0]
  ------------------
  381|      0|        {
  382|      0|          if (r->flags.used && r->flags.dirty)
  ------------------
  |  Branch (382:15): [True: 0, False: 0]
  |  Branch (382:32): [True: 0, False: 0]
  ------------------
  383|      0|            {
  384|      0|              int rc;
  385|       |
  386|      0|              rc = write_cache_item (r);
  387|      0|              if (rc)
  ------------------
  |  Branch (387:19): [True: 0, False: 0]
  ------------------
  388|      0|                return rc;
  389|      0|              if (!unused)
  ------------------
  |  Branch (389:19): [True: 0, False: 0]
  ------------------
  390|      0|                unused = r;
  391|      0|              r->flags.used = 0;
  392|      0|              cache_entries--;
  393|      0|              if (!--n)
  ------------------
  |  Branch (393:19): [True: 0, False: 0]
  ------------------
  394|      0|                break;
  395|      0|	    }
  396|      0|	}
  397|      0|      release_write_lock ();
  398|       |
  399|       |      /* Now put into the cache.  */
  400|      0|      log_assert (unused);
  401|      0|      r = unused;
  402|      0|      r->flags.used = 1;
  403|      0|      r->recno = recno;
  404|      0|      memcpy (r->data, data, TRUST_RECORD_LEN);
  ------------------
  |  |   25|      0|#define TRUST_RECORD_LEN 40
  ------------------
  405|      0|      r->flags.dirty = 1;
  406|      0|      cache_is_dirty = 1;
  407|      0|      cache_entries++;
  408|      0|      return 0;
  409|      0|    }
  410|       |
  411|       |  /* We should never reach this.  */
  412|      0|  BUG();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  413|      0|}
tdbio.c:get_trusthashrec:
  971|      2|{
  972|      2|  static ulong trusthashtbl; /* Record number of the trust hashtable.  */
  973|       |
  974|      2|  (void)ctrl;
  975|       |
  976|      2|  if (!trusthashtbl)
  ------------------
  |  Branch (976:7): [True: 1, False: 1]
  ------------------
  977|      1|    {
  978|      1|      TRUSTREC vr;
  979|      1|      int rc;
  980|       |
  981|      1|      rc = tdbio_read_record (0, &vr, RECTYPE_VER );
  ------------------
  |  |   36|      1|#define RECTYPE_VER  1
  ------------------
  982|      1|      if (rc)
  ------------------
  |  Branch (982:11): [True: 0, False: 1]
  ------------------
  983|      0|        log_fatal (_("%s: error reading version record: %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  984|      0|                   db_name, gpg_strerror (rc) );
  985|       |
  986|      1|      if (!vr.r.ver.trusthashtbl)
  ------------------
  |  Branch (986:11): [True: 0, False: 1]
  ------------------
  987|      0|        {
  988|       |          /* Oops: the trustdb is corrupt because the hashtable is
  989|       |           * always created along with the version record.  However,
  990|       |           * if something went initially wrong it may happen that
  991|       |           * there is just the version record.  We try to fix it here.
  992|       |           * If we can't do that we return 0 - this is the version
  993|       |           * record and thus the actual read will detect the mismatch
  994|       |           * and bail out.  Note that create_hashtable updates VR.  */
  995|      0|          take_write_lock ();
  996|      0|          if (lseek (db_fd, 0, SEEK_END) == TRUST_RECORD_LEN)
  ------------------
  |  |   25|      0|#define TRUST_RECORD_LEN 40
  ------------------
  |  Branch (996:15): [True: 0, False: 0]
  ------------------
  997|      0|            create_hashtable (ctrl, &vr, 0);
  998|      0|          release_write_lock ();
  999|      0|        }
 1000|      1|      trusthashtbl = vr.r.ver.trusthashtbl;
 1001|      1|    }
 1002|       |
 1003|      2|  return trusthashtbl;
 1004|      2|}
tdbio.c:lookup_hashtable:
 1298|      2|{
 1299|      2|  int rc;
 1300|      2|  ulong hashrec, item;
 1301|      2|  int msb;
 1302|      2|  int level = 0;
 1303|       |
 1304|      2|  if (!table)
  ------------------
  |  Branch (1304:7): [True: 0, False: 2]
  ------------------
 1305|      0|    {
 1306|      0|      rc = gpg_error (GPG_ERR_INV_RECORD);
 1307|      0|      log_error("lookup_hashtable failed: %s\n", "request for record 0");
 1308|      0|      return rc;
 1309|      0|    }
 1310|       |
 1311|      2|  hashrec = table;
 1312|      2| next_level:
 1313|      2|  msb = key[level];
 1314|      2|  hashrec += msb / ITEMS_PER_HTBL_RECORD;
  ------------------
  |  |   27|      2|#define ITEMS_PER_HTBL_RECORD	((TRUST_RECORD_LEN-2)/4)
  |  |  ------------------
  |  |  |  |   25|      2|#define TRUST_RECORD_LEN 40
  |  |  ------------------
  ------------------
 1315|      2|  rc = tdbio_read_record (hashrec, rec, RECTYPE_HTBL);
  ------------------
  |  |   37|      2|#define RECTYPE_HTBL 10
  ------------------
 1316|      2|  if (rc)
  ------------------
  |  Branch (1316:7): [True: 0, False: 2]
  ------------------
 1317|      0|    {
 1318|      0|      log_error("lookup_hashtable failed: %s\n", gpg_strerror (rc) );
 1319|      0|      return rc;
 1320|      0|    }
 1321|       |
 1322|      2|  item = rec->r.htbl.item[msb % ITEMS_PER_HTBL_RECORD];
  ------------------
  |  |   27|      2|#define ITEMS_PER_HTBL_RECORD	((TRUST_RECORD_LEN-2)/4)
  |  |  ------------------
  |  |  |  |   25|      2|#define TRUST_RECORD_LEN 40
  |  |  ------------------
  ------------------
 1323|      2|  if (!item)
  ------------------
  |  Branch (1323:7): [True: 2, False: 0]
  ------------------
 1324|      2|    return gpg_error (GPG_ERR_NOT_FOUND);
 1325|       |
 1326|      0|  rc = tdbio_read_record (item, rec, 0);
 1327|      0|  if (rc)
  ------------------
  |  Branch (1327:7): [True: 0, False: 0]
  ------------------
 1328|      0|    {
 1329|      0|      log_error( "hashtable read failed: %s\n", gpg_strerror (rc) );
 1330|      0|      return rc;
 1331|      0|    }
 1332|      0|  if (rec->rectype == RECTYPE_HTBL)
  ------------------
  |  |   37|      0|#define RECTYPE_HTBL 10
  ------------------
  |  Branch (1332:7): [True: 0, False: 0]
  ------------------
 1333|      0|    {
 1334|      0|      hashrec = item;
 1335|      0|      level++;
 1336|      0|      if (level >= keylen)
  ------------------
  |  Branch (1336:11): [True: 0, False: 0]
  ------------------
 1337|      0|        {
 1338|      0|          log_error ("hashtable has invalid indirections\n");
 1339|      0|          return GPG_ERR_TRUSTDB;
 1340|      0|	}
 1341|      0|      goto next_level;
 1342|      0|    }
 1343|      0|  else if (rec->rectype == RECTYPE_HLST)
  ------------------
  |  |   38|      0|#define RECTYPE_HLST 11
  ------------------
  |  Branch (1343:12): [True: 0, False: 0]
  ------------------
 1344|      0|    {
 1345|      0|      for (;;)
 1346|      0|        {
 1347|      0|          int i;
 1348|       |
 1349|      0|          for (i=0; i < ITEMS_PER_HLST_RECORD; i++)
  ------------------
  |  |   28|      0|#define ITEMS_PER_HLST_RECORD	((TRUST_RECORD_LEN-6)/5)
  |  |  ------------------
  |  |  |  |   25|      0|#define TRUST_RECORD_LEN 40
  |  |  ------------------
  ------------------
  |  Branch (1349:21): [True: 0, False: 0]
  ------------------
 1350|      0|            {
 1351|      0|              if (rec->r.hlst.rnum[i])
  ------------------
  |  Branch (1351:19): [True: 0, False: 0]
  ------------------
 1352|      0|                {
 1353|      0|                  TRUSTREC tmp;
 1354|       |
 1355|      0|                  rc = tdbio_read_record (rec->r.hlst.rnum[i], &tmp, 0);
 1356|      0|                  if (rc)
  ------------------
  |  Branch (1356:23): [True: 0, False: 0]
  ------------------
 1357|      0|                    {
 1358|      0|                      log_error ("lookup_hashtable: read item failed: %s\n",
 1359|      0|                                 gpg_strerror (rc));
 1360|      0|                      return rc;
 1361|      0|		    }
 1362|      0|                  if ((*cmpfnc)(cmpdata, &tmp))
  ------------------
  |  Branch (1362:23): [True: 0, False: 0]
  ------------------
 1363|      0|                    {
 1364|      0|                      *rec = tmp;
 1365|      0|                      return 0;
 1366|      0|		    }
 1367|      0|		}
 1368|      0|	    }
 1369|      0|          if (rec->r.hlst.next)
  ------------------
  |  Branch (1369:15): [True: 0, False: 0]
  ------------------
 1370|      0|            {
 1371|      0|              rc = tdbio_read_record (rec->r.hlst.next, rec, RECTYPE_HLST);
  ------------------
  |  |   38|      0|#define RECTYPE_HLST 11
  ------------------
 1372|      0|              if (rc)
  ------------------
  |  Branch (1372:19): [True: 0, False: 0]
  ------------------
 1373|      0|                {
 1374|      0|                  log_error ("lookup_hashtable: read hlst failed: %s\n",
 1375|      0|                             gpg_strerror (rc) );
 1376|      0|                  return rc;
 1377|      0|		}
 1378|      0|	    }
 1379|      0|          else
 1380|      0|            return gpg_error (GPG_ERR_NOT_FOUND);
 1381|      0|	}
 1382|      0|    }
 1383|       |
 1384|      0|  if ((*cmpfnc)(cmpdata, rec))
  ------------------
  |  Branch (1384:7): [True: 0, False: 0]
  ------------------
 1385|      0|    return 0; /* really found */
 1386|       |
 1387|      0|  return gpg_error (GPG_ERR_NOT_FOUND); /* no: not found */
 1388|      0|}

clear_ownertrusts:
  281|      2|{
  282|       |#ifdef NO_TRUST_MODELS
  283|       |  (void)pk;
  284|       |  return 0;
  285|       |#else
  286|      2|  return tdb_clear_ownertrusts (ctrl, pk);
  287|      2|#endif
  288|      2|}
revalidation_mark:
  293|     11|{
  294|     11|#ifndef NO_TRUST_MODELS
  295|     11|  tdb_revalidation_mark (ctrl);
  296|     11|#endif
  297|     11|}
check_trustdb_stale:
  302|      1|{
  303|      1|#ifndef NO_TRUST_MODELS
  304|      1|  tdb_check_trustdb_stale (ctrl);
  305|       |#else
  306|       |  (void)ctrl;
  307|       |#endif
  308|      1|}
check_or_update_trustdb:
  313|     53|{
  314|     53|#ifndef NO_TRUST_MODELS
  315|     53|  tdb_check_or_update (ctrl);
  316|       |#else
  317|       |  (void)ctrl;
  318|       |#endif
  319|     53|}

setup_trustdb:
  537|      1|{
  538|       |    /* just store the args */
  539|      1|    if( trustdb_args.init )
  ------------------
  |  Branch (539:9): [True: 0, False: 1]
  ------------------
  540|      0|	return 0;
  541|      1|    trustdb_args.level = level;
  542|      1|    trustdb_args.dbname = dbname? xstrdup(dbname): NULL;
  ------------------
  |  |  112|      0|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
  |  Branch (542:27): [True: 0, False: 1]
  ------------------
  543|      1|    return 0;
  544|      1|}
init_trustdb:
  573|     18|{
  574|     18|  int level = trustdb_args.level;
  575|     18|  const char* dbname = trustdb_args.dbname;
  576|       |
  577|     18|  if( trustdb_args.init )
  ------------------
  |  Branch (577:7): [True: 17, False: 1]
  ------------------
  578|     17|    return 0;
  579|       |
  580|      1|  trustdb_args.init = 1;
  581|       |
  582|      1|  if(level==0 || level==1)
  ------------------
  |  Branch (582:6): [True: 0, False: 1]
  |  Branch (582:18): [True: 1, False: 0]
  ------------------
  583|      1|    {
  584|      1|      int rc = tdbio_set_dbname (ctrl, dbname, (!no_create && level),
  ------------------
  |  Branch (584:49): [True: 1, False: 0]
  |  Branch (584:63): [True: 1, False: 0]
  ------------------
  585|      1|                                 &trustdb_args.no_trustdb);
  586|      1|      if (no_create && trustdb_args.no_trustdb)
  ------------------
  |  Branch (586:11): [True: 0, False: 1]
  |  Branch (586:24): [True: 0, False: 0]
  ------------------
  587|      0|        {
  588|       |          /* No trustdb found and the caller asked us not to create
  589|       |           * it.  Return an error and set the initialization state
  590|       |           * back so that we always test for an existing trustdb.  */
  591|      0|          trustdb_args.init = 0;
  592|      0|          return gpg_error (GPG_ERR_ENOENT);
  593|      0|        }
  594|      1|      if (rc)
  ------------------
  |  Branch (594:11): [True: 0, False: 1]
  ------------------
  595|      0|	log_fatal("can't init trustdb: %s\n", gpg_strerror (rc) );
  596|      1|    }
  597|      0|  else
  598|      0|    BUG();
  ------------------
  |  |   44|      0|#  define BUG() bug_at ( __FILE__, __LINE__, __FUNCTION__)
  ------------------
  599|       |
  600|      1|  if(opt.trust_model==TM_AUTO)
  ------------------
  |  Branch (600:6): [True: 0, False: 1]
  ------------------
  601|      0|    {
  602|       |      /* Try and set the trust model off of whatever the trustdb says
  603|       |	 it is. */
  604|      0|      opt.trust_model=tdbio_read_model();
  605|       |
  606|       |      /* Sanity check this ;) */
  607|      0|      if(opt.trust_model != TM_CLASSIC
  ------------------
  |  Branch (607:10): [True: 0, False: 0]
  ------------------
  608|      0|	 && opt.trust_model != TM_PGP
  ------------------
  |  Branch (608:6): [True: 0, False: 0]
  ------------------
  609|      0|	 && opt.trust_model != TM_TOFU_PGP
  ------------------
  |  Branch (609:6): [True: 0, False: 0]
  ------------------
  610|      0|	 && opt.trust_model != TM_TOFU
  ------------------
  |  Branch (610:6): [True: 0, False: 0]
  ------------------
  611|      0|	 && opt.trust_model != TM_EXTERNAL)
  ------------------
  |  Branch (611:6): [True: 0, False: 0]
  ------------------
  612|      0|	{
  613|      0|	  log_info(_("unable to use unknown trust model (%d) - "
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  614|      0|		     "assuming %s trust model\n"),opt.trust_model,"pgp");
  615|      0|	  opt.trust_model = TM_PGP;
  616|      0|	}
  617|       |
  618|      0|      if(opt.verbose)
  ------------------
  |  Branch (618:10): [True: 0, False: 0]
  ------------------
  619|      0|	log_info(_("using %s trust model\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  620|      0|                 trust_model_string (opt.trust_model));
  621|      0|    }
  622|       |
  623|      1|  if (opt.trust_model==TM_PGP || opt.trust_model==TM_CLASSIC
  ------------------
  |  Branch (623:7): [True: 0, False: 1]
  |  Branch (623:34): [True: 1, False: 0]
  ------------------
  624|      1|      || opt.trust_model == TM_TOFU || opt.trust_model == TM_TOFU_PGP)
  ------------------
  |  Branch (624:10): [True: 0, False: 0]
  |  Branch (624:40): [True: 0, False: 0]
  ------------------
  625|      1|    {
  626|       |      /* Verify the list of ultimately trusted keys and move the
  627|       |	 --trusted-keys list there as well. */
  628|      1|      if(level==1)
  ------------------
  |  Branch (628:10): [True: 1, False: 0]
  ------------------
  629|      1|	verify_own_keys (ctrl);
  630|       |
  631|      1|      if(!tdbio_db_matches_options())
  ------------------
  |  Branch (631:10): [True: 0, False: 1]
  ------------------
  632|      0|	pending_check_trustdb=1;
  633|      1|    }
  634|       |
  635|      1|  return 0;
  636|      1|}
check_trustdb:
  656|      2|{
  657|      2|  init_trustdb (ctrl, 0);
  658|      2|  if (opt.trust_model == TM_PGP || opt.trust_model == TM_CLASSIC
  ------------------
  |  Branch (658:7): [True: 0, False: 2]
  |  Branch (658:36): [True: 2, False: 0]
  ------------------
  659|      2|      || opt.trust_model == TM_TOFU_PGP || opt.trust_model == TM_TOFU)
  ------------------
  |  Branch (659:10): [True: 0, False: 0]
  |  Branch (659:44): [True: 0, False: 0]
  ------------------
  660|      2|    {
  661|      2|      if (opt.batch && !opt.answer_yes)
  ------------------
  |  Branch (661:11): [True: 0, False: 2]
  |  Branch (661:24): [True: 0, False: 0]
  ------------------
  662|      0|	{
  663|      0|	  ulong scheduled;
  664|       |
  665|      0|	  scheduled = tdbio_read_nextcheck ();
  666|      0|	  if (!scheduled)
  ------------------
  |  Branch (666:8): [True: 0, False: 0]
  ------------------
  667|      0|	    {
  668|      0|	      log_info (_("no need for a trustdb check\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  669|      0|	      return;
  670|      0|	    }
  671|       |
  672|      0|	  if (scheduled > make_timestamp ())
  ------------------
  |  Branch (672:8): [True: 0, False: 0]
  ------------------
  673|      0|	    {
  674|      0|	      log_info (_("next trustdb check due at %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  675|      0|			strtimestamp (scheduled));
  676|      0|	      return;
  677|      0|	    }
  678|      0|	}
  679|       |
  680|      2|      validate_keys (ctrl, 0);
  681|      2|    }
  682|      0|  else
  683|      0|    log_info (_("no need for a trustdb check with '%s' trust model\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  684|      0|	      trust_model_string(opt.trust_model));
  685|      2|}
tdb_revalidation_mark:
  705|     11|{
  706|     11|  init_trustdb (ctrl, 0);
  707|     11|  if (trustdb_args.no_trustdb && opt.trust_model == TM_ALWAYS)
  ------------------
  |  Branch (707:7): [True: 0, False: 11]
  |  Branch (707:34): [True: 0, False: 0]
  ------------------
  708|      0|    return;
  709|       |
  710|       |  /* We simply set the time for the next check to 1 (far back in 1970)
  711|       |     so that a --update-trustdb will be scheduled.  */
  712|     11|  if (tdbio_write_nextcheck (ctrl, 1))
  ------------------
  |  Branch (712:7): [True: 2, False: 9]
  ------------------
  713|      2|    do_sync ();
  714|     11|  pending_check_trustdb = 1;
  715|     11|}
trustdb_pending_check:
  719|     53|{
  720|     53|  return pending_check_trustdb;
  721|     53|}
tdb_check_or_update:
  727|     53|{
  728|     53|  if (trustdb_pending_check ())
  ------------------
  |  Branch (728:7): [True: 2, False: 51]
  ------------------
  729|      2|    {
  730|      2|      if (opt.interactive)
  ------------------
  |  Branch (730:11): [True: 0, False: 2]
  ------------------
  731|      0|	update_trustdb (ctrl);
  732|      2|      else if (!opt.no_auto_check_trustdb)
  ------------------
  |  Branch (732:16): [True: 2, False: 0]
  ------------------
  733|      2|	check_trustdb (ctrl);
  734|      2|    }
  735|     53|}
tdb_clear_ownertrusts:
  991|      2|{
  992|      2|  TRUSTREC rec;
  993|      2|  gpg_error_t err;
  994|       |
  995|      2|  init_trustdb (ctrl, 0);
  996|       |
  997|      2|  if (trustdb_args.no_trustdb && opt.trust_model == TM_ALWAYS)
  ------------------
  |  Branch (997:7): [True: 0, False: 2]
  |  Branch (997:34): [True: 0, False: 0]
  ------------------
  998|      0|    return 0;
  999|       |
 1000|      2|  err = read_trust_record (ctrl, pk, &rec);
 1001|      2|  if (!err)
  ------------------
  |  Branch (1001:7): [True: 0, False: 2]
  ------------------
 1002|      0|    {
 1003|      0|      if (DBG_TRUST)
  ------------------
  |  |  353|      0|#define DBG_TRUST  (opt.debug & DBG_TRUST_VALUE)
  |  |  ------------------
  |  |  |  |  340|      0|#define DBG_TRUST_VALUE   256	/* debug the trustdb */
  |  |  ------------------
  |  |  |  Branch (353:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1004|      0|	{
 1005|      0|	  log_debug ("clearing ownertrust (old value %u)\n",
 1006|      0|		     (unsigned int)rec.r.trust.ownertrust);
 1007|      0|	  log_debug ("clearing min_ownertrust (old value %u)\n",
 1008|      0|		     (unsigned int)rec.r.trust.min_ownertrust);
 1009|      0|	}
 1010|      0|      if (rec.r.trust.ownertrust || rec.r.trust.min_ownertrust)
  ------------------
  |  Branch (1010:11): [True: 0, False: 0]
  |  Branch (1010:37): [True: 0, False: 0]
  ------------------
 1011|      0|        {
 1012|      0|          rec.r.trust.ownertrust = 0;
 1013|      0|          rec.r.trust.min_ownertrust = 0;
 1014|      0|          write_record (ctrl, &rec);
 1015|      0|          tdb_revalidation_mark (ctrl);
 1016|      0|          do_sync ();
 1017|      0|          return 1;
 1018|      0|        }
 1019|      0|    }
 1020|      2|  else if (gpg_err_code (err) != GPG_ERR_NOT_FOUND)
  ------------------
  |  Branch (1020:12): [True: 0, False: 2]
  ------------------
 1021|      0|    {
 1022|      0|      tdbio_invalid ();
 1023|      0|    }
 1024|      2|  return 0;
 1025|      2|}
tdb_check_trustdb_stale:
 1132|      1|{
 1133|      1|  static int did_nextcheck=0;
 1134|       |
 1135|      1|  init_trustdb (ctrl, 0);
 1136|       |
 1137|      1|  if (trustdb_args.no_trustdb)
  ------------------
  |  Branch (1137:7): [True: 0, False: 1]
  ------------------
 1138|      0|    return;  /* No trustdb => can't be stale.  */
 1139|       |
 1140|      1|  if (!did_nextcheck
  ------------------
  |  Branch (1140:7): [True: 1, False: 0]
  ------------------
 1141|      1|      && (opt.trust_model == TM_PGP || opt.trust_model == TM_CLASSIC
  ------------------
  |  Branch (1141:11): [True: 0, False: 1]
  |  Branch (1141:40): [True: 1, False: 0]
  ------------------
 1142|      1|          || opt.trust_model == TM_TOFU_PGP || opt.trust_model == TM_TOFU))
  ------------------
  |  Branch (1142:14): [True: 0, False: 0]
  |  Branch (1142:48): [True: 0, False: 0]
  ------------------
 1143|      1|    {
 1144|      1|      ulong scheduled;
 1145|       |
 1146|      1|      did_nextcheck = 1;
 1147|      1|      scheduled = tdbio_read_nextcheck ();
 1148|      1|      if ((scheduled && scheduled <= make_timestamp ())
  ------------------
  |  Branch (1148:12): [True: 0, False: 1]
  |  Branch (1148:25): [True: 0, False: 0]
  ------------------
 1149|      1|	  || pending_check_trustdb)
  ------------------
  |  Branch (1149:7): [True: 0, False: 1]
  ------------------
 1150|      0|        {
 1151|      0|          if (opt.no_auto_check_trustdb)
  ------------------
  |  Branch (1151:15): [True: 0, False: 0]
  ------------------
 1152|      0|            {
 1153|      0|              pending_check_trustdb = 1;
 1154|      0|              if (!opt.quiet)
  ------------------
  |  Branch (1154:19): [True: 0, False: 0]
  ------------------
 1155|      0|                log_info (_("please do a --check-trustdb\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1156|      0|            }
 1157|      0|          else
 1158|      0|            {
 1159|      0|              if (!opt.quiet)
  ------------------
  |  Branch (1159:19): [True: 0, False: 0]
  ------------------
 1160|      0|                log_info (_("checking the trustdb\n"));
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 1161|      0|              validate_keys (ctrl, 0);
 1162|      0|            }
 1163|      0|        }
 1164|      1|    }
 1165|      1|}
trustdb.c:verify_own_keys:
  359|      1|{
  360|      1|  TRUSTREC rec;
  361|      1|  ulong recnum;
  362|      1|  int rc;
  363|      1|  struct key_item *k, *k2;
  364|      1|  int need_revalidation = 0;
  365|       |
  366|      1|  if (utk_list)
  ------------------
  |  Branch (366:7): [True: 0, False: 1]
  ------------------
  367|      0|    return; /* Has already been run.  */
  368|       |
  369|       |  /* scan the trustdb to find all ultimately trusted keys */
  370|     30|  for (recnum=1; !tdbio_read_record (recnum, &rec, 0); recnum++ )
  ------------------
  |  Branch (370:18): [True: 29, False: 1]
  ------------------
  371|     29|    {
  372|     29|      if (rec.rectype == RECTYPE_TRUST
  ------------------
  |  |   39|     58|#define RECTYPE_TRUST 12
  ------------------
  |  Branch (372:11): [True: 0, False: 29]
  ------------------
  373|     29|          && (rec.r.trust.ownertrust & TRUST_MASK) == TRUST_ULTIMATE)
  ------------------
  |  |   25|      0|#define TRUST_MASK	 15
  ------------------
                        && (rec.r.trust.ownertrust & TRUST_MASK) == TRUST_ULTIMATE)
  ------------------
  |  |   32|      0|#define TRUST_ULTIMATE	  6  /* u: ultimately trusted */
  ------------------
  |  Branch (373:14): [True: 0, False: 0]
  ------------------
  374|      0|        {
  375|      0|          u32 kid[2];
  376|       |
  377|      0|          keyid_from_fpr20 (ctrl, rec.r.trust.fingerprint, kid);
  378|      0|          if (!add_utk (kid))
  ------------------
  |  Branch (378:15): [True: 0, False: 0]
  ------------------
  379|      0|            log_info (_("key %s occurs more than once in the trustdb\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  380|      0|                      keystr(kid));
  381|      0|          else if ((rec.r.trust.flags & 1))
  ------------------
  |  Branch (381:20): [True: 0, False: 0]
  ------------------
  382|      0|            {
  383|       |              /* Record marked as inserted via --trusted-key.  Is this
  384|       |               * still the case?  */
  385|      0|              for (k2 = user_utk_list; k2; k2 = k2->next)
  ------------------
  |  Branch (385:40): [True: 0, False: 0]
  ------------------
  386|      0|                if (k2->kid[0] == kid[0] && k2->kid[1] == kid[1])
  ------------------
  |  Branch (386:21): [True: 0, False: 0]
  |  Branch (386:45): [True: 0, False: 0]
  ------------------
  387|      0|                  break;
  388|      0|              if (!k2) /* No - clear the flag.  */
  ------------------
  |  Branch (388:19): [True: 0, False: 0]
  ------------------
  389|      0|                {
  390|      0|                  if (DBG_TRUST)
  ------------------
  |  |  353|      0|#define DBG_TRUST  (opt.debug & DBG_TRUST_VALUE)
  |  |  ------------------
  |  |  |  |  340|      0|#define DBG_TRUST_VALUE   256	/* debug the trustdb */
  |  |  ------------------
  |  |  |  Branch (353:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  391|      0|                    log_debug ("clearing former --trusted-key %s\n",
  392|      0|                               keystr (kid));
  393|      0|                  rec.r.trust.ownertrust = TRUST_UNKNOWN;
  ------------------
  |  |   26|      0|#define TRUST_UNKNOWN	  0  /* o: not yet calculated/assigned */
  ------------------
  394|      0|                  rec.r.trust.flags &= ~(rec.r.trust.flags & 1);
  395|      0|                  write_record (ctrl, &rec);
  396|      0|                  need_revalidation = 1;
  397|      0|                }
  398|      0|            }
  399|      0|        }
  400|     29|    }
  401|       |
  402|      1|  if (need_revalidation)
  ------------------
  |  Branch (402:7): [True: 0, False: 1]
  ------------------
  403|      0|    {
  404|      0|      tdb_revalidation_mark (ctrl);
  405|      0|      do_sync ();
  406|      0|    }
  407|       |
  408|       |  /* Put any --trusted-key keys into the trustdb */
  409|      1|  for (k = user_utk_list; k; k = k->next)
  ------------------
  |  Branch (409:27): [True: 0, False: 1]
  ------------------
  410|      0|    {
  411|      0|      if ( add_utk (k->kid) )
  ------------------
  |  Branch (411:12): [True: 0, False: 0]
  ------------------
  412|      0|        { /* not yet in trustDB as ultimately trusted */
  413|      0|          PKT_public_key pk;
  414|       |
  415|      0|          memset (&pk, 0, sizeof pk);
  416|      0|          rc = get_pubkey_with_ldap_fallback (ctrl, &pk, k->kid);
  417|      0|          if (rc)
  ------------------
  |  Branch (417:15): [True: 0, False: 0]
  ------------------
  418|      0|	    log_info(_("key %s: no public key for trusted key - skipped\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  419|      0|		     keystr(k->kid));
  420|      0|          else
  421|      0|	    {
  422|      0|	      tdb_update_ownertrust
  423|      0|                (ctrl, &pk, ((tdb_get_ownertrust (ctrl, &pk, 0) & ~TRUST_MASK)
  ------------------
  |  |   25|      0|#define TRUST_MASK	 15
  ------------------
  424|      0|                             | TRUST_ULTIMATE ),  1);
  ------------------
  |  |   32|      0|#define TRUST_ULTIMATE	  6  /* u: ultimately trusted */
  ------------------
  425|      0|	      release_public_key_parts (&pk);
  426|      0|	    }
  427|       |
  428|      0|          if (!opt.quiet)
  ------------------
  |  Branch (428:15): [True: 0, False: 0]
  ------------------
  429|      0|            log_info (_("key %s marked as ultimately trusted\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  430|      0|                      keystr(k->kid));
  431|      0|        }
  432|      0|    }
  433|       |
  434|       |  /* release the helper table table */
  435|      1|  release_key_items (user_utk_list);
  436|      1|  user_utk_list = NULL;
  437|      1|  return;
  438|      1|}
trustdb.c:release_key_items:
  137|  6.14k|{
  138|  6.14k|  struct key_item *k2;
  139|       |
  140|  6.14k|  for (; k; k = k2)
  ------------------
  |  Branch (140:10): [True: 0, False: 6.14k]
  ------------------
  141|      0|    {
  142|      0|      k2 = k->next;
  143|      0|      xfree (k->trust_regexp);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  144|      0|      xfree (k);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  145|      0|    }
  146|  6.14k|}
trustdb.c:do_sync:
  505|      4|{
  506|      4|    int rc = tdbio_sync ();
  507|      4|    if(rc)
  ------------------
  |  Branch (507:8): [True: 0, False: 4]
  ------------------
  508|      0|      {
  509|      0|        log_error (_("trustdb: sync failed: %s\n"), gpg_strerror (rc) );
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
  510|      0|        g10_exit(2);
  511|      0|      }
  512|      4|}
trustdb.c:read_trust_record:
  773|      2|{
  774|      2|  int rc;
  775|       |
  776|      2|  init_trustdb (ctrl, 0);
  777|      2|  rc = tdbio_search_trust_bypk (ctrl, pk, rec);
  778|      2|  if (rc)
  ------------------
  |  Branch (778:7): [True: 2, False: 0]
  ------------------
  779|      2|    {
  780|      2|      if (gpg_err_code (rc) != GPG_ERR_NOT_FOUND)
  ------------------
  |  Branch (780:11): [True: 0, False: 2]
  ------------------
  781|      0|        log_error ("trustdb: searching trust record failed: %s\n",
  782|      0|                   gpg_strerror (rc));
  783|      2|      return rc;
  784|      2|    }
  785|       |
  786|      0|  if (rec->rectype != RECTYPE_TRUST)
  ------------------
  |  |   39|      0|#define RECTYPE_TRUST 12
  ------------------
  |  Branch (786:7): [True: 0, False: 0]
  ------------------
  787|      0|    {
  788|      0|      log_error ("trustdb: record %lu is not a trust record\n",
  789|      0|                 rec->recnum);
  790|      0|      return GPG_ERR_TRUSTDB;
  791|      0|    }
  792|       |
  793|      0|  return 0;
  794|      0|}
trustdb.c:validate_keys:
 2132|      2|{
 2133|      2|  int rc = 0;
 2134|      2|  int quit=0;
 2135|      2|  struct key_item *klist = NULL;
 2136|      2|  struct key_item *k;
 2137|      2|  struct key_array *keys = NULL;
 2138|      2|  struct key_array *kar;
 2139|      2|  KEYDB_HANDLE kdb = NULL;
 2140|      2|  KBNODE node;
 2141|      2|  int depth;
 2142|      2|  int ot_unknown, ot_undefined, ot_never, ot_marginal, ot_full, ot_ultimate;
 2143|      2|  KeyHashTable stored,used,full_trust;
 2144|      2|  u32 start_time, next_expire;
 2145|       |
 2146|       |  /* Make sure we have all sigs cached.  TODO: This is going to
 2147|       |     require some architectural re-thinking, as it is agonizingly slow.
 2148|       |     Perhaps combine this with reset_trust_records(), or only check
 2149|       |     the caches on keys that are actually involved in the web of
 2150|       |     trust. */
 2151|      2|  keydb_rebuild_caches (ctrl, 0);
 2152|       |
 2153|      2|  kdb = keydb_new (ctrl);
 2154|      2|  if (!kdb)
  ------------------
  |  Branch (2154:7): [True: 0, False: 2]
  ------------------
 2155|      0|    return gpg_error_from_syserror ();
 2156|       |
 2157|      2|  start_time = make_timestamp ();
 2158|      2|  next_expire = 0xffffffff; /* set next expire to the year 2106 */
 2159|      2|  stored = new_key_hash_table ();
 2160|      2|  used = new_key_hash_table ();
 2161|      2|  full_trust = new_key_hash_table ();
 2162|       |
 2163|      2|  reset_trust_records (ctrl);
 2164|       |
 2165|       |  /* Fixme: Instead of always building a UTK list, we could just build it
 2166|       |   * here when needed */
 2167|      2|  if (!utk_list)
  ------------------
  |  Branch (2167:7): [True: 2, False: 0]
  ------------------
 2168|      2|    {
 2169|      2|      if (!opt.quiet)
  ------------------
  |  Branch (2169:11): [True: 2, False: 0]
  ------------------
 2170|      2|        log_info (_("no ultimately trusted keys found\n"));
  ------------------
  |  |   28|      2|#  define _(a) gettext (a)
  ------------------
 2171|      2|      goto leave;
 2172|      2|    }
 2173|       |
 2174|       |  /* mark all UTKs as used and fully_trusted and set validity to
 2175|       |     ultimate */
 2176|      0|  for (k=utk_list; k; k = k->next)
  ------------------
  |  Branch (2176:20): [True: 0, False: 0]
  ------------------
 2177|      0|    {
 2178|      0|      KBNODE keyblock;
 2179|      0|      PKT_public_key *pk;
 2180|       |
 2181|      0|      keyblock = get_pubkeyblock (ctrl, k->kid);
 2182|      0|      if (!keyblock)
  ------------------
  |  Branch (2182:11): [True: 0, False: 0]
  ------------------
 2183|      0|        {
 2184|      0|          log_error (_("public key of ultimately"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2185|      0|                       " trusted key %s not found\n"), keystr(k->kid));
 2186|      0|          continue;
 2187|      0|        }
 2188|      0|      mark_keyblock_seen (used, keyblock);
 2189|      0|      mark_keyblock_seen (stored, keyblock);
 2190|      0|      mark_keyblock_seen (full_trust, keyblock);
 2191|      0|      pk = keyblock->pkt->pkt.public_key;
 2192|      0|      for (node=keyblock; node; node = node->next)
  ------------------
  |  Branch (2192:27): [True: 0, False: 0]
  ------------------
 2193|      0|        {
 2194|      0|          if (node->pkt->pkttype == PKT_USER_ID)
  ------------------
  |  Branch (2194:15): [True: 0, False: 0]
  ------------------
 2195|      0|	    update_validity (ctrl, pk, node->pkt->pkt.user_id,
 2196|      0|                             0, TRUST_ULTIMATE);
  ------------------
  |  |   32|      0|#define TRUST_ULTIMATE	  6  /* u: ultimately trusted */
  ------------------
 2197|      0|        }
 2198|      0|      if ( pk->expiredate && pk->expiredate >= start_time
  ------------------
  |  Branch (2198:12): [True: 0, False: 0]
  |  Branch (2198:30): [True: 0, False: 0]
  ------------------
 2199|      0|           && pk->expiredate < next_expire)
  ------------------
  |  Branch (2199:15): [True: 0, False: 0]
  ------------------
 2200|      0|        next_expire = pk->expiredate;
 2201|       |
 2202|      0|      release_kbnode (keyblock);
 2203|      0|      do_sync ();
 2204|      0|    }
 2205|       |
 2206|      0|  if (opt.trust_model == TM_TOFU)
  ------------------
  |  Branch (2206:7): [True: 0, False: 0]
  ------------------
 2207|       |    /* In the TOFU trust model, we only need to save the ultimately
 2208|       |       trusted keys.  */
 2209|      0|    goto leave;
 2210|       |
 2211|      0|  klist = utk_list;
 2212|       |
 2213|      0|  if (!opt.quiet)
  ------------------
  |  Branch (2213:7): [True: 0, False: 0]
  ------------------
 2214|      0|    log_info ("marginals needed: %d  completes needed: %d  trust model: %s\n",
 2215|      0|              opt.marginals_needed, opt.completes_needed,
 2216|      0|              trust_model_string (opt.trust_model));
 2217|       |
 2218|      0|  for (depth=0; depth < opt.max_cert_depth; depth++)
  ------------------
  |  Branch (2218:17): [True: 0, False: 0]
  ------------------
 2219|      0|    {
 2220|      0|      int valids=0,key_count;
 2221|       |      /* See whether we should assign ownertrust values to the keys in
 2222|       |         klist.  */
 2223|      0|      ot_unknown = ot_undefined = ot_never = 0;
 2224|      0|      ot_marginal = ot_full = ot_ultimate = 0;
 2225|      0|      for (k=klist; k; k = k->next)
  ------------------
  |  Branch (2225:21): [True: 0, False: 0]
  ------------------
 2226|      0|        {
 2227|      0|	  int min=0;
 2228|       |
 2229|       |	  /* 120 and 60 are as per RFC2440 */
 2230|      0|	  if(k->trust_value>=120)
  ------------------
  |  Branch (2230:7): [True: 0, False: 0]
  ------------------
 2231|      0|	    min=TRUST_FULLY;
  ------------------
  |  |   31|      0|#define TRUST_FULLY	  5  /* f: fully trusted      */
  ------------------
 2232|      0|	  else if(k->trust_value>=60)
  ------------------
  |  Branch (2232:12): [True: 0, False: 0]
  ------------------
 2233|      0|	    min=TRUST_MARGINAL;
  ------------------
  |  |   30|      0|#define TRUST_MARGINAL	  4  /* m: marginally trusted */
  ------------------
 2234|       |
 2235|      0|	  if(min!=k->min_ownertrust)
  ------------------
  |  Branch (2235:7): [True: 0, False: 0]
  ------------------
 2236|      0|	    update_min_ownertrust (ctrl, k->kid,min);
 2237|       |
 2238|      0|          if (interactive && k->ownertrust == TRUST_UNKNOWN)
  ------------------
  |  |   26|      0|#define TRUST_UNKNOWN	  0  /* o: not yet calculated/assigned */
  ------------------
  |  Branch (2238:15): [True: 0, False: 0]
  |  Branch (2238:30): [True: 0, False: 0]
  ------------------
 2239|      0|	    {
 2240|      0|	      k->ownertrust = ask_ownertrust (ctrl, k->kid,min);
 2241|       |
 2242|      0|	      if (k->ownertrust == (unsigned int)(-1))
  ------------------
  |  Branch (2242:12): [True: 0, False: 0]
  ------------------
 2243|      0|		{
 2244|      0|		  quit=1;
 2245|      0|		  goto leave;
 2246|      0|		}
 2247|      0|	    }
 2248|       |
 2249|       |	  /* This can happen during transition from an old trustdb
 2250|       |	     before trust sigs.  It can also happen if a user uses two
 2251|       |	     different versions of GnuPG or changes the --trust-model
 2252|       |	     setting. */
 2253|      0|	  if(k->ownertrust<min)
  ------------------
  |  Branch (2253:7): [True: 0, False: 0]
  ------------------
 2254|      0|	    {
 2255|      0|	      if(DBG_TRUST)
  ------------------
  |  |  353|      0|#define DBG_TRUST  (opt.debug & DBG_TRUST_VALUE)
  |  |  ------------------
  |  |  |  |  340|      0|#define DBG_TRUST_VALUE   256	/* debug the trustdb */
  |  |  ------------------
  |  |  |  Branch (353:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2256|      0|		log_debug("key %08lX%08lX:"
 2257|      0|			  " overriding ownertrust '%s' with '%s'\n",
 2258|      0|			  (ulong)k->kid[0],(ulong)k->kid[1],
 2259|      0|			  trust_value_to_string(k->ownertrust),
 2260|      0|			  trust_value_to_string(min));
 2261|       |
 2262|      0|	      k->ownertrust=min;
 2263|      0|	    }
 2264|       |
 2265|      0|	  if (k->ownertrust == TRUST_UNKNOWN)
  ------------------
  |  |   26|      0|#define TRUST_UNKNOWN	  0  /* o: not yet calculated/assigned */
  ------------------
  |  Branch (2265:8): [True: 0, False: 0]
  ------------------
 2266|      0|            ot_unknown++;
 2267|      0|          else if (k->ownertrust == TRUST_UNDEFINED)
  ------------------
  |  |   28|      0|#define TRUST_UNDEFINED   2  /* q: not enough information for calculation */
  ------------------
  |  Branch (2267:20): [True: 0, False: 0]
  ------------------
 2268|      0|            ot_undefined++;
 2269|      0|          else if (k->ownertrust == TRUST_NEVER)
  ------------------
  |  |   29|      0|#define TRUST_NEVER	  3  /* n: never trust this pubkey */
  ------------------
  |  Branch (2269:20): [True: 0, False: 0]
  ------------------
 2270|      0|            ot_never++;
 2271|      0|          else if (k->ownertrust == TRUST_MARGINAL)
  ------------------
  |  |   30|      0|#define TRUST_MARGINAL	  4  /* m: marginally trusted */
  ------------------
  |  Branch (2271:20): [True: 0, False: 0]
  ------------------
 2272|      0|            ot_marginal++;
 2273|      0|          else if (k->ownertrust == TRUST_FULLY)
  ------------------
  |  |   31|      0|#define TRUST_FULLY	  5  /* f: fully trusted      */
  ------------------
  |  Branch (2273:20): [True: 0, False: 0]
  ------------------
 2274|      0|            ot_full++;
 2275|      0|          else if (k->ownertrust == TRUST_ULTIMATE)
  ------------------
  |  |   32|      0|#define TRUST_ULTIMATE	  6  /* u: ultimately trusted */
  ------------------
  |  Branch (2275:20): [True: 0, False: 0]
  ------------------
 2276|      0|            ot_ultimate++;
 2277|       |
 2278|      0|	  valids++;
 2279|      0|        }
 2280|       |
 2281|       |      /* Find all keys which are signed by a key in kdlist */
 2282|      0|      keys = validate_key_list (ctrl, kdb, full_trust, klist,
 2283|      0|				start_time, &next_expire);
 2284|      0|      if (!keys)
  ------------------
  |  Branch (2284:11): [True: 0, False: 0]
  ------------------
 2285|      0|        {
 2286|      0|          log_error ("validate_key_list failed\n");
 2287|      0|          rc = GPG_ERR_GENERAL;
 2288|      0|          goto leave;
 2289|      0|        }
 2290|       |
 2291|      0|      for (key_count=0, kar=keys; kar->keyblock; kar++, key_count++)
  ------------------
  |  Branch (2291:35): [True: 0, False: 0]
  ------------------
 2292|      0|        ;
 2293|       |
 2294|       |      /* Store the calculated valididation status somewhere */
 2295|      0|      if (opt.verbose > 1 && DBG_TRUST)
  ------------------
  |  |  353|      0|#define DBG_TRUST  (opt.debug & DBG_TRUST_VALUE)
  |  |  ------------------
  |  |  |  |  340|      0|#define DBG_TRUST_VALUE   256	/* debug the trustdb */
  |  |  ------------------
  |  |  |  Branch (353:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2295:11): [True: 0, False: 0]
  ------------------
 2296|      0|        dump_key_array (depth, keys);
 2297|       |
 2298|      0|      for (kar=keys; kar->keyblock; kar++)
  ------------------
  |  Branch (2298:22): [True: 0, False: 0]
  ------------------
 2299|      0|        store_validation_status (ctrl, depth, kar->keyblock, stored);
 2300|       |
 2301|      0|      if (!opt.quiet)
  ------------------
  |  Branch (2301:11): [True: 0, False: 0]
  ------------------
 2302|      0|        log_info (_("depth: %d  valid: %3d  signed: %3d"
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2303|      0|                    "  trust: %d-, %dq, %dn, %dm, %df, %du\n"),
 2304|      0|                  depth, valids, key_count, ot_unknown, ot_undefined,
 2305|      0|                  ot_never, ot_marginal, ot_full, ot_ultimate );
 2306|       |
 2307|       |      /* Build a new kdlist from all fully valid keys in KEYS */
 2308|      0|      if (klist != utk_list)
  ------------------
  |  Branch (2308:11): [True: 0, False: 0]
  ------------------
 2309|      0|        release_key_items (klist);
 2310|      0|      klist = NULL;
 2311|      0|      for (kar=keys; kar->keyblock; kar++)
  ------------------
  |  Branch (2311:22): [True: 0, False: 0]
  ------------------
 2312|      0|        {
 2313|      0|          for (node=kar->keyblock; node; node = node->next)
  ------------------
  |  Branch (2313:36): [True: 0, False: 0]
  ------------------
 2314|      0|            {
 2315|      0|              if (node->pkt->pkttype == PKT_USER_ID && (node->flag & 4))
  ------------------
  |  Branch (2315:19): [True: 0, False: 0]
  |  Branch (2315:56): [True: 0, False: 0]
  ------------------
 2316|      0|                {
 2317|      0|		  u32 kid[2];
 2318|       |
 2319|       |		  /* have we used this key already? */
 2320|      0|                  keyid_from_pk (kar->keyblock->pkt->pkt.public_key, kid);
 2321|      0|		  if(test_key_hash_table(used,kid)==0)
  ------------------
  |  Branch (2321:8): [True: 0, False: 0]
  ------------------
 2322|      0|		    {
 2323|       |		      /* Normally we add both the primary and subkey
 2324|       |			 ids to the hash via mark_keyblock_seen, but
 2325|       |			 since we aren't using this hash as a skipfnc,
 2326|       |			 that doesn't matter here. */
 2327|      0|		      add_key_hash_table (used,kid);
 2328|      0|		      k = new_key_item ();
 2329|      0|		      k->kid[0]=kid[0];
 2330|      0|		      k->kid[1]=kid[1];
 2331|      0|		      k->ownertrust =
 2332|      0|			(tdb_get_ownertrust
 2333|      0|                           (ctrl, kar->keyblock->pkt->pkt.public_key, 0)
 2334|      0|                         & TRUST_MASK);
  ------------------
  |  |   25|      0|#define TRUST_MASK	 15
  ------------------
 2335|      0|		      k->min_ownertrust = tdb_get_min_ownertrust
 2336|      0|                        (ctrl, kar->keyblock->pkt->pkt.public_key, 0);
 2337|      0|		      k->trust_depth=
 2338|      0|			kar->keyblock->pkt->pkt.public_key->trust_depth;
 2339|      0|		      k->trust_value=
 2340|      0|			kar->keyblock->pkt->pkt.public_key->trust_value;
 2341|      0|		      if(kar->keyblock->pkt->pkt.public_key->trust_regexp)
  ------------------
  |  Branch (2341:12): [True: 0, False: 0]
  ------------------
 2342|      0|			k->trust_regexp=
 2343|      0|			  xstrdup(kar->keyblock->pkt->
  ------------------
  |  |  112|      0|#define xstrdup(a)       gcry_xstrdup ((a))
  ------------------
 2344|      0|				   pkt.public_key->trust_regexp);
 2345|      0|		      k->next = klist;
 2346|      0|		      klist = k;
 2347|      0|		      break;
 2348|      0|		    }
 2349|      0|		}
 2350|      0|	    }
 2351|      0|	}
 2352|      0|      release_key_array (keys);
 2353|      0|      keys = NULL;
 2354|      0|      if (!klist)
  ------------------
  |  Branch (2354:11): [True: 0, False: 0]
  ------------------
 2355|      0|        break; /* no need to dive in deeper */
 2356|      0|    }
 2357|       |
 2358|      2| leave:
 2359|      2|  keydb_release (kdb);
 2360|      2|  release_key_array (keys);
 2361|      2|  if (klist != utk_list)
  ------------------
  |  Branch (2361:7): [True: 0, False: 2]
  ------------------
 2362|      0|    release_key_items (klist);
 2363|      2|  release_key_hash_table (full_trust);
 2364|      2|  release_key_hash_table (used);
 2365|      2|  release_key_hash_table (stored);
 2366|      2|  if (!rc && !quit) /* mark trustDB as checked */
  ------------------
  |  Branch (2366:7): [True: 2, False: 0]
  |  Branch (2366:14): [True: 2, False: 0]
  ------------------
 2367|      2|    {
 2368|      2|      int rc2;
 2369|       |
 2370|      2|      if (next_expire == 0xffffffff || next_expire < start_time )
  ------------------
  |  Branch (2370:11): [True: 2, False: 0]
  |  Branch (2370:40): [True: 0, False: 0]
  ------------------
 2371|      2|        tdbio_write_nextcheck (ctrl, 0);
 2372|      0|      else
 2373|      0|        {
 2374|      0|          tdbio_write_nextcheck (ctrl, next_expire);
 2375|      0|          if (!opt.quiet)
  ------------------
  |  Branch (2375:15): [True: 0, False: 0]
  ------------------
 2376|      0|            log_info (_("next trustdb check due at %s\n"),
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2377|      0|                      strtimestamp (next_expire));
 2378|      0|        }
 2379|       |
 2380|      2|      rc2 = tdbio_update_version_record (ctrl);
 2381|      2|      if (rc2)
  ------------------
  |  Branch (2381:11): [True: 0, False: 2]
  ------------------
 2382|      0|	{
 2383|      0|	  log_error (_("unable to update trustdb version record: "
  ------------------
  |  |   28|      0|#  define _(a) gettext (a)
  ------------------
 2384|      0|                       "write failed: %s\n"), gpg_strerror (rc2));
 2385|      0|	  tdbio_invalid ();
 2386|      0|	}
 2387|       |
 2388|      2|      do_sync ();
 2389|      2|      pending_check_trustdb = 0;
 2390|      2|    }
 2391|       |
 2392|      2|  return rc;
 2393|      0|}
trustdb.c:new_key_hash_table:
  160|      6|{
  161|      6|  struct key_item **tbl;
  162|       |
  163|      6|  tbl = xmalloc_clear (KEY_HASH_TABLE_SIZE * sizeof *tbl);
  ------------------
  |  |  116|      6|#define xmalloc_clear(a) gcry_xcalloc (1, (a))
  ------------------
  164|      6|  return tbl;
  165|      6|}
trustdb.c:reset_trust_records:
 2065|      2|{
 2066|      2|  TRUSTREC rec;
 2067|      2|  ulong recnum;
 2068|      2|  int count = 0, nreset = 0;
 2069|       |
 2070|     60|  for (recnum=1; !tdbio_read_record (recnum, &rec, 0); recnum++ )
  ------------------
  |  Branch (2070:18): [True: 58, False: 2]
  ------------------
 2071|     58|    {
 2072|     58|      if(rec.rectype==RECTYPE_TRUST)
  ------------------
  |  |   39|     58|#define RECTYPE_TRUST 12
  ------------------
  |  Branch (2072:10): [True: 0, False: 58]
  ------------------
 2073|      0|	{
 2074|      0|	  count++;
 2075|      0|	  if(rec.r.trust.min_ownertrust)
  ------------------
  |  Branch (2075:7): [True: 0, False: 0]
  ------------------
 2076|      0|	    {
 2077|      0|	      rec.r.trust.min_ownertrust=0;
 2078|      0|	      write_record (ctrl, &rec);
 2079|      0|	    }
 2080|       |
 2081|      0|	}
 2082|     58|      else if(rec.rectype==RECTYPE_VALID
  ------------------
  |  |   40|    116|#define RECTYPE_VALID 13
  ------------------
  |  Branch (2082:15): [True: 0, False: 58]
  ------------------
 2083|     58|	      && ((rec.r.valid.validity&TRUST_MASK)
  ------------------
  |  |   25|      0|#define TRUST_MASK	 15
  ------------------
  |  Branch (2083:12): [True: 0, False: 0]
  ------------------
 2084|      0|		  || rec.r.valid.marginal_count
  ------------------
  |  Branch (2084:8): [True: 0, False: 0]
  ------------------
 2085|      0|		  || rec.r.valid.full_count))
  ------------------
  |  Branch (2085:8): [True: 0, False: 0]
  ------------------
 2086|      0|	{
 2087|      0|	  rec.r.valid.validity &= ~TRUST_MASK;
  ------------------
  |  |   25|      0|#define TRUST_MASK	 15
  ------------------
 2088|      0|	  rec.r.valid.marginal_count=rec.r.valid.full_count=0;
 2089|      0|	  nreset++;
 2090|      0|	  write_record (ctrl, &rec);
 2091|      0|	}
 2092|       |
 2093|     58|    }
 2094|       |
 2095|      2|  if (opt.verbose)
  ------------------
  |  Branch (2095:7): [True: 0, False: 2]
  ------------------
 2096|      0|    {
 2097|      0|      log_info (ngettext("%d key processed",
 2098|      0|                         "%d keys processed",
 2099|      0|                         count), count);
 2100|      0|      log_printf (ngettext(" (%d validity count cleared)\n",
 2101|      0|                           " (%d validity counts cleared)\n",
 2102|      0|                           nreset), nreset);
 2103|      0|    }
 2104|      2|}
trustdb.c:release_key_array:
  218|      2|{
  219|      2|    struct key_array *k;
  220|       |
  221|      2|    if (keys) {
  ------------------
  |  Branch (221:9): [True: 0, False: 2]
  ------------------
  222|      0|        for (k=keys; k->keyblock; k++)
  ------------------
  |  Branch (222:22): [True: 0, False: 0]
  ------------------
  223|      0|            release_kbnode (k->keyblock);
  224|      0|        xfree (keys);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  225|      0|    }
  226|      2|}
trustdb.c:release_key_hash_table:
  169|      6|{
  170|      6|  int i;
  171|       |
  172|      6|  if (!tbl)
  ------------------
  |  Branch (172:7): [True: 0, False: 6]
  ------------------
  173|      0|    return;
  174|  6.15k|  for (i=0; i < KEY_HASH_TABLE_SIZE; i++)
  ------------------
  |  |  148|  6.15k|#define KEY_HASH_TABLE_SIZE 1024
  ------------------
  |  Branch (174:13): [True: 6.14k, False: 6]
  ------------------
  175|  6.14k|    release_key_items (tbl[i]);
  176|      6|  xfree (tbl);
  ------------------
  |  |  104|      6|#define xfree(a)         gcry_free ((a))
  ------------------
  177|      6|}

keybox-search.c:buf16_to_ulong:
   49|    441|{
   50|    441|  const unsigned char *p = buffer;
   51|       |
   52|    441|  return (((unsigned long)p[0] << 8) | p[1]);
   53|    441|}
keybox-search.c:buf32_to_ulong:
   89|     48|{
   90|     48|  const unsigned char *p = buffer;
   91|       |
   92|     48|  return (((unsigned long)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
   93|     48|}
keybox-update.c:buf32_to_u32:
  105|      1|{
  106|      1|  const unsigned char *p = buffer;
  107|       |
  108|      1|  return (((u32)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
  109|      1|}

_keybox_create_openpgp_blob:
  755|     11|{
  756|     11|  gpg_error_t err;
  757|     11|  KEYBOXBLOB blob;
  758|     11|  int need_fpr32 = 0;
  759|       |
  760|     11|  *r_blob = NULL;
  761|       |
  762|       |
  763|       |  /* Check whether we need a blob with 32 bit fingerprints. We could
  764|       |   * use this always but for backward compatibility we do this only for
  765|       |   * v5 keys.  */
  766|     11|  if (info->primary.version == 5)
  ------------------
  |  Branch (766:7): [True: 0, False: 11]
  ------------------
  767|      0|    need_fpr32 = 1;
  768|     11|  else
  769|     11|    {
  770|     11|      struct _keybox_openpgp_key_info *kinfo;
  771|     22|      for (kinfo = &info->subkeys; kinfo; kinfo = kinfo->next)
  ------------------
  |  Branch (771:36): [True: 11, False: 11]
  ------------------
  772|     11|        if (kinfo->version == 5)
  ------------------
  |  Branch (772:13): [True: 0, False: 11]
  ------------------
  773|      0|          {
  774|      0|            need_fpr32 = 1;
  775|      0|            break;
  776|      0|          }
  777|     11|    }
  778|       |
  779|     11|  blob = xtrycalloc (1, sizeof *blob);
  ------------------
  |  |   99|     11|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  780|     11|  if (!blob)
  ------------------
  |  Branch (780:7): [True: 0, False: 11]
  ------------------
  781|      0|    return gpg_error_from_syserror ();
  782|       |
  783|     11|  blob->nkeys = 1 + info->nsubkeys;
  784|     11|  blob->keys = xtrycalloc (blob->nkeys, sizeof *blob->keys );
  ------------------
  |  |   99|     11|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  785|     11|  if (!blob->keys)
  ------------------
  |  Branch (785:7): [True: 0, False: 11]
  ------------------
  786|      0|    {
  787|      0|      err = gpg_error_from_syserror ();
  788|      0|      goto leave;
  789|      0|    }
  790|       |
  791|     11|  blob->nuids = info->nuids;
  792|     11|  if (blob->nuids)
  ------------------
  |  Branch (792:7): [True: 11, False: 0]
  ------------------
  793|     11|    {
  794|     11|      blob->uids = xtrycalloc (blob->nuids, sizeof *blob->uids );
  ------------------
  |  |   99|     11|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  795|     11|      if (!blob->uids)
  ------------------
  |  Branch (795:11): [True: 0, False: 11]
  ------------------
  796|      0|        {
  797|      0|          err = gpg_error_from_syserror ();
  798|      0|          goto leave;
  799|      0|        }
  800|     11|    }
  801|       |
  802|     11|  blob->nsigs = info->nsigs;
  803|     11|  if (blob->nsigs)
  ------------------
  |  Branch (803:7): [True: 11, False: 0]
  ------------------
  804|     11|    {
  805|     11|      blob->sigs = xtrycalloc (blob->nsigs, sizeof *blob->sigs );
  ------------------
  |  |   99|     11|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  806|     11|      if (!blob->sigs)
  ------------------
  |  Branch (806:11): [True: 0, False: 11]
  ------------------
  807|      0|        {
  808|      0|          err = gpg_error_from_syserror ();
  809|      0|          goto leave;
  810|      0|        }
  811|     11|    }
  812|       |
  813|     11|  err = pgp_create_key_part (blob, info);
  814|     11|  if (err)
  ------------------
  |  Branch (814:7): [True: 0, False: 11]
  ------------------
  815|      0|    goto leave;
  816|     11|  pgp_create_uid_part (blob, info);
  817|     11|  pgp_create_sig_part (blob, NULL);
  818|       |
  819|     11|  init_membuf (&blob->bufbuf, 1024);
  820|     11|  blob->buf = &blob->bufbuf;
  821|     11|  err = create_blob_header (blob, KEYBOX_BLOBTYPE_PGP,
  822|     11|                            as_ephemeral, need_fpr32);
  823|     11|  if (err)
  ------------------
  |  Branch (823:7): [True: 0, False: 11]
  ------------------
  824|      0|    goto leave;
  825|     11|  err = pgp_create_blob_keyblock (blob, image, imagelen);
  826|     11|  if (err)
  ------------------
  |  Branch (826:7): [True: 0, False: 11]
  ------------------
  827|      0|    goto leave;
  828|     11|  err = create_blob_trailer (blob);
  829|     11|  if (err)
  ------------------
  |  Branch (829:7): [True: 0, False: 11]
  ------------------
  830|      0|    goto leave;
  831|     11|  err = create_blob_finish (blob);
  832|     11|  if (err)
  ------------------
  |  Branch (832:7): [True: 0, False: 11]
  ------------------
  833|      0|    goto leave;
  834|       |
  835|     11| leave:
  836|     11|  release_kid_list (blob->temp_kids);
  837|     11|  blob->temp_kids = NULL;
  838|     11|  if (err)
  ------------------
  |  Branch (838:7): [True: 0, False: 11]
  ------------------
  839|      0|    _keybox_release_blob (blob);
  840|     11|  else
  841|     11|    *r_blob = blob;
  842|     11|  return err;
  843|     11|}
_keybox_new_blob:
 1050|    388|{
 1051|    388|  KEYBOXBLOB blob;
 1052|       |
 1053|    388|  *r_blob = NULL;
 1054|    388|  blob = xtrycalloc (1, sizeof *blob);
  ------------------
  |  |   99|    388|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
 1055|    388|  if (!blob)
  ------------------
  |  Branch (1055:7): [True: 0, False: 388]
  ------------------
 1056|      0|    return gpg_error_from_syserror ();
 1057|       |
 1058|    388|  blob->blob = image;
 1059|    388|  blob->bloblen = imagelen;
 1060|    388|  blob->fileoffset = off;
 1061|    388|  *r_blob = blob;
 1062|    388|  return 0;
 1063|    388|}
_keybox_release_blob:
 1068|  1.69k|{
 1069|  1.69k|  int i;
 1070|  1.69k|  if (!blob)
  ------------------
  |  Branch (1070:7): [True: 1.29k, False: 399]
  ------------------
 1071|  1.29k|    return;
 1072|    399|  if (blob->buf)
  ------------------
  |  Branch (1072:7): [True: 11, False: 388]
  ------------------
 1073|     11|    {
 1074|     11|      size_t len;
 1075|     11|      xfree (get_membuf (blob->buf, &len));
  ------------------
  |  |  104|     11|#define xfree(a)         gcry_free ((a))
  ------------------
 1076|     11|    }
 1077|    399|  xfree (blob->keys );
  ------------------
  |  |  104|    399|#define xfree(a)         gcry_free ((a))
  ------------------
 1078|    399|  xfree (blob->serialbuf);
  ------------------
  |  |  104|    399|#define xfree(a)         gcry_free ((a))
  ------------------
 1079|    410|  for (i=0; i < blob->nuids; i++)
  ------------------
  |  Branch (1079:13): [True: 11, False: 399]
  ------------------
 1080|     11|    xfree (blob->uids[i].name);
  ------------------
  |  |  104|    410|#define xfree(a)         gcry_free ((a))
  ------------------
 1081|    399|  xfree (blob->uids );
  ------------------
  |  |  104|    399|#define xfree(a)         gcry_free ((a))
  ------------------
 1082|    399|  xfree (blob->sigs );
  ------------------
  |  |  104|    399|#define xfree(a)         gcry_free ((a))
  ------------------
 1083|    399|  xfree (blob->blob );
  ------------------
  |  |  104|    399|#define xfree(a)         gcry_free ((a))
  ------------------
 1084|    399|  xfree (blob );
  ------------------
  |  |  104|    399|#define xfree(a)         gcry_free ((a))
  ------------------
 1085|    399|}
_keybox_get_blob_image:
 1091|    691|{
 1092|    691|  *n = blob->bloblen;
 1093|    691|  return blob->blob;
 1094|    691|}
_keybox_get_blob_fileoffset:
 1098|      9|{
 1099|      9|  return blob->fileoffset;
 1100|      9|}
keybox-blob.c:pgp_create_key_part:
  422|     11|{
  423|     11|  gpg_error_t err;
  424|     11|  int n = 0;
  425|     11|  struct _keybox_openpgp_key_info *kinfo;
  426|       |
  427|     11|  err = pgp_create_key_part_single (blob, n++, &info->primary);
  428|     11|  if (err)
  ------------------
  |  Branch (428:7): [True: 0, False: 11]
  ------------------
  429|      0|    return err;
  430|     11|  if (info->nsubkeys)
  ------------------
  |  Branch (430:7): [True: 3, False: 8]
  ------------------
  431|      6|    for (kinfo = &info->subkeys; kinfo; kinfo = kinfo->next)
  ------------------
  |  Branch (431:34): [True: 3, False: 3]
  ------------------
  432|      3|      if ((err=pgp_create_key_part_single (blob, n++, kinfo)))
  ------------------
  |  Branch (432:11): [True: 0, False: 3]
  ------------------
  433|      0|        return err;
  434|       |
  435|     11|  assert (n == blob->nkeys);
  436|     11|  return 0;
  437|     11|}
keybox-blob.c:pgp_create_key_part_single:
  397|     14|{
  398|     14|  size_t fprlen;
  399|     14|  int off;
  400|       |
  401|     14|  fprlen = kinfo->fprlen;
  402|     14|  memcpy (blob->keys[n].fpr, kinfo->fpr, fprlen);
  403|     14|  blob->keys[n].fprlen = fprlen;
  404|     14|  if (fprlen < 20) /* v3 fpr - shift right and fill with zeroes. */
  ------------------
  |  Branch (404:7): [True: 0, False: 14]
  ------------------
  405|      0|    {
  406|      0|      memmove (blob->keys[n].fpr + 20 - fprlen, blob->keys[n].fpr, fprlen);
  407|      0|      memset (blob->keys[n].fpr, 0, 20 - fprlen);
  408|      0|      off = pgp_temp_store_kid (blob, kinfo);
  409|      0|      if (off == -1)
  ------------------
  |  Branch (409:11): [True: 0, False: 0]
  ------------------
  410|      0|        return gpg_error_from_syserror ();
  411|      0|      blob->keys[n].off_kid = off;
  412|      0|    }
  413|     14|  else
  414|     14|    blob->keys[n].off_kid = 0; /* Will be fixed up later */
  415|     14|  blob->keys[n].flags = 0;
  416|     14|  return 0;
  417|     14|}
keybox-blob.c:pgp_create_uid_part:
  442|     11|{
  443|     11|  int n = 0;
  444|     11|  struct _keybox_openpgp_uid_info *u;
  445|       |
  446|     11|  if (info->nuids)
  ------------------
  |  Branch (446:7): [True: 11, False: 0]
  ------------------
  447|     11|    {
  448|     22|      for (u = &info->uids; u; u = u->next)
  ------------------
  |  Branch (448:29): [True: 11, False: 11]
  ------------------
  449|     11|        {
  450|     11|          blob->uids[n].off = u->off;
  451|     11|          blob->uids[n].len = u->len;
  452|     11|          blob->uids[n].flags = 0;
  453|     11|          blob->uids[n].validity = 0;
  454|     11|          n++;
  455|     11|        }
  456|     11|    }
  457|       |
  458|     11|  assert (n == blob->nuids);
  459|     11|}
keybox-blob.c:pgp_create_sig_part:
  464|     11|{
  465|     11|  int n;
  466|       |
  467|     70|  for (n=0; n < blob->nsigs; n++)
  ------------------
  |  Branch (467:13): [True: 59, False: 11]
  ------------------
  468|     59|    {
  469|     59|      blob->sigs[n] = sigstatus? sigstatus[n+1] : 0;
  ------------------
  |  Branch (469:23): [True: 0, False: 59]
  ------------------
  470|     59|    }
  471|     11|}
keybox-blob.c:init_membuf:
  259|     11|{
  260|     11|  mb->len = 0;
  261|     11|  mb->size = initiallen;
  262|     11|  mb->out_of_core = 0;
  263|     11|  mb->buf = xtrymalloc (initiallen);
  ------------------
  |  |   97|     11|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  264|     11|  if (!mb->buf)
  ------------------
  |  Branch (264:7): [True: 0, False: 11]
  ------------------
  265|      0|      mb->out_of_core = 1;
  266|     11|}
keybox-blob.c:create_blob_header:
  559|     11|{
  560|     11|  struct membuf *a = blob->buf;
  561|     11|  int i;
  562|       |
  563|     11|  put32 ( a, 0 ); /* blob length, needs fixup */
  564|     11|  put8 ( a, blobtype);
  565|     11|  put8 ( a, want_fpr32? 2:1 );  /* blob type version */
  ------------------
  |  Branch (565:13): [True: 0, False: 11]
  ------------------
  566|     11|  put16 ( a, as_ephemeral? 2:0 ); /* blob flags */
  ------------------
  |  Branch (566:14): [True: 0, False: 11]
  ------------------
  567|       |
  568|     11|  put32 ( a, 0 ); /* offset to the raw data, needs fixup */
  569|     11|  put32 ( a, 0 ); /* length of the raw data, needs fixup */
  570|       |
  571|     11|  put16 ( a, blob->nkeys );
  572|     11|  if (want_fpr32)
  ------------------
  |  Branch (572:7): [True: 0, False: 11]
  ------------------
  573|      0|    put16 ( a, 32 + 2 + 2 + 20);  /* size of key info */
  574|     11|  else
  575|     11|    put16 ( a, 20 + 4 + 2 + 2 );  /* size of key info */
  576|     25|  for ( i=0; i < blob->nkeys; i++ )
  ------------------
  |  Branch (576:14): [True: 14, False: 11]
  ------------------
  577|     14|    {
  578|     14|      if (want_fpr32)
  ------------------
  |  Branch (578:11): [True: 0, False: 14]
  ------------------
  579|      0|        {
  580|      0|          put_membuf (a, blob->keys[i].fpr, blob->keys[i].fprlen);
  581|      0|          if (blob->keys[i].fprlen < 32)
  ------------------
  |  Branch (581:15): [True: 0, False: 0]
  ------------------
  582|      0|            put_membuf (a, NULL, 32 - blob->keys[i].fprlen);
  583|      0|          blob->keys[i].off_kid_addr = a->len;
  584|      0|          if (blob->keys[i].fprlen == 32)
  ------------------
  |  Branch (584:15): [True: 0, False: 0]
  ------------------
  585|      0|            put16 ( a, (blob->keys[i].flags | 0x80));
  586|      0|          else
  587|      0|            put16 ( a, blob->keys[i].flags);
  588|      0|          put16 ( a, 0 ); /* reserved */
  589|       |          /* FIXME: Put the real grip here instead of the filler.  */
  590|      0|          put_membuf (a, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 20);
  591|      0|        }
  592|     14|      else
  593|     14|        {
  594|     14|          log_assert (blob->keys[i].fprlen <= 20);
  595|      0|          put_membuf (a, blob->keys[i].fpr, 20);
  596|     14|          blob->keys[i].off_kid_addr = a->len;
  597|     14|          put32 ( a, 0 ); /* offset to keyid, fixed up later */
  598|     14|          put16 ( a, blob->keys[i].flags );
  599|     14|          put16 ( a, 0 ); /* reserved */
  600|     14|        }
  601|     14|    }
  602|       |
  603|     11|  put16 (a, blob->seriallen); /*fixme: check that it fits into 16 bits*/
  604|     11|  if (blob->serial)
  ------------------
  |  Branch (604:7): [True: 0, False: 11]
  ------------------
  605|      0|    put_membuf (a, blob->serial, blob->seriallen);
  606|       |
  607|     11|  put16 ( a, blob->nuids );
  608|     11|  put16 ( a, 4 + 4 + 2 + 1 + 1 );  /* size of uid info */
  609|     22|  for (i=0; i < blob->nuids; i++)
  ------------------
  |  Branch (609:13): [True: 11, False: 11]
  ------------------
  610|     11|    {
  611|     11|      blob->uids[i].off_addr = a->len;
  612|     11|      put32 ( a, 0 ); /* offset to userid, fixed up later */
  613|     11|      put32 ( a, blob->uids[i].len );
  614|     11|      put16 ( a, blob->uids[i].flags );
  615|     11|      put8  ( a, 0 ); /* validity */
  616|     11|      put8  ( a, 0 ); /* reserved */
  617|     11|    }
  618|       |
  619|     11|  put16 ( a, blob->nsigs );
  620|     11|  put16 ( a, 4 );  /* size of sig info */
  621|     70|  for (i=0; i < blob->nsigs; i++)
  ------------------
  |  Branch (621:13): [True: 59, False: 11]
  ------------------
  622|     59|    {
  623|     59|      put32 ( a, blob->sigs[i]);
  624|     59|    }
  625|       |
  626|     11|  put8 ( a, 0 );  /* assigned ownertrust */
  627|     11|  put8 ( a, 0 );  /* validity of all user IDs */
  628|     11|  put16 ( a, 0 );  /* reserved */
  629|     11|  put32 ( a, 0 );  /* time of next recheck */
  630|     11|  put32 ( a, 0 );  /* newest timestamp (none) */
  631|     11|  put32 ( a, make_timestamp() );  /* creation time */
  632|     11|  put32 ( a, 0 );  /* size of reserved space */
  633|       |  /* reserved space (which is currently of size 0) */
  634|       |
  635|       |  /* space where we write keyIDs and other stuff so that the
  636|       |     pointers can actually point to somewhere */
  637|     11|  if (blobtype == KEYBOX_BLOBTYPE_PGP && !want_fpr32)
  ------------------
  |  Branch (637:7): [True: 11, False: 0]
  |  Branch (637:42): [True: 11, False: 0]
  ------------------
  638|     11|    {
  639|       |      /* For version 1 blobs, we need to store the keyids for all v3
  640|       |       * keys because those key IDs are not part of the fingerprint.
  641|       |       * While we are doing that, we fixup all the keyID offsets.  For
  642|       |       * version 2 blobs (which can't carry v3 keys) we compute the
  643|       |       * keyids in the fly because they are just stripped down
  644|       |       * fingerprints.  */
  645|     25|      for (i=0; i < blob->nkeys; i++ )
  ------------------
  |  Branch (645:17): [True: 14, False: 11]
  ------------------
  646|     14|        {
  647|     14|          if (blob->keys[i].off_kid)
  ------------------
  |  Branch (647:15): [True: 0, False: 14]
  ------------------
  648|      0|            { /* this is a v3 one */
  649|      0|              add_fixup (blob, blob->keys[i].off_kid_addr, a->len);
  650|      0|              write_stored_kid (blob, blob->keys[i].off_kid);
  651|      0|            }
  652|     14|          else
  653|     14|            { /* the better v4 key IDs - just store an offset 8 bytes back */
  654|     14|              add_fixup (blob, blob->keys[i].off_kid_addr,
  655|     14|                         blob->keys[i].off_kid_addr - 8);
  656|     14|            }
  657|     14|        }
  658|     11|    }
  659|       |
  660|     11|  if (blobtype == KEYBOX_BLOBTYPE_X509)
  ------------------
  |  Branch (660:7): [True: 0, False: 11]
  ------------------
  661|      0|    {
  662|       |      /* We don't want to point to ASN.1 encoded UserIDs (DNs) but to
  663|       |         the utf-8 string representation of them */
  664|      0|      for (i=0; i < blob->nuids; i++ )
  ------------------
  |  Branch (664:17): [True: 0, False: 0]
  ------------------
  665|      0|        {
  666|      0|          if (blob->uids[i].name)
  ------------------
  |  Branch (666:15): [True: 0, False: 0]
  ------------------
  667|      0|            { /* this is a v3 one */
  668|      0|              add_fixup (blob, blob->uids[i].off_addr, a->len);
  669|      0|              put_membuf (blob->buf, blob->uids[i].name, blob->uids[i].len);
  670|      0|            }
  671|      0|        }
  672|      0|    }
  673|       |
  674|     11|    return 0;
  675|     11|}
keybox-blob.c:put32:
  331|    172|{
  332|    172|  unsigned char tmp[4];
  333|    172|  tmp[0] = a>>24;
  334|    172|  tmp[1] = a>>16;
  335|    172|  tmp[2] = a>>8;
  336|    172|  tmp[3] = a;
  337|    172|  put_membuf (mb, tmp, 4);
  338|    172|}
keybox-blob.c:put8:
  316|     66|{
  317|     66|  put_membuf (mb, &a, 1);
  318|     66|}
keybox-blob.c:put16:
  322|    138|{
  323|    138|  unsigned char tmp[2];
  324|    138|  tmp[0] = a>>8;
  325|    138|  tmp[1] = a;
  326|    138|  put_membuf (mb, tmp, 2);
  327|    138|}
keybox-blob.c:put_membuf:
  270|    412|{
  271|    412|  if (mb->out_of_core)
  ------------------
  |  Branch (271:7): [True: 0, False: 412]
  ------------------
  272|      0|    return;
  273|       |
  274|    412|  if (mb->len + len >= mb->size)
  ------------------
  |  Branch (274:7): [True: 6, False: 406]
  ------------------
  275|      6|    {
  276|      6|      char *p;
  277|       |
  278|      6|      mb->size += len + 1024;
  279|      6|      p = xtryrealloc (mb->buf, mb->size);
  ------------------
  |  |  101|      6|#define xtryrealloc(a,b) gcry_realloc ((a),(b))
  ------------------
  280|      6|      if (!p)
  ------------------
  |  Branch (280:11): [True: 0, False: 6]
  ------------------
  281|      0|        {
  282|      0|          mb->out_of_core = 1;
  283|      0|          return;
  284|      0|        }
  285|      6|      mb->buf = p;
  286|      6|    }
  287|    412|  if (buf)
  ------------------
  |  Branch (287:7): [True: 401, False: 11]
  ------------------
  288|    401|    memcpy (mb->buf + mb->len, buf, len);
  289|     11|  else
  290|     11|    memset (mb->buf + mb->len, 0, len);
  291|    412|  mb->len += len;
  292|    412|}
keybox-blob.c:add_fixup:
  345|     58|{
  346|     58|  struct fixup_list *fl;
  347|       |
  348|     58|  if (blob->fixup_out_of_core)
  ------------------
  |  Branch (348:7): [True: 0, False: 58]
  ------------------
  349|      0|    return;
  350|       |
  351|     58|  fl = xtrycalloc(1, sizeof *fl);
  ------------------
  |  |   99|     58|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  352|     58|  if (!fl)
  ------------------
  |  Branch (352:7): [True: 0, False: 58]
  ------------------
  353|      0|    blob->fixup_out_of_core = 1;
  354|     58|  else
  355|     58|    {
  356|     58|      fl->off = off;
  357|     58|      fl->val = val;
  358|     58|      fl->next = blob->fixups;
  359|     58|      blob->fixups = fl;
  360|     58|    }
  361|     58|}
keybox-blob.c:pgp_create_blob_keyblock:
  477|     11|{
  478|     11|  struct membuf *a = blob->buf;
  479|     11|  int n;
  480|     11|  u32 kbstart = a->len;
  481|       |
  482|     11|  add_fixup (blob, 8, kbstart);
  483|       |
  484|     22|  for (n = 0; n < blob->nuids; n++)
  ------------------
  |  Branch (484:15): [True: 11, False: 11]
  ------------------
  485|     11|    add_fixup (blob, blob->uids[n].off_addr, kbstart + blob->uids[n].off);
  486|       |
  487|     11|  put_membuf (a, image, imagelen);
  488|       |
  489|     11|  add_fixup (blob, 12, a->len - kbstart);
  490|     11|  return 0;
  491|     11|}
keybox-blob.c:create_blob_trailer:
  681|     11|{
  682|     11|  (void)blob;
  683|     11|  return 0;
  684|     11|}
keybox-blob.c:create_blob_finish:
  689|     11|{
  690|     11|  struct membuf *a = blob->buf;
  691|     11|  unsigned char *p;
  692|     11|  unsigned char *pp;
  693|     11|  size_t n;
  694|       |
  695|       |  /* Write placeholders for the checksum.  */
  696|     11|  put_membuf (a, NULL, 20);
  697|       |
  698|       |  /* get the memory area */
  699|     11|  n = 0; /* (Just to avoid compiler warning.) */
  700|     11|  p = get_membuf (a, &n);
  701|     11|  if (!p)
  ------------------
  |  Branch (701:7): [True: 0, False: 11]
  ------------------
  702|      0|    return gpg_error (GPG_ERR_ENOMEM);
  703|     11|  assert (n >= 20);
  704|       |
  705|       |  /* fixup the length */
  706|     11|  add_fixup (blob, 0, n);
  707|       |
  708|       |  /* do the fixups */
  709|     11|  if (blob->fixup_out_of_core)
  ------------------
  |  Branch (709:7): [True: 0, False: 11]
  ------------------
  710|      0|    {
  711|      0|      xfree (p);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  712|      0|      return gpg_error (GPG_ERR_ENOMEM);
  713|      0|    }
  714|       |
  715|     11|  {
  716|     11|    struct fixup_list *fl, *next;
  717|     69|    for (fl = blob->fixups; fl; fl = next)
  ------------------
  |  Branch (717:29): [True: 58, False: 11]
  ------------------
  718|     58|      {
  719|     58|        assert (fl->off+4 <= n);
  720|     58|        p[fl->off+0] = fl->val >> 24;
  721|     58|        p[fl->off+1] = fl->val >> 16;
  722|     58|        p[fl->off+2] = fl->val >>  8;
  723|     58|        p[fl->off+3] = fl->val;
  724|     58|        next = fl->next;
  725|     58|        xfree (fl);
  ------------------
  |  |  104|     58|#define xfree(a)         gcry_free ((a))
  ------------------
  726|     58|      }
  727|     11|    blob->fixups = NULL;
  728|     11|  }
  729|       |
  730|       |  /* Compute and store the SHA-1 checksum. */
  731|      0|  gcry_md_hash_buffer (GCRY_MD_SHA1, p + n - 20, p, n - 20);
  732|       |
  733|     11|  pp = xtrymalloc (n);
  ------------------
  |  |   97|     11|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  734|     11|  if ( !pp )
  ------------------
  |  Branch (734:8): [True: 0, False: 11]
  ------------------
  735|      0|    {
  736|      0|      xfree (p);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  737|      0|      return gpg_error_from_syserror ();
  738|      0|    }
  739|     11|  memcpy (pp , p, n);
  740|     11|  xfree (p);
  ------------------
  |  |  104|     11|#define xfree(a)         gcry_free ((a))
  ------------------
  741|     11|  blob->blob = pp;
  742|     11|  blob->bloblen = n;
  743|       |
  744|     11|  return 0;
  745|     11|}
keybox-blob.c:release_kid_list:
  543|     11|{
  544|     11|  struct keyid_list *r, *r2;
  545|       |
  546|     11|  for ( r = kl; r; r = r2 )
  ------------------
  |  Branch (546:17): [True: 0, False: 11]
  ------------------
  547|      0|    {
  548|      0|      r2 = r->next;
  549|      0|      xfree (r);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  550|      0|    }
  551|     11|}
keybox-blob.c:get_membuf:
  296|     22|{
  297|     22|  char *p;
  298|       |
  299|     22|  if (mb->out_of_core)
  ------------------
  |  Branch (299:7): [True: 11, False: 11]
  ------------------
  300|     11|    {
  301|     11|      xfree (mb->buf);
  ------------------
  |  |  104|     11|#define xfree(a)         gcry_free ((a))
  ------------------
  302|     11|      mb->buf = NULL;
  303|     11|      return NULL;
  304|     11|    }
  305|       |
  306|     11|  p = mb->buf;
  307|     11|  *len = mb->len;
  308|     11|  mb->buf = NULL;
  309|     11|  mb->out_of_core = 1; /* don't allow a reuse */
  310|     11|  return p;
  311|     22|}

keybox-search.c:blob_get_type:
  182|    411|{
  183|    411|  const unsigned char *buffer;
  184|    411|  size_t length;
  185|       |
  186|    411|  buffer = _keybox_get_blob_image (blob, &length);
  187|    411|  if (length < 32)
  ------------------
  |  Branch (187:7): [True: 0, False: 411]
  ------------------
  188|      0|    return -1; /* blob too short */
  189|       |
  190|    411|  return buffer[4];
  191|    411|}
keybox-update.c:blob_get_type:
  182|      9|{
  183|      9|  const unsigned char *buffer;
  184|      9|  size_t length;
  185|       |
  186|      9|  buffer = _keybox_get_blob_image (blob, &length);
  187|      9|  if (length < 32)
  ------------------
  |  Branch (187:7): [True: 0, False: 9]
  ------------------
  188|      0|    return -1; /* blob too short */
  189|       |
  190|      9|  return buffer[4];
  191|      9|}

_keybox_read_blob:
   52|    660|{
   53|    660|  unsigned char *image;
   54|    660|  size_t imagelen = 0;
   55|    660|  int c1, c2, c3, c4, type;
   56|    660|  int rc;
   57|    660|  off_t off;
   58|       |
   59|    660|  if (skipped_deleted)
  ------------------
  |  Branch (59:7): [True: 0, False: 660]
  ------------------
   60|      0|    *skipped_deleted = 0;
   61|    660| again:
   62|    660|  if (r_blob)
  ------------------
  |  Branch (62:7): [True: 651, False: 9]
  ------------------
   63|    651|    *r_blob = NULL;
   64|    660|  off = es_ftello (fp);
   65|    660|  if (off == (off_t)-1)
  ------------------
  |  Branch (65:7): [True: 0, False: 660]
  ------------------
   66|      0|    return gpg_error_from_syserror ();
   67|       |
   68|    660|  if ((c1 = es_getc (fp)) == EOF
  ------------------
  |  Branch (68:7): [True: 263, False: 397]
  ------------------
   69|    660|      || (c2 = es_getc (fp)) == EOF
  ------------------
  |  Branch (69:10): [True: 0, False: 397]
  ------------------
   70|    660|      || (c3 = es_getc (fp)) == EOF
  ------------------
  |  Branch (70:10): [True: 0, False: 397]
  ------------------
   71|    660|      || (c4 = es_getc (fp)) == EOF
  ------------------
  |  Branch (71:10): [True: 0, False: 397]
  ------------------
   72|    660|      || (type = es_getc (fp)) == EOF)
  ------------------
  |  Branch (72:10): [True: 0, False: 397]
  ------------------
   73|    263|    {
   74|    263|      if ( c1 == EOF && !es_ferror (fp) )
  ------------------
  |  Branch (74:12): [True: 263, False: 0]
  |  Branch (74:25): [True: 263, False: 0]
  ------------------
   75|    263|        return -1; /* eof */
   76|      0|      if (!es_ferror (fp))
  ------------------
  |  Branch (76:11): [True: 0, False: 0]
  ------------------
   77|      0|        return gpg_error (GPG_ERR_TOO_SHORT);
   78|      0|      return gpg_error_from_syserror ();
   79|      0|    }
   80|       |
   81|    397|  imagelen = ((unsigned int) c1 << 24) | (c2 << 16) | (c3 << 8 ) | c4;
   82|    397|  if (imagelen < 5)
  ------------------
  |  Branch (82:7): [True: 0, False: 397]
  ------------------
   83|      0|    return gpg_error (GPG_ERR_TOO_SHORT);
   84|       |
   85|    397|  if (!type)
  ------------------
  |  Branch (85:7): [True: 0, False: 397]
  ------------------
   86|      0|    {
   87|       |      /* Special treatment for empty blobs. */
   88|      0|      if (es_fseek (fp, imagelen-5, SEEK_CUR))
  ------------------
  |  Branch (88:11): [True: 0, False: 0]
  ------------------
   89|      0|        return gpg_error_from_syserror ();
   90|      0|      if (skipped_deleted)
  ------------------
  |  Branch (90:11): [True: 0, False: 0]
  ------------------
   91|      0|        *skipped_deleted = 1;
   92|      0|      goto again;
   93|      0|    }
   94|       |
   95|    397|  if (imagelen > IMAGELEN_LIMIT) /* Sanity check. */
  ------------------
  |  |   30|    397|#define IMAGELEN_LIMIT (5*1024*1024)
  ------------------
  |  Branch (95:7): [True: 0, False: 397]
  ------------------
   96|      0|    {
   97|       |      /* Seek forward so that the caller may choose to ignore this
   98|       |         record.  */
   99|      0|      if (es_fseek (fp, imagelen-5, SEEK_CUR))
  ------------------
  |  Branch (99:11): [True: 0, False: 0]
  ------------------
  100|      0|        return gpg_error_from_syserror ();
  101|      0|      return gpg_error (GPG_ERR_TOO_LARGE);
  102|      0|    }
  103|       |
  104|    397|  if (!r_blob)
  ------------------
  |  Branch (104:7): [True: 9, False: 388]
  ------------------
  105|      9|    {
  106|       |      /* This blob shall be skipped.  */
  107|      9|      if (es_fseek (fp, imagelen-5, SEEK_CUR))
  ------------------
  |  Branch (107:11): [True: 0, False: 9]
  ------------------
  108|      0|        return gpg_error_from_syserror ();
  109|      9|      return 0;
  110|      9|    }
  111|       |
  112|    388|  image = xtrymalloc (imagelen);
  ------------------
  |  |   97|    388|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  113|    388|  if (!image)
  ------------------
  |  Branch (113:7): [True: 0, False: 388]
  ------------------
  114|      0|    return gpg_error_from_syserror ();
  115|       |
  116|    388|  image[0] = c1; image[1] = c2; image[2] = c3; image[3] = c4; image[4] = type;
  117|    388|  if (es_fread (image+5, imagelen-5, 1, fp) != 1)
  ------------------
  |  Branch (117:7): [True: 0, False: 388]
  ------------------
  118|      0|    {
  119|      0|      gpg_error_t tmperr = gpg_error_from_syserror ();
  120|      0|      xfree (image);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  121|      0|      return tmperr;
  122|      0|    }
  123|       |
  124|    388|  rc = _keybox_new_blob (r_blob, image, imagelen, off);
  125|    388|  if (rc)
  ------------------
  |  Branch (125:7): [True: 0, False: 388]
  ------------------
  126|      0|    xfree (image);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  127|    388|  return rc;
  128|    388|}
_keybox_write_blob:
  134|     11|{
  135|     11|  const unsigned char *image;
  136|     11|  size_t length;
  137|       |
  138|     11|  image = _keybox_get_blob_image (blob, &length);
  139|       |
  140|     11|  if (length > IMAGELEN_LIMIT)
  ------------------
  |  |   30|     11|#define IMAGELEN_LIMIT (5*1024*1024)
  ------------------
  |  Branch (140:7): [True: 0, False: 11]
  ------------------
  141|      0|    return gpg_error (GPG_ERR_TOO_LARGE);
  142|       |
  143|     11|  if (fp)
  ------------------
  |  Branch (143:7): [True: 11, False: 0]
  ------------------
  144|     11|    {
  145|     11|      if (es_fwrite (image, length, 1, fp) != 1)
  ------------------
  |  Branch (145:11): [True: 0, False: 11]
  ------------------
  146|      0|        return gpg_error_from_syserror ();
  147|     11|    }
  148|      0|  else
  149|      0|    {
  150|      0|      if (fwrite (image, length, 1, outfp) != 1)
  ------------------
  |  Branch (150:11): [True: 0, False: 0]
  ------------------
  151|      0|        return gpg_error_from_syserror ();
  152|      0|    }
  153|       |
  154|     11|  return 0;
  155|     11|}
_keybox_write_header_blob:
  161|      1|{
  162|      1|  unsigned char image[32];
  163|      1|  u32 val;
  164|       |
  165|      1|  memset (image, 0, sizeof image);
  166|       |  /* Length of this blob. */
  167|      1|  image[3] = 32;
  168|       |
  169|      1|  image[4] = KEYBOX_BLOBTYPE_HEADER;
  170|      1|  image[5] = 1; /* Version */
  171|      1|  if (for_openpgp)
  ------------------
  |  Branch (171:7): [True: 1, False: 0]
  ------------------
  172|      1|    image[7] = 0x02; /* OpenPGP data may be available.  */
  173|       |
  174|      1|  memcpy (image+8, "KBXf", 4);
  175|      1|  val = time (NULL);
  176|       |  /* created_at and last maintenance run. */
  177|      1|  image[16]   = (val >> 24);
  178|      1|  image[16+1] = (val >> 16);
  179|      1|  image[16+2] = (val >>  8);
  180|      1|  image[16+3] = (val      );
  181|      1|  image[20]   = (val >> 24);
  182|      1|  image[20+1] = (val >> 16);
  183|      1|  image[20+2] = (val >>  8);
  184|      1|  image[20+3] = (val      );
  185|       |
  186|      1|  if (es_fwrite (image, 32, 1, fp) != 1)
  ------------------
  |  Branch (186:7): [True: 0, False: 1]
  ------------------
  187|      0|    return gpg_error_from_syserror ();
  188|       |
  189|      1|  return 0;
  190|      1|}

keybox_register_file:
   41|      1|{
   42|      1|  KB_NAME kr;
   43|       |
   44|      1|  *r_token = NULL;
   45|       |
   46|      1|  for (kr=kb_names; kr; kr = kr->next)
  ------------------
  |  Branch (46:21): [True: 0, False: 1]
  ------------------
   47|      0|    {
   48|      0|      if (same_file_p (kr->fname, fname) )
  ------------------
  |  Branch (48:11): [True: 0, False: 0]
  ------------------
   49|      0|        {
   50|      0|          *r_token = kr;
   51|      0|          return gpg_error (GPG_ERR_EEXIST); /* Already registered. */
   52|      0|        }
   53|      0|    }
   54|       |
   55|      1|  kr = xtrymalloc (sizeof *kr + strlen (fname));
  ------------------
  |  |   97|      1|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
   56|      1|  if (!kr)
  ------------------
  |  Branch (56:7): [True: 0, False: 1]
  ------------------
   57|      0|    return gpg_error_from_syserror ();
   58|      1|  strcpy (kr->fname, fname);
   59|      1|  kr->secret = !!secret;
   60|       |
   61|      1|  kr->handle_table = NULL;
   62|      1|  kr->handle_table_size = 0;
   63|       |
   64|      1|  kr->lockhd = NULL;
   65|      1|  kr->is_locked = 0;
   66|      1|  kr->did_full_scan = 0;
   67|       |  /* keep a list of all issued pointers */
   68|      1|  kr->next = kb_names;
   69|      1|  kb_names = kr;
   70|       |
   71|       |  /* create the offset table the first time a function here is used */
   72|       |/*      if (!kb_offtbl) */
   73|       |/*        kb_offtbl = new_offset_hash_table (); */
   74|       |
   75|      1|  *r_token = kr;
   76|      1|  return 0;
   77|      1|}
keybox_is_writable:
   81|     37|{
   82|     37|  KB_NAME r = token;
   83|       |
   84|     37|  return r? !gnupg_access (r->fname, W_OK) : 0;
  ------------------
  |  Branch (84:10): [True: 37, False: 0]
  ------------------
   85|     37|}
keybox_new_openpgp:
  149|    380|{
  150|    380|  KB_NAME resource = token;
  151|       |
  152|    380|  return do_keybox_new (resource, secret, 1);
  153|    380|}
keybox_release:
  169|    380|{
  170|    380|  if (!hd)
  ------------------
  |  Branch (170:7): [True: 0, False: 380]
  ------------------
  171|      0|    return;
  172|    380|  if (hd->kb->handle_table)
  ------------------
  |  Branch (172:7): [True: 380, False: 0]
  ------------------
  173|    380|    {
  174|    380|      int idx;
  175|  1.52k|      for (idx=0; idx < hd->kb->handle_table_size; idx++)
  ------------------
  |  Branch (175:19): [True: 1.14k, False: 380]
  ------------------
  176|  1.14k|        if (hd->kb->handle_table[idx] == hd)
  ------------------
  |  Branch (176:13): [True: 380, False: 760]
  ------------------
  177|    380|          hd->kb->handle_table[idx] = NULL;
  178|    380|    }
  179|    380|  _keybox_release_blob (hd->found.blob);
  180|    380|  _keybox_release_blob (hd->saved_found.blob);
  181|    380|  if (hd->fp)
  ------------------
  |  Branch (181:7): [True: 205, False: 175]
  ------------------
  182|    205|    {
  183|    205|      es_fclose (hd->fp);
  184|    205|      hd->fp = NULL;
  185|    205|    }
  186|    380|  xfree (hd->word_match.name);
  ------------------
  |  |  104|    380|#define xfree(a)         gcry_free ((a))
  ------------------
  187|    380|  xfree (hd->word_match.pattern);
  ------------------
  |  |  104|    380|#define xfree(a)         gcry_free ((a))
  ------------------
  188|    380|  xfree (hd);
  ------------------
  |  |  104|    380|#define xfree(a)         gcry_free ((a))
  ------------------
  189|    380|}
_keybox_close_file:
  244|     12|{
  245|     12|  int idx;
  246|     12|  KEYBOX_HANDLE roverhd;
  247|       |
  248|     12|  if (!hd || !hd->kb || !hd->kb->handle_table)
  ------------------
  |  Branch (248:7): [True: 0, False: 12]
  |  Branch (248:14): [True: 0, False: 12]
  |  Branch (248:25): [True: 0, False: 12]
  ------------------
  249|      0|    return;
  250|       |
  251|     48|  for (idx=0; idx < hd->kb->handle_table_size; idx++)
  ------------------
  |  Branch (251:15): [True: 36, False: 12]
  ------------------
  252|     36|    if ((roverhd = hd->kb->handle_table[idx]))
  ------------------
  |  Branch (252:9): [True: 23, False: 13]
  ------------------
  253|     23|      {
  254|     23|        if (roverhd->fp)
  ------------------
  |  Branch (254:13): [True: 15, False: 8]
  ------------------
  255|     15|          {
  256|     15|            es_fclose (roverhd->fp);
  257|     15|            roverhd->fp = NULL;
  258|     15|          }
  259|     23|      }
  260|     12|  log_assert (!hd->fp);
  261|     12|}
keybox_lock:
  271|     35|{
  272|     35|  gpg_error_t err = 0;
  273|     35|  KB_NAME kb = hd->kb;
  274|       |
  275|     35|  if (!keybox_is_writable (kb))
  ------------------
  |  Branch (275:7): [True: 0, False: 35]
  ------------------
  276|      0|    return 0;
  277|       |
  278|       |  /* Make sure the lock handle has been created.  */
  279|     35|  if (!kb->lockhd)
  ------------------
  |  Branch (279:7): [True: 1, False: 34]
  ------------------
  280|      1|    {
  281|      1|      kb->lockhd = dotlock_create (kb->fname, 0);
  282|      1|      if (!kb->lockhd)
  ------------------
  |  Branch (282:11): [True: 0, False: 1]
  ------------------
  283|      0|        {
  284|      0|          err = gpg_error_from_syserror ();
  285|      0|          log_info ("can't allocate lock for '%s'\n", kb->fname );
  286|      0|          return err;
  287|      0|        }
  288|      1|    }
  289|       |
  290|     35|  if (yes) /* Take the lock.  */
  ------------------
  |  Branch (290:7): [True: 23, False: 12]
  ------------------
  291|     23|    {
  292|     23|      if (!kb->is_locked)
  ------------------
  |  Branch (292:11): [True: 12, False: 11]
  ------------------
  293|     12|        {
  294|       |#ifdef HAVE_W32_SYSTEM
  295|       |          /* Under Windows we need to close the file before we try
  296|       |           * to lock it.  This is because another process might have
  297|       |           * taken the lock and is using keybox_file_rename to
  298|       |           * rename the base file.  Now if our dotlock_take below is
  299|       |           * waiting for the lock but we have the base file still
  300|       |           * open, keybox_file_rename will never succeed as we are
  301|       |           * in a deadlock.  */
  302|       |          _keybox_close_file (hd);
  303|       |#endif /*HAVE_W32_SYSTEM*/
  304|     12|          if (dotlock_take (kb->lockhd, timeout))
  ------------------
  |  Branch (304:15): [True: 0, False: 12]
  ------------------
  305|      0|            {
  306|      0|              err = gpg_error_from_syserror ();
  307|      0|              if (!timeout && gpg_err_code (err) == GPG_ERR_EACCES)
  ------------------
  |  Branch (307:19): [True: 0, False: 0]
  |  Branch (307:31): [True: 0, False: 0]
  ------------------
  308|      0|                ; /* No diagnostic if we only tried to lock.  */
  309|      0|              else
  310|      0|                log_info ("can't lock '%s'\n", kb->fname );
  311|      0|            }
  312|     12|          else
  313|     12|            kb->is_locked = 1;
  314|     12|        }
  315|     23|    }
  316|     12|  else /* Release the lock.  */
  317|     12|    {
  318|     12|      if (kb->is_locked)
  ------------------
  |  Branch (318:11): [True: 12, False: 0]
  ------------------
  319|     12|        {
  320|     12|          if (dotlock_release (kb->lockhd))
  ------------------
  |  Branch (320:15): [True: 0, False: 12]
  ------------------
  321|      0|            {
  322|      0|              err = gpg_error_from_syserror ();
  323|      0|              log_info ("can't unlock '%s'\n", kb->fname );
  324|      0|            }
  325|     12|          else
  326|     12|            kb->is_locked = 0;
  327|     12|        }
  328|     12|   }
  329|       |
  330|     35|  return err;
  331|     35|}
keybox-init.c:do_keybox_new:
   91|    380|{
   92|    380|  KEYBOX_HANDLE hd;
   93|    380|  int idx;
   94|       |
   95|    380|  assert (resource && !resource->secret == !secret);
   96|    380|  hd = xtrycalloc (1, sizeof *hd);
  ------------------
  |  |   99|    380|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
   97|    380|  if (hd)
  ------------------
  |  Branch (97:7): [True: 380, False: 0]
  ------------------
   98|    380|    {
   99|    380|      hd->kb = resource;
  100|    380|      hd->secret = !!secret;
  101|    380|      hd->for_openpgp = for_openpgp;
  102|    380|      if (!resource->handle_table)
  ------------------
  |  Branch (102:11): [True: 1, False: 379]
  ------------------
  103|      1|        {
  104|      1|          resource->handle_table_size = 3;
  105|      1|          resource->handle_table = xtrycalloc (resource->handle_table_size,
  ------------------
  |  |   99|      1|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  106|      1|                                               sizeof *resource->handle_table);
  107|      1|          if (!resource->handle_table)
  ------------------
  |  Branch (107:15): [True: 0, False: 1]
  ------------------
  108|      0|            {
  109|      0|              resource->handle_table_size = 0;
  110|      0|              xfree (hd);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  111|      0|              return NULL;
  112|      0|            }
  113|      1|        }
  114|    743|      for (idx=0; idx < resource->handle_table_size; idx++)
  ------------------
  |  Branch (114:19): [True: 743, False: 0]
  ------------------
  115|    743|        if (!resource->handle_table[idx])
  ------------------
  |  Branch (115:13): [True: 380, False: 363]
  ------------------
  116|    380|          {
  117|    380|            resource->handle_table[idx] = hd;
  118|    380|            break;
  119|    380|          }
  120|    380|      if (!(idx < resource->handle_table_size))
  ------------------
  |  Branch (120:11): [True: 0, False: 380]
  ------------------
  121|      0|        {
  122|      0|          KEYBOX_HANDLE *tmptbl;
  123|      0|          size_t newsize;
  124|       |
  125|      0|          newsize = resource->handle_table_size + 5;
  126|      0|          tmptbl = xtryrealloc (resource->handle_table,
  ------------------
  |  |  101|      0|#define xtryrealloc(a,b) gcry_realloc ((a),(b))
  ------------------
  127|      0|                                newsize * sizeof (*tmptbl));
  128|      0|          if (!tmptbl)
  ------------------
  |  Branch (128:15): [True: 0, False: 0]
  ------------------
  129|      0|            {
  130|      0|              xfree (hd);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  131|      0|              return NULL;
  132|      0|            }
  133|      0|          resource->handle_table = tmptbl;
  134|      0|          resource->handle_table_size = newsize;
  135|      0|          resource->handle_table[idx] = hd;
  136|      0|          for (idx++; idx < resource->handle_table_size; idx++)
  ------------------
  |  Branch (136:23): [True: 0, False: 0]
  ------------------
  137|      0|            resource->handle_table[idx] = NULL;
  138|      0|        }
  139|    380|    }
  140|    380|  return hd;
  141|    380|}

_keybox_parse_openpgp:
  513|     11|{
  514|     11|  gpg_error_t err = 0;
  515|     11|  const unsigned char *image_start, *data;
  516|     11|  size_t n, datalen;
  517|     11|  int pkttype;
  518|     11|  int first = 1;
  519|     11|  int read_error = 0;
  520|     11|  struct _keybox_openpgp_key_info *k, **ktail = NULL;
  521|     11|  struct _keybox_openpgp_uid_info *u, **utail = NULL;
  522|       |
  523|     11|  memset (info, 0, sizeof *info);
  524|     11|  if (nparsed)
  ------------------
  |  Branch (524:7): [True: 11, False: 0]
  ------------------
  525|     11|    *nparsed = 0;
  526|       |
  527|     11|  image_start = image;
  528|    176|  while (image)
  ------------------
  |  Branch (528:10): [True: 165, False: 11]
  ------------------
  529|    165|    {
  530|    165|      err = next_packet (&image, &imagelen, &data, &datalen, &pkttype, &n);
  531|    165|      if (err)
  ------------------
  |  Branch (531:11): [True: 0, False: 165]
  ------------------
  532|      0|        {
  533|      0|          read_error = 1;
  534|      0|          break;
  535|      0|        }
  536|       |
  537|    165|      if (first)
  ------------------
  |  Branch (537:11): [True: 11, False: 154]
  ------------------
  538|     11|        {
  539|     11|          if (pkttype == PKT_PUBLIC_KEY)
  ------------------
  |  Branch (539:15): [True: 11, False: 0]
  ------------------
  540|     11|            ;
  541|      0|          else if (pkttype == PKT_SECRET_KEY)
  ------------------
  |  Branch (541:20): [True: 0, False: 0]
  ------------------
  542|      0|            info->is_secret = 1;
  543|      0|          else
  544|      0|            {
  545|      0|              err = gpg_error (GPG_ERR_UNEXPECTED);
  546|      0|              if (nparsed)
  ------------------
  |  Branch (546:19): [True: 0, False: 0]
  ------------------
  547|      0|                *nparsed += n;
  548|      0|              break;
  549|      0|            }
  550|     11|          first = 0;
  551|     11|        }
  552|    154|      else if (pkttype == PKT_PUBLIC_KEY || pkttype == PKT_SECRET_KEY)
  ------------------
  |  Branch (552:16): [True: 0, False: 154]
  |  Branch (552:45): [True: 0, False: 154]
  ------------------
  553|      0|        break; /* Next keyblock encountered - ready. */
  554|       |
  555|    165|      if (nparsed)
  ------------------
  |  Branch (555:11): [True: 165, False: 0]
  ------------------
  556|    165|        *nparsed += n;
  557|       |
  558|    165|      if (pkttype == PKT_SIGNATURE)
  ------------------
  |  Branch (558:11): [True: 59, False: 106]
  ------------------
  559|     59|        {
  560|       |          /* For now we only count the total number of signatures. */
  561|     59|          info->nsigs++;
  562|     59|        }
  563|    106|      else if (pkttype == PKT_USER_ID)
  ------------------
  |  Branch (563:16): [True: 11, False: 95]
  ------------------
  564|     11|        {
  565|     11|          info->nuids++;
  566|     11|          if (info->nuids == 1)
  ------------------
  |  Branch (566:15): [True: 11, False: 0]
  ------------------
  567|     11|            {
  568|     11|              info->uids.off = data - image_start;
  569|     11|              info->uids.len = datalen;
  570|     11|              utail = &info->uids.next;
  571|     11|            }
  572|      0|          else
  573|      0|            {
  574|      0|              u = xtrycalloc (1, sizeof *u);
  ------------------
  |  |   99|      0|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  575|      0|              if (!u)
  ------------------
  |  Branch (575:19): [True: 0, False: 0]
  ------------------
  576|      0|                {
  577|      0|                  err = gpg_error_from_syserror ();
  578|      0|                  break;
  579|      0|                }
  580|      0|              u->off = data - image_start;
  581|      0|              u->len = datalen;
  582|      0|              *utail = u;
  583|      0|              utail = &u->next;
  584|      0|            }
  585|     11|        }
  586|     95|      else if (pkttype == PKT_PUBLIC_KEY || pkttype == PKT_SECRET_KEY)
  ------------------
  |  Branch (586:16): [True: 11, False: 84]
  |  Branch (586:45): [True: 0, False: 84]
  ------------------
  587|     11|        {
  588|     11|          err = parse_key (data, datalen, &info->primary);
  589|     11|          if (err)
  ------------------
  |  Branch (589:15): [True: 0, False: 11]
  ------------------
  590|      0|            break;
  591|     11|        }
  592|     84|      else if( pkttype == PKT_PUBLIC_SUBKEY && datalen && *data == '#' )
  ------------------
  |  Branch (592:16): [True: 3, False: 81]
  |  Branch (592:48): [True: 3, False: 0]
  |  Branch (592:59): [True: 0, False: 3]
  ------------------
  593|      0|        {
  594|       |          /* Early versions of GnuPG used old PGP comment packets;
  595|       |           * luckily all those comments are prefixed by a hash
  596|       |           * sign - ignore these packets. */
  597|      0|        }
  598|     84|      else if (pkttype == PKT_PUBLIC_SUBKEY || pkttype == PKT_SECRET_SUBKEY)
  ------------------
  |  Branch (598:16): [True: 3, False: 81]
  |  Branch (598:48): [True: 0, False: 81]
  ------------------
  599|      3|        {
  600|      3|          info->nsubkeys++;
  601|      3|          if (info->nsubkeys == 1)
  ------------------
  |  Branch (601:15): [True: 3, False: 0]
  ------------------
  602|      3|            {
  603|      3|              err = parse_key (data, datalen, &info->subkeys);
  604|      3|              if (err)
  ------------------
  |  Branch (604:19): [True: 0, False: 3]
  ------------------
  605|      0|                {
  606|      0|                  info->nsubkeys--;
  607|       |                  /* We ignore subkeys with unknown algorithms. */
  608|      0|                  if (gpg_err_code (err) == GPG_ERR_UNKNOWN_ALGORITHM
  ------------------
  |  Branch (608:23): [True: 0, False: 0]
  ------------------
  609|      0|                      || gpg_err_code (err) == GPG_ERR_UNSUPPORTED_ALGORITHM)
  ------------------
  |  Branch (609:26): [True: 0, False: 0]
  ------------------
  610|      0|                    err = 0;
  611|      0|                  if (err)
  ------------------
  |  Branch (611:23): [True: 0, False: 0]
  ------------------
  612|      0|                    break;
  613|      0|                }
  614|      3|              else
  615|      3|                ktail = &info->subkeys.next;
  616|      3|            }
  617|      0|          else
  618|      0|            {
  619|      0|              k = xtrycalloc (1, sizeof *k);
  ------------------
  |  |   99|      0|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  620|      0|              if (!k)
  ------------------
  |  Branch (620:19): [True: 0, False: 0]
  ------------------
  621|      0|                {
  622|      0|                  err = gpg_error_from_syserror ();
  623|      0|                  break;
  624|      0|                }
  625|      0|              err = parse_key (data, datalen, k);
  626|      0|              if (err)
  ------------------
  |  Branch (626:19): [True: 0, False: 0]
  ------------------
  627|      0|                {
  628|      0|                  xfree (k);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  629|      0|                  info->nsubkeys--;
  630|       |                  /* We ignore subkeys with unknown algorithms. */
  631|      0|                  if (gpg_err_code (err) == GPG_ERR_UNKNOWN_ALGORITHM
  ------------------
  |  Branch (631:23): [True: 0, False: 0]
  ------------------
  632|      0|                      || gpg_err_code (err) == GPG_ERR_UNSUPPORTED_ALGORITHM)
  ------------------
  |  Branch (632:26): [True: 0, False: 0]
  ------------------
  633|      0|                    err = 0;
  634|      0|                  if (err)
  ------------------
  |  Branch (634:23): [True: 0, False: 0]
  ------------------
  635|      0|                    break;
  636|      0|                }
  637|      0|              else
  638|      0|                {
  639|      0|                  *ktail = k;
  640|      0|                  ktail = &k->next;
  641|      0|                }
  642|      0|            }
  643|      3|        }
  644|    165|    }
  645|       |
  646|     11|  if (err)
  ------------------
  |  Branch (646:7): [True: 0, False: 11]
  ------------------
  647|      0|    {
  648|      0|      _keybox_destroy_openpgp_info (info);
  649|      0|      if (!read_error)
  ------------------
  |  Branch (649:11): [True: 0, False: 0]
  ------------------
  650|      0|        {
  651|       |          /* Packet parsing worked, thus we should be able to skip the
  652|       |             rest of the keyblock.  */
  653|      0|          while (image)
  ------------------
  |  Branch (653:18): [True: 0, False: 0]
  ------------------
  654|      0|            {
  655|      0|              if (next_packet (&image, &imagelen,
  ------------------
  |  Branch (655:19): [True: 0, False: 0]
  ------------------
  656|      0|                               &data, &datalen, &pkttype, &n) )
  657|      0|                break; /* Another error - stop here. */
  658|       |
  659|      0|              if (pkttype == PKT_PUBLIC_KEY || pkttype == PKT_SECRET_KEY)
  ------------------
  |  Branch (659:19): [True: 0, False: 0]
  |  Branch (659:48): [True: 0, False: 0]
  ------------------
  660|      0|                break; /* Next keyblock encountered - ready. */
  661|       |
  662|      0|              if (nparsed)
  ------------------
  |  Branch (662:19): [True: 0, False: 0]
  ------------------
  663|      0|                *nparsed += n;
  664|      0|            }
  665|      0|        }
  666|      0|    }
  667|       |
  668|     11|  return err;
  669|     11|}
_keybox_destroy_openpgp_info:
  675|     11|{
  676|     11|  struct _keybox_openpgp_key_info *k, *k2;
  677|     11|  struct _keybox_openpgp_uid_info *u, *u2;
  678|       |
  679|     11|  log_assert (!info->primary.next);
  680|     11|  for (k=info->subkeys.next; k; k = k2)
  ------------------
  |  Branch (680:30): [True: 0, False: 11]
  ------------------
  681|      0|    {
  682|      0|      k2 = k->next;
  683|      0|      xfree (k);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  684|      0|    }
  685|       |
  686|     11|  for (u=info->uids.next; u; u = u2)
  ------------------
  |  Branch (686:27): [True: 0, False: 11]
  ------------------
  687|      0|    {
  688|      0|      u2 = u->next;
  689|      0|      xfree (u);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  690|      0|    }
  691|     11|}
keybox-openpgp.c:next_packet:
   68|    165|{
   69|    165|  const unsigned char *buf = *bufptr;
   70|    165|  size_t len = *buflen;
   71|    165|  int c, ctb, pkttype;
   72|    165|  unsigned long pktlen;
   73|       |
   74|    165|  if (!len)
  ------------------
  |  Branch (74:7): [True: 0, False: 165]
  ------------------
   75|      0|    return gpg_error (GPG_ERR_NO_DATA);
   76|       |
   77|    165|  ctb = *buf++; len--;
   78|    165|  if ( !(ctb & 0x80) )
  ------------------
  |  Branch (78:8): [True: 0, False: 165]
  ------------------
   79|      0|    return gpg_error (GPG_ERR_INV_PACKET); /* Invalid CTB. */
   80|       |
   81|    165|  if ((ctb & 0x40))  /* New style (OpenPGP) CTB.  */
  ------------------
  |  Branch (81:7): [True: 0, False: 165]
  ------------------
   82|      0|    {
   83|      0|      pkttype = (ctb & 0x3f);
   84|      0|      if (!len)
  ------------------
  |  Branch (84:11): [True: 0, False: 0]
  ------------------
   85|      0|        return gpg_error (GPG_ERR_INV_PACKET); /* No 1st length byte. */
   86|      0|      c = *buf++; len--;
   87|      0|      if (pkttype == PKT_COMPRESSED)
  ------------------
  |  Branch (87:11): [True: 0, False: 0]
  ------------------
   88|      0|        return gpg_error (GPG_ERR_UNEXPECTED); /* ... packet in a keyblock. */
   89|      0|      if ( c < 192 )
  ------------------
  |  Branch (89:12): [True: 0, False: 0]
  ------------------
   90|      0|        pktlen = c;
   91|      0|      else if ( c < 224 )
  ------------------
  |  Branch (91:17): [True: 0, False: 0]
  ------------------
   92|      0|        {
   93|      0|          pktlen = (c - 192) * 256;
   94|      0|          if (!len)
  ------------------
  |  Branch (94:15): [True: 0, False: 0]
  ------------------
   95|      0|            return gpg_error (GPG_ERR_INV_PACKET); /* No 2nd length byte. */
   96|      0|          c = *buf++; len--;
   97|      0|          pktlen += c + 192;
   98|      0|        }
   99|      0|      else if (c == 255)
  ------------------
  |  Branch (99:16): [True: 0, False: 0]
  ------------------
  100|      0|        {
  101|      0|          if (len <4 )
  ------------------
  |  Branch (101:15): [True: 0, False: 0]
  ------------------
  102|      0|            return gpg_error (GPG_ERR_INV_PACKET); /* No length bytes. */
  103|      0|          pktlen = buf32_to_ulong (buf);
  104|      0|          buf += 4;
  105|      0|          len -= 4;
  106|      0|      }
  107|      0|      else /* Partial length encoding is not allowed for key packets. */
  108|      0|        return gpg_error (GPG_ERR_UNEXPECTED);
  109|      0|    }
  110|    165|  else /* Old style CTB.  */
  111|    165|    {
  112|    165|      int lenbytes;
  113|       |
  114|    165|      pktlen = 0;
  115|    165|      pkttype = (ctb>>2)&0xf;
  116|    165|      lenbytes = ((ctb&3)==3)? 0 : (1<<(ctb & 3));
  ------------------
  |  Branch (116:18): [True: 0, False: 165]
  ------------------
  117|    165|      if (!lenbytes) /* Not allowed in key packets.  */
  ------------------
  |  Branch (117:11): [True: 0, False: 165]
  ------------------
  118|      0|        return gpg_error (GPG_ERR_UNEXPECTED);
  119|    165|      if (len < lenbytes)
  ------------------
  |  Branch (119:11): [True: 0, False: 165]
  ------------------
  120|      0|        return gpg_error (GPG_ERR_INV_PACKET); /* Not enough length bytes.  */
  121|    350|      for (; lenbytes; lenbytes--)
  ------------------
  |  Branch (121:14): [True: 185, False: 165]
  ------------------
  122|    185|        {
  123|    185|          pktlen <<= 8;
  124|    185|          pktlen |= *buf++; len--;
  125|    185|	}
  126|    165|    }
  127|       |
  128|       |  /* Do some basic sanity check.  */
  129|    165|  switch (pkttype)
  130|    165|    {
  131|     59|    case PKT_SIGNATURE:
  ------------------
  |  Branch (131:5): [True: 59, False: 106]
  ------------------
  132|     59|    case PKT_SECRET_KEY:
  ------------------
  |  Branch (132:5): [True: 0, False: 165]
  ------------------
  133|     70|    case PKT_PUBLIC_KEY:
  ------------------
  |  Branch (133:5): [True: 11, False: 154]
  ------------------
  134|     70|    case PKT_SECRET_SUBKEY:
  ------------------
  |  Branch (134:5): [True: 0, False: 165]
  ------------------
  135|     70|    case PKT_MARKER:
  ------------------
  |  Branch (135:5): [True: 0, False: 165]
  ------------------
  136|    151|    case PKT_RING_TRUST:
  ------------------
  |  Branch (136:5): [True: 81, False: 84]
  ------------------
  137|    162|    case PKT_USER_ID:
  ------------------
  |  Branch (137:5): [True: 11, False: 154]
  ------------------
  138|    165|    case PKT_PUBLIC_SUBKEY:
  ------------------
  |  Branch (138:5): [True: 3, False: 162]
  ------------------
  139|    165|    case PKT_OLD_COMMENT:
  ------------------
  |  Branch (139:5): [True: 0, False: 165]
  ------------------
  140|    165|    case PKT_ATTRIBUTE:
  ------------------
  |  Branch (140:5): [True: 0, False: 165]
  ------------------
  141|    165|    case PKT_COMMENT:
  ------------------
  |  Branch (141:5): [True: 0, False: 165]
  ------------------
  142|    165|    case PKT_GPG_CONTROL:
  ------------------
  |  Branch (142:5): [True: 0, False: 165]
  ------------------
  143|    165|      break; /* Okay these are allowed packets. */
  144|      0|    default:
  ------------------
  |  Branch (144:5): [True: 0, False: 165]
  ------------------
  145|      0|      return gpg_error (GPG_ERR_UNEXPECTED);
  146|    165|    }
  147|       |
  148|    165|  if (pkttype == 63 && pktlen == 0xFFFFFFFF)
  ------------------
  |  Branch (148:7): [True: 0, False: 165]
  |  Branch (148:24): [True: 0, False: 0]
  ------------------
  149|       |    /* Sometimes the decompressing layer enters an error state in
  150|       |       which it simply outputs 0xff for every byte read.  If we have a
  151|       |       stream of 0xff bytes, then it will be detected as a new format
  152|       |       packet with type 63 and a 4-byte encoded length that is 4G-1.
  153|       |       Since packets with type 63 are private and we use them as a
  154|       |       control packet, which won't be 4 GB, we reject such packets as
  155|       |       invalid.  */
  156|      0|    return gpg_error (GPG_ERR_INV_PACKET);
  157|       |
  158|    165|  if (pktlen > len)
  ------------------
  |  Branch (158:7): [True: 0, False: 165]
  ------------------
  159|      0|    return gpg_error (GPG_ERR_INV_PACKET); /* Packet length header too long. */
  160|       |
  161|    165|  *r_data = buf;
  162|    165|  *r_datalen = pktlen;
  163|    165|  *r_pkttype = pkttype;
  164|    165|  *r_ntotal = (buf - *bufptr) + pktlen;
  165|       |
  166|    165|  *bufptr = buf + pktlen;
  167|    165|  *buflen = len - pktlen;
  168|    165|  if (!*buflen)
  ------------------
  |  Branch (168:7): [True: 11, False: 154]
  ------------------
  169|     11|    *bufptr = NULL;
  170|       |
  171|    165|  return 0;
  172|    165|}
keybox-openpgp.c:parse_key:
  267|     14|{
  268|     14|  gpg_error_t err;
  269|     14|  const unsigned char *data_start = data;
  270|     14|  int i, version, algorithm;
  271|     14|  size_t n;
  272|     14|  int npkey;
  273|     14|  unsigned char hashbuffer[768];
  274|     14|  gcry_md_hd_t md;
  275|     14|  int is_ecc = 0;
  276|     14|  int is_v5;
  277|       |  /* unsigned int pkbytes;  for v5: # of octets of the public key params.  */
  278|     14|  struct keyparm_s keyparm[OPENPGP_MAX_NPKEY];
  279|     14|  unsigned char *helpmpibuf[OPENPGP_MAX_NPKEY] = { NULL };
  280|       |
  281|     14|  if (datalen < 5)
  ------------------
  |  Branch (281:7): [True: 0, False: 14]
  ------------------
  282|      0|    return gpg_error (GPG_ERR_INV_PACKET);
  283|     14|  version = *data++; datalen--;
  284|     14|  if (version < 2 || version > 5 )
  ------------------
  |  Branch (284:7): [True: 0, False: 14]
  |  Branch (284:22): [True: 0, False: 14]
  ------------------
  285|      0|    return gpg_error (GPG_ERR_INV_PACKET); /* Invalid version. */
  286|     14|  is_v5 = version == 5;
  287|       |
  288|       |  /*timestamp = ((data[0]<<24)|(data[1]<<16)|(data[2]<<8)|(data[3]));*/
  289|     14|  data +=4; datalen -=4;
  290|       |
  291|     14|  if (version < 4)
  ------------------
  |  Branch (291:7): [True: 0, False: 14]
  ------------------
  292|      0|    {
  293|      0|      if (datalen < 2)
  ------------------
  |  Branch (293:11): [True: 0, False: 0]
  ------------------
  294|      0|        return gpg_error (GPG_ERR_INV_PACKET);
  295|      0|      data +=2; datalen -= 2;
  296|      0|    }
  297|       |
  298|     14|  if (!datalen)
  ------------------
  |  Branch (298:7): [True: 0, False: 14]
  ------------------
  299|      0|    return gpg_error (GPG_ERR_INV_PACKET);
  300|     14|  algorithm = *data++; datalen--;
  301|       |
  302|     14|  if (is_v5)
  ------------------
  |  Branch (302:7): [True: 0, False: 14]
  ------------------
  303|      0|    {
  304|      0|      if (datalen < 4)
  ------------------
  |  Branch (304:11): [True: 0, False: 0]
  ------------------
  305|      0|        return gpg_error (GPG_ERR_INV_PACKET);
  306|       |      /* pkbytes = buf32_to_uint (data); */
  307|      0|      data += 4;
  308|      0|      datalen -= 4;
  309|      0|    }
  310|       |
  311|     14|  switch (algorithm)
  312|     14|    {
  313|      6|    case PUBKEY_ALGO_RSA:
  ------------------
  |  Branch (313:5): [True: 6, False: 8]
  ------------------
  314|      6|    case PUBKEY_ALGO_RSA_E:
  ------------------
  |  Branch (314:5): [True: 0, False: 14]
  ------------------
  315|      6|    case PUBKEY_ALGO_RSA_S:
  ------------------
  |  Branch (315:5): [True: 0, False: 14]
  ------------------
  316|      6|      npkey = 2;
  317|      6|      break;
  318|      0|    case PUBKEY_ALGO_ELGAMAL_E:
  ------------------
  |  Branch (318:5): [True: 0, False: 14]
  ------------------
  319|      0|    case PUBKEY_ALGO_ELGAMAL:
  ------------------
  |  Branch (319:5): [True: 0, False: 14]
  ------------------
  320|      0|      npkey = 3;
  321|      0|      break;
  322|      0|    case PUBKEY_ALGO_DSA:
  ------------------
  |  Branch (322:5): [True: 0, False: 14]
  ------------------
  323|      0|      npkey = 4;
  324|      0|      break;
  325|      0|    case PUBKEY_ALGO_ECDH:
  ------------------
  |  Branch (325:5): [True: 0, False: 14]
  ------------------
  326|      0|      npkey = 3;
  327|      0|      is_ecc = 1;
  328|      0|      break;
  329|      8|    case PUBKEY_ALGO_ECDSA:
  ------------------
  |  Branch (329:5): [True: 8, False: 6]
  ------------------
  330|      8|    case PUBKEY_ALGO_EDDSA:
  ------------------
  |  Branch (330:5): [True: 0, False: 14]
  ------------------
  331|      8|      npkey = 2;
  332|      8|      is_ecc = 1;
  333|      8|      break;
  334|      0|    default: /* Unknown algorithm. */
  ------------------
  |  Branch (334:5): [True: 0, False: 14]
  ------------------
  335|      0|      return gpg_error (GPG_ERR_UNKNOWN_ALGORITHM);
  336|     14|    }
  337|       |
  338|     14|  ki->version = version;
  339|     14|  ki->algo = algorithm;
  340|       |
  341|     42|  for (i=0; i < npkey; i++ )
  ------------------
  |  Branch (341:13): [True: 28, False: 14]
  ------------------
  342|     28|    {
  343|     28|      unsigned int nbits, nbytes;
  344|       |
  345|     28|      if (datalen < 2)
  ------------------
  |  Branch (345:11): [True: 0, False: 28]
  ------------------
  346|      0|        return gpg_error (GPG_ERR_INV_PACKET);
  347|       |
  348|     28|      if (is_ecc && (i == 0 || i == 2))
  ------------------
  |  Branch (348:11): [True: 16, False: 12]
  |  Branch (348:22): [True: 8, False: 8]
  |  Branch (348:32): [True: 0, False: 8]
  ------------------
  349|      8|        {
  350|      8|          nbytes = data[0];
  351|      8|          if (nbytes < 2 || nbytes > 254)
  ------------------
  |  Branch (351:15): [True: 0, False: 8]
  |  Branch (351:29): [True: 0, False: 8]
  ------------------
  352|      0|            return gpg_error (GPG_ERR_INV_PACKET);
  353|      8|          nbytes++; /* The size byte itself.  */
  354|      8|          if (datalen < nbytes)
  ------------------
  |  Branch (354:15): [True: 0, False: 8]
  ------------------
  355|      0|            return gpg_error (GPG_ERR_INV_PACKET);
  356|       |
  357|      8|          keyparm[i].mpi = data;
  358|      8|          keyparm[i].len = nbytes;
  359|      8|        }
  360|     20|      else
  361|     20|        {
  362|     20|          nbits = ((data[0]<<8)|(data[1]));
  363|     20|          data += 2;
  364|     20|          datalen -= 2;
  365|     20|          nbytes = (nbits+7) / 8;
  366|     20|          if (datalen < nbytes)
  ------------------
  |  Branch (366:15): [True: 0, False: 20]
  ------------------
  367|      0|            return gpg_error (GPG_ERR_INV_PACKET);
  368|       |
  369|     20|          keyparm[i].mpi = data;
  370|     20|          keyparm[i].len = nbytes;
  371|     20|        }
  372|       |
  373|     28|      data += nbytes; datalen -= nbytes;
  374|     28|    }
  375|     14|  n = data - data_start;
  376|       |
  377|       |
  378|       |  /* Note: Starting here we need to jump to leave on error. */
  379|       |
  380|       |  /* For non-ECC, make sure the MPIs are unsigned.  */
  381|     14|  if (!is_ecc)
  ------------------
  |  Branch (381:7): [True: 6, False: 8]
  ------------------
  382|     18|    for (i=0; i < npkey; i++)
  ------------------
  |  Branch (382:15): [True: 12, False: 6]
  ------------------
  383|     12|      {
  384|     12|        if (!keyparm[i].len || (keyparm[i].mpi[0] & 0x80))
  ------------------
  |  Branch (384:13): [True: 0, False: 12]
  |  Branch (384:32): [True: 6, False: 6]
  ------------------
  385|      6|          {
  386|      6|            helpmpibuf[i] = xtrymalloc (1+keyparm[i].len);
  ------------------
  |  |   97|      6|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
  387|      6|            if (!helpmpibuf[i])
  ------------------
  |  Branch (387:17): [True: 0, False: 6]
  ------------------
  388|      0|              {
  389|      0|                err = gpg_error_from_syserror ();
  390|      0|                goto leave;
  391|      0|              }
  392|      6|            helpmpibuf[i][0] = 0;
  393|      6|            memcpy (helpmpibuf[i]+1, keyparm[i].mpi, keyparm[i].len);
  394|      6|            keyparm[i].mpi = helpmpibuf[i];
  395|      6|            keyparm[i].len++;
  396|      6|          }
  397|     12|      }
  398|       |
  399|     14|  err = keygrip_from_keyparm (algorithm, keyparm, ki->grip);
  400|     14|  if (err)
  ------------------
  |  Branch (400:7): [True: 0, False: 14]
  ------------------
  401|      0|    goto leave;
  402|       |
  403|     14|  if (version < 4)
  ------------------
  |  Branch (403:7): [True: 0, False: 14]
  ------------------
  404|      0|    {
  405|       |      /* We do not support any other algorithm than RSA in v3
  406|       |         packets. */
  407|      0|      if (algorithm < 1 || algorithm > 3)
  ------------------
  |  Branch (407:11): [True: 0, False: 0]
  |  Branch (407:28): [True: 0, False: 0]
  ------------------
  408|      0|        return gpg_error (GPG_ERR_UNSUPPORTED_ALGORITHM);
  409|       |
  410|      0|      err = gcry_md_open (&md, GCRY_MD_MD5, 0);
  411|      0|      if (err)
  ------------------
  |  Branch (411:11): [True: 0, False: 0]
  ------------------
  412|      0|        return err; /* Oops */
  413|      0|      gcry_md_write (md, keyparm[0].mpi, keyparm[0].len);
  414|      0|      gcry_md_write (md, keyparm[1].mpi, keyparm[1].len);
  415|      0|      memcpy (ki->fpr, gcry_md_read (md, 0), 16);
  416|      0|      gcry_md_close (md);
  417|      0|      ki->fprlen = 16;
  418|       |
  419|      0|      if (keyparm[0].len < 8)
  ------------------
  |  Branch (419:11): [True: 0, False: 0]
  ------------------
  420|      0|        {
  421|       |          /* Moduli less than 64 bit are out of the specs scope.  Zero
  422|       |             them out because this is what gpg does too. */
  423|      0|          memset (ki->keyid, 0, 8);
  424|      0|        }
  425|      0|      else
  426|      0|        memcpy (ki->keyid, keyparm[0].mpi + keyparm[0].len - 8, 8);
  427|      0|    }
  428|     14|  else
  429|     14|    {
  430|       |      /* Its a pity that we need to prefix the buffer with the tag
  431|       |         and a length header: We can't simply pass it to the fast
  432|       |         hashing function for that reason.  It might be a good idea to
  433|       |         have a scatter-gather enabled hash function. What we do here
  434|       |         is to use a static buffer if this one is large enough and
  435|       |         only use the regular hash functions if this buffer is not
  436|       |         large enough.
  437|       |         FIXME: Factor this out to a shared fingerprint function.
  438|       |       */
  439|     14|      if (version == 5)
  ------------------
  |  Branch (439:11): [True: 0, False: 14]
  ------------------
  440|      0|        {
  441|      0|          if ( 5 + n < sizeof hashbuffer )
  ------------------
  |  Branch (441:16): [True: 0, False: 0]
  ------------------
  442|      0|            {
  443|      0|              hashbuffer[0] = 0x9a;     /* CTB */
  444|      0|              hashbuffer[1] = (n >> 24);/* 4 byte length header. */
  445|      0|              hashbuffer[2] = (n >> 16);
  446|      0|              hashbuffer[3] = (n >>  8);
  447|      0|              hashbuffer[4] = (n      );
  448|      0|              memcpy (hashbuffer + 5, data_start, n);
  449|      0|              gcry_md_hash_buffer (GCRY_MD_SHA256, ki->fpr, hashbuffer, 5 + n);
  450|      0|            }
  451|      0|          else
  452|      0|            {
  453|      0|              err = gcry_md_open (&md, GCRY_MD_SHA256, 0);
  454|      0|              if (err)
  ------------------
  |  Branch (454:19): [True: 0, False: 0]
  ------------------
  455|      0|                return err; /* Oops */
  456|      0|              gcry_md_putc (md, 0x9a );     /* CTB */
  457|      0|              gcry_md_putc (md, (n >> 24)); /* 4 byte length header. */
  458|      0|              gcry_md_putc (md, (n >> 16));
  459|      0|              gcry_md_putc (md, (n >>  8));
  460|      0|              gcry_md_putc (md, (n      ));
  461|      0|              gcry_md_write (md, data_start, n);
  462|      0|              memcpy (ki->fpr, gcry_md_read (md, 0), 32);
  463|      0|              gcry_md_close (md);
  464|      0|            }
  465|      0|          ki->fprlen = 32;
  466|      0|          memcpy (ki->keyid, ki->fpr, 8);
  467|      0|        }
  468|     14|      else
  469|     14|        {
  470|     14|          if ( 3 + n < sizeof hashbuffer )
  ------------------
  |  Branch (470:16): [True: 14, False: 0]
  ------------------
  471|     14|            {
  472|     14|              hashbuffer[0] = 0x99;     /* CTB */
  473|     14|              hashbuffer[1] = (n >> 8); /* 2 byte length header. */
  474|     14|              hashbuffer[2] = (n     );
  475|     14|              memcpy (hashbuffer + 3, data_start, n);
  476|     14|              gcry_md_hash_buffer (GCRY_MD_SHA1, ki->fpr, hashbuffer, 3 + n);
  477|     14|            }
  478|      0|          else
  479|      0|            {
  480|      0|              err = gcry_md_open (&md, GCRY_MD_SHA1, 0);
  481|      0|              if (err)
  ------------------
  |  Branch (481:19): [True: 0, False: 0]
  ------------------
  482|      0|                return err; /* Oops */
  483|      0|              gcry_md_putc (md, 0x99 );     /* CTB */
  484|      0|              gcry_md_putc (md, (n >> 8));  /* 2 byte length header. */
  485|      0|              gcry_md_putc (md, (n     ));
  486|      0|              gcry_md_write (md, data_start, n);
  487|      0|              memcpy (ki->fpr, gcry_md_read (md, 0), 20);
  488|      0|              gcry_md_close (md);
  489|      0|            }
  490|     14|          ki->fprlen = 20;
  491|     14|          memcpy (ki->keyid, ki->fpr+12, 8);
  492|     14|        }
  493|     14|    }
  494|       |
  495|     14| leave:
  496|     42|  for (i=0; i < npkey; i++)
  ------------------
  |  Branch (496:13): [True: 28, False: 14]
  ------------------
  497|     28|    xfree (helpmpibuf[i]);
  ------------------
  |  |  104|     42|#define xfree(a)         gcry_free ((a))
  ------------------
  498|       |
  499|     14|  return err;
  500|     14|}
keybox-openpgp.c:keygrip_from_keyparm:
  180|     14|{
  181|     14|  gpg_error_t err;
  182|     14|  gcry_sexp_t s_pkey = NULL;
  183|       |
  184|     14|  switch (algo)
  185|     14|    {
  186|      0|    case PUBKEY_ALGO_DSA:
  ------------------
  |  Branch (186:5): [True: 0, False: 14]
  ------------------
  187|      0|      err = gcry_sexp_build (&s_pkey, NULL,
  188|      0|                             "(public-key(dsa(p%b)(q%b)(g%b)(y%b)))",
  189|      0|                             kp[0].len, kp[0].mpi,
  190|      0|                             kp[1].len, kp[1].mpi,
  191|      0|                             kp[2].len, kp[2].mpi,
  192|      0|                             kp[3].len, kp[3].mpi);
  193|      0|      break;
  194|       |
  195|      0|    case PUBKEY_ALGO_ELGAMAL:
  ------------------
  |  Branch (195:5): [True: 0, False: 14]
  ------------------
  196|      0|    case PUBKEY_ALGO_ELGAMAL_E:
  ------------------
  |  Branch (196:5): [True: 0, False: 14]
  ------------------
  197|      0|      err = gcry_sexp_build (&s_pkey, NULL,
  198|      0|                             "(public-key(elg(p%b)(g%b)(y%b)))",
  199|      0|                             kp[0].len, kp[0].mpi,
  200|      0|                             kp[1].len, kp[1].mpi,
  201|      0|                             kp[2].len, kp[2].mpi);
  202|      0|      break;
  203|       |
  204|      6|    case PUBKEY_ALGO_RSA:
  ------------------
  |  Branch (204:5): [True: 6, False: 8]
  ------------------
  205|      6|    case PUBKEY_ALGO_RSA_S:
  ------------------
  |  Branch (205:5): [True: 0, False: 14]
  ------------------
  206|      6|    case PUBKEY_ALGO_RSA_E:
  ------------------
  |  Branch (206:5): [True: 0, False: 14]
  ------------------
  207|      6|      err = gcry_sexp_build (&s_pkey, NULL,
  208|      6|                             "(public-key(rsa(n%b)(e%b)))",
  209|      6|                             kp[0].len, kp[0].mpi,
  210|      6|                             kp[1].len, kp[1].mpi);
  211|      6|      break;
  212|       |
  213|      0|    case PUBKEY_ALGO_EDDSA:
  ------------------
  |  Branch (213:5): [True: 0, False: 14]
  ------------------
  214|      8|    case PUBKEY_ALGO_ECDSA:
  ------------------
  |  Branch (214:5): [True: 8, False: 6]
  ------------------
  215|      8|    case PUBKEY_ALGO_ECDH:
  ------------------
  |  Branch (215:5): [True: 0, False: 14]
  ------------------
  216|      8|      {
  217|      8|        char *curve = openpgp_oidbuf_to_str (kp[0].mpi, kp[0].len);
  218|      8|        if (!curve)
  ------------------
  |  Branch (218:13): [True: 0, False: 8]
  ------------------
  219|      0|          err = gpg_error_from_syserror ();
  220|      8|        else
  221|      8|          {
  222|      8|            err = gcry_sexp_build
  223|      8|              (&s_pkey, NULL,
  224|      8|               (algo == PUBKEY_ALGO_EDDSA)?
  ------------------
  |  Branch (224:16): [True: 0, False: 8]
  ------------------
  225|      0|               "(public-key(ecc(curve%s)(flags eddsa)(q%b)))":
  226|      8|               (algo == PUBKEY_ALGO_ECDH
  ------------------
  |  Branch (226:17): [True: 0, False: 8]
  ------------------
  227|      8|                && openpgp_oidbuf_is_cv25519 (kp[0].mpi, kp[0].len))?
  ------------------
  |  Branch (227:20): [True: 0, False: 0]
  ------------------
  228|      0|               "(public-key(ecc(curve%s)(flags djb-tweak)(q%b)))":
  229|      8|               "(public-key(ecc(curve%s)(q%b)))",
  230|      8|               curve, kp[1].len, kp[1].mpi);
  231|      8|            xfree (curve);
  ------------------
  |  |  104|      8|#define xfree(a)         gcry_free ((a))
  ------------------
  232|      8|          }
  233|      8|      }
  234|      8|      break;
  235|       |
  236|      0|    default:
  ------------------
  |  Branch (236:5): [True: 0, False: 14]
  ------------------
  237|      0|      err = gpg_error (GPG_ERR_PUBKEY_ALGO);
  238|      0|      break;
  239|     14|    }
  240|       |
  241|     14|  if (!err && !gcry_pk_get_keygrip (s_pkey, grip))
  ------------------
  |  Branch (241:7): [True: 14, False: 0]
  |  Branch (241:15): [True: 0, False: 14]
  ------------------
  242|      0|    {
  243|       |      /* Some Linux distributions remove certain curves from Libgcrypt
  244|       |       * but not from GnuPG and thus the keygrip can't be computed.
  245|       |       * Emit a better error message for this case.  */
  246|      0|      if (!gcry_pk_get_curve (s_pkey, 0, NULL))
  ------------------
  |  Branch (246:11): [True: 0, False: 0]
  ------------------
  247|      0|        err = gpg_error (GPG_ERR_UNKNOWN_CURVE);
  248|      0|      else
  249|      0|        {
  250|      0|          log_info ("kbx: error computing keygrip\n");
  251|      0|          err = gpg_error (GPG_ERR_GENERAL);
  252|      0|        }
  253|      0|    }
  254|       |
  255|     14|  gcry_sexp_release (s_pkey);
  256|       |
  257|     14|  if (err)
  ------------------
  |  Branch (257:7): [True: 0, False: 14]
  ------------------
  258|      0|    memset (grip, 0, 20);
  259|     14|  return err;
  260|     14|}

_keybox_get_flag_location:
  105|     24|{
  106|     24|  size_t pos;
  107|     24|  size_t nkeys, keyinfolen;
  108|     24|  size_t nuids, uidinfolen;
  109|     24|  size_t nserial;
  110|     24|  size_t nsigs, siginfolen, siginfooff;
  111|       |
  112|     24|  switch (what)
  113|     24|    {
  114|      0|    case KEYBOX_FLAG_BLOB:
  ------------------
  |  Branch (114:5): [True: 0, False: 24]
  ------------------
  115|      0|      if (length < 8)
  ------------------
  |  Branch (115:11): [True: 0, False: 0]
  ------------------
  116|      0|        return GPG_ERR_INV_OBJ;
  117|      0|      *flag_off = 6;
  118|      0|      *flag_size = 2;
  119|      0|      break;
  120|       |
  121|      0|    case KEYBOX_FLAG_OWNERTRUST:
  ------------------
  |  Branch (121:5): [True: 0, False: 24]
  ------------------
  122|      0|    case KEYBOX_FLAG_VALIDITY:
  ------------------
  |  Branch (122:5): [True: 0, False: 24]
  ------------------
  123|      0|    case KEYBOX_FLAG_CREATED_AT:
  ------------------
  |  Branch (123:5): [True: 0, False: 24]
  ------------------
  124|     24|    case KEYBOX_FLAG_SIG_INFO:
  ------------------
  |  Branch (124:5): [True: 24, False: 0]
  ------------------
  125|     24|      if (length < 20)
  ------------------
  |  Branch (125:11): [True: 0, False: 24]
  ------------------
  126|      0|        return GPG_ERR_INV_OBJ;
  127|       |      /* Key info. */
  128|     24|      nkeys = get16 (buffer + 16);
  ------------------
  |  |   45|     24|#define get16(a) buf16_to_ulong ((a))
  ------------------
  129|     24|      keyinfolen = get16 (buffer + 18 );
  ------------------
  |  |   45|     24|#define get16(a) buf16_to_ulong ((a))
  ------------------
  130|     24|      if (keyinfolen < 28)
  ------------------
  |  Branch (130:11): [True: 0, False: 24]
  ------------------
  131|      0|        return GPG_ERR_INV_OBJ;
  132|     24|      pos = 20 + keyinfolen*nkeys;
  133|     24|      if (pos+2 > length)
  ------------------
  |  Branch (133:11): [True: 0, False: 24]
  ------------------
  134|      0|        return GPG_ERR_INV_OBJ; /* Out of bounds. */
  135|       |      /* Serial number. */
  136|     24|      nserial = get16 (buffer+pos);
  ------------------
  |  |   45|     24|#define get16(a) buf16_to_ulong ((a))
  ------------------
  137|     24|      pos += 2 + nserial;
  138|     24|      if (pos+4 > length)
  ------------------
  |  Branch (138:11): [True: 0, False: 24]
  ------------------
  139|      0|        return GPG_ERR_INV_OBJ; /* Out of bounds. */
  140|       |      /* User IDs. */
  141|     24|      nuids = get16 (buffer + pos); pos += 2;
  ------------------
  |  |   45|     24|#define get16(a) buf16_to_ulong ((a))
  ------------------
  142|     24|      uidinfolen = get16 (buffer + pos); pos += 2;
  ------------------
  |  |   45|     24|#define get16(a) buf16_to_ulong ((a))
  ------------------
  143|     24|      if (uidinfolen < 12 )
  ------------------
  |  Branch (143:11): [True: 0, False: 24]
  ------------------
  144|      0|        return GPG_ERR_INV_OBJ;
  145|     24|      pos += uidinfolen*nuids;
  146|     24|      if (pos+4 > length)
  ------------------
  |  Branch (146:11): [True: 0, False: 24]
  ------------------
  147|      0|        return GPG_ERR_INV_OBJ ; /* Out of bounds. */
  148|       |      /* Signature info. */
  149|     24|      siginfooff = pos;
  150|     24|      nsigs = get16 (buffer + pos); pos += 2;
  ------------------
  |  |   45|     24|#define get16(a) buf16_to_ulong ((a))
  ------------------
  151|     24|      siginfolen = get16 (buffer + pos); pos += 2;
  ------------------
  |  |   45|     24|#define get16(a) buf16_to_ulong ((a))
  ------------------
  152|     24|      if (siginfolen < 4 )
  ------------------
  |  Branch (152:11): [True: 0, False: 24]
  ------------------
  153|      0|        return GPG_ERR_INV_OBJ;
  154|     24|      pos += siginfolen*nsigs;
  155|     24|      if (pos+1+1+2+4+4+4+4 > length)
  ------------------
  |  Branch (155:11): [True: 0, False: 24]
  ------------------
  156|      0|        return GPG_ERR_INV_OBJ ; /* Out of bounds. */
  157|     24|      *flag_size = 1;
  158|     24|      *flag_off = pos;
  159|     24|      switch (what)
  160|     24|        {
  161|      0|        case KEYBOX_FLAG_VALIDITY:
  ------------------
  |  Branch (161:9): [True: 0, False: 24]
  ------------------
  162|      0|          *flag_off += 1;
  163|      0|          break;
  164|      0|        case KEYBOX_FLAG_CREATED_AT:
  ------------------
  |  Branch (164:9): [True: 0, False: 24]
  ------------------
  165|      0|          *flag_size = 4;
  166|      0|          *flag_off += 1+2+4+4+4;
  167|      0|          break;
  168|     24|        case KEYBOX_FLAG_SIG_INFO:
  ------------------
  |  Branch (168:9): [True: 24, False: 0]
  ------------------
  169|     24|          *flag_size = siginfolen * nsigs;
  170|     24|          *flag_off = siginfooff;
  171|     24|          break;
  172|      0|        default:
  ------------------
  |  Branch (172:9): [True: 0, False: 24]
  ------------------
  173|      0|          break;
  174|     24|        }
  175|     24|      break;
  176|       |
  177|     24|    default:
  ------------------
  |  Branch (177:5): [True: 0, False: 24]
  ------------------
  178|      0|      return GPG_ERR_INV_FLAG;
  179|     24|    }
  180|     24|  return 0;
  181|     24|}
keybox_search_reset:
  901|  1.44k|{
  902|  1.44k|  if (!hd)
  ------------------
  |  Branch (902:7): [True: 0, False: 1.44k]
  ------------------
  903|      0|    return gpg_error (GPG_ERR_INV_VALUE);
  904|       |
  905|  1.44k|  if (hd->found.blob)
  ------------------
  |  Branch (905:7): [True: 9, False: 1.43k]
  ------------------
  906|      9|    {
  907|      9|      _keybox_release_blob (hd->found.blob);
  908|      9|      hd->found.blob = NULL;
  909|      9|    }
  910|       |
  911|  1.44k|  if (hd->fp)
  ------------------
  |  Branch (911:7): [True: 1.28k, False: 161]
  ------------------
  912|  1.28k|    {
  913|  1.28k|      if (es_fseeko (hd->fp, 0, SEEK_SET))
  ------------------
  |  Branch (913:11): [True: 0, False: 1.28k]
  ------------------
  914|      0|        {
  915|       |          /* Ooops.  Seek did not work.  Close so that the search will
  916|       |           * open the file again.  */
  917|      0|          es_fclose (hd->fp);
  918|      0|          hd->fp = NULL;
  919|      0|        }
  920|  1.28k|    }
  921|  1.44k|  hd->error = 0;
  922|  1.44k|  hd->eof = 0;
  923|  1.44k|  return 0;
  924|  1.44k|}
keybox_search:
  936|    296|{
  937|    296|  gpg_error_t rc;
  938|    296|  size_t n;
  939|    296|  int need_words, any_skip;
  940|    296|  KEYBOXBLOB blob = NULL;
  941|    296|  struct sn_array_s *sn_array = NULL;
  942|    296|  int pk_no, uid_no;
  943|    296|  off_t lastfoundoff;
  944|       |
  945|    296|  if (!hd)
  ------------------
  |  Branch (945:7): [True: 0, False: 296]
  ------------------
  946|      0|    return gpg_error (GPG_ERR_INV_VALUE);
  947|       |
  948|       |  /* Clear last found result but record the offset of the last found
  949|       |   * blob which we may need later. */
  950|    296|  if (hd->found.blob)
  ------------------
  |  Branch (950:7): [True: 0, False: 296]
  ------------------
  951|      0|    {
  952|      0|      lastfoundoff = _keybox_get_blob_fileoffset (hd->found.blob);
  953|      0|      _keybox_release_blob (hd->found.blob);
  954|      0|      hd->found.blob = NULL;
  955|      0|    }
  956|    296|  else
  957|    296|    lastfoundoff = 0;
  958|       |
  959|    296|  if (hd->error)
  ------------------
  |  Branch (959:7): [True: 0, False: 296]
  ------------------
  960|      0|    return hd->error; /* still in error state */
  961|    296|  if (hd->eof)
  ------------------
  |  Branch (961:7): [True: 0, False: 296]
  ------------------
  962|      0|    return -1; /* still EOF */
  963|       |
  964|       |  /* figure out what information we need */
  965|    296|  need_words = any_skip = 0;
  966|    592|  for (n=0; n < ndesc; n++)
  ------------------
  |  Branch (966:13): [True: 296, False: 296]
  ------------------
  967|    296|    {
  968|    296|      switch (desc[n].mode)
  969|    296|        {
  970|      0|        case KEYDB_SEARCH_MODE_WORDS:
  ------------------
  |  Branch (970:9): [True: 0, False: 296]
  ------------------
  971|      0|          need_words = 1;
  972|      0|          break;
  973|      1|        case KEYDB_SEARCH_MODE_FIRST:
  ------------------
  |  Branch (973:9): [True: 1, False: 295]
  ------------------
  974|       |          /* always restart the search in this mode */
  975|      1|          keybox_search_reset (hd);
  976|      1|          lastfoundoff = 0;
  977|      1|          break;
  978|    295|        default:
  ------------------
  |  Branch (978:9): [True: 295, False: 1]
  ------------------
  979|    295|          break;
  980|    296|	}
  981|    296|      if (desc[n].skipfnc)
  ------------------
  |  Branch (981:11): [True: 0, False: 296]
  ------------------
  982|      0|        any_skip = 1;
  983|    296|      if (desc[n].snhex && !sn_array)
  ------------------
  |  Branch (983:11): [True: 0, False: 296]
  |  Branch (983:28): [True: 0, False: 0]
  ------------------
  984|      0|        {
  985|      0|          sn_array = xtrycalloc (ndesc, sizeof *sn_array);
  ------------------
  |  |   99|      0|#define xtrycalloc(a,b)  gcry_calloc ((a),(b))
  ------------------
  986|      0|          if (!sn_array)
  ------------------
  |  Branch (986:15): [True: 0, False: 0]
  ------------------
  987|      0|            return (hd->error = gpg_error_from_syserror ());
  988|      0|        }
  989|    296|    }
  990|       |
  991|    296|  (void)need_words;  /* Not yet implemented.  */
  992|       |
  993|    296|  if (!hd->fp)
  ------------------
  |  Branch (993:7): [True: 220, False: 76]
  ------------------
  994|    220|    {
  995|    220|      rc = open_file (hd);
  996|    220|      if (rc)
  ------------------
  |  Branch (996:11): [True: 0, False: 220]
  ------------------
  997|      0|        {
  998|      0|          xfree (sn_array);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  999|      0|          return rc;
 1000|      0|        }
 1001|       |      /* log_debug ("%s: re-opened file\n", __func__); */
 1002|    220|      if (ndesc && desc[0].mode != KEYDB_SEARCH_MODE_FIRST && lastfoundoff)
  ------------------
  |  Branch (1002:11): [True: 220, False: 0]
  |  Branch (1002:20): [True: 219, False: 1]
  |  Branch (1002:63): [True: 0, False: 219]
  ------------------
 1003|      0|        {
 1004|       |          /* Search mode is not first and the last search operation
 1005|       |           * returned a blob which also was not the first one.  We now
 1006|       |           * need to skip over that blob and hope that the file has
 1007|       |           * not changed.  */
 1008|      0|          if (es_fseeko (hd->fp, lastfoundoff, SEEK_SET))
  ------------------
  |  Branch (1008:15): [True: 0, False: 0]
  ------------------
 1009|      0|            {
 1010|      0|              rc = gpg_error_from_syserror ();
 1011|      0|              log_debug ("%s: seeking to last found offset failed: %s\n",
 1012|      0|                         __func__, gpg_strerror (rc));
 1013|      0|              xfree (sn_array);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1014|      0|              return gpg_error (GPG_ERR_NOTHING_FOUND);
 1015|      0|            }
 1016|       |          /* log_debug ("%s: re-opened file and sought to last offset\n", */
 1017|       |          /*            __func__); */
 1018|      0|          rc = _keybox_read_blob (NULL, hd->fp, NULL);
 1019|      0|          if (rc)
  ------------------
  |  Branch (1019:15): [True: 0, False: 0]
  ------------------
 1020|      0|            {
 1021|      0|              log_debug ("%s: skipping last found blob failed: %s\n",
 1022|      0|                         __func__, gpg_strerror (rc));
 1023|      0|              xfree (sn_array);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
 1024|      0|              return gpg_error (GPG_ERR_NOTHING_FOUND);
 1025|      0|            }
 1026|      0|        }
 1027|    220|    }
 1028|       |
 1029|       |  /* Kludge: We need to convert an SN given as hexstring to its binary
 1030|       |     representation - in some cases we are not able to store it in the
 1031|       |     search descriptor, because due to the way we use it, it is not
 1032|       |     possible to free allocated memory. */
 1033|    296|  if (sn_array)
  ------------------
  |  Branch (1033:7): [True: 0, False: 296]
  ------------------
 1034|      0|    {
 1035|      0|      const unsigned char *s;
 1036|      0|      int i, odd;
 1037|      0|      size_t snlen;
 1038|       |
 1039|      0|      for (n=0; n < ndesc; n++)
  ------------------
  |  Branch (1039:17): [True: 0, False: 0]
  ------------------
 1040|      0|        {
 1041|      0|          if (!desc[n].sn)
  ------------------
  |  Branch (1041:15): [True: 0, False: 0]
  ------------------
 1042|      0|            ;
 1043|      0|          else if (desc[n].snhex)
  ------------------
  |  Branch (1043:20): [True: 0, False: 0]
  ------------------
 1044|      0|            {
 1045|      0|              unsigned char *sn;
 1046|       |
 1047|      0|              s = desc[n].sn;
 1048|      0|              for (i=0; *s && *s != '/' && i < desc[n].snlen; s++, i++)
  ------------------
  |  Branch (1048:25): [True: 0, False: 0]
  |  Branch (1048:31): [True: 0, False: 0]
  |  Branch (1048:44): [True: 0, False: 0]
  ------------------
 1049|      0|                ;
 1050|      0|              odd = (i & 1);
 1051|      0|              snlen = (i+1)/2;
 1052|      0|              sn_array[n].sn = xtrymalloc (snlen);
  ------------------
  |  |   97|      0|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
 1053|      0|              if (!sn_array[n].sn)
  ------------------
  |  Branch (1053:19): [True: 0, False: 0]
  ------------------
 1054|      0|                {
 1055|      0|                  hd->error = gpg_error_from_syserror ();
 1056|      0|                  release_sn_array (sn_array, n);
 1057|      0|                  return hd->error;
 1058|      0|                }
 1059|      0|              sn_array[n].snlen = snlen;
 1060|      0|              sn = sn_array[n].sn;
 1061|      0|              s = desc[n].sn;
 1062|      0|              if (odd)
  ------------------
  |  Branch (1062:19): [True: 0, False: 0]
  ------------------
 1063|      0|                {
 1064|      0|                  *sn++ = xtoi_1 (s);
  ------------------
  |  |   33|      0|#define xtoi_1(p)   (*(p) <= '9'? (*(p)- '0'): \
  |  |  ------------------
  |  |  |  Branch (33:22): [True: 0, False: 0]
  |  |  ------------------
  |  |   34|      0|                     *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))
  |  |  ------------------
  |  |  |  Branch (34:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1065|      0|                  s++;
 1066|      0|                }
 1067|      0|              for (; *s && *s != '/';  s += 2)
  ------------------
  |  Branch (1067:22): [True: 0, False: 0]
  |  Branch (1067:28): [True: 0, False: 0]
  ------------------
 1068|      0|                *sn++ = xtoi_2 (s);
  ------------------
  |  |   35|      0|#define xtoi_2(p)   ((xtoi_1(p) * 16) + xtoi_1((p)+1))
  |  |  ------------------
  |  |  |  |   33|      0|#define xtoi_1(p)   (*(p) <= '9'? (*(p)- '0'): \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (33:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   34|      0|                     *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (34:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define xtoi_2(p)   ((xtoi_1(p) * 16) + xtoi_1((p)+1))
  |  |  ------------------
  |  |  |  |   33|      0|#define xtoi_1(p)   (*(p) <= '9'? (*(p)- '0'): \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (33:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   34|      0|                     *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (34:22): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1069|      0|            }
 1070|      0|          else
 1071|      0|            {
 1072|      0|              const unsigned char *sn;
 1073|       |
 1074|      0|              sn = desc[n].sn;
 1075|      0|              snlen = desc[n].snlen;
 1076|      0|              sn_array[n].sn = xtrymalloc (snlen);
  ------------------
  |  |   97|      0|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
 1077|      0|              if (!sn_array[n].sn)
  ------------------
  |  Branch (1077:19): [True: 0, False: 0]
  ------------------
 1078|      0|                {
 1079|      0|                  hd->error = gpg_error_from_syserror ();
 1080|      0|                  release_sn_array (sn_array, n);
 1081|      0|                  return hd->error;
 1082|      0|                }
 1083|      0|              sn_array[n].snlen = snlen;
 1084|      0|              memcpy (sn_array[n].sn, sn, snlen);
 1085|      0|            }
 1086|      0|        }
 1087|      0|    }
 1088|       |
 1089|       |
 1090|    296|  pk_no = uid_no = 0;
 1091|    296|  for (;;)
 1092|    650|    {
 1093|    650|      unsigned int blobflags;
 1094|    650|      int blobtype;
 1095|       |
 1096|    650|      _keybox_release_blob (blob); blob = NULL;
 1097|    650|      rc = _keybox_read_blob (&blob, hd->fp, NULL);
 1098|    650|      if (gpg_err_code (rc) == GPG_ERR_TOO_LARGE
  ------------------
  |  Branch (1098:11): [True: 0, False: 650]
  ------------------
 1099|    650|          && gpg_err_source (rc) == GPG_ERR_SOURCE_KEYBOX)
  ------------------
  |  Branch (1099:14): [True: 0, False: 0]
  ------------------
 1100|      0|        {
 1101|      0|          ++*r_skipped;
 1102|      0|          continue; /* Skip too large records.  */
 1103|      0|        }
 1104|       |
 1105|    650|      if (rc)
  ------------------
  |  Branch (1105:11): [True: 263, False: 387]
  ------------------
 1106|    263|        break;
 1107|       |
 1108|    387|      blobtype = blob_get_type (blob);
 1109|    387|      if (blobtype == KEYBOX_BLOBTYPE_HEADER)
  ------------------
  |  Branch (1109:11): [True: 296, False: 91]
  ------------------
 1110|    296|        continue;
 1111|     91|      if (want_blobtype && blobtype != want_blobtype)
  ------------------
  |  Branch (1111:11): [True: 91, False: 0]
  |  Branch (1111:28): [True: 0, False: 91]
  ------------------
 1112|      0|        continue;
 1113|       |
 1114|     91|      blobflags = blob_get_blob_flags (blob);
 1115|     91|      if (!hd->ephemeral && (blobflags & 2))
  ------------------
  |  Branch (1115:11): [True: 91, False: 0]
  |  Branch (1115:29): [True: 0, False: 91]
  ------------------
 1116|      0|        continue; /* Not in ephemeral mode but blob is flagged ephemeral.  */
 1117|       |
 1118|    149|      for (n=0; n < ndesc; n++)
  ------------------
  |  Branch (1118:17): [True: 91, False: 58]
  ------------------
 1119|     91|        {
 1120|     91|          switch (desc[n].mode)
 1121|     91|            {
 1122|      0|            case KEYDB_SEARCH_MODE_NONE:
  ------------------
  |  Branch (1122:13): [True: 0, False: 91]
  ------------------
 1123|      0|              never_reached ();
  ------------------
  |  |   88|      0|#define never_reached() do {                             \
  |  |   89|      0|    log_debug ("%s:%d: oops - should never get here\n",  \
  |  |   90|      0|               __FILE__, __LINE__ );                     \
  |  |   91|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (91:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1124|      0|              break;
 1125|      0|            case KEYDB_SEARCH_MODE_EXACT:
  ------------------
  |  Branch (1125:13): [True: 0, False: 91]
  ------------------
 1126|      0|              uid_no = has_username (blob, desc[n].u.name, 0);
 1127|      0|              if (uid_no)
  ------------------
  |  Branch (1127:19): [True: 0, False: 0]
  ------------------
 1128|      0|                goto found;
 1129|      0|              break;
 1130|      0|            case KEYDB_SEARCH_MODE_MAIL:
  ------------------
  |  Branch (1130:13): [True: 0, False: 91]
  ------------------
 1131|      0|              uid_no = has_mail (blob, desc[n].u.name, 0);
 1132|      0|              if (uid_no)
  ------------------
  |  Branch (1132:19): [True: 0, False: 0]
  ------------------
 1133|      0|                goto found;
 1134|      0|              break;
 1135|      0|            case KEYDB_SEARCH_MODE_MAILSUB:
  ------------------
  |  Branch (1135:13): [True: 0, False: 91]
  ------------------
 1136|      0|              uid_no = has_mail (blob, desc[n].u.name, 1);
 1137|      0|              if (uid_no)
  ------------------
  |  Branch (1137:19): [True: 0, False: 0]
  ------------------
 1138|      0|                goto found;
 1139|      0|              break;
 1140|      0|            case KEYDB_SEARCH_MODE_SUBSTR:
  ------------------
  |  Branch (1140:13): [True: 0, False: 91]
  ------------------
 1141|      0|              uid_no =  has_username (blob, desc[n].u.name, 1);
 1142|      0|              if (uid_no)
  ------------------
  |  Branch (1142:19): [True: 0, False: 0]
  ------------------
 1143|      0|                goto found;
 1144|      0|              break;
 1145|      0|            case KEYDB_SEARCH_MODE_MAILEND:
  ------------------
  |  Branch (1145:13): [True: 0, False: 91]
  ------------------
 1146|      0|            case KEYDB_SEARCH_MODE_WORDS:
  ------------------
  |  Branch (1146:13): [True: 0, False: 91]
  ------------------
 1147|       |              /* not yet implemented */
 1148|      0|              break;
 1149|      0|            case KEYDB_SEARCH_MODE_ISSUER:
  ------------------
  |  Branch (1149:13): [True: 0, False: 91]
  ------------------
 1150|      0|              if (has_issuer (blob, desc[n].u.name))
  ------------------
  |  Branch (1150:19): [True: 0, False: 0]
  ------------------
 1151|      0|                goto found;
 1152|      0|              break;
 1153|      0|            case KEYDB_SEARCH_MODE_ISSUER_SN:
  ------------------
  |  Branch (1153:13): [True: 0, False: 91]
  ------------------
 1154|      0|              if (has_issuer_sn (blob, desc[n].u.name,
  ------------------
  |  Branch (1154:19): [True: 0, False: 0]
  ------------------
 1155|      0|                                 sn_array? sn_array[n].sn : desc[n].sn,
  ------------------
  |  Branch (1155:34): [True: 0, False: 0]
  ------------------
 1156|      0|                                 sn_array? sn_array[n].snlen : desc[n].snlen))
  ------------------
  |  Branch (1156:34): [True: 0, False: 0]
  ------------------
 1157|      0|                goto found;
 1158|      0|              break;
 1159|      0|            case KEYDB_SEARCH_MODE_SN:
  ------------------
  |  Branch (1159:13): [True: 0, False: 91]
  ------------------
 1160|      0|              if (has_sn (blob, sn_array? sn_array[n].sn : desc[n].sn,
  ------------------
  |  Branch (1160:19): [True: 0, False: 0]
  |  Branch (1160:33): [True: 0, False: 0]
  ------------------
 1161|      0|                                sn_array? sn_array[n].snlen : desc[n].snlen))
  ------------------
  |  Branch (1161:33): [True: 0, False: 0]
  ------------------
 1162|      0|                goto found;
 1163|      0|              break;
 1164|      0|            case KEYDB_SEARCH_MODE_SUBJECT:
  ------------------
  |  Branch (1164:13): [True: 0, False: 91]
  ------------------
 1165|      0|              if (has_subject (blob, desc[n].u.name))
  ------------------
  |  Branch (1165:19): [True: 0, False: 0]
  ------------------
 1166|      0|                goto found;
 1167|      0|              break;
 1168|      0|            case KEYDB_SEARCH_MODE_SHORT_KID:
  ------------------
  |  Branch (1168:13): [True: 0, False: 91]
  ------------------
 1169|      0|              pk_no = has_short_kid (blob, desc[n].u.kid[1]);
 1170|      0|              if (pk_no)
  ------------------
  |  Branch (1170:19): [True: 0, False: 0]
  ------------------
 1171|      0|                goto found;
 1172|      0|              break;
 1173|     53|            case KEYDB_SEARCH_MODE_LONG_KID:
  ------------------
  |  Branch (1173:13): [True: 53, False: 38]
  ------------------
 1174|     53|              pk_no = has_long_kid (blob, desc[n].u.kid[0], desc[n].u.kid[1]);
 1175|     53|              if (pk_no)
  ------------------
  |  Branch (1175:19): [True: 11, False: 42]
  ------------------
 1176|     11|                goto found;
 1177|     42|              break;
 1178|       |
 1179|     42|            case KEYDB_SEARCH_MODE_FPR:
  ------------------
  |  Branch (1179:13): [True: 38, False: 53]
  ------------------
 1180|     38|              pk_no = has_fingerprint (blob, desc[n].u.fpr, desc[n].fprlen);
 1181|     38|              if (pk_no)
  ------------------
  |  Branch (1181:19): [True: 22, False: 16]
  ------------------
 1182|     22|                goto found;
 1183|     16|              break;
 1184|       |
 1185|     16|            case KEYDB_SEARCH_MODE_KEYGRIP:
  ------------------
  |  Branch (1185:13): [True: 0, False: 91]
  ------------------
 1186|      0|              if (has_keygrip (blob, desc[n].u.grip))
  ------------------
  |  Branch (1186:19): [True: 0, False: 0]
  ------------------
 1187|      0|                goto found;
 1188|      0|              break;
 1189|      0|            case KEYDB_SEARCH_MODE_UBID:
  ------------------
  |  Branch (1189:13): [True: 0, False: 91]
  ------------------
 1190|      0|              if (has_ubid (blob, desc[n].u.ubid))
  ------------------
  |  Branch (1190:19): [True: 0, False: 0]
  ------------------
 1191|      0|                goto found;
 1192|      0|              break;
 1193|      0|            case KEYDB_SEARCH_MODE_FIRST:
  ------------------
  |  Branch (1193:13): [True: 0, False: 91]
  ------------------
 1194|      0|              goto found;
 1195|      0|              break;
 1196|      0|            case KEYDB_SEARCH_MODE_NEXT:
  ------------------
  |  Branch (1196:13): [True: 0, False: 91]
  ------------------
 1197|      0|              goto found;
 1198|      0|              break;
 1199|      0|            default:
  ------------------
  |  Branch (1199:13): [True: 0, False: 91]
  ------------------
 1200|      0|              rc = gpg_error (GPG_ERR_INV_VALUE);
 1201|      0|              goto found;
 1202|     91|            }
 1203|     91|	}
 1204|     58|      continue;
 1205|     58|    found:
 1206|       |      /* Record which DESC we matched on.  Note this value is only
 1207|       |	 meaningful if this function returns with no errors. */
 1208|     33|      if(r_descindex)
  ------------------
  |  Branch (1208:10): [True: 0, False: 33]
  ------------------
 1209|      0|	*r_descindex = n;
 1210|     33|      for (n=any_skip?0:ndesc; n < ndesc; n++)
  ------------------
  |  Branch (1210:14): [True: 0, False: 33]
  |  Branch (1210:32): [True: 0, False: 33]
  ------------------
 1211|      0|        {
 1212|      0|          u32 kid[2];
 1213|       |
 1214|      0|          if (desc[n].skipfnc
  ------------------
  |  Branch (1214:15): [True: 0, False: 0]
  ------------------
 1215|      0|              && blob_get_first_keyid (blob, kid)
  ------------------
  |  Branch (1215:18): [True: 0, False: 0]
  ------------------
 1216|      0|	      && desc[n].skipfnc (desc[n].skipfncvalue, kid, uid_no))
  ------------------
  |  Branch (1216:11): [True: 0, False: 0]
  ------------------
 1217|      0|		break;
 1218|      0|        }
 1219|     33|      if (n == ndesc)
  ------------------
  |  Branch (1219:11): [True: 33, False: 0]
  ------------------
 1220|     33|        break; /* got it */
 1221|     33|    }
 1222|       |
 1223|    296|  if (!rc)
  ------------------
  |  Branch (1223:7): [True: 33, False: 263]
  ------------------
 1224|     33|    {
 1225|     33|      hd->found.blob = blob;
 1226|     33|      hd->found.pk_no = pk_no;
 1227|     33|      hd->found.uid_no = uid_no;
 1228|     33|    }
 1229|    263|  else if (rc == -1 || gpg_err_code (rc) == GPG_ERR_EOF)
  ------------------
  |  Branch (1229:12): [True: 263, False: 0]
  |  Branch (1229:24): [True: 0, False: 0]
  ------------------
 1230|    263|    {
 1231|    263|      _keybox_release_blob (blob);
 1232|    263|      hd->eof = 1;
 1233|    263|    }
 1234|      0|  else
 1235|      0|    {
 1236|      0|      _keybox_release_blob (blob);
 1237|      0|      hd->error = rc;
 1238|      0|    }
 1239|       |
 1240|    296|  if (sn_array)
  ------------------
  |  Branch (1240:7): [True: 0, False: 296]
  ------------------
 1241|      0|    release_sn_array (sn_array, ndesc);
 1242|       |
 1243|    296|  return rc;
 1244|    296|}
keybox_get_keyblock:
 1336|     24|{
 1337|     24|  gpg_error_t err;
 1338|     24|  const unsigned char *buffer;
 1339|     24|  size_t length;
 1340|     24|  size_t image_off, image_len;
 1341|     24|  size_t siginfo_off, siginfo_len;
 1342|       |
 1343|     24|  *r_iobuf = NULL;
 1344|       |
 1345|     24|  if (!hd)
  ------------------
  |  Branch (1345:7): [True: 0, False: 24]
  ------------------
 1346|      0|    return gpg_error (GPG_ERR_INV_VALUE);
 1347|     24|  if (!hd->found.blob)
  ------------------
  |  Branch (1347:7): [True: 0, False: 24]
  ------------------
 1348|      0|    return gpg_error (GPG_ERR_NOTHING_FOUND);
 1349|       |
 1350|     24|  if (blob_get_type (hd->found.blob) != KEYBOX_BLOBTYPE_PGP)
  ------------------
  |  Branch (1350:7): [True: 0, False: 24]
  ------------------
 1351|      0|    return gpg_error (GPG_ERR_WRONG_BLOB_TYPE);
 1352|       |
 1353|     24|  buffer = _keybox_get_blob_image (hd->found.blob, &length);
 1354|     24|  if (length < 40)
  ------------------
  |  Branch (1354:7): [True: 0, False: 24]
  ------------------
 1355|      0|    return gpg_error (GPG_ERR_TOO_SHORT);
 1356|     24|  image_off = get32 (buffer+8);
  ------------------
  |  |   44|     24|#define get32(a) buf32_to_ulong ((a))
  ------------------
 1357|     24|  image_len = get32 (buffer+12);
  ------------------
  |  |   44|     24|#define get32(a) buf32_to_ulong ((a))
  ------------------
 1358|     24|  if ((uint64_t)image_off+(uint64_t)image_len > (uint64_t)length)
  ------------------
  |  Branch (1358:7): [True: 0, False: 24]
  ------------------
 1359|      0|    return gpg_error (GPG_ERR_TOO_SHORT);
 1360|       |
 1361|     24|  err = _keybox_get_flag_location (buffer, length, KEYBOX_FLAG_SIG_INFO,
 1362|     24|                                   &siginfo_off, &siginfo_len);
 1363|     24|  if (err)
  ------------------
  |  Branch (1363:7): [True: 0, False: 24]
  ------------------
 1364|      0|    return err;
 1365|       |
 1366|     24|  *r_pk_no  = hd->found.pk_no;
 1367|     24|  *r_uid_no = hd->found.uid_no;
 1368|     24|  *r_iobuf = iobuf_temp_with_content (buffer+image_off, image_len);
 1369|     24|  return 0;
 1370|     24|}
keybox_offset:
 1460|      4|{
 1461|      4|  if (!hd->fp)
  ------------------
  |  Branch (1461:7): [True: 0, False: 4]
  ------------------
 1462|      0|    return 0;
 1463|      4|  return es_ftello (hd->fp);
 1464|      4|}
keybox-search.c:open_file:
  879|    220|{
  880|       |
  881|    220|  hd->fp = es_fopen (hd->kb->fname, "rb");
  882|    220|  if (!hd->fp)
  ------------------
  |  Branch (882:7): [True: 0, False: 220]
  ------------------
  883|      0|    {
  884|      0|      hd->error = gpg_error_from_syserror ();
  885|      0|      return hd->error;
  886|      0|    }
  887|       |
  888|    220|  return 0;
  889|    220|}
keybox-search.c:blob_get_blob_flags:
   50|     91|{
   51|     91|  const unsigned char *buffer;
   52|     91|  size_t length;
   53|       |
   54|     91|  buffer = _keybox_get_blob_image (blob, &length);
   55|     91|  if (length < 8)
  ------------------
  |  Branch (55:7): [True: 0, False: 91]
  ------------------
   56|      0|    return 0; /* oops */
   57|       |
   58|     91|  return get16 (buffer + 6);
  ------------------
  |  |   45|     91|#define get16(a) buf16_to_ulong ((a))
  ------------------
   59|     91|}
keybox-search.c:blob_cmp_fpr_part:
  286|     53|{
  287|     53|  const unsigned char *buffer;
  288|     53|  size_t length;
  289|     53|  size_t pos, off;
  290|     53|  size_t nkeys, keyinfolen;
  291|     53|  int idx, fpr32, storedfprlen;
  292|       |
  293|     53|  buffer = _keybox_get_blob_image (blob, &length);
  294|     53|  if (length < 40)
  ------------------
  |  Branch (294:7): [True: 0, False: 53]
  ------------------
  295|      0|    return 0; /* blob too short */
  296|     53|  fpr32 = buffer[5] == 2;
  297|       |
  298|       |  /*keys*/
  299|     53|  nkeys = get16 (buffer + 16);
  ------------------
  |  |   45|     53|#define get16(a) buf16_to_ulong ((a))
  ------------------
  300|     53|  keyinfolen = get16 (buffer + 18 );
  ------------------
  |  |   45|     53|#define get16(a) buf16_to_ulong ((a))
  ------------------
  301|     53|  if (keyinfolen < (fpr32?56:28))
  ------------------
  |  Branch (301:7): [True: 0, False: 53]
  |  Branch (301:21): [True: 0, False: 53]
  ------------------
  302|      0|    return 0; /* invalid blob */
  303|     53|  pos = 20;
  304|     53|  if (pos + (uint64_t)keyinfolen*nkeys > (uint64_t)length)
  ------------------
  |  Branch (304:7): [True: 0, False: 53]
  ------------------
  305|      0|    return 0; /* out of bounds */
  306|       |
  307|    123|  for (idx=0; idx < nkeys; idx++)
  ------------------
  |  Branch (307:15): [True: 81, False: 42]
  ------------------
  308|     81|    {
  309|     81|      off = pos + idx*keyinfolen;
  310|     81|      if (fpr32)
  ------------------
  |  Branch (310:11): [True: 0, False: 81]
  ------------------
  311|      0|        storedfprlen = (get16 (buffer + off + 32) & 0x80)? 32:20;
  ------------------
  |  |   45|      0|#define get16(a) buf16_to_ulong ((a))
  ------------------
  |  Branch (311:24): [True: 0, False: 0]
  ------------------
  312|     81|      else
  313|     81|        storedfprlen = 20;
  314|     81|      if ((fpr32 || storedfprlen == fproff + fprlen)
  ------------------
  |  Branch (314:12): [True: 0, False: 81]
  |  Branch (314:21): [True: 81, False: 0]
  ------------------
  315|     81|          && !memcmp (buffer + off + fproff, fpr, fprlen))
  ------------------
  |  Branch (315:14): [True: 11, False: 70]
  ------------------
  316|     11|        return idx+1; /* found */
  317|     81|    }
  318|     42|  return 0; /* not found */
  319|     53|}
keybox-search.c:has_long_kid:
  711|     53|{
  712|     53|  const unsigned char *buffer;
  713|     53|  size_t length;
  714|     53|  int fpr32;
  715|     53|  unsigned char buf[8];
  716|       |
  717|     53|  buffer = _keybox_get_blob_image (blob, &length);
  718|     53|  if (length < 48)
  ------------------
  |  Branch (718:7): [True: 0, False: 53]
  ------------------
  719|      0|    return 0; /* blob too short */
  720|     53|  fpr32 = buffer[5] == 2;
  721|     53|  if (fpr32 && length < 56)
  ------------------
  |  Branch (721:7): [True: 0, False: 53]
  |  Branch (721:16): [True: 0, False: 0]
  ------------------
  722|      0|    return 0; /* blob to short */
  723|       |
  724|     53|  buf[0] = mkid >> 24;
  725|     53|  buf[1] = mkid >> 16;
  726|     53|  buf[2] = mkid >> 8;
  727|     53|  buf[3] = mkid;
  728|     53|  buf[4] = lkid >> 24;
  729|     53|  buf[5] = lkid >> 16;
  730|     53|  buf[6] = lkid >> 8;
  731|     53|  buf[7] = lkid;
  732|       |
  733|     53|  if (fpr32 && (get16 (buffer + 20 + 32) & 0x80))
  ------------------
  |  |   45|      0|#define get16(a) buf16_to_ulong ((a))
  ------------------
  |  Branch (733:7): [True: 0, False: 53]
  |  Branch (733:16): [True: 0, False: 0]
  ------------------
  734|      0|    return blob_cmp_fpr_part (blob, buf, 0, 8);
  735|     53|  else
  736|     53|    return blob_cmp_fpr_part (blob, buf, 12, 8);
  737|     53|}
keybox-search.c:has_fingerprint:
  741|     38|{
  742|     38|  return blob_cmp_fpr (blob, fpr, fprlen);
  743|     38|}
keybox-search.c:blob_cmp_fpr:
  246|     38|{
  247|     38|  const unsigned char *buffer;
  248|     38|  size_t length;
  249|     38|  size_t pos, off;
  250|     38|  size_t nkeys, keyinfolen;
  251|     38|  int idx, fpr32, storedfprlen;
  252|       |
  253|     38|  buffer = _keybox_get_blob_image (blob, &length);
  254|     38|  if (length < 40)
  ------------------
  |  Branch (254:7): [True: 0, False: 38]
  ------------------
  255|      0|    return 0; /* blob too short */
  256|     38|  fpr32 = buffer[5] == 2;
  257|       |
  258|       |  /*keys*/
  259|     38|  nkeys = get16 (buffer + 16);
  ------------------
  |  |   45|     38|#define get16(a) buf16_to_ulong ((a))
  ------------------
  260|     38|  keyinfolen = get16 (buffer + 18 );
  ------------------
  |  |   45|     38|#define get16(a) buf16_to_ulong ((a))
  ------------------
  261|     38|  if (keyinfolen < (fpr32?56:28))
  ------------------
  |  Branch (261:7): [True: 0, False: 38]
  |  Branch (261:21): [True: 0, False: 38]
  ------------------
  262|      0|    return 0; /* invalid blob */
  263|     38|  pos = 20;
  264|     38|  if (pos + (uint64_t)keyinfolen*nkeys > (uint64_t)length)
  ------------------
  |  Branch (264:7): [True: 0, False: 38]
  ------------------
  265|      0|    return 0; /* out of bounds */
  266|       |
  267|     70|  for (idx=0; idx < nkeys; idx++)
  ------------------
  |  Branch (267:15): [True: 54, False: 16]
  ------------------
  268|     54|    {
  269|     54|      off = pos + idx*keyinfolen;
  270|     54|      if (fpr32)
  ------------------
  |  Branch (270:11): [True: 0, False: 54]
  ------------------
  271|      0|        storedfprlen = (get16 (buffer + off + 32) & 0x80)? 32:20;
  ------------------
  |  |   45|      0|#define get16(a) buf16_to_ulong ((a))
  ------------------
  |  Branch (271:24): [True: 0, False: 0]
  ------------------
  272|     54|      else
  273|     54|        storedfprlen = 20;
  274|     54|      if (storedfprlen == fprlen
  ------------------
  |  Branch (274:11): [True: 54, False: 0]
  ------------------
  275|     54|          && !memcmp (buffer + off, fpr, storedfprlen))
  ------------------
  |  Branch (275:14): [True: 22, False: 32]
  ------------------
  276|     22|        return idx+1; /* found */
  277|     54|    }
  278|     16|  return 0; /* not found */
  279|     38|}

keybox_insert_keyblock:
  360|      2|{
  361|      2|  gpg_error_t err;
  362|      2|  const char *fname;
  363|      2|  KEYBOXBLOB blob;
  364|      2|  size_t nparsed;
  365|      2|  struct _keybox_openpgp_info info;
  366|       |
  367|      2|  if (!hd)
  ------------------
  |  Branch (367:7): [True: 0, False: 2]
  ------------------
  368|      0|    return gpg_error (GPG_ERR_INV_HANDLE);
  369|      2|  if (!hd->kb)
  ------------------
  |  Branch (369:7): [True: 0, False: 2]
  ------------------
  370|      0|    return gpg_error (GPG_ERR_INV_HANDLE);
  371|      2|  fname = hd->kb->fname;
  372|      2|  if (!fname)
  ------------------
  |  Branch (372:7): [True: 0, False: 2]
  ------------------
  373|      0|    return gpg_error (GPG_ERR_INV_HANDLE);
  374|       |
  375|       |
  376|       |  /* Close this one otherwise we will mess up the position for a next
  377|       |     search.  Fixme: it would be better to adjust the position after
  378|       |     the write operation.  */
  379|      2|  _keybox_close_file (hd);
  380|       |
  381|      2|  err = _keybox_parse_openpgp (image, imagelen, &nparsed, &info);
  382|      2|  if (err)
  ------------------
  |  Branch (382:7): [True: 0, False: 2]
  ------------------
  383|      0|    return err;
  384|      2|  assert (nparsed <= imagelen);
  385|      2|  err = _keybox_create_openpgp_blob (&blob, &info, image, imagelen,
  386|      2|                                      hd->ephemeral);
  387|      2|  _keybox_destroy_openpgp_info (&info);
  388|      2|  if (!err)
  ------------------
  |  Branch (388:7): [True: 2, False: 0]
  ------------------
  389|      2|    {
  390|      2|      err = blob_filecopy (FILECOPY_INSERT, fname, blob, hd->secret, 1, 0);
  ------------------
  |  |   36|      2|#define FILECOPY_INSERT 1
  ------------------
  391|      2|      _keybox_release_blob (blob);
  392|       |      /*    if (!rc && !hd->secret && kb_offtbl) */
  393|       |      /*      { */
  394|       |      /*        update_offset_hash_table_from_kb (kb_offtbl, kb, 0); */
  395|       |      /*      } */
  396|      2|    }
  397|      2|  return err;
  398|      2|}
keybox_update_keyblock:
  405|      9|{
  406|      9|  gpg_error_t err;
  407|      9|  const char *fname;
  408|      9|  off_t off;
  409|      9|  KEYBOXBLOB blob;
  410|      9|  size_t nparsed;
  411|      9|  struct _keybox_openpgp_info info;
  412|       |
  413|      9|  if (!hd || !image || !imagelen)
  ------------------
  |  Branch (413:7): [True: 0, False: 9]
  |  Branch (413:14): [True: 0, False: 9]
  |  Branch (413:24): [True: 0, False: 9]
  ------------------
  414|      0|    return gpg_error (GPG_ERR_INV_VALUE);
  415|      9|  if (!hd->found.blob)
  ------------------
  |  Branch (415:7): [True: 0, False: 9]
  ------------------
  416|      0|    return gpg_error (GPG_ERR_NOTHING_FOUND);
  417|      9|  if (blob_get_type (hd->found.blob) != KEYBOX_BLOBTYPE_PGP)
  ------------------
  |  Branch (417:7): [True: 0, False: 9]
  ------------------
  418|      0|    return gpg_error (GPG_ERR_WRONG_BLOB_TYPE);
  419|      9|  fname = hd->kb->fname;
  420|      9|  if (!fname)
  ------------------
  |  Branch (420:7): [True: 0, False: 9]
  ------------------
  421|      0|    return gpg_error (GPG_ERR_INV_HANDLE);
  422|       |
  423|      9|  off = _keybox_get_blob_fileoffset (hd->found.blob);
  424|      9|  if (off == (off_t)-1)
  ------------------
  |  Branch (424:7): [True: 0, False: 9]
  ------------------
  425|      0|    return gpg_error (GPG_ERR_GENERAL);
  426|       |
  427|       |  /* Close the file so that we do no mess up the position for a
  428|       |     next search.  */
  429|      9|  _keybox_close_file (hd);
  430|       |
  431|       |  /* Build a new blob.  */
  432|      9|  err = _keybox_parse_openpgp (image, imagelen, &nparsed, &info);
  433|      9|  if (err)
  ------------------
  |  Branch (433:7): [True: 0, False: 9]
  ------------------
  434|      0|    return err;
  435|      9|  assert (nparsed <= imagelen);
  436|      9|  err = _keybox_create_openpgp_blob (&blob, &info, image, imagelen,
  437|      9|                                     hd->ephemeral);
  438|      9|  _keybox_destroy_openpgp_info (&info);
  439|       |
  440|       |  /* Update the keyblock.  */
  441|      9|  if (!err)
  ------------------
  |  Branch (441:7): [True: 9, False: 0]
  ------------------
  442|      9|    {
  443|      9|      err = blob_filecopy (FILECOPY_UPDATE, fname, blob, hd->secret, 1, off);
  ------------------
  |  |   38|      9|#define FILECOPY_UPDATE 3
  ------------------
  444|      9|      _keybox_release_blob (blob);
  445|      9|    }
  446|      9|  return err;
  447|      9|}
keybox_compress:
  629|      1|{
  630|      1|  gpg_err_code_t ec;
  631|      1|  int read_rc, rc;
  632|      1|  const char *fname;
  633|      1|  estream_t fp, newfp;
  634|      1|  char *bakfname = NULL;
  635|      1|  char *tmpfname = NULL;
  636|      1|  int first_blob;
  637|      1|  KEYBOXBLOB blob = NULL;
  638|      1|  u32 cut_time;
  639|      1|  int any_changes = 0;
  640|      1|  int skipped_deleted;
  641|       |
  642|      1|  if (!hd)
  ------------------
  |  Branch (642:7): [True: 0, False: 1]
  ------------------
  643|      0|    return gpg_error (GPG_ERR_INV_HANDLE);
  644|      1|  if (!hd->kb)
  ------------------
  |  Branch (644:7): [True: 0, False: 1]
  ------------------
  645|      0|    return gpg_error (GPG_ERR_INV_HANDLE);
  646|      1|  if (hd->secret)
  ------------------
  |  Branch (646:7): [True: 0, False: 1]
  ------------------
  647|      0|    return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
  648|      1|  fname = hd->kb->fname;
  649|      1|  if (!fname)
  ------------------
  |  Branch (649:7): [True: 0, False: 1]
  ------------------
  650|      0|    return gpg_error (GPG_ERR_INV_HANDLE);
  651|       |
  652|      1|  _keybox_close_file (hd);
  653|       |
  654|       |  /* Open the source file. Because we do a rename, we have to check the
  655|       |     permissions of the file */
  656|      1|  if ((ec = gnupg_access (fname, W_OK)))
  ------------------
  |  Branch (656:7): [True: 0, False: 1]
  ------------------
  657|      0|    return gpg_error (ec);
  658|       |
  659|      1|  fp = es_fopen (fname, "rb");
  660|      1|  if (!fp && errno == ENOENT)
  ------------------
  |  Branch (660:7): [True: 0, False: 1]
  |  Branch (660:14): [True: 0, False: 0]
  ------------------
  661|      0|    return 0; /* Ready. File has been deleted right after the access above. */
  662|      1|  if (!fp)
  ------------------
  |  Branch (662:7): [True: 0, False: 1]
  ------------------
  663|      0|    {
  664|      0|      rc = gpg_error_from_syserror ();
  665|      0|      return rc;
  666|      0|    }
  667|       |
  668|       |  /* A quick test to see if we need to compress the file at all.  We
  669|       |     schedule a compress run after 3 hours. */
  670|      1|  if ( !_keybox_read_blob (&blob, fp, NULL) )
  ------------------
  |  Branch (670:8): [True: 1, False: 0]
  ------------------
  671|      1|    {
  672|      1|      const unsigned char *buffer;
  673|      1|      size_t length;
  674|       |
  675|      1|      buffer = _keybox_get_blob_image (blob, &length);
  676|      1|      if (length > 4 && buffer[4] == KEYBOX_BLOBTYPE_HEADER)
  ------------------
  |  Branch (676:11): [True: 1, False: 0]
  |  Branch (676:25): [True: 1, False: 0]
  ------------------
  677|      1|        {
  678|      1|          u32 last_maint = buf32_to_u32 (buffer+20);
  679|       |
  680|      1|          if ( (last_maint + 3*3600) > make_timestamp () )
  ------------------
  |  Branch (680:16): [True: 1, False: 0]
  ------------------
  681|      1|            {
  682|      1|              es_fclose (fp);
  683|      1|              _keybox_release_blob (blob);
  684|      1|              return 0; /* Compress run not yet needed. */
  685|      1|            }
  686|      1|        }
  687|      0|      _keybox_release_blob (blob);
  688|      0|      es_fseek (fp, 0, SEEK_SET);
  689|      0|      es_clearerr (fp);
  690|      0|    }
  691|       |
  692|       |  /* Create the new file. */
  693|      0|  rc = create_tmp_file (fname, &bakfname, &tmpfname, &newfp);
  694|      0|  if (rc)
  ------------------
  |  Branch (694:7): [True: 0, False: 0]
  ------------------
  695|      0|    {
  696|      0|      es_fclose (fp);
  697|      0|      return rc;;
  698|      0|    }
  699|       |
  700|       |
  701|       |  /* Processing loop.  By reading using _keybox_read_blob we
  702|       |     automagically skip any blobs flagged as deleted.  Thus what we
  703|       |     only have to do is to check all ephemeral flagged blocks whether
  704|       |     their time has come and write out all other blobs. */
  705|      0|  cut_time = make_timestamp () - 86400;
  706|      0|  first_blob = 1;
  707|      0|  skipped_deleted = 0;
  708|      0|  for (rc=0; !(read_rc = _keybox_read_blob (&blob, fp, &skipped_deleted));
  ------------------
  |  Branch (708:14): [True: 0, False: 0]
  ------------------
  709|      0|       _keybox_release_blob (blob), blob = NULL )
  710|      0|    {
  711|      0|      unsigned int blobflags;
  712|      0|      const unsigned char *buffer;
  713|      0|      size_t length, pos, size;
  714|      0|      u32 created_at;
  715|       |
  716|      0|      if (skipped_deleted)
  ------------------
  |  Branch (716:11): [True: 0, False: 0]
  ------------------
  717|      0|        any_changes = 1;
  718|      0|      buffer = _keybox_get_blob_image (blob, &length);
  719|      0|      if (first_blob)
  ------------------
  |  Branch (719:11): [True: 0, False: 0]
  ------------------
  720|      0|        {
  721|      0|          first_blob = 0;
  722|      0|          if (length > 4 && buffer[4] == KEYBOX_BLOBTYPE_HEADER)
  ------------------
  |  Branch (722:15): [True: 0, False: 0]
  |  Branch (722:29): [True: 0, False: 0]
  ------------------
  723|      0|            {
  724|       |              /* Write out the blob with an updated maintenance time
  725|       |                 stamp and if needed (ie. used by gpg) set the openpgp
  726|       |                 flag.  */
  727|      0|              _keybox_update_header_blob (blob, hd->for_openpgp);
  728|      0|              rc = _keybox_write_blob (blob, newfp, NULL);
  729|      0|              if (rc)
  ------------------
  |  Branch (729:19): [True: 0, False: 0]
  ------------------
  730|      0|                break;
  731|      0|              continue;
  732|      0|            }
  733|       |
  734|       |          /* The header blob is missing.  Insert it.  */
  735|      0|          rc = _keybox_write_header_blob (newfp, hd->for_openpgp);
  736|      0|          if (rc)
  ------------------
  |  Branch (736:15): [True: 0, False: 0]
  ------------------
  737|      0|            break;
  738|      0|          any_changes = 1;
  739|      0|        }
  740|      0|      else if (length > 4 && buffer[4] == KEYBOX_BLOBTYPE_HEADER)
  ------------------
  |  Branch (740:16): [True: 0, False: 0]
  |  Branch (740:30): [True: 0, False: 0]
  ------------------
  741|      0|        {
  742|       |          /* Oops: There is another header record - remove it. */
  743|      0|          any_changes = 1;
  744|      0|          continue;
  745|      0|        }
  746|       |
  747|      0|      if (_keybox_get_flag_location (buffer, length,
  ------------------
  |  Branch (747:11): [True: 0, False: 0]
  ------------------
  748|      0|                                     KEYBOX_FLAG_BLOB, &pos, &size)
  749|      0|          || size != 2)
  ------------------
  |  Branch (749:14): [True: 0, False: 0]
  ------------------
  750|      0|        {
  751|      0|          rc = gpg_error (GPG_ERR_BUG);
  752|      0|          break;
  753|      0|        }
  754|      0|      blobflags = buf16_to_uint (buffer+pos);
  755|      0|      if ((blobflags & KEYBOX_FLAG_BLOB_EPHEMERAL))
  ------------------
  |  |   54|      0|#define KEYBOX_FLAG_BLOB_EPHEMERAL  2
  ------------------
  |  Branch (755:11): [True: 0, False: 0]
  ------------------
  756|      0|        {
  757|       |          /* This is an ephemeral blob. */
  758|      0|          if (_keybox_get_flag_location (buffer, length,
  ------------------
  |  Branch (758:15): [True: 0, False: 0]
  ------------------
  759|      0|                                         KEYBOX_FLAG_CREATED_AT, &pos, &size)
  760|      0|              || size != 4)
  ------------------
  |  Branch (760:18): [True: 0, False: 0]
  ------------------
  761|      0|            created_at = 0; /* oops. */
  762|      0|          else
  763|      0|            created_at = buf32_to_u32 (buffer+pos);
  764|       |
  765|      0|          if (created_at && created_at < cut_time)
  ------------------
  |  Branch (765:15): [True: 0, False: 0]
  |  Branch (765:29): [True: 0, False: 0]
  ------------------
  766|      0|            {
  767|      0|              any_changes = 1;
  768|      0|              continue; /* Skip this blob. */
  769|      0|            }
  770|      0|        }
  771|       |
  772|      0|      rc = _keybox_write_blob (blob, newfp, NULL);
  773|      0|      if (rc)
  ------------------
  |  Branch (773:11): [True: 0, False: 0]
  ------------------
  774|      0|        break;
  775|      0|    }
  776|      0|  if (skipped_deleted)
  ------------------
  |  Branch (776:7): [True: 0, False: 0]
  ------------------
  777|      0|    any_changes = 1;
  778|      0|  _keybox_release_blob (blob); blob = NULL;
  779|      0|  if (!rc && read_rc == -1)
  ------------------
  |  Branch (779:7): [True: 0, False: 0]
  |  Branch (779:14): [True: 0, False: 0]
  ------------------
  780|      0|    rc = 0;
  781|      0|  else if (!rc)
  ------------------
  |  Branch (781:12): [True: 0, False: 0]
  ------------------
  782|      0|    rc = read_rc;
  783|       |
  784|       |  /* Close both files. */
  785|      0|  if (es_fclose(fp) && !rc)
  ------------------
  |  Branch (785:7): [True: 0, False: 0]
  |  Branch (785:24): [True: 0, False: 0]
  ------------------
  786|      0|    rc = gpg_error_from_syserror ();
  787|      0|  if (es_fclose(newfp) && !rc)
  ------------------
  |  Branch (787:7): [True: 0, False: 0]
  |  Branch (787:27): [True: 0, False: 0]
  ------------------
  788|      0|    rc = gpg_error_from_syserror ();
  789|       |
  790|       |  /* Rename or remove the temporary file. */
  791|      0|  if (rc || !any_changes)
  ------------------
  |  Branch (791:7): [True: 0, False: 0]
  |  Branch (791:13): [True: 0, False: 0]
  ------------------
  792|      0|    gnupg_remove (tmpfname);
  793|      0|  else
  794|      0|    rc = rename_tmp_file (bakfname, tmpfname, fname, hd->secret);
  795|       |
  796|      0|  xfree(bakfname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  797|      0|  xfree(tmpfname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
  798|      0|  return rc;
  799|      0|}
keybox-update.c:blob_filecopy:
  163|     11|{
  164|     11|  gpg_err_code_t ec;
  165|     11|  estream_t fp, newfp;
  166|     11|  int rc = 0;
  167|     11|  char *bakfname = NULL;
  168|     11|  char *tmpfname = NULL;
  169|     11|  char buffer[4096];  /* (Must be at least 32 bytes) */
  170|     11|  int nread, nbytes;
  171|       |
  172|       |  /* Open the source file. Because we do a rename, we have to check the
  173|       |     permissions of the file */
  174|     11|  if ((ec = gnupg_access (fname, W_OK)))
  ------------------
  |  Branch (174:7): [True: 0, False: 11]
  ------------------
  175|      0|    return gpg_error (ec);
  176|       |
  177|     11|  fp = es_fopen (fname, "rb");
  178|     11|  if (mode == FILECOPY_INSERT && !fp && errno == ENOENT)
  ------------------
  |  |   36|     22|#define FILECOPY_INSERT 1
  ------------------
  |  Branch (178:7): [True: 2, False: 9]
  |  Branch (178:34): [True: 0, False: 2]
  |  Branch (178:41): [True: 0, False: 0]
  ------------------
  179|      0|    {
  180|       |      /* Insert mode but file does not exist:
  181|       |         Create a new keybox file. */
  182|      0|      newfp = es_fopen (fname, "wb");
  183|      0|      if (!newfp )
  ------------------
  |  Branch (183:11): [True: 0, False: 0]
  ------------------
  184|      0|        return gpg_error_from_syserror ();
  185|       |
  186|      0|      rc = _keybox_write_header_blob (newfp, for_openpgp);
  187|      0|      if (rc)
  ------------------
  |  Branch (187:11): [True: 0, False: 0]
  ------------------
  188|      0|        {
  189|      0|          es_fclose (newfp);
  190|      0|          return rc;
  191|      0|        }
  192|       |
  193|      0|      rc = _keybox_write_blob (blob, newfp, NULL);
  194|      0|      if (rc)
  ------------------
  |  Branch (194:11): [True: 0, False: 0]
  ------------------
  195|      0|        {
  196|      0|          es_fclose (newfp);
  197|      0|          return rc;
  198|      0|        }
  199|       |
  200|      0|      if ( es_fclose (newfp) )
  ------------------
  |  Branch (200:12): [True: 0, False: 0]
  ------------------
  201|      0|        return gpg_error_from_syserror ();
  202|       |
  203|       |/*        if (chmod( fname, S_IRUSR | S_IWUSR )) */
  204|       |/*          { */
  205|       |/*            log_debug ("%s: chmod failed: %s\n", fname, strerror(errno) ); */
  206|       |/*            return KEYBOX_File_Error; */
  207|       |/*          } */
  208|      0|      return 0; /* Ready. */
  209|      0|    }
  210|       |
  211|     11|  if (!fp)
  ------------------
  |  Branch (211:7): [True: 0, False: 11]
  ------------------
  212|      0|    {
  213|      0|      rc = gpg_error_from_syserror ();
  214|      0|      goto leave;
  215|      0|    }
  216|       |
  217|       |  /* Create the new file.  On success NEWFP is initialized.  */
  218|     11|  rc = create_tmp_file (fname, &bakfname, &tmpfname, &newfp);
  219|     11|  if (rc)
  ------------------
  |  Branch (219:7): [True: 0, False: 11]
  ------------------
  220|      0|    {
  221|      0|      es_fclose (fp);
  222|      0|      goto leave;
  223|      0|    }
  224|       |
  225|       |  /* prepare for insert */
  226|     11|  if (mode == FILECOPY_INSERT)
  ------------------
  |  |   36|     11|#define FILECOPY_INSERT 1
  ------------------
  |  Branch (226:7): [True: 2, False: 9]
  ------------------
  227|      2|    {
  228|      2|      int first_record = 1;
  229|       |
  230|       |      /* Copy everything to the new file.  If this is for OpenPGP, we
  231|       |         make sure that the openpgp flag is set in the header.  (We
  232|       |         failsafe the blob type.) */
  233|      4|      while ( (nread = es_fread (buffer, 1, DIM(buffer), fp)) > 0 )
  ------------------
  |  |   47|      4|#define DIM(v)		     (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (233:15): [True: 2, False: 2]
  ------------------
  234|      2|        {
  235|      2|          if (first_record && for_openpgp
  ------------------
  |  Branch (235:15): [True: 2, False: 0]
  |  Branch (235:31): [True: 2, False: 0]
  ------------------
  236|      2|              && buffer[4] == KEYBOX_BLOBTYPE_HEADER)
  ------------------
  |  Branch (236:18): [True: 2, False: 0]
  ------------------
  237|      2|            {
  238|      2|              first_record = 0;
  239|      2|              buffer[7] |= 0x02; /* OpenPGP data may be available.  */
  240|      2|            }
  241|       |
  242|      2|          if (es_fwrite (buffer, nread, 1, newfp) != 1)
  ------------------
  |  Branch (242:15): [True: 0, False: 2]
  ------------------
  243|      0|            {
  244|      0|              rc = gpg_error_from_syserror ();
  245|      0|              es_fclose (fp);
  246|      0|              es_fclose (newfp);
  247|      0|              goto leave;
  248|      0|            }
  249|      2|        }
  250|      2|      if (es_ferror (fp))
  ------------------
  |  Branch (250:11): [True: 0, False: 2]
  ------------------
  251|      0|        {
  252|      0|          rc = gpg_error_from_syserror ();
  253|      0|          es_fclose (fp);
  254|      0|          es_fclose (newfp);
  255|      0|          goto leave;
  256|      0|        }
  257|      2|    }
  258|       |
  259|       |  /* Prepare for delete or update. */
  260|     11|  if ( mode == FILECOPY_DELETE || mode == FILECOPY_UPDATE )
  ------------------
  |  |   37|     22|#define FILECOPY_DELETE 2
  ------------------
                if ( mode == FILECOPY_DELETE || mode == FILECOPY_UPDATE )
  ------------------
  |  |   38|     11|#define FILECOPY_UPDATE 3
  ------------------
  |  Branch (260:8): [True: 0, False: 11]
  |  Branch (260:35): [True: 9, False: 2]
  ------------------
  261|      9|    {
  262|      9|      off_t current = 0;
  263|       |
  264|       |      /* Copy first part to the new file. */
  265|     18|      while ( current < start_offset )
  ------------------
  |  Branch (265:15): [True: 9, False: 9]
  ------------------
  266|      9|        {
  267|      9|          nbytes = DIM(buffer);
  ------------------
  |  |   47|      9|#define DIM(v)		     (sizeof(v)/sizeof((v)[0]))
  ------------------
  268|      9|          if (current + nbytes > start_offset)
  ------------------
  |  Branch (268:15): [True: 9, False: 0]
  ------------------
  269|      9|              nbytes = start_offset - current;
  270|      9|          nread = es_fread (buffer, 1, nbytes, fp);
  271|      9|          if (!nread)
  ------------------
  |  Branch (271:15): [True: 0, False: 9]
  ------------------
  272|      0|            break;
  273|      9|          current += nread;
  274|       |
  275|      9|          if (es_fwrite (buffer, nread, 1, newfp) != 1)
  ------------------
  |  Branch (275:15): [True: 0, False: 9]
  ------------------
  276|      0|            {
  277|      0|              rc = gpg_error_from_syserror ();
  278|      0|              es_fclose (fp);
  279|      0|              es_fclose (newfp);
  280|      0|              goto leave;
  281|      0|            }
  282|      9|        }
  283|      9|      if (es_ferror (fp))
  ------------------
  |  Branch (283:11): [True: 0, False: 9]
  ------------------
  284|      0|        {
  285|      0|          rc = gpg_error_from_syserror ();
  286|      0|          es_fclose (fp);
  287|      0|          es_fclose (newfp);
  288|      0|          goto leave;
  289|      0|        }
  290|       |
  291|       |      /* Skip this blob. */
  292|      9|      rc = _keybox_read_blob (NULL, fp, NULL);
  293|      9|      if (rc)
  ------------------
  |  Branch (293:11): [True: 0, False: 9]
  ------------------
  294|      0|        {
  295|      0|          es_fclose (fp);
  296|      0|          es_fclose (newfp);
  297|      0|          goto leave;
  298|      0|        }
  299|      9|    }
  300|       |
  301|       |  /* Do an insert or update. */
  302|     11|  if ( mode == FILECOPY_INSERT || mode == FILECOPY_UPDATE )
  ------------------
  |  |   36|     22|#define FILECOPY_INSERT 1
  ------------------
                if ( mode == FILECOPY_INSERT || mode == FILECOPY_UPDATE )
  ------------------
  |  |   38|      9|#define FILECOPY_UPDATE 3
  ------------------
  |  Branch (302:8): [True: 2, False: 9]
  |  Branch (302:35): [True: 9, False: 0]
  ------------------
  303|     11|    {
  304|     11|      rc = _keybox_write_blob (blob, newfp, NULL);
  305|     11|      if (rc)
  ------------------
  |  Branch (305:11): [True: 0, False: 11]
  ------------------
  306|      0|        {
  307|      0|          es_fclose (fp);
  308|      0|          es_fclose (newfp);
  309|      0|          goto leave;
  310|      0|        }
  311|     11|    }
  312|       |
  313|       |  /* Copy the rest of the packet for an delete or update. */
  314|     11|  if (mode == FILECOPY_DELETE || mode == FILECOPY_UPDATE)
  ------------------
  |  |   37|     22|#define FILECOPY_DELETE 2
  ------------------
                if (mode == FILECOPY_DELETE || mode == FILECOPY_UPDATE)
  ------------------
  |  |   38|     11|#define FILECOPY_UPDATE 3
  ------------------
  |  Branch (314:7): [True: 0, False: 11]
  |  Branch (314:34): [True: 9, False: 2]
  ------------------
  315|      9|    {
  316|      9|      while ( (nread = es_fread (buffer, 1, DIM(buffer), fp)) > 0 )
  ------------------
  |  |   47|      9|#define DIM(v)		     (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (316:15): [True: 0, False: 9]
  ------------------
  317|      0|        {
  318|      0|          if (es_fwrite (buffer, nread, 1, newfp) != 1)
  ------------------
  |  Branch (318:15): [True: 0, False: 0]
  ------------------
  319|      0|            {
  320|      0|              rc = gpg_error_from_syserror ();
  321|      0|              es_fclose (fp);
  322|      0|              es_fclose (newfp);
  323|      0|              goto leave;
  324|      0|            }
  325|      0|        }
  326|      9|      if (es_ferror (fp))
  ------------------
  |  Branch (326:11): [True: 0, False: 9]
  ------------------
  327|      0|        {
  328|      0|          rc = gpg_error_from_syserror ();
  329|      0|          es_fclose (fp);
  330|      0|          es_fclose (newfp);
  331|      0|          goto leave;
  332|      0|        }
  333|      9|    }
  334|       |
  335|       |  /* Close both files. */
  336|     11|  if (es_fclose(fp))
  ------------------
  |  Branch (336:7): [True: 0, False: 11]
  ------------------
  337|      0|    {
  338|      0|      rc = gpg_error_from_syserror ();
  339|      0|      es_fclose (newfp);
  340|      0|      goto leave;
  341|      0|    }
  342|     11|  if (es_fclose(newfp))
  ------------------
  |  Branch (342:7): [True: 0, False: 11]
  ------------------
  343|      0|    {
  344|      0|      rc = gpg_error_from_syserror ();
  345|      0|      goto leave;
  346|      0|    }
  347|       |
  348|     11|  rc = rename_tmp_file (bakfname, tmpfname, fname, secret);
  349|       |
  350|     11| leave:
  351|     11|  xfree(bakfname);
  ------------------
  |  |  104|     11|#define xfree(a)         gcry_free ((a))
  ------------------
  352|     11|  xfree(tmpfname);
  ------------------
  |  |  104|     11|#define xfree(a)         gcry_free ((a))
  ------------------
  353|     11|  return rc;
  354|     11|}
keybox-update.c:create_tmp_file:
   75|     11|{
   76|     11|  gpg_error_t err;
   77|       |
   78|     11|  err = keybox_tmp_names (template, 0, r_bakfname, r_tmpfname);
   79|     11|  if (!err)
  ------------------
  |  Branch (79:7): [True: 11, False: 0]
  ------------------
   80|     11|    {
   81|     11|      *r_fp = es_fopen (*r_tmpfname, "wb");
   82|     11|      if (!*r_fp)
  ------------------
  |  Branch (82:11): [True: 0, False: 11]
  ------------------
   83|      0|        {
   84|      0|          err = gpg_error_from_syserror ();
   85|      0|          xfree (*r_tmpfname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
   86|      0|          *r_tmpfname = NULL;
   87|      0|          xfree (*r_bakfname);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
   88|      0|          *r_bakfname = NULL;
   89|      0|        }
   90|     11|    }
   91|       |
   92|     11|  return err;
   93|     11|}
keybox-update.c:rename_tmp_file:
   99|     11|{
  100|     11|  int rc=0;
  101|     11|  int block = 0;
  102|       |
  103|       |  /* restrict the permissions for secret keyboxs */
  104|     11|#ifndef HAVE_DOSISH_SYSTEM
  105|       |/*    if (secret && !opt.preserve_permissions) */
  106|       |/*      { */
  107|       |/*        if (chmod (tmpfname, S_IRUSR | S_IWUSR) )  */
  108|       |/*          { */
  109|       |/*            log_debug ("chmod of '%s' failed: %s\n", */
  110|       |/*                       tmpfname, strerror(errno) ); */
  111|       |/*            return KEYBOX_Write_File; */
  112|       |/*  	} */
  113|       |/*      } */
  114|     11|#endif
  115|       |
  116|       |  /* fixme: invalidate close caches (not used with stdio)*/
  117|       |/*    iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)tmpfname ); */
  118|       |/*    iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)bakfname ); */
  119|       |/*    iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)fname ); */
  120|       |
  121|       |  /* First make a backup file except for secret keyboxes. */
  122|     11|  if (!secret)
  ------------------
  |  Branch (122:7): [True: 11, False: 0]
  ------------------
  123|     11|    {
  124|     11|      block = 1;
  125|     11|      rc = gnupg_rename_file (fname, bakfname, &block);
  126|     11|      if (rc)
  ------------------
  |  Branch (126:11): [True: 0, False: 11]
  ------------------
  127|      0|        goto leave;
  128|     11|    }
  129|       |
  130|       |  /* Then rename the file. */
  131|     11|  rc = gnupg_rename_file (tmpfname, fname, NULL);
  132|     11|  if (block)
  ------------------
  |  Branch (132:7): [True: 11, False: 0]
  ------------------
  133|     11|    {
  134|     11|      gnupg_unblock_all_signals ();
  135|     11|      block = 0;
  136|     11|    }
  137|       |  /* if (rc) */
  138|       |  /*   { */
  139|       |  /*     if (secret) */
  140|       |  /*       { */
  141|       |  /*         log_info ("WARNING: 2 files with confidential" */
  142|       |  /*                   " information exists.\n"); */
  143|       |  /*         log_info ("%s is the unchanged one\n", fname ); */
  144|       |  /*         log_info ("%s is the new one\n", tmpfname ); */
  145|       |  /*         log_info ("Please fix this possible security flaw\n"); */
  146|       |  /*       } */
  147|       |  /*   } */
  148|       |
  149|     11| leave:
  150|     11|  if (block)
  ------------------
  |  Branch (150:7): [True: 0, False: 11]
  ------------------
  151|      0|    gnupg_unblock_all_signals ();
  152|     11|  return rc;
  153|     11|}

keybox_tmp_names:
   40|     12|{
   41|     12|  gpg_error_t err;
   42|     12|  char *bak_name, *tmp_name;
   43|       |
   44|     12|  *r_bakname = NULL;
   45|     12|  *r_tmpname = NULL;
   46|       |
   47|       |# ifdef USE_ONLY_8DOT3
   48|       |  /* Here is another Windoze bug?:
   49|       |   * you can't rename("pubring.kbx.tmp", "pubring.kbx");
   50|       |   * but	rename("pubring.kbx.tmp", "pubring.aaa");
   51|       |   * works.  So we replace ".kbx" by ".kb_" or ".k__".  Note that we
   52|       |   * can't use ".bak" and ".tmp", because these suffixes are used by
   53|       |   * gpg's keyrings and would lead to a sharing violation or data
   54|       |   * corruption.  If the name does not end in ".kbx" we assume working
   55|       |   * on a modern file system and append the suffix.  */
   56|       |  {
   57|       |    const char *ext   = for_keyring? EXTSEP_S GPGEXT_GPG : EXTSEP_S "kbx";
   58|       |    const char *b_ext = for_keyring? EXTSEP_S "bak"      : EXTSEP_S "kb_";
   59|       |    const char *t_ext = for_keyring? EXTSEP_S "tmp"      : EXTSEP_S "k__";
   60|       |    int repl;
   61|       |
   62|       |    if (strlen (ext) != 4 || strlen (b_ext) != 4)
   63|       |      BUG ();
   64|       |    repl = (strlen (filename) > 4
   65|       |            && !strcmp (filename + strlen (filename) - 4, ext));
   66|       |    bak_name = xtrymalloc (strlen (filename) + (repl?0:4) + 1);
   67|       |    if (!bak_name)
   68|       |      return gpg_error_from_syserror ();
   69|       |    strcpy (bak_name, filename);
   70|       |    strcpy (bak_name + strlen (filename) - (repl?4:0), b_ext);
   71|       |
   72|       |    tmp_name = xtrymalloc (strlen (filename) + (repl?0:4) + 1);
   73|       |    if (!tmp_name)
   74|       |      {
   75|       |        err = gpg_error_from_syserror ();
   76|       |        xfree (bak_name);
   77|       |        return err;
   78|       |      }
   79|       |    strcpy (tmp_name, filename);
   80|       |    strcpy (tmp_name + strlen (filename) - (repl?4:0), t_ext);
   81|       |  }
   82|       |# else /* Posix file names */
   83|     12|  (void)for_keyring;
   84|     12|  bak_name = xtrymalloc (strlen (filename) + 2);
  ------------------
  |  |   97|     12|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
   85|     12|  if (!bak_name)
  ------------------
  |  Branch (85:7): [True: 0, False: 12]
  ------------------
   86|      0|    return gpg_error_from_syserror ();
   87|     12|  strcpy (stpcpy (bak_name, filename), "~");
   88|       |
   89|     12|  tmp_name = xtrymalloc (strlen (filename) + 5);
  ------------------
  |  |   97|     12|#define xtrymalloc(a)    gcry_malloc ((a))
  ------------------
   90|     12|  if (!tmp_name)
  ------------------
  |  Branch (90:7): [True: 0, False: 12]
  ------------------
   91|      0|    {
   92|      0|      err = gpg_error_from_syserror ();
   93|      0|      xfree (bak_name);
  ------------------
  |  |  104|      0|#define xfree(a)         gcry_free ((a))
  ------------------
   94|      0|      return err;
   95|      0|    }
   96|     12|  strcpy (stpcpy (tmp_name,filename), EXTSEP_S "tmp");
  ------------------
  |  |  889|     12|#define EXTSEP_S "."
  ------------------
   97|     12|# endif /* Posix filename */
   98|       |
   99|     12|  *r_bakname = bak_name;
  100|     12|  *r_tmpname = tmp_name;
  101|     12|  return 0;
  102|     12|}

LLVMFuzzerTestOneInput:
   93|     53|int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   94|     53|    if (! initialized) {
  ------------------
  |  Branch (94:9): [True: 1, False: 52]
  ------------------
   95|      1|        ctrlGlobal = (ctrl_t) malloc(sizeof(*ctrlGlobal));
   96|      1|        if (!ctrlGlobal) {
  ------------------
  |  Branch (96:13): [True: 0, False: 1]
  ------------------
   97|      0|            exit(1);
   98|      0|        }
   99|       |        //deletes previous tmp dir and (re)create it as a ramfs
  100|       |        //system("umount /tmp/fuzzdirimport");
  101|      1|        rmrfdir("/tmp/fuzzdirimport");
  102|      1|        if (mkdir("/tmp/fuzzdirimport", 0700) < 0) {
  ------------------
  |  Branch (102:13): [True: 0, False: 1]
  ------------------
  103|      0|            printf("failed mkdir, errno=%d\n", errno);
  104|      0|            if (errno != EEXIST) {
  ------------------
  |  Branch (104:17): [True: 0, False: 0]
  ------------------
  105|      0|                return 0;
  106|      0|            }
  107|      0|        }
  108|       |        //system("mount -t tmpfs -o size=64M tmpfs /tmp/fuzzdirimport");
  109|      1|        filename=strdup("/tmp/fuzzdirimport/fuzz.gpg");
  110|      1|        if (!filename) {
  ------------------
  |  Branch (110:13): [True: 0, False: 1]
  ------------------
  111|      0|            free(ctrlGlobal);
  112|      0|            return 0;
  113|      0|        }
  114|      1|        fd = open(filename, O_RDWR | O_CREAT, 0666);
  115|      1|        if (fd == -1) {
  ------------------
  |  Branch (115:13): [True: 0, False: 1]
  ------------------
  116|      0|            free(filename);
  117|      0|            free(ctrlGlobal);
  118|      0|            printf("failed open, errno=%d\n", errno);
  119|      0|            return 0;
  120|      0|        }
  121|      1|        gnupg_set_homedir("/tmp/fuzzdirimport/");
  122|      1|        gpg_error_t gpgerr = keydb_add_resource ("pubring" EXTSEP_S GPGEXT_GPG, KEYDB_RESOURCE_FLAG_DEFAULT);
  ------------------
  |  |  122|      1|#define GPGEXT_GPG "gpg"
  ------------------
                      gpg_error_t gpgerr = keydb_add_resource ("pubring" EXTSEP_S GPGEXT_GPG, KEYDB_RESOURCE_FLAG_DEFAULT);
  ------------------
  |  |  212|      1|#define KEYDB_RESOURCE_FLAG_DEFAULT  4  /* The default one.  */
  ------------------
  123|      1|        if (gpgerr != GPG_ERR_NO_ERROR) {
  ------------------
  |  Branch (123:13): [True: 0, False: 1]
  ------------------
  124|      0|            free(filename);
  125|      0|            free(ctrlGlobal);
  126|      0|            close(fd);
  127|      0|            printf("failed keydb_add_resource, errno=%d\n", gpgerr);
  128|      0|            return 0;
  129|      0|        }
  130|      1|        gpgerr = setup_trustdb (1, NULL);
  131|      1|        if (gpgerr != GPG_ERR_NO_ERROR) {
  ------------------
  |  Branch (131:13): [True: 0, False: 1]
  ------------------
  132|      0|            free(filename);
  133|      0|            free(ctrlGlobal);
  134|      0|            close(fd);
  135|      0|            printf("failed setup_trustdb, errno=%d\n", gpgerr);
  136|      0|            return 0;
  137|      0|        }
  138|       |        //populate /tmp/fuzzdirimport/ as homedir ~/.gnupg
  139|      1|        strlist_t sl = NULL;
  140|      1|        public_key_list (ctrlGlobal, sl, 0, 0);
  141|      1|        free_strlist(sl);
  142|       |        //no output for stderr
  143|      1|        log_set_file("/dev/null");
  144|      1|        gcry_set_log_handler (my_gcry_logger, NULL);
  145|      1|        gnupg_initialize_compliance (GNUPG_MODULE_NAME_GPG);
  ------------------
  |  |  293|      1|#define GNUPG_MODULE_NAME_GPG           8
  ------------------
  146|      1|        initialized = true;
  147|      1|    }
  148|       |
  149|     53|    memset(ctrlGlobal, 0, sizeof(*ctrlGlobal));
  150|     53|    ctrlGlobal->magic = SERVER_CONTROL_MAGIC;
  ------------------
  |  |   83|     53|# define SERVER_CONTROL_MAGIC 0x53616c696e676572
  ------------------
  151|     53|    if (Size > MAX_LEN) {
  ------------------
  |  |   42|     53|#define MAX_LEN 0x2000
  ------------------
  |  Branch (151:9): [True: 19, False: 34]
  ------------------
  152|       |        // limit maximum size to avoid long computing times
  153|     19|        Size = MAX_LEN;
  ------------------
  |  |   42|     19|#define MAX_LEN 0x2000
  ------------------
  154|     19|    }
  155|       |
  156|     53|    if (ftruncate(fd, Size) == -1) {
  ------------------
  |  Branch (156:9): [True: 0, False: 53]
  ------------------
  157|      0|        return 0;
  158|      0|    }
  159|     53|    if (lseek (fd, 0, SEEK_SET) < 0) {
  ------------------
  |  Branch (159:9): [True: 0, False: 53]
  ------------------
  160|      0|        return 0;
  161|      0|    }
  162|     53|    if (write (fd, Data, Size) != Size) {
  ------------------
  |  Branch (162:9): [True: 0, False: 53]
  ------------------
  163|      0|        return 0;
  164|      0|    }
  165|       |
  166|     53|    import_keys (ctrlGlobal, &filename, 1, NULL, IMPORT_REPAIR_KEYS, 0, NULL);
  ------------------
  |  |  394|     53|#define IMPORT_REPAIR_KEYS               (1<<11)
  ------------------
  167|     53|    gpg_deinit_default_ctrl (ctrlGlobal);
  168|       |    /*memset(ctrlGlobal, 0, sizeof(*ctrlGlobal));
  169|       |    ctrlGlobal->magic = SERVER_CONTROL_MAGIC;
  170|       |    PKT_public_key pk;
  171|       |    get_pubkey_fromfile (ctrlGlobal, &pk, filename);
  172|       |    release_public_key_parts (&pk);
  173|       |    gpg_deinit_default_ctrl (ctrlGlobal);*/
  174|       |
  175|     53|    return 0;
  176|     53|}
fuzz_import.c:rmrfdir:
   86|      1|{
   87|      1|    ftw(path, unlink_cb, 16);
   88|      1|    if (rmdir(path) != 0) {
  ------------------
  |  Branch (88:9): [True: 0, False: 1]
  ------------------
   89|      0|        printf("failed rmdir, errno=%d\n", errno);
   90|      0|    }
   91|      1|}
fuzz_import.c:unlink_cb:
   78|      5|{
   79|      5|    if (typeflag == FTW_F){
  ------------------
  |  Branch (79:9): [True: 4, False: 1]
  ------------------
   80|      4|        unlink(fpath);
   81|      4|    }
   82|      5|    return 0;
   83|      5|}
fuzz_import.c:gpg_deinit_default_ctrl:
   62|     53|{
   63|       |#ifdef USE_TOFU
   64|       |    tofu_closedbs (ctrl);
   65|       |#endif
   66|     53|    gpg_dirmngr_deinit_session_data (ctrl);
   67|       |
   68|     53|    keydb_release (ctrl->cached_getkey_kdb);
   69|     53|}

assuan-socket-connect.c:_assuan_error:
  237|     11|{
  238|     11|  return gpg_err_make (ctx?ctx->err_source: GPG_ERR_SOURCE_ASSUAN, errcode);
  ------------------
  |  Branch (238:24): [True: 11, False: 0]
  ------------------
  239|     11|}

_assuan_log_handler:
  128|    110|{
  129|    110|  FILE *fp;
  130|    110|  const char *prf;
  131|    110|  int saved_errno = errno;
  132|       |
  133|       |  /* For now.  */
  134|    110|  if (msg == NULL)
  ------------------
  |  Branch (134:7): [True: 110, False: 0]
  ------------------
  135|    110|    return TEST_LOG_CAT (cat);
  ------------------
  |  |   55|    110|#define TEST_LOG_CAT(x) (!! (log_cats & (1 << (x - 1))))
  ------------------
  136|       |
  137|      0|  if (! TEST_LOG_CAT (cat))
  ------------------
  |  |   55|      0|#define TEST_LOG_CAT(x) (!! (log_cats & (1 << (x - 1))))
  ------------------
  |  Branch (137:7): [True: 0, False: 0]
  ------------------
  138|      0|    return 0;
  139|       |
  140|      0|  fp = ctx->log_fp ? ctx->log_fp : _assuan_log;
  ------------------
  |  Branch (140:8): [True: 0, False: 0]
  ------------------
  141|      0|  if (!fp)
  ------------------
  |  Branch (141:7): [True: 0, False: 0]
  ------------------
  142|      0|    return 0;
  143|       |
  144|      0|  prf = assuan_get_assuan_log_prefix ();
  145|      0|  if (*prf)
  ------------------
  |  Branch (145:7): [True: 0, False: 0]
  ------------------
  146|      0|    fprintf (fp, "%s[%u]: ", prf, (unsigned int)getpid ());
  147|       |
  148|      0|  fprintf (fp, "%s", msg);
  149|       |  /* If the log stream is a file, the output would be buffered.  This
  150|       |     is bad for debugging, thus we flush the stream if FORMAT ends
  151|       |     with a LF.  */
  152|      0|  if (msg && *msg && msg[strlen (msg) - 1] == '\n')
  ------------------
  |  Branch (152:7): [True: 0, False: 0]
  |  Branch (152:14): [True: 0, False: 0]
  |  Branch (152:22): [True: 0, False: 0]
  ------------------
  153|      0|    fflush (fp);
  154|      0|  gpg_err_set_errno (saved_errno);
  155|       |
  156|      0|  return 0;
  157|      0|}

assuan_socket_connect:
  221|     11|{
  222|     11|  gpg_error_t err = 0;
  223|     11|  assuan_fd_t fd;
  224|     11|#ifdef WITH_IPV6
  225|     11|  struct sockaddr_in6 srvr_addr_in6;
  226|     11|#endif
  227|     11|  struct sockaddr_un srvr_addr_un;
  228|     11|  struct sockaddr_in srvr_addr_in;
  229|     11|  struct sockaddr *srvr_addr = NULL;
  230|     11|  uint16_t port = 0;
  231|     11|  size_t len = 0;
  232|     11|  const char *s;
  233|     11|  int af = AF_LOCAL;
  234|     11|  int pf = PF_LOCAL;
  235|       |
  236|     11|  TRACE2 (ctx, ASSUAN_LOG_CTX, "assuan_socket_connect", ctx,
  ------------------
  |  |  152|     11|  _assuan_debug (ctx, lvl, "%s (%s=%p): call: " fmt "\n",		\
  |  |  153|     22|		 name, STRINGIFY (tag), (void *) (uintptr_t) tag, arg1, \
  |  |  ------------------
  |  |  |  |   35|     11|#define STRINGIFY(v) #v
  |  |  ------------------
  |  |  |  Branch (153:53): [True: 11, False: 0]
  |  |  ------------------
  |  |  154|     11|		 arg2)
  ------------------
  237|     11|	  "name=%s, flags=0x%x", name ? name : "(null)", flags);
  238|       |
  239|     11|  if (!ctx || !name)
  ------------------
  |  Branch (239:7): [True: 0, False: 11]
  |  Branch (239:15): [True: 0, False: 11]
  ------------------
  240|      0|    return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
  241|       |
  242|     11|  if (!strncmp (name, "file://", 7) && name[7])
  ------------------
  |  Branch (242:7): [True: 0, False: 11]
  |  Branch (242:40): [True: 0, False: 0]
  ------------------
  243|      0|    name += 7;
  244|     11|  else if (!strncmp (name, "assuan://", 9) && name[9])
  ------------------
  |  Branch (244:12): [True: 0, False: 11]
  |  Branch (244:47): [True: 0, False: 0]
  ------------------
  245|      0|    {
  246|      0|      name += 9;
  247|      0|      af = AF_INET;
  248|      0|      pf = PF_INET;
  249|      0|    }
  250|     11|  else /* Default.  */
  251|     11|    {
  252|       |      /* We require that the name starts with a slash if no URL
  253|       |         schemata is used.  To make things easier we allow an optional
  254|       |         drive prefix.  */
  255|     11|      s = name;
  256|     11|      if (*s && s[1] == ':')
  ------------------
  |  Branch (256:11): [True: 11, False: 0]
  |  Branch (256:17): [True: 0, False: 11]
  ------------------
  257|      0|        s += 2;
  258|     11|      if (*s != DIRSEP_C && *s != '/')
  ------------------
  |  |   51|     22|#define DIRSEP_C '/'
  ------------------
  |  Branch (258:11): [True: 0, False: 11]
  |  Branch (258:29): [True: 0, False: 0]
  ------------------
  259|      0|        return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE);
  260|     11|    }
  261|       |
  262|     11|  if (af == AF_LOCAL)
  ------------------
  |  Branch (262:7): [True: 11, False: 0]
  ------------------
  263|     11|    {
  264|     11|      int redirected;
  265|       |
  266|     11|      if (_assuan_sock_set_sockaddr_un (name, (struct sockaddr *)&srvr_addr_un,
  ------------------
  |  Branch (266:11): [True: 0, False: 11]
  ------------------
  267|     11|                                        &redirected))
  268|      0|        return _assuan_error (ctx, gpg_err_code_from_syserror ());
  269|       |
  270|     11|      len = SUN_LEN (&srvr_addr_un);
  271|     11|      srvr_addr = (struct sockaddr *)&srvr_addr_un;
  272|     11|    }
  273|      0|  else
  274|      0|    {
  275|      0|      char *addrstr, *p;
  276|      0|#ifdef HAVE_INET_PTON
  277|      0|      void *addrbuf = NULL;
  278|      0|#endif
  279|       |
  280|      0|      addrstr = _assuan_malloc (ctx, strlen (name) + 1);
  281|      0|      if (!addrstr)
  ------------------
  |  Branch (281:11): [True: 0, False: 0]
  ------------------
  282|      0|        return _assuan_error (ctx, gpg_err_code_from_syserror ());
  283|       |
  284|      0|      if (*name == '[')
  ------------------
  |  Branch (284:11): [True: 0, False: 0]
  ------------------
  285|      0|        {
  286|      0|          strcpy (addrstr, name+1);
  287|      0|          p = strchr (addrstr, ']');
  288|      0|          if (!p || p[1] != ':' || !parse_portno (p+2, &port))
  ------------------
  |  Branch (288:15): [True: 0, False: 0]
  |  Branch (288:21): [True: 0, False: 0]
  |  Branch (288:36): [True: 0, False: 0]
  ------------------
  289|      0|            err = _assuan_error (ctx, GPG_ERR_BAD_URI);
  290|      0|          else
  291|      0|            {
  292|      0|              *p = 0;
  293|      0|#ifdef WITH_IPV6
  294|      0|              af = AF_INET6;
  295|      0|              pf = PF_INET6;
  296|      0|              memset (&srvr_addr_in6, 0, sizeof srvr_addr_in6);
  297|      0|              srvr_addr_in6.sin6_family = af;
  298|      0|              srvr_addr_in6.sin6_port = htons (port);
  299|      0|#ifdef HAVE_INET_PTON
  300|      0|              addrbuf = &srvr_addr_in6.sin6_addr;
  301|      0|#endif
  302|      0|              srvr_addr = (struct sockaddr *)&srvr_addr_in6;
  303|      0|              len = sizeof srvr_addr_in6;
  304|       |#else
  305|       |              err =  _assuan_error (ctx, GPG_ERR_EAFNOSUPPORT);
  306|       |#endif
  307|      0|            }
  308|      0|        }
  309|      0|      else
  310|      0|        {
  311|      0|          strcpy (addrstr, name);
  312|      0|          p = strchr (addrstr, ':');
  313|      0|          if (!p || !parse_portno (p+1, &port))
  ------------------
  |  Branch (313:15): [True: 0, False: 0]
  |  Branch (313:21): [True: 0, False: 0]
  ------------------
  314|      0|            err = _assuan_error (ctx, GPG_ERR_BAD_URI);
  315|      0|          else
  316|      0|            {
  317|      0|              *p = 0;
  318|      0|              memset (&srvr_addr_in, 0, sizeof srvr_addr_in);
  319|      0|              srvr_addr_in.sin_family = af;
  320|      0|              srvr_addr_in.sin_port = htons (port);
  321|      0|#ifdef HAVE_INET_PTON
  322|      0|              addrbuf = &srvr_addr_in.sin_addr;
  323|      0|#endif
  324|      0|              srvr_addr = (struct sockaddr *)&srvr_addr_in;
  325|      0|              len = sizeof srvr_addr_in;
  326|      0|            }
  327|      0|        }
  328|       |
  329|      0|      if (!err)
  ------------------
  |  Branch (329:11): [True: 0, False: 0]
  ------------------
  330|      0|        {
  331|      0|#ifdef HAVE_INET_PTON
  332|      0|          switch (inet_pton (af, addrstr, addrbuf))
  333|      0|            {
  334|      0|            case 1:  break;
  ------------------
  |  Branch (334:13): [True: 0, False: 0]
  ------------------
  335|      0|            case 0:  err = _assuan_error (ctx, GPG_ERR_BAD_URI); break;
  ------------------
  |  Branch (335:13): [True: 0, False: 0]
  ------------------
  336|      0|            default: err = _assuan_error (ctx, gpg_err_code_from_syserror ());
  ------------------
  |  Branch (336:13): [True: 0, False: 0]
  ------------------
  337|      0|            }
  338|       |#else /*!HAVE_INET_PTON*/
  339|       |          /* We need to use the old function.  If we are here v6
  340|       |             support isn't enabled anyway and thus we can do fine
  341|       |             without.  Note that Windows as a compatible inet_pton
  342|       |             function named inetPton, but only since Vista.  */
  343|       |          srvr_addr_in.sin_addr.s_addr = inet_addr (addrstr);
  344|       |          if (srvr_addr_in.sin_addr.s_addr == INADDR_NONE)
  345|       |            err = _assuan_error (ctx, GPG_ERR_BAD_URI);
  346|       |#endif /*!HAVE_INET_PTON*/
  347|      0|        }
  348|       |
  349|      0|      _assuan_free (ctx, addrstr);
  350|      0|      if (err)
  ------------------
  |  Branch (350:11): [True: 0, False: 0]
  ------------------
  351|      0|        return err;
  352|      0|    }
  353|       |
  354|     11|  fd = _assuan_sock_new (ctx, pf, SOCK_STREAM, 0);
  355|     11|  if (fd == ASSUAN_INVALID_FD)
  ------------------
  |  |   86|     11|#define ASSUAN_INVALID_FD  (-1)
  ------------------
  |  Branch (355:7): [True: 0, False: 11]
  ------------------
  356|      0|    {
  357|      0|      err = _assuan_error (ctx, gpg_err_code_from_syserror ());
  358|      0|      TRACE1 (ctx, ASSUAN_LOG_SYSIO, "assuan_socket_connect", ctx,
  ------------------
  |  |  149|      0|  _assuan_debug (ctx, lvl, "%s (%s=%p): call: " fmt "\n",		\
  |  |  150|      0|		 name, STRINGIFY (tag), (void *) (uintptr_t) tag, arg1)
  |  |  ------------------
  |  |  |  |   35|      0|#define STRINGIFY(v) #v
  |  |  ------------------
  ------------------
  359|      0|              "can't create socket: %s", strerror (errno));
  360|      0|      return err;
  361|      0|    }
  362|       |
  363|     11|  if (_assuan_sock_connect (ctx, fd, srvr_addr, len) == -1)
  ------------------
  |  Branch (363:7): [True: 11, False: 0]
  ------------------
  364|     11|    {
  365|     11|      TRACE2 (ctx, ASSUAN_LOG_SYSIO, "assuan_socket_connect", ctx,
  ------------------
  |  |  152|     11|  _assuan_debug (ctx, lvl, "%s (%s=%p): call: " fmt "\n",		\
  |  |  153|     11|		 name, STRINGIFY (tag), (void *) (uintptr_t) tag, arg1, \
  |  |  ------------------
  |  |  |  |   35|     11|#define STRINGIFY(v) #v
  |  |  ------------------
  |  |  154|     11|		 arg2)
  ------------------
  366|     11|	      "can't connect to `%s': %s\n", name, strerror (errno));
  367|     11|      _assuan_close (ctx, fd);
  368|     11|      return _assuan_error (ctx, GPG_ERR_ASS_CONNECT_FAILED);
  369|     11|    }
  370|       |
  371|      0|  err = _assuan_connect_finalize (ctx, fd, flags);
  372|       |
  373|      0|  if (err)
  ------------------
  |  Branch (373:7): [True: 0, False: 0]
  ------------------
  374|      0|    _assuan_reset (ctx);
  375|       |
  376|      0|  return err;
  377|     11|}

_assuan_sock_new:
  527|     11|{
  528|       |#ifdef HAVE_W32_SYSTEM
  529|       |  assuan_fd_t res;
  530|       |  if (domain == AF_UNIX || domain == AF_LOCAL)
  531|       |    domain = AF_INET;
  532|       |  res = _assuan_socket (ctx, domain, type, proto);
  533|       |  return res;
  534|       |#else
  535|     11|  return _assuan_socket (ctx, domain, type, proto);
  536|     11|#endif
  537|     11|}
_assuan_sock_connect:
 1011|     11|{
 1012|       |#ifdef HAVE_W32_SYSTEM
 1013|       |  if (addr->sa_family == AF_LOCAL || addr->sa_family == AF_UNIX)
 1014|       |    {
 1015|       |      struct sockaddr_in myaddr;
 1016|       |      struct sockaddr_un *unaddr;
 1017|       |      unsigned short port;
 1018|       |      char nonce[16];
 1019|       |      int cygwin;
 1020|       |      int ret;
 1021|       |
 1022|       |      unaddr = (struct sockaddr_un *)addr;
 1023|       |      if (read_port_and_nonce (unaddr->sun_path, &port, nonce, &cygwin))
 1024|       |        return -1;
 1025|       |
 1026|       |      myaddr.sin_family = AF_INET;
 1027|       |      myaddr.sin_port = htons (port);
 1028|       |      myaddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
 1029|       |
 1030|       |      /* Set return values.  */
 1031|       |      unaddr->sun_family = myaddr.sin_family;
 1032|       |      unaddr->sun_port = myaddr.sin_port;
 1033|       |      unaddr->sun_addr.s_addr = myaddr.sin_addr.s_addr;
 1034|       |
 1035|       |      ret = _assuan_connect (ctx, sockfd,
 1036|       |			    (struct sockaddr *)&myaddr, sizeof myaddr);
 1037|       |      if (!ret)
 1038|       |        {
 1039|       |          /* Send the nonce. */
 1040|       |          ret = do_writen (ctx, sockfd, nonce, 16);
 1041|       |          if (!ret && cygwin)
 1042|       |            {
 1043|       |              char buffer[16];
 1044|       |
 1045|       |              /* The client sends the nonce back - not useful.  We do
 1046|       |                 a dummy read.  */
 1047|       |              ret = do_readn (ctx, sockfd, buffer, 16);
 1048|       |              if (!ret)
 1049|       |                {
 1050|       |                  /* Send our credentials.  */
 1051|       |                  int n = getpid ();
 1052|       |                  memcpy (buffer, &n, 4);
 1053|       |                  memset (buffer+4, 0, 4); /* uid = gid = 0 */
 1054|       |                  ret = do_writen (ctx, sockfd, buffer, 8);
 1055|       |                  if (!ret)
 1056|       |                    {
 1057|       |                      /* Receive credentials.  We don't need them.  */
 1058|       |                      ret = do_readn (ctx, sockfd, buffer, 8);
 1059|       |                    }
 1060|       |                }
 1061|       |            }
 1062|       |        }
 1063|       |      return ret;
 1064|       |    }
 1065|       |  else if (use_socks (addr))
 1066|       |    {
 1067|       |      return socks5_connect (ctx, sockfd, tor_mode,
 1068|       |                             NULL, NULL, 0, addr, addrlen);
 1069|       |    }
 1070|       |  else
 1071|       |    {
 1072|       |      return _assuan_connect (ctx, sockfd, addr, addrlen);
 1073|       |    }
 1074|       |#else
 1075|     11|# if HAVE_STAT
 1076|     11|  if (addr->sa_family == AF_LOCAL || addr->sa_family == AF_UNIX)
  ------------------
  |  Branch (1076:7): [True: 11, False: 0]
  |  Branch (1076:38): [True: 0, False: 0]
  ------------------
 1077|     11|    {
 1078|     11|      struct sockaddr_un *unaddr;
 1079|     11|      struct stat statbuf;
 1080|     11|      int redirect, res;
 1081|       |
 1082|     11|      unaddr = (struct sockaddr_un *)addr;
 1083|     11|      if (!stat (unaddr->sun_path, &statbuf)
  ------------------
  |  Branch (1083:11): [True: 0, False: 11]
  ------------------
 1084|     11|          && !S_ISSOCK (statbuf.st_mode)
  ------------------
  |  Branch (1084:14): [True: 0, False: 0]
  ------------------
 1085|     11|          && S_ISREG (statbuf.st_mode))
 1086|      0|        {
 1087|       |          /* The given socket file is not a socket but a regular file.
 1088|       |             We use the content of that file to redirect to another
 1089|       |             socket file.  This can be used to use sockets on file
 1090|       |             systems which do not support sockets or if for example a
 1091|       |             home directory is shared by several machines.  */
 1092|      0|          unaddr = eval_redirection (unaddr->sun_path, &redirect);
 1093|      0|          if (unaddr)
  ------------------
  |  Branch (1093:15): [True: 0, False: 0]
  ------------------
 1094|      0|            {
 1095|      0|              res = _assuan_connect (ctx, sockfd, (struct sockaddr *)unaddr,
 1096|      0|                                     SUN_LEN (unaddr));
 1097|      0|              free (unaddr);
 1098|      0|              return res;
 1099|      0|            }
 1100|      0|          if (redirect)
  ------------------
  |  Branch (1100:15): [True: 0, False: 0]
  ------------------
 1101|      0|            return -1;
 1102|       |          /* Continue using the standard connect.  */
 1103|      0|        }
 1104|       |
 1105|     11|    }
 1106|     11|# endif /*HAVE_STAT*/
 1107|       |
 1108|     11|  if (use_socks (addr))
  ------------------
  |  Branch (1108:7): [True: 0, False: 11]
  ------------------
 1109|      0|    {
 1110|      0|      return socks5_connect (ctx, sockfd, tor_mode,
 1111|      0|                             NULL, NULL, 0, addr, addrlen);
 1112|      0|    }
 1113|     11|  else
 1114|     11|    {
 1115|     11|      return _assuan_connect (ctx, sockfd, addr, addrlen);
 1116|     11|    }
 1117|     11|#endif
 1118|     11|}
_assuan_sock_set_sockaddr_un:
 1278|     11|{
 1279|     11|  struct sockaddr_un *unaddr = (struct sockaddr_un *)addr;
 1280|     11|#if !defined(HAVE_W32_SYSTEM) && defined(HAVE_STAT)
 1281|     11|  struct stat statbuf;
 1282|     11|#endif
 1283|       |
 1284|     11|  if (r_redirected)
  ------------------
  |  Branch (1284:7): [True: 11, False: 0]
  ------------------
 1285|     11|    *r_redirected = 0;
 1286|       |
 1287|     11|#if !defined(HAVE_W32_SYSTEM) && defined(HAVE_STAT)
 1288|     11|  if (r_redirected
  ------------------
  |  Branch (1288:7): [True: 11, False: 0]
  ------------------
 1289|     11|      && !stat (fname, &statbuf)
  ------------------
  |  Branch (1289:10): [True: 0, False: 11]
  ------------------
 1290|     11|      && !S_ISSOCK (statbuf.st_mode)
  ------------------
  |  Branch (1290:10): [True: 0, False: 0]
  ------------------
 1291|     11|      && S_ISREG (statbuf.st_mode))
 1292|      0|    {
 1293|       |      /* The given socket file is not a socket but a regular file.  We
 1294|       |         use the content of that file to redirect to another socket
 1295|       |         file.  This can be used to use sockets on file systems which
 1296|       |         do not support sockets or if for example a home directory is
 1297|       |         shared by several machines.  */
 1298|      0|      struct sockaddr_un *unaddr_new;
 1299|      0|      int redirect;
 1300|       |
 1301|      0|      unaddr_new = eval_redirection (fname, &redirect);
 1302|      0|      if (unaddr_new)
  ------------------
  |  Branch (1302:11): [True: 0, False: 0]
  ------------------
 1303|      0|        {
 1304|      0|          memcpy (unaddr, unaddr_new, sizeof *unaddr);
 1305|      0|          free (unaddr_new);
 1306|      0|          *r_redirected = 1;
 1307|      0|          return 0;
 1308|      0|        }
 1309|      0|      if (redirect)
  ------------------
  |  Branch (1309:11): [True: 0, False: 0]
  ------------------
 1310|      0|        {
 1311|      0|          *r_redirected = 1;
 1312|      0|          return -1;  /* Error.  */
 1313|      0|        }
 1314|       |      /* Fallback to standard setup.  */
 1315|      0|    }
 1316|     11|#endif /*!HAVE_W32_SYSTEM && HAVE_STAT*/
 1317|       |
 1318|     11|  if (strlen (fname)+1 >= sizeof unaddr->sun_path)
  ------------------
  |  Branch (1318:7): [True: 0, False: 11]
  ------------------
 1319|      0|    {
 1320|      0|      gpg_err_set_errno (ENAMETOOLONG);
 1321|      0|      return -1;
 1322|      0|    }
 1323|       |
 1324|     11|  memset (unaddr, 0, sizeof *unaddr);
 1325|     11|  unaddr->sun_family = AF_LOCAL;
 1326|     11|  strncpy (unaddr->sun_path, fname, sizeof unaddr->sun_path - 1);
 1327|     11|  unaddr->sun_path[sizeof unaddr->sun_path - 1] = 0;
 1328|       |
 1329|     11|  return 0;
 1330|     11|}
assuan-socket.c:use_socks:
  953|     11|{
  954|     11|  union {
  955|     11|    struct sockaddr *addr;
  956|     11|    struct sockaddr_in *addr_in;
  957|     11|    struct sockaddr_in6 *addr_in6;
  958|     11|  } addru;
  959|       |
  960|     11|  addru.addr = addr;
  961|       |
  962|     11|  if (!tor_mode)
  ------------------
  |  Branch (962:7): [True: 11, False: 0]
  ------------------
  963|     11|    return 0;
  964|      0|  else if (addr->sa_family == AF_INET6)
  ------------------
  |  Branch (964:12): [True: 0, False: 0]
  ------------------
  965|      0|    {
  966|      0|      const unsigned char *s;
  967|      0|      int i;
  968|       |
  969|      0|      s = (unsigned char *)&addru.addr_in6->sin6_addr.s6_addr;
  970|      0|      if (s[15] != 1)
  ------------------
  |  Branch (970:11): [True: 0, False: 0]
  ------------------
  971|      0|        return 1;   /* Last octet is not 1 - not the loopback address.  */
  972|      0|      for (i=0; i < 15; i++, s++)
  ------------------
  |  Branch (972:17): [True: 0, False: 0]
  ------------------
  973|      0|        if (*s)
  ------------------
  |  Branch (973:13): [True: 0, False: 0]
  ------------------
  974|      0|          return 1; /* Non-zero octet found - not the loopback address.  */
  975|       |
  976|      0|      return 0; /* This is the loopback address.  */
  977|      0|    }
  978|      0|  else if (addr->sa_family == AF_INET)
  ------------------
  |  Branch (978:12): [True: 0, False: 0]
  ------------------
  979|      0|    {
  980|      0|      if (*(unsigned char*)&addru.addr_in->sin_addr.s_addr == 127)
  ------------------
  |  Branch (980:11): [True: 0, False: 0]
  ------------------
  981|      0|        return 0; /* Loopback (127.0.0.0/8) */
  982|       |
  983|      0|      return 1;
  984|      0|    }
  985|      0|  else
  986|      0|    return 0;
  987|     11|}

_assuan_pre_syscall:
  120|     22|{
  121|     22|  if (pre_syscall_func)
  ------------------
  |  Branch (121:7): [True: 0, False: 22]
  ------------------
  122|      0|    pre_syscall_func ();
  123|     22|}
_assuan_post_syscall:
  129|     22|{
  130|     22|  if (post_syscall_func)
  ------------------
  |  Branch (130:7): [True: 0, False: 22]
  ------------------
  131|      0|    post_syscall_func ();
  132|     22|}
assuan_new_ext:
  140|     11|{
  141|     11|  struct assuan_context_s wctx;
  142|     11|  assuan_context_t ctx;
  143|       |
  144|     11|  if (!_assuan_syscall_func_initialized)
  ------------------
  |  Branch (144:7): [True: 1, False: 10]
  ------------------
  145|      1|    {
  146|      1|      gpgrt_get_syscall_clamp (&pre_syscall_func, &post_syscall_func);
  147|      1|      _assuan_syscall_func_initialized = 1;
  148|      1|    }
  149|       |
  150|       |  /* Set up a working context so we can use standard functions.  */
  151|     11|  memset (&wctx, 0, sizeof (wctx));
  152|     11|  wctx.err_source = err_source;
  153|     11|  wctx.malloc_hooks = *malloc_hooks;
  154|     11|  wctx.log_cb = log_cb;
  155|     11|  wctx.log_cb_data = log_cb_data;
  156|       |
  157|       |  /* Need a new block for the trace macros to work.  */
  158|     11|  {
  159|     11|    TRACE_BEG8 (&wctx, ASSUAN_LOG_CTX, "assuan_new_ext", r_ctx,
  ------------------
  |  |  135|     11|  _TRACE (ctx, lvl, name, tag);						\
  |  |  ------------------
  |  |  |  |   84|     11|  assuan_context_t _assuan_trace_context = ctx;				\
  |  |  |  |   85|     11|  int _assuan_trace_level = lvl;					\
  |  |  |  |   86|     11|  const char *const _assuan_trace_func = name;				\
  |  |  |  |   87|     11|  const char *const _assuan_trace_tagname = STRINGIFY (tag);		\
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|     11|#define STRINGIFY(v) #v
  |  |  |  |  ------------------
  |  |  |  |   88|     11|  void *_assuan_trace_tag = (void *) (uintptr_t) tag
  |  |  ------------------
  |  |  136|     11|  _assuan_debug (_assuan_trace_context, _assuan_trace_level,            \
  |  |  137|     11|                 "%s (%s=%p): enter: " fmt "\n",                        \
  |  |  138|     11|		 _assuan_trace_func, _assuan_trace_tagname,		\
  |  |  139|     11|		 _assuan_trace_tag, arg1, arg2, arg3, arg4,		\
  |  |  140|     11|		 arg5, arg6, arg7, arg8)
  ------------------
  160|     11|		"err_source = %i (%s), malloc_hooks = %p (%p, %p, %p), "
  161|     11|		"log_cb = %p, log_cb_data = %p", err_source,
  162|     11|		gpg_strsource (err_source), malloc_hooks, malloc_hooks->malloc,
  163|     11|		malloc_hooks->realloc, malloc_hooks->free, log_cb, log_cb_data);
  164|       |
  165|     11|    *r_ctx = NULL;
  166|     11|    ctx = _assuan_malloc (&wctx, sizeof (*ctx));
  167|     11|    if (!ctx)
  ------------------
  |  Branch (167:9): [True: 0, False: 11]
  ------------------
  168|      0|      return TRACE_ERR (gpg_err_code_from_syserror ());
  ------------------
  |  |  169|      0|  err == 0 ? (TRACE_SUC ()) :						\
  |  |  ------------------
  |  |  |  |  190|      0|  _assuan_debug (_assuan_trace_context, _assuan_trace_level,	 \
  |  |  |  |  191|      0|		 "%s (%s=%p): leave\n",				 \
  |  |  |  |  192|      0|		_assuan_trace_func, _assuan_trace_tagname,	 \
  |  |  |  |  193|      0|		_assuan_trace_tag), 0
  |  |  ------------------
  |  |  |  Branch (169:3): [True: 0, False: 0]
  |  |  ------------------
  |  |  170|      0|    (_assuan_debug (_assuan_trace_context, _assuan_trace_level,		\
  |  |  171|      0|		    "%s (%s=%p): error: %s <%s>\n",			\
  |  |  172|      0|		    _assuan_trace_func, _assuan_trace_tagname,		\
  |  |  173|      0|		    _assuan_trace_tag, gpg_strerror (err),		\
  |  |  174|      0|		    ctx?gpg_strsource (ctx->err_source):""),            \
  |  |  ------------------
  |  |  |  Branch (174:7): [True: 0, False: 0]
  |  |  ------------------
  |  |  175|      0|     _assuan_error (ctx, err))
  ------------------
  169|       |
  170|     11|    memcpy (ctx, &wctx, sizeof (*ctx));
  171|     11|    ctx->system = _assuan_system_hooks;
  172|       |
  173|       |    /* FIXME: Delegate to subsystems/engines, as the FDs are not our
  174|       |       responsibility (we don't deallocate them, for example).  */
  175|     11|    ctx->input_fd = ASSUAN_INVALID_FD;
  ------------------
  |  |   86|     11|#define ASSUAN_INVALID_FD  (-1)
  ------------------
  176|     11|    ctx->output_fd = ASSUAN_INVALID_FD;
  ------------------
  |  |   86|     11|#define ASSUAN_INVALID_FD  (-1)
  ------------------
  177|     11|    ctx->inbound.fd = ASSUAN_INVALID_FD;
  ------------------
  |  |   86|     11|#define ASSUAN_INVALID_FD  (-1)
  ------------------
  178|     11|    ctx->outbound.fd = ASSUAN_INVALID_FD;
  ------------------
  |  |   86|     11|#define ASSUAN_INVALID_FD  (-1)
  ------------------
  179|     11|    ctx->listen_fd = ASSUAN_INVALID_FD;
  ------------------
  |  |   86|     11|#define ASSUAN_INVALID_FD  (-1)
  ------------------
  180|       |
  181|     11|    *r_ctx = ctx;
  182|       |
  183|     11|    return TRACE_SUC1 ("ctx=%p", ctx);
  ------------------
  |  |  200|     11|  _assuan_debug (_assuan_trace_context, _assuan_trace_level,		\
  |  |  201|     11|		 "%s (%s=%p): leave: " fmt "\n",			\
  |  |  202|     11|		 _assuan_trace_func, _assuan_trace_tagname,		\
  |  |  203|     11|		 _assuan_trace_tag, arg1), 0
  ------------------
  184|     11|  }
  185|     11|}
assuan_new:
  191|     11|{
  192|     11|  return assuan_new_ext (r_ctx, _assuan_default_err_source,
  193|     11|			 &_assuan_default_malloc_hooks,
  194|     11|			 _assuan_default_log_cb,
  195|     11|			 _assuan_default_log_cb_data);
  196|     11|}
_assuan_reset:
  202|     11|{
  203|     11|  if (ctx->engine.release)
  ------------------
  |  Branch (203:7): [True: 0, False: 11]
  ------------------
  204|      0|    {
  205|      0|      (*ctx->engine.release) (ctx);
  206|      0|      ctx->engine.release = NULL;
  207|      0|    }
  208|       |
  209|       |  /* FIXME: Clean standard commands */
  210|     11|}
assuan_release:
  216|     11|{
  217|     11|  if (! ctx)
  ------------------
  |  Branch (217:7): [True: 0, False: 11]
  ------------------
  218|      0|    return;
  219|       |
  220|     11|  TRACE (ctx, ASSUAN_LOG_CTX, "assuan_release", ctx);
  ------------------
  |  |  143|     11|  _assuan_debug (ctx, lvl, "%s (%s=%p): call\n",			\
  |  |  144|     11|		 name, STRINGIFY (tag), (void *) (uintptr_t) tag)
  |  |  ------------------
  |  |  |  |   35|     11|#define STRINGIFY(v) #v
  |  |  ------------------
  ------------------
  221|       |
  222|     11|  _assuan_reset (ctx);
  223|       |  /* None of the members that are our responsibility requires
  224|       |     deallocation.  To avoid sensitive data in the line buffers we
  225|       |     wipe them out, though.  Note that we can't wipe the entire
  226|       |     context because it also has a pointer to the actual free().  */
  227|     11|  wipememory (&ctx->inbound, sizeof ctx->inbound);
  ------------------
  |  |  410|     11|#define wipememory(_ptr,_len) wipememory2(_ptr,0,_len)
  |  |  ------------------
  |  |  |  |  405|     11|#define wipememory2(_ptr,_set,_len) do { \
  |  |  |  |  406|     11|              volatile char *_vptr=(volatile char *)(_ptr); \
  |  |  |  |  407|     11|              size_t _vlen=(_len); \
  |  |  |  |  408|  22.3k|              while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (408:21): [True: 22.3k, False: 11]
  |  |  |  |  ------------------
  |  |  |  |  409|     11|                  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (409:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  228|     11|  wipememory (&ctx->outbound, sizeof ctx->outbound);
  ------------------
  |  |  410|     11|#define wipememory(_ptr,_len) wipememory2(_ptr,0,_len)
  |  |  ------------------
  |  |  |  |  405|     11|#define wipememory2(_ptr,_set,_len) do { \
  |  |  |  |  406|     11|              volatile char *_vptr=(volatile char *)(_ptr); \
  |  |  |  |  407|     11|              size_t _vlen=(_len); \
  |  |  |  |  408|  11.3k|              while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (408:21): [True: 11.3k, False: 11]
  |  |  |  |  ------------------
  |  |  |  |  409|     11|                  } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (409:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  229|     11|  _assuan_free (ctx, ctx);
  230|     11|}

_assuan_debug:
   48|    110|{
   49|    110|  va_list arg_ptr;
   50|    110|  int saved_errno;
   51|    110|  char *msg;
   52|    110|  int res;
   53|       |
   54|       |  /* vasprintf is an expensive operation thus we first check whether
   55|       |     the callback has enabled CAT for logging.  */
   56|    110|  if (!ctx
  ------------------
  |  Branch (56:7): [True: 0, False: 110]
  ------------------
   57|    110|      || !ctx->log_cb
  ------------------
  |  Branch (57:10): [True: 0, False: 110]
  ------------------
   58|    110|      || !(*ctx->log_cb) (ctx, ctx->log_cb_data, cat, NULL))
  ------------------
  |  Branch (58:10): [True: 110, False: 0]
  ------------------
   59|    110|    return;
   60|       |
   61|      0|  saved_errno = errno;
   62|      0|  va_start (arg_ptr, format);
   63|      0|  res = gpgrt_vasprintf (&msg, format, arg_ptr);
   64|      0|  va_end (arg_ptr);
   65|      0|  if (res < 0)
  ------------------
  |  Branch (65:7): [True: 0, False: 0]
  ------------------
   66|      0|    return;
   67|      0|  ctx->log_cb (ctx, ctx->log_cb_data, cat, msg);
   68|      0|  gpgrt_free (msg);
   69|      0|  gpg_err_set_errno (saved_errno);
   70|      0|}

__assuan_close:
  103|     11|{
  104|     11|  return close (fd);
  105|     11|}
__assuan_socket:
  421|     11|{
  422|     11|  return socket (namespace, style, protocol);
  423|     11|}
__assuan_connect:
  429|     11|{
  430|     11|  return connect (sock, addr, length);
  431|     11|}

_assuan_malloc:
   49|     11|{
   50|     11|  return ctx->malloc_hooks.malloc (cnt);
   51|     11|}
_assuan_free:
   82|     11|{
   83|     11|  if (ptr)
  ------------------
  |  Branch (83:7): [True: 11, False: 0]
  ------------------
   84|     11|    ctx->malloc_hooks.free (ptr);
   85|     11|}
_assuan_close:
  181|     11|{
  182|     11|  TRACE1 (ctx, ASSUAN_LOG_SYSIO, "_assuan_close", ctx,
  ------------------
  |  |  149|     11|  _assuan_debug (ctx, lvl, "%s (%s=%p): call: " fmt "\n",		\
  |  |  150|     11|		 name, STRINGIFY (tag), (void *) (uintptr_t) tag, arg1)
  |  |  ------------------
  |  |  |  |   35|     11|#define STRINGIFY(v) #v
  |  |  ------------------
  ------------------
  183|     11|	  "fd=0x%x", fd);
  184|       |
  185|     11|  if (ctx->system.version)
  ------------------
  |  Branch (185:7): [True: 0, False: 11]
  ------------------
  186|      0|    return (ctx->system.close) (ctx, fd);
  187|     11|  else
  188|     11|    {
  189|     11|      int res;
  190|     11|      _assuan_pre_syscall ();
  191|     11|      res = __assuan_close (ctx, fd);
  192|     11|      _assuan_post_syscall ();
  193|     11|      return res;
  194|     11|    }
  195|     11|}
_assuan_socket:
  505|     11|{
  506|     11|  assuan_fd_t res;
  507|     11|  TRACE_BEG3 (ctx, ASSUAN_LOG_SYSIO, "_assuan_socket", ctx,
  ------------------
  |  |  115|     11|  _TRACE (ctx, lvl, name, tag);					      \
  |  |  ------------------
  |  |  |  |   84|     11|  assuan_context_t _assuan_trace_context = ctx;				\
  |  |  |  |   85|     11|  int _assuan_trace_level = lvl;					\
  |  |  |  |   86|     11|  const char *const _assuan_trace_func = name;				\
  |  |  |  |   87|     11|  const char *const _assuan_trace_tagname = STRINGIFY (tag);		\
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|     11|#define STRINGIFY(v) #v
  |  |  |  |  ------------------
  |  |  |  |   88|     11|  void *_assuan_trace_tag = (void *) (uintptr_t) tag
  |  |  ------------------
  |  |  116|     11|  _assuan_debug (_assuan_trace_context, _assuan_trace_level,	      \
  |  |  117|     11|		 "%s (%s=%p): enter: " fmt "\n",		      \
  |  |  118|     11|		 _assuan_trace_func, _assuan_trace_tagname,	      \
  |  |  119|     11|		 _assuan_trace_tag, arg1, arg2, arg3)
  ------------------
  508|     11|	      "namespace=%i,style=%i,protocol=%i",
  509|     11|	      namespace, style, protocol);
  510|       |
  511|     11|  if (ctx->system.version)
  ------------------
  |  Branch (511:7): [True: 0, False: 11]
  ------------------
  512|      0|    res = (ctx->system.socket) (ctx, namespace, style, protocol);
  513|     11|  else
  514|     11|    res = __assuan_socket (ctx, namespace, style, protocol);
  515|     11|  return TRACE_SYSRES (res);
  ------------------
  |  |  179|     11|  res >= 0 ? ((void) (TRACE_SUC1 ("result=%i", res)), (res)) :		\
  |  |  ------------------
  |  |  |  |  200|     11|  _assuan_debug (_assuan_trace_context, _assuan_trace_level,		\
  |  |  |  |  201|     11|		 "%s (%s=%p): leave: " fmt "\n",			\
  |  |  |  |  202|     11|		 _assuan_trace_func, _assuan_trace_tagname,		\
  |  |  |  |  203|     11|		 _assuan_trace_tag, arg1), 0
  |  |  ------------------
  |  |  |  Branch (179:3): [True: 11, False: 0]
  |  |  ------------------
  |  |  180|     11|    (_assuan_debug (_assuan_trace_context, _assuan_trace_level, "%s (%s=%p): error: %s\n", \
  |  |  181|      0|		    _assuan_trace_func, _assuan_trace_tagname,		\
  |  |  182|      0|		   _assuan_trace_tag, strerror (errno)), (res))
  ------------------
  516|     11|}
_assuan_connect:
  522|     11|{
  523|     11|  int res;
  524|     11|  TRACE_BEG3 (ctx, ASSUAN_LOG_SYSIO, "_assuan_connect", ctx,
  ------------------
  |  |  115|     11|  _TRACE (ctx, lvl, name, tag);					      \
  |  |  ------------------
  |  |  |  |   84|     11|  assuan_context_t _assuan_trace_context = ctx;				\
  |  |  |  |   85|     11|  int _assuan_trace_level = lvl;					\
  |  |  |  |   86|     11|  const char *const _assuan_trace_func = name;				\
  |  |  |  |   87|     11|  const char *const _assuan_trace_tagname = STRINGIFY (tag);		\
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|     11|#define STRINGIFY(v) #v
  |  |  |  |  ------------------
  |  |  |  |   88|     11|  void *_assuan_trace_tag = (void *) (uintptr_t) tag
  |  |  ------------------
  |  |  116|     11|  _assuan_debug (_assuan_trace_context, _assuan_trace_level,	      \
  |  |  117|     11|		 "%s (%s=%p): enter: " fmt "\n",		      \
  |  |  118|     11|		 _assuan_trace_func, _assuan_trace_tagname,	      \
  |  |  119|     11|		 _assuan_trace_tag, arg1, arg2, arg3)
  ------------------
  525|     11|	      "socket=%i,addr=%p,length=%i", sock, addr, length);
  526|       |
  527|     11|  if (ctx->system.version)
  ------------------
  |  Branch (527:7): [True: 0, False: 11]
  ------------------
  528|      0|    res = (ctx->system.connect) (ctx, sock, addr, length);
  529|     11|  else
  530|     11|    {
  531|     11|      _assuan_pre_syscall ();
  532|     11|      res = __assuan_connect (ctx, sock, addr, length);
  533|     11|      _assuan_post_syscall ();
  534|     11|    }
  535|     11|  return TRACE_SYSRES (res);
  ------------------
  |  |  179|     11|  res >= 0 ? ((void) (TRACE_SUC1 ("result=%i", res)), (res)) :		\
  |  |  ------------------
  |  |  |  |  200|      0|  _assuan_debug (_assuan_trace_context, _assuan_trace_level,		\
  |  |  |  |  201|      0|		 "%s (%s=%p): leave: " fmt "\n",			\
  |  |  |  |  202|      0|		 _assuan_trace_func, _assuan_trace_tagname,		\
  |  |  |  |  203|      0|		 _assuan_trace_tag, arg1), 0
  |  |  ------------------
  |  |  |  Branch (179:3): [True: 0, False: 11]
  |  |  ------------------
  |  |  180|     11|    (_assuan_debug (_assuan_trace_context, _assuan_trace_level, "%s (%s=%p): error: %s\n", \
  |  |  181|     11|		    _assuan_trace_func, _assuan_trace_tagname,		\
  |  |  182|     11|		   _assuan_trace_tag, strerror (errno)), (res))
  ------------------
  536|     11|}

sha1.c:_gcry_ctz:
   84|  1.01k|{
   85|  1.01k|#if defined (HAVE_BUILTIN_CTZ)
   86|  1.01k|  return x ? __builtin_ctz (x) : 8 * sizeof (x);
  ------------------
  |  Branch (86:10): [True: 1.01k, False: 0]
  ------------------
   87|       |#else
   88|       |  /* See
   89|       |   * http://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightModLookup
   90|       |   */
   91|       |  static const unsigned char mod37[] =
   92|       |    {
   93|       |      sizeof (unsigned int)*8,
   94|       |          0,  1, 26,  2, 23, 27,  0,  3, 16, 24, 30, 28, 11,  0, 13,
   95|       |      4,  7, 17,  0, 25, 22, 31, 15, 29, 10, 12,  6,  0, 21, 14,  9,
   96|       |      5, 20,  8, 19, 18
   97|       |    };
   98|       |  return (int)mod37[(-x & x) % 37];
   99|       |#endif
  100|  1.01k|}
sha256.c:_gcry_ctz:
   84|     64|{
   85|     64|#if defined (HAVE_BUILTIN_CTZ)
   86|     64|  return x ? __builtin_ctz (x) : 8 * sizeof (x);
  ------------------
  |  Branch (86:10): [True: 64, False: 0]
  ------------------
   87|       |#else
   88|       |  /* See
   89|       |   * http://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightModLookup
   90|       |   */
   91|       |  static const unsigned char mod37[] =
   92|       |    {
   93|       |      sizeof (unsigned int)*8,
   94|       |          0,  1, 26,  2, 23, 27,  0,  3, 16, 24, 30, 28, 11,  0, 13,
   95|       |      4,  7, 17,  0, 25, 22, 31, 15, 29, 10, 12,  6,  0, 21, 14,  9,
   96|       |      5, 20,  8, 19, 18
   97|       |    };
   98|       |  return (int)mod37[(-x & x) % 37];
   99|       |#endif
  100|     64|}
sha512.c:_gcry_ctz:
   84|    127|{
   85|    127|#if defined (HAVE_BUILTIN_CTZ)
   86|    127|  return x ? __builtin_ctz (x) : 8 * sizeof (x);
  ------------------
  |  Branch (86:10): [True: 127, False: 0]
  ------------------
   87|       |#else
   88|       |  /* See
   89|       |   * http://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightModLookup
   90|       |   */
   91|       |  static const unsigned char mod37[] =
   92|       |    {
   93|       |      sizeof (unsigned int)*8,
   94|       |          0,  1, 26,  2, 23, 27,  0,  3, 16, 24, 30, 28, 11,  0, 13,
   95|       |      4,  7, 17,  0, 25, 22, 31, 15, 29, 10, 12,  6,  0, 21, 14,  9,
   96|       |      5, 20,  8, 19, 18
   97|       |    };
   98|       |  return (int)mod37[(-x & x) % 37];
   99|       |#endif
  100|    127|}

sha1.c:buf_put_be32:
  141|  7.13k|{
  142|  7.13k|  bufhelp_u32_t *out = _buf;
  143|  7.13k|  out->a = be_bswap32(val);
  ------------------
  |  |   73|  7.13k|# define be_bswap32(x) _gcry_bswap32(x)
  |  |  ------------------
  |  |  |  |   46|  7.13k|# define _gcry_bswap32 __builtin_bswap32
  |  |  ------------------
  ------------------
  144|  7.13k|}
sha256.c:buf_put_be32:
  141|    640|{
  142|    640|  bufhelp_u32_t *out = _buf;
  143|    640|  out->a = be_bswap32(val);
  ------------------
  |  |   73|    640|# define be_bswap32(x) _gcry_bswap32(x)
  |  |  ------------------
  |  |  |  |   46|    640|# define _gcry_bswap32 __builtin_bswap32
  |  |  ------------------
  ------------------
  144|    640|}
sha512.c:buf_put_be64:
  171|  1.27k|{
  172|  1.27k|  bufhelp_u64_t *out = _buf;
  173|  1.27k|  out->a = be_bswap64(val);
  ------------------
  |  |   75|  1.27k|# define be_bswap64(x) _gcry_bswap64(x)
  |  |  ------------------
  |  |  |  |   56|  1.27k|# define _gcry_bswap64 __builtin_bswap64
  |  |  ------------------
  ------------------
  174|  1.27k|}
crc.c:buf_put_le32:
  147|  1.48k|{
  148|  1.48k|  bufhelp_u32_t *out = _buf;
  149|  1.48k|  out->a = le_bswap32(val);
  ------------------
  |  |   72|  1.48k|# define le_bswap32(x) ((u32)(x))
  ------------------
  150|  1.48k|}
hash-common.c:buf_cpy:
  203|  3.10k|{
  204|  3.10k|  byte *dst = _dst;
  205|  3.10k|  const byte *src = _src;
  206|       |
  207|  3.10k|#if __GNUC__ >= 4
  208|  3.10k|  if (!__builtin_constant_p (len))
  ------------------
  |  Branch (208:7): [True: 3.10k, False: 0]
  ------------------
  209|  3.10k|    {
  210|  3.10k|      if (UNLIKELY(len == 0))
  ------------------
  |  |   86|  3.10k|#define UNLIKELY(expr)    __builtin_expect( !!(expr), 0 )
  |  |  ------------------
  |  |  |  Branch (86:27): [True: 0, False: 3.10k]
  |  |  ------------------
  ------------------
  211|      0|	return;
  212|  3.10k|      memcpy(_dst, _src, len);
  213|  3.10k|      return;
  214|  3.10k|    }
  215|      0|#endif
  216|       |
  217|      0|  while (len >= sizeof(u64))
  ------------------
  |  Branch (217:10): [True: 0, False: 0]
  ------------------
  218|      0|    {
  219|      0|      buf_put_he64(dst, buf_get_he64(src));
  ------------------
  |  |  195|      0|# define buf_put_he64 buf_put_le64
  ------------------
                    buf_put_he64(dst, buf_get_he64(src));
  ------------------
  |  |  194|      0|# define buf_get_he64 buf_get_le64
  ------------------
  220|      0|      dst += sizeof(u64);
  221|      0|      src += sizeof(u64);
  222|      0|      len -= sizeof(u64);
  223|      0|    }
  224|       |
  225|      0|  if (len >= sizeof(u32))
  ------------------
  |  Branch (225:7): [True: 0, False: 0]
  ------------------
  226|      0|    {
  227|      0|      buf_put_he32(dst, buf_get_he32(src));
  ------------------
  |  |  193|      0|# define buf_put_he32 buf_put_le32
  ------------------
                    buf_put_he32(dst, buf_get_he32(src));
  ------------------
  |  |  192|      0|# define buf_get_he32 buf_get_le32
  ------------------
  228|      0|      dst += sizeof(u32);
  229|      0|      src += sizeof(u32);
  230|      0|      len -= sizeof(u32);
  231|      0|    }
  232|       |
  233|       |  /* Handle tail.  */
  234|      0|  for (; len; len--)
  ------------------
  |  Branch (234:10): [True: 0, False: 0]
  ------------------
  235|      0|    *dst++ = *src++;
  236|      0|}

_gcry_cipher_init:
 1984|      1|{
 1985|      1|  return 0;
 1986|      1|}

crc.c:crc32_read:
  485|     44|{
  486|     44|  CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
  487|     44|  return ctx->buf;
  488|     44|}
crc.c:crc24rfc2440_init:
  840|  1.55k|{
  841|  1.55k|  CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
  842|  1.55k|  u32 hwf = _gcry_get_hw_features ();
  843|       |
  844|  1.55k|#ifdef USE_INTEL_PCLMUL
  845|  1.55k|  ctx->use_pclmul = (hwf & HWF_INTEL_SSE4_1) && (hwf & HWF_INTEL_PCLMUL);
  ------------------
  |  |  230|  1.55k|#define HWF_INTEL_SSE4_1        (1 << 8)
  ------------------
                ctx->use_pclmul = (hwf & HWF_INTEL_SSE4_1) && (hwf & HWF_INTEL_PCLMUL);
  ------------------
  |  |  231|  1.55k|#define HWF_INTEL_PCLMUL        (1 << 9)
  ------------------
  |  Branch (845:21): [True: 1.55k, False: 0]
  |  Branch (845:49): [True: 1.55k, False: 0]
  ------------------
  846|  1.55k|#endif
  847|       |#ifdef USE_ARM_PMULL
  848|       |  ctx->use_pmull = (hwf & HWF_ARM_NEON) && (hwf & HWF_ARM_PMULL);
  849|       |#endif
  850|       |#ifdef USE_PPC_VPMSUM
  851|       |  ctx->use_vpmsum = !!(hwf & HWF_PPC_ARCH_2_07);
  852|       |#endif
  853|       |
  854|  1.55k|  (void)hwf;
  855|  1.55k|  (void)flags;
  856|       |
  857|  1.55k|  ctx->CRC = crc24_init();
  858|  1.55k|}
crc.c:crc24_init:
  807|  1.55k|{
  808|       |  /* Transformed to 32-bit CRC by multiplied by x⁸ and then byte swapped. */
  809|  1.55k|  return 0xce04b7; /* _gcry_bswap(0xb704ce << 8) */
  810|  1.55k|}
crc.c:crc24rfc2440_write:
  862|  1.00k|{
  863|  1.00k|  const unsigned char *inbuf = inbuf_arg;
  864|  1.00k|  CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
  865|  1.00k|  u32 crc;
  866|       |
  867|  1.00k|#ifdef USE_INTEL_PCLMUL
  868|  1.00k|  if (ctx->use_pclmul)
  ------------------
  |  Branch (868:7): [True: 1.00k, False: 0]
  ------------------
  869|  1.00k|    {
  870|  1.00k|      _gcry_crc24rfc2440_intel_pclmul(&ctx->CRC, inbuf, inlen);
  871|  1.00k|      return;
  872|  1.00k|    }
  873|      0|#endif
  874|       |#ifdef USE_ARM_PMULL
  875|       |  if (ctx->use_pmull)
  876|       |    {
  877|       |      _gcry_crc24rfc2440_armv8_ce_pmull(&ctx->CRC, inbuf, inlen);
  878|       |      return;
  879|       |    }
  880|       |#endif
  881|       |#ifdef USE_PPC_VPMSUM
  882|       |  if (ctx->use_vpmsum)
  883|       |    {
  884|       |      _gcry_crc24rfc2440_ppc8_vpmsum(&ctx->CRC, inbuf, inlen);
  885|       |      return;
  886|       |    }
  887|       |#endif
  888|       |
  889|      0|  if (!inbuf || !inlen)
  ------------------
  |  Branch (889:7): [True: 0, False: 0]
  |  Branch (889:17): [True: 0, False: 0]
  ------------------
  890|      0|    return;
  891|       |
  892|      0|  crc = ctx->CRC;
  893|       |
  894|      0|  while (inlen >= 16)
  ------------------
  |  Branch (894:10): [True: 0, False: 0]
  ------------------
  895|      0|    {
  896|      0|      inlen -= 16;
  897|      0|      crc = crc24_next4(crc, buf_get_le32(&inbuf[0]));
  898|      0|      crc = crc24_next4(crc, buf_get_le32(&inbuf[4]));
  899|      0|      crc = crc24_next4(crc, buf_get_le32(&inbuf[8]));
  900|      0|      crc = crc24_next4(crc, buf_get_le32(&inbuf[12]));
  901|      0|      inbuf += 16;
  902|      0|    }
  903|       |
  904|      0|  while (inlen >= 4)
  ------------------
  |  Branch (904:10): [True: 0, False: 0]
  ------------------
  905|      0|    {
  906|      0|      inlen -= 4;
  907|      0|      crc = crc24_next4(crc, buf_get_le32(inbuf));
  908|      0|      inbuf += 4;
  909|      0|    }
  910|       |
  911|      0|  while (inlen--)
  ------------------
  |  Branch (911:10): [True: 0, False: 0]
  ------------------
  912|      0|    {
  913|      0|      crc = crc24_next(crc, *inbuf++);
  914|      0|    }
  915|       |
  916|      0|  ctx->CRC = crc;
  917|      0|}
crc.c:crc24rfc2440_final:
  921|  1.48k|{
  922|  1.48k|  CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
  923|  1.48k|  ctx->CRC = crc24_final(ctx->CRC);
  924|  1.48k|  buf_put_le32 (ctx->buf, ctx->CRC);
  925|  1.48k|}
crc.c:crc24_final:
  834|  1.48k|{
  835|  1.48k|  return crc & 0xffffff;
  836|  1.48k|}

_gcry_dsa_normalize_hash:
  452|     16|{
  453|     16|  gpg_err_code_t rc = 0;
  454|     16|  const void *abuf;
  455|     16|  unsigned int abits;
  456|     16|  gcry_mpi_t hash;
  457|       |
  458|     16|  if (mpi_is_opaque (input))
  ------------------
  |  |  114|     16|#define mpi_is_opaque(a)      ((a) && ((a)->flags&4))
  |  |  ------------------
  |  |  |  Branch (114:32): [True: 16, False: 0]
  |  |  |  Branch (114:39): [True: 0, False: 16]
  |  |  ------------------
  ------------------
  459|      0|    {
  460|      0|      abuf = mpi_get_opaque (input, &abits);
  ------------------
  |  |  562|      0|#define mpi_get_opaque(a,b)    _gcry_mpi_get_opaque ((a), (b))
  ------------------
  461|      0|      rc = _gcry_mpi_scan (&hash, GCRYMPI_FMT_USG, abuf, (abits+7)/8, NULL);
  462|      0|      if (rc)
  ------------------
  |  Branch (462:11): [True: 0, False: 0]
  ------------------
  463|      0|        return rc;
  464|      0|      if (abits > qbits)
  ------------------
  |  Branch (464:11): [True: 0, False: 0]
  ------------------
  465|      0|        mpi_rshift (hash, hash, abits - qbits);
  ------------------
  |  |  558|      0|#define mpi_rshift(a,b,c)      _gcry_mpi_rshift ((a),(b),(c))
  ------------------
  466|      0|    }
  467|     16|  else
  468|     16|    hash = input;
  469|       |
  470|     16|  *out = hash;
  471|       |
  472|     16|  return rc;
  473|     16|}

_gcry_ecc_fill_in_curve:
  621|     32|{
  622|     32|  int idx;
  623|     32|  const char *resname = NULL; /* Set to a found curve name.  */
  624|       |
  625|     32|  if (name)
  ------------------
  |  Branch (625:7): [True: 32, False: 0]
  ------------------
  626|     32|    idx = find_domain_parms_idx (name);
  627|      0|  else
  628|      0|    {
  629|      0|      for (idx = 0; domain_parms[idx].desc; idx++)
  ------------------
  |  Branch (629:21): [True: 0, False: 0]
  ------------------
  630|      0|        if (nbits == domain_parms[idx].nbits
  ------------------
  |  Branch (630:13): [True: 0, False: 0]
  ------------------
  631|      0|            && domain_parms[idx].model == MPI_EC_WEIERSTRASS)
  ------------------
  |  Branch (631:16): [True: 0, False: 0]
  ------------------
  632|      0|          break;
  633|      0|      if (!domain_parms[idx].desc)
  ------------------
  |  Branch (633:11): [True: 0, False: 0]
  ------------------
  634|      0|        idx = -1;
  635|      0|    }
  636|     32|  if (idx < 0)
  ------------------
  |  Branch (636:7): [True: 0, False: 32]
  ------------------
  637|      0|    return GPG_ERR_UNKNOWN_CURVE;
  638|       |
  639|     32|  resname = domain_parms[idx].desc;
  640|       |
  641|       |  /* In fips mode we only support NIST curves.  Note that it is
  642|       |     possible to bypass this check by specifying the curve parameters
  643|       |     directly.  */
  644|     32|  if (fips_mode () && !domain_parms[idx].fips )
  ------------------
  |  |  449|     64|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 32]
  |  |  ------------------
  ------------------
  |  Branch (644:23): [True: 0, False: 0]
  ------------------
  645|      0|    return GPG_ERR_NOT_SUPPORTED;
  646|       |
  647|     32|  switch (domain_parms[idx].model)
  648|     32|    {
  649|     32|    case MPI_EC_WEIERSTRASS:
  ------------------
  |  Branch (649:5): [True: 32, False: 0]
  ------------------
  650|     32|    case MPI_EC_EDWARDS:
  ------------------
  |  Branch (650:5): [True: 0, False: 32]
  ------------------
  651|     32|    case MPI_EC_MONTGOMERY:
  ------------------
  |  Branch (651:5): [True: 0, False: 32]
  ------------------
  652|     32|      break;
  653|      0|    default:
  ------------------
  |  Branch (653:5): [True: 0, False: 32]
  ------------------
  654|      0|      return GPG_ERR_BUG;
  655|     32|    }
  656|       |
  657|       |
  658|     32|  if (r_nbits)
  ------------------
  |  Branch (658:7): [True: 16, False: 16]
  ------------------
  659|     16|    *r_nbits = domain_parms[idx].nbits;
  660|       |
  661|     32|  if (curve)
  ------------------
  |  Branch (661:7): [True: 16, False: 16]
  ------------------
  662|     16|    {
  663|     16|      curve->model = domain_parms[idx].model;
  664|     16|      curve->dialect = domain_parms[idx].dialect;
  665|     16|      if (!curve->p)
  ------------------
  |  Branch (665:11): [True: 16, False: 0]
  ------------------
  666|     16|        curve->p = scanval (domain_parms[idx].p);
  667|     16|      if (!curve->a)
  ------------------
  |  Branch (667:11): [True: 16, False: 0]
  ------------------
  668|     16|        {
  669|     16|          curve->a = scanval (domain_parms[idx].a);
  670|     16|          if (curve->a->sign)
  ------------------
  |  Branch (670:15): [True: 0, False: 16]
  ------------------
  671|      0|            {
  672|      0|              mpi_resize (curve->a, curve->p->nlimbs);
  ------------------
  |  |  100|      0|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  ------------------
  673|      0|              _gcry_mpih_sub_n (curve->a->d, curve->p->d,
  674|      0|                                curve->a->d, curve->p->nlimbs);
  675|      0|              curve->a->nlimbs = curve->p->nlimbs;
  676|      0|              curve->a->sign = 0;
  677|      0|            }
  678|     16|        }
  679|     16|      if (!curve->b)
  ------------------
  |  Branch (679:11): [True: 16, False: 0]
  ------------------
  680|     16|        {
  681|     16|          curve->b = scanval (domain_parms[idx].b);
  682|     16|          if (curve->b->sign)
  ------------------
  |  Branch (682:15): [True: 0, False: 16]
  ------------------
  683|      0|            {
  684|      0|              mpi_resize (curve->b, curve->p->nlimbs);
  ------------------
  |  |  100|      0|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  ------------------
  685|      0|              _gcry_mpih_sub_n (curve->b->d, curve->p->d,
  686|      0|                                curve->b->d, curve->p->nlimbs);
  687|      0|              curve->b->nlimbs = curve->p->nlimbs;
  688|      0|              curve->b->sign = 0;
  689|      0|            }
  690|     16|        }
  691|     16|      if (!curve->n)
  ------------------
  |  Branch (691:11): [True: 16, False: 0]
  ------------------
  692|     16|        curve->n = scanval (domain_parms[idx].n);
  693|     16|      if (!curve->G.x)
  ------------------
  |  Branch (693:11): [True: 16, False: 0]
  ------------------
  694|     16|        curve->G.x = scanval (domain_parms[idx].g_x);
  695|     16|      if (!curve->G.y)
  ------------------
  |  Branch (695:11): [True: 16, False: 0]
  ------------------
  696|     16|        curve->G.y = scanval (domain_parms[idx].g_y);
  697|     16|      curve->h = domain_parms[idx].h;
  698|       |
  699|       |      /*
  700|       |       * In the constants of domain_parms, we defined Curve25519
  701|       |       * domain parameters as the ones in RFC-7748 before the errata
  702|       |       * (eid4730).  To keep the computation having exact same values,
  703|       |       * we recover the new value of g_y, here.
  704|       |       */
  705|     16|      if (!strcmp (resname, "Curve25519"))
  ------------------
  |  Branch (705:11): [True: 0, False: 16]
  ------------------
  706|      0|        mpi_sub (curve->G.y, curve->p, curve->G.y);
  ------------------
  |  |  519|      0|#define mpi_sub(w,u,v)         _gcry_mpi_sub ((w),(u),(v))
  ------------------
  707|       |
  708|     16|      if (!curve->G.z)
  ------------------
  |  Branch (708:11): [True: 16, False: 0]
  ------------------
  709|     16|        curve->G.z = mpi_alloc_set_ui (1);
  ------------------
  |  |  119|     16|#define mpi_alloc_set_ui(a)   _gcry_mpi_alloc_set_ui ((a))
  ------------------
  710|     16|      if (!curve->name)
  ------------------
  |  Branch (710:11): [True: 16, False: 0]
  ------------------
  711|     16|        curve->name = resname;
  712|     16|    }
  713|       |
  714|     32|  return 0;
  715|     32|}
_gcry_ecc_update_curve_param:
  728|      8|{
  729|      8|  int idx;
  730|       |
  731|      8|  idx = find_domain_parms_idx (name);
  732|      8|  if (idx < 0)
  ------------------
  |  Branch (732:7): [True: 0, False: 8]
  ------------------
  733|      0|    return GPG_ERR_UNKNOWN_CURVE;
  734|       |
  735|      8|  if (g)
  ------------------
  |  Branch (735:7): [True: 8, False: 0]
  ------------------
  736|      8|    {
  737|      8|      char *buf;
  738|      8|      size_t len;
  739|       |
  740|      8|      len = 4;
  741|      8|      len += strlen (domain_parms[idx].g_x+2);
  742|      8|      len += strlen (domain_parms[idx].g_y+2);
  743|      8|      len++;
  744|      8|      buf = xtrymalloc (len);
  ------------------
  |  |  138|      8|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  745|      8|      if (!buf)
  ------------------
  |  Branch (745:11): [True: 0, False: 8]
  ------------------
  746|      0|        return gpg_err_code_from_syserror ();
  747|      8|      strcpy (stpcpy (stpcpy (buf, "0x04"), domain_parms[idx].g_x+2),
  748|      8|              domain_parms[idx].g_y+2);
  749|      8|      _gcry_mpi_release (*g);
  750|      8|      *g = scanval (buf);
  751|      8|      xfree (buf);
  ------------------
  |  |  150|      8|#define xfree(a)         _gcry_free ((a))
  ------------------
  752|      8|    }
  753|      8|  if (model)
  ------------------
  |  Branch (753:7): [True: 8, False: 0]
  ------------------
  754|      8|    *model = domain_parms[idx].model;
  755|      8|  if (dialect)
  ------------------
  |  Branch (755:7): [True: 8, False: 0]
  ------------------
  756|      8|    *dialect = domain_parms[idx].dialect;
  757|      8|  if (p)
  ------------------
  |  Branch (757:7): [True: 8, False: 0]
  ------------------
  758|      8|    {
  759|      8|      _gcry_mpi_release (*p);
  760|      8|      *p = scanval (domain_parms[idx].p);
  761|      8|    }
  762|      8|  if (a)
  ------------------
  |  Branch (762:7): [True: 8, False: 0]
  ------------------
  763|      8|    {
  764|      8|      _gcry_mpi_release (*a);
  765|      8|      *a = scanval (domain_parms[idx].a);
  766|      8|    }
  767|      8|  if (b)
  ------------------
  |  Branch (767:7): [True: 8, False: 0]
  ------------------
  768|      8|    {
  769|      8|      _gcry_mpi_release (*b);
  770|      8|      *b = scanval (domain_parms[idx].b);
  771|      8|    }
  772|      8|  if (n)
  ------------------
  |  Branch (772:7): [True: 8, False: 0]
  ------------------
  773|      8|    {
  774|      8|      _gcry_mpi_release (*n);
  775|      8|      *n = scanval (domain_parms[idx].n);
  776|      8|    }
  777|      8|  return 0;
  778|      8|}
_gcry_mpi_ec_internal_new:
 1261|     16|{
 1262|     16|  gpg_err_code_t errc;
 1263|     16|  elliptic_curve_t E;
 1264|     16|  mpi_ec_t ec;
 1265|       |
 1266|     16|  *r_ec = NULL;
 1267|       |
 1268|     16|  memset (&E, 0, sizeof E);
 1269|     16|  errc = mpi_ec_get_elliptic_curve (&E, r_flags, keyparam, curvename);
 1270|     16|  if (errc)
  ------------------
  |  Branch (1270:7): [True: 0, False: 16]
  ------------------
 1271|      0|    goto leave;
 1272|       |
 1273|     16|  ec = _gcry_mpi_ec_p_internal_new (E.model, E.dialect, *r_flags,
 1274|     16|                                    E.p, E.a, E.b);
 1275|     16|  if (!ec)
  ------------------
  |  Branch (1275:7): [True: 0, False: 16]
  ------------------
 1276|      0|    goto leave;
 1277|       |
 1278|     16|  errc = mpi_ec_setup_elliptic_curve (ec, *r_flags, &E, keyparam);
 1279|     16|  if (errc)
  ------------------
  |  Branch (1279:7): [True: 0, False: 16]
  ------------------
 1280|      0|    {
 1281|      0|      _gcry_mpi_ec_free (ec);
 1282|      0|      goto leave;
 1283|      0|    }
 1284|     16|  else
 1285|     16|    *r_ec = ec;
 1286|       |
 1287|     16|  if (!errc && DBG_CIPHER)
  ------------------
  |  |   25|     16|#define DBG_CIPHER _gcry_get_debug_flag( 1 )
  |  |  ------------------
  |  |  |  Branch (25:20): [True: 0, False: 16]
  |  |  ------------------
  ------------------
  |  Branch (1287:7): [True: 16, False: 0]
  ------------------
 1288|      0|    {
 1289|      0|      gcry_mpi_t mpi_q = NULL;
 1290|      0|      gcry_sexp_t l1;
 1291|      0|      char msg[80];
 1292|       |
 1293|      0|      l1 = sexp_find_token (keyparam, "q", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1294|      0|      if (l1)
  ------------------
  |  Branch (1294:11): [True: 0, False: 0]
  ------------------
 1295|      0|        {
 1296|      0|          mpi_q = sexp_nth_mpi (l1, 1, GCRYMPI_FMT_OPAQUE);
  ------------------
  |  |  390|      0|#define sexp_nth_mpi(a, b, c)        _gcry_sexp_nth_mpi ((a), (b), (c))
  ------------------
 1297|      0|          sexp_release (l1);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1298|      0|        }
 1299|       |
 1300|      0|      log_debug ("%s info: %s/%s%s\n", name_op,
  ------------------
  |  |  205|      0|#define log_debug   _gcry_log_debug
  ------------------
 1301|      0|                 _gcry_ecc_model2str (ec->model),
 1302|      0|                 _gcry_ecc_dialect2str (ec->dialect),
 1303|      0|                 (*r_flags & PUBKEY_FLAG_EDDSA)? "+EdDSA" : "");
  ------------------
  |  |   41|      0|#define PUBKEY_FLAG_EDDSA          (1 << 12)
  ------------------
  |  Branch (1303:18): [True: 0, False: 0]
  ------------------
 1304|      0|      if (ec->name)
  ------------------
  |  Branch (1304:11): [True: 0, False: 0]
  ------------------
 1305|      0|        log_debug  ("%s name: %s\n", name_op, ec->name);
  ------------------
  |  |  205|      0|#define log_debug   _gcry_log_debug
  ------------------
 1306|      0|      snprintf (msg, sizeof msg, "%s    p", name_op);
 1307|      0|      log_printmpi (msg, ec->p);
  ------------------
  |  |  208|      0|#define log_printmpi _gcry_log_printmpi
  ------------------
 1308|      0|      snprintf (msg, sizeof msg, "%s    a", name_op);
 1309|      0|      log_printmpi (msg, ec->a);
  ------------------
  |  |  208|      0|#define log_printmpi _gcry_log_printmpi
  ------------------
 1310|      0|      snprintf (msg, sizeof msg, "%s    b", name_op);
 1311|      0|      log_printmpi (msg, ec->b);
  ------------------
  |  |  208|      0|#define log_printmpi _gcry_log_printmpi
  ------------------
 1312|      0|      snprintf (msg, sizeof msg, "%s  g", name_op);
 1313|      0|      log_printpnt (msg, ec->G, NULL);
  ------------------
  |  |  275|      0|#define log_printpnt(a,p,c) _gcry_mpi_point_log ((a), (p), (c))
  ------------------
 1314|      0|      snprintf (msg, sizeof msg, "%s    n", name_op);
 1315|      0|      log_printmpi (msg, ec->n);
  ------------------
  |  |  208|      0|#define log_printmpi _gcry_log_printmpi
  ------------------
 1316|      0|      log_debug ("%s    h:+%02x\n", name_op, ec->h);
  ------------------
  |  |  205|      0|#define log_debug   _gcry_log_debug
  ------------------
 1317|      0|      if (mpi_q)
  ------------------
  |  Branch (1317:11): [True: 0, False: 0]
  ------------------
 1318|      0|        {
 1319|      0|          snprintf (msg, sizeof msg, "%s    q", name_op);
 1320|      0|          log_printmpi (msg, mpi_q);
  ------------------
  |  |  208|      0|#define log_printmpi _gcry_log_printmpi
  ------------------
 1321|      0|          mpi_free (mpi_q);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1322|      0|        }
 1323|      0|      if (!fips_mode () && ec->d)
  ------------------
  |  |  449|      0|#define fips_mode() (!_gcry_no_fips_mode_required)
  ------------------
  |  Branch (1323:11): [True: 0, False: 0]
  |  Branch (1323:28): [True: 0, False: 0]
  ------------------
 1324|      0|        {
 1325|      0|          snprintf (msg, sizeof msg, "%s    d", name_op);
 1326|      0|          log_printmpi (msg, ec->d);
  ------------------
  |  |  208|      0|#define log_printmpi _gcry_log_printmpi
  ------------------
 1327|      0|        }
 1328|      0|    }
 1329|       |
 1330|     16| leave:
 1331|     16|  _gcry_ecc_curve_free (&E);
 1332|     16|  return errc;
 1333|     16|}
ecc-curves.c:find_domain_parms_idx:
  584|     40|{
  585|     40|  int idx, aliasno;
  586|       |
  587|       |  /* First check our native curves.  */
  588|  1.12k|  for (idx = 0; domain_parms[idx].desc; idx++)
  ------------------
  |  Branch (588:17): [True: 1.08k, False: 40]
  ------------------
  589|  1.08k|    if (!strcmp (name, domain_parms[idx].desc))
  ------------------
  |  Branch (589:9): [True: 0, False: 1.08k]
  ------------------
  590|      0|      return idx;
  591|       |
  592|       |  /* If not found consult the alias table.  */
  593|     40|  if (!domain_parms[idx].desc)
  ------------------
  |  Branch (593:7): [True: 40, False: 0]
  ------------------
  594|     40|    {
  595|    600|      for (aliasno = 0; curve_aliases[aliasno].name; aliasno++)
  ------------------
  |  Branch (595:25): [True: 600, False: 0]
  ------------------
  596|    600|        if (!strcmp (name, curve_aliases[aliasno].other))
  ------------------
  |  Branch (596:13): [True: 40, False: 560]
  ------------------
  597|     40|          break;
  598|     40|      if (curve_aliases[aliasno].name)
  ------------------
  |  Branch (598:11): [True: 40, False: 0]
  ------------------
  599|     40|        {
  600|    280|          for (idx = 0; domain_parms[idx].desc; idx++)
  ------------------
  |  Branch (600:25): [True: 280, False: 0]
  ------------------
  601|    280|            if (!strcmp (curve_aliases[aliasno].name, domain_parms[idx].desc))
  ------------------
  |  Branch (601:17): [True: 40, False: 240]
  ------------------
  602|     40|              return idx;
  603|     40|        }
  604|     40|    }
  605|       |
  606|      0|  return -1;
  607|     40|}
ecc-curves.c:scanval:
  569|    136|{
  570|    136|  gpg_err_code_t rc;
  571|    136|  gcry_mpi_t val;
  572|       |
  573|    136|  rc = _gcry_mpi_scan (&val, GCRYMPI_FMT_HEX, string, 0, NULL);
  574|    136|  if (rc)
  ------------------
  |  Branch (574:7): [True: 0, False: 136]
  ------------------
  575|      0|    log_fatal ("scanning ECC parameter failed: %s\n", gpg_strerror (rc));
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
  576|    136|  return val;
  577|    136|}
ecc-curves.c:point_from_keyparam:
  963|     16|{
  964|     16|  gcry_err_code_t rc;
  965|     16|  gcry_sexp_t l1;
  966|     16|  gcry_mpi_point_t point;
  967|       |
  968|     16|  l1 = sexp_find_token (keyparam, name, 0);
  ------------------
  |  |  381|     16|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  969|     16|  if (l1)
  ------------------
  |  Branch (969:7): [True: 16, False: 0]
  ------------------
  970|     16|    {
  971|     16|      gcry_mpi_t a;
  972|       |
  973|     16|      a = sexp_nth_mpi (l1, 1, GCRYMPI_FMT_OPAQUE);
  ------------------
  |  |  390|     16|#define sexp_nth_mpi(a, b, c)        _gcry_sexp_nth_mpi ((a), (b), (c))
  ------------------
  974|     16|      sexp_release (l1);
  ------------------
  |  |  372|     16|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  975|     16|      if (!a)
  ------------------
  |  Branch (975:11): [True: 0, False: 16]
  ------------------
  976|      0|        return GPG_ERR_INV_OBJ;
  977|       |
  978|     16|      point = mpi_point_new (0);
  ------------------
  |  |  532|     16|#define mpi_point_new(n)       _gcry_mpi_point_new((n))
  ------------------
  979|     16|      rc = _gcry_mpi_ec_decode_point (point, a, ec);
  980|     16|      mpi_free (a);
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  981|     16|      if (rc)
  ------------------
  |  Branch (981:11): [True: 0, False: 16]
  ------------------
  982|      0|        {
  983|      0|          mpi_point_release (point);
  ------------------
  |  |  535|      0|  do                                             \
  |  |  536|      0|    {                                            \
  |  |  537|      0|      _gcry_mpi_point_release ((p));             \
  |  |  538|      0|      (p) = NULL;                                \
  |  |  539|      0|    }                                            \
  |  |  540|      0|  while (0)
  |  |  ------------------
  |  |  |  Branch (540:10): [Folded - Ignored]
  |  |  ------------------
  ------------------
  984|      0|          return rc;
  985|      0|        }
  986|     16|    }
  987|      0|  else
  988|      0|    {
  989|      0|      char *tmpname;
  990|      0|      gcry_mpi_t x = NULL;
  991|      0|      gcry_mpi_t y = NULL;
  992|      0|      gcry_mpi_t z = NULL;
  993|       |
  994|      0|      tmpname = xtrymalloc (strlen (name) + 2 + 1);
  ------------------
  |  |  138|      0|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  995|      0|      if (!tmpname)
  ------------------
  |  Branch (995:11): [True: 0, False: 0]
  ------------------
  996|      0|        return gpg_err_code_from_syserror ();
  997|      0|      strcpy (stpcpy (tmpname, name), ".x");
  998|      0|      rc = mpi_from_keyparam (&x, keyparam, tmpname, 0);
  999|      0|      if (rc)
  ------------------
  |  Branch (999:11): [True: 0, False: 0]
  ------------------
 1000|      0|        {
 1001|      0|          xfree (tmpname);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1002|      0|          return rc;
 1003|      0|        }
 1004|      0|      strcpy (stpcpy (tmpname, name), ".y");
 1005|      0|      rc = mpi_from_keyparam (&y, keyparam, tmpname, 0);
 1006|      0|      if (rc)
  ------------------
  |  Branch (1006:11): [True: 0, False: 0]
  ------------------
 1007|      0|        {
 1008|      0|          mpi_free (x);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1009|      0|          xfree (tmpname);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1010|      0|          return rc;
 1011|      0|        }
 1012|      0|      strcpy (stpcpy (tmpname, name), ".z");
 1013|      0|      rc = mpi_from_keyparam (&z, keyparam, tmpname, 0);
 1014|      0|      if (rc)
  ------------------
  |  Branch (1014:11): [True: 0, False: 0]
  ------------------
 1015|      0|        {
 1016|      0|          mpi_free (y);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1017|      0|          mpi_free (x);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1018|      0|          xfree (tmpname);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1019|      0|          return rc;
 1020|      0|        }
 1021|      0|      if (!z)
  ------------------
  |  Branch (1021:11): [True: 0, False: 0]
  ------------------
 1022|      0|        z = mpi_set_ui (NULL, 1);
  ------------------
  |  |  505|      0|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
 1023|      0|      if (x && y)
  ------------------
  |  Branch (1023:11): [True: 0, False: 0]
  |  Branch (1023:16): [True: 0, False: 0]
  ------------------
 1024|      0|        point = mpi_point_snatch_set (NULL, x, y, z);
  ------------------
  |  |  548|      0|#define mpi_point_snatch_set(p,x,y,z) _gcry_mpi_point_snatch_set((p),(x), \
  |  |  549|      0|                                                                 (y),(z))
  ------------------
 1025|      0|      else
 1026|      0|        {
 1027|      0|          mpi_free (x);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1028|      0|          mpi_free (y);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1029|      0|          mpi_free (z);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1030|      0|          point = NULL;
 1031|      0|        }
 1032|      0|      xfree (tmpname);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1033|      0|    }
 1034|       |
 1035|     16|  if (point)
  ------------------
  |  Branch (1035:7): [True: 16, False: 0]
  ------------------
 1036|     16|    *r_a = point;
 1037|     16|  return 0;
 1038|     16|}
ecc-curves.c:mpi_from_keyparam:
  940|     16|{
  941|     16|  gcry_err_code_t ec = 0;
  942|     16|  gcry_sexp_t l1;
  943|       |
  944|     16|  l1 = sexp_find_token (keyparam, name, 0);
  ------------------
  |  |  381|     16|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  945|     16|  if (l1)
  ------------------
  |  Branch (945:7): [True: 0, False: 16]
  ------------------
  946|      0|    {
  947|      0|      *r_a = sexp_nth_mpi (l1, 1, opaque? GCRYMPI_FMT_OPAQUE : GCRYMPI_FMT_USG);
  ------------------
  |  |  390|      0|#define sexp_nth_mpi(a, b, c)        _gcry_sexp_nth_mpi ((a), (b), (c))
  |  |  ------------------
  |  |  |  Branch (390:69): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  948|      0|      sexp_release (l1);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  949|      0|      if (!*r_a)
  ------------------
  |  Branch (949:11): [True: 0, False: 0]
  ------------------
  950|      0|        ec = GPG_ERR_INV_OBJ;
  951|      0|    }
  952|     16|  return ec;
  953|     16|}
ecc-curves.c:mpi_ec_get_elliptic_curve:
 1045|     16|{
 1046|     16|  gpg_err_code_t errc;
 1047|     16|  unsigned int nbits;
 1048|     16|  gcry_sexp_t l1;
 1049|       |
 1050|     16|  errc = _gcry_pk_util_get_nbits (keyparam, &nbits);
 1051|     16|  if (errc)
  ------------------
  |  Branch (1051:7): [True: 0, False: 16]
  ------------------
 1052|      0|    return errc;
 1053|       |
 1054|     16|  E->model = MPI_EC_WEIERSTRASS;
 1055|     16|  E->dialect = ECC_DIALECT_STANDARD;
 1056|     16|  E->h = 1;
 1057|       |
 1058|     16|  if (keyparam)
  ------------------
  |  Branch (1058:7): [True: 16, False: 0]
  ------------------
 1059|     16|    {
 1060|       |      /* Parse an optional flags list.  */
 1061|     16|      l1 = sexp_find_token (keyparam, "flags", 0);
  ------------------
  |  |  381|     16|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1062|     16|      if (l1)
  ------------------
  |  Branch (1062:11): [True: 0, False: 16]
  ------------------
 1063|      0|        {
 1064|      0|          int flags = 0;
 1065|       |
 1066|      0|          errc = _gcry_pk_util_parse_flaglist (l1, &flags, NULL);
 1067|      0|          sexp_release (l1);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1068|      0|          l1 = NULL;
 1069|      0|          if (errc)
  ------------------
  |  Branch (1069:15): [True: 0, False: 0]
  ------------------
 1070|      0|            goto leave;
 1071|       |
 1072|      0|          *r_flags |= flags;
 1073|      0|        }
 1074|       |
 1075|       |      /* Parse the deprecated optional transient-key flag.  */
 1076|     16|      l1 = sexp_find_token (keyparam, "transient-key", 0);
  ------------------
  |  |  381|     16|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1077|     16|      if (l1)
  ------------------
  |  Branch (1077:11): [True: 0, False: 16]
  ------------------
 1078|      0|        {
 1079|      0|          *r_flags |= PUBKEY_FLAG_TRANSIENT_KEY;
  ------------------
  |  |   34|      0|#define PUBKEY_FLAG_TRANSIENT_KEY  (1 << 5)
  ------------------
 1080|      0|          sexp_release (l1);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1081|      0|        }
 1082|       |
 1083|       |      /* Check whether a curve name was given.  */
 1084|     16|      l1 = sexp_find_token (keyparam, "curve", 5);
  ------------------
  |  |  381|     16|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1085|       |
 1086|       |      /* If we don't have a curve name or if override parameters have
 1087|       |         explicitly been requested, parse them.  */
 1088|     16|      if (!l1 || (*r_flags & PUBKEY_FLAG_PARAM))
  ------------------
  |  |   38|     16|#define PUBKEY_FLAG_PARAM          (1 << 9)
  ------------------
  |  Branch (1088:11): [True: 0, False: 16]
  |  Branch (1088:18): [True: 0, False: 16]
  ------------------
 1089|      0|        {
 1090|      0|          gcry_mpi_point_t G = NULL;
 1091|      0|          gcry_mpi_t cofactor = NULL;
 1092|       |
 1093|      0|          errc = mpi_from_keyparam (&E->p, keyparam, "p", 0);
 1094|      0|          if (errc)
  ------------------
  |  Branch (1094:15): [True: 0, False: 0]
  ------------------
 1095|      0|            goto leave;
 1096|      0|          errc = mpi_from_keyparam (&E->a, keyparam, "a", 0);
 1097|      0|          if (errc)
  ------------------
  |  Branch (1097:15): [True: 0, False: 0]
  ------------------
 1098|      0|            goto leave;
 1099|      0|          errc = mpi_from_keyparam (&E->b, keyparam, "b", 0);
 1100|      0|          if (errc)
  ------------------
  |  Branch (1100:15): [True: 0, False: 0]
  ------------------
 1101|      0|            goto leave;
 1102|      0|          errc = point_from_keyparam (&G, keyparam, "g", NULL);
 1103|      0|          if (errc)
  ------------------
  |  Branch (1103:15): [True: 0, False: 0]
  ------------------
 1104|      0|            goto leave;
 1105|      0|          if (G)
  ------------------
  |  Branch (1105:15): [True: 0, False: 0]
  ------------------
 1106|      0|            {
 1107|      0|              _gcry_mpi_point_init (&E->G);
 1108|      0|              mpi_point_set (&E->G, G->x, G->y, G->z);
  ------------------
  |  |  547|      0|#define mpi_point_set(p,x,y,z)        _gcry_mpi_point_set((p),(x),(y),(z))
  ------------------
 1109|      0|              mpi_point_set (G, NULL, NULL, NULL);
  ------------------
  |  |  547|      0|#define mpi_point_set(p,x,y,z)        _gcry_mpi_point_set((p),(x),(y),(z))
  ------------------
 1110|      0|              mpi_point_release (G);
  ------------------
  |  |  535|      0|  do                                             \
  |  |  536|      0|    {                                            \
  |  |  537|      0|      _gcry_mpi_point_release ((p));             \
  |  |  538|      0|      (p) = NULL;                                \
  |  |  539|      0|    }                                            \
  |  |  540|      0|  while (0)
  |  |  ------------------
  |  |  |  Branch (540:10): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1111|      0|            }
 1112|      0|          errc = mpi_from_keyparam (&E->n, keyparam, "n", 0);
 1113|      0|          if (errc)
  ------------------
  |  Branch (1113:15): [True: 0, False: 0]
  ------------------
 1114|      0|            goto leave;
 1115|      0|          errc = mpi_from_keyparam (&cofactor, keyparam, "h", 0);
 1116|      0|          if (errc)
  ------------------
  |  Branch (1116:15): [True: 0, False: 0]
  ------------------
 1117|      0|            goto leave;
 1118|      0|          if (cofactor)
  ------------------
  |  Branch (1118:15): [True: 0, False: 0]
  ------------------
 1119|      0|            {
 1120|      0|              mpi_get_ui (&E->h, cofactor);
  ------------------
  |  |  506|      0|#define mpi_get_ui(w,u)        _gcry_mpi_get_ui( (w), (u) )
  ------------------
 1121|      0|              mpi_free (cofactor);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1122|      0|            }
 1123|      0|        }
 1124|     16|    }
 1125|      0|  else
 1126|      0|    l1 = NULL; /* No curvename.  */
 1127|       |
 1128|       |  /* Check whether a curve parameter is available and use that to fill
 1129|       |     in missing values.  If no curve parameter is available try an
 1130|       |     optional provided curvename.  If only the curvename has been
 1131|       |     given use that one. */
 1132|     16|  if (l1 || curvename || nbits)
  ------------------
  |  Branch (1132:7): [True: 16, False: 0]
  |  Branch (1132:13): [True: 0, False: 0]
  |  Branch (1132:26): [True: 0, False: 0]
  ------------------
 1133|     16|    {
 1134|     16|      char *name;
 1135|       |
 1136|     16|      if (l1)
  ------------------
  |  Branch (1136:11): [True: 16, False: 0]
  ------------------
 1137|     16|        {
 1138|     16|          name = sexp_nth_string (l1, 1);
  ------------------
  |  |  389|     16|#define sexp_nth_string(a, b)        _gcry_sexp_nth_string ((a), (b))
  ------------------
 1139|     16|          sexp_release (l1);
  ------------------
  |  |  372|     16|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1140|     16|          if (!name)
  ------------------
  |  Branch (1140:15): [True: 0, False: 16]
  ------------------
 1141|      0|            {
 1142|      0|              errc = GPG_ERR_INV_OBJ; /* Name missing or out of core. */
 1143|      0|              goto leave;
 1144|      0|            }
 1145|     16|        }
 1146|      0|      else
 1147|      0|        name = NULL;
 1148|       |
 1149|     16|      errc = _gcry_ecc_fill_in_curve (nbits, name? name : curvename, E, NULL);
  ------------------
  |  Branch (1149:46): [True: 16, False: 0]
  ------------------
 1150|     16|      xfree (name);
  ------------------
  |  |  150|     16|#define xfree(a)         _gcry_free ((a))
  ------------------
 1151|     16|      if (errc)
  ------------------
  |  Branch (1151:11): [True: 0, False: 16]
  ------------------
 1152|      0|        goto leave;
 1153|     16|    }
 1154|       |
 1155|     16| leave:
 1156|     16|  return errc;
 1157|     16|}
ecc-curves.c:mpi_ec_setup_elliptic_curve:
 1162|     16|{
 1163|     16|  gpg_err_code_t errc = 0;
 1164|       |
 1165|     16|  ec->G = mpi_point_snatch_set (NULL, E->G.x, E->G.y, E->G.z);
  ------------------
  |  |  548|     16|#define mpi_point_snatch_set(p,x,y,z) _gcry_mpi_point_snatch_set((p),(x), \
  |  |  549|     16|                                                                 (y),(z))
  ------------------
 1166|     16|  E->G.x = NULL;
 1167|     16|  E->G.y = NULL;
 1168|     16|  E->G.z = NULL;
 1169|     16|  ec->n = E->n;
 1170|     16|  E->n = NULL;
 1171|     16|  ec->h = E->h;
 1172|     16|  ec->name = E->name;
 1173|       |
 1174|       |  /* Now that we know the curve name we can look for the public key
 1175|       |     Q.  point_from_keyparam needs to know the curve parameters so
 1176|       |     that it is able to use the correct decompression.  Parsing
 1177|       |     the private key D could have been done earlier but it is less
 1178|       |     surprising if we do it here as well.  */
 1179|     16|  if (keyparam)
  ------------------
  |  Branch (1179:7): [True: 16, False: 0]
  ------------------
 1180|     16|    {
 1181|     16|      int is_opaque_bytes = ((ec->dialect == ECC_DIALECT_ED25519
  ------------------
  |  Branch (1181:31): [True: 0, False: 16]
  ------------------
 1182|     16|                              && (flags & PUBKEY_FLAG_EDDSA))
  ------------------
  |  |   41|      0|#define PUBKEY_FLAG_EDDSA          (1 << 12)
  ------------------
  |  Branch (1182:34): [True: 0, False: 0]
  ------------------
 1183|     16|                             || (ec->dialect == ECC_DIALECT_SAFECURVE));
  ------------------
  |  Branch (1183:33): [True: 0, False: 16]
  ------------------
 1184|       |
 1185|     16|      errc = point_from_keyparam (&ec->Q, keyparam, "q", ec);
 1186|     16|      if (errc)
  ------------------
  |  Branch (1186:11): [True: 0, False: 16]
  ------------------
 1187|      0|        return errc;
 1188|     16|      errc = mpi_from_keyparam (&ec->d, keyparam, "d", is_opaque_bytes);
 1189|       |
 1190|       |      /* Size of opaque bytes should match size of P.  */
 1191|     16|      if (!errc && ec->d && is_opaque_bytes)
  ------------------
  |  Branch (1191:11): [True: 16, False: 0]
  |  Branch (1191:20): [True: 0, False: 16]
  |  Branch (1191:29): [True: 0, False: 0]
  ------------------
 1192|      0|        {
 1193|      0|          unsigned int n = mpi_get_nbits (ec->d);
  ------------------
  |  |  552|      0|#define mpi_get_nbits(a)       _gcry_mpi_get_nbits ((a))
  ------------------
 1194|      0|          unsigned int len;
 1195|       |
 1196|      0|          len = (ec->nbits+7)/8;
 1197|       |          /* EdDSA requires additional bit for sign.  */
 1198|      0|          if ((ec->nbits%8) == 0 && ec->model == MPI_EC_EDWARDS)
  ------------------
  |  Branch (1198:15): [True: 0, False: 0]
  |  Branch (1198:37): [True: 0, False: 0]
  ------------------
 1199|      0|            len++;
 1200|       |
 1201|      0|          if ((n+7)/8 != len)
  ------------------
  |  Branch (1201:15): [True: 0, False: 0]
  ------------------
 1202|      0|            {
 1203|      0|              if (ec->dialect == ECC_DIALECT_ED25519)
  ------------------
  |  Branch (1203:19): [True: 0, False: 0]
  ------------------
 1204|      0|                {
 1205|       |                  /*
 1206|       |                   * GnuPG (<= 2.2) or OpenPGP implementations with no
 1207|       |                   * SOS support may remove zeros at the beginning.
 1208|       |                   * Recover those zeros.
 1209|       |                   */
 1210|       |                  /*
 1211|       |                   * Also, GnuPG (<= 2.2) may add additional zero at
 1212|       |                   * the beginning, when private key is moved from
 1213|       |                   * OpenPGP to gpg-agent.  Remove such a zero-prefix.
 1214|       |                   */
 1215|      0|                  const unsigned char *buf;
 1216|      0|                  unsigned char *value;
 1217|       |
 1218|      0|                  buf = mpi_get_opaque (ec->d, &n);
  ------------------
  |  |  562|      0|#define mpi_get_opaque(a,b)    _gcry_mpi_get_opaque ((a), (b))
  ------------------
 1219|      0|                  if (!buf)
  ------------------
  |  Branch (1219:23): [True: 0, False: 0]
  ------------------
 1220|      0|                    return GPG_ERR_INV_OBJ;
 1221|       |
 1222|      0|                  value = xtrymalloc_secure (len);
  ------------------
  |  |  140|      0|#define xtrymalloc_secure(a)   _gcry_malloc_secure ((a))
  ------------------
 1223|      0|                  if (!value)
  ------------------
  |  Branch (1223:23): [True: 0, False: 0]
  ------------------
 1224|      0|                    return gpg_err_code_from_syserror ();
 1225|       |
 1226|      0|                  if ((n+7)/8 < len)
  ------------------
  |  Branch (1226:23): [True: 0, False: 0]
  ------------------
 1227|       |                    /* Recover zeros.  */
 1228|      0|                    {
 1229|      0|                      memset (value, 0, len - (n+7)/8);
 1230|      0|                      memcpy (value + len - (n+7)/8, buf, (n+7)/8);
 1231|      0|                    }
 1232|      0|                  else if ((n+7)/8 == len + 1)
  ------------------
  |  Branch (1232:28): [True: 0, False: 0]
  ------------------
 1233|       |                    /* Remove a zero.  */
 1234|      0|                    memcpy (value, buf+1, len);
 1235|      0|                  else
 1236|      0|                    {
 1237|      0|                      xfree (value);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1238|      0|                      return GPG_ERR_INV_OBJ;
 1239|      0|                    }
 1240|       |
 1241|      0|                  mpi_set_opaque (ec->d, value, len*8);
  ------------------
  |  |  561|      0|#define mpi_set_opaque(a,b,c)  _gcry_mpi_set_opaque ((a), (b), (c))
  ------------------
 1242|      0|                }
 1243|      0|              else
 1244|      0|                {
 1245|      0|                  if (DBG_CIPHER)
  ------------------
  |  |   25|      0|#define DBG_CIPHER _gcry_get_debug_flag( 1 )
  |  |  ------------------
  |  |  |  Branch (25:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1246|      0|                    log_debug ("scalar size (%d) != prime size (%d)",
  ------------------
  |  |  205|      0|#define log_debug   _gcry_log_debug
  ------------------
 1247|      0|                               (n+7)/8, len);
 1248|       |
 1249|      0|                  errc = GPG_ERR_INV_OBJ;
 1250|      0|                }
 1251|      0|            }
 1252|      0|        }
 1253|     16|    }
 1254|       |
 1255|     16|  return errc;
 1256|     16|}

_gcry_ecc_ecdsa_verify:
  204|     16|{
  205|     16|  gpg_err_code_t err = 0;
  206|     16|  gcry_mpi_t hash, h, h1, h2, x;
  207|     16|  mpi_point_struct Q, Q1, Q2;
  208|     16|  unsigned int nbits;
  209|     16|  gcry_mpi_t hash_computed_internally = NULL;
  210|       |
  211|     16|  if (!_gcry_mpi_ec_curve_point (ec->Q, ec))
  ------------------
  |  Branch (211:7): [True: 0, False: 16]
  ------------------
  212|      0|    return GPG_ERR_BROKEN_PUBKEY;
  213|       |
  214|     16|  if( !(mpi_cmp_ui (r, 0) > 0 && mpi_cmp (r, ec->n) < 0) )
  ------------------
  |  |  512|     16|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
                if( !(mpi_cmp_ui (r, 0) > 0 && mpi_cmp (r, ec->n) < 0) )
  ------------------
  |  |  510|     16|#define mpi_cmp( u, v )        _gcry_mpi_cmp( (u), (v) )
  ------------------
  |  Branch (214:9): [True: 16, False: 0]
  |  Branch (214:34): [True: 16, False: 0]
  ------------------
  215|      0|    return GPG_ERR_BAD_SIGNATURE; /* Assertion	0 < r < n  failed.  */
  216|     16|  if( !(mpi_cmp_ui (s, 0) > 0 && mpi_cmp (s, ec->n) < 0) )
  ------------------
  |  |  512|     16|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
                if( !(mpi_cmp_ui (s, 0) > 0 && mpi_cmp (s, ec->n) < 0) )
  ------------------
  |  |  510|     16|#define mpi_cmp( u, v )        _gcry_mpi_cmp( (u), (v) )
  ------------------
  |  Branch (216:9): [True: 16, False: 0]
  |  Branch (216:34): [True: 16, False: 0]
  ------------------
  217|      0|    return GPG_ERR_BAD_SIGNATURE; /* Assertion	0 < s < n  failed.  */
  218|       |
  219|     16|  nbits = mpi_get_nbits (ec->n);
  ------------------
  |  |  552|     16|#define mpi_get_nbits(a)       _gcry_mpi_get_nbits ((a))
  ------------------
  220|     16|  if ((flags & PUBKEY_FLAG_PREHASH))
  ------------------
  |  |   46|     16|#define PUBKEY_FLAG_PREHASH        (1 << 17)
  ------------------
  |  Branch (220:7): [True: 0, False: 16]
  ------------------
  221|      0|    {
  222|      0|      err = _gcry_dsa_compute_hash (&hash_computed_internally, input,
  223|      0|                                    hashalgo);
  224|      0|      if (err)
  ------------------
  |  Branch (224:11): [True: 0, False: 0]
  ------------------
  225|      0|        return err;
  226|      0|      input = hash_computed_internally;
  227|      0|    }
  228|       |
  229|     16|  err = _gcry_dsa_normalize_hash (input, &hash, nbits);
  230|     16|  if (err)
  ------------------
  |  Branch (230:7): [True: 0, False: 16]
  ------------------
  231|      0|    {
  232|      0|      mpi_free (hash_computed_internally);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  233|      0|      return err;
  234|      0|    }
  235|       |
  236|     16|  h  = mpi_alloc (0);
  ------------------
  |  |   97|     16|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  237|     16|  h1 = mpi_alloc (0);
  ------------------
  |  |   97|     16|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  238|     16|  h2 = mpi_alloc (0);
  ------------------
  |  |   97|     16|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  239|     16|  x = mpi_alloc (0);
  ------------------
  |  |   97|     16|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  240|     16|  point_init (&Q);
  ------------------
  |  |   50|     16|#define point_init(a)  _gcry_mpi_point_init ((a))
  ------------------
  241|     16|  point_init (&Q1);
  ------------------
  |  |   50|     16|#define point_init(a)  _gcry_mpi_point_init ((a))
  ------------------
  242|     16|  point_init (&Q2);
  ------------------
  |  |   50|     16|#define point_init(a)  _gcry_mpi_point_init ((a))
  ------------------
  243|       |
  244|       |  /* h  = s^(-1) (mod n) */
  245|     16|  mpi_invm (h, s, ec->n);
  ------------------
  |  |  530|     16|#define mpi_invm(g,a,b)        _gcry_mpi_invm ( (g), (a), (b) )
  ------------------
  246|       |  /* h1 = hash * s^(-1) (mod n) */
  247|     16|  mpi_mulm (h1, hash, h, ec->n);
  ------------------
  |  |  524|     16|#define mpi_mulm(w,u,v,m)      _gcry_mpi_mulm ((w),(u),(v),(m))
  ------------------
  248|       |  /* Q1 = [ hash * s^(-1) ]G  */
  249|     16|  _gcry_mpi_ec_mul_point (&Q1, h1, ec->G, ec);
  250|       |  /* h2 = r * s^(-1) (mod n) */
  251|     16|  mpi_mulm (h2, r, h, ec->n);
  ------------------
  |  |  524|     16|#define mpi_mulm(w,u,v,m)      _gcry_mpi_mulm ((w),(u),(v),(m))
  ------------------
  252|       |  /* Q2 = [ r * s^(-1) ]Q */
  253|     16|  _gcry_mpi_ec_mul_point (&Q2, h2, ec->Q, ec);
  254|       |  /* Q  = ([hash * s^(-1)]G) + ([r * s^(-1)]Q) */
  255|     16|  _gcry_mpi_ec_add_points (&Q, &Q1, &Q2, ec);
  256|       |
  257|     16|  if (!mpi_cmp_ui (Q.z, 0))
  ------------------
  |  |  512|     16|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
  |  Branch (257:7): [True: 0, False: 16]
  ------------------
  258|      0|    {
  259|      0|      if (DBG_CIPHER)
  ------------------
  |  |   25|      0|#define DBG_CIPHER _gcry_get_debug_flag( 1 )
  |  |  ------------------
  |  |  |  Branch (25:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  260|      0|          log_debug ("ecc verify: Rejected\n");
  ------------------
  |  |  205|      0|#define log_debug   _gcry_log_debug
  ------------------
  261|      0|      err = GPG_ERR_BAD_SIGNATURE;
  262|      0|      goto leave;
  263|      0|    }
  264|     16|  if (_gcry_mpi_ec_get_affine (x, NULL, &Q, ec))
  ------------------
  |  Branch (264:7): [True: 0, False: 16]
  ------------------
  265|      0|    {
  266|      0|      if (DBG_CIPHER)
  ------------------
  |  |   25|      0|#define DBG_CIPHER _gcry_get_debug_flag( 1 )
  |  |  ------------------
  |  |  |  Branch (25:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  267|      0|        log_debug ("ecc verify: Failed to get affine coordinates\n");
  ------------------
  |  |  205|      0|#define log_debug   _gcry_log_debug
  ------------------
  268|      0|      err = GPG_ERR_BAD_SIGNATURE;
  269|      0|      goto leave;
  270|      0|    }
  271|     16|  mpi_mod (x, x, ec->n); /* x = x mod E_n */
  ------------------
  |  |  528|     16|#define mpi_mod(r,a,m)         _gcry_mpi_mod ((r), (a), (m))
  ------------------
  272|     16|  if (mpi_cmp (x, r))   /* x != r */
  ------------------
  |  |  510|     16|#define mpi_cmp( u, v )        _gcry_mpi_cmp( (u), (v) )
  |  |  ------------------
  |  |  |  Branch (510:32): [True: 0, False: 16]
  |  |  ------------------
  ------------------
  273|      0|    {
  274|      0|      if (DBG_CIPHER)
  ------------------
  |  |   25|      0|#define DBG_CIPHER _gcry_get_debug_flag( 1 )
  |  |  ------------------
  |  |  |  Branch (25:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  275|      0|        {
  276|      0|          log_mpidump ("     x", x);
  ------------------
  |  |  212|      0|#define log_mpidump _gcry_log_printmpi
  ------------------
  277|      0|          log_mpidump ("     r", r);
  ------------------
  |  |  212|      0|#define log_mpidump _gcry_log_printmpi
  ------------------
  278|      0|          log_mpidump ("     s", s);
  ------------------
  |  |  212|      0|#define log_mpidump _gcry_log_printmpi
  ------------------
  279|      0|        }
  280|      0|      err = GPG_ERR_BAD_SIGNATURE;
  281|      0|      goto leave;
  282|      0|    }
  283|       |
  284|     16| leave:
  285|     16|  point_free (&Q2);
  ------------------
  |  |   51|     16|#define point_free(a)  _gcry_mpi_point_free_parts ((a))
  ------------------
  286|     16|  point_free (&Q1);
  ------------------
  |  |   51|     16|#define point_free(a)  _gcry_mpi_point_free_parts ((a))
  ------------------
  287|     16|  point_free (&Q);
  ------------------
  |  |   51|     16|#define point_free(a)  _gcry_mpi_point_free_parts ((a))
  ------------------
  288|     16|  mpi_free (x);
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  289|     16|  mpi_free (h2);
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  290|     16|  mpi_free (h1);
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  291|     16|  mpi_free (h);
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  292|     16|  if (hash != input)
  ------------------
  |  Branch (292:7): [True: 0, False: 16]
  ------------------
  293|      0|    mpi_free (hash);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  294|     16|  mpi_free (hash_computed_internally);
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  295|       |
  296|     16|  return err;
  297|     16|}

_gcry_ecc_curve_free:
   40|     16|{
   41|     16|  mpi_free (E->p); E->p = NULL;
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
   42|     16|  mpi_free (E->a); E->a = NULL;
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
   43|     16|  mpi_free (E->b);  E->b = NULL;
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
   44|     16|  _gcry_mpi_point_free_parts (&E->G);
   45|     16|  mpi_free (E->n);  E->n = NULL;
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
   46|     16|}
_gcry_ecc_sec_decodepoint:
  180|     16|{
  181|     16|  gpg_err_code_t rc;
  182|     16|  size_t n;
  183|     16|  const unsigned char *buf;
  184|     16|  unsigned char *buf_memory;
  185|     16|  gcry_mpi_t x, y;
  186|       |
  187|     16|  if (mpi_is_opaque (value))
  ------------------
  |  |  114|     16|#define mpi_is_opaque(a)      ((a) && ((a)->flags&4))
  |  |  ------------------
  |  |  |  Branch (114:32): [True: 16, False: 0]
  |  |  |  Branch (114:39): [True: 16, False: 0]
  |  |  ------------------
  ------------------
  188|     16|    {
  189|     16|      unsigned int nbits;
  190|       |
  191|     16|      buf = mpi_get_opaque (value, &nbits);
  ------------------
  |  |  562|     16|#define mpi_get_opaque(a,b)    _gcry_mpi_get_opaque ((a), (b))
  ------------------
  192|     16|      if (!buf)
  ------------------
  |  Branch (192:11): [True: 0, False: 16]
  ------------------
  193|      0|        return GPG_ERR_INV_OBJ;
  194|     16|      n = (nbits + 7)/8;
  195|     16|      buf_memory = NULL;
  196|     16|    }
  197|      0|  else
  198|      0|    {
  199|      0|      n = (mpi_get_nbits (value)+7)/8;
  ------------------
  |  |  552|      0|#define mpi_get_nbits(a)       _gcry_mpi_get_nbits ((a))
  ------------------
  200|      0|      buf_memory = xmalloc (n);
  ------------------
  |  |  144|      0|#define xmalloc(a)       _gcry_xmalloc ((a))
  ------------------
  201|      0|      rc = _gcry_mpi_print (GCRYMPI_FMT_USG, buf_memory, n, &n, value);
  202|      0|      if (rc)
  ------------------
  |  Branch (202:11): [True: 0, False: 0]
  ------------------
  203|      0|        {
  204|      0|          xfree (buf_memory);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  205|      0|          return rc;
  206|      0|        }
  207|      0|      buf = buf_memory;
  208|      0|    }
  209|       |
  210|     16|  if (n < 1)
  ------------------
  |  Branch (210:7): [True: 0, False: 16]
  ------------------
  211|      0|    {
  212|      0|      xfree (buf_memory);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  213|      0|      return GPG_ERR_INV_OBJ;
  214|      0|    }
  215|       |
  216|     16|  if (*buf == 2 || *buf == 3)
  ------------------
  |  Branch (216:7): [True: 0, False: 16]
  |  Branch (216:20): [True: 0, False: 16]
  ------------------
  217|      0|    {
  218|      0|      gcry_mpi_t x3;
  219|      0|      gcry_mpi_t t;
  220|      0|      gcry_mpi_t p1_4;
  221|      0|      int y_bit = (*buf == 3);
  222|       |
  223|      0|      if (!mpi_test_bit (ec->p, 1))
  ------------------
  |  |  553|      0|#define mpi_test_bit(a,b)      _gcry_mpi_test_bit ((a),(b))
  ------------------
  |  Branch (223:11): [True: 0, False: 0]
  ------------------
  224|      0|        {
  225|      0|          xfree (buf_memory);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  226|      0|          return GPG_ERR_NOT_IMPLEMENTED; /* No support for point compression.  */
  227|      0|        }
  228|       |
  229|      0|      n = n - 1;
  230|      0|      rc = _gcry_mpi_scan (&x, GCRYMPI_FMT_USG, buf+1, n, NULL);
  231|      0|      xfree (buf_memory);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  232|      0|      if (rc)
  ------------------
  |  Branch (232:11): [True: 0, False: 0]
  ------------------
  233|      0|        return rc;
  234|       |
  235|       |      /*
  236|       |       * Recover Y.  The Weierstrass curve: y^2 = x^3 + a*x + b
  237|       |       */
  238|       |
  239|      0|      x3 = mpi_new (0);
  ------------------
  |  |  491|      0|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
  240|      0|      t = mpi_new (0);
  ------------------
  |  |  491|      0|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
  241|      0|      p1_4 = mpi_new (0);
  ------------------
  |  |  491|      0|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
  242|      0|      y = mpi_new (0);
  ------------------
  |  |  491|      0|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
  243|       |
  244|       |      /* Compute right hand side.  */
  245|      0|      mpi_powm (x3, x, mpi_const (MPI_C_THREE), ec->p);
  ------------------
  |  |  525|      0|#define mpi_powm(w,b,e,m)      _gcry_mpi_powm ( (w), (b), (e), (m) )
  ------------------
  246|      0|      mpi_mul (t, ec->a, x);
  ------------------
  |  |  523|      0|#define mpi_mul(w,u,v)         _gcry_mpi_mul ((w),(u),(v))
  ------------------
  247|      0|      mpi_mod (t, t, ec->p);
  ------------------
  |  |  528|      0|#define mpi_mod(r,a,m)         _gcry_mpi_mod ((r), (a), (m))
  ------------------
  248|      0|      mpi_add (t, t, ec->b);
  ------------------
  |  |  516|      0|#define mpi_add(w,u,v)         _gcry_mpi_add ((w),(u),(v))
  ------------------
  249|      0|      mpi_mod (t, t, ec->p);
  ------------------
  |  |  528|      0|#define mpi_mod(r,a,m)         _gcry_mpi_mod ((r), (a), (m))
  ------------------
  250|      0|      mpi_add (t, t, x3);
  ------------------
  |  |  516|      0|#define mpi_add(w,u,v)         _gcry_mpi_add ((w),(u),(v))
  ------------------
  251|      0|      mpi_mod (t, t, ec->p);
  ------------------
  |  |  528|      0|#define mpi_mod(r,a,m)         _gcry_mpi_mod ((r), (a), (m))
  ------------------
  252|       |
  253|       |      /*
  254|       |       * When p mod 4 = 3, modular square root of A can be computed by
  255|       |       * A^((p+1)/4) mod p
  256|       |       */
  257|       |
  258|       |      /* Compute (p+1)/4 into p1_4 */
  259|      0|      mpi_rshift (p1_4, ec->p, 2);
  ------------------
  |  |  558|      0|#define mpi_rshift(a,b,c)      _gcry_mpi_rshift ((a),(b),(c))
  ------------------
  260|      0|      _gcry_mpi_add_ui (p1_4, p1_4, 1);
  261|       |
  262|      0|      mpi_powm (y, t, p1_4, ec->p);
  ------------------
  |  |  525|      0|#define mpi_powm(w,b,e,m)      _gcry_mpi_powm ( (w), (b), (e), (m) )
  ------------------
  263|       |
  264|      0|      if (y_bit != mpi_test_bit (y, 0))
  ------------------
  |  |  553|      0|#define mpi_test_bit(a,b)      _gcry_mpi_test_bit ((a),(b))
  ------------------
  |  Branch (264:11): [True: 0, False: 0]
  ------------------
  265|      0|        mpi_sub (y, ec->p, y);
  ------------------
  |  |  519|      0|#define mpi_sub(w,u,v)         _gcry_mpi_sub ((w),(u),(v))
  ------------------
  266|       |
  267|      0|      mpi_free (p1_4);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  268|      0|      mpi_free (t);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  269|      0|      mpi_free (x3);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  270|      0|    }
  271|     16|  else if (*buf == 4)
  ------------------
  |  Branch (271:12): [True: 16, False: 0]
  ------------------
  272|     16|    {
  273|     16|      if ( ((n-1)%2) )
  ------------------
  |  Branch (273:12): [True: 0, False: 16]
  ------------------
  274|      0|        {
  275|      0|          xfree (buf_memory);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  276|      0|          return GPG_ERR_INV_OBJ;
  277|      0|        }
  278|     16|      n = (n-1)/2;
  279|     16|      rc = _gcry_mpi_scan (&x, GCRYMPI_FMT_USG, buf+1, n, NULL);
  280|     16|      if (rc)
  ------------------
  |  Branch (280:11): [True: 0, False: 16]
  ------------------
  281|      0|        {
  282|      0|          xfree (buf_memory);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  283|      0|          return rc;
  284|      0|        }
  285|     16|      rc = _gcry_mpi_scan (&y, GCRYMPI_FMT_USG, buf+1+n, n, NULL);
  286|     16|      xfree (buf_memory);
  ------------------
  |  |  150|     16|#define xfree(a)         _gcry_free ((a))
  ------------------
  287|     16|      if (rc)
  ------------------
  |  Branch (287:11): [True: 0, False: 16]
  ------------------
  288|      0|        {
  289|      0|          mpi_free (x);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  290|      0|          return rc;
  291|      0|        }
  292|     16|    }
  293|      0|  else
  294|      0|    {
  295|      0|      xfree (buf_memory);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  296|      0|      return GPG_ERR_INV_OBJ;
  297|      0|    }
  298|       |
  299|     16|  mpi_set (result->x, x);
  ------------------
  |  |  504|     16|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
  300|     16|  mpi_set (result->y, y);
  ------------------
  |  |  504|     16|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
  301|     16|  mpi_set_ui (result->z, 1);
  ------------------
  |  |  505|     16|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
  302|       |
  303|     16|  mpi_free (x);
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  304|     16|  mpi_free (y);
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  305|       |
  306|     16|  return 0;
  307|     16|}

ecc.c:ecc_verify:
  830|     16|{
  831|     16|  gcry_err_code_t rc;
  832|     16|  struct pk_encoding_ctx ctx;
  833|     16|  gcry_sexp_t l1 = NULL;
  834|     16|  gcry_mpi_t sig_r = NULL;
  835|     16|  gcry_mpi_t sig_s = NULL;
  836|     16|  gcry_mpi_t data = NULL;
  837|     16|  int sigflags;
  838|     16|  mpi_ec_t ec = NULL;
  839|     16|  int flags = 0;
  840|       |
  841|     16|  _gcry_pk_util_init_encoding_ctx (&ctx, PUBKEY_OP_VERIFY,
  842|     16|                                   ecc_get_nbits (s_keyparms));
  843|       |
  844|       |  /*
  845|       |   * Extract the key.
  846|       |   */
  847|     16|  rc = _gcry_mpi_ec_internal_new (&ec, &flags, "ecc_verify",
  848|     16|                                  s_keyparms, NULL);
  849|     16|  if (rc)
  ------------------
  |  Branch (849:7): [True: 0, False: 16]
  ------------------
  850|      0|    goto leave;
  851|     16|  if (!ec->p || !ec->a || !ec->b || !ec->G || !ec->n || !ec->Q)
  ------------------
  |  Branch (851:7): [True: 0, False: 16]
  |  Branch (851:17): [True: 0, False: 16]
  |  Branch (851:27): [True: 0, False: 16]
  |  Branch (851:37): [True: 0, False: 16]
  |  Branch (851:47): [True: 0, False: 16]
  |  Branch (851:57): [True: 0, False: 16]
  ------------------
  852|      0|    {
  853|      0|      rc = GPG_ERR_NO_OBJ;
  854|      0|      goto leave;
  855|      0|    }
  856|       |
  857|     16|  if (ec->model == MPI_EC_MONTGOMERY)
  ------------------
  |  Branch (857:7): [True: 0, False: 16]
  ------------------
  858|      0|    {
  859|      0|      if (DBG_CIPHER)
  ------------------
  |  |   25|      0|#define DBG_CIPHER _gcry_get_debug_flag( 1 )
  |  |  ------------------
  |  |  |  Branch (25:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  860|      0|        log_debug ("ecc_verify: Can't use a Montgomery curve\n");
  ------------------
  |  |  205|      0|#define log_debug   _gcry_log_debug
  ------------------
  861|      0|      rc = GPG_ERR_INTERNAL;
  862|      0|      goto leave;
  863|      0|    }
  864|       |
  865|     16|  ctx.flags |= flags;
  866|     16|  if (ec->model == MPI_EC_EDWARDS && ec->dialect == ECC_DIALECT_SAFECURVE)
  ------------------
  |  Branch (866:7): [True: 0, False: 16]
  |  Branch (866:38): [True: 0, False: 0]
  ------------------
  867|      0|    ctx.flags |= PUBKEY_FLAG_EDDSA;
  ------------------
  |  |   41|      0|#define PUBKEY_FLAG_EDDSA          (1 << 12)
  ------------------
  868|       |  /* Clear hash algo for EdDSA.  */
  869|     16|  if ((ctx.flags & PUBKEY_FLAG_EDDSA))
  ------------------
  |  |   41|     16|#define PUBKEY_FLAG_EDDSA          (1 << 12)
  ------------------
  |  Branch (869:7): [True: 0, False: 16]
  ------------------
  870|      0|    ctx.hash_algo = GCRY_MD_NONE;
  871|       |
  872|       |  /* Extract the data.  */
  873|     16|  rc = _gcry_pk_util_data_to_mpi (s_data, &data, &ctx);
  874|     16|  if (rc)
  ------------------
  |  Branch (874:7): [True: 0, False: 16]
  ------------------
  875|      0|    goto leave;
  876|     16|  if (DBG_CIPHER)
  ------------------
  |  |   25|     16|#define DBG_CIPHER _gcry_get_debug_flag( 1 )
  |  |  ------------------
  |  |  |  Branch (25:20): [True: 0, False: 16]
  |  |  ------------------
  ------------------
  877|      0|    log_mpidump ("ecc_verify data", data);
  ------------------
  |  |  212|      0|#define log_mpidump _gcry_log_printmpi
  ------------------
  878|       |
  879|       |  /* Hash algo is determined by curve in EdDSA.  Fill it if not specified.  */
  880|     16|  if ((ctx.flags & PUBKEY_FLAG_EDDSA) && !ctx.hash_algo)
  ------------------
  |  |   41|     16|#define PUBKEY_FLAG_EDDSA          (1 << 12)
  ------------------
  |  Branch (880:7): [True: 0, False: 16]
  |  Branch (880:42): [True: 0, False: 0]
  ------------------
  881|      0|    {
  882|      0|      if (ec->dialect == ECC_DIALECT_ED25519)
  ------------------
  |  Branch (882:11): [True: 0, False: 0]
  ------------------
  883|      0|        ctx.hash_algo = GCRY_MD_SHA512;
  884|      0|      else if (ec->dialect == ECC_DIALECT_SAFECURVE)
  ------------------
  |  Branch (884:16): [True: 0, False: 0]
  ------------------
  885|      0|        ctx.hash_algo = GCRY_MD_SHAKE256;
  886|      0|    }
  887|       |
  888|       |  /*
  889|       |   * Extract the signature value.
  890|       |   */
  891|     16|  rc = _gcry_pk_util_preparse_sigval (s_sig, ecc_names, &l1, &sigflags);
  892|     16|  if (rc)
  ------------------
  |  Branch (892:7): [True: 0, False: 16]
  ------------------
  893|      0|    goto leave;
  894|     16|  rc = sexp_extract_param (l1, NULL, (sigflags & PUBKEY_FLAG_EDDSA)? "/rs":"rs",
  ------------------
  |  |  391|     16|#define sexp_extract_param           _gcry_sexp_extract_param
  ------------------
                rc = sexp_extract_param (l1, NULL, (sigflags & PUBKEY_FLAG_EDDSA)? "/rs":"rs",
  ------------------
  |  |   41|     16|#define PUBKEY_FLAG_EDDSA          (1 << 12)
  ------------------
  |  Branch (894:38): [True: 0, False: 16]
  ------------------
  895|     16|                           &sig_r, &sig_s, NULL);
  896|     16|  if (rc)
  ------------------
  |  Branch (896:7): [True: 0, False: 16]
  ------------------
  897|      0|    goto leave;
  898|     16|  if (DBG_CIPHER)
  ------------------
  |  |   25|     16|#define DBG_CIPHER _gcry_get_debug_flag( 1 )
  |  |  ------------------
  |  |  |  Branch (25:20): [True: 0, False: 16]
  |  |  ------------------
  ------------------
  899|      0|    {
  900|      0|      log_mpidump ("ecc_verify  s_r", sig_r);
  ------------------
  |  |  212|      0|#define log_mpidump _gcry_log_printmpi
  ------------------
  901|      0|      log_mpidump ("ecc_verify  s_s", sig_s);
  ------------------
  |  |  212|      0|#define log_mpidump _gcry_log_printmpi
  ------------------
  902|      0|    }
  903|     16|  if ((ctx.flags & PUBKEY_FLAG_EDDSA) ^ (sigflags & PUBKEY_FLAG_EDDSA))
  ------------------
  |  |   41|     16|#define PUBKEY_FLAG_EDDSA          (1 << 12)
  ------------------
                if ((ctx.flags & PUBKEY_FLAG_EDDSA) ^ (sigflags & PUBKEY_FLAG_EDDSA))
  ------------------
  |  |   41|     16|#define PUBKEY_FLAG_EDDSA          (1 << 12)
  ------------------
  |  Branch (903:7): [True: 0, False: 16]
  ------------------
  904|      0|    {
  905|      0|      rc = GPG_ERR_CONFLICT; /* Inconsistent use of flag/algoname.  */
  906|      0|      goto leave;
  907|      0|    }
  908|       |
  909|       |  /*
  910|       |   * Verify the signature.
  911|       |   */
  912|     16|  if ((sigflags & PUBKEY_FLAG_EDDSA))
  ------------------
  |  |   41|     16|#define PUBKEY_FLAG_EDDSA          (1 << 12)
  ------------------
  |  Branch (912:7): [True: 0, False: 16]
  ------------------
  913|      0|    {
  914|      0|      rc = _gcry_ecc_eddsa_verify (data, ec, sig_r, sig_s, &ctx);
  915|      0|    }
  916|     16|  else if ((sigflags & PUBKEY_FLAG_GOST))
  ------------------
  |  |   42|     16|#define PUBKEY_FLAG_GOST           (1 << 13)
  ------------------
  |  Branch (916:12): [True: 0, False: 16]
  ------------------
  917|      0|    {
  918|      0|      rc = _gcry_ecc_gost_verify (data, ec, sig_r, sig_s);
  919|      0|    }
  920|     16|  else if ((sigflags & PUBKEY_FLAG_SM2))
  ------------------
  |  |   45|     16|#define PUBKEY_FLAG_SM2            (1 << 16)
  ------------------
  |  Branch (920:12): [True: 0, False: 16]
  ------------------
  921|      0|    {
  922|      0|      rc = _gcry_ecc_sm2_verify (data, ec, sig_r, sig_s);
  923|      0|    }
  924|     16|  else
  925|     16|    {
  926|     16|      rc = _gcry_ecc_ecdsa_verify (data, ec, sig_r, sig_s,
  927|     16|                                   ctx.flags, ctx.hash_algo);
  928|     16|    }
  929|       |
  930|     16| leave:
  931|     16|  _gcry_mpi_release (data);
  932|     16|  _gcry_mpi_release (sig_r);
  933|     16|  _gcry_mpi_release (sig_s);
  934|     16|  _gcry_mpi_ec_free (ec);
  935|     16|  sexp_release (l1);
  ------------------
  |  |  372|     16|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  936|     16|  _gcry_pk_util_free_encoding_ctx (&ctx);
  937|     16|  if (DBG_CIPHER)
  ------------------
  |  |   25|     16|#define DBG_CIPHER _gcry_get_debug_flag( 1 )
  |  |  ------------------
  |  |  |  Branch (25:20): [True: 0, False: 16]
  |  |  ------------------
  ------------------
  938|      0|    log_debug ("ecc_verify    => %s\n", rc?gpg_strerror (rc):"Good");
  ------------------
  |  |  205|      0|#define log_debug   _gcry_log_debug
  ------------------
  |  Branch (938:41): [True: 0, False: 0]
  ------------------
  939|     16|  return rc;
  940|     16|}
ecc.c:ecc_get_nbits:
 1336|     16|{
 1337|     16|  gcry_sexp_t l1;
 1338|     16|  gcry_mpi_t p;
 1339|     16|  unsigned int nbits = 0;
 1340|     16|  char *curve;
 1341|       |
 1342|     16|  l1 = sexp_find_token (parms, "p", 1);
  ------------------
  |  |  381|     16|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1343|     16|  if (!l1)
  ------------------
  |  Branch (1343:7): [True: 16, False: 0]
  ------------------
 1344|     16|    { /* Parameter P not found - check whether we have "curve".  */
 1345|     16|      l1 = sexp_find_token (parms, "curve", 5);
  ------------------
  |  |  381|     16|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1346|     16|      if (!l1)
  ------------------
  |  Branch (1346:11): [True: 0, False: 16]
  ------------------
 1347|      0|        return 0; /* Neither P nor CURVE found.  */
 1348|       |
 1349|     16|      curve = sexp_nth_string (l1, 1);
  ------------------
  |  |  389|     16|#define sexp_nth_string(a, b)        _gcry_sexp_nth_string ((a), (b))
  ------------------
 1350|     16|      sexp_release (l1);
  ------------------
  |  |  372|     16|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1351|     16|      if (!curve)
  ------------------
  |  Branch (1351:11): [True: 0, False: 16]
  ------------------
 1352|      0|        return 0;  /* No curve name given (or out of core). */
 1353|       |
 1354|     16|      if (_gcry_ecc_fill_in_curve (0, curve, NULL, &nbits))
  ------------------
  |  Branch (1354:11): [True: 0, False: 16]
  ------------------
 1355|      0|        nbits = 0;
 1356|     16|      xfree (curve);
  ------------------
  |  |  150|     16|#define xfree(a)         _gcry_free ((a))
  ------------------
 1357|     16|    }
 1358|      0|  else
 1359|      0|    {
 1360|      0|      p = sexp_nth_mpi (l1, 1, GCRYMPI_FMT_USG);
  ------------------
  |  |  390|      0|#define sexp_nth_mpi(a, b, c)        _gcry_sexp_nth_mpi ((a), (b), (c))
  ------------------
 1361|      0|      sexp_release (l1);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1362|      0|      if (p)
  ------------------
  |  Branch (1362:11): [True: 0, False: 0]
  ------------------
 1363|      0|        {
 1364|      0|          nbits = mpi_get_nbits (p);
  ------------------
  |  |  552|      0|#define mpi_get_nbits(a)       _gcry_mpi_get_nbits ((a))
  ------------------
 1365|      0|          _gcry_mpi_release (p);
 1366|      0|        }
 1367|      0|    }
 1368|     16|  return nbits;
 1369|     16|}
ecc.c:compute_keygrip:
 1375|      8|{
 1376|      8|#define N_COMPONENTS 6
 1377|      8|  static const char names[N_COMPONENTS] = "pabgnq";
 1378|      8|  gpg_err_code_t rc;
 1379|      8|  gcry_sexp_t l1;
 1380|      8|  gcry_mpi_t values[N_COMPONENTS];
 1381|      8|  int idx;
 1382|      8|  char *curvename = NULL;
 1383|      8|  int flags = 0;
 1384|      8|  enum gcry_mpi_ec_models model = 0;
 1385|      8|  enum ecc_dialects dialect = 0;
 1386|      8|  const unsigned char *raw;
 1387|      8|  unsigned int n;
 1388|      8|  int maybe_uncompress;
 1389|       |
 1390|       |  /* Clear the values first.  */
 1391|     56|  for (idx=0; idx < N_COMPONENTS; idx++)
  ------------------
  |  | 1376|     56|#define N_COMPONENTS 6
  ------------------
  |  Branch (1391:15): [True: 48, False: 8]
  ------------------
 1392|     48|    values[idx] = NULL;
 1393|       |
 1394|       |
 1395|       |  /* Look for flags. */
 1396|      8|  l1 = sexp_find_token (keyparms, "flags", 0);
  ------------------
  |  |  381|      8|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1397|      8|  if (l1)
  ------------------
  |  Branch (1397:7): [True: 0, False: 8]
  ------------------
 1398|      0|    {
 1399|      0|      rc = _gcry_pk_util_parse_flaglist (l1, &flags, NULL);
 1400|      0|      if (rc)
  ------------------
  |  Branch (1400:11): [True: 0, False: 0]
  ------------------
 1401|      0|        goto leave;
 1402|      0|    }
 1403|       |
 1404|       |  /* Extract the parameters.  */
 1405|      8|  if ((flags & PUBKEY_FLAG_PARAM))
  ------------------
  |  |   38|      8|#define PUBKEY_FLAG_PARAM          (1 << 9)
  ------------------
  |  Branch (1405:7): [True: 0, False: 8]
  ------------------
 1406|      0|    rc = sexp_extract_param (keyparms, NULL, "p?a?b?g?n?/q",
  ------------------
  |  |  391|      0|#define sexp_extract_param           _gcry_sexp_extract_param
  ------------------
 1407|      0|                             &values[0], &values[1], &values[2],
 1408|      0|                             &values[3], &values[4], &values[5],
 1409|      0|                             NULL);
 1410|      8|  else
 1411|      8|    rc = sexp_extract_param (keyparms, NULL, "/q", &values[5], NULL);
  ------------------
  |  |  391|      8|#define sexp_extract_param           _gcry_sexp_extract_param
  ------------------
 1412|      8|  if (rc)
  ------------------
  |  Branch (1412:7): [True: 0, False: 8]
  ------------------
 1413|      0|    goto leave;
 1414|       |
 1415|       |  /* Check whether a curve parameter is available and use that to fill
 1416|       |     in missing values.  */
 1417|      8|  sexp_release (l1);
  ------------------
  |  |  372|      8|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1418|      8|  l1 = sexp_find_token (keyparms, "curve", 5);
  ------------------
  |  |  381|      8|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1419|      8|  if (l1)
  ------------------
  |  Branch (1419:7): [True: 8, False: 0]
  ------------------
 1420|      8|    {
 1421|      8|      curvename = sexp_nth_string (l1, 1);
  ------------------
  |  |  389|      8|#define sexp_nth_string(a, b)        _gcry_sexp_nth_string ((a), (b))
  ------------------
 1422|      8|      if (curvename)
  ------------------
  |  Branch (1422:11): [True: 8, False: 0]
  ------------------
 1423|      8|        {
 1424|      8|          rc = _gcry_ecc_update_curve_param (curvename,
 1425|      8|                                             &model, &dialect,
 1426|      8|                                             &values[0], &values[1], &values[2],
 1427|      8|                                             &values[3], &values[4]);
 1428|      8|          if (rc)
  ------------------
  |  Branch (1428:15): [True: 0, False: 8]
  ------------------
 1429|      0|            goto leave;
 1430|      8|        }
 1431|      8|    }
 1432|       |
 1433|       |  /* Guess required fields if a curve parameter has not been given.
 1434|       |     FIXME: This is a crude hacks.  We need to fix that.  */
 1435|      8|  if (!curvename)
  ------------------
  |  Branch (1435:7): [True: 0, False: 8]
  ------------------
 1436|      0|    {
 1437|      0|      model = ((flags & PUBKEY_FLAG_EDDSA)
  ------------------
  |  |   41|      0|#define PUBKEY_FLAG_EDDSA          (1 << 12)
  ------------------
  |  Branch (1437:16): [True: 0, False: 0]
  ------------------
 1438|      0|               ? MPI_EC_EDWARDS
 1439|      0|               : MPI_EC_WEIERSTRASS);
 1440|      0|      dialect = ((flags & PUBKEY_FLAG_EDDSA)
  ------------------
  |  |   41|      0|#define PUBKEY_FLAG_EDDSA          (1 << 12)
  ------------------
  |  Branch (1440:18): [True: 0, False: 0]
  ------------------
 1441|      0|                 ? ECC_DIALECT_ED25519
 1442|      0|                 : ECC_DIALECT_STANDARD);
 1443|      0|    }
 1444|       |
 1445|       |  /* Check that all parameters are known and normalize all MPIs (that
 1446|       |     should not be required but we use an internal function later and
 1447|       |     thus we better make 100% sure that they are normalized). */
 1448|     56|  for (idx = 0; idx < N_COMPONENTS; idx++)
  ------------------
  |  | 1376|     56|#define N_COMPONENTS 6
  ------------------
  |  Branch (1448:17): [True: 48, False: 8]
  ------------------
 1449|     48|    if (!values[idx])
  ------------------
  |  Branch (1449:9): [True: 0, False: 48]
  ------------------
 1450|      0|      {
 1451|      0|        rc = GPG_ERR_NO_OBJ;
 1452|      0|        goto leave;
 1453|      0|      }
 1454|     48|    else
 1455|     48|      _gcry_mpi_normalize (values[idx]);
 1456|       |
 1457|       |  /* Uncompress the public key with the exception of EdDSA where
 1458|       |     compression is the default and we thus compute the keygrip using
 1459|       |     the compressed version.  Because we don't support any non-eddsa
 1460|       |     compression, the only thing we need to do is to compress
 1461|       |     EdDSA.  */
 1462|      8|  if ((flags & PUBKEY_FLAG_EDDSA) && dialect == ECC_DIALECT_ED25519)
  ------------------
  |  |   41|      8|#define PUBKEY_FLAG_EDDSA          (1 << 12)
  ------------------
  |  Branch (1462:7): [True: 0, False: 8]
  |  Branch (1462:38): [True: 0, False: 0]
  ------------------
 1463|      0|    {
 1464|      0|      const unsigned int pbits = mpi_get_nbits (values[0]);
  ------------------
  |  |  552|      0|#define mpi_get_nbits(a)       _gcry_mpi_get_nbits ((a))
  ------------------
 1465|       |
 1466|      0|      rc = _gcry_ecc_eddsa_ensure_compact (values[5], pbits);
 1467|      0|      if (rc)
  ------------------
  |  Branch (1467:11): [True: 0, False: 0]
  ------------------
 1468|      0|        goto leave;
 1469|      0|      maybe_uncompress = 0;
 1470|      0|    }
 1471|      8|  else if ((flags & PUBKEY_FLAG_DJB_TWEAK))
  ------------------
  |  |   44|      8|#define PUBKEY_FLAG_DJB_TWEAK      (1 << 15)
  ------------------
  |  Branch (1471:12): [True: 0, False: 8]
  ------------------
 1472|      0|    {
 1473|       |      /* Remove the prefix 0x40 for keygrip computation.  */
 1474|      0|      raw = mpi_get_opaque (values[5], &n);
  ------------------
  |  |  562|      0|#define mpi_get_opaque(a,b)    _gcry_mpi_get_opaque ((a), (b))
  ------------------
 1475|      0|      if (raw)
  ------------------
  |  Branch (1475:11): [True: 0, False: 0]
  ------------------
 1476|      0|        {
 1477|      0|          n = (n + 7)/8;
 1478|       |
 1479|      0|          if (n > 1 && (n%2) && raw[0] == 0x40)
  ------------------
  |  Branch (1479:15): [True: 0, False: 0]
  |  Branch (1479:24): [True: 0, False: 0]
  |  Branch (1479:33): [True: 0, False: 0]
  ------------------
 1480|      0|            if (!_gcry_mpi_set_opaque_copy (values[5], raw + 1, (n - 1)*8))
  ------------------
  |  Branch (1480:17): [True: 0, False: 0]
  ------------------
 1481|      0|                rc = gpg_err_code_from_syserror ();
 1482|      0|        }
 1483|      0|      else
 1484|      0|        {
 1485|      0|          rc = GPG_ERR_INV_OBJ;
 1486|      0|          goto leave;
 1487|      0|        }
 1488|      0|      maybe_uncompress = 0;
 1489|      0|    }
 1490|      8|  else
 1491|      8|    maybe_uncompress = 1;
 1492|       |
 1493|       |  /* Hash them all.  */
 1494|     56|  for (idx = 0; idx < N_COMPONENTS; idx++)
  ------------------
  |  | 1376|     56|#define N_COMPONENTS 6
  ------------------
  |  Branch (1494:17): [True: 48, False: 8]
  ------------------
 1495|     48|    {
 1496|     48|      char buf[30];
 1497|     48|      unsigned char *rawbuffer;
 1498|     48|      unsigned int rawlen;
 1499|       |
 1500|     48|      if (mpi_is_opaque (values[idx]))
  ------------------
  |  |  114|     48|#define mpi_is_opaque(a)      ((a) && ((a)->flags&4))
  |  |  ------------------
  |  |  |  Branch (114:32): [True: 48, False: 0]
  |  |  |  Branch (114:39): [True: 8, False: 40]
  |  |  ------------------
  ------------------
 1501|      8|        {
 1502|      8|          rawbuffer = NULL;
 1503|      8|          raw = mpi_get_opaque (values[idx], &rawlen);
  ------------------
  |  |  562|      8|#define mpi_get_opaque(a,b)    _gcry_mpi_get_opaque ((a), (b))
  ------------------
 1504|      8|          rawlen = (rawlen + 7)/8;
 1505|      8|        }
 1506|     40|      else
 1507|     40|        {
 1508|     40|          rawbuffer = _gcry_mpi_get_buffer (values[idx], 0, &rawlen, NULL);
 1509|     40|          if (!rawbuffer)
  ------------------
  |  Branch (1509:15): [True: 0, False: 40]
  ------------------
 1510|      0|            {
 1511|      0|              rc = gpg_err_code_from_syserror ();
 1512|      0|              goto leave;
 1513|      0|            }
 1514|     40|          raw = rawbuffer;
 1515|     40|        }
 1516|       |
 1517|     48|      if (maybe_uncompress && idx == 5 && rawlen > 1
  ------------------
  |  Branch (1517:11): [True: 48, False: 0]
  |  Branch (1517:31): [True: 8, False: 40]
  |  Branch (1517:43): [True: 8, False: 0]
  ------------------
 1518|     48|          && (*raw == 0x02 || *raw == 0x03))
  ------------------
  |  Branch (1518:15): [True: 0, False: 8]
  |  Branch (1518:31): [True: 0, False: 8]
  ------------------
 1519|      0|        {
 1520|       |          /* This is a compressed Q - uncompress.  */
 1521|      0|          mpi_ec_t ec = NULL;
 1522|      0|          gcry_mpi_t x, y;
 1523|      0|          gcry_mpi_t x3;
 1524|      0|          gcry_mpi_t t;
 1525|      0|          gcry_mpi_t p1_4;
 1526|      0|          int y_bit = (*raw == 0x03);
 1527|       |
 1528|       |          /* We need to get the curve parameters as MPIs so that we
 1529|       |           * can do computations.  We have them in VALUES but it is
 1530|       |           * possible that the caller provided them as opaque MPIs. */
 1531|      0|          rc = _gcry_mpi_ec_internal_new (&ec, &flags, "ecc_keygrip",
 1532|      0|                                          keyparms, NULL);
 1533|      0|          if (rc)
  ------------------
  |  Branch (1533:15): [True: 0, False: 0]
  ------------------
 1534|      0|            goto leave;
 1535|      0|          if (!ec->p || !ec->a || !ec->b || !ec->G || !ec->n)
  ------------------
  |  Branch (1535:15): [True: 0, False: 0]
  |  Branch (1535:25): [True: 0, False: 0]
  |  Branch (1535:35): [True: 0, False: 0]
  |  Branch (1535:45): [True: 0, False: 0]
  |  Branch (1535:55): [True: 0, False: 0]
  ------------------
 1536|      0|            {
 1537|      0|              rc = GPG_ERR_NO_OBJ;
 1538|      0|              _gcry_mpi_ec_free (ec);
 1539|      0|              goto leave;
 1540|      0|            }
 1541|       |
 1542|      0|          if (!mpi_test_bit (ec->p, 1))
  ------------------
  |  |  553|      0|#define mpi_test_bit(a,b)      _gcry_mpi_test_bit ((a),(b))
  ------------------
  |  Branch (1542:15): [True: 0, False: 0]
  ------------------
 1543|      0|            {
 1544|       |              /* No support for point compression for this curve.  */
 1545|      0|              rc = GPG_ERR_NOT_IMPLEMENTED;
 1546|      0|              _gcry_mpi_ec_free (ec);
 1547|      0|              xfree (rawbuffer);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1548|      0|              goto leave;
 1549|      0|            }
 1550|       |
 1551|      0|          raw++;
 1552|      0|          rawlen--;
 1553|      0|          rc = _gcry_mpi_scan (&x, GCRYMPI_FMT_USG, raw, rawlen, NULL);
 1554|      0|          if (rc)
  ------------------
  |  Branch (1554:15): [True: 0, False: 0]
  ------------------
 1555|      0|            {
 1556|      0|              _gcry_mpi_ec_free (ec);
 1557|      0|              xfree (rawbuffer);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1558|      0|              goto leave;
 1559|      0|            }
 1560|       |
 1561|       |          /*
 1562|       |           * Recover Y.  The Weierstrass curve: y^2 = x^3 + a*x + b
 1563|       |           */
 1564|       |
 1565|      0|          x3 = mpi_new (0);
  ------------------
  |  |  491|      0|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
 1566|      0|          t = mpi_new (0);
  ------------------
  |  |  491|      0|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
 1567|      0|          p1_4 = mpi_new (0);
  ------------------
  |  |  491|      0|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
 1568|      0|          y = mpi_new (0);
  ------------------
  |  |  491|      0|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
 1569|       |
 1570|       |          /* Compute right hand side.  */
 1571|      0|          mpi_powm (x3, x, mpi_const (MPI_C_THREE), ec->p);
  ------------------
  |  |  525|      0|#define mpi_powm(w,b,e,m)      _gcry_mpi_powm ( (w), (b), (e), (m) )
  ------------------
 1572|      0|          mpi_mul (t, ec->a, x);
  ------------------
  |  |  523|      0|#define mpi_mul(w,u,v)         _gcry_mpi_mul ((w),(u),(v))
  ------------------
 1573|      0|          mpi_mod (t, t, ec->p);
  ------------------
  |  |  528|      0|#define mpi_mod(r,a,m)         _gcry_mpi_mod ((r), (a), (m))
  ------------------
 1574|      0|          mpi_add (t, t, ec->b);
  ------------------
  |  |  516|      0|#define mpi_add(w,u,v)         _gcry_mpi_add ((w),(u),(v))
  ------------------
 1575|      0|          mpi_mod (t, t, ec->p);
  ------------------
  |  |  528|      0|#define mpi_mod(r,a,m)         _gcry_mpi_mod ((r), (a), (m))
  ------------------
 1576|      0|          mpi_add (t, t, x3);
  ------------------
  |  |  516|      0|#define mpi_add(w,u,v)         _gcry_mpi_add ((w),(u),(v))
  ------------------
 1577|      0|          mpi_mod (t, t, ec->p);
  ------------------
  |  |  528|      0|#define mpi_mod(r,a,m)         _gcry_mpi_mod ((r), (a), (m))
  ------------------
 1578|       |
 1579|       |          /*
 1580|       |           * When p mod 4 = 3, modular square root of A can be computed by
 1581|       |           * A^((p+1)/4) mod p
 1582|       |           */
 1583|       |
 1584|       |          /* Compute (p+1)/4 into p1_4 */
 1585|      0|          mpi_rshift (p1_4, ec->p, 2);
  ------------------
  |  |  558|      0|#define mpi_rshift(a,b,c)      _gcry_mpi_rshift ((a),(b),(c))
  ------------------
 1586|      0|          _gcry_mpi_add_ui (p1_4, p1_4, 1);
 1587|       |
 1588|      0|          mpi_powm (y, t, p1_4, ec->p);
  ------------------
  |  |  525|      0|#define mpi_powm(w,b,e,m)      _gcry_mpi_powm ( (w), (b), (e), (m) )
  ------------------
 1589|       |
 1590|      0|          if (y_bit != mpi_test_bit (y, 0))
  ------------------
  |  |  553|      0|#define mpi_test_bit(a,b)      _gcry_mpi_test_bit ((a),(b))
  ------------------
  |  Branch (1590:15): [True: 0, False: 0]
  ------------------
 1591|      0|            mpi_sub (y, ec->p, y);
  ------------------
  |  |  519|      0|#define mpi_sub(w,u,v)         _gcry_mpi_sub ((w),(u),(v))
  ------------------
 1592|       |
 1593|      0|          mpi_free (p1_4);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1594|      0|          mpi_free (t);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1595|      0|          mpi_free (x3);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1596|       |
 1597|      0|          xfree (rawbuffer);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1598|      0|          rawbuffer = _gcry_ecc_ec2os_buf (x, y, ec->p, &rawlen);
 1599|      0|          raw = rawbuffer;
 1600|       |
 1601|      0|          mpi_free (x);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1602|      0|          mpi_free (y);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1603|      0|          _gcry_mpi_ec_free (ec);
 1604|      0|        }
 1605|       |
 1606|     48|      snprintf (buf, sizeof buf, "(1:%c%u:", names[idx], rawlen);
 1607|     48|      _gcry_md_write (md, buf, strlen (buf));
 1608|     48|      _gcry_md_write (md, raw, rawlen);
 1609|     48|      _gcry_md_write (md, ")", 1);
 1610|     48|      xfree (rawbuffer);
  ------------------
  |  |  150|     48|#define xfree(a)         _gcry_free ((a))
  ------------------
 1611|     48|    }
 1612|       |
 1613|      8| leave:
 1614|      8|  xfree (curvename);
  ------------------
  |  |  150|      8|#define xfree(a)         _gcry_free ((a))
  ------------------
 1615|      8|  sexp_release (l1);
  ------------------
  |  |  372|      8|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1616|     56|  for (idx = 0; idx < N_COMPONENTS; idx++)
  ------------------
  |  | 1376|     56|#define N_COMPONENTS 6
  ------------------
  |  Branch (1616:17): [True: 48, False: 8]
  ------------------
 1617|     48|    _gcry_mpi_release (values[idx]);
 1618|       |
 1619|      8|  return rc;
 1620|      8|#undef N_COMPONENTS
 1621|      8|}

_gcry_md_block_write:
  121|  3.18k|{
  122|  3.18k|  const unsigned char *inbuf = inbuf_arg;
  123|  3.18k|  gcry_md_block_ctx_t *hd = context;
  124|  3.18k|  unsigned int stack_burn = 0;
  125|  3.18k|  unsigned int nburn;
  126|  3.18k|  const unsigned int blocksize_shift = hd->blocksize_shift;
  127|  3.18k|  const unsigned int blocksize = 1 << blocksize_shift;
  128|  3.18k|  size_t inblocks;
  129|  3.18k|  size_t copylen;
  130|       |
  131|  3.18k|  if (sizeof(hd->buf) < blocksize)
  ------------------
  |  Branch (131:7): [True: 0, False: 3.18k]
  ------------------
  132|      0|    BUG();
  ------------------
  |  |  187|      0|#define BUG() _gcry_bug( __FILE__ , __LINE__, __FUNCTION__ )
  ------------------
  133|       |
  134|  3.18k|  if (!hd->bwrite)
  ------------------
  |  Branch (134:7): [True: 0, False: 3.18k]
  ------------------
  135|      0|    return;
  136|       |
  137|  3.18k|  if (hd->count > blocksize)
  ------------------
  |  Branch (137:7): [True: 0, False: 3.18k]
  ------------------
  138|      0|    {
  139|       |      /* This happens only when gcry_md_write is called after final.
  140|       |       * Writing after final is used for mitigating timing attacks. */
  141|      0|      hd->count = 0;
  142|      0|    }
  143|       |
  144|  5.07k|  while (hd->count)
  ------------------
  |  Branch (144:10): [True: 3.68k, False: 1.39k]
  ------------------
  145|  3.68k|    {
  146|  3.68k|      if (hd->count == blocksize)  /* Flush the buffer. */
  ------------------
  |  Branch (146:11): [True: 179, False: 3.50k]
  ------------------
  147|    179|	{
  148|    179|	  nburn = hd->bwrite (hd, hd->buf, 1);
  149|    179|	  stack_burn = nburn > stack_burn ? nburn : stack_burn;
  ------------------
  |  Branch (149:17): [True: 0, False: 179]
  ------------------
  150|    179|	  hd->count = 0;
  151|    179|	  if (!++hd->nblocks)
  ------------------
  |  Branch (151:8): [True: 0, False: 179]
  ------------------
  152|      0|	    hd->nblocks_high++;
  153|    179|	}
  154|  3.50k|      else
  155|  3.50k|	{
  156|  3.50k|	  copylen = inlen;
  157|  3.50k|	  if (copylen > blocksize - hd->count)
  ------------------
  |  Branch (157:8): [True: 179, False: 3.32k]
  ------------------
  158|    179|	    copylen = blocksize - hd->count;
  159|       |
  160|  3.50k|	  if (copylen == 0)
  ------------------
  |  Branch (160:8): [True: 1.78k, False: 1.71k]
  ------------------
  161|  1.78k|	    break;
  162|       |
  163|  1.71k|	  buf_cpy (&hd->buf[hd->count], inbuf, copylen);
  164|  1.71k|	  hd->count += copylen;
  165|  1.71k|	  inbuf += copylen;
  166|  1.71k|	  inlen -= copylen;
  167|  1.71k|	}
  168|  3.68k|    }
  169|       |
  170|  3.18k|  if (inlen == 0)
  ------------------
  |  Branch (170:7): [True: 1.78k, False: 1.39k]
  ------------------
  171|  1.78k|    return;
  172|       |
  173|  1.39k|  if (inlen >= blocksize)
  ------------------
  |  Branch (173:7): [True: 74, False: 1.32k]
  ------------------
  174|     74|    {
  175|     74|      inblocks = inlen >> blocksize_shift;
  176|     74|      nburn = hd->bwrite (hd, inbuf, inblocks);
  177|     74|      stack_burn = nburn > stack_burn ? nburn : stack_burn;
  ------------------
  |  Branch (177:20): [True: 0, False: 74]
  ------------------
  178|     74|      hd->count = 0;
  179|     74|      hd->nblocks_high += (hd->nblocks + inblocks < inblocks);
  180|     74|      hd->nblocks += inblocks;
  181|     74|      inlen -= inblocks << blocksize_shift;
  182|     74|      inbuf += inblocks << blocksize_shift;
  183|     74|    }
  184|       |
  185|  1.39k|  if (inlen)
  ------------------
  |  Branch (185:7): [True: 1.38k, False: 8]
  ------------------
  186|  1.38k|    {
  187|  1.38k|      buf_cpy (hd->buf, inbuf, inlen);
  188|  1.38k|      hd->count = inlen;
  189|  1.38k|    }
  190|       |
  191|  1.39k|  if (stack_burn > 0)
  ------------------
  |  Branch (191:7): [True: 0, False: 1.39k]
  ------------------
  192|      0|    _gcry_burn_stack (stack_burn);
  ------------------
  |  |  371|      0|	do { __gcry_burn_stack (bytes); \
  |  |  372|      0|	     __gcry_burn_stack_dummy (); } while(0)
  |  |  ------------------
  |  |  |  |  364|      0|#define  __gcry_burn_stack_dummy() asm volatile ("":::"memory")
  |  |  ------------------
  |  |  |  Branch (372:43): [Folded - Ignored]
  |  |  ------------------
  ------------------
  193|  1.39k|}

_gcry_mac_init:
  384|      1|{
  385|      1|  return 0;
  386|      1|}

_gcry_md_open:
  530|  1.23k|{
  531|  1.23k|  gcry_err_code_t rc;
  532|  1.23k|  gcry_md_hd_t hd;
  533|       |
  534|  1.23k|  if ((flags & ~(GCRY_MD_FLAG_SECURE
  ------------------
  |  Branch (534:7): [True: 0, False: 1.23k]
  ------------------
  535|  1.23k|                 | GCRY_MD_FLAG_HMAC
  536|  1.23k|                 | GCRY_MD_FLAG_BUGEMU1)))
  537|      0|    rc = GPG_ERR_INV_ARG;
  538|  1.23k|  else
  539|  1.23k|    rc = md_open (&hd, algo, flags);
  540|       |
  541|  1.23k|  *h = rc? NULL : hd;
  ------------------
  |  Branch (541:8): [True: 0, False: 1.23k]
  ------------------
  542|  1.23k|  return rc;
  543|  1.23k|}
_gcry_md_enable:
  612|    158|{
  613|    158|  return md_enable (hd, algorithm);
  614|    158|}
_gcry_md_reset:
  700|  1.50k|{
  701|  1.50k|  GcryDigestEntry *r;
  702|       |
  703|       |  /* Note: We allow this even in fips non operational mode.  */
  704|       |
  705|  1.50k|  a->bufpos = a->ctx->flags.finalized = 0;
  706|       |
  707|  1.50k|  if (a->ctx->flags.hmac)
  ------------------
  |  Branch (707:7): [True: 0, False: 1.50k]
  ------------------
  708|      0|    for (r = a->ctx->list; r; r = r->next)
  ------------------
  |  Branch (708:28): [True: 0, False: 0]
  ------------------
  709|      0|      {
  710|      0|        memcpy (r->context, (char *)r->context + r->spec->contextsize,
  711|      0|                r->spec->contextsize);
  712|      0|      }
  713|  1.50k|  else
  714|  3.01k|    for (r = a->ctx->list; r; r = r->next)
  ------------------
  |  Branch (714:28): [True: 1.50k, False: 1.50k]
  ------------------
  715|  1.50k|      {
  716|  1.50k|        memset (r->context, 0, r->spec->contextsize);
  717|  1.50k|        (*r->spec->init) (r->context,
  718|  1.50k|                          a->ctx->flags.bugemu1? GCRY_MD_FLAG_BUGEMU1:0);
  ------------------
  |  Branch (718:27): [True: 0, False: 1.50k]
  ------------------
  719|  1.50k|      }
  720|  1.50k|}
_gcry_md_close:
  746|  1.23k|{
  747|       |  /* Note: We allow this even in fips non operational mode.  */
  748|  1.23k|  md_close (hd);
  749|  1.23k|}
_gcry_md_write:
  780|  2.57k|{
  781|  2.57k|  md_write (hd, inbuf, inlen);
  782|  2.57k|}
_gcry_md_ctl:
 1001|  3.75k|{
 1002|  3.75k|  gcry_err_code_t rc = 0;
 1003|       |
 1004|  3.75k|  (void)buflen; /* Currently not used.  */
 1005|       |
 1006|  3.75k|  switch (cmd)
 1007|  3.75k|    {
 1008|  3.75k|    case GCRYCTL_FINALIZE:
  ------------------
  |  Branch (1008:5): [True: 3.75k, False: 0]
  ------------------
 1009|  3.75k|      md_final (hd);
 1010|  3.75k|      break;
 1011|      0|    case GCRYCTL_START_DUMP:
  ------------------
  |  Branch (1011:5): [True: 0, False: 3.75k]
  ------------------
 1012|      0|      md_start_debug (hd, buffer);
 1013|      0|      break;
 1014|      0|    case GCRYCTL_STOP_DUMP:
  ------------------
  |  Branch (1014:5): [True: 0, False: 3.75k]
  ------------------
 1015|      0|      md_stop_debug ( hd );
 1016|      0|      break;
 1017|      0|    default:
  ------------------
  |  Branch (1017:5): [True: 0, False: 3.75k]
  ------------------
 1018|      0|      rc = GPG_ERR_INV_OP;
 1019|  3.75k|    }
 1020|  3.75k|  return rc;
 1021|  3.75k|}
_gcry_md_read:
 1103|  1.10k|{
 1104|       |  /* This function is expected to always return a digest, thus we
 1105|       |     can't return an error which we actually should do in
 1106|       |     non-operational state.  */
 1107|  1.10k|  _gcry_md_ctl (hd, GCRYCTL_FINALIZE, NULL, 0);
 1108|  1.10k|  return md_read (hd, algo);
 1109|  1.10k|}
_gcry_md_hash_buffer:
 1184|     25|{
 1185|     25|  const gcry_md_spec_t *spec;
 1186|       |
 1187|     25|  spec = spec_from_algo (algo);
 1188|     25|  if (!spec)
  ------------------
  |  Branch (1188:7): [True: 0, False: 25]
  ------------------
 1189|      0|    {
 1190|      0|      log_debug ("md_hash_buffer: algorithm %d not available\n", algo);
  ------------------
  |  |  205|      0|#define log_debug   _gcry_log_debug
  ------------------
 1191|      0|      return;
 1192|      0|    }
 1193|       |
 1194|     25|  if (spec->hash_buffers != NULL)
  ------------------
  |  Branch (1194:7): [True: 25, False: 0]
  ------------------
 1195|     25|    {
 1196|     25|      gcry_buffer_t iov;
 1197|       |
 1198|     25|      iov.size = 0;
 1199|     25|      iov.data = (void *)buffer;
 1200|     25|      iov.off = 0;
 1201|     25|      iov.len = length;
 1202|       |
 1203|     25|      if (spec->flags.disabled || (!spec->flags.fips && fips_mode ()))
  ------------------
  |  |  449|      0|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1203:11): [True: 0, False: 25]
  |  Branch (1203:36): [True: 0, False: 25]
  ------------------
 1204|      0|        log_bug ("gcry_md_hash_buffer failed for algo %d: %s",
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
 1205|      0|                algo, gpg_strerror (gcry_error (GPG_ERR_DIGEST_ALGO)));
 1206|       |
 1207|     25|      spec->hash_buffers (digest, spec->mdlen, &iov, 1);
 1208|     25|    }
 1209|      0|  else
 1210|      0|    {
 1211|       |      /* For the others we do not have a fast function, so we use the
 1212|       |         normal functions. */
 1213|      0|      gcry_md_hd_t h;
 1214|      0|      gpg_err_code_t err;
 1215|       |
 1216|      0|      err = md_open (&h, algo, 0);
 1217|      0|      if (err)
  ------------------
  |  Branch (1217:11): [True: 0, False: 0]
  ------------------
 1218|      0|        log_bug ("gcry_md_open failed for algo %d: %s",
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
 1219|      0|                algo, gpg_strerror (gcry_error(err)));
 1220|      0|      md_write (h, (byte *) buffer, length);
 1221|      0|      md_final (h);
 1222|      0|      memcpy (digest, md_read (h, algo), md_digest_length (algo));
 1223|      0|      md_close (h);
 1224|      0|    }
 1225|     25|}
_gcry_md_get_algo:
 1356|  1.01k|{
 1357|  1.01k|  return md_get_algo (hd);
 1358|  1.01k|}
_gcry_md_get_algo_dlen:
 1380|  1.17k|{
 1381|  1.17k|  return md_digest_length (algorithm);
 1382|  1.17k|}
_gcry_md_algo_info:
 1429|   126k|{
 1430|   126k|  gcry_err_code_t rc;
 1431|       |
 1432|   126k|  switch (what)
 1433|   126k|    {
 1434|   126k|    case GCRYCTL_TEST_ALGO:
  ------------------
  |  Branch (1434:5): [True: 126k, False: 284]
  ------------------
 1435|   126k|      if (buffer || nbytes)
  ------------------
  |  Branch (1435:11): [True: 0, False: 126k]
  |  Branch (1435:21): [True: 0, False: 126k]
  ------------------
 1436|      0|	rc = GPG_ERR_INV_ARG;
 1437|   126k|      else
 1438|   126k|	rc = check_digest_algo (algo);
 1439|   126k|      break;
 1440|       |
 1441|    284|    case GCRYCTL_GET_ASNOID:
  ------------------
  |  Branch (1441:5): [True: 284, False: 126k]
  ------------------
 1442|       |      /* We need to check that the algo is available because
 1443|       |         md_asn_oid would otherwise raise an assertion. */
 1444|    284|      rc = check_digest_algo (algo);
 1445|    284|      if (!rc)
  ------------------
  |  Branch (1445:11): [True: 284, False: 0]
  ------------------
 1446|    284|        {
 1447|    284|          const char unsigned *asn;
 1448|    284|          size_t asnlen;
 1449|       |
 1450|    284|          asn = md_asn_oid (algo, &asnlen, NULL);
 1451|    284|          if (buffer && (*nbytes >= asnlen))
  ------------------
  |  Branch (1451:15): [True: 142, False: 142]
  |  Branch (1451:25): [True: 142, False: 0]
  ------------------
 1452|    142|            {
 1453|    142|              memcpy (buffer, asn, asnlen);
 1454|    142|              *nbytes = asnlen;
 1455|    142|            }
 1456|    142|          else if (!buffer && nbytes)
  ------------------
  |  Branch (1456:20): [True: 142, False: 0]
  |  Branch (1456:31): [True: 142, False: 0]
  ------------------
 1457|    142|            *nbytes = asnlen;
 1458|      0|          else
 1459|      0|            {
 1460|      0|              if (buffer)
  ------------------
  |  Branch (1460:19): [True: 0, False: 0]
  ------------------
 1461|      0|                rc = GPG_ERR_TOO_SHORT;
 1462|      0|              else
 1463|      0|                rc = GPG_ERR_INV_ARG;
 1464|      0|            }
 1465|    284|        }
 1466|    284|      break;
 1467|       |
 1468|      0|    case GCRYCTL_SELFTEST:
  ------------------
  |  Branch (1468:5): [True: 0, False: 126k]
  ------------------
 1469|       |      /* Helper function for the regression tests.  */
 1470|      0|      rc = gpg_err_code (_gcry_md_selftest (algo, nbytes? (int)*nbytes : 0,
  ------------------
  |  Branch (1470:51): [True: 0, False: 0]
  ------------------
 1471|      0|                                             NULL));
 1472|      0|      break;
 1473|       |
 1474|      0|    default:
  ------------------
  |  Branch (1474:5): [True: 0, False: 126k]
  ------------------
 1475|      0|      rc = GPG_ERR_INV_OP;
 1476|      0|      break;
 1477|   126k|  }
 1478|       |
 1479|   126k|  return rc;
 1480|   126k|}
_gcry_md_info:
 1538|     15|{
 1539|     15|  gcry_err_code_t rc = 0;
 1540|       |
 1541|     15|  switch (cmd)
 1542|     15|    {
 1543|     15|    case GCRYCTL_IS_SECURE:
  ------------------
  |  Branch (1543:5): [True: 15, False: 0]
  ------------------
 1544|     15|      *nbytes = h->ctx->flags.secure;
 1545|     15|      break;
 1546|       |
 1547|      0|    case GCRYCTL_IS_ALGO_ENABLED:
  ------------------
  |  Branch (1547:5): [True: 0, False: 15]
  ------------------
 1548|      0|      {
 1549|      0|	GcryDigestEntry *r;
 1550|      0|	int algo;
 1551|       |
 1552|      0|	if ( !buffer || !nbytes || *nbytes != sizeof (int))
  ------------------
  |  Branch (1552:7): [True: 0, False: 0]
  |  Branch (1552:18): [True: 0, False: 0]
  |  Branch (1552:29): [True: 0, False: 0]
  ------------------
 1553|      0|	  rc = GPG_ERR_INV_ARG;
 1554|      0|	else
 1555|      0|	  {
 1556|      0|	    algo = *(int*)buffer;
 1557|       |
 1558|      0|	    *nbytes = 0;
 1559|      0|	    for(r=h->ctx->list; r; r = r->next ) {
  ------------------
  |  Branch (1559:26): [True: 0, False: 0]
  ------------------
 1560|      0|	      if (r->spec->algo == algo)
  ------------------
  |  Branch (1560:12): [True: 0, False: 0]
  ------------------
 1561|      0|		{
 1562|      0|		  *nbytes = 1;
 1563|      0|		  break;
 1564|      0|		}
 1565|      0|	    }
 1566|      0|	  }
 1567|      0|	break;
 1568|      0|      }
 1569|       |
 1570|      0|  default:
  ------------------
  |  Branch (1570:3): [True: 0, False: 15]
  ------------------
 1571|      0|    rc = GPG_ERR_INV_OP;
 1572|     15|  }
 1573|       |
 1574|     15|  return rc;
 1575|     15|}
_gcry_md_init:
 1581|      1|{
 1582|      1|  return 0;
 1583|      1|}
_gcry_md_is_secure:
 1588|     15|{
 1589|     15|  size_t value;
 1590|       |
 1591|     15|  if (_gcry_md_info (a, GCRYCTL_IS_SECURE, NULL, &value))
  ------------------
  |  Branch (1591:7): [True: 0, False: 15]
  ------------------
 1592|      0|    value = 1; /* It seems to be better to assume secure memory on
 1593|       |                  error. */
 1594|     15|  return value;
 1595|     15|}
md.c:spec_from_algo:
  301|   129k|{
  302|   129k|  const gcry_md_spec_t *spec = NULL;
  303|       |
  304|   129k|  algo = map_algo (algo);
  305|       |
  306|   129k|  if (algo >= 0 && algo < DIM(digest_list_algo0))
  ------------------
  |  |  104|   129k|#define DIM(v) (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (306:7): [True: 129k, False: 0]
  |  Branch (306:20): [True: 129k, False: 53]
  ------------------
  307|   129k|    spec = digest_list_algo0[algo];
  308|     53|  else if (algo >= 301 && algo < 301 + DIM(digest_list_algo301))
  ------------------
  |  |  104|     53|#define DIM(v) (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (308:12): [True: 53, False: 0]
  |  Branch (308:27): [True: 53, False: 0]
  ------------------
  309|     53|    spec = digest_list_algo301[algo - 301];
  310|       |
  311|   129k|  if (spec)
  ------------------
  |  Branch (311:7): [True: 129k, False: 0]
  ------------------
  312|   129k|    gcry_assert (spec->algo == algo);
  ------------------
  |  |  188|   129k|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|   129k|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [True: 129k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|   129k|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
  313|       |
  314|      0|  return spec;
  315|   129k|}
md.c:map_algo:
  292|   129k|{
  293|   129k|  return algo;
  294|   129k|}
md.c:md_open:
  450|  1.23k|{
  451|  1.23k|  gcry_err_code_t err = 0;
  452|  1.23k|  int secure = !!(flags & GCRY_MD_FLAG_SECURE);
  453|  1.23k|  int hmac =   !!(flags & GCRY_MD_FLAG_HMAC);
  454|  1.23k|  int bufsize = secure ? 512 : 1024;
  ------------------
  |  Branch (454:17): [True: 0, False: 1.23k]
  ------------------
  455|  1.23k|  gcry_md_hd_t hd;
  456|  1.23k|  size_t n;
  457|       |
  458|       |  /* Allocate a memory area to hold the caller visible buffer with it's
  459|       |   * control information and the data required by this module. Set the
  460|       |   * context pointer at the beginning to this area.
  461|       |   * We have to use this strange scheme because we want to hide the
  462|       |   * internal data but have a variable sized buffer.
  463|       |   *
  464|       |   *	+---+------+---........------+-------------+
  465|       |   *	!ctx! bctl !  buffer	     ! private	   !
  466|       |   *	+---+------+---........------+-------------+
  467|       |   *	  !			      ^
  468|       |   *	  !---------------------------!
  469|       |   *
  470|       |   * We have to make sure that private is well aligned.
  471|       |   */
  472|  1.23k|  n = offsetof (struct gcry_md_handle, buf) + bufsize;
  473|  1.23k|  n = ((n + sizeof (PROPERLY_ALIGNED_TYPE) - 1)
  474|  1.23k|       / sizeof (PROPERLY_ALIGNED_TYPE)) * sizeof (PROPERLY_ALIGNED_TYPE);
  475|       |
  476|       |  /* Allocate and set the Context pointer to the private data */
  477|  1.23k|  if (secure)
  ------------------
  |  Branch (477:7): [True: 0, False: 1.23k]
  ------------------
  478|      0|    hd = xtrymalloc_secure (n + sizeof (struct gcry_md_context));
  ------------------
  |  |  140|      0|#define xtrymalloc_secure(a)   _gcry_malloc_secure ((a))
  ------------------
  479|  1.23k|  else
  480|  1.23k|    hd = xtrymalloc (n + sizeof (struct gcry_md_context));
  ------------------
  |  |  138|  1.23k|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  481|       |
  482|  1.23k|  if (! hd)
  ------------------
  |  Branch (482:7): [True: 0, False: 1.23k]
  ------------------
  483|      0|    err = gpg_err_code_from_errno (errno);
  484|       |
  485|  1.23k|  if (! err)
  ------------------
  |  Branch (485:7): [True: 1.23k, False: 0]
  ------------------
  486|  1.23k|    {
  487|  1.23k|      struct gcry_md_context *ctx;
  488|       |
  489|  1.23k|      ctx = (void *) (hd->buf - offsetof (struct gcry_md_handle, buf) + n);
  490|       |      /* Setup the globally visible data (bctl in the diagram).*/
  491|  1.23k|      hd->ctx = ctx;
  492|  1.23k|      hd->bufsize = n - offsetof (struct gcry_md_handle, buf);
  493|  1.23k|      hd->bufpos = 0;
  494|       |
  495|       |      /* Initialize the private data. */
  496|  1.23k|      wipememory2 (ctx, 0, sizeof *ctx);
  ------------------
  |  |  388|  1.23k|#define wipememory2(_ptr,_set,_len) do { \
  |  |  389|  1.23k|	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  ------------------
  |  |  |  |   87|  2.47k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  ------------------
  |  |               	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  ------------------
  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  ------------------
  |  |  |  Branch (389:12): [Folded - Ignored]
  |  |  |  Branch (389:33): [Folded - Ignored]
  |  |  ------------------
  |  |  390|      0|		if (CONSTANT_P(_set) && (_set) == 0) \
  |  |  ------------------
  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (87:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (390:27): [Folded - Ignored]
  |  |  ------------------
  |  |  391|      0|		  _gcry_fast_wipememory((void *)(_ptr), (_len)); \
  |  |  392|      0|		else \
  |  |  393|      0|		  _gcry_fast_wipememory2((void *)(_ptr), (_set), (_len)); \
  |  |  394|  1.23k|	      } else { \
  |  |  395|  1.23k|		fast_wipememory2_inline((void *)(_ptr), (_set), (_len)); \
  |  |  ------------------
  |  |  |  |  380|  1.23k|#define fast_wipememory2_inline(_ptr,_set,_len) do { \
  |  |  |  |  381|  1.23k|	      memset((_ptr), (_set), (_len)); \
  |  |  |  |  382|  1.23k|	      asm volatile ("\n" :: "r" (_ptr) : "memory"); \
  |  |  |  |  383|  1.23k|	    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (383:14): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  396|  1.23k|	      } \
  |  |  397|  1.23k|	    } while(0)
  |  |  ------------------
  |  |  |  Branch (397:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  497|  1.23k|      ctx->magic = secure ? CTX_MAGIC_SECURE : CTX_MAGIC_NORMAL;
  ------------------
  |  |  277|      0|#define CTX_MAGIC_SECURE 0x16917011
  ------------------
                    ctx->magic = secure ? CTX_MAGIC_SECURE : CTX_MAGIC_NORMAL;
  ------------------
  |  |  276|  2.47k|#define CTX_MAGIC_NORMAL 0x11071961
  ------------------
  |  Branch (497:20): [True: 0, False: 1.23k]
  ------------------
  498|  1.23k|      ctx->actual_handle_size = n + sizeof (struct gcry_md_context);
  499|  1.23k|      ctx->flags.secure = secure;
  500|  1.23k|      ctx->flags.hmac = hmac;
  501|  1.23k|      ctx->flags.bugemu1 = !!(flags & GCRY_MD_FLAG_BUGEMU1);
  502|  1.23k|    }
  503|       |
  504|  1.23k|  if (! err)
  ------------------
  |  Branch (504:7): [True: 1.23k, False: 0]
  ------------------
  505|  1.23k|    {
  506|       |      /* Hmmm, should we really do that? - yes [-wk] */
  507|  1.23k|      _gcry_fast_random_poll ();
  508|       |
  509|  1.23k|      if (algo)
  ------------------
  |  Branch (509:11): [True: 1.23k, False: 0]
  ------------------
  510|  1.23k|	{
  511|  1.23k|	  err = md_enable (hd, algo);
  512|  1.23k|	  if (err)
  ------------------
  |  Branch (512:8): [True: 0, False: 1.23k]
  ------------------
  513|      0|	    md_close (hd);
  514|  1.23k|	}
  515|  1.23k|    }
  516|       |
  517|  1.23k|  if (! err)
  ------------------
  |  Branch (517:7): [True: 1.23k, False: 0]
  ------------------
  518|  1.23k|    *h = hd;
  519|       |
  520|  1.23k|  return err;
  521|  1.23k|}
md.c:md_enable:
  549|  1.39k|{
  550|  1.39k|  struct gcry_md_context *h = hd->ctx;
  551|  1.39k|  const gcry_md_spec_t *spec;
  552|  1.39k|  GcryDigestEntry *entry;
  553|  1.39k|  gcry_err_code_t err = 0;
  554|       |
  555|  1.39k|  for (entry = h->list; entry; entry = entry->next)
  ------------------
  |  Branch (555:25): [True: 158, False: 1.23k]
  ------------------
  556|    158|    if (entry->spec->algo == algorithm)
  ------------------
  |  Branch (556:9): [True: 158, False: 0]
  ------------------
  557|    158|      return 0; /* Already enabled */
  558|       |
  559|  1.23k|  spec = spec_from_algo (algorithm);
  560|  1.23k|  if (!spec)
  ------------------
  |  Branch (560:7): [True: 0, False: 1.23k]
  ------------------
  561|      0|    {
  562|      0|      log_debug ("md_enable: algorithm %d not available\n", algorithm);
  ------------------
  |  |  205|      0|#define log_debug   _gcry_log_debug
  ------------------
  563|      0|      err = GPG_ERR_DIGEST_ALGO;
  564|      0|    }
  565|       |
  566|  1.23k|  if (!err && spec->flags.disabled)
  ------------------
  |  Branch (566:7): [True: 1.23k, False: 0]
  |  Branch (566:15): [True: 0, False: 1.23k]
  ------------------
  567|      0|    err = GPG_ERR_DIGEST_ALGO;
  568|       |
  569|       |  /* Any non-FIPS algorithm should go this way */
  570|  1.23k|  if (!err && !spec->flags.fips && fips_mode ())
  ------------------
  |  |  449|      0|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (570:7): [True: 1.23k, False: 0]
  |  Branch (570:15): [True: 0, False: 1.23k]
  ------------------
  571|      0|    err = GPG_ERR_DIGEST_ALGO;
  572|       |
  573|  1.23k|  if (!err && h->flags.hmac && spec->read == NULL)
  ------------------
  |  Branch (573:7): [True: 1.23k, False: 0]
  |  Branch (573:15): [True: 0, False: 1.23k]
  |  Branch (573:32): [True: 0, False: 0]
  ------------------
  574|      0|    {
  575|       |      /* Expandable output function cannot act as part of HMAC. */
  576|      0|      err = GPG_ERR_DIGEST_ALGO;
  577|      0|    }
  578|       |
  579|  1.23k|  if (!err)
  ------------------
  |  Branch (579:7): [True: 1.23k, False: 0]
  ------------------
  580|  1.23k|    {
  581|  1.23k|      size_t size = (sizeof (*entry)
  582|  1.23k|                     + spec->contextsize * (h->flags.hmac? 3 : 1)
  ------------------
  |  Branch (582:45): [True: 0, False: 1.23k]
  ------------------
  583|  1.23k|                     - sizeof (entry->context));
  584|       |
  585|       |      /* And allocate a new list entry. */
  586|  1.23k|      if (h->flags.secure)
  ------------------
  |  Branch (586:11): [True: 0, False: 1.23k]
  ------------------
  587|      0|	entry = xtrymalloc_secure (size);
  ------------------
  |  |  140|      0|#define xtrymalloc_secure(a)   _gcry_malloc_secure ((a))
  ------------------
  588|  1.23k|      else
  589|  1.23k|	entry = xtrymalloc (size);
  ------------------
  |  |  138|  1.23k|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  590|       |
  591|  1.23k|      if (! entry)
  ------------------
  |  Branch (591:11): [True: 0, False: 1.23k]
  ------------------
  592|      0|	err = gpg_err_code_from_errno (errno);
  593|  1.23k|      else
  594|  1.23k|	{
  595|  1.23k|	  entry->spec = spec;
  596|  1.23k|	  entry->next = h->list;
  597|  1.23k|          entry->actual_struct_size = size;
  598|  1.23k|	  h->list = entry;
  599|       |
  600|       |	  /* And init this instance. */
  601|  1.23k|	  entry->spec->init (entry->context,
  602|  1.23k|                             h->flags.bugemu1? GCRY_MD_FLAG_BUGEMU1:0);
  ------------------
  |  Branch (602:30): [True: 0, False: 1.23k]
  ------------------
  603|  1.23k|	}
  604|  1.23k|    }
  605|       |
  606|  1.23k|  return err;
  607|  1.39k|}
md.c:md_close:
  725|  1.23k|{
  726|  1.23k|  GcryDigestEntry *r, *r2;
  727|       |
  728|  1.23k|  if (! a)
  ------------------
  |  Branch (728:7): [True: 0, False: 1.23k]
  ------------------
  729|      0|    return;
  730|  1.23k|  if (a->ctx->debug)
  ------------------
  |  Branch (730:7): [True: 0, False: 1.23k]
  ------------------
  731|      0|    md_stop_debug (a);
  732|  2.47k|  for (r = a->ctx->list; r; r = r2)
  ------------------
  |  Branch (732:26): [True: 1.23k, False: 1.23k]
  ------------------
  733|  1.23k|    {
  734|  1.23k|      r2 = r->next;
  735|  1.23k|      wipememory (r, r->actual_struct_size);
  ------------------
  |  |  398|  1.23k|#define wipememory(_ptr,_len) wipememory2((_ptr),0,(_len))
  |  |  ------------------
  |  |  |  |  388|  1.23k|#define wipememory2(_ptr,_set,_len) do { \
  |  |  |  |  389|  1.23k|	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|  2.47k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |               	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (389:12): [True: 1.23k, False: 0]
  |  |  |  |  |  Branch (389:33): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  390|  1.23k|		if (CONSTANT_P(_set) && (_set) == 0) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|  2.47k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (87:27): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  391|  1.23k|		  _gcry_fast_wipememory((void *)(_ptr), (_len)); \
  |  |  |  |  392|  1.23k|		else \
  |  |  |  |  393|  1.23k|		  _gcry_fast_wipememory2((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  394|  1.23k|	      } else { \
  |  |  |  |  395|      0|		fast_wipememory2_inline((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  380|      0|#define fast_wipememory2_inline(_ptr,_set,_len) do { \
  |  |  |  |  |  |  381|      0|	      memset((_ptr), (_set), (_len)); \
  |  |  |  |  |  |  382|      0|	      asm volatile ("\n" :: "r" (_ptr) : "memory"); \
  |  |  |  |  |  |  383|      0|	    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (383:14): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  396|      0|	      } \
  |  |  |  |  397|  1.23k|	    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (397:14): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  736|  1.23k|      xfree (r);
  ------------------
  |  |  150|  1.23k|#define xfree(a)         _gcry_free ((a))
  ------------------
  737|  1.23k|    }
  738|       |
  739|  1.23k|  wipememory (a, a->ctx->actual_handle_size);
  ------------------
  |  |  398|  1.23k|#define wipememory(_ptr,_len) wipememory2((_ptr),0,(_len))
  |  |  ------------------
  |  |  |  |  388|  1.23k|#define wipememory2(_ptr,_set,_len) do { \
  |  |  |  |  389|  1.23k|	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|  2.47k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |               	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (389:12): [True: 1.23k, False: 0]
  |  |  |  |  |  Branch (389:33): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  390|  1.23k|		if (CONSTANT_P(_set) && (_set) == 0) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|  2.47k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (87:27): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  391|  1.23k|		  _gcry_fast_wipememory((void *)(_ptr), (_len)); \
  |  |  |  |  392|  1.23k|		else \
  |  |  |  |  393|  1.23k|		  _gcry_fast_wipememory2((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  394|  1.23k|	      } else { \
  |  |  |  |  395|      0|		fast_wipememory2_inline((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  380|      0|#define fast_wipememory2_inline(_ptr,_set,_len) do { \
  |  |  |  |  |  |  381|      0|	      memset((_ptr), (_set), (_len)); \
  |  |  |  |  |  |  382|      0|	      asm volatile ("\n" :: "r" (_ptr) : "memory"); \
  |  |  |  |  |  |  383|      0|	    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (383:14): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  396|      0|	      } \
  |  |  |  |  397|  1.23k|	    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (397:14): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  740|  1.23k|  xfree(a);
  ------------------
  |  |  150|  1.23k|#define xfree(a)         _gcry_free ((a))
  ------------------
  741|  1.23k|}
md.c:md_write:
  754|  2.82k|{
  755|  2.82k|  GcryDigestEntry *r;
  756|       |
  757|  2.82k|  if (a->ctx->debug)
  ------------------
  |  Branch (757:7): [True: 0, False: 2.82k]
  ------------------
  758|      0|    {
  759|      0|      if (a->bufpos && fwrite (a->buf, a->bufpos, 1, a->ctx->debug) != 1)
  ------------------
  |  Branch (759:11): [True: 0, False: 0]
  |  Branch (759:24): [True: 0, False: 0]
  ------------------
  760|      0|	BUG();
  ------------------
  |  |  187|      0|#define BUG() _gcry_bug( __FILE__ , __LINE__, __FUNCTION__ )
  ------------------
  761|      0|      if (inlen && fwrite (inbuf, inlen, 1, a->ctx->debug) != 1)
  ------------------
  |  Branch (761:11): [True: 0, False: 0]
  |  Branch (761:20): [True: 0, False: 0]
  ------------------
  762|      0|	BUG();
  ------------------
  |  |  187|      0|#define BUG() _gcry_bug( __FILE__ , __LINE__, __FUNCTION__ )
  ------------------
  763|      0|    }
  764|       |
  765|  5.65k|  for (r = a->ctx->list; r; r = r->next)
  ------------------
  |  Branch (765:26): [True: 2.82k, False: 2.82k]
  ------------------
  766|  2.82k|    {
  767|  2.82k|      if (a->bufpos)
  ------------------
  |  Branch (767:11): [True: 1.33k, False: 1.49k]
  ------------------
  768|  1.33k|	(*r->spec->write) (r->context, a->buf, a->bufpos);
  769|  2.82k|      (*r->spec->write) (r->context, inbuf, inlen);
  770|  2.82k|    }
  771|  2.82k|  a->bufpos = 0;
  772|  2.82k|}
md.c:md_final:
  787|  3.75k|{
  788|  3.75k|  GcryDigestEntry *r;
  789|       |
  790|  3.75k|  if (a->ctx->flags.finalized)
  ------------------
  |  Branch (790:7): [True: 1.08k, False: 2.67k]
  ------------------
  791|  1.08k|    return;
  792|       |
  793|  2.67k|  if (a->bufpos)
  ------------------
  |  Branch (793:7): [True: 253, False: 2.41k]
  ------------------
  794|    253|    md_write (a, NULL, 0);
  795|       |
  796|  5.34k|  for (r = a->ctx->list; r; r = r->next)
  ------------------
  |  Branch (796:26): [True: 2.67k, False: 2.67k]
  ------------------
  797|  2.67k|    (*r->spec->final) (r->context);
  798|       |
  799|  2.67k|  a->ctx->flags.finalized = 1;
  800|       |
  801|  2.67k|  if (!a->ctx->flags.hmac)
  ------------------
  |  Branch (801:7): [True: 2.67k, False: 0]
  ------------------
  802|  2.67k|    return;
  803|       |
  804|      0|  for (r = a->ctx->list; r; r = r->next)
  ------------------
  |  Branch (804:26): [True: 0, False: 0]
  ------------------
  805|      0|    {
  806|      0|      byte *p;
  807|      0|      size_t dlen = r->spec->mdlen;
  808|      0|      byte *hash;
  809|      0|      gcry_err_code_t err;
  810|       |
  811|      0|      if (r->spec->read == NULL)
  ------------------
  |  Branch (811:11): [True: 0, False: 0]
  ------------------
  812|      0|        continue;
  813|       |
  814|      0|      p = r->spec->read (r->context);
  815|       |
  816|      0|      if (a->ctx->flags.secure)
  ------------------
  |  Branch (816:11): [True: 0, False: 0]
  ------------------
  817|      0|        hash = xtrymalloc_secure (dlen);
  ------------------
  |  |  140|      0|#define xtrymalloc_secure(a)   _gcry_malloc_secure ((a))
  ------------------
  818|      0|      else
  819|      0|        hash = xtrymalloc (dlen);
  ------------------
  |  |  138|      0|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  820|      0|      if (!hash)
  ------------------
  |  Branch (820:11): [True: 0, False: 0]
  ------------------
  821|      0|        {
  822|      0|          err = gpg_err_code_from_errno (errno);
  823|      0|          _gcry_fatal_error (err, NULL);
  824|      0|        }
  825|       |
  826|      0|      memcpy (hash, p, dlen);
  827|      0|      memcpy (r->context, (char *)r->context + r->spec->contextsize * 2,
  828|      0|              r->spec->contextsize);
  829|      0|      (*r->spec->write) (r->context, hash, dlen);
  830|      0|      (*r->spec->final) (r->context);
  831|      0|      xfree (hash);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  832|      0|    }
  833|      0|}
md.c:md_read:
 1063|  1.10k|{
 1064|  1.10k|  GcryDigestEntry *r = a->ctx->list;
 1065|       |
 1066|  1.10k|  if (! algo)
  ------------------
  |  Branch (1066:7): [True: 1.01k, False: 89]
  ------------------
 1067|  1.01k|    {
 1068|       |      /* Return the first algorithm */
 1069|  1.01k|      if (r)
  ------------------
  |  Branch (1069:11): [True: 1.01k, False: 0]
  ------------------
 1070|  1.01k|        {
 1071|  1.01k|          if (r->next)
  ------------------
  |  Branch (1071:15): [True: 0, False: 1.01k]
  ------------------
 1072|      0|            log_debug ("more than one algorithm in md_read(0)\n");
  ------------------
  |  |  205|      0|#define log_debug   _gcry_log_debug
  ------------------
 1073|  1.01k|          if (r->spec->read)
  ------------------
  |  Branch (1073:15): [True: 1.01k, False: 0]
  ------------------
 1074|  1.01k|            return r->spec->read (r->context);
 1075|  1.01k|        }
 1076|  1.01k|    }
 1077|     89|  else
 1078|     89|    {
 1079|     89|      for (r = a->ctx->list; r; r = r->next)
  ------------------
  |  Branch (1079:30): [True: 89, False: 0]
  ------------------
 1080|     89|	if (r->spec->algo == algo)
  ------------------
  |  Branch (1080:6): [True: 89, False: 0]
  ------------------
 1081|     89|	  {
 1082|     89|	    if (r->spec->read)
  ------------------
  |  Branch (1082:10): [True: 89, False: 0]
  ------------------
 1083|     89|              return r->spec->read (r->context);
 1084|      0|            break;
 1085|     89|	  }
 1086|     89|    }
 1087|       |
 1088|      0|  if (r && !r->spec->read)
  ------------------
  |  Branch (1088:7): [True: 0, False: 0]
  |  Branch (1088:12): [True: 0, False: 0]
  ------------------
 1089|      0|    _gcry_fatal_error (GPG_ERR_DIGEST_ALGO,
 1090|      0|                       "requested algo has no fixed digest length");
 1091|      0|  else
 1092|      0|    _gcry_fatal_error (GPG_ERR_DIGEST_ALGO, "requested algo not in md context");
 1093|      0|  return NULL;
 1094|      0|}
md.c:md_get_algo:
 1342|  1.01k|{
 1343|  1.01k|  GcryDigestEntry *r = a->ctx->list;
 1344|       |
 1345|  1.01k|  if (r && r->next)
  ------------------
  |  Branch (1345:7): [True: 1.01k, False: 0]
  |  Branch (1345:12): [True: 0, False: 1.01k]
  ------------------
 1346|      0|    {
 1347|      0|      fips_signal_error ("possible usage error");
  ------------------
  |  |  459|      0|           _gcry_fips_signal_error (__FILE__, __LINE__, __FUNCTION__, 0, (a))
  ------------------
 1348|      0|      log_error ("WARNING: more than one algorithm in md_get_algo()\n");
  ------------------
  |  |  203|      0|#define log_error   _gcry_log_error
  ------------------
 1349|      0|    }
 1350|  1.01k|  return r ? r->spec->algo : 0;
  ------------------
  |  Branch (1350:10): [True: 1.01k, False: 0]
  ------------------
 1351|  1.01k|}
md.c:md_digest_length:
 1366|  1.17k|{
 1367|  1.17k|  const gcry_md_spec_t *spec;
 1368|       |
 1369|  1.17k|  spec = spec_from_algo (algorithm);
 1370|  1.17k|  return spec? spec->mdlen : 0;
  ------------------
  |  Branch (1370:10): [True: 1.17k, False: 0]
  ------------------
 1371|  1.17k|}
md.c:check_digest_algo:
  431|   126k|{
  432|   126k|  const gcry_md_spec_t *spec;
  433|       |
  434|   126k|  spec = spec_from_algo (algorithm);
  435|   126k|  if (spec && !spec->flags.disabled && (spec->flags.fips || !fips_mode ()))
  ------------------
  |  |  449|  78.0k|#define fips_mode() (!_gcry_no_fips_mode_required)
  ------------------
  |  Branch (435:7): [True: 126k, False: 0]
  |  Branch (435:15): [True: 126k, False: 0]
  |  Branch (435:41): [True: 48.9k, False: 78.0k]
  |  Branch (435:61): [True: 78.0k, False: 0]
  ------------------
  436|   126k|    return 0;
  437|       |
  438|      0|  return GPG_ERR_DIGEST_ALGO;
  439|       |
  440|   126k|}
md.c:md_asn_oid:
 1389|    284|{
 1390|    284|  const gcry_md_spec_t *spec;
 1391|    284|  const byte *asnoid = NULL;
 1392|       |
 1393|    284|  spec = spec_from_algo (algorithm);
 1394|    284|  if (spec)
  ------------------
  |  Branch (1394:7): [True: 284, False: 0]
  ------------------
 1395|    284|    {
 1396|    284|      if (asnlen)
  ------------------
  |  Branch (1396:11): [True: 284, False: 0]
  ------------------
 1397|    284|	*asnlen = spec->asnlen;
 1398|    284|      if (mdlen)
  ------------------
  |  Branch (1398:11): [True: 0, False: 284]
  ------------------
 1399|      0|	*mdlen = spec->mdlen;
 1400|    284|      asnoid = spec->asnoid;
 1401|    284|    }
 1402|      0|  else
 1403|      0|    log_bug ("no ASN.1 OID for md algo %d\n", algorithm);
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
 1404|       |
 1405|    284|  return asnoid;
 1406|    284|}

_gcry_primegen_init:
  148|      1|{
  149|       |  /* This function was formerly used to initialize the primepool
  150|       |     Mutex. This has been replace by a static initialization.  */
  151|      1|  return 0;
  152|      1|}

_gcry_pk_util_get_nbits:
  292|     16|{
  293|     16|  char buf[50];
  294|     16|  const char *s;
  295|     16|  size_t n;
  296|       |
  297|     16|  *r_nbits = 0;
  298|       |
  299|     16|  list = sexp_find_token (list, "nbits", 0);
  ------------------
  |  |  381|     16|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  300|     16|  if (!list)
  ------------------
  |  Branch (300:7): [True: 16, False: 0]
  ------------------
  301|     16|    return 0; /* No NBITS found.  */
  302|       |
  303|      0|  s = sexp_nth_data (list, 1, &n);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
  304|      0|  if (!s || n >= DIM (buf) - 1 )
  ------------------
  |  |  104|      0|#define DIM(v) (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (304:7): [True: 0, False: 0]
  |  Branch (304:13): [True: 0, False: 0]
  ------------------
  305|      0|    {
  306|       |      /* NBITS given without a cdr.  */
  307|      0|      sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  308|      0|      return GPG_ERR_INV_OBJ;
  309|      0|    }
  310|      0|  memcpy (buf, s, n);
  311|      0|  buf[n] = 0;
  312|      0|  *r_nbits = (unsigned int)strtoul (buf, NULL, 0);
  313|      0|  sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  314|      0|  return 0;
  315|      0|}
_gcry_pk_util_preparse_sigval:
  378|     31|{
  379|     31|  gpg_err_code_t rc;
  380|     31|  gcry_sexp_t l1 = NULL;
  381|     31|  gcry_sexp_t l2 = NULL;
  382|     31|  char *name = NULL;
  383|     31|  int i;
  384|       |
  385|     31|  *r_parms = NULL;
  386|     31|  if (r_eccflags)
  ------------------
  |  Branch (386:7): [True: 16, False: 15]
  ------------------
  387|     16|    *r_eccflags = 0;
  388|       |
  389|       |  /* Extract the signature value.  */
  390|     31|  l1 = sexp_find_token (s_sig, "sig-val", 0);
  ------------------
  |  |  381|     31|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  391|     31|  if (!l1)
  ------------------
  |  Branch (391:7): [True: 0, False: 31]
  ------------------
  392|      0|    {
  393|      0|      rc = GPG_ERR_INV_OBJ; /* Does not contain a signature value object.  */
  394|      0|      goto leave;
  395|      0|    }
  396|       |
  397|     31|  l2 = sexp_nth (l1, 1);
  ------------------
  |  |  383|     31|#define sexp_nth(a, b)               _gcry_sexp_nth ((a), (b))
  ------------------
  398|     31|  if (!l2)
  ------------------
  |  Branch (398:7): [True: 0, False: 31]
  ------------------
  399|      0|    {
  400|      0|      rc = GPG_ERR_NO_OBJ;   /* No cadr for the sig object.  */
  401|      0|      goto leave;
  402|      0|    }
  403|     31|  name = sexp_nth_string (l2, 0);
  ------------------
  |  |  389|     31|#define sexp_nth_string(a, b)        _gcry_sexp_nth_string ((a), (b))
  ------------------
  404|     31|  if (!name)
  ------------------
  |  Branch (404:7): [True: 0, False: 31]
  ------------------
  405|      0|    {
  406|      0|      rc = GPG_ERR_INV_OBJ;  /* Invalid structure of object.  */
  407|      0|      goto leave;
  408|      0|    }
  409|     31|  else if (!strcmp (name, "flags"))
  ------------------
  |  Branch (409:12): [True: 0, False: 31]
  ------------------
  410|      0|    {
  411|       |      /* Skip a "flags" parameter and look again for the algorithm
  412|       |	 name.  This is not used but here just for the sake of
  413|       |	 consistent S-expressions we need to handle it. */
  414|      0|      sexp_release (l2);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  415|      0|      l2 = sexp_nth (l1, 2);
  ------------------
  |  |  383|      0|#define sexp_nth(a, b)               _gcry_sexp_nth ((a), (b))
  ------------------
  416|      0|      if (!l2)
  ------------------
  |  Branch (416:11): [True: 0, False: 0]
  ------------------
  417|      0|	{
  418|      0|	  rc = GPG_ERR_INV_OBJ;
  419|      0|          goto leave;
  420|      0|	}
  421|      0|      xfree (name);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  422|      0|      name = sexp_nth_string (l2, 0);
  ------------------
  |  |  389|      0|#define sexp_nth_string(a, b)        _gcry_sexp_nth_string ((a), (b))
  ------------------
  423|      0|      if (!name)
  ------------------
  |  Branch (423:11): [True: 0, False: 0]
  ------------------
  424|      0|        {
  425|      0|          rc = GPG_ERR_INV_OBJ;  /* Invalid structure of object.  */
  426|      0|          goto leave;
  427|      0|        }
  428|      0|    }
  429|       |
  430|     47|  for (i=0; algo_names[i]; i++)
  ------------------
  |  Branch (430:13): [True: 47, False: 0]
  ------------------
  431|     47|    if (!stricmp (name, algo_names[i]))
  ------------------
  |  |  351|     47|#define stricmp(a,b)	 strcasecmp( (a), (b) )
  ------------------
  |  Branch (431:9): [True: 31, False: 16]
  ------------------
  432|     31|      break;
  433|     31|  if (!algo_names[i])
  ------------------
  |  Branch (433:7): [True: 0, False: 31]
  ------------------
  434|      0|    {
  435|      0|      rc = GPG_ERR_CONFLICT; /* "sig-val" uses an unexpected algo. */
  436|      0|      goto leave;
  437|      0|    }
  438|     31|  if (r_eccflags)
  ------------------
  |  Branch (438:7): [True: 16, False: 15]
  ------------------
  439|     16|    {
  440|     16|      if (!strcmp (name, "eddsa"))
  ------------------
  |  Branch (440:11): [True: 0, False: 16]
  ------------------
  441|      0|        *r_eccflags = PUBKEY_FLAG_EDDSA;
  ------------------
  |  |   41|      0|#define PUBKEY_FLAG_EDDSA          (1 << 12)
  ------------------
  442|     16|      if (!strcmp (name, "gost"))
  ------------------
  |  Branch (442:11): [True: 0, False: 16]
  ------------------
  443|      0|        *r_eccflags = PUBKEY_FLAG_GOST;
  ------------------
  |  |   42|      0|#define PUBKEY_FLAG_GOST           (1 << 13)
  ------------------
  444|     16|      if (!strcmp (name, "sm2"))
  ------------------
  |  Branch (444:11): [True: 0, False: 16]
  ------------------
  445|      0|        *r_eccflags = PUBKEY_FLAG_SM2;
  ------------------
  |  |   45|      0|#define PUBKEY_FLAG_SM2            (1 << 16)
  ------------------
  446|     16|    }
  447|       |
  448|     31|  *r_parms = l2;
  449|     31|  l2 = NULL;
  450|     31|  rc = 0;
  451|       |
  452|     31| leave:
  453|     31|  xfree (name);
  ------------------
  |  |  150|     31|#define xfree(a)         _gcry_free ((a))
  ------------------
  454|     31|  sexp_release (l2);
  ------------------
  |  |  372|     31|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  455|     31|  sexp_release (l1);
  ------------------
  |  |  372|     31|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  456|     31|  return rc;
  457|     31|}
_gcry_pk_util_init_encoding_ctx:
  630|     31|{
  631|     31|  ctx->op = op;
  632|     31|  ctx->nbits = nbits;
  633|     31|  ctx->encoding = PUBKEY_ENC_UNKNOWN;
  634|     31|  ctx->flags = 0;
  635|     31|  if (fips_mode ())
  ------------------
  |  |  449|     31|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 31]
  |  |  ------------------
  ------------------
  636|      0|    {
  637|      0|      ctx->hash_algo = GCRY_MD_SHA256;
  638|      0|    }
  639|     31|  else
  640|     31|    {
  641|     31|      ctx->hash_algo = GCRY_MD_SHA1;
  642|     31|    }
  643|     31|  ctx->label = NULL;
  644|     31|  ctx->labellen = 0;
  645|     31|  ctx->saltlen = 20;
  646|     31|  ctx->verify_cmp = NULL;
  647|     31|  ctx->verify_arg = NULL;
  648|     31|}
_gcry_pk_util_free_encoding_ctx:
  653|     31|{
  654|     31|  xfree (ctx->label);
  ------------------
  |  |  150|     31|#define xfree(a)         _gcry_free ((a))
  ------------------
  655|     31|}
_gcry_pk_util_data_to_mpi:
  691|     31|{
  692|     31|  gcry_err_code_t rc = 0;
  693|     31|  gcry_sexp_t ldata, lhash, lvalue;
  694|     31|  size_t n;
  695|     31|  const char *s;
  696|     31|  int unknown_flag = 0;
  697|     31|  int parsed_flags = 0;
  698|       |
  699|     31|  *ret_mpi = NULL;
  700|     31|  ldata = sexp_find_token (input, "data", 0);
  ------------------
  |  |  381|     31|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  701|     31|  if (!ldata)
  ------------------
  |  Branch (701:7): [True: 31, False: 0]
  ------------------
  702|     31|    { /* assume old style */
  703|     31|      int mpifmt = (ctx->flags & PUBKEY_FLAG_RAW_FLAG) ?
  ------------------
  |  |   33|     31|#define PUBKEY_FLAG_RAW_FLAG       (1 << 4)
  ------------------
  |  Branch (703:20): [True: 0, False: 31]
  ------------------
  704|     31|        GCRYMPI_FMT_OPAQUE : GCRYMPI_FMT_STD;
  705|       |
  706|     31|      *ret_mpi = sexp_nth_mpi (input, 0, mpifmt);
  ------------------
  |  |  390|     31|#define sexp_nth_mpi(a, b, c)        _gcry_sexp_nth_mpi ((a), (b), (c))
  ------------------
  707|     31|      return *ret_mpi ? GPG_ERR_NO_ERROR : GPG_ERR_INV_OBJ;
  ------------------
  |  Branch (707:14): [True: 31, False: 0]
  ------------------
  708|     31|    }
  709|       |
  710|       |  /* See whether there is a flags list.  */
  711|      0|  {
  712|      0|    gcry_sexp_t lflags = sexp_find_token (ldata, "flags", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  713|      0|    if (lflags)
  ------------------
  |  Branch (713:9): [True: 0, False: 0]
  ------------------
  714|      0|      {
  715|      0|        if (_gcry_pk_util_parse_flaglist (lflags,
  ------------------
  |  Branch (715:13): [True: 0, False: 0]
  ------------------
  716|      0|                                          &parsed_flags, &ctx->encoding))
  717|      0|          unknown_flag = 1;
  718|      0|        sexp_release (lflags);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  719|      0|      }
  720|      0|  }
  721|       |
  722|      0|  if (ctx->encoding == PUBKEY_ENC_UNKNOWN)
  ------------------
  |  Branch (722:7): [True: 0, False: 0]
  ------------------
  723|      0|    ctx->encoding = PUBKEY_ENC_RAW; /* default to raw */
  724|       |
  725|       |  /* Get HASH or MPI */
  726|      0|  lhash = sexp_find_token (ldata, "hash", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  727|      0|  lvalue = lhash? NULL : sexp_find_token (ldata, "value", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  |  Branch (727:12): [True: 0, False: 0]
  ------------------
  728|       |
  729|      0|  if (!(!lhash ^ !lvalue))
  ------------------
  |  Branch (729:7): [True: 0, False: 0]
  ------------------
  730|      0|    rc = GPG_ERR_INV_OBJ; /* none or both given */
  731|      0|  else if (unknown_flag)
  ------------------
  |  Branch (731:12): [True: 0, False: 0]
  ------------------
  732|      0|    rc = GPG_ERR_INV_FLAG;
  733|      0|  else if (ctx->encoding == PUBKEY_ENC_RAW
  ------------------
  |  Branch (733:12): [True: 0, False: 0]
  ------------------
  734|      0|           && ((parsed_flags & PUBKEY_FLAG_EDDSA)
  ------------------
  |  |   41|      0|#define PUBKEY_FLAG_EDDSA          (1 << 12)
  ------------------
  |  Branch (734:16): [True: 0, False: 0]
  ------------------
  735|      0|               || (ctx->flags & PUBKEY_FLAG_EDDSA)))
  ------------------
  |  |   41|      0|#define PUBKEY_FLAG_EDDSA          (1 << 12)
  ------------------
  |  Branch (735:19): [True: 0, False: 0]
  ------------------
  736|      0|    {
  737|       |      /* Prepare for EdDSA.  */
  738|      0|      gcry_sexp_t list;
  739|      0|      void *value;
  740|      0|      size_t valuelen;
  741|       |
  742|      0|      if (!lvalue)
  ------------------
  |  Branch (742:11): [True: 0, False: 0]
  ------------------
  743|      0|        {
  744|      0|          rc = GPG_ERR_INV_OBJ;
  745|      0|          goto leave;
  746|      0|        }
  747|       |      /* Hash algo is determined by curve.  No hash-algo is OK.  */
  748|       |      /* Get HASH-ALGO. */
  749|      0|      list = sexp_find_token (ldata, "hash-algo", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  750|      0|      if (list)
  ------------------
  |  Branch (750:11): [True: 0, False: 0]
  ------------------
  751|      0|        {
  752|      0|          s = sexp_nth_data (list, 1, &n);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
  753|      0|          if (!s)
  ------------------
  |  Branch (753:15): [True: 0, False: 0]
  ------------------
  754|      0|            rc = GPG_ERR_NO_OBJ;
  755|      0|          else
  756|      0|            {
  757|      0|              ctx->hash_algo = get_hash_algo (s, n);
  758|      0|              if (!ctx->hash_algo)
  ------------------
  |  Branch (758:19): [True: 0, False: 0]
  ------------------
  759|      0|                rc = GPG_ERR_DIGEST_ALGO;
  760|      0|            }
  761|      0|          sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  762|      0|        }
  763|      0|      if (rc)
  ------------------
  |  Branch (763:11): [True: 0, False: 0]
  ------------------
  764|      0|        goto leave;
  765|       |
  766|       |      /* Get LABEL. */
  767|      0|      list = sexp_find_token (ldata, "label", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  768|      0|      if (list)
  ------------------
  |  Branch (768:11): [True: 0, False: 0]
  ------------------
  769|      0|        {
  770|      0|          s = sexp_nth_data (list, 1, &n);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
  771|      0|          if (!s)
  ------------------
  |  Branch (771:15): [True: 0, False: 0]
  ------------------
  772|      0|            rc = GPG_ERR_NO_OBJ;
  773|      0|          else if (n > 0)
  ------------------
  |  Branch (773:20): [True: 0, False: 0]
  ------------------
  774|      0|            {
  775|      0|              ctx->label = xtrymalloc (n);
  ------------------
  |  |  138|      0|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  776|      0|              if (!ctx->label)
  ------------------
  |  Branch (776:19): [True: 0, False: 0]
  ------------------
  777|      0|                rc = gpg_err_code_from_syserror ();
  778|      0|              else
  779|      0|                {
  780|      0|                  memcpy (ctx->label, s, n);
  781|      0|                  ctx->labellen = n;
  782|      0|                }
  783|      0|            }
  784|      0|          sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  785|      0|          if (rc)
  ------------------
  |  Branch (785:15): [True: 0, False: 0]
  ------------------
  786|      0|            goto leave;
  787|      0|        }
  788|       |
  789|       |      /* Get VALUE.  */
  790|      0|      value = sexp_nth_buffer (lvalue, 1, &valuelen);
  ------------------
  |  |  388|      0|#define sexp_nth_buffer(a, b, c)     _gcry_sexp_nth_buffer ((a), (b), (c))
  ------------------
  791|      0|      if (!value)
  ------------------
  |  Branch (791:11): [True: 0, False: 0]
  ------------------
  792|      0|        {
  793|       |          /* We assume that a zero length message is meant by
  794|       |             "(value)".  This is commonly used by test vectors.  Note
  795|       |             that S-expression do not allow zero length items. */
  796|      0|          valuelen = 0;
  797|      0|          value = xtrymalloc (1);
  ------------------
  |  |  138|      0|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  798|      0|          if (!value)
  ------------------
  |  Branch (798:15): [True: 0, False: 0]
  ------------------
  799|      0|            rc = gpg_err_code_from_syserror ();
  800|      0|        }
  801|      0|      else if ((valuelen * 8) < valuelen)
  ------------------
  |  Branch (801:16): [True: 0, False: 0]
  ------------------
  802|      0|        {
  803|      0|          xfree (value);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  804|      0|          rc = GPG_ERR_TOO_LARGE;
  805|      0|        }
  806|      0|      if (rc)
  ------------------
  |  Branch (806:11): [True: 0, False: 0]
  ------------------
  807|      0|        goto leave;
  808|       |
  809|       |      /* Note that mpi_set_opaque takes ownership of VALUE.  */
  810|      0|      *ret_mpi = mpi_set_opaque (NULL, value, valuelen*8);
  ------------------
  |  |  561|      0|#define mpi_set_opaque(a,b,c)  _gcry_mpi_set_opaque ((a), (b), (c))
  ------------------
  811|      0|    }
  812|      0|  else if (ctx->encoding == PUBKEY_ENC_RAW
  ------------------
  |  Branch (812:12): [True: 0, False: 0]
  ------------------
  813|      0|           && (lhash || (lvalue && (parsed_flags & PUBKEY_FLAG_PREHASH)))
  ------------------
  |  |   46|      0|#define PUBKEY_FLAG_PREHASH        (1 << 17)
  ------------------
  |  Branch (813:16): [True: 0, False: 0]
  |  Branch (813:26): [True: 0, False: 0]
  |  Branch (813:36): [True: 0, False: 0]
  ------------------
  814|      0|           && ((parsed_flags & PUBKEY_FLAG_RAW_FLAG)
  ------------------
  |  |   33|      0|#define PUBKEY_FLAG_RAW_FLAG       (1 << 4)
  ------------------
  |  Branch (814:16): [True: 0, False: 0]
  ------------------
  815|      0|               || (parsed_flags & PUBKEY_FLAG_RFC6979)))
  ------------------
  |  |   30|      0|#define PUBKEY_FLAG_RFC6979        (1 << 1)
  ------------------
  |  Branch (815:19): [True: 0, False: 0]
  ------------------
  816|      0|    {
  817|      0|      void * value;
  818|      0|      size_t valuelen;
  819|      0|      gcry_sexp_t list;
  820|       |
  821|       |      /* Raw encoding along with a hash element.  This is commonly
  822|       |         used for DSA.  For better backward error compatibility we
  823|       |         allow this only if either the rfc6979 flag has been given or
  824|       |         the raw flags was explicitly given.  */
  825|       |
  826|      0|      if (lvalue && (parsed_flags & PUBKEY_FLAG_PREHASH))
  ------------------
  |  |   46|      0|#define PUBKEY_FLAG_PREHASH        (1 << 17)
  ------------------
  |  Branch (826:11): [True: 0, False: 0]
  |  Branch (826:21): [True: 0, False: 0]
  ------------------
  827|      0|        {
  828|       |          /* Get HASH-ALGO. */
  829|      0|          list = sexp_find_token (ldata, "hash-algo", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  830|      0|          if (list)
  ------------------
  |  Branch (830:15): [True: 0, False: 0]
  ------------------
  831|      0|            {
  832|      0|              s = sexp_nth_data (list, 1, &n);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
  833|      0|              if (!s)
  ------------------
  |  Branch (833:19): [True: 0, False: 0]
  ------------------
  834|      0|                rc = GPG_ERR_NO_OBJ;
  835|      0|              else
  836|      0|                {
  837|      0|                  ctx->hash_algo = get_hash_algo (s, n);
  838|      0|                  if (!ctx->hash_algo)
  ------------------
  |  Branch (838:23): [True: 0, False: 0]
  ------------------
  839|      0|                    rc = GPG_ERR_DIGEST_ALGO;
  840|      0|                }
  841|      0|              sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  842|      0|              if (rc)
  ------------------
  |  Branch (842:19): [True: 0, False: 0]
  ------------------
  843|      0|                goto leave;
  844|      0|            }
  845|       |
  846|       |          /* Get optional LABEL.  */
  847|      0|          list = sexp_find_token (ldata, "label", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  848|      0|          if (list)
  ------------------
  |  Branch (848:15): [True: 0, False: 0]
  ------------------
  849|      0|            {
  850|      0|              s = sexp_nth_data (list, 1, &n);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
  851|      0|              if (!s)
  ------------------
  |  Branch (851:19): [True: 0, False: 0]
  ------------------
  852|      0|                rc = GPG_ERR_NO_OBJ;
  853|      0|              else if (n > 0)
  ------------------
  |  Branch (853:24): [True: 0, False: 0]
  ------------------
  854|      0|                {
  855|      0|                  ctx->label = xtrymalloc (n);
  ------------------
  |  |  138|      0|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  856|      0|                  if (!ctx->label)
  ------------------
  |  Branch (856:23): [True: 0, False: 0]
  ------------------
  857|      0|                    rc = gpg_err_code_from_syserror ();
  858|      0|                  else
  859|      0|                    {
  860|      0|                      memcpy (ctx->label, s, n);
  861|      0|                      ctx->labellen = n;
  862|      0|                    }
  863|      0|                }
  864|      0|              else
  865|      0|                rc = GPG_ERR_INV_ARG;
  866|      0|              sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  867|      0|              if (rc)
  ------------------
  |  Branch (867:19): [True: 0, False: 0]
  ------------------
  868|      0|                goto leave;
  869|      0|            }
  870|       |
  871|      0|          if ( !(value=sexp_nth_buffer (lvalue, 1, &valuelen)) || !valuelen )
  ------------------
  |  |  388|      0|#define sexp_nth_buffer(a, b, c)     _gcry_sexp_nth_buffer ((a), (b), (c))
  ------------------
  |  Branch (871:16): [True: 0, False: 0]
  |  Branch (871:67): [True: 0, False: 0]
  ------------------
  872|      0|            rc = GPG_ERR_INV_OBJ;
  873|      0|          else if ((valuelen * 8) < valuelen)
  ------------------
  |  Branch (873:20): [True: 0, False: 0]
  ------------------
  874|      0|            {
  875|      0|              xfree (value);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  876|      0|              rc = GPG_ERR_TOO_LARGE;
  877|      0|            }
  878|      0|          else
  879|      0|            *ret_mpi = mpi_set_opaque (NULL, value, valuelen*8);
  ------------------
  |  |  561|      0|#define mpi_set_opaque(a,b,c)  _gcry_mpi_set_opaque ((a), (b), (c))
  ------------------
  880|      0|        }
  881|      0|      else if (lhash)
  ------------------
  |  Branch (881:16): [True: 0, False: 0]
  ------------------
  882|      0|        {
  883|       |          /* Get optional LABEL.  */
  884|      0|          list = sexp_find_token (ldata, "label", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  885|      0|          if (list)
  ------------------
  |  Branch (885:15): [True: 0, False: 0]
  ------------------
  886|      0|            {
  887|      0|              s = sexp_nth_data (list, 1, &n);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
  888|      0|              if (!s)
  ------------------
  |  Branch (888:19): [True: 0, False: 0]
  ------------------
  889|      0|                rc = GPG_ERR_NO_OBJ;
  890|      0|              else if (n > 0)
  ------------------
  |  Branch (890:24): [True: 0, False: 0]
  ------------------
  891|      0|                {
  892|      0|                  ctx->label = xtrymalloc (n);
  ------------------
  |  |  138|      0|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  893|      0|                  if (!ctx->label)
  ------------------
  |  Branch (893:23): [True: 0, False: 0]
  ------------------
  894|      0|                    rc = gpg_err_code_from_syserror ();
  895|      0|                  else
  896|      0|                    {
  897|      0|                      memcpy (ctx->label, s, n);
  898|      0|                      ctx->labellen = n;
  899|      0|                    }
  900|      0|                }
  901|      0|              else
  902|      0|                rc = GPG_ERR_INV_ARG;
  903|      0|              sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  904|      0|              if (rc)
  ------------------
  |  Branch (904:19): [True: 0, False: 0]
  ------------------
  905|      0|                goto leave;
  906|      0|            }
  907|       |
  908|      0|          if (sexp_length (lhash) != 3)
  ------------------
  |  |  382|      0|#define sexp_length(a)               _gcry_sexp_length ((a))
  ------------------
  |  Branch (908:15): [True: 0, False: 0]
  ------------------
  909|      0|            rc = GPG_ERR_INV_OBJ;
  910|      0|          else if ( !(s=sexp_nth_data (lhash, 1, &n)) || !n )
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
  |  Branch (910:21): [True: 0, False: 0]
  |  Branch (910:58): [True: 0, False: 0]
  ------------------
  911|      0|            rc = GPG_ERR_INV_OBJ;
  912|      0|          else
  913|      0|            {
  914|      0|              ctx->hash_algo = get_hash_algo (s, n);
  915|       |
  916|      0|              if (!ctx->hash_algo)
  ------------------
  |  Branch (916:19): [True: 0, False: 0]
  ------------------
  917|      0|                rc = GPG_ERR_DIGEST_ALGO;
  918|      0|              else if ( !(value=sexp_nth_buffer (lhash, 2, &valuelen))
  ------------------
  |  |  388|      0|#define sexp_nth_buffer(a, b, c)     _gcry_sexp_nth_buffer ((a), (b), (c))
  ------------------
  |  Branch (918:25): [True: 0, False: 0]
  ------------------
  919|      0|                        || !valuelen )
  ------------------
  |  Branch (919:28): [True: 0, False: 0]
  ------------------
  920|      0|                rc = GPG_ERR_INV_OBJ;
  921|      0|              else if ((valuelen * 8) < valuelen)
  ------------------
  |  Branch (921:24): [True: 0, False: 0]
  ------------------
  922|      0|                {
  923|      0|                  xfree (value);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  924|      0|                  rc = GPG_ERR_TOO_LARGE;
  925|      0|                }
  926|      0|              else
  927|      0|                *ret_mpi = mpi_set_opaque (NULL, value, valuelen*8);
  ------------------
  |  |  561|      0|#define mpi_set_opaque(a,b,c)  _gcry_mpi_set_opaque ((a), (b), (c))
  ------------------
  928|      0|            }
  929|      0|        }
  930|      0|      else
  931|      0|        rc = GPG_ERR_CONFLICT;
  932|       |
  933|      0|      if (rc)
  ------------------
  |  Branch (933:11): [True: 0, False: 0]
  ------------------
  934|      0|        goto leave;
  935|      0|    }
  936|      0|  else if (ctx->encoding == PUBKEY_ENC_RAW && lvalue)
  ------------------
  |  Branch (936:12): [True: 0, False: 0]
  |  Branch (936:47): [True: 0, False: 0]
  ------------------
  937|      0|    {
  938|       |      /* RFC6979 may only be used with the a hash value and not the
  939|       |         MPI based value.  */
  940|      0|      if (parsed_flags & PUBKEY_FLAG_RFC6979)
  ------------------
  |  |   30|      0|#define PUBKEY_FLAG_RFC6979        (1 << 1)
  ------------------
  |  Branch (940:11): [True: 0, False: 0]
  ------------------
  941|      0|        {
  942|      0|          rc = GPG_ERR_CONFLICT;
  943|      0|          goto leave;
  944|      0|        }
  945|       |
  946|       |      /* Get the value */
  947|      0|      *ret_mpi = sexp_nth_mpi (lvalue, 1, GCRYMPI_FMT_USG);
  ------------------
  |  |  390|      0|#define sexp_nth_mpi(a, b, c)        _gcry_sexp_nth_mpi ((a), (b), (c))
  ------------------
  948|      0|      if (!*ret_mpi)
  ------------------
  |  Branch (948:11): [True: 0, False: 0]
  ------------------
  949|      0|        rc = GPG_ERR_INV_OBJ;
  950|      0|    }
  951|      0|  else if (ctx->encoding == PUBKEY_ENC_PKCS1 && lvalue
  ------------------
  |  Branch (951:12): [True: 0, False: 0]
  |  Branch (951:49): [True: 0, False: 0]
  ------------------
  952|      0|	   && ctx->op == PUBKEY_OP_ENCRYPT)
  ------------------
  |  Branch (952:8): [True: 0, False: 0]
  ------------------
  953|      0|    {
  954|      0|      const void * value;
  955|      0|      size_t valuelen;
  956|      0|      gcry_sexp_t list;
  957|      0|      void *random_override = NULL;
  958|      0|      size_t random_override_len = 0;
  959|       |
  960|      0|      if ( !(value=sexp_nth_data (lvalue, 1, &valuelen)) || !valuelen )
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
  |  Branch (960:12): [True: 0, False: 0]
  |  Branch (960:61): [True: 0, False: 0]
  ------------------
  961|      0|        rc = GPG_ERR_INV_OBJ;
  962|      0|      else
  963|      0|        {
  964|       |          /* Get optional RANDOM-OVERRIDE.  */
  965|      0|          list = sexp_find_token (ldata, "random-override", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  966|      0|          if (list)
  ------------------
  |  Branch (966:15): [True: 0, False: 0]
  ------------------
  967|      0|            {
  968|      0|              s = sexp_nth_data (list, 1, &n);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
  969|      0|              if (!s)
  ------------------
  |  Branch (969:19): [True: 0, False: 0]
  ------------------
  970|      0|                rc = GPG_ERR_NO_OBJ;
  971|      0|              else if (n > 0)
  ------------------
  |  Branch (971:24): [True: 0, False: 0]
  ------------------
  972|      0|                {
  973|      0|                  random_override = xtrymalloc (n);
  ------------------
  |  |  138|      0|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  974|      0|                  if (!random_override)
  ------------------
  |  Branch (974:23): [True: 0, False: 0]
  ------------------
  975|      0|                    rc = gpg_err_code_from_syserror ();
  976|      0|                  else
  977|      0|                    {
  978|      0|                      memcpy (random_override, s, n);
  979|      0|                      random_override_len = n;
  980|      0|                    }
  981|      0|                }
  982|      0|              sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  983|      0|              if (rc)
  ------------------
  |  Branch (983:19): [True: 0, False: 0]
  ------------------
  984|      0|                goto leave;
  985|      0|            }
  986|       |
  987|      0|          rc = _gcry_rsa_pkcs1_encode_for_enc (ret_mpi, ctx->nbits,
  988|      0|                                               value, valuelen,
  989|      0|                                               random_override,
  990|      0|                                               random_override_len);
  991|      0|          xfree (random_override);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  992|      0|        }
  993|      0|    }
  994|      0|  else if (ctx->encoding == PUBKEY_ENC_PKCS1
  ------------------
  |  Branch (994:12): [True: 0, False: 0]
  ------------------
  995|      0|           && (lhash || (lvalue && (parsed_flags & PUBKEY_FLAG_PREHASH)))
  ------------------
  |  |   46|      0|#define PUBKEY_FLAG_PREHASH        (1 << 17)
  ------------------
  |  Branch (995:16): [True: 0, False: 0]
  |  Branch (995:26): [True: 0, False: 0]
  |  Branch (995:36): [True: 0, False: 0]
  ------------------
  996|      0|	   && (ctx->op == PUBKEY_OP_SIGN || ctx->op == PUBKEY_OP_VERIFY))
  ------------------
  |  Branch (996:9): [True: 0, False: 0]
  |  Branch (996:38): [True: 0, False: 0]
  ------------------
  997|      0|    {
  998|      0|      if (lvalue && (parsed_flags & PUBKEY_FLAG_PREHASH))
  ------------------
  |  |   46|      0|#define PUBKEY_FLAG_PREHASH        (1 << 17)
  ------------------
  |  Branch (998:11): [True: 0, False: 0]
  |  Branch (998:21): [True: 0, False: 0]
  ------------------
  999|      0|        {
 1000|      0|          void * value;
 1001|      0|          size_t valuelen;
 1002|      0|          gcry_sexp_t list;
 1003|       |
 1004|       |          /* Get HASH-ALGO. */
 1005|      0|          list = sexp_find_token (ldata, "hash-algo", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1006|      0|          if (list)
  ------------------
  |  Branch (1006:15): [True: 0, False: 0]
  ------------------
 1007|      0|            {
 1008|      0|              s = sexp_nth_data (list, 1, &n);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
 1009|      0|              if (!s)
  ------------------
  |  Branch (1009:19): [True: 0, False: 0]
  ------------------
 1010|      0|                rc = GPG_ERR_NO_OBJ;
 1011|      0|              else
 1012|      0|                {
 1013|      0|                  ctx->hash_algo = get_hash_algo (s, n);
 1014|      0|                  if (!ctx->hash_algo)
  ------------------
  |  Branch (1014:23): [True: 0, False: 0]
  ------------------
 1015|      0|                    rc = GPG_ERR_DIGEST_ALGO;
 1016|      0|                }
 1017|      0|              sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1018|      0|              if (rc)
  ------------------
  |  Branch (1018:19): [True: 0, False: 0]
  ------------------
 1019|      0|                goto leave;
 1020|      0|            }
 1021|       |
 1022|      0|          if ( !(value=sexp_nth_buffer (lvalue, 1, &valuelen)) || !valuelen )
  ------------------
  |  |  388|      0|#define sexp_nth_buffer(a, b, c)     _gcry_sexp_nth_buffer ((a), (b), (c))
  ------------------
  |  Branch (1022:16): [True: 0, False: 0]
  |  Branch (1022:67): [True: 0, False: 0]
  ------------------
 1023|      0|            rc = GPG_ERR_INV_OBJ;
 1024|      0|          else if ((valuelen * 8) < valuelen)
  ------------------
  |  Branch (1024:20): [True: 0, False: 0]
  ------------------
 1025|      0|            {
 1026|      0|              xfree (value);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1027|      0|              rc = GPG_ERR_TOO_LARGE;
 1028|      0|            }
 1029|      0|          else
 1030|      0|            {
 1031|      0|              void *hash;
 1032|       |
 1033|      0|              n = _gcry_md_get_algo_dlen (ctx->hash_algo);
 1034|      0|              hash = xtrymalloc (n);
  ------------------
  |  |  138|      0|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
 1035|      0|              if (!hash)
  ------------------
  |  Branch (1035:19): [True: 0, False: 0]
  ------------------
 1036|      0|                rc = gpg_err_code_from_syserror ();
 1037|      0|              else
 1038|      0|                {
 1039|      0|                  _gcry_md_hash_buffer (ctx->hash_algo, hash, value, valuelen);
 1040|      0|                  rc = _gcry_rsa_pkcs1_encode_for_sig (ret_mpi, ctx->nbits,
 1041|      0|                                                       hash, n, ctx->hash_algo);
 1042|      0|                  xfree (hash);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1043|      0|                }
 1044|      0|            }
 1045|      0|        }
 1046|      0|      else if (lhash)
  ------------------
  |  Branch (1046:16): [True: 0, False: 0]
  ------------------
 1047|      0|        {
 1048|      0|          if (sexp_length (lhash) != 3)
  ------------------
  |  |  382|      0|#define sexp_length(a)               _gcry_sexp_length ((a))
  ------------------
  |  Branch (1048:15): [True: 0, False: 0]
  ------------------
 1049|      0|            rc = GPG_ERR_INV_OBJ;
 1050|      0|          else if ( !(s=sexp_nth_data (lhash, 1, &n)) || !n )
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
  |  Branch (1050:21): [True: 0, False: 0]
  |  Branch (1050:58): [True: 0, False: 0]
  ------------------
 1051|      0|            rc = GPG_ERR_INV_OBJ;
 1052|      0|          else
 1053|      0|            {
 1054|      0|              const void * value;
 1055|      0|              size_t valuelen;
 1056|       |
 1057|      0|              ctx->hash_algo = get_hash_algo (s, n);
 1058|       |
 1059|      0|              if (!ctx->hash_algo)
  ------------------
  |  Branch (1059:19): [True: 0, False: 0]
  ------------------
 1060|      0|                rc = GPG_ERR_DIGEST_ALGO;
 1061|      0|              else if ( !(value=sexp_nth_data (lhash, 2, &valuelen))
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
  |  Branch (1061:25): [True: 0, False: 0]
  ------------------
 1062|      0|                        || !valuelen )
  ------------------
  |  Branch (1062:28): [True: 0, False: 0]
  ------------------
 1063|      0|                rc = GPG_ERR_INV_OBJ;
 1064|      0|              else
 1065|      0|                rc = _gcry_rsa_pkcs1_encode_for_sig (ret_mpi, ctx->nbits,
 1066|      0|                                                     value, valuelen,
 1067|      0|                                                     ctx->hash_algo);
 1068|      0|            }
 1069|      0|        }
 1070|      0|    }
 1071|      0|  else if (ctx->encoding == PUBKEY_ENC_PKCS1_RAW && lvalue
  ------------------
  |  Branch (1071:12): [True: 0, False: 0]
  |  Branch (1071:53): [True: 0, False: 0]
  ------------------
 1072|      0|	   && (ctx->op == PUBKEY_OP_SIGN || ctx->op == PUBKEY_OP_VERIFY))
  ------------------
  |  Branch (1072:9): [True: 0, False: 0]
  |  Branch (1072:38): [True: 0, False: 0]
  ------------------
 1073|      0|    {
 1074|      0|      const void * value;
 1075|      0|      size_t valuelen;
 1076|       |
 1077|      0|      if (sexp_length (lvalue) != 2)
  ------------------
  |  |  382|      0|#define sexp_length(a)               _gcry_sexp_length ((a))
  ------------------
  |  Branch (1077:11): [True: 0, False: 0]
  ------------------
 1078|      0|        rc = GPG_ERR_INV_OBJ;
 1079|      0|      else if ( !(value=sexp_nth_data (lvalue, 1, &valuelen))
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
  |  Branch (1079:17): [True: 0, False: 0]
  ------------------
 1080|      0|                || !valuelen )
  ------------------
  |  Branch (1080:20): [True: 0, False: 0]
  ------------------
 1081|      0|        rc = GPG_ERR_INV_OBJ;
 1082|      0|      else
 1083|      0|        rc = _gcry_rsa_pkcs1_encode_raw_for_sig (ret_mpi, ctx->nbits,
 1084|      0|                                                 value, valuelen);
 1085|      0|    }
 1086|      0|  else if (ctx->encoding == PUBKEY_ENC_OAEP && lvalue
  ------------------
  |  Branch (1086:12): [True: 0, False: 0]
  |  Branch (1086:48): [True: 0, False: 0]
  ------------------
 1087|      0|	   && ctx->op == PUBKEY_OP_ENCRYPT)
  ------------------
  |  Branch (1087:8): [True: 0, False: 0]
  ------------------
 1088|      0|    {
 1089|      0|      const void * value;
 1090|      0|      size_t valuelen;
 1091|       |
 1092|      0|      if ( !(value=sexp_nth_data (lvalue, 1, &valuelen)) || !valuelen )
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
  |  Branch (1092:12): [True: 0, False: 0]
  |  Branch (1092:61): [True: 0, False: 0]
  ------------------
 1093|      0|	rc = GPG_ERR_INV_OBJ;
 1094|      0|      else
 1095|      0|	{
 1096|      0|	  gcry_sexp_t list;
 1097|      0|          void *random_override = NULL;
 1098|      0|          size_t random_override_len = 0;
 1099|       |
 1100|       |	  /* Get HASH-ALGO. */
 1101|      0|	  list = sexp_find_token (ldata, "hash-algo", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1102|      0|	  if (list)
  ------------------
  |  Branch (1102:8): [True: 0, False: 0]
  ------------------
 1103|      0|	    {
 1104|      0|	      s = sexp_nth_data (list, 1, &n);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
 1105|      0|	      if (!s)
  ------------------
  |  Branch (1105:12): [True: 0, False: 0]
  ------------------
 1106|      0|		rc = GPG_ERR_NO_OBJ;
 1107|      0|	      else
 1108|      0|		{
 1109|      0|		  ctx->hash_algo = get_hash_algo (s, n);
 1110|      0|		  if (!ctx->hash_algo)
  ------------------
  |  Branch (1110:9): [True: 0, False: 0]
  ------------------
 1111|      0|		    rc = GPG_ERR_DIGEST_ALGO;
 1112|      0|		}
 1113|      0|	      sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1114|      0|	      if (rc)
  ------------------
  |  Branch (1114:12): [True: 0, False: 0]
  ------------------
 1115|      0|		goto leave;
 1116|      0|	    }
 1117|       |
 1118|       |	  /* Get LABEL. */
 1119|      0|	  list = sexp_find_token (ldata, "label", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1120|      0|	  if (list)
  ------------------
  |  Branch (1120:8): [True: 0, False: 0]
  ------------------
 1121|      0|	    {
 1122|      0|	      s = sexp_nth_data (list, 1, &n);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
 1123|      0|	      if (!s)
  ------------------
  |  Branch (1123:12): [True: 0, False: 0]
  ------------------
 1124|      0|		rc = GPG_ERR_NO_OBJ;
 1125|      0|	      else if (n > 0)
  ------------------
  |  Branch (1125:17): [True: 0, False: 0]
  ------------------
 1126|      0|		{
 1127|      0|		  ctx->label = xtrymalloc (n);
  ------------------
  |  |  138|      0|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
 1128|      0|		  if (!ctx->label)
  ------------------
  |  Branch (1128:9): [True: 0, False: 0]
  ------------------
 1129|      0|		    rc = gpg_err_code_from_syserror ();
 1130|      0|		  else
 1131|      0|		    {
 1132|      0|		      memcpy (ctx->label, s, n);
 1133|      0|		      ctx->labellen = n;
 1134|      0|		    }
 1135|      0|		}
 1136|      0|	      sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1137|      0|	      if (rc)
  ------------------
  |  Branch (1137:12): [True: 0, False: 0]
  ------------------
 1138|      0|		goto leave;
 1139|      0|	    }
 1140|       |          /* Get optional RANDOM-OVERRIDE.  */
 1141|      0|          list = sexp_find_token (ldata, "random-override", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1142|      0|          if (list)
  ------------------
  |  Branch (1142:15): [True: 0, False: 0]
  ------------------
 1143|      0|            {
 1144|      0|              s = sexp_nth_data (list, 1, &n);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
 1145|      0|              if (!s)
  ------------------
  |  Branch (1145:19): [True: 0, False: 0]
  ------------------
 1146|      0|                rc = GPG_ERR_NO_OBJ;
 1147|      0|              else if (n > 0)
  ------------------
  |  Branch (1147:24): [True: 0, False: 0]
  ------------------
 1148|      0|                {
 1149|      0|                  random_override = xtrymalloc (n);
  ------------------
  |  |  138|      0|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
 1150|      0|                  if (!random_override)
  ------------------
  |  Branch (1150:23): [True: 0, False: 0]
  ------------------
 1151|      0|                    rc = gpg_err_code_from_syserror ();
 1152|      0|                  else
 1153|      0|                    {
 1154|      0|                      memcpy (random_override, s, n);
 1155|      0|                      random_override_len = n;
 1156|      0|                    }
 1157|      0|                }
 1158|      0|              sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1159|      0|              if (rc)
  ------------------
  |  Branch (1159:19): [True: 0, False: 0]
  ------------------
 1160|      0|                goto leave;
 1161|      0|            }
 1162|       |
 1163|      0|	  rc = _gcry_rsa_oaep_encode (ret_mpi, ctx->nbits, ctx->hash_algo,
 1164|      0|                                      value, valuelen,
 1165|      0|                                      ctx->label, ctx->labellen,
 1166|      0|                                      random_override, random_override_len);
 1167|       |
 1168|      0|          xfree (random_override);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1169|      0|	}
 1170|      0|    }
 1171|      0|  else if (ctx->encoding == PUBKEY_ENC_PSS && ctx->op == PUBKEY_OP_SIGN)
  ------------------
  |  Branch (1171:12): [True: 0, False: 0]
  |  Branch (1171:47): [True: 0, False: 0]
  ------------------
 1172|      0|    {
 1173|      0|      const void * value;
 1174|      0|      size_t valuelen;
 1175|      0|      gcry_sexp_t list;
 1176|      0|      void *random_override = NULL;
 1177|       |
 1178|      0|      if (lvalue)
  ------------------
  |  Branch (1178:11): [True: 0, False: 0]
  ------------------
 1179|      0|        {
 1180|       |          /* Get HASH-ALGO. */
 1181|      0|          list = sexp_find_token (ldata, "hash-algo", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1182|      0|          if (list)
  ------------------
  |  Branch (1182:15): [True: 0, False: 0]
  ------------------
 1183|      0|            {
 1184|      0|              s = sexp_nth_data (list, 1, &n);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
 1185|      0|              if (!s)
  ------------------
  |  Branch (1185:19): [True: 0, False: 0]
  ------------------
 1186|      0|                rc = GPG_ERR_NO_OBJ;
 1187|      0|              else
 1188|      0|                {
 1189|      0|                  ctx->hash_algo = get_hash_algo (s, n);
 1190|      0|                  if (!ctx->hash_algo)
  ------------------
  |  Branch (1190:23): [True: 0, False: 0]
  ------------------
 1191|      0|                    rc = GPG_ERR_DIGEST_ALGO;
 1192|      0|                }
 1193|      0|              sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1194|      0|              if (rc)
  ------------------
  |  Branch (1194:19): [True: 0, False: 0]
  ------------------
 1195|      0|                goto leave;
 1196|      0|            }
 1197|       |
 1198|      0|          if ( !(value=sexp_nth_data (lvalue, 1, &valuelen)) || !valuelen )
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
  |  Branch (1198:16): [True: 0, False: 0]
  |  Branch (1198:65): [True: 0, False: 0]
  ------------------
 1199|      0|            rc = GPG_ERR_INV_OBJ;
 1200|      0|          ctx->flags |= PUBKEY_FLAG_PREHASH;
  ------------------
  |  |   46|      0|#define PUBKEY_FLAG_PREHASH        (1 << 17)
  ------------------
 1201|      0|        }
 1202|      0|      else if (lhash)
  ------------------
  |  Branch (1202:16): [True: 0, False: 0]
  ------------------
 1203|      0|        {
 1204|      0|          if (sexp_length (lhash) != 3)
  ------------------
  |  |  382|      0|#define sexp_length(a)               _gcry_sexp_length ((a))
  ------------------
  |  Branch (1204:15): [True: 0, False: 0]
  ------------------
 1205|      0|            rc = GPG_ERR_INV_OBJ;
 1206|      0|          else if ( !(s=sexp_nth_data (lhash, 1, &n)) || !n )
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
  |  Branch (1206:21): [True: 0, False: 0]
  |  Branch (1206:58): [True: 0, False: 0]
  ------------------
 1207|      0|            rc = GPG_ERR_INV_OBJ;
 1208|      0|          else
 1209|      0|            {
 1210|      0|              ctx->hash_algo = get_hash_algo (s, n);
 1211|       |
 1212|      0|              if (!ctx->hash_algo)
  ------------------
  |  Branch (1212:19): [True: 0, False: 0]
  ------------------
 1213|      0|                rc = GPG_ERR_DIGEST_ALGO;
 1214|      0|              else if ( !(value=sexp_nth_data (lhash, 2, &valuelen))
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
  |  Branch (1214:25): [True: 0, False: 0]
  ------------------
 1215|      0|                        || !valuelen )
  ------------------
  |  Branch (1215:28): [True: 0, False: 0]
  ------------------
 1216|      0|                rc = GPG_ERR_INV_OBJ;
 1217|      0|            }
 1218|      0|        }
 1219|      0|      else
 1220|      0|        rc = GPG_ERR_CONFLICT;
 1221|       |
 1222|      0|      if (rc)
  ------------------
  |  Branch (1222:11): [True: 0, False: 0]
  ------------------
 1223|      0|        goto leave;
 1224|       |
 1225|       |      /* Get SALT-LENGTH. */
 1226|      0|      list = sexp_find_token (ldata, "salt-length", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1227|      0|      if (list)
  ------------------
  |  Branch (1227:11): [True: 0, False: 0]
  ------------------
 1228|      0|        {
 1229|      0|          s = sexp_nth_data (list, 1, &n);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
 1230|      0|          if (!s)
  ------------------
  |  Branch (1230:15): [True: 0, False: 0]
  ------------------
 1231|      0|            {
 1232|      0|              rc = GPG_ERR_NO_OBJ;
 1233|      0|              goto leave;
 1234|      0|            }
 1235|      0|          ctx->saltlen = (unsigned int)strtoul (s, NULL, 10);
 1236|      0|          sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1237|      0|        }
 1238|       |
 1239|       |      /* Get optional RANDOM-OVERRIDE.  */
 1240|      0|      list = sexp_find_token (ldata, "random-override", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1241|      0|      if (list)
  ------------------
  |  Branch (1241:11): [True: 0, False: 0]
  ------------------
 1242|      0|        {
 1243|      0|          s = sexp_nth_data (list, 1, &n);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
 1244|      0|          if (!s)
  ------------------
  |  Branch (1244:15): [True: 0, False: 0]
  ------------------
 1245|      0|            rc = GPG_ERR_NO_OBJ;
 1246|      0|          else if (n == ctx->saltlen)
  ------------------
  |  Branch (1246:20): [True: 0, False: 0]
  ------------------
 1247|      0|            {
 1248|      0|              random_override = xtrymalloc (n);
  ------------------
  |  |  138|      0|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
 1249|      0|              if (!random_override)
  ------------------
  |  Branch (1249:19): [True: 0, False: 0]
  ------------------
 1250|      0|                rc = gpg_err_code_from_syserror ();
 1251|      0|              else
 1252|      0|                memcpy (random_override, s, n);
 1253|      0|            }
 1254|      0|          else
 1255|      0|            rc = GPG_ERR_INV_ARG;
 1256|      0|          sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1257|      0|          if (rc)
  ------------------
  |  Branch (1257:15): [True: 0, False: 0]
  ------------------
 1258|      0|            goto leave;
 1259|      0|        }
 1260|       |
 1261|       |      /* Encode the data.  (NBITS-1 is due to 8.1.1, step 1.) */
 1262|      0|      rc = _gcry_rsa_pss_encode (ret_mpi, ctx->nbits - 1,
 1263|      0|                                 ctx->hash_algo, ctx->saltlen,
 1264|      0|                                 !(ctx->flags & PUBKEY_FLAG_PREHASH),
  ------------------
  |  |   46|      0|#define PUBKEY_FLAG_PREHASH        (1 << 17)
  ------------------
 1265|      0|                                 value, valuelen,
 1266|      0|                                 random_override);
 1267|      0|      xfree (random_override);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1268|      0|    }
 1269|      0|  else if (ctx->encoding == PUBKEY_ENC_PSS && ctx->op == PUBKEY_OP_VERIFY)
  ------------------
  |  Branch (1269:12): [True: 0, False: 0]
  |  Branch (1269:47): [True: 0, False: 0]
  ------------------
 1270|      0|    {
 1271|      0|      gcry_sexp_t list;
 1272|       |
 1273|      0|      if (lvalue)
  ------------------
  |  Branch (1273:11): [True: 0, False: 0]
  ------------------
 1274|      0|        {
 1275|       |          /* Get HASH-ALGO. */
 1276|      0|          list = sexp_find_token (ldata, "hash-algo", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1277|      0|          if (list)
  ------------------
  |  Branch (1277:15): [True: 0, False: 0]
  ------------------
 1278|      0|            {
 1279|      0|              s = sexp_nth_data (list, 1, &n);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
 1280|      0|              if (!s)
  ------------------
  |  Branch (1280:19): [True: 0, False: 0]
  ------------------
 1281|      0|                rc = GPG_ERR_NO_OBJ;
 1282|      0|              else
 1283|      0|                {
 1284|      0|                  ctx->hash_algo = get_hash_algo (s, n);
 1285|      0|                  if (!ctx->hash_algo)
  ------------------
  |  Branch (1285:23): [True: 0, False: 0]
  ------------------
 1286|      0|                    rc = GPG_ERR_DIGEST_ALGO;
 1287|      0|                }
 1288|      0|              sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1289|      0|              if (rc)
  ------------------
  |  Branch (1289:19): [True: 0, False: 0]
  ------------------
 1290|      0|                goto leave;
 1291|      0|            }
 1292|       |
 1293|      0|          *ret_mpi = sexp_nth_mpi (lvalue, 1, GCRYMPI_FMT_OPAQUE);
  ------------------
  |  |  390|      0|#define sexp_nth_mpi(a, b, c)        _gcry_sexp_nth_mpi ((a), (b), (c))
  ------------------
 1294|      0|          if (!*ret_mpi)
  ------------------
  |  Branch (1294:15): [True: 0, False: 0]
  ------------------
 1295|      0|            rc = GPG_ERR_INV_OBJ;
 1296|       |
 1297|      0|          ctx->flags |= PUBKEY_FLAG_PREHASH;
  ------------------
  |  |   46|      0|#define PUBKEY_FLAG_PREHASH        (1 << 17)
  ------------------
 1298|      0|        }
 1299|      0|      else if (lhash)
  ------------------
  |  Branch (1299:16): [True: 0, False: 0]
  ------------------
 1300|      0|        {
 1301|      0|          if (sexp_length (lhash) != 3)
  ------------------
  |  |  382|      0|#define sexp_length(a)               _gcry_sexp_length ((a))
  ------------------
  |  Branch (1301:15): [True: 0, False: 0]
  ------------------
 1302|      0|            rc = GPG_ERR_INV_OBJ;
 1303|      0|          else if ( !(s=sexp_nth_data (lhash, 1, &n)) || !n )
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
  |  Branch (1303:21): [True: 0, False: 0]
  |  Branch (1303:58): [True: 0, False: 0]
  ------------------
 1304|      0|            rc = GPG_ERR_INV_OBJ;
 1305|      0|          else
 1306|      0|            {
 1307|      0|              ctx->hash_algo = get_hash_algo (s, n);
 1308|       |
 1309|      0|              if (!ctx->hash_algo)
  ------------------
  |  Branch (1309:19): [True: 0, False: 0]
  ------------------
 1310|      0|                rc = GPG_ERR_DIGEST_ALGO;
 1311|      0|              else
 1312|      0|                {
 1313|      0|                  *ret_mpi = sexp_nth_mpi (lhash, 2, GCRYMPI_FMT_OPAQUE);
  ------------------
  |  |  390|      0|#define sexp_nth_mpi(a, b, c)        _gcry_sexp_nth_mpi ((a), (b), (c))
  ------------------
 1314|      0|                  if (!*ret_mpi)
  ------------------
  |  Branch (1314:23): [True: 0, False: 0]
  ------------------
 1315|      0|                    rc = GPG_ERR_INV_OBJ;
 1316|      0|                }
 1317|      0|            }
 1318|      0|        }
 1319|      0|      else
 1320|      0|        rc = GPG_ERR_CONFLICT;
 1321|       |
 1322|      0|      if (rc)
  ------------------
  |  Branch (1322:11): [True: 0, False: 0]
  ------------------
 1323|      0|        goto leave;
 1324|       |
 1325|       |      /* Get SALT-LENGTH. */
 1326|      0|      list = sexp_find_token (ldata, "salt-length", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1327|      0|      if (list)
  ------------------
  |  Branch (1327:11): [True: 0, False: 0]
  ------------------
 1328|      0|        {
 1329|      0|          s = sexp_nth_data (list, 1, &n);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
 1330|      0|          if (!s)
  ------------------
  |  Branch (1330:15): [True: 0, False: 0]
  ------------------
 1331|      0|            {
 1332|      0|              rc = GPG_ERR_NO_OBJ;
 1333|      0|              goto leave;
 1334|      0|            }
 1335|      0|          ctx->saltlen = (unsigned int)strtoul (s, NULL, 10);
 1336|      0|          if (ctx->saltlen > 16384)
  ------------------
  |  Branch (1336:15): [True: 0, False: 0]
  ------------------
 1337|      0|            rc = GPG_ERR_TOO_LARGE;
 1338|      0|          sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1339|      0|          if (rc)
  ------------------
  |  Branch (1339:15): [True: 0, False: 0]
  ------------------
 1340|      0|            goto leave;
 1341|      0|        }
 1342|       |
 1343|      0|      ctx->verify_cmp = pss_verify_cmp;
 1344|      0|      ctx->verify_arg = *ret_mpi;
 1345|      0|    }
 1346|      0|  else
 1347|      0|    rc = GPG_ERR_CONFLICT;
 1348|       |
 1349|      0| leave:
 1350|      0|  sexp_release (ldata);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1351|      0|  sexp_release (lhash);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1352|      0|  sexp_release (lvalue);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1353|       |
 1354|      0|  if (!rc)
  ------------------
  |  Branch (1354:7): [True: 0, False: 0]
  ------------------
 1355|      0|    ctx->flags |= parsed_flags;
 1356|      0|  else
 1357|      0|    {
 1358|      0|      xfree (ctx->label);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1359|      0|      ctx->label = NULL;
 1360|      0|    }
 1361|       |
 1362|      0|  return rc;
 1363|      0|}

_gcry_pk_verify:
  605|     31|{
  606|     31|  gcry_err_code_t rc;
  607|     31|  gcry_pk_spec_t *spec;
  608|     31|  gcry_sexp_t keyparms;
  609|       |
  610|     31|  rc = spec_from_sexp (s_pkey, 0, &spec, &keyparms);
  611|     31|  if (rc)
  ------------------
  |  Branch (611:7): [True: 0, False: 31]
  ------------------
  612|      0|    goto leave;
  613|       |
  614|     31|  if (spec->flags.disabled)
  ------------------
  |  Branch (614:7): [True: 0, False: 31]
  ------------------
  615|      0|    rc = GPG_ERR_PUBKEY_ALGO;
  616|     31|  else if (!spec->flags.fips && fips_mode ())
  ------------------
  |  |  449|      0|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (616:12): [True: 0, False: 31]
  ------------------
  617|      0|    rc = GPG_ERR_PUBKEY_ALGO;
  618|     31|  else if (spec->verify)
  ------------------
  |  Branch (618:12): [True: 31, False: 0]
  ------------------
  619|     31|    rc = spec->verify (s_sig, s_hash, keyparms);
  620|      0|  else
  621|      0|    rc = GPG_ERR_NOT_IMPLEMENTED;
  622|       |
  623|     31| leave:
  624|     31|  sexp_release (keyparms);
  ------------------
  |  |  372|     31|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  625|     31|  return rc;
  626|     31|}
_gcry_pk_get_keygrip:
  934|     14|{
  935|     14|  gcry_sexp_t list = NULL;
  936|     14|  gcry_sexp_t l2 = NULL;
  937|     14|  gcry_pk_spec_t *spec = NULL;
  938|     14|  const char *s;
  939|     14|  char *name = NULL;
  940|     14|  int idx;
  941|     14|  const char *elems;
  942|     14|  gcry_md_hd_t md = NULL;
  943|     14|  int okay = 0;
  944|       |
  945|       |  /* Check that the first element is valid. */
  946|     14|  list = sexp_find_token (key, "public-key", 0);
  ------------------
  |  |  381|     14|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  947|     14|  if (! list)
  ------------------
  |  Branch (947:7): [True: 0, False: 14]
  ------------------
  948|      0|    list = sexp_find_token (key, "private-key", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  949|     14|  if (! list)
  ------------------
  |  Branch (949:7): [True: 0, False: 14]
  ------------------
  950|      0|    list = sexp_find_token (key, "protected-private-key", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  951|     14|  if (! list)
  ------------------
  |  Branch (951:7): [True: 0, False: 14]
  ------------------
  952|      0|    list = sexp_find_token (key, "shadowed-private-key", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  953|     14|  if (! list)
  ------------------
  |  Branch (953:7): [True: 0, False: 14]
  ------------------
  954|      0|    return NULL; /* No public- or private-key object. */
  955|       |
  956|     14|  l2 = sexp_cadr (list);
  ------------------
  |  |  386|     14|#define sexp_cadr(a)                 _gcry_sexp_cadr ((a))
  ------------------
  957|     14|  sexp_release (list);
  ------------------
  |  |  372|     14|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  958|     14|  list = l2;
  959|     14|  l2 = NULL;
  960|       |
  961|     14|  name = _gcry_sexp_nth_string (list, 0);
  962|     14|  if (!name)
  ------------------
  |  Branch (962:7): [True: 0, False: 14]
  ------------------
  963|      0|    goto fail; /* Invalid structure of object. */
  964|       |
  965|     14|  spec = spec_from_name (name);
  966|     14|  if (!spec)
  ------------------
  |  Branch (966:7): [True: 0, False: 14]
  ------------------
  967|      0|    goto fail; /* Unknown algorithm.  */
  968|       |
  969|     14|  elems = spec->elements_grip;
  970|     14|  if (!elems)
  ------------------
  |  Branch (970:7): [True: 0, False: 14]
  ------------------
  971|      0|    goto fail; /* No grip parameter.  */
  972|       |
  973|     14|  if (_gcry_md_open (&md, GCRY_MD_SHA1, 0))
  ------------------
  |  Branch (973:7): [True: 0, False: 14]
  ------------------
  974|      0|    goto fail;
  975|       |
  976|     14|  if (spec->comp_keygrip)
  ------------------
  |  Branch (976:7): [True: 14, False: 0]
  ------------------
  977|     14|    {
  978|       |      /* Module specific method to compute a keygrip.  */
  979|     14|      if (spec->comp_keygrip (md, list))
  ------------------
  |  Branch (979:11): [True: 0, False: 14]
  ------------------
  980|      0|        goto fail;
  981|     14|    }
  982|      0|  else
  983|      0|    {
  984|       |      /* Generic method to compute a keygrip.  */
  985|      0|      for (idx = 0, s = elems; *s; s++, idx++)
  ------------------
  |  Branch (985:32): [True: 0, False: 0]
  ------------------
  986|      0|        {
  987|      0|          const char *data;
  988|      0|          size_t datalen;
  989|      0|          char buf[30];
  990|       |
  991|      0|          l2 = sexp_find_token (list, s, 1);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  992|      0|          if (! l2)
  ------------------
  |  Branch (992:15): [True: 0, False: 0]
  ------------------
  993|      0|            goto fail;
  994|      0|          data = sexp_nth_data (l2, 1, &datalen);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
  995|      0|          if (! data)
  ------------------
  |  Branch (995:15): [True: 0, False: 0]
  ------------------
  996|      0|            goto fail;
  997|       |
  998|      0|          snprintf (buf, sizeof buf, "(1:%c%u:", *s, (unsigned int)datalen);
  999|      0|          _gcry_md_write (md, buf, strlen (buf));
 1000|      0|          _gcry_md_write (md, data, datalen);
 1001|      0|          sexp_release (l2);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1002|      0|          l2 = NULL;
 1003|      0|          _gcry_md_write (md, ")", 1);
 1004|      0|        }
 1005|      0|    }
 1006|       |
 1007|     14|  if (!array)
  ------------------
  |  Branch (1007:7): [True: 0, False: 14]
  ------------------
 1008|      0|    {
 1009|      0|      array = xtrymalloc (20);
  ------------------
  |  |  138|      0|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
 1010|      0|      if (! array)
  ------------------
  |  Branch (1010:11): [True: 0, False: 0]
  ------------------
 1011|      0|        goto fail;
 1012|      0|    }
 1013|       |
 1014|     14|  memcpy (array, _gcry_md_read (md, GCRY_MD_SHA1), 20);
 1015|     14|  okay = 1;
 1016|       |
 1017|     14| fail:
 1018|     14|  xfree (name);
  ------------------
  |  |  150|     14|#define xfree(a)         _gcry_free ((a))
  ------------------
 1019|     14|  sexp_release (l2);
  ------------------
  |  |  372|     14|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1020|     14|  _gcry_md_close (md);
 1021|     14|  sexp_release (list);
  ------------------
  |  |  372|     14|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1022|     14|  return okay? array : NULL;
  ------------------
  |  Branch (1022:10): [True: 14, False: 0]
  ------------------
 1023|     14|}
_gcry_pk_algo_info:
 1133|   127k|{
 1134|   127k|  gcry_err_code_t rc = 0;
 1135|       |
 1136|   127k|  switch (what)
 1137|   127k|    {
 1138|   127k|    case GCRYCTL_TEST_ALGO:
  ------------------
  |  Branch (1138:5): [True: 127k, False: 0]
  ------------------
 1139|   127k|      {
 1140|   127k|	int use = nbytes ? *nbytes : 0;
  ------------------
  |  Branch (1140:12): [True: 127k, False: 0]
  ------------------
 1141|   127k|	if (buffer)
  ------------------
  |  Branch (1141:6): [True: 0, False: 127k]
  ------------------
 1142|      0|	  rc = GPG_ERR_INV_ARG;
 1143|   127k|	else if (check_pubkey_algo (algorithm, use))
  ------------------
  |  Branch (1143:11): [True: 0, False: 127k]
  ------------------
 1144|      0|	  rc = GPG_ERR_PUBKEY_ALGO;
 1145|   127k|	break;
 1146|      0|      }
 1147|       |
 1148|      0|    case GCRYCTL_GET_ALGO_USAGE:
  ------------------
  |  Branch (1148:5): [True: 0, False: 127k]
  ------------------
 1149|      0|      {
 1150|      0|	gcry_pk_spec_t *spec;
 1151|       |
 1152|      0|	spec = spec_from_algo (algorithm);
 1153|      0|        *nbytes = spec? spec->use : 0;
  ------------------
  |  Branch (1153:19): [True: 0, False: 0]
  ------------------
 1154|      0|	break;
 1155|      0|      }
 1156|       |
 1157|      0|    case GCRYCTL_GET_ALGO_NPKEY:
  ------------------
  |  Branch (1157:5): [True: 0, False: 127k]
  ------------------
 1158|      0|      {
 1159|       |	/* FIXME?  */
 1160|      0|	int npkey = pubkey_get_npkey (algorithm);
 1161|      0|	*nbytes = npkey;
 1162|      0|	break;
 1163|      0|      }
 1164|      0|    case GCRYCTL_GET_ALGO_NSKEY:
  ------------------
  |  Branch (1164:5): [True: 0, False: 127k]
  ------------------
 1165|      0|      {
 1166|       |	/* FIXME?  */
 1167|      0|	int nskey = pubkey_get_nskey (algorithm);
 1168|      0|	*nbytes = nskey;
 1169|      0|	break;
 1170|      0|      }
 1171|      0|    case GCRYCTL_GET_ALGO_NSIGN:
  ------------------
  |  Branch (1171:5): [True: 0, False: 127k]
  ------------------
 1172|      0|      {
 1173|       |	/* FIXME?  */
 1174|      0|	int nsign = pubkey_get_nsig (algorithm);
 1175|      0|	*nbytes = nsign;
 1176|      0|	break;
 1177|      0|      }
 1178|      0|    case GCRYCTL_GET_ALGO_NENCR:
  ------------------
  |  Branch (1178:5): [True: 0, False: 127k]
  ------------------
 1179|      0|      {
 1180|       |	/* FIXME?  */
 1181|      0|	int nencr = pubkey_get_nenc (algorithm);
 1182|      0|	*nbytes = nencr;
 1183|      0|	break;
 1184|      0|      }
 1185|       |
 1186|      0|    default:
  ------------------
  |  Branch (1186:5): [True: 0, False: 127k]
  ------------------
 1187|      0|      rc = GPG_ERR_INV_OP;
 1188|   127k|    }
 1189|       |
 1190|   127k|  return rc;
 1191|   127k|}
_gcry_pk_init:
 1239|      1|{
 1240|      1|  return 0;
 1241|      1|}
pubkey.c:spec_from_name:
   92|     45|{
   93|     45|  gcry_pk_spec_t *spec;
   94|     45|  int idx;
   95|     45|  const char **aliases;
   96|       |
   97|     66|  for (idx=0; (spec = pubkey_list[idx]); idx++)
  ------------------
  |  Branch (97:15): [True: 66, False: 0]
  ------------------
   98|     66|    {
   99|     66|      if (!stricmp (name, spec->name))
  ------------------
  |  |  351|     66|#define stricmp(a,b)	 strcasecmp( (a), (b) )
  ------------------
  |  Branch (99:11): [True: 29, False: 37]
  ------------------
  100|     29|        return spec;
  101|    179|      for (aliases = spec->aliases; *aliases; aliases++)
  ------------------
  |  Branch (101:37): [True: 158, False: 21]
  ------------------
  102|    158|        if (!stricmp (name, *aliases))
  ------------------
  |  |  351|    158|#define stricmp(a,b)	 strcasecmp( (a), (b) )
  ------------------
  |  Branch (102:13): [True: 16, False: 142]
  ------------------
  103|     16|          return spec;
  104|     37|    }
  105|       |
  106|      0|  return NULL;
  107|     45|}
pubkey.c:spec_from_algo:
   75|   127k|{
   76|   127k|  int idx;
   77|   127k|  gcry_pk_spec_t *spec;
   78|       |
   79|   127k|  algo = map_algo (algo);
   80|       |
   81|   508k|  for (idx = 0; (spec = pubkey_list[idx]); idx++)
  ------------------
  |  Branch (81:17): [True: 508k, False: 0]
  ------------------
   82|   508k|    if (algo == spec->algo)
  ------------------
  |  Branch (82:9): [True: 127k, False: 380k]
  ------------------
   83|   127k|      return spec;
   84|      0|  return NULL;
   85|   127k|}
pubkey.c:spec_from_sexp:
  125|     31|{
  126|     31|  gcry_sexp_t list, l2;
  127|     31|  char *name;
  128|     31|  gcry_pk_spec_t *spec;
  129|       |
  130|     31|  *r_spec = NULL;
  131|     31|  if (r_parms)
  ------------------
  |  Branch (131:7): [True: 31, False: 0]
  ------------------
  132|     31|    *r_parms = NULL;
  133|       |
  134|       |  /* Check that the first element is valid.  If we are looking for a
  135|       |     public key but a private key was supplied, we allow the use of
  136|       |     the private key anyway.  The rationale for this is that the
  137|       |     private key is a superset of the public key.  */
  138|     31|  list = sexp_find_token (sexp, want_private? "private-key":"public-key", 0);
  ------------------
  |  |  381|     62|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  |  |  ------------------
  |  |  |  Branch (381:67): [True: 0, False: 31]
  |  |  ------------------
  ------------------
  139|     31|  if (!list && !want_private)
  ------------------
  |  Branch (139:7): [True: 0, False: 31]
  |  Branch (139:16): [True: 0, False: 0]
  ------------------
  140|      0|    list = sexp_find_token (sexp, "private-key", 0);
  ------------------
  |  |  381|      0|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
  141|     31|  if (!list)
  ------------------
  |  Branch (141:7): [True: 0, False: 31]
  ------------------
  142|      0|    return GPG_ERR_INV_OBJ; /* Does not contain a key object.  */
  143|       |
  144|     31|  l2 = sexp_cadr (list);
  ------------------
  |  |  386|     31|#define sexp_cadr(a)                 _gcry_sexp_cadr ((a))
  ------------------
  145|     31|  sexp_release (list);
  ------------------
  |  |  372|     31|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  146|     31|  list = l2;
  147|     31|  name = sexp_nth_string (list, 0);
  ------------------
  |  |  389|     31|#define sexp_nth_string(a, b)        _gcry_sexp_nth_string ((a), (b))
  ------------------
  148|     31|  if (!name)
  ------------------
  |  Branch (148:7): [True: 0, False: 31]
  ------------------
  149|      0|    {
  150|      0|      sexp_release ( list );
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  151|      0|      return GPG_ERR_INV_OBJ;      /* Invalid structure of object. */
  152|      0|    }
  153|     31|  spec = spec_from_name (name);
  154|     31|  xfree (name);
  ------------------
  |  |  150|     31|#define xfree(a)         _gcry_free ((a))
  ------------------
  155|     31|  if (!spec)
  ------------------
  |  Branch (155:7): [True: 0, False: 31]
  ------------------
  156|      0|    {
  157|      0|      sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  158|      0|      return GPG_ERR_PUBKEY_ALGO; /* Unknown algorithm. */
  159|      0|    }
  160|     31|  *r_spec = spec;
  161|     31|  if (r_parms)
  ------------------
  |  Branch (161:7): [True: 31, False: 0]
  ------------------
  162|     31|    *r_parms = list;
  163|      0|  else
  164|      0|    sexp_release (list);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  165|     31|  return 0;
  166|     31|}
pubkey.c:map_algo:
   57|   127k|{
   58|   127k| switch (algo)
   59|   127k|   {
   60|      6|   case GCRY_PK_RSA_E: return GCRY_PK_RSA;
  ------------------
  |  Branch (60:4): [True: 6, False: 127k]
  ------------------
   61|      0|   case GCRY_PK_RSA_S: return GCRY_PK_RSA;
  ------------------
  |  Branch (61:4): [True: 0, False: 127k]
  ------------------
   62|      0|   case GCRY_PK_ELG_E: return GCRY_PK_ELG;
  ------------------
  |  Branch (62:4): [True: 0, False: 127k]
  ------------------
   63|      0|   case GCRY_PK_ECDSA: return GCRY_PK_ECC;
  ------------------
  |  Branch (63:4): [True: 0, False: 127k]
  ------------------
   64|      0|   case GCRY_PK_EDDSA: return GCRY_PK_ECC;
  ------------------
  |  Branch (64:4): [True: 0, False: 127k]
  ------------------
   65|      0|   case GCRY_PK_ECDH:  return GCRY_PK_ECC;
  ------------------
  |  Branch (65:4): [True: 0, False: 127k]
  ------------------
   66|   127k|   default:            return algo;
  ------------------
  |  Branch (66:4): [True: 127k, False: 6]
  ------------------
   67|   127k|   }
   68|   127k|}
pubkey.c:check_pubkey_algo:
  224|   127k|{
  225|   127k|  gcry_err_code_t err = 0;
  226|   127k|  gcry_pk_spec_t *spec;
  227|       |
  228|   127k|  spec = spec_from_algo (algo);
  229|   127k|  if (spec && !spec->flags.disabled && (spec->flags.fips || !fips_mode ()))
  ------------------
  |  |  449|   126k|#define fips_mode() (!_gcry_no_fips_mode_required)
  ------------------
  |  Branch (229:7): [True: 127k, False: 0]
  |  Branch (229:15): [True: 127k, False: 0]
  |  Branch (229:41): [True: 629, False: 126k]
  |  Branch (229:61): [True: 126k, False: 0]
  ------------------
  230|   127k|    {
  231|   127k|      if (((use & GCRY_PK_USAGE_SIGN)
  ------------------
  |  | 1151|   127k|#define GCRY_PK_USAGE_SIGN 1   /* Good for signatures. */
  ------------------
  |  Branch (231:12): [True: 0, False: 127k]
  ------------------
  232|   127k|	   && (! (spec->use & GCRY_PK_USAGE_SIGN)))
  ------------------
  |  | 1151|      0|#define GCRY_PK_USAGE_SIGN 1   /* Good for signatures. */
  ------------------
  |  Branch (232:8): [True: 0, False: 0]
  ------------------
  233|   127k|	  || ((use & GCRY_PK_USAGE_ENCR)
  ------------------
  |  | 1152|   127k|#define GCRY_PK_USAGE_ENCR 2   /* Good for encryption. */
  ------------------
  |  Branch (233:8): [True: 0, False: 127k]
  ------------------
  234|   127k|	      && (! (spec->use & GCRY_PK_USAGE_ENCR))))
  ------------------
  |  | 1152|      0|#define GCRY_PK_USAGE_ENCR 2   /* Good for encryption. */
  ------------------
  |  Branch (234:11): [True: 0, False: 0]
  ------------------
  235|      0|	err = GPG_ERR_WRONG_PUBKEY_ALGO;
  236|   127k|    }
  237|      0|  else
  238|      0|    err = GPG_ERR_PUBKEY_ALGO;
  239|       |
  240|   127k|  return err;
  241|   127k|}

rsa.c:public:
  988|     15|{
  989|     15|  if( output == input )  /* powm doesn't like output and input the same */
  ------------------
  |  Branch (989:7): [True: 0, False: 15]
  ------------------
  990|      0|    {
  991|      0|      gcry_mpi_t x = mpi_alloc( mpi_get_nlimbs(input)*2 );
  ------------------
  |  |   97|      0|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  992|      0|      mpi_powm( x, input, pkey->e, pkey->n );
  ------------------
  |  |  525|      0|#define mpi_powm(w,b,e,m)      _gcry_mpi_powm ( (w), (b), (e), (m) )
  ------------------
  993|      0|      mpi_set(output, x);
  ------------------
  |  |  504|      0|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
  994|      0|      mpi_free(x);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  995|      0|    }
  996|     15|  else
  997|     15|    mpi_powm( output, input, pkey->e, pkey->n );
  ------------------
  |  |  525|     15|#define mpi_powm(w,b,e,m)      _gcry_mpi_powm ( (w), (b), (e), (m) )
  ------------------
  998|     15|}
rsa.c:rsa_verify:
 1664|     15|{
 1665|     15|  gcry_err_code_t rc;
 1666|     15|  struct pk_encoding_ctx ctx;
 1667|     15|  gcry_sexp_t l1 = NULL;
 1668|     15|  gcry_mpi_t sig = NULL;
 1669|     15|  gcry_mpi_t data = NULL;
 1670|     15|  RSA_public_key pk = { NULL, NULL };
 1671|     15|  gcry_mpi_t result = NULL;
 1672|     15|  unsigned int nbits = rsa_get_nbits (keyparms);
 1673|       |
 1674|     15|  rc = rsa_check_verify_keysize (nbits);
 1675|     15|  if (rc)
  ------------------
  |  Branch (1675:7): [True: 0, False: 15]
  ------------------
 1676|      0|    return rc;
 1677|       |
 1678|     15|  _gcry_pk_util_init_encoding_ctx (&ctx, PUBKEY_OP_VERIFY, nbits);
 1679|       |
 1680|       |  /* Extract the data.  */
 1681|     15|  rc = _gcry_pk_util_data_to_mpi (s_data, &data, &ctx);
 1682|     15|  if (rc)
  ------------------
  |  Branch (1682:7): [True: 0, False: 15]
  ------------------
 1683|      0|    goto leave;
 1684|     15|  if (DBG_CIPHER)
  ------------------
  |  |   25|     15|#define DBG_CIPHER _gcry_get_debug_flag( 1 )
  |  |  ------------------
  |  |  |  Branch (25:20): [True: 0, False: 15]
  |  |  ------------------
  ------------------
 1685|      0|    log_printmpi ("rsa_verify data", data);
  ------------------
  |  |  208|      0|#define log_printmpi _gcry_log_printmpi
  ------------------
 1686|     15|  if (ctx.encoding != PUBKEY_ENC_PSS && mpi_is_opaque (data))
  ------------------
  |  |  114|     15|#define mpi_is_opaque(a)      ((a) && ((a)->flags&4))
  |  |  ------------------
  |  |  |  Branch (114:32): [True: 15, False: 0]
  |  |  |  Branch (114:39): [True: 0, False: 15]
  |  |  ------------------
  ------------------
  |  Branch (1686:7): [True: 15, False: 0]
  ------------------
 1687|      0|    {
 1688|      0|      rc = GPG_ERR_INV_DATA;
 1689|      0|      goto leave;
 1690|      0|    }
 1691|       |
 1692|       |  /* Extract the signature value.  */
 1693|     15|  rc = _gcry_pk_util_preparse_sigval (s_sig, rsa_names, &l1, NULL);
 1694|     15|  if (rc)
  ------------------
  |  Branch (1694:7): [True: 0, False: 15]
  ------------------
 1695|      0|    goto leave;
 1696|     15|  rc = sexp_extract_param (l1, NULL, "s", &sig, NULL);
  ------------------
  |  |  391|     15|#define sexp_extract_param           _gcry_sexp_extract_param
  ------------------
 1697|     15|  if (rc)
  ------------------
  |  Branch (1697:7): [True: 0, False: 15]
  ------------------
 1698|      0|    goto leave;
 1699|     15|  if (DBG_CIPHER)
  ------------------
  |  |   25|     15|#define DBG_CIPHER _gcry_get_debug_flag( 1 )
  |  |  ------------------
  |  |  |  Branch (25:20): [True: 0, False: 15]
  |  |  ------------------
  ------------------
 1700|      0|    log_printmpi ("rsa_verify  sig", sig);
  ------------------
  |  |  208|      0|#define log_printmpi _gcry_log_printmpi
  ------------------
 1701|       |
 1702|       |  /* Extract the key.  */
 1703|     15|  rc = sexp_extract_param (keyparms, NULL, "ne", &pk.n, &pk.e, NULL);
  ------------------
  |  |  391|     15|#define sexp_extract_param           _gcry_sexp_extract_param
  ------------------
 1704|     15|  if (rc)
  ------------------
  |  Branch (1704:7): [True: 0, False: 15]
  ------------------
 1705|      0|    goto leave;
 1706|     15|  if (DBG_CIPHER)
  ------------------
  |  |   25|     15|#define DBG_CIPHER _gcry_get_debug_flag( 1 )
  |  |  ------------------
  |  |  |  Branch (25:20): [True: 0, False: 15]
  |  |  ------------------
  ------------------
 1707|      0|    {
 1708|      0|      log_printmpi ("rsa_verify    n", pk.n);
  ------------------
  |  |  208|      0|#define log_printmpi _gcry_log_printmpi
  ------------------
 1709|      0|      log_printmpi ("rsa_verify    e", pk.e);
  ------------------
  |  |  208|      0|#define log_printmpi _gcry_log_printmpi
  ------------------
 1710|      0|    }
 1711|       |
 1712|       |  /* Do RSA computation and compare.  */
 1713|     15|  result = mpi_new (0);
  ------------------
  |  |  491|     15|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
 1714|     15|  public (result, sig, &pk);
 1715|     15|  if (DBG_CIPHER)
  ------------------
  |  |   25|     15|#define DBG_CIPHER _gcry_get_debug_flag( 1 )
  |  |  ------------------
  |  |  |  Branch (25:20): [True: 0, False: 15]
  |  |  ------------------
  ------------------
 1716|      0|    log_printmpi ("rsa_verify  cmp", result);
  ------------------
  |  |  208|      0|#define log_printmpi _gcry_log_printmpi
  ------------------
 1717|     15|  if (ctx.verify_cmp)
  ------------------
  |  Branch (1717:7): [True: 0, False: 15]
  ------------------
 1718|      0|    rc = ctx.verify_cmp (&ctx, result);
 1719|     15|  else
 1720|     15|    rc = mpi_cmp (result, data) ? GPG_ERR_BAD_SIGNATURE : 0;
  ------------------
  |  |  510|     15|#define mpi_cmp( u, v )        _gcry_mpi_cmp( (u), (v) )
  |  |  ------------------
  |  |  |  Branch (510:32): [True: 0, False: 15]
  |  |  ------------------
  ------------------
 1721|       |
 1722|     15| leave:
 1723|     15|  _gcry_mpi_release (result);
 1724|     15|  _gcry_mpi_release (pk.n);
 1725|     15|  _gcry_mpi_release (pk.e);
 1726|     15|  _gcry_mpi_release (data);
 1727|     15|  _gcry_mpi_release (sig);
 1728|     15|  sexp_release (l1);
  ------------------
  |  |  372|     15|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1729|     15|  _gcry_pk_util_free_encoding_ctx (&ctx);
 1730|     15|  if (DBG_CIPHER)
  ------------------
  |  |   25|     15|#define DBG_CIPHER _gcry_get_debug_flag( 1 )
  |  |  ------------------
  |  |  |  Branch (25:20): [True: 0, False: 15]
  |  |  ------------------
  ------------------
 1731|      0|    log_debug ("rsa_verify    => %s\n", rc?gpg_strerror (rc):"Good");
  ------------------
  |  |  205|      0|#define log_debug   _gcry_log_debug
  ------------------
  |  Branch (1731:41): [True: 0, False: 0]
  ------------------
 1732|     15|  return rc;
 1733|     15|}
rsa.c:rsa_check_verify_keysize:
  414|     15|{
  415|     15|  if (fips_mode ())
  ------------------
  |  |  449|     15|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 15]
  |  |  ------------------
  ------------------
  416|      0|    {
  417|      0|      if ((nbits >= 1024 && (nbits % 256) == 0) || nbits >= 2048)
  ------------------
  |  Branch (417:12): [True: 0, False: 0]
  |  Branch (417:29): [True: 0, False: 0]
  |  Branch (417:52): [True: 0, False: 0]
  ------------------
  418|      0|        return GPG_ERR_NO_ERROR;
  419|       |
  420|      0|      return GPG_ERR_INV_VALUE;
  421|      0|    }
  422|       |
  423|     15|  return GPG_ERR_NO_ERROR;
  424|     15|}
rsa.c:rsa_get_nbits:
 1749|     15|{
 1750|     15|  gcry_sexp_t l1;
 1751|     15|  gcry_mpi_t n;
 1752|     15|  unsigned int nbits;
 1753|       |
 1754|     15|  l1 = sexp_find_token (parms, "n", 1);
  ------------------
  |  |  381|     15|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1755|     15|  if (!l1)
  ------------------
  |  Branch (1755:7): [True: 0, False: 15]
  ------------------
 1756|      0|    return 0; /* Parameter N not found.  */
 1757|       |
 1758|     15|  n = sexp_nth_mpi (l1, 1, GCRYMPI_FMT_USG);
  ------------------
  |  |  390|     15|#define sexp_nth_mpi(a, b, c)        _gcry_sexp_nth_mpi ((a), (b), (c))
  ------------------
 1759|     15|  sexp_release (l1);
  ------------------
  |  |  372|     15|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1760|     15|  nbits = n? mpi_get_nbits (n) : 0;
  ------------------
  |  |  552|     15|#define mpi_get_nbits(a)       _gcry_mpi_get_nbits ((a))
  ------------------
  |  Branch (1760:11): [True: 15, False: 0]
  ------------------
 1761|     15|  _gcry_mpi_release (n);
 1762|     15|  return nbits;
 1763|     15|}
rsa.c:compute_keygrip:
 1781|      6|{
 1782|      6|  gcry_sexp_t l1;
 1783|      6|  const char *data;
 1784|      6|  size_t datalen;
 1785|       |
 1786|      6|  l1 = sexp_find_token (keyparam, "n", 1);
  ------------------
  |  |  381|      6|#define sexp_find_token(a, b, c)     _gcry_sexp_find_token ((a), (b), (c))
  ------------------
 1787|      6|  if (!l1)
  ------------------
  |  Branch (1787:7): [True: 0, False: 6]
  ------------------
 1788|      0|    return GPG_ERR_NO_OBJ;
 1789|       |
 1790|      6|  data = sexp_nth_data (l1, 1, &datalen);
  ------------------
  |  |  387|      6|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
 1791|      6|  if (!data)
  ------------------
  |  Branch (1791:7): [True: 0, False: 6]
  ------------------
 1792|      0|    {
 1793|      0|      sexp_release (l1);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1794|      0|      return GPG_ERR_NO_OBJ;
 1795|      0|    }
 1796|       |
 1797|      6|  _gcry_md_write (md, data, datalen);
 1798|      6|  sexp_release (l1);
  ------------------
  |  |  372|      6|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 1799|       |
 1800|      6|  return 0;
 1801|      6|}

sha1.c:sha1_init:
  298|  1.01k|{
  299|  1.01k|  SHA1_CONTEXT *hd = context;
  300|  1.01k|  unsigned int features = _gcry_get_hw_features ();
  301|       |
  302|  1.01k|  (void)flags;
  303|       |
  304|  1.01k|  hd->h0 = 0x67452301;
  305|  1.01k|  hd->h1 = 0xefcdab89;
  306|  1.01k|  hd->h2 = 0x98badcfe;
  307|  1.01k|  hd->h3 = 0x10325476;
  308|  1.01k|  hd->h4 = 0xc3d2e1f0;
  309|       |
  310|  1.01k|  hd->bctx.nblocks = 0;
  311|  1.01k|  hd->bctx.nblocks_high = 0;
  312|  1.01k|  hd->bctx.count = 0;
  313|  1.01k|  hd->bctx.blocksize_shift = _gcry_ctz(64);
  314|       |
  315|       |  /* Order of feature checks is important here; last match will be
  316|       |   * selected.  Keep slower implementations at the top and faster at
  317|       |   * the bottom.  */
  318|  1.01k|  hd->bctx.bwrite = do_transform_generic;
  319|  1.01k|#ifdef USE_SSSE3
  320|  1.01k|  if ((features & HWF_INTEL_SSSE3) != 0)
  ------------------
  |  |  229|  1.01k|#define HWF_INTEL_SSSE3         (1 << 7)
  ------------------
  |  Branch (320:7): [True: 1.01k, False: 0]
  ------------------
  321|  1.01k|    hd->bctx.bwrite = do_sha1_transform_amd64_ssse3;
  322|  1.01k|#endif
  323|  1.01k|#ifdef USE_AVX
  324|       |  /* AVX implementation uses SHLD which is known to be slow on non-Intel CPUs.
  325|       |   * Therefore use this implementation on Intel CPUs only. */
  326|  1.01k|  if ((features & HWF_INTEL_AVX) && (features & HWF_INTEL_FAST_SHLD))
  ------------------
  |  |  234|  1.01k|#define HWF_INTEL_AVX           (1 << 12)
  ------------------
                if ((features & HWF_INTEL_AVX) && (features & HWF_INTEL_FAST_SHLD))
  ------------------
  |  |  227|  1.01k|#define HWF_INTEL_FAST_SHLD     (1 << 5)
  ------------------
  |  Branch (326:7): [True: 1.01k, False: 0]
  |  Branch (326:37): [True: 1.01k, False: 0]
  ------------------
  327|  1.01k|    hd->bctx.bwrite = do_sha1_transform_amd64_avx;
  328|  1.01k|#endif
  329|  1.01k|#ifdef USE_BMI2
  330|  1.01k|  if ((features & HWF_INTEL_AVX) && (features & HWF_INTEL_BMI2))
  ------------------
  |  |  234|  1.01k|#define HWF_INTEL_AVX           (1 << 12)
  ------------------
                if ((features & HWF_INTEL_AVX) && (features & HWF_INTEL_BMI2))
  ------------------
  |  |  228|  1.01k|#define HWF_INTEL_BMI2          (1 << 6)
  ------------------
  |  Branch (330:7): [True: 1.01k, False: 0]
  |  Branch (330:37): [True: 1.01k, False: 0]
  ------------------
  331|  1.01k|    hd->bctx.bwrite = do_sha1_transform_amd64_avx_bmi2;
  332|  1.01k|#endif
  333|  1.01k|#ifdef USE_AVX2
  334|  1.01k|  if ((features & HWF_INTEL_AVX2) && (features & HWF_INTEL_AVX) &&
  ------------------
  |  |  235|  1.01k|#define HWF_INTEL_AVX2          (1 << 13)
  ------------------
                if ((features & HWF_INTEL_AVX2) && (features & HWF_INTEL_AVX) &&
  ------------------
  |  |  234|  1.01k|#define HWF_INTEL_AVX           (1 << 12)
  ------------------
  |  Branch (334:7): [True: 1.01k, False: 0]
  |  Branch (334:38): [True: 1.01k, False: 0]
  ------------------
  335|  1.01k|      (features & HWF_INTEL_BMI2))
  ------------------
  |  |  228|  1.01k|#define HWF_INTEL_BMI2          (1 << 6)
  ------------------
  |  Branch (335:7): [True: 1.01k, False: 0]
  ------------------
  336|  1.01k|    hd->bctx.bwrite = do_sha1_transform_amd64_avx2_bmi2;
  337|  1.01k|#endif
  338|  1.01k|#ifdef USE_SHAEXT
  339|  1.01k|  if ((features & HWF_INTEL_SHAEXT) && (features & HWF_INTEL_SSE4_1))
  ------------------
  |  |  238|  1.01k|#define HWF_INTEL_SHAEXT        (1 << 16)
  ------------------
                if ((features & HWF_INTEL_SHAEXT) && (features & HWF_INTEL_SSE4_1))
  ------------------
  |  |  230|      0|#define HWF_INTEL_SSE4_1        (1 << 8)
  ------------------
  |  Branch (339:7): [True: 0, False: 1.01k]
  |  Branch (339:40): [True: 0, False: 0]
  ------------------
  340|      0|    hd->bctx.bwrite = do_sha1_transform_intel_shaext;
  341|  1.01k|#endif
  342|       |#ifdef USE_NEON
  343|       |  if ((features & HWF_ARM_NEON) != 0)
  344|       |    hd->bctx.bwrite = do_sha1_transform_armv7_neon;
  345|       |#endif
  346|       |#ifdef USE_ARM_CE
  347|       |  if ((features & HWF_ARM_SHA1) != 0)
  348|       |    hd->bctx.bwrite = do_sha1_transform_armv8_ce;
  349|       |#endif
  350|       |#ifdef SHA1_USE_S390X_CRYPTO
  351|       |  hd->use_s390x_crypto = 0;
  352|       |  if ((features & HWF_S390X_MSA) != 0)
  353|       |    {
  354|       |      if ((kimd_query () & km_function_to_mask (KMID_FUNCTION_SHA1)) &&
  355|       |	  (klmd_query () & km_function_to_mask (KMID_FUNCTION_SHA1)))
  356|       |	{
  357|       |	  hd->bctx.bwrite = do_sha1_transform_s390x;
  358|       |	  hd->use_s390x_crypto = 1;
  359|       |	}
  360|       |    }
  361|       |#endif
  362|       |
  363|  1.01k|  (void)features;
  364|  1.01k|}
sha1.c:do_sha1_transform_amd64_avx_bmi2:
  176|  1.12k|{
  177|  1.12k|  SHA1_CONTEXT *hd = ctx;
  178|  1.12k|  return _gcry_sha1_transform_amd64_avx_bmi2 (&hd->h0, data, nblks)
  179|  1.12k|         + ASM_EXTRA_STACK;
  ------------------
  |  |  133|  1.12k|#  define ASM_EXTRA_STACK 0
  ------------------
  180|  1.12k|}
sha1.c:do_sha1_transform_amd64_avx2_bmi2:
  190|  1.15k|{
  191|  1.15k|  SHA1_CONTEXT *hd = ctx;
  192|       |
  193|       |  /* AVX2/BMI2 function only handles pair of blocks so nblks needs to be
  194|       |   * multiple of 2 and function does not handle zero nblks. Use AVX/BMI2
  195|       |   * code to handle these cases. */
  196|       |
  197|  1.15k|  if (nblks <= 1)
  ------------------
  |  Branch (197:7): [True: 1.12k, False: 38]
  ------------------
  198|  1.12k|    return do_sha1_transform_amd64_avx_bmi2 (ctx, data, nblks);
  199|       |
  200|     38|  if (nblks & 1)
  ------------------
  |  Branch (200:7): [True: 17, False: 21]
  ------------------
  201|     17|    {
  202|     17|      (void)_gcry_sha1_transform_amd64_avx_bmi2 (&hd->h0, data, 1);
  203|     17|      nblks--;
  204|     17|      data += 64;
  205|     17|    }
  206|       |
  207|     38|  return _gcry_sha1_transform_amd64_avx2_bmi2 (&hd->h0, data, nblks)
  208|     38|         + ASM_EXTRA_STACK;
  ------------------
  |  |  133|     38|#  define ASM_EXTRA_STACK 0
  ------------------
  209|  1.15k|}
sha1.c:_gcry_sha1_hash_buffers:
  642|     25|{
  643|     25|  SHA1_CONTEXT hd;
  644|       |
  645|     25|  (void)nbytes;
  646|       |
  647|     25|  sha1_init (&hd, 0);
  648|     50|  for (;iovcnt > 0; iov++, iovcnt--)
  ------------------
  |  Branch (648:9): [True: 25, False: 25]
  ------------------
  649|     25|    _gcry_md_block_write (&hd,
  650|     25|                          (const char*)iov[0].data + iov[0].off, iov[0].len);
  651|     25|  sha1_final (&hd);
  652|     25|  memcpy (outbuf, hd.bctx.buf, 20);
  653|     25|}
sha1.c:sha1_final:
  556|  1.01k|{
  557|  1.01k|  SHA1_CONTEXT *hd = context;
  558|  1.01k|  u32 t, th, msb, lsb;
  559|  1.01k|  unsigned char *p;
  560|  1.01k|  unsigned int burn;
  561|       |
  562|  1.01k|  t = hd->bctx.nblocks;
  563|  1.01k|  if (sizeof t == sizeof hd->bctx.nblocks)
  ------------------
  |  Branch (563:7): [Folded - Ignored]
  ------------------
  564|      0|    th = hd->bctx.nblocks_high;
  565|  1.01k|  else
  566|  1.01k|    th = hd->bctx.nblocks >> 32;
  567|       |
  568|       |  /* multiply by 64 to make a byte count */
  569|  1.01k|  lsb = t << 6;
  570|  1.01k|  msb = (th << 6) | (t >> 26);
  571|       |  /* add the count */
  572|  1.01k|  t = lsb;
  573|  1.01k|  if( (lsb += hd->bctx.count) < t )
  ------------------
  |  Branch (573:7): [True: 0, False: 1.01k]
  ------------------
  574|      0|    msb++;
  575|       |  /* multiply by 8 to make a bit count */
  576|  1.01k|  t = lsb;
  577|  1.01k|  lsb <<= 3;
  578|  1.01k|  msb <<= 3;
  579|  1.01k|  msb |= t >> 29;
  580|       |
  581|  1.01k|  if (0)
  ------------------
  |  Branch (581:7): [Folded - Ignored]
  ------------------
  582|      0|    { }
  583|       |#ifdef SHA1_USE_S390X_CRYPTO
  584|       |  else if (hd->use_s390x_crypto)
  585|       |    {
  586|       |      burn = do_sha1_final_s390x (hd, hd->bctx.buf, hd->bctx.count, msb, lsb);
  587|       |    }
  588|       |#endif
  589|  1.01k|  else if (hd->bctx.count < 56)  /* enough room */
  ------------------
  |  Branch (589:12): [True: 1.01k, False: 2]
  ------------------
  590|  1.01k|    {
  591|  1.01k|      hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad */
  592|  1.01k|      if (hd->bctx.count < 56)
  ------------------
  |  Branch (592:11): [True: 1.01k, False: 0]
  ------------------
  593|  1.01k|	memset (&hd->bctx.buf[hd->bctx.count], 0, 56 - hd->bctx.count);
  594|       |
  595|       |      /* append the 64 bit count */
  596|  1.01k|      buf_put_be32(hd->bctx.buf + 56, msb);
  597|  1.01k|      buf_put_be32(hd->bctx.buf + 60, lsb);
  598|  1.01k|      burn = (*hd->bctx.bwrite) ( hd, hd->bctx.buf, 1 );
  599|  1.01k|    }
  600|      2|  else  /* need one extra block */
  601|      2|    {
  602|      2|      hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad character */
  603|       |      /* fill pad and next block with zeroes */
  604|      2|      memset (&hd->bctx.buf[hd->bctx.count], 0, 64 - hd->bctx.count + 56);
  605|       |
  606|       |      /* append the 64 bit count */
  607|      2|      buf_put_be32(hd->bctx.buf + 64 + 56, msb);
  608|      2|      buf_put_be32(hd->bctx.buf + 64 + 60, lsb);
  609|      2|      burn = (*hd->bctx.bwrite) ( hd, hd->bctx.buf, 2 );
  610|      2|    }
  611|       |
  612|  1.01k|  p = hd->bctx.buf;
  613|  1.01k|#define X(a) do { buf_put_be32(p, hd->h##a); p += 4; } while(0)
  614|  1.01k|  X(0);
  ------------------
  |  |  613|  1.01k|#define X(a) do { buf_put_be32(p, hd->h##a); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (613:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  615|  1.01k|  X(1);
  ------------------
  |  |  613|  1.01k|#define X(a) do { buf_put_be32(p, hd->h##a); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (613:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  616|  1.01k|  X(2);
  ------------------
  |  |  613|  1.01k|#define X(a) do { buf_put_be32(p, hd->h##a); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (613:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  617|  1.01k|  X(3);
  ------------------
  |  |  613|  1.01k|#define X(a) do { buf_put_be32(p, hd->h##a); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (613:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  618|  1.01k|  X(4);
  ------------------
  |  |  613|  1.01k|#define X(a) do { buf_put_be32(p, hd->h##a); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (613:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  619|  1.01k|#undef X
  620|       |
  621|  1.01k|  hd->bctx.count = 0;
  622|       |
  623|  1.01k|  _gcry_burn_stack (burn);
  ------------------
  |  |  371|  1.01k|	do { __gcry_burn_stack (bytes); \
  |  |  372|  1.01k|	     __gcry_burn_stack_dummy (); } while(0)
  |  |  ------------------
  |  |  |  |  364|  1.01k|#define  __gcry_burn_stack_dummy() asm volatile ("":::"memory")
  |  |  ------------------
  |  |  |  Branch (372:43): [Folded - Ignored]
  |  |  ------------------
  ------------------
  624|  1.01k|}
sha1.c:sha1_read:
  628|    994|{
  629|    994|  SHA1_CONTEXT *hd = context;
  630|       |
  631|    994|  return hd->bctx.buf;
  632|    994|}

sha256.c:sha256_common_init:
  287|     64|{
  288|     64|  unsigned int features = _gcry_get_hw_features ();
  289|       |
  290|     64|  hd->bctx.nblocks = 0;
  291|     64|  hd->bctx.nblocks_high = 0;
  292|     64|  hd->bctx.count = 0;
  293|     64|  hd->bctx.blocksize_shift = _gcry_ctz(64);
  294|       |
  295|       |  /* Order of feature checks is important here; last match will be
  296|       |   * selected.  Keep slower implementations at the top and faster at
  297|       |   * the bottom.  */
  298|     64|  hd->bctx.bwrite = do_transform_generic;
  299|     64|#ifdef USE_SSSE3
  300|     64|  if ((features & HWF_INTEL_SSSE3) != 0)
  ------------------
  |  |  229|     64|#define HWF_INTEL_SSSE3         (1 << 7)
  ------------------
  |  Branch (300:7): [True: 64, False: 0]
  ------------------
  301|     64|    hd->bctx.bwrite = do_sha256_transform_amd64_ssse3;
  302|     64|#endif
  303|     64|#ifdef USE_AVX
  304|       |  /* AVX implementation uses SHLD which is known to be slow on non-Intel CPUs.
  305|       |   * Therefore use this implementation on Intel CPUs only. */
  306|     64|  if ((features & HWF_INTEL_AVX) && (features & HWF_INTEL_FAST_SHLD))
  ------------------
  |  |  234|     64|#define HWF_INTEL_AVX           (1 << 12)
  ------------------
                if ((features & HWF_INTEL_AVX) && (features & HWF_INTEL_FAST_SHLD))
  ------------------
  |  |  227|     64|#define HWF_INTEL_FAST_SHLD     (1 << 5)
  ------------------
  |  Branch (306:7): [True: 64, False: 0]
  |  Branch (306:37): [True: 64, False: 0]
  ------------------
  307|     64|    hd->bctx.bwrite = do_sha256_transform_amd64_avx;
  308|     64|#endif
  309|     64|#ifdef USE_AVX2
  310|     64|  if ((features & HWF_INTEL_AVX2) && (features & HWF_INTEL_BMI2))
  ------------------
  |  |  235|     64|#define HWF_INTEL_AVX2          (1 << 13)
  ------------------
                if ((features & HWF_INTEL_AVX2) && (features & HWF_INTEL_BMI2))
  ------------------
  |  |  228|     64|#define HWF_INTEL_BMI2          (1 << 6)
  ------------------
  |  Branch (310:7): [True: 64, False: 0]
  |  Branch (310:38): [True: 64, False: 0]
  ------------------
  311|     64|    hd->bctx.bwrite = do_sha256_transform_amd64_avx2;
  312|     64|#endif
  313|     64|#ifdef USE_SHAEXT
  314|     64|  if ((features & HWF_INTEL_SHAEXT) && (features & HWF_INTEL_SSE4_1))
  ------------------
  |  |  238|     64|#define HWF_INTEL_SHAEXT        (1 << 16)
  ------------------
                if ((features & HWF_INTEL_SHAEXT) && (features & HWF_INTEL_SSE4_1))
  ------------------
  |  |  230|      0|#define HWF_INTEL_SSE4_1        (1 << 8)
  ------------------
  |  Branch (314:7): [True: 0, False: 64]
  |  Branch (314:40): [True: 0, False: 0]
  ------------------
  315|      0|    hd->bctx.bwrite = do_sha256_transform_intel_shaext;
  316|     64|#endif
  317|       |#ifdef USE_ARM_CE
  318|       |  if ((features & HWF_ARM_SHA2) != 0)
  319|       |    hd->bctx.bwrite = do_sha256_transform_armv8_ce;
  320|       |#endif
  321|       |#ifdef USE_PPC_CRYPTO
  322|       |  if ((features & HWF_PPC_VCRYPTO) != 0)
  323|       |    hd->bctx.bwrite = do_sha256_transform_ppc8;
  324|       |  if ((features & HWF_PPC_VCRYPTO) != 0 && (features & HWF_PPC_ARCH_3_00) != 0)
  325|       |    hd->bctx.bwrite = do_sha256_transform_ppc9;
  326|       |#endif
  327|       |#ifdef USE_S390X_CRYPTO
  328|       |  hd->use_s390x_crypto = 0;
  329|       |  if ((features & HWF_S390X_MSA) != 0)
  330|       |    {
  331|       |      if ((kimd_query () & km_function_to_mask (KMID_FUNCTION_SHA256)) &&
  332|       |	  (klmd_query () & km_function_to_mask (KMID_FUNCTION_SHA256)))
  333|       |	{
  334|       |	  hd->bctx.bwrite = do_sha256_transform_s390x;
  335|       |	  hd->use_s390x_crypto = 1;
  336|       |	}
  337|       |    }
  338|       |#endif
  339|     64|  (void)features;
  340|     64|}
sha256.c:do_sha256_transform_amd64_avx2:
  184|    178|{
  185|    178|  SHA256_CONTEXT *hd = ctx;
  186|    178|  return _gcry_sha256_transform_amd64_avx2 (data, hd->h, nblks)
  187|    178|         + ASM_EXTRA_STACK;
  ------------------
  |  |  141|    178|#  define ASM_EXTRA_STACK 0
  ------------------
  188|    178|}
sha256.c:sha256_final:
  549|     64|{
  550|     64|  SHA256_CONTEXT *hd = context;
  551|     64|  u32 t, th, msb, lsb;
  552|     64|  byte *p;
  553|     64|  unsigned int burn;
  554|       |
  555|     64|  t = hd->bctx.nblocks;
  556|     64|  if (sizeof t == sizeof hd->bctx.nblocks)
  ------------------
  |  Branch (556:7): [Folded - Ignored]
  ------------------
  557|      0|    th = hd->bctx.nblocks_high;
  558|     64|  else
  559|     64|    th = hd->bctx.nblocks >> 32;
  560|       |
  561|       |  /* multiply by 64 to make a byte count */
  562|     64|  lsb = t << 6;
  563|     64|  msb = (th << 6) | (t >> 26);
  564|       |  /* add the count */
  565|     64|  t = lsb;
  566|     64|  if ((lsb += hd->bctx.count) < t)
  ------------------
  |  Branch (566:7): [True: 0, False: 64]
  ------------------
  567|      0|    msb++;
  568|       |  /* multiply by 8 to make a bit count */
  569|     64|  t = lsb;
  570|     64|  lsb <<= 3;
  571|     64|  msb <<= 3;
  572|     64|  msb |= t >> 29;
  573|       |
  574|     64|  if (0)
  ------------------
  |  Branch (574:7): [Folded - Ignored]
  ------------------
  575|      0|    { }
  576|       |#ifdef USE_S390X_CRYPTO
  577|       |  else if (hd->use_s390x_crypto)
  578|       |    {
  579|       |      burn = do_sha256_final_s390x (hd, hd->bctx.buf, hd->bctx.count, msb, lsb);
  580|       |    }
  581|       |#endif
  582|     64|  else if (hd->bctx.count < 56)  /* enough room */
  ------------------
  |  Branch (582:12): [True: 47, False: 17]
  ------------------
  583|     47|    {
  584|     47|      hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad */
  585|     47|      if (hd->bctx.count < 56)
  ------------------
  |  Branch (585:11): [True: 47, False: 0]
  ------------------
  586|     47|	memset (&hd->bctx.buf[hd->bctx.count], 0, 56 - hd->bctx.count);
  587|       |
  588|       |      /* append the 64 bit count */
  589|     47|      buf_put_be32(hd->bctx.buf + 56, msb);
  590|     47|      buf_put_be32(hd->bctx.buf + 60, lsb);
  591|     47|      burn = (*hd->bctx.bwrite) (hd, hd->bctx.buf, 1);
  592|     47|    }
  593|     17|  else  /* need one extra block */
  594|     17|    {
  595|     17|      hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad character */
  596|       |      /* fill pad and next block with zeroes */
  597|     17|      memset (&hd->bctx.buf[hd->bctx.count], 0, 64 - hd->bctx.count + 56);
  598|       |
  599|       |      /* append the 64 bit count */
  600|     17|      buf_put_be32(hd->bctx.buf + 64 + 56, msb);
  601|     17|      buf_put_be32(hd->bctx.buf + 64 + 60, lsb);
  602|     17|      burn = (*hd->bctx.bwrite) (hd, hd->bctx.buf, 2);
  603|     17|    }
  604|       |
  605|     64|  p = hd->bctx.buf;
  606|     64|#define X(a) do { buf_put_be32(p, hd->h[a]); p += 4; } while(0)
  607|     64|  X(0);
  ------------------
  |  |  606|     64|#define X(a) do { buf_put_be32(p, hd->h[a]); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (606:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  608|     64|  X(1);
  ------------------
  |  |  606|     64|#define X(a) do { buf_put_be32(p, hd->h[a]); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (606:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  609|     64|  X(2);
  ------------------
  |  |  606|     64|#define X(a) do { buf_put_be32(p, hd->h[a]); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (606:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  610|     64|  X(3);
  ------------------
  |  |  606|     64|#define X(a) do { buf_put_be32(p, hd->h[a]); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (606:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  611|     64|  X(4);
  ------------------
  |  |  606|     64|#define X(a) do { buf_put_be32(p, hd->h[a]); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (606:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  612|     64|  X(5);
  ------------------
  |  |  606|     64|#define X(a) do { buf_put_be32(p, hd->h[a]); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (606:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  613|     64|  X(6);
  ------------------
  |  |  606|     64|#define X(a) do { buf_put_be32(p, hd->h[a]); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (606:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  614|     64|  X(7);
  ------------------
  |  |  606|     64|#define X(a) do { buf_put_be32(p, hd->h[a]); p += 4; } while(0)
  |  |  ------------------
  |  |  |  Branch (606:62): [Folded - Ignored]
  |  |  ------------------
  ------------------
  615|     64|#undef X
  616|       |
  617|     64|  hd->bctx.count = 0;
  618|       |
  619|     64|  _gcry_burn_stack (burn);
  ------------------
  |  |  371|     64|	do { __gcry_burn_stack (bytes); \
  |  |  372|     64|	     __gcry_burn_stack_dummy (); } while(0)
  |  |  ------------------
  |  |  |  |  364|     64|#define  __gcry_burn_stack_dummy() asm volatile ("":::"memory")
  |  |  ------------------
  |  |  |  Branch (372:43): [Folded - Ignored]
  |  |  ------------------
  ------------------
  620|     64|}
sha256.c:sha256_read:
  624|     64|{
  625|     64|  SHA256_CONTEXT *hd = context;
  626|       |
  627|     64|  return hd->bctx.buf;
  628|     64|}
sha256.c:sha256_init:
  345|     64|{
  346|     64|  SHA256_CONTEXT *hd = context;
  347|       |
  348|     64|  (void)flags;
  349|       |
  350|     64|  hd->h[0] = 0x6a09e667;
  351|     64|  hd->h[1] = 0xbb67ae85;
  352|     64|  hd->h[2] = 0x3c6ef372;
  353|     64|  hd->h[3] = 0xa54ff53a;
  354|     64|  hd->h[4] = 0x510e527f;
  355|     64|  hd->h[5] = 0x9b05688c;
  356|     64|  hd->h[6] = 0x1f83d9ab;
  357|     64|  hd->h[7] = 0x5be0cd19;
  358|       |
  359|     64|  sha256_common_init (hd);
  360|     64|}

sha512.c:sha512_init:
  500|    127|{
  501|    127|  SHA512_CONTEXT *ctx = context;
  502|    127|  SHA512_STATE *hd = &ctx->state;
  503|       |
  504|    127|  hd->h[0] = U64_C(0x6a09e667f3bcc908);
  ------------------
  |  |  106|    127|#  define U64_C(c) (UINT64_C(c))
  ------------------
  505|    127|  hd->h[1] = U64_C(0xbb67ae8584caa73b);
  ------------------
  |  |  106|    127|#  define U64_C(c) (UINT64_C(c))
  ------------------
  506|    127|  hd->h[2] = U64_C(0x3c6ef372fe94f82b);
  ------------------
  |  |  106|    127|#  define U64_C(c) (UINT64_C(c))
  ------------------
  507|    127|  hd->h[3] = U64_C(0xa54ff53a5f1d36f1);
  ------------------
  |  |  106|    127|#  define U64_C(c) (UINT64_C(c))
  ------------------
  508|    127|  hd->h[4] = U64_C(0x510e527fade682d1);
  ------------------
  |  |  106|    127|#  define U64_C(c) (UINT64_C(c))
  ------------------
  509|    127|  hd->h[5] = U64_C(0x9b05688c2b3e6c1f);
  ------------------
  |  |  106|    127|#  define U64_C(c) (UINT64_C(c))
  ------------------
  510|    127|  hd->h[6] = U64_C(0x1f83d9abfb41bd6b);
  ------------------
  |  |  106|    127|#  define U64_C(c) (UINT64_C(c))
  ------------------
  511|    127|  hd->h[7] = U64_C(0x5be0cd19137e2179);
  ------------------
  |  |  106|    127|#  define U64_C(c) (UINT64_C(c))
  ------------------
  512|       |
  513|    127|  sha512_init_common (ctx, flags);
  514|    127|}
sha512.c:sha512_init_common:
  433|    127|{
  434|    127|  unsigned int features = _gcry_get_hw_features ();
  435|       |
  436|    127|  (void)flags;
  437|    127|  (void)k;
  438|       |
  439|    127|  ctx->bctx.nblocks = 0;
  440|    127|  ctx->bctx.nblocks_high = 0;
  441|    127|  ctx->bctx.count = 0;
  442|    127|  ctx->bctx.blocksize_shift = _gcry_ctz(128);
  443|       |
  444|       |  /* Order of feature checks is important here; last match will be
  445|       |   * selected.  Keep slower implementations at the top and faster at
  446|       |   * the bottom.  */
  447|    127|  ctx->bctx.bwrite = do_transform_generic;
  448|       |#ifdef USE_ARM_NEON_ASM
  449|       |  if ((features & HWF_ARM_NEON) != 0)
  450|       |    ctx->bctx.bwrite = do_sha512_transform_armv7_neon;
  451|       |#endif
  452|       |#ifdef USE_ARM64_SHA512
  453|       |  if ((features & HWF_ARM_NEON) && (features & HWF_ARM_SHA512))
  454|       |    ctx->bctx.bwrite = do_sha512_transform_armv8_ce;
  455|       |#endif
  456|    127|#ifdef USE_SSSE3
  457|    127|  if ((features & HWF_INTEL_SSSE3) != 0)
  ------------------
  |  |  229|    127|#define HWF_INTEL_SSSE3         (1 << 7)
  ------------------
  |  Branch (457:7): [True: 127, False: 0]
  ------------------
  458|    127|    ctx->bctx.bwrite = do_sha512_transform_amd64_ssse3;
  459|    127|#endif
  460|    127|#ifdef USE_AVX
  461|    127|  if ((features & HWF_INTEL_AVX) && (features & HWF_INTEL_FAST_SHLD))
  ------------------
  |  |  234|    127|#define HWF_INTEL_AVX           (1 << 12)
  ------------------
                if ((features & HWF_INTEL_AVX) && (features & HWF_INTEL_FAST_SHLD))
  ------------------
  |  |  227|    127|#define HWF_INTEL_FAST_SHLD     (1 << 5)
  ------------------
  |  Branch (461:7): [True: 127, False: 0]
  |  Branch (461:37): [True: 127, False: 0]
  ------------------
  462|    127|    ctx->bctx.bwrite = do_sha512_transform_amd64_avx;
  463|    127|#endif
  464|    127|#ifdef USE_AVX2
  465|    127|  if ((features & HWF_INTEL_AVX2) && (features & HWF_INTEL_BMI2))
  ------------------
  |  |  235|    127|#define HWF_INTEL_AVX2          (1 << 13)
  ------------------
                if ((features & HWF_INTEL_AVX2) && (features & HWF_INTEL_BMI2))
  ------------------
  |  |  228|    127|#define HWF_INTEL_BMI2          (1 << 6)
  ------------------
  |  Branch (465:7): [True: 127, False: 0]
  |  Branch (465:38): [True: 127, False: 0]
  ------------------
  466|    127|    ctx->bctx.bwrite = do_sha512_transform_amd64_avx2;
  467|    127|#endif
  468|    127|#ifdef USE_AVX512
  469|    127|  if ((features & HWF_INTEL_AVX512) && (features & HWF_INTEL_CPU))
  ------------------
  |  |  240|    127|#define HWF_INTEL_AVX512        (1 << 18)
  ------------------
                if ((features & HWF_INTEL_AVX512) && (features & HWF_INTEL_CPU))
  ------------------
  |  |  226|      0|#define HWF_INTEL_CPU           (1 << 4)
  ------------------
  |  Branch (469:7): [True: 0, False: 127]
  |  Branch (469:40): [True: 0, False: 0]
  ------------------
  470|      0|    ctx->bctx.bwrite = do_sha512_transform_amd64_avx512;
  471|    127|#endif
  472|       |#ifdef USE_PPC_CRYPTO
  473|       |  if ((features & HWF_PPC_VCRYPTO) != 0)
  474|       |    ctx->bctx.bwrite = do_sha512_transform_ppc8;
  475|       |  if ((features & HWF_PPC_VCRYPTO) != 0 && (features & HWF_PPC_ARCH_3_00) != 0)
  476|       |    ctx->bctx.bwrite = do_sha512_transform_ppc9;
  477|       |#endif
  478|       |#ifdef USE_SSSE3_I386
  479|       |  if ((features & HWF_INTEL_SSSE3) != 0)
  480|       |    ctx->bctx.bwrite = do_sha512_transform_i386_ssse3;
  481|       |#endif
  482|       |#ifdef USE_S390X_CRYPTO
  483|       |  ctx->use_s390x_crypto = 0;
  484|       |  if ((features & HWF_S390X_MSA) != 0)
  485|       |    {
  486|       |      if ((kimd_query () & km_function_to_mask (KMID_FUNCTION_SHA512)) &&
  487|       |	  (klmd_query () & km_function_to_mask (KMID_FUNCTION_SHA512)))
  488|       |	{
  489|       |	  ctx->bctx.bwrite = do_sha512_transform_s390x;
  490|       |	  ctx->use_s390x_crypto = 1;
  491|       |	}
  492|       |    }
  493|       |#endif
  494|    127|  (void)features;
  495|    127|}
sha512.c:do_sha512_transform_amd64_avx2:
  312|    127|{
  313|    127|  SHA512_CONTEXT *hd = ctx;
  314|    127|  unsigned int burn;
  315|    127|  burn = _gcry_sha512_transform_amd64_avx2 (data, &hd->state, nblks);
  316|    127|  burn += burn > 0 ? ASM_EXTRA_STACK : 0;
  ------------------
  |  |  236|      0|#  define ASM_EXTRA_STACK 0
  ------------------
  |  Branch (316:11): [True: 0, False: 127]
  ------------------
  317|    127|  return burn;
  318|    127|}
sha512.c:sha512_final:
  856|    127|{
  857|    127|  SHA512_CONTEXT *hd = context;
  858|    127|  unsigned int burn;
  859|    127|  u64 t, th, msb, lsb;
  860|    127|  byte *p;
  861|       |
  862|    127|  t = hd->bctx.nblocks;
  863|       |  /* if (sizeof t == sizeof hd->bctx.nblocks) */
  864|    127|  th = hd->bctx.nblocks_high;
  865|       |  /* else */
  866|       |  /*   th = hd->bctx.nblocks >> 64; In case we ever use u128  */
  867|       |
  868|       |  /* multiply by 128 to make a byte count */
  869|    127|  lsb = t << 7;
  870|    127|  msb = (th << 7) | (t >> 57);
  871|       |  /* add the count */
  872|    127|  t = lsb;
  873|    127|  if ((lsb += hd->bctx.count) < t)
  ------------------
  |  Branch (873:7): [True: 0, False: 127]
  ------------------
  874|      0|    msb++;
  875|       |  /* multiply by 8 to make a bit count */
  876|    127|  t = lsb;
  877|    127|  lsb <<= 3;
  878|    127|  msb <<= 3;
  879|    127|  msb |= t >> 61;
  880|       |
  881|    127|  if (0)
  ------------------
  |  Branch (881:7): [Folded - Ignored]
  ------------------
  882|      0|    { }
  883|       |#ifdef USE_S390X_CRYPTO
  884|       |  else if (hd->use_s390x_crypto)
  885|       |    {
  886|       |      burn = do_sha512_final_s390x (hd, hd->bctx.buf, hd->bctx.count, msb, lsb);
  887|       |    }
  888|       |#endif
  889|    127|  else
  890|    127|    {
  891|    127|      if (hd->bctx.count < 112)
  ------------------
  |  Branch (891:11): [True: 127, False: 0]
  ------------------
  892|    127|	{
  893|       |	  /* enough room */
  894|    127|	  hd->bctx.buf[hd->bctx.count++] = 0x80;  /* pad */
  895|    127|	  if (hd->bctx.count < 112)
  ------------------
  |  Branch (895:8): [True: 127, False: 0]
  ------------------
  896|    127|	    memset (&hd->bctx.buf[hd->bctx.count], 0, 112 - hd->bctx.count);
  897|    127|	}
  898|      0|      else
  899|      0|	{
  900|       |	  /* need one extra block */
  901|      0|	  hd->bctx.buf[hd->bctx.count++] = 0x80;  /* pad character */
  902|      0|	  if (hd->bctx.count < 128)
  ------------------
  |  Branch (902:8): [True: 0, False: 0]
  ------------------
  903|      0|	    memset (&hd->bctx.buf[hd->bctx.count], 0, 128 - hd->bctx.count);
  904|      0|	  hd->bctx.count = 128;
  905|      0|	  _gcry_md_block_write (context, NULL, 0); /* flush */
  906|      0|	  memset (hd->bctx.buf, 0, 112);  /* fill next block with zeroes */
  907|      0|	}
  908|       |      /* append the 128 bit count */
  909|    127|      buf_put_be64(hd->bctx.buf + 112, msb);
  910|    127|      buf_put_be64(hd->bctx.buf + 120, lsb);
  911|    127|      burn = (*hd->bctx.bwrite) (hd, hd->bctx.buf, 1);
  912|    127|    }
  913|       |
  914|    127|  p = hd->bctx.buf;
  915|    127|#define X(a) do { buf_put_be64(p, hd->state.h[a]); p += 8; } while (0)
  916|    127|  X (0);
  ------------------
  |  |  915|    127|#define X(a) do { buf_put_be64(p, hd->state.h[a]); p += 8; } while (0)
  |  |  ------------------
  |  |  |  Branch (915:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
  917|    127|  X (1);
  ------------------
  |  |  915|    127|#define X(a) do { buf_put_be64(p, hd->state.h[a]); p += 8; } while (0)
  |  |  ------------------
  |  |  |  Branch (915:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
  918|    127|  X (2);
  ------------------
  |  |  915|    127|#define X(a) do { buf_put_be64(p, hd->state.h[a]); p += 8; } while (0)
  |  |  ------------------
  |  |  |  Branch (915:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
  919|    127|  X (3);
  ------------------
  |  |  915|    127|#define X(a) do { buf_put_be64(p, hd->state.h[a]); p += 8; } while (0)
  |  |  ------------------
  |  |  |  Branch (915:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
  920|    127|  X (4);
  ------------------
  |  |  915|    127|#define X(a) do { buf_put_be64(p, hd->state.h[a]); p += 8; } while (0)
  |  |  ------------------
  |  |  |  Branch (915:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
  921|    127|  X (5);
  ------------------
  |  |  915|    127|#define X(a) do { buf_put_be64(p, hd->state.h[a]); p += 8; } while (0)
  |  |  ------------------
  |  |  |  Branch (915:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
  922|       |  /* Note that these last two chunks are included even for SHA384.
  923|       |     We just ignore them. */
  924|    127|  X (6);
  ------------------
  |  |  915|    127|#define X(a) do { buf_put_be64(p, hd->state.h[a]); p += 8; } while (0)
  |  |  ------------------
  |  |  |  Branch (915:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
  925|    127|  X (7);
  ------------------
  |  |  915|    127|#define X(a) do { buf_put_be64(p, hd->state.h[a]); p += 8; } while (0)
  |  |  ------------------
  |  |  |  Branch (915:69): [Folded - Ignored]
  |  |  ------------------
  ------------------
  926|    127|#undef X
  927|       |
  928|    127|  hd->bctx.count = 0;
  929|       |
  930|    127|  _gcry_burn_stack (burn);
  ------------------
  |  |  371|    127|	do { __gcry_burn_stack (bytes); \
  |  |  372|    127|	     __gcry_burn_stack_dummy (); } while(0)
  |  |  ------------------
  |  |  |  |  364|    127|#define  __gcry_burn_stack_dummy() asm volatile ("":::"memory")
  |  |  ------------------
  |  |  |  Branch (372:43): [Folded - Ignored]
  |  |  ------------------
  ------------------
  931|    127|}

mpicoder.c:buf_put_be64:
  171|  4.89k|{
  172|  4.89k|  bufhelp_u64_t *out = _buf;
  173|  4.89k|  out->a = be_bswap64(val);
  ------------------
  |  |   75|  4.89k|# define be_bswap64(x) _gcry_bswap64(x)
  |  |  ------------------
  |  |  |  |   56|  4.89k|# define _gcry_bswap64 __builtin_bswap64
  |  |  ------------------
  ------------------
  174|  4.89k|}
mpicoder.c:buf_get_be64:
  161|  5.15k|{
  162|  5.15k|  return be_bswap64(((const bufhelp_u64_t *)_buf)->a);
  ------------------
  |  |   75|  5.15k|# define be_bswap64(x) _gcry_bswap64(x)
  |  |  ------------------
  |  |  |  |   56|  5.15k|# define _gcry_bswap64 __builtin_bswap64
  |  |  ------------------
  ------------------
  163|  5.15k|}
mpicoder.c:buf_get_le32:
  136|  2.38k|{
  137|  2.38k|  return le_bswap32(((const bufhelp_u32_t *)_buf)->a);
  ------------------
  |  |   72|  2.38k|# define le_bswap32(x) ((u32)(x))
  ------------------
  138|  2.38k|}
ec-nist.c:buf_get_le64:
  166|   783k|{
  167|   783k|  return le_bswap64(((const bufhelp_u64_t *)_buf)->a);
  ------------------
  |  |   74|   783k|# define le_bswap64(x) ((u64)(x))
  ------------------
  168|   783k|}

ec-nist.c:mpi_nbits_more_than:
 1040|   156k|{
 1041|   156k|  unsigned int nbits_nlimbs;
 1042|   156k|  mpi_limb_t wlimb;
 1043|   156k|  unsigned int n;
 1044|       |
 1045|   156k|  nbits_nlimbs = (nbits + BITS_PER_MPI_LIMB - 1) / BITS_PER_MPI_LIMB;
  ------------------
  |  |   49|   156k|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|   156k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|   156k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                nbits_nlimbs = (nbits + BITS_PER_MPI_LIMB - 1) / BITS_PER_MPI_LIMB;
  ------------------
  |  |   49|   156k|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|   156k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|   156k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1046|       |
 1047|       |  /* Note: Assumes that 'w' is normalized. */
 1048|       |
 1049|   156k|  if (w->nlimbs > nbits_nlimbs)
  ------------------
  |  Branch (1049:7): [True: 0, False: 156k]
  ------------------
 1050|      0|    return 1;
 1051|   156k|  if (w->nlimbs < nbits_nlimbs)
  ------------------
  |  Branch (1051:7): [True: 63.0k, False: 93.5k]
  ------------------
 1052|  63.0k|    return 0;
 1053|  93.5k|  if ((nbits % BITS_PER_MPI_LIMB) == 0)
  ------------------
  |  |   49|  93.5k|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|  93.5k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|  93.5k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1053:7): [True: 93.5k, False: 0]
  ------------------
 1054|  93.5k|    return 0;
 1055|       |
 1056|      0|  wlimb = w->d[nbits_nlimbs - 1];
 1057|      0|  if (wlimb == 0)
  ------------------
  |  Branch (1057:7): [True: 0, False: 0]
  ------------------
 1058|      0|    log_bug ("mpi_nbits_more_than: input mpi not normalized\n");
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
 1059|       |
 1060|      0|  count_leading_zeros (n, wlimb);
  ------------------
  |  |  617|      0|  do {                                                                  \
  |  |  618|      0|    UDItype __cbtmp;                                                    \
  |  |  619|      0|    __asm__ ("bsrq %1,%0"                                               \
  |  |  620|      0|             : "=r" (__cbtmp) : "rm" ((UDItype)(x))                     \
  |  |  621|      0|             __CLOBBER_CC);                                             \
  |  |  622|      0|    (count) = __cbtmp ^ 63;                                             \
  |  |  623|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (623:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1061|       |
 1062|      0|  return (BITS_PER_MPI_LIMB - n) > (nbits % BITS_PER_MPI_LIMB);
  ------------------
  |  |   49|      0|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                return (BITS_PER_MPI_LIMB - n) > (nbits % BITS_PER_MPI_LIMB);
  ------------------
  |  |   49|      0|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1063|      0|}
ec-nist.c:LIMB64_HILO:
   59|  2.03M|{
   60|  2.03M|  mpi_limb64_t v = hi;
   61|  2.03M|  return (v << 32) | lo;
   62|  2.03M|}
ec-nist.c:LOAD32:
   52|  2.81M|{
   53|  2.81M|  unsigned int shr = (pos % 2) * 32;
   54|  2.81M|  return (x[pos / 2] >> shr);
   55|  2.81M|}

_gcry_mpi_ec_nist256_mod:
  287|   156k|{
  288|   156k|  static const mpi_limb64_t p_mult[12][5] =
  289|   156k|  {
  290|   156k|    { /* P * -3 */
  291|   156k|      LIMB64_C(0x00000000U, 0x00000003U), LIMB64_C(0xfffffffdU, 0x00000000U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0x00000000U, 0x00000003U), LIMB64_C(0xfffffffdU, 0x00000000U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  292|   156k|      LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000002U, 0xfffffffcU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000002U, 0xfffffffcU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  293|   156k|      LIMB64_C(0xffffffffU, 0xfffffffdU)
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  294|   156k|    },
  295|   156k|    { /* P * -2 */
  296|   156k|      LIMB64_C(0x00000000U, 0x00000002U), LIMB64_C(0xfffffffeU, 0x00000000U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0x00000000U, 0x00000002U), LIMB64_C(0xfffffffeU, 0x00000000U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  297|   156k|      LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000001U, 0xfffffffdU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000001U, 0xfffffffdU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  298|   156k|      LIMB64_C(0xffffffffU, 0xfffffffeU)
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  299|   156k|    },
  300|   156k|    { /* P * -1 */
  301|   156k|      LIMB64_C(0x00000000U, 0x00000001U), LIMB64_C(0xffffffffU, 0x00000000U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0x00000000U, 0x00000001U), LIMB64_C(0xffffffffU, 0x00000000U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  302|   156k|      LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000000U, 0xfffffffeU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000000U, 0xfffffffeU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  303|   156k|      LIMB64_C(0xffffffffU, 0xffffffffU)
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  304|   156k|    },
  305|   156k|    { /* P * 0 */
  306|   156k|      LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0x00000000U, 0x00000000U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0x00000000U, 0x00000000U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  307|   156k|      LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0x00000000U, 0x00000000U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0x00000000U, 0x00000000U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  308|   156k|      LIMB64_C(0x00000000U, 0x00000000U)
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  309|   156k|    },
  310|   156k|    { /* P * 1 */
  311|   156k|      LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000000U, 0xffffffffU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0xffffffffU, 0xffffffffU), LIMB64_C(0x00000000U, 0xffffffffU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  312|   156k|      LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xffffffffU, 0x00000001U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xffffffffU, 0x00000001U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  313|   156k|      LIMB64_C(0x00000000U, 0x00000000U)
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  314|   156k|    },
  315|   156k|    { /* P * 2 */
  316|   156k|      LIMB64_C(0xffffffffU, 0xfffffffeU), LIMB64_C(0x00000001U, 0xffffffffU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0xffffffffU, 0xfffffffeU), LIMB64_C(0x00000001U, 0xffffffffU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  317|   156k|      LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xfffffffeU, 0x00000002U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xfffffffeU, 0x00000002U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  318|   156k|      LIMB64_C(0x00000000U, 0x00000001U)
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  319|   156k|    },
  320|   156k|    { /* P * 3 */
  321|   156k|      LIMB64_C(0xffffffffU, 0xfffffffdU), LIMB64_C(0x00000002U, 0xffffffffU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0xffffffffU, 0xfffffffdU), LIMB64_C(0x00000002U, 0xffffffffU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  322|   156k|      LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xfffffffdU, 0x00000003U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xfffffffdU, 0x00000003U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  323|   156k|      LIMB64_C(0x00000000U, 0x00000002U)
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  324|   156k|    },
  325|   156k|    { /* P * 4 */
  326|   156k|      LIMB64_C(0xffffffffU, 0xfffffffcU), LIMB64_C(0x00000003U, 0xffffffffU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0xffffffffU, 0xfffffffcU), LIMB64_C(0x00000003U, 0xffffffffU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  327|   156k|      LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xfffffffcU, 0x00000004U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xfffffffcU, 0x00000004U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  328|   156k|      LIMB64_C(0x00000000U, 0x00000003U)
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  329|   156k|    },
  330|   156k|    { /* P * 5 */
  331|   156k|      LIMB64_C(0xffffffffU, 0xfffffffbU), LIMB64_C(0x00000004U, 0xffffffffU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0xffffffffU, 0xfffffffbU), LIMB64_C(0x00000004U, 0xffffffffU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  332|   156k|      LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xfffffffbU, 0x00000005U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xfffffffbU, 0x00000005U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  333|   156k|      LIMB64_C(0x00000000U, 0x00000004U)
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  334|   156k|    },
  335|   156k|    { /* P * 6 */
  336|   156k|      LIMB64_C(0xffffffffU, 0xfffffffaU), LIMB64_C(0x00000005U, 0xffffffffU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0xffffffffU, 0xfffffffaU), LIMB64_C(0x00000005U, 0xffffffffU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  337|   156k|      LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xfffffffaU, 0x00000006U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xfffffffaU, 0x00000006U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  338|   156k|      LIMB64_C(0x00000000U, 0x00000005U)
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  339|   156k|    },
  340|   156k|    { /* P * 7 */
  341|   156k|      LIMB64_C(0xffffffffU, 0xfffffff9U), LIMB64_C(0x00000006U, 0xffffffffU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0xffffffffU, 0xfffffff9U), LIMB64_C(0x00000006U, 0xffffffffU),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  342|   156k|      LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xfffffff9U, 0x00000007U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
                    LIMB64_C(0x00000000U, 0x00000000U), LIMB64_C(0xfffffff9U, 0x00000007U),
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  343|   156k|      LIMB64_C(0x00000000U, 0x00000006U)
  ------------------
  |  |   42|   156k|#define LIMB64_C(hi, lo) (((mpi_limb_t)(u32)(hi) << 32) | (u32)(lo))
  ------------------
  344|   156k|    }
  345|   156k|  };
  346|   156k|  const mpi_limb64_t zero = LIMB_TO64(0);
  ------------------
  |  |   37|   156k|#define LIMB_TO64(v) ((mpi_limb_t)(v))
  ------------------
  347|   156k|  mpi_ptr_t wp;
  348|   156k|  mpi_limb64_t s[(256 + BITS_PER_MPI_LIMB64 - 1) / BITS_PER_MPI_LIMB64 + 1];
  349|   156k|  mpi_limb64_t t[DIM(s)];
  350|   156k|  mpi_limb64_t d[DIM(s)];
  351|   156k|  mpi_limb64_t e[DIM(s)];
  352|   156k|  const mpi_size_t wsize = DIM(s) - 1;
  ------------------
  |  |  104|   156k|#define DIM(v) (sizeof(v)/sizeof((v)[0]))
  ------------------
  353|   156k|  mpi_size_t psize = ctx->p->nlimbs;
  354|   156k|  mpi_limb_t mask1;
  355|   156k|  mpi_limb_t mask2;
  356|   156k|  mpi_limb_t mask3;
  357|   156k|  mpi_limb_t s_is_negative;
  358|   156k|  mpi_limb_t d_is_negative;
  359|   156k|  int carry;
  360|       |
  361|   156k|  MPN_NORMALIZE (w->d, w->nlimbs);
  ------------------
  |  |  119|   156k|    do {		       \
  |  |  120|   156k|	while( (n) > 0 ) {     \
  |  |  ------------------
  |  |  |  Branch (120:9): [True: 156k, False: 0]
  |  |  ------------------
  |  |  121|   156k|	    if( (d)[(n)-1] ) \
  |  |  ------------------
  |  |  |  Branch (121:10): [True: 156k, False: 0]
  |  |  ------------------
  |  |  122|   156k|		break;	       \
  |  |  123|   156k|	    (n)--;	       \
  |  |  124|      0|	}		       \
  |  |  125|   156k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (125:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  362|   156k|  if (mpi_nbits_more_than (w, 2 * 256))
  ------------------
  |  Branch (362:7): [True: 0, False: 156k]
  ------------------
  363|      0|    log_bug ("W must be less than m^2\n");
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
  364|       |
  365|   156k|  RESIZE_AND_CLEAR_IF_NEEDED (w, wsize * 2 * LIMBS_PER_LIMB64);
  ------------------
  |  |   83|   156k|    do {			   \
  |  |   84|   156k|	if( (a)->nlimbs < (b) )   \
  |  |  ------------------
  |  |  |  Branch (84:6): [True: 63.0k, False: 93.5k]
  |  |  ------------------
  |  |   85|   156k|	    mpi_resize((a), (b));  \
  |  |  ------------------
  |  |  |  |  100|  63.0k|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  |  |  ------------------
  |  |   86|   156k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (86:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  366|   156k|  RESIZE_AND_CLEAR_IF_NEEDED (ctx->p, wsize * LIMBS_PER_LIMB64);
  ------------------
  |  |   83|   156k|    do {			   \
  |  |   84|   156k|	if( (a)->nlimbs < (b) )   \
  |  |  ------------------
  |  |  |  Branch (84:6): [True: 0, False: 156k]
  |  |  ------------------
  |  |   85|   156k|	    mpi_resize((a), (b));  \
  |  |  ------------------
  |  |  |  |  100|      0|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  |  |  ------------------
  |  |   86|   156k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (86:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  367|   156k|  ctx->p->nlimbs = psize;
  368|       |
  369|   156k|  wp = w->d;
  370|       |
  371|   156k|  prefetch (p_mult, sizeof(p_mult));
  372|       |
  373|       |  /* See "FIPS 186-4, D.2.3 Curve P-256". */
  374|       |
  375|       |  /* "S1 + S2" with 64-bit limbs:
  376|       |   *     [A15:A14]:[A13:A12]:[A11:0]:[0:0]
  377|       |   *  +    [0:A15]:[A14:A13]:[A12:0]:[0:0]
  378|       |   *  => s[4]:s[3]:s[2]:s[1]:s[0]
  379|       |   */
  380|   156k|  s[0] = zero;
  381|   156k|  ADD4_LIMB64 (s[4], s[3], s[2], s[1],
  ------------------
  |  |   99|   156k|  __asm__ ("addq %11, %3\n" \
  |  |  100|   156k|	   "adcq %10, %2\n" \
  |  |  101|   156k|	   "adcq %9, %1\n" \
  |  |  102|   156k|	   "adcq %8, %0\n" \
  |  |  103|   156k|	   : "=r" (A3), \
  |  |  104|   156k|	     "=&r" (A2), \
  |  |  105|   156k|	     "=&r" (A1), \
  |  |  106|   156k|	     "=&r" (A0) \
  |  |  107|   156k|	   : "0" ((mpi_limb_t)(B3)), \
  |  |  108|   156k|	     "1" ((mpi_limb_t)(B2)), \
  |  |  109|   156k|	     "2" ((mpi_limb_t)(B1)), \
  |  |  110|   156k|	     "3" ((mpi_limb_t)(B0)), \
  |  |  111|   156k|	     "rme" ((mpi_limb_t)(C3)), \
  |  |  112|   156k|	     "rme" ((mpi_limb_t)(C2)), \
  |  |  113|   156k|	     "rme" ((mpi_limb_t)(C1)), \
  |  |  114|   156k|	     "rme" ((mpi_limb_t)(C0)) \
  |  |  115|   156k|	   : "cc")
  ------------------
  382|   156k|	       zero,
  383|   156k|	       LOAD64(wp, 14 / 2),
  384|   156k|	       LOAD64(wp, 12 / 2),
  385|   156k|	       LIMB64_HILO(LOAD32(wp, 11), 0),
  386|   156k|	       zero,
  387|   156k|	       LIMB64_HILO(0, LOAD32(wp, 15)),
  388|   156k|	       LOAD64_UNALIGNED(wp, 13 / 2),
  389|   156k|	       LIMB64_HILO(LOAD32(wp, 12), 0));
  390|       |
  391|       |  /* "S3 + S4" with 64-bit limbs:
  392|       |   *     [A15:A14]:[  0:  0]:[  0:A10]:[ A9:A8]
  393|       |   *  +   [A8:A13]:[A15:A14]:[A13:A11]:[A10:A9]
  394|       |   *  => t[4]:t[3]:t[2]:t[1]:t[0]
  395|       |   */
  396|   156k|  ADD5_LIMB64 (t[4], t[3], t[2], t[1], t[0],
  ------------------
  |  |  138|   156k|  __asm__ ("addq %14, %4\n" \
  |  |  139|   156k|	   "adcq %13, %3\n" \
  |  |  140|   156k|	   "adcq %12, %2\n" \
  |  |  141|   156k|	   "adcq %11, %1\n" \
  |  |  142|   156k|	   "adcq %10, %0\n" \
  |  |  143|   156k|	   : "=r" (A4), \
  |  |  144|   156k|	     "=&r" (A3), \
  |  |  145|   156k|	     "=&r" (A2), \
  |  |  146|   156k|	     "=&r" (A1), \
  |  |  147|   156k|	     "=&r" (A0) \
  |  |  148|   156k|	   : "0" ((mpi_limb_t)(B4)), \
  |  |  149|   156k|	     "1" ((mpi_limb_t)(B3)), \
  |  |  150|   156k|	     "2" ((mpi_limb_t)(B2)), \
  |  |  151|   156k|	     "3" ((mpi_limb_t)(B1)), \
  |  |  152|   156k|	     "4" ((mpi_limb_t)(B0)), \
  |  |  153|   156k|	     "rme" ((mpi_limb_t)(C4)), \
  |  |  154|   156k|	     "rme" ((mpi_limb_t)(C3)), \
  |  |  155|   156k|	     "rme" ((mpi_limb_t)(C2)), \
  |  |  156|   156k|	     "rme" ((mpi_limb_t)(C1)), \
  |  |  157|   156k|	     "rme" ((mpi_limb_t)(C0)) \
  |  |  158|   156k|	   : "cc")
  ------------------
  397|   156k|	       zero,
  398|   156k|	       LOAD64(wp, 14 / 2),
  399|   156k|	       zero,
  400|   156k|	       LIMB64_HILO(0, LOAD32(wp, 10)),
  401|   156k|	       LOAD64(wp, 8 / 2),
  402|   156k|	       zero,
  403|   156k|	       LIMB64_HILO(LOAD32(wp, 8), LOAD32(wp, 13)),
  404|   156k|	       LOAD64(wp, 14 / 2),
  405|   156k|	       LIMB64_HILO(LOAD32(wp, 13), LOAD32(wp, 11)),
  406|   156k|	       LOAD64_UNALIGNED(wp, 9 / 2));
  407|       |
  408|       |  /* "2*S1 + 2*S2" */
  409|   156k|  ADD5_LIMB64 (s[4], s[3], s[2], s[1], s[0],
  ------------------
  |  |  138|   156k|  __asm__ ("addq %14, %4\n" \
  |  |  139|   156k|	   "adcq %13, %3\n" \
  |  |  140|   156k|	   "adcq %12, %2\n" \
  |  |  141|   156k|	   "adcq %11, %1\n" \
  |  |  142|   156k|	   "adcq %10, %0\n" \
  |  |  143|   156k|	   : "=r" (A4), \
  |  |  144|   156k|	     "=&r" (A3), \
  |  |  145|   156k|	     "=&r" (A2), \
  |  |  146|   156k|	     "=&r" (A1), \
  |  |  147|   156k|	     "=&r" (A0) \
  |  |  148|   156k|	   : "0" ((mpi_limb_t)(B4)), \
  |  |  149|   156k|	     "1" ((mpi_limb_t)(B3)), \
  |  |  150|   156k|	     "2" ((mpi_limb_t)(B2)), \
  |  |  151|   156k|	     "3" ((mpi_limb_t)(B1)), \
  |  |  152|   156k|	     "4" ((mpi_limb_t)(B0)), \
  |  |  153|   156k|	     "rme" ((mpi_limb_t)(C4)), \
  |  |  154|   156k|	     "rme" ((mpi_limb_t)(C3)), \
  |  |  155|   156k|	     "rme" ((mpi_limb_t)(C2)), \
  |  |  156|   156k|	     "rme" ((mpi_limb_t)(C1)), \
  |  |  157|   156k|	     "rme" ((mpi_limb_t)(C0)) \
  |  |  158|   156k|	   : "cc")
  ------------------
  410|   156k|               s[4], s[3], s[2], s[1], s[0],
  411|   156k|               s[4], s[3], s[2], s[1], s[0]);
  412|       |
  413|       |  /* "T + S3 + S4" */
  414|   156k|  ADD5_LIMB64 (t[4], t[3], t[2], t[1], t[0],
  ------------------
  |  |  138|   156k|  __asm__ ("addq %14, %4\n" \
  |  |  139|   156k|	   "adcq %13, %3\n" \
  |  |  140|   156k|	   "adcq %12, %2\n" \
  |  |  141|   156k|	   "adcq %11, %1\n" \
  |  |  142|   156k|	   "adcq %10, %0\n" \
  |  |  143|   156k|	   : "=r" (A4), \
  |  |  144|   156k|	     "=&r" (A3), \
  |  |  145|   156k|	     "=&r" (A2), \
  |  |  146|   156k|	     "=&r" (A1), \
  |  |  147|   156k|	     "=&r" (A0) \
  |  |  148|   156k|	   : "0" ((mpi_limb_t)(B4)), \
  |  |  149|   156k|	     "1" ((mpi_limb_t)(B3)), \
  |  |  150|   156k|	     "2" ((mpi_limb_t)(B2)), \
  |  |  151|   156k|	     "3" ((mpi_limb_t)(B1)), \
  |  |  152|   156k|	     "4" ((mpi_limb_t)(B0)), \
  |  |  153|   156k|	     "rme" ((mpi_limb_t)(C4)), \
  |  |  154|   156k|	     "rme" ((mpi_limb_t)(C3)), \
  |  |  155|   156k|	     "rme" ((mpi_limb_t)(C2)), \
  |  |  156|   156k|	     "rme" ((mpi_limb_t)(C1)), \
  |  |  157|   156k|	     "rme" ((mpi_limb_t)(C0)) \
  |  |  158|   156k|	   : "cc")
  ------------------
  415|   156k|	       t[4], t[3], t[2], t[1], t[0],
  416|   156k|	       zero,
  417|   156k|	       LOAD64(wp, 6 / 2),
  418|   156k|	       LOAD64(wp, 4 / 2),
  419|   156k|	       LOAD64(wp, 2 / 2),
  420|   156k|	       LOAD64(wp, 0 / 2));
  421|       |
  422|       |  /* "2*S1 + 2*S2 - D3" with 64-bit limbs:
  423|       |   *    s[4]:    s[3]:    s[2]:    s[1]:     s[0]
  424|       |   *  -       [A12:0]:[A10:A9]:[A8:A15]:[A14:A13]
  425|       |   *  => s[4]:s[3]:s[2]:s[1]:s[0]
  426|       |   */
  427|   156k|  SUB5_LIMB64 (s[4], s[3], s[2], s[1], s[0],
  ------------------
  |  |  162|   156k|  __asm__ ("subq %14, %4\n" \
  |  |  163|   156k|	   "sbbq %13, %3\n" \
  |  |  164|   156k|	   "sbbq %12, %2\n" \
  |  |  165|   156k|	   "sbbq %11, %1\n" \
  |  |  166|   156k|	   "sbbq %10, %0\n" \
  |  |  167|   156k|	   : "=r" (A4), \
  |  |  168|   156k|	     "=&r" (A3), \
  |  |  169|   156k|	     "=&r" (A2), \
  |  |  170|   156k|	     "=&r" (A1), \
  |  |  171|   156k|	     "=&r" (A0) \
  |  |  172|   156k|	   : "0" ((mpi_limb_t)(B4)), \
  |  |  173|   156k|	     "1" ((mpi_limb_t)(B3)), \
  |  |  174|   156k|	     "2" ((mpi_limb_t)(B2)), \
  |  |  175|   156k|	     "3" ((mpi_limb_t)(B1)), \
  |  |  176|   156k|	     "4" ((mpi_limb_t)(B0)), \
  |  |  177|   156k|	     "rme" ((mpi_limb_t)(C4)), \
  |  |  178|   156k|	     "rme" ((mpi_limb_t)(C3)), \
  |  |  179|   156k|	     "rme" ((mpi_limb_t)(C2)), \
  |  |  180|   156k|	     "rme" ((mpi_limb_t)(C1)), \
  |  |  181|   156k|	     "rme" ((mpi_limb_t)(C0)) \
  |  |  182|   156k|	   : "cc")
  ------------------
  428|   156k|               s[4], s[3], s[2], s[1], s[0],
  429|   156k|	       zero,
  430|   156k|	       LIMB64_HILO(LOAD32(wp, 12), 0),
  431|   156k|	       LOAD64_UNALIGNED(wp, 9 / 2),
  432|   156k|	       LIMB64_HILO(LOAD32(wp, 8), LOAD32(wp, 15)),
  433|   156k|	       LOAD64_UNALIGNED(wp, 13 / 2));
  434|       |
  435|       |  /* "T + 2*S1 + 2*S2 + S3 + S4 - D3" */
  436|   156k|  ADD5_LIMB64 (s[4], s[3], s[2], s[1], s[0],
  ------------------
  |  |  138|   156k|  __asm__ ("addq %14, %4\n" \
  |  |  139|   156k|	   "adcq %13, %3\n" \
  |  |  140|   156k|	   "adcq %12, %2\n" \
  |  |  141|   156k|	   "adcq %11, %1\n" \
  |  |  142|   156k|	   "adcq %10, %0\n" \
  |  |  143|   156k|	   : "=r" (A4), \
  |  |  144|   156k|	     "=&r" (A3), \
  |  |  145|   156k|	     "=&r" (A2), \
  |  |  146|   156k|	     "=&r" (A1), \
  |  |  147|   156k|	     "=&r" (A0) \
  |  |  148|   156k|	   : "0" ((mpi_limb_t)(B4)), \
  |  |  149|   156k|	     "1" ((mpi_limb_t)(B3)), \
  |  |  150|   156k|	     "2" ((mpi_limb_t)(B2)), \
  |  |  151|   156k|	     "3" ((mpi_limb_t)(B1)), \
  |  |  152|   156k|	     "4" ((mpi_limb_t)(B0)), \
  |  |  153|   156k|	     "rme" ((mpi_limb_t)(C4)), \
  |  |  154|   156k|	     "rme" ((mpi_limb_t)(C3)), \
  |  |  155|   156k|	     "rme" ((mpi_limb_t)(C2)), \
  |  |  156|   156k|	     "rme" ((mpi_limb_t)(C1)), \
  |  |  157|   156k|	     "rme" ((mpi_limb_t)(C0)) \
  |  |  158|   156k|	   : "cc")
  ------------------
  437|   156k|               s[4], s[3], s[2], s[1], s[0],
  438|   156k|               t[4], t[3], t[2], t[1], t[0]);
  439|       |
  440|       |  /* "D1 + D2" with 64-bit limbs:
  441|       |   *     [0:A13]:[A12:A11] + [A15:A14]:[A13:A12] => d[2]:d[1]:d[0]
  442|       |   *     [A10:A8] + [A11:A9] => d[4]:d[3]
  443|       |   */
  444|   156k|  ADD3_LIMB64 (d[2], d[1], d[0],
  ------------------
  |  |   69|   156k|  __asm__ ("addq %8, %2\n" \
  |  |   70|   156k|	   "adcq %7, %1\n" \
  |  |   71|   156k|	   "adcq %6, %0\n" \
  |  |   72|   156k|	   : "=r" (A2), \
  |  |   73|   156k|	     "=&r" (A1), \
  |  |   74|   156k|	     "=&r" (A0) \
  |  |   75|   156k|	   : "0" ((mpi_limb_t)(B2)), \
  |  |   76|   156k|	     "1" ((mpi_limb_t)(B1)), \
  |  |   77|   156k|	     "2" ((mpi_limb_t)(B0)), \
  |  |   78|   156k|	     "rme" ((mpi_limb_t)(C2)), \
  |  |   79|   156k|	     "rme" ((mpi_limb_t)(C1)), \
  |  |   80|   156k|	     "rme" ((mpi_limb_t)(C0)) \
  |  |   81|   156k|	   : "cc")
  ------------------
  445|   156k|	       zero,
  446|   156k|	       LIMB64_HILO(0, LOAD32(wp, 13)),
  447|   156k|	       LOAD64_UNALIGNED(wp, 11 / 2),
  448|   156k|	       zero,
  449|   156k|	       LOAD64(wp, 14 / 2),
  450|   156k|	       LOAD64(wp, 12 / 2));
  451|   156k|  ADD2_LIMB64 (d[4], d[3],
  ------------------
  |  |  556|   156k|  add_ssaaaa(A1, A0, B1, B0, C1, C0)
  |  |  ------------------
  |  |  |  |  582|   156k|  __asm__ ("addq %5,%1\n"                                               \
  |  |  |  |  583|   156k|	   "adcq %3,%0"                                                 \
  |  |  |  |  584|   156k|	   : "=r" ((sh)),                                               \
  |  |  |  |  585|   156k|	     "=&r" ((sl))                                               \
  |  |  |  |  586|   156k|	   : "0" ((UDItype)(ah)),                                       \
  |  |  |  |  587|   156k|	     "g"  ((UDItype)(bh)),                                      \
  |  |  |  |  588|   156k|	     "1" ((UDItype)(al)),                                       \
  |  |  |  |  589|   156k|	     "g"  ((UDItype)(bl))                                       \
  |  |  |  |  590|   156k|	   __CLOBBER_CC)
  |  |  ------------------
  ------------------
  452|   156k|	       zero, LIMB64_HILO(LOAD32(wp, 10), LOAD32(wp, 8)),
  453|   156k|	       zero, LIMB64_HILO(LOAD32(wp, 11), LOAD32(wp, 9)));
  454|       |
  455|       |  /* "D1 + D2 + D4" with 64-bit limbs:
  456|       |   *    d[4]:    d[3]:     d[2]:  d[1]:     d[0]
  457|       |   *  -       [A13:0]:[A11:A10]:[A9:0]:[A15:A14]
  458|       |   *  => d[4]:d[3]:d[2]:d[1]:d[0]
  459|       |   */
  460|   156k|  ADD5_LIMB64 (d[4], d[3], d[2], d[1], d[0],
  ------------------
  |  |  138|   156k|  __asm__ ("addq %14, %4\n" \
  |  |  139|   156k|	   "adcq %13, %3\n" \
  |  |  140|   156k|	   "adcq %12, %2\n" \
  |  |  141|   156k|	   "adcq %11, %1\n" \
  |  |  142|   156k|	   "adcq %10, %0\n" \
  |  |  143|   156k|	   : "=r" (A4), \
  |  |  144|   156k|	     "=&r" (A3), \
  |  |  145|   156k|	     "=&r" (A2), \
  |  |  146|   156k|	     "=&r" (A1), \
  |  |  147|   156k|	     "=&r" (A0) \
  |  |  148|   156k|	   : "0" ((mpi_limb_t)(B4)), \
  |  |  149|   156k|	     "1" ((mpi_limb_t)(B3)), \
  |  |  150|   156k|	     "2" ((mpi_limb_t)(B2)), \
  |  |  151|   156k|	     "3" ((mpi_limb_t)(B1)), \
  |  |  152|   156k|	     "4" ((mpi_limb_t)(B0)), \
  |  |  153|   156k|	     "rme" ((mpi_limb_t)(C4)), \
  |  |  154|   156k|	     "rme" ((mpi_limb_t)(C3)), \
  |  |  155|   156k|	     "rme" ((mpi_limb_t)(C2)), \
  |  |  156|   156k|	     "rme" ((mpi_limb_t)(C1)), \
  |  |  157|   156k|	     "rme" ((mpi_limb_t)(C0)) \
  |  |  158|   156k|	   : "cc")
  ------------------
  461|   156k|               d[4], d[3], d[2], d[1], d[0],
  462|   156k|	       zero,
  463|   156k|	       LIMB64_HILO(LOAD32(wp, 13), 0),
  464|   156k|	       LOAD64(wp, 10 / 2),
  465|   156k|	       LIMB64_HILO(LOAD32(wp, 9), 0),
  466|   156k|	       LOAD64(wp, 14 / 2));
  467|       |
  468|       |  /* "T + 2*S1 + 2*S2 + S3 + S4 - D1 - D2 - D3 - D4" */
  469|   156k|  SUB5_LIMB64 (s[4], s[3], s[2], s[1], s[0],
  ------------------
  |  |  162|   156k|  __asm__ ("subq %14, %4\n" \
  |  |  163|   156k|	   "sbbq %13, %3\n" \
  |  |  164|   156k|	   "sbbq %12, %2\n" \
  |  |  165|   156k|	   "sbbq %11, %1\n" \
  |  |  166|   156k|	   "sbbq %10, %0\n" \
  |  |  167|   156k|	   : "=r" (A4), \
  |  |  168|   156k|	     "=&r" (A3), \
  |  |  169|   156k|	     "=&r" (A2), \
  |  |  170|   156k|	     "=&r" (A1), \
  |  |  171|   156k|	     "=&r" (A0) \
  |  |  172|   156k|	   : "0" ((mpi_limb_t)(B4)), \
  |  |  173|   156k|	     "1" ((mpi_limb_t)(B3)), \
  |  |  174|   156k|	     "2" ((mpi_limb_t)(B2)), \
  |  |  175|   156k|	     "3" ((mpi_limb_t)(B1)), \
  |  |  176|   156k|	     "4" ((mpi_limb_t)(B0)), \
  |  |  177|   156k|	     "rme" ((mpi_limb_t)(C4)), \
  |  |  178|   156k|	     "rme" ((mpi_limb_t)(C3)), \
  |  |  179|   156k|	     "rme" ((mpi_limb_t)(C2)), \
  |  |  180|   156k|	     "rme" ((mpi_limb_t)(C1)), \
  |  |  181|   156k|	     "rme" ((mpi_limb_t)(C0)) \
  |  |  182|   156k|	   : "cc")
  ------------------
  470|   156k|               s[4], s[3], s[2], s[1], s[0],
  471|   156k|               d[4], d[3], d[2], d[1], d[0]);
  472|       |
  473|       |  /* mod p:
  474|       |   *  's[4]' holds carry value (-4..6). Subtract (carry + 1) * p. Result
  475|       |   *  will be with in range -2*p...p. Handle result being negative with
  476|       |   *  addition and conditional store. */
  477|       |
  478|   156k|  carry = LO32_LIMB64(s[4]);
  ------------------
  |  |   41|   156k|#define LO32_LIMB64(v) ((u32)(v))
  ------------------
  479|       |
  480|   156k|  SUB5_LIMB64 (s[4], s[3], s[2], s[1], s[0],
  ------------------
  |  |  162|   156k|  __asm__ ("subq %14, %4\n" \
  |  |  163|   156k|	   "sbbq %13, %3\n" \
  |  |  164|   156k|	   "sbbq %12, %2\n" \
  |  |  165|   156k|	   "sbbq %11, %1\n" \
  |  |  166|   156k|	   "sbbq %10, %0\n" \
  |  |  167|   156k|	   : "=r" (A4), \
  |  |  168|   156k|	     "=&r" (A3), \
  |  |  169|   156k|	     "=&r" (A2), \
  |  |  170|   156k|	     "=&r" (A1), \
  |  |  171|   156k|	     "=&r" (A0) \
  |  |  172|   156k|	   : "0" ((mpi_limb_t)(B4)), \
  |  |  173|   156k|	     "1" ((mpi_limb_t)(B3)), \
  |  |  174|   156k|	     "2" ((mpi_limb_t)(B2)), \
  |  |  175|   156k|	     "3" ((mpi_limb_t)(B1)), \
  |  |  176|   156k|	     "4" ((mpi_limb_t)(B0)), \
  |  |  177|   156k|	     "rme" ((mpi_limb_t)(C4)), \
  |  |  178|   156k|	     "rme" ((mpi_limb_t)(C3)), \
  |  |  179|   156k|	     "rme" ((mpi_limb_t)(C2)), \
  |  |  180|   156k|	     "rme" ((mpi_limb_t)(C1)), \
  |  |  181|   156k|	     "rme" ((mpi_limb_t)(C0)) \
  |  |  182|   156k|	   : "cc")
  ------------------
  481|   156k|	       s[4], s[3], s[2], s[1], s[0],
  482|   156k|	       p_mult[carry + 4][4], p_mult[carry + 4][3],
  483|   156k|	       p_mult[carry + 4][2], p_mult[carry + 4][1],
  484|   156k|	       p_mult[carry + 4][0]);
  485|       |
  486|       |  /* Add 1*P */
  487|   156k|  ADD5_LIMB64 (d[4], d[3], d[2], d[1], d[0],
  ------------------
  |  |  138|   156k|  __asm__ ("addq %14, %4\n" \
  |  |  139|   156k|	   "adcq %13, %3\n" \
  |  |  140|   156k|	   "adcq %12, %2\n" \
  |  |  141|   156k|	   "adcq %11, %1\n" \
  |  |  142|   156k|	   "adcq %10, %0\n" \
  |  |  143|   156k|	   : "=r" (A4), \
  |  |  144|   156k|	     "=&r" (A3), \
  |  |  145|   156k|	     "=&r" (A2), \
  |  |  146|   156k|	     "=&r" (A1), \
  |  |  147|   156k|	     "=&r" (A0) \
  |  |  148|   156k|	   : "0" ((mpi_limb_t)(B4)), \
  |  |  149|   156k|	     "1" ((mpi_limb_t)(B3)), \
  |  |  150|   156k|	     "2" ((mpi_limb_t)(B2)), \
  |  |  151|   156k|	     "3" ((mpi_limb_t)(B1)), \
  |  |  152|   156k|	     "4" ((mpi_limb_t)(B0)), \
  |  |  153|   156k|	     "rme" ((mpi_limb_t)(C4)), \
  |  |  154|   156k|	     "rme" ((mpi_limb_t)(C3)), \
  |  |  155|   156k|	     "rme" ((mpi_limb_t)(C2)), \
  |  |  156|   156k|	     "rme" ((mpi_limb_t)(C1)), \
  |  |  157|   156k|	     "rme" ((mpi_limb_t)(C0)) \
  |  |  158|   156k|	   : "cc")
  ------------------
  488|   156k|	       s[4], s[3], s[2], s[1], s[0],
  489|   156k|	       zero,
  490|   156k|	       p_mult[0 + 4][3], p_mult[0 + 4][2],
  491|   156k|	       p_mult[0 + 4][1], p_mult[0 + 4][0]);
  492|       |
  493|       |  /* Add 2*P */
  494|   156k|  ADD5_LIMB64 (e[4], e[3], e[2], e[1], e[0],
  ------------------
  |  |  138|   156k|  __asm__ ("addq %14, %4\n" \
  |  |  139|   156k|	   "adcq %13, %3\n" \
  |  |  140|   156k|	   "adcq %12, %2\n" \
  |  |  141|   156k|	   "adcq %11, %1\n" \
  |  |  142|   156k|	   "adcq %10, %0\n" \
  |  |  143|   156k|	   : "=r" (A4), \
  |  |  144|   156k|	     "=&r" (A3), \
  |  |  145|   156k|	     "=&r" (A2), \
  |  |  146|   156k|	     "=&r" (A1), \
  |  |  147|   156k|	     "=&r" (A0) \
  |  |  148|   156k|	   : "0" ((mpi_limb_t)(B4)), \
  |  |  149|   156k|	     "1" ((mpi_limb_t)(B3)), \
  |  |  150|   156k|	     "2" ((mpi_limb_t)(B2)), \
  |  |  151|   156k|	     "3" ((mpi_limb_t)(B1)), \
  |  |  152|   156k|	     "4" ((mpi_limb_t)(B0)), \
  |  |  153|   156k|	     "rme" ((mpi_limb_t)(C4)), \
  |  |  154|   156k|	     "rme" ((mpi_limb_t)(C3)), \
  |  |  155|   156k|	     "rme" ((mpi_limb_t)(C2)), \
  |  |  156|   156k|	     "rme" ((mpi_limb_t)(C1)), \
  |  |  157|   156k|	     "rme" ((mpi_limb_t)(C0)) \
  |  |  158|   156k|	   : "cc")
  ------------------
  495|   156k|	       s[4], s[3], s[2], s[1], s[0],
  496|   156k|	       zero,
  497|   156k|	       p_mult[1 + 4][3], p_mult[1 + 4][2],
  498|   156k|	       p_mult[1 + 4][1], p_mult[1 + 4][0]);
  499|       |
  500|   156k|  s_is_negative = LO32_LIMB64(s[4]) >> 31;
  ------------------
  |  |   41|   156k|#define LO32_LIMB64(v) ((u32)(v))
  ------------------
  501|   156k|  d_is_negative = LO32_LIMB64(d[4]) >> 31;
  ------------------
  |  |   41|   156k|#define LO32_LIMB64(v) ((u32)(v))
  ------------------
  502|   156k|  mask3 = vzero - d_is_negative;
  503|   156k|  mask2 = (vzero - s_is_negative) & ~mask3;
  504|   156k|  mask1 = (s_is_negative - vone) & ~mask3;
  505|       |
  506|   156k|  s[0] = LIMB_OR64(MASK_AND64(mask2, d[0]), MASK_AND64(mask1, s[0]));
  ------------------
  |  |   44|   156k|#define LIMB_OR64(val1, val2) ((val1) | (val2))
  ------------------
  507|   156k|  s[1] = LIMB_OR64(MASK_AND64(mask2, d[1]), MASK_AND64(mask1, s[1]));
  ------------------
  |  |   44|   156k|#define LIMB_OR64(val1, val2) ((val1) | (val2))
  ------------------
  508|   156k|  s[2] = LIMB_OR64(MASK_AND64(mask2, d[2]), MASK_AND64(mask1, s[2]));
  ------------------
  |  |   44|   156k|#define LIMB_OR64(val1, val2) ((val1) | (val2))
  ------------------
  509|   156k|  s[3] = LIMB_OR64(MASK_AND64(mask2, d[3]), MASK_AND64(mask1, s[3]));
  ------------------
  |  |   44|   156k|#define LIMB_OR64(val1, val2) ((val1) | (val2))
  ------------------
  510|   156k|  s[0] = LIMB_OR64(MASK_AND64(mask3, e[0]), s[0]);
  ------------------
  |  |   44|   156k|#define LIMB_OR64(val1, val2) ((val1) | (val2))
  ------------------
  511|   156k|  s[1] = LIMB_OR64(MASK_AND64(mask3, e[1]), s[1]);
  ------------------
  |  |   44|   156k|#define LIMB_OR64(val1, val2) ((val1) | (val2))
  ------------------
  512|   156k|  s[2] = LIMB_OR64(MASK_AND64(mask3, e[2]), s[2]);
  ------------------
  |  |   44|   156k|#define LIMB_OR64(val1, val2) ((val1) | (val2))
  ------------------
  513|   156k|  s[3] = LIMB_OR64(MASK_AND64(mask3, e[3]), s[3]);
  ------------------
  |  |   44|   156k|#define LIMB_OR64(val1, val2) ((val1) | (val2))
  ------------------
  514|       |
  515|   156k|  STORE64(wp, 0, s[0]);
  ------------------
  |  |   36|   156k|#define STORE64(x, pos, v) ((x)[pos] = (mpi_limb_t)(v))
  ------------------
  516|   156k|  STORE64(wp, 1, s[1]);
  ------------------
  |  |   36|   156k|#define STORE64(x, pos, v) ((x)[pos] = (mpi_limb_t)(v))
  ------------------
  517|   156k|  STORE64(wp, 2, s[2]);
  ------------------
  |  |   36|   156k|#define STORE64(x, pos, v) ((x)[pos] = (mpi_limb_t)(v))
  ------------------
  518|   156k|  STORE64(wp, 3, s[3]);
  ------------------
  |  |   36|   156k|#define STORE64(x, pos, v) ((x)[pos] = (mpi_limb_t)(v))
  ------------------
  519|       |
  520|   156k|  w->nlimbs = wsize * LIMBS_PER_LIMB64;
  ------------------
  |  |   34|   156k|#define LIMBS_PER_LIMB64 1
  ------------------
  521|   156k|  MPN_NORMALIZE (wp, w->nlimbs);
  ------------------
  |  |  119|   156k|    do {		       \
  |  |  120|   156k|	while( (n) > 0 ) {     \
  |  |  ------------------
  |  |  |  Branch (120:9): [True: 156k, False: 0]
  |  |  ------------------
  |  |  121|   156k|	    if( (d)[(n)-1] ) \
  |  |  ------------------
  |  |  |  Branch (121:10): [True: 156k, False: 96]
  |  |  ------------------
  |  |  122|   156k|		break;	       \
  |  |  123|   156k|	    (n)--;	       \
  |  |  124|     96|	}		       \
  |  |  125|   156k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (125:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  522|   156k|}
ec-nist.c:prefetch:
   46|   156k|{
   47|   156k|  const volatile byte *vtab = tab;
   48|       |
   49|   156k|  if (len > 0 * 64)
  ------------------
  |  Branch (49:7): [True: 156k, False: 0]
  ------------------
   50|   156k|    (void)vtab[0 * 64];
   51|   156k|  if (len > 1 * 64)
  ------------------
  |  Branch (51:7): [True: 156k, False: 0]
  ------------------
   52|   156k|    (void)vtab[1 * 64];
   53|   156k|  if (len > 2 * 64)
  ------------------
  |  Branch (53:7): [True: 156k, False: 0]
  ------------------
   54|   156k|    (void)vtab[2 * 64];
   55|   156k|  if (len > 3 * 64)
  ------------------
  |  Branch (55:7): [True: 156k, False: 0]
  ------------------
   56|   156k|    (void)vtab[3 * 64];
   57|   156k|  if (len > 4 * 64)
  ------------------
  |  Branch (57:7): [True: 156k, False: 0]
  ------------------
   58|   156k|    (void)vtab[4 * 64];
   59|   156k|  if (len > 5 * 64)
  ------------------
  |  Branch (59:7): [True: 156k, False: 0]
  ------------------
   60|   156k|    (void)vtab[5 * 64];
   61|   156k|  if (len > 6 * 64)
  ------------------
  |  Branch (61:7): [True: 156k, False: 0]
  ------------------
   62|   156k|    (void)vtab[6 * 64];
   63|   156k|  if (len > 7 * 64)
  ------------------
  |  Branch (63:7): [True: 156k, False: 0]
  ------------------
   64|   156k|    (void)vtab[7 * 64];
   65|   156k|  if (len > 8 * 64)
  ------------------
  |  Branch (65:7): [True: 0, False: 156k]
  ------------------
   66|      0|    (void)vtab[8 * 64];
   67|   156k|  if (len > 9 * 64)
  ------------------
  |  Branch (67:7): [True: 0, False: 156k]
  ------------------
   68|      0|    (void)vtab[9 * 64];
   69|   156k|  if (len > 10 * 64)
  ------------------
  |  Branch (69:7): [True: 0, False: 156k]
  ------------------
   70|      0|    (void)vtab[10 * 64];
   71|   156k|  (void)vtab[len - 1];
   72|   156k|}

_gcry_mpi_point_new:
   89|     32|{
   90|     32|  mpi_point_t p;
   91|       |
   92|     32|  (void)nbits;  /* Currently not used.  */
   93|       |
   94|     32|  p = xmalloc (sizeof *p);
  ------------------
  |  |  144|     32|#define xmalloc(a)       _gcry_xmalloc ((a))
  ------------------
   95|     32|  _gcry_mpi_point_init (p);
   96|     32|  return p;
   97|     32|}
_gcry_mpi_point_release:
  103|     32|{
  104|     32|  if (p)
  ------------------
  |  Branch (104:7): [True: 32, False: 0]
  ------------------
  105|     32|    {
  106|     32|      _gcry_mpi_point_free_parts (p);
  107|     32|      xfree (p);
  ------------------
  |  |  150|     32|#define xfree(a)         _gcry_free ((a))
  ------------------
  108|     32|    }
  109|     32|}
_gcry_mpi_point_init:
  116|    144|{
  117|    144|  p->x = mpi_new (0);
  ------------------
  |  |  491|    144|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
  118|    144|  p->y = mpi_new (0);
  ------------------
  |  |  491|    144|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
  119|    144|  p->z = mpi_new (0);
  ------------------
  |  |  491|    144|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
  120|    144|}
_gcry_mpi_point_free_parts:
  126|    192|{
  127|    192|  mpi_free (p->x); p->x = NULL;
  ------------------
  |  |   99|    192|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  128|    192|  mpi_free (p->y); p->y = NULL;
  ------------------
  |  |   99|    192|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  129|    192|  mpi_free (p->z); p->z = NULL;
  ------------------
  |  |   99|    192|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  130|    192|}
_gcry_mpi_point_snatch_set:
  251|     16|{
  252|     16|  if (!point)
  ------------------
  |  Branch (252:7): [True: 16, False: 0]
  ------------------
  253|     16|    point = mpi_point_new (0);
  ------------------
  |  |  532|     16|#define mpi_point_new(n)       _gcry_mpi_point_new((n))
  ------------------
  254|       |
  255|     16|  if (x)
  ------------------
  |  Branch (255:7): [True: 16, False: 0]
  ------------------
  256|     16|    mpi_snatch (point->x, x);
  ------------------
  |  |  503|     16|#define mpi_snatch( w, u)      _gcry_mpi_snatch( (w), (u) )
  ------------------
  257|      0|  else
  258|      0|    mpi_clear (point->x);
  ------------------
  |  |  116|      0|#define mpi_clear(a)          _gcry_mpi_clear ((a))
  ------------------
  259|     16|  if (y)
  ------------------
  |  Branch (259:7): [True: 16, False: 0]
  ------------------
  260|     16|    mpi_snatch (point->y, y);
  ------------------
  |  |  503|     16|#define mpi_snatch( w, u)      _gcry_mpi_snatch( (w), (u) )
  ------------------
  261|      0|  else
  262|      0|    mpi_clear (point->y);
  ------------------
  |  |  116|      0|#define mpi_clear(a)          _gcry_mpi_clear ((a))
  ------------------
  263|     16|  if (z)
  ------------------
  |  Branch (263:7): [True: 16, False: 0]
  ------------------
  264|     16|    mpi_snatch (point->z, z);
  ------------------
  |  |  503|     16|#define mpi_snatch( w, u)      _gcry_mpi_snatch( (w), (u) )
  ------------------
  265|      0|  else
  266|      0|    mpi_clear (point->z);
  ------------------
  |  |  116|      0|#define mpi_clear(a)          _gcry_mpi_clear ((a))
  ------------------
  267|       |
  268|     16|  return point;
  269|     16|}
_gcry_mpi_ec_get_reset:
  729|     16|{
  730|     16|  ec->t.valid.a_is_pminus3 = 0;
  731|     16|  ec->t.valid.two_inv_p = 0;
  732|     16|}
_gcry_mpi_ec_p_internal_new:
  996|     16|{
  997|     16|  mpi_ec_t ctx;
  998|       |
  999|     16|  ctx = xcalloc (1, sizeof *ctx);
  ------------------
  |  |  145|     16|#define xcalloc(a,b)     _gcry_xcalloc ((a),(b))
  ------------------
 1000|     16|  ec_p_init (ctx, model, dialect, flags, p, a, b);
 1001|       |
 1002|     16|  return ctx;
 1003|     16|}
_gcry_mpi_ec_free:
 1040|     16|{
 1041|     16|  if (ctx)
  ------------------
  |  Branch (1041:7): [True: 16, False: 0]
  ------------------
 1042|     16|    {
 1043|     16|      ec_deinit (ctx);
 1044|     16|      xfree (ctx);
  ------------------
  |  |  150|     16|#define xfree(a)         _gcry_free ((a))
  ------------------
 1045|     16|    }
 1046|     16|}
_gcry_mpi_ec_decode_point:
 1096|     16|{
 1097|     16|  gpg_err_code_t rc;
 1098|       |
 1099|     16|  if (ec
  ------------------
  |  Branch (1099:7): [True: 16, False: 0]
  ------------------
 1100|     16|      && (ec->dialect == ECC_DIALECT_ED25519
  ------------------
  |  Branch (1100:11): [True: 0, False: 16]
  ------------------
 1101|     16|          || (ec->model == MPI_EC_EDWARDS
  ------------------
  |  Branch (1101:15): [True: 0, False: 16]
  ------------------
 1102|     16|              && ec->dialect == ECC_DIALECT_SAFECURVE)))
  ------------------
  |  Branch (1102:18): [True: 0, False: 0]
  ------------------
 1103|      0|    rc = _gcry_ecc_eddsa_decodepoint (value, ec, result, NULL, NULL);
 1104|     16|  else if (ec && ec->model == MPI_EC_MONTGOMERY)
  ------------------
  |  Branch (1104:12): [True: 16, False: 0]
  |  Branch (1104:18): [True: 0, False: 16]
  ------------------
 1105|      0|    rc = _gcry_ecc_mont_decodepoint (value, ec, result);
 1106|     16|  else
 1107|     16|    rc = _gcry_ecc_sec_decodepoint (value, ec, result);
 1108|       |
 1109|     16|  return rc;
 1110|     16|}
_gcry_mpi_ec_get_affine:
 1120|     32|{
 1121|     32|  if (!mpi_cmp_ui (point->z, 0))
  ------------------
  |  |  512|     32|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
  |  Branch (1121:7): [True: 0, False: 32]
  ------------------
 1122|      0|    return -1;
 1123|       |
 1124|     32|  switch (ctx->model)
 1125|     32|    {
 1126|     32|    case MPI_EC_WEIERSTRASS: /* Using Jacobian coordinates.  */
  ------------------
  |  Branch (1126:5): [True: 32, False: 0]
  ------------------
 1127|     32|      {
 1128|     32|        gcry_mpi_t z1, z2, z3;
 1129|       |
 1130|     32|	if (!mpi_cmp_ui (point->z, 1))
  ------------------
  |  |  512|     32|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
  |  Branch (1130:6): [True: 16, False: 16]
  ------------------
 1131|     16|	  {
 1132|     16|	    if (x)
  ------------------
  |  Branch (1132:10): [True: 16, False: 0]
  ------------------
 1133|     16|	      mpi_set (x, point->x);
  ------------------
  |  |  504|     16|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
 1134|     16|	    if (y)
  ------------------
  |  Branch (1134:10): [True: 16, False: 0]
  ------------------
 1135|     16|	      mpi_set (y, point->y);
  ------------------
  |  |  504|     16|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
 1136|     16|	    return 0;
 1137|     16|	  }
 1138|       |
 1139|     16|        z1 = mpi_new (0);
  ------------------
  |  |  491|     16|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
 1140|     16|        z2 = mpi_new (0);
  ------------------
  |  |  491|     16|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
 1141|     16|        ec_invm (z1, point->z, ctx);  /* z1 = z^(-1) mod p  */
 1142|     16|        ec_mulm (z2, z1, z1, ctx);    /* z2 = z^(-2) mod p  */
 1143|       |
 1144|     16|        if (x)
  ------------------
  |  Branch (1144:13): [True: 16, False: 0]
  ------------------
 1145|     16|          ec_mulm (x, point->x, z2, ctx);
 1146|       |
 1147|     16|        if (y)
  ------------------
  |  Branch (1147:13): [True: 0, False: 16]
  ------------------
 1148|      0|          {
 1149|      0|            z3 = mpi_new (0);
  ------------------
  |  |  491|      0|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
 1150|      0|            ec_mulm (z3, z2, z1, ctx);      /* z3 = z^(-3) mod p  */
 1151|      0|            ec_mulm (y, point->y, z3, ctx);
 1152|      0|            mpi_free (z3);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1153|      0|          }
 1154|       |
 1155|     16|        mpi_free (z2);
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1156|     16|        mpi_free (z1);
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1157|     16|      }
 1158|      0|      return 0;
 1159|       |
 1160|      0|    case MPI_EC_MONTGOMERY:
  ------------------
  |  Branch (1160:5): [True: 0, False: 32]
  ------------------
 1161|      0|      {
 1162|      0|        if (x)
  ------------------
  |  Branch (1162:13): [True: 0, False: 0]
  ------------------
 1163|      0|          mpi_set (x, point->x);
  ------------------
  |  |  504|      0|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
 1164|       |
 1165|      0|        if (y)
  ------------------
  |  Branch (1165:13): [True: 0, False: 0]
  ------------------
 1166|      0|          {
 1167|      0|            log_fatal ("%s: Getting Y-coordinate on %s is not supported\n",
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
 1168|      0|                       "_gcry_mpi_ec_get_affine", "Montgomery");
 1169|      0|            return -1;
 1170|      0|          }
 1171|      0|      }
 1172|      0|      return 0;
 1173|       |
 1174|      0|    case MPI_EC_EDWARDS:
  ------------------
  |  Branch (1174:5): [True: 0, False: 32]
  ------------------
 1175|      0|      {
 1176|      0|        gcry_mpi_t z;
 1177|       |
 1178|      0|	if (!mpi_cmp_ui (point->z, 1))
  ------------------
  |  |  512|      0|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
  |  Branch (1178:6): [True: 0, False: 0]
  ------------------
 1179|      0|	  {
 1180|      0|	    if (x)
  ------------------
  |  Branch (1180:10): [True: 0, False: 0]
  ------------------
 1181|      0|	      mpi_set (x, point->x);
  ------------------
  |  |  504|      0|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
 1182|      0|	    if (y)
  ------------------
  |  Branch (1182:10): [True: 0, False: 0]
  ------------------
 1183|      0|	      mpi_set (y, point->y);
  ------------------
  |  |  504|      0|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
 1184|      0|	    return 0;
 1185|      0|	  }
 1186|       |
 1187|      0|        z = mpi_new (0);
  ------------------
  |  |  491|      0|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
 1188|      0|        ec_invm (z, point->z, ctx);
 1189|       |
 1190|      0|        mpi_resize (z, ctx->p->nlimbs);
  ------------------
  |  |  100|      0|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  ------------------
 1191|      0|        z->nlimbs = ctx->p->nlimbs;
 1192|       |
 1193|      0|        if (x)
  ------------------
  |  Branch (1193:13): [True: 0, False: 0]
  ------------------
 1194|      0|          {
 1195|      0|            mpi_resize (x, ctx->p->nlimbs);
  ------------------
  |  |  100|      0|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  ------------------
 1196|      0|            x->nlimbs = ctx->p->nlimbs;
 1197|      0|            ctx->mulm (x, point->x, z, ctx);
 1198|      0|          }
 1199|      0|        if (y)
  ------------------
  |  Branch (1199:13): [True: 0, False: 0]
  ------------------
 1200|      0|          {
 1201|      0|            mpi_resize (y, ctx->p->nlimbs);
  ------------------
  |  |  100|      0|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  ------------------
 1202|      0|            y->nlimbs = ctx->p->nlimbs;
 1203|      0|            ctx->mulm (y, point->y, z, ctx);
 1204|      0|          }
 1205|       |
 1206|      0|        _gcry_mpi_release (z);
 1207|      0|      }
 1208|      0|      return 0;
 1209|       |
 1210|      0|    default:
  ------------------
  |  Branch (1210:5): [True: 0, False: 32]
  ------------------
 1211|      0|      return -1;
 1212|     32|    }
 1213|     32|}
_gcry_mpi_ec_dup_point:
 1388|  8.12k|{
 1389|  8.12k|  switch (ctx->model)
  ------------------
  |  Branch (1389:11): [True: 0, False: 8.12k]
  ------------------
 1390|  8.12k|    {
 1391|  8.12k|    case MPI_EC_WEIERSTRASS:
  ------------------
  |  Branch (1391:5): [True: 8.12k, False: 0]
  ------------------
 1392|  8.12k|      dup_point_weierstrass (result, point, ctx);
 1393|  8.12k|      break;
 1394|      0|    case MPI_EC_MONTGOMERY:
  ------------------
  |  Branch (1394:5): [True: 0, False: 8.12k]
  ------------------
 1395|      0|      dup_point_montgomery (result, point, ctx);
 1396|      0|      break;
 1397|      0|    case MPI_EC_EDWARDS:
  ------------------
  |  Branch (1397:5): [True: 0, False: 8.12k]
  ------------------
 1398|      0|      dup_point_edwards (result, point, ctx);
 1399|      0|      break;
 1400|  8.12k|    }
 1401|  8.12k|}
_gcry_mpi_ec_add_points:
 1691|  2.84k|{
 1692|  2.84k|  switch (ctx->model)
  ------------------
  |  Branch (1692:11): [True: 0, False: 2.84k]
  ------------------
 1693|  2.84k|    {
 1694|  2.84k|    case MPI_EC_WEIERSTRASS:
  ------------------
  |  Branch (1694:5): [True: 2.84k, False: 0]
  ------------------
 1695|  2.84k|      add_points_weierstrass (result, p1, p2, ctx);
 1696|  2.84k|      break;
 1697|      0|    case MPI_EC_MONTGOMERY:
  ------------------
  |  Branch (1697:5): [True: 0, False: 2.84k]
  ------------------
 1698|      0|      add_points_montgomery (result, p1, p2, ctx);
 1699|      0|      break;
 1700|      0|    case MPI_EC_EDWARDS:
  ------------------
  |  Branch (1700:5): [True: 0, False: 2.84k]
  ------------------
 1701|      0|      add_points_edwards (result, p1, p2, ctx);
 1702|      0|      break;
 1703|  2.84k|    }
 1704|  2.84k|}
_gcry_mpi_ec_mul_point:
 1779|     32|{
 1780|     32|  gcry_mpi_t x1, y1, z1, k, h, yy;
 1781|     32|  unsigned int i, loops;
 1782|     32|  mpi_point_struct p1, p2, p1inv;
 1783|       |
 1784|       |  /* First try HW accelerated scalar multiplications.  Error
 1785|       |     is returned if acceleration is not supported or if HW
 1786|       |     does not support acceleration of given input.  */
 1787|     32|  if (mpi_ec_hw_mul_point (result, scalar, point, ctx) >= 0)
  ------------------
  |  |   46|     32|# define mpi_ec_hw_mul_point(r,s,p,c) (-1)
  ------------------
  |  Branch (1787:7): [Folded - Ignored]
  ------------------
 1788|      0|    {
 1789|      0|      return;
 1790|      0|    }
 1791|       |
 1792|     32|  if (ctx->model == MPI_EC_EDWARDS
  ------------------
  |  Branch (1792:7): [True: 0, False: 32]
  ------------------
 1793|     32|      || (ctx->model == MPI_EC_WEIERSTRASS
  ------------------
  |  Branch (1793:11): [True: 32, False: 0]
  ------------------
 1794|     32|          && mpi_is_secure (scalar)))
  ------------------
  |  |  115|     32|#define mpi_is_secure(a)      ((a) && ((a)->flags&1))
  |  |  ------------------
  |  |  |  Branch (115:32): [True: 32, False: 0]
  |  |  |  Branch (115:39): [True: 0, False: 32]
  |  |  ------------------
  ------------------
 1795|      0|    {
 1796|       |      /* Simple left to right binary method.  Algorithm 3.27 from
 1797|       |       * {author={Hankerson, Darrel and Menezes, Alfred J. and Vanstone, Scott},
 1798|       |       *  title = {Guide to Elliptic Curve Cryptography},
 1799|       |       *  year = {2003}, isbn = {038795273X},
 1800|       |       *  url = {http://www.cacr.math.uwaterloo.ca/ecc/},
 1801|       |       *  publisher = {Springer-Verlag New York, Inc.}} */
 1802|      0|      unsigned int nbits;
 1803|      0|      int j;
 1804|       |
 1805|      0|      if (mpi_cmp (scalar, ctx->p) >= 0)
  ------------------
  |  |  510|      0|#define mpi_cmp( u, v )        _gcry_mpi_cmp( (u), (v) )
  ------------------
  |  Branch (1805:11): [True: 0, False: 0]
  ------------------
 1806|      0|        nbits = mpi_get_nbits (scalar);
  ------------------
  |  |  552|      0|#define mpi_get_nbits(a)       _gcry_mpi_get_nbits ((a))
  ------------------
 1807|      0|      else
 1808|      0|        nbits = mpi_get_nbits (ctx->p);
  ------------------
  |  |  552|      0|#define mpi_get_nbits(a)       _gcry_mpi_get_nbits ((a))
  ------------------
 1809|       |
 1810|      0|      if (ctx->model == MPI_EC_WEIERSTRASS)
  ------------------
  |  Branch (1810:11): [True: 0, False: 0]
  ------------------
 1811|      0|        {
 1812|      0|          mpi_set_ui (result->x, 1);
  ------------------
  |  |  505|      0|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
 1813|      0|          mpi_set_ui (result->y, 1);
  ------------------
  |  |  505|      0|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
 1814|      0|          mpi_set_ui (result->z, 0);
  ------------------
  |  |  505|      0|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
 1815|      0|        }
 1816|      0|      else
 1817|      0|        {
 1818|      0|          mpi_set_ui (result->x, 0);
  ------------------
  |  |  505|      0|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
 1819|      0|          mpi_set_ui (result->y, 1);
  ------------------
  |  |  505|      0|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
 1820|      0|          mpi_set_ui (result->z, 1);
  ------------------
  |  |  505|      0|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
 1821|      0|          mpi_point_resize (point, ctx);
  ------------------
  |  |  550|      0|#define mpi_point_resize(p,ctx) _gcry_mpi_ec_point_resize (p, ctx)
  ------------------
 1822|      0|        }
 1823|       |
 1824|      0|      if (mpi_is_secure (scalar))
  ------------------
  |  |  115|      0|#define mpi_is_secure(a)      ((a) && ((a)->flags&1))
  |  |  ------------------
  |  |  |  Branch (115:32): [True: 0, False: 0]
  |  |  |  Branch (115:39): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1825|      0|        {
 1826|       |          /* If SCALAR is in secure memory we assume that it is the
 1827|       |             secret key we use constant time operation.  */
 1828|      0|          mpi_point_struct tmppnt;
 1829|       |
 1830|      0|          point_init (&tmppnt);
  ------------------
  |  |   35|      0|#define point_init(a)  _gcry_mpi_point_init ((a))
  ------------------
 1831|      0|          mpi_point_resize (result, ctx);
  ------------------
  |  |  550|      0|#define mpi_point_resize(p,ctx) _gcry_mpi_ec_point_resize (p, ctx)
  ------------------
 1832|      0|          mpi_point_resize (&tmppnt, ctx);
  ------------------
  |  |  550|      0|#define mpi_point_resize(p,ctx) _gcry_mpi_ec_point_resize (p, ctx)
  ------------------
 1833|      0|          for (j=nbits-1; j >= 0; j--)
  ------------------
  |  Branch (1833:27): [True: 0, False: 0]
  ------------------
 1834|      0|            {
 1835|      0|              _gcry_mpi_ec_dup_point (result, result, ctx);
 1836|      0|              _gcry_mpi_ec_add_points (&tmppnt, result, point, ctx);
 1837|      0|              point_swap_cond (result, &tmppnt, mpi_test_bit (scalar, j), ctx);
  ------------------
  |  |  553|      0|#define mpi_test_bit(a,b)      _gcry_mpi_test_bit ((a),(b))
  ------------------
 1838|      0|            }
 1839|      0|          point_free (&tmppnt);
  ------------------
  |  |   36|      0|#define point_free(a)  _gcry_mpi_point_free_parts ((a))
  ------------------
 1840|      0|        }
 1841|      0|      else
 1842|      0|        {
 1843|      0|          if (ctx->model == MPI_EC_EDWARDS)
  ------------------
  |  Branch (1843:15): [True: 0, False: 0]
  ------------------
 1844|      0|            {
 1845|      0|              mpi_point_resize (result, ctx);
  ------------------
  |  |  550|      0|#define mpi_point_resize(p,ctx) _gcry_mpi_ec_point_resize (p, ctx)
  ------------------
 1846|      0|              mpi_point_resize (point, ctx);
  ------------------
  |  |  550|      0|#define mpi_point_resize(p,ctx) _gcry_mpi_ec_point_resize (p, ctx)
  ------------------
 1847|      0|            }
 1848|       |
 1849|      0|          for (j=nbits-1; j >= 0; j--)
  ------------------
  |  Branch (1849:27): [True: 0, False: 0]
  ------------------
 1850|      0|            {
 1851|      0|              _gcry_mpi_ec_dup_point (result, result, ctx);
 1852|      0|              if (mpi_test_bit (scalar, j))
  ------------------
  |  |  553|      0|#define mpi_test_bit(a,b)      _gcry_mpi_test_bit ((a),(b))
  |  |  ------------------
  |  |  |  Branch (553:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1853|      0|                _gcry_mpi_ec_add_points (result, result, point, ctx);
 1854|      0|            }
 1855|      0|        }
 1856|      0|      return;
 1857|      0|    }
 1858|     32|  else if (ctx->model == MPI_EC_MONTGOMERY)
  ------------------
  |  Branch (1858:12): [True: 0, False: 32]
  ------------------
 1859|      0|    {
 1860|      0|      unsigned int nbits;
 1861|      0|      int j;
 1862|      0|      mpi_point_struct p1_, p2_;
 1863|      0|      mpi_point_t q1, q2, prd, sum;
 1864|      0|      unsigned long sw;
 1865|      0|      mpi_size_t rsize;
 1866|      0|      int scalar_copied = 0;
 1867|       |
 1868|       |      /* Compute scalar point multiplication with Montgomery Ladder.
 1869|       |         Note that we don't use Y-coordinate in the points at all.
 1870|       |         RESULT->Y will be filled by zero.  */
 1871|       |
 1872|      0|      nbits = mpi_get_nbits (scalar);
  ------------------
  |  |  552|      0|#define mpi_get_nbits(a)       _gcry_mpi_get_nbits ((a))
  ------------------
 1873|      0|      point_init (&p1);
  ------------------
  |  |   35|      0|#define point_init(a)  _gcry_mpi_point_init ((a))
  ------------------
 1874|      0|      point_init (&p2);
  ------------------
  |  |   35|      0|#define point_init(a)  _gcry_mpi_point_init ((a))
  ------------------
 1875|      0|      point_init (&p1_);
  ------------------
  |  |   35|      0|#define point_init(a)  _gcry_mpi_point_init ((a))
  ------------------
 1876|      0|      point_init (&p2_);
  ------------------
  |  |   35|      0|#define point_init(a)  _gcry_mpi_point_init ((a))
  ------------------
 1877|      0|      mpi_set_ui (p1.x, 1);
  ------------------
  |  |  505|      0|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
 1878|      0|      mpi_free (p2.x);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1879|      0|      p2.x  = mpi_copy (point->x);
  ------------------
  |  |  101|      0|# define mpi_copy(a)	       _gcry_mpi_copy((a))
  ------------------
 1880|      0|      mpi_set_ui (p2.z, 1);
  ------------------
  |  |  505|      0|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
 1881|       |
 1882|      0|      if (mpi_is_opaque (scalar))
  ------------------
  |  |  114|      0|#define mpi_is_opaque(a)      ((a) && ((a)->flags&4))
  |  |  ------------------
  |  |  |  Branch (114:32): [True: 0, False: 0]
  |  |  |  Branch (114:39): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1883|      0|        {
 1884|      0|          const unsigned int pbits = ctx->nbits;
 1885|      0|          gcry_mpi_t a;
 1886|      0|          unsigned int n;
 1887|      0|          unsigned char *raw;
 1888|       |
 1889|      0|          scalar_copied = 1;
 1890|       |
 1891|      0|          raw = _gcry_mpi_get_opaque_copy (scalar, &n);
 1892|      0|          if ((n+7)/8 != (pbits+7)/8)
  ------------------
  |  Branch (1892:15): [True: 0, False: 0]
  ------------------
 1893|      0|            log_fatal ("scalar size (%d) != prime size (%d)\n",
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
 1894|      0|                       (n+7)/8, (pbits+7)/8);
 1895|       |
 1896|      0|          reverse_buffer (raw, (n+7)/8);
 1897|      0|          if ((pbits % 8))
  ------------------
  |  Branch (1897:15): [True: 0, False: 0]
  ------------------
 1898|      0|            raw[0] &= (1 << (pbits % 8)) - 1;
 1899|      0|          raw[0] |= (1 << ((pbits + 7) % 8));
 1900|      0|          raw[(pbits+7)/8 - 1] &= (256 - ctx->h);
 1901|      0|          a = mpi_is_secure (scalar) ? mpi_snew (pbits): mpi_new (pbits);
  ------------------
  |  |  115|      0|#define mpi_is_secure(a)      ((a) && ((a)->flags&1))
  |  |  ------------------
  |  |  |  Branch (115:32): [True: 0, False: 0]
  |  |  |  Branch (115:39): [True: 0, False: 0]
  |  |  ------------------
  ------------------
                        a = mpi_is_secure (scalar) ? mpi_snew (pbits): mpi_new (pbits);
  ------------------
  |  |  493|      0|#define mpi_snew(n)            _gcry_mpi_snew ((n))
  ------------------
                        a = mpi_is_secure (scalar) ? mpi_snew (pbits): mpi_new (pbits);
  ------------------
  |  |  491|      0|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
 1902|      0|          _gcry_mpi_set_buffer (a, raw, (n+7)/8, 0);
 1903|      0|          xfree (raw);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1904|       |
 1905|      0|          scalar = a;
 1906|      0|        }
 1907|       |
 1908|      0|      mpi_point_resize (&p1, ctx);
  ------------------
  |  |  550|      0|#define mpi_point_resize(p,ctx) _gcry_mpi_ec_point_resize (p, ctx)
  ------------------
 1909|      0|      mpi_point_resize (&p2, ctx);
  ------------------
  |  |  550|      0|#define mpi_point_resize(p,ctx) _gcry_mpi_ec_point_resize (p, ctx)
  ------------------
 1910|      0|      mpi_point_resize (&p1_, ctx);
  ------------------
  |  |  550|      0|#define mpi_point_resize(p,ctx) _gcry_mpi_ec_point_resize (p, ctx)
  ------------------
 1911|      0|      mpi_point_resize (&p2_, ctx);
  ------------------
  |  |  550|      0|#define mpi_point_resize(p,ctx) _gcry_mpi_ec_point_resize (p, ctx)
  ------------------
 1912|       |
 1913|      0|      mpi_resize (point->x, ctx->p->nlimbs);
  ------------------
  |  |  100|      0|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  ------------------
 1914|      0|      point->x->nlimbs = ctx->p->nlimbs;
 1915|       |
 1916|      0|      q1 = &p1;
 1917|      0|      q2 = &p2;
 1918|      0|      prd = &p1_;
 1919|      0|      sum = &p2_;
 1920|       |
 1921|      0|      for (j=nbits-1; j >= 0; j--)
  ------------------
  |  Branch (1921:23): [True: 0, False: 0]
  ------------------
 1922|      0|        {
 1923|      0|          mpi_point_t t;
 1924|       |
 1925|      0|          sw = mpi_test_bit (scalar, j);
  ------------------
  |  |  553|      0|#define mpi_test_bit(a,b)      _gcry_mpi_test_bit ((a),(b))
  ------------------
 1926|      0|          point_swap_cond (q1, q2, sw, ctx);
 1927|      0|          montgomery_ladder (prd, sum, q1, q2, point->x, ctx);
 1928|      0|          point_swap_cond (prd, sum, sw, ctx);
 1929|      0|          t = q1;  q1 = prd;  prd = t;
 1930|      0|          t = q2;  q2 = sum;  sum = t;
 1931|      0|        }
 1932|       |
 1933|      0|      mpi_clear (result->y);
  ------------------
  |  |  116|      0|#define mpi_clear(a)          _gcry_mpi_clear ((a))
  ------------------
 1934|      0|      sw = (nbits & 1);
 1935|      0|      point_swap_cond (&p1, &p1_, sw, ctx);
 1936|       |
 1937|      0|      rsize = p1.z->nlimbs;
 1938|      0|      MPN_NORMALIZE (p1.z->d, rsize);
  ------------------
  |  |  119|      0|    do {		       \
  |  |  120|      0|	while( (n) > 0 ) {     \
  |  |  ------------------
  |  |  |  Branch (120:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  121|      0|	    if( (d)[(n)-1] ) \
  |  |  ------------------
  |  |  |  Branch (121:10): [True: 0, False: 0]
  |  |  ------------------
  |  |  122|      0|		break;	       \
  |  |  123|      0|	    (n)--;	       \
  |  |  124|      0|	}		       \
  |  |  125|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (125:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1939|      0|      if (rsize == 0)
  ------------------
  |  Branch (1939:11): [True: 0, False: 0]
  ------------------
 1940|      0|        {
 1941|      0|          mpi_set_ui (result->x, 1);
  ------------------
  |  |  505|      0|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
 1942|      0|          mpi_set_ui (result->z, 0);
  ------------------
  |  |  505|      0|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
 1943|      0|        }
 1944|      0|      else
 1945|      0|        {
 1946|      0|          z1 = mpi_new (0);
  ------------------
  |  |  491|      0|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
 1947|      0|          ec_invm (z1, p1.z, ctx);
 1948|      0|          ec_mulm (result->x, p1.x, z1, ctx);
 1949|      0|          mpi_set_ui (result->z, 1);
  ------------------
  |  |  505|      0|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
 1950|      0|          mpi_free (z1);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1951|      0|        }
 1952|       |
 1953|      0|      point_free (&p1);
  ------------------
  |  |   36|      0|#define point_free(a)  _gcry_mpi_point_free_parts ((a))
  ------------------
 1954|      0|      point_free (&p2);
  ------------------
  |  |   36|      0|#define point_free(a)  _gcry_mpi_point_free_parts ((a))
  ------------------
 1955|      0|      point_free (&p1_);
  ------------------
  |  |   36|      0|#define point_free(a)  _gcry_mpi_point_free_parts ((a))
  ------------------
 1956|      0|      point_free (&p2_);
  ------------------
  |  |   36|      0|#define point_free(a)  _gcry_mpi_point_free_parts ((a))
  ------------------
 1957|      0|      if (scalar_copied)
  ------------------
  |  Branch (1957:11): [True: 0, False: 0]
  ------------------
 1958|      0|        _gcry_mpi_release (scalar);
 1959|      0|      return;
 1960|      0|    }
 1961|       |
 1962|     32|  x1 = mpi_alloc_like (ctx->p);
  ------------------
  |  |  117|     32|#define mpi_alloc_like(a)     _gcry_mpi_alloc_like((a))
  ------------------
 1963|     32|  y1 = mpi_alloc_like (ctx->p);
  ------------------
  |  |  117|     32|#define mpi_alloc_like(a)     _gcry_mpi_alloc_like((a))
  ------------------
 1964|     32|  h  = mpi_alloc_like (ctx->p);
  ------------------
  |  |  117|     32|#define mpi_alloc_like(a)     _gcry_mpi_alloc_like((a))
  ------------------
 1965|     32|  k  = mpi_copy (scalar);
  ------------------
  |  |  101|     32|# define mpi_copy(a)	       _gcry_mpi_copy((a))
  ------------------
 1966|     32|  yy = mpi_copy (point->y);
  ------------------
  |  |  101|     32|# define mpi_copy(a)	       _gcry_mpi_copy((a))
  ------------------
 1967|       |
 1968|     32|  if ( mpi_has_sign (k) )
  ------------------
  |  |   81|     32|#define mpi_has_sign(a)	      ((a)->sign)
  |  |  ------------------
  |  |  |  Branch (81:31): [True: 0, False: 32]
  |  |  ------------------
  ------------------
 1969|      0|    {
 1970|      0|      k->sign = 0;
 1971|      0|      ec_invm (yy, yy, ctx);
 1972|      0|    }
 1973|       |
 1974|     32|  if (!mpi_cmp_ui (point->z, 1))
  ------------------
  |  |  512|     32|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
  |  Branch (1974:7): [True: 32, False: 0]
  ------------------
 1975|     32|    {
 1976|     32|      mpi_set (x1, point->x);
  ------------------
  |  |  504|     32|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
 1977|     32|      mpi_set (y1, yy);
  ------------------
  |  |  504|     32|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
 1978|     32|    }
 1979|      0|  else
 1980|      0|    {
 1981|      0|      gcry_mpi_t z2, z3;
 1982|       |
 1983|      0|      z2 = mpi_alloc_like (ctx->p);
  ------------------
  |  |  117|      0|#define mpi_alloc_like(a)     _gcry_mpi_alloc_like((a))
  ------------------
 1984|      0|      z3 = mpi_alloc_like (ctx->p);
  ------------------
  |  |  117|      0|#define mpi_alloc_like(a)     _gcry_mpi_alloc_like((a))
  ------------------
 1985|      0|      ec_mulm (z2, point->z, point->z, ctx);
 1986|      0|      ec_mulm (z3, point->z, z2, ctx);
 1987|      0|      ec_invm (z2, z2, ctx);
 1988|      0|      ec_mulm (x1, point->x, z2, ctx);
 1989|      0|      ec_invm (z3, z3, ctx);
 1990|      0|      ec_mulm (y1, yy, z3, ctx);
 1991|      0|      mpi_free (z2);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1992|      0|      mpi_free (z3);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 1993|      0|    }
 1994|     32|  z1 = mpi_copy (mpi_const (MPI_C_ONE));
  ------------------
  |  |  101|     32|# define mpi_copy(a)	       _gcry_mpi_copy((a))
  ------------------
 1995|       |
 1996|     32|  mpi_mul (h, k, mpi_const (MPI_C_THREE)); /* h = 3k */
  ------------------
  |  |  523|     32|#define mpi_mul(w,u,v)         _gcry_mpi_mul ((w),(u),(v))
  ------------------
 1997|     32|  loops = mpi_get_nbits (h);
  ------------------
  |  |  552|     32|#define mpi_get_nbits(a)       _gcry_mpi_get_nbits ((a))
  ------------------
 1998|     32|  if (loops < 2)
  ------------------
  |  Branch (1998:7): [True: 0, False: 32]
  ------------------
 1999|      0|    {
 2000|       |      /* If SCALAR is zero, the above mpi_mul sets H to zero and thus
 2001|       |         LOOPs will be zero.  To avoid an underflow of I in the main
 2002|       |         loop we set LOOP to 2 and the result to (0,0,0).  */
 2003|      0|      loops = 2;
 2004|      0|      mpi_clear (result->x);
  ------------------
  |  |  116|      0|#define mpi_clear(a)          _gcry_mpi_clear ((a))
  ------------------
 2005|      0|      mpi_clear (result->y);
  ------------------
  |  |  116|      0|#define mpi_clear(a)          _gcry_mpi_clear ((a))
  ------------------
 2006|      0|      mpi_clear (result->z);
  ------------------
  |  |  116|      0|#define mpi_clear(a)          _gcry_mpi_clear ((a))
  ------------------
 2007|      0|    }
 2008|     32|  else
 2009|     32|    {
 2010|     32|      mpi_set (result->x, point->x);
  ------------------
  |  |  504|     32|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
 2011|     32|      mpi_set (result->y, yy);
  ------------------
  |  |  504|     32|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
 2012|     32|      mpi_set (result->z, point->z);
  ------------------
  |  |  504|     32|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
 2013|     32|    }
 2014|     32|  mpi_free (yy); yy = NULL;
  ------------------
  |  |   99|     32|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 2015|       |
 2016|     32|  p1.x = x1; x1 = NULL;
 2017|     32|  p1.y = y1; y1 = NULL;
 2018|     32|  p1.z = z1; z1 = NULL;
 2019|     32|  point_init (&p2);
  ------------------
  |  |   35|     32|#define point_init(a)  _gcry_mpi_point_init ((a))
  ------------------
 2020|     32|  point_init (&p1inv);
  ------------------
  |  |   35|     32|#define point_init(a)  _gcry_mpi_point_init ((a))
  ------------------
 2021|       |
 2022|       |  /* Invert point: y = p - y mod p  */
 2023|     32|  point_set (&p1inv, &p1);
 2024|     32|  ec_subm (p1inv.y, ctx->p, p1inv.y, ctx);
 2025|       |
 2026|  8.16k|  for (i=loops-2; i > 0; i--)
  ------------------
  |  Branch (2026:19): [True: 8.12k, False: 32]
  ------------------
 2027|  8.12k|    {
 2028|  8.12k|      _gcry_mpi_ec_dup_point (result, result, ctx);
 2029|  8.12k|      if (mpi_test_bit (h, i) == 1 && mpi_test_bit (k, i) == 0)
  ------------------
  |  |  553|  8.12k|#define mpi_test_bit(a,b)      _gcry_mpi_test_bit ((a),(b))
  ------------------
                    if (mpi_test_bit (h, i) == 1 && mpi_test_bit (k, i) == 0)
  ------------------
  |  |  553|  4.03k|#define mpi_test_bit(a,b)      _gcry_mpi_test_bit ((a),(b))
  ------------------
  |  Branch (2029:11): [True: 4.03k, False: 4.09k]
  |  Branch (2029:39): [True: 1.40k, False: 2.62k]
  ------------------
 2030|  1.40k|        {
 2031|  1.40k|          point_set (&p2, result);
 2032|  1.40k|          _gcry_mpi_ec_add_points (result, &p2, &p1, ctx);
 2033|  1.40k|        }
 2034|  8.12k|      if (mpi_test_bit (h, i) == 0 && mpi_test_bit (k, i) == 1)
  ------------------
  |  |  553|  8.12k|#define mpi_test_bit(a,b)      _gcry_mpi_test_bit ((a),(b))
  ------------------
                    if (mpi_test_bit (h, i) == 0 && mpi_test_bit (k, i) == 1)
  ------------------
  |  |  553|  4.09k|#define mpi_test_bit(a,b)      _gcry_mpi_test_bit ((a),(b))
  ------------------
  |  Branch (2034:11): [True: 4.09k, False: 4.03k]
  |  Branch (2034:39): [True: 1.42k, False: 2.67k]
  ------------------
 2035|  1.42k|        {
 2036|  1.42k|          point_set (&p2, result);
 2037|  1.42k|          _gcry_mpi_ec_add_points (result, &p2, &p1inv, ctx);
 2038|  1.42k|        }
 2039|  8.12k|    }
 2040|       |
 2041|     32|  point_free (&p1);
  ------------------
  |  |   36|     32|#define point_free(a)  _gcry_mpi_point_free_parts ((a))
  ------------------
 2042|     32|  point_free (&p2);
  ------------------
  |  |   36|     32|#define point_free(a)  _gcry_mpi_point_free_parts ((a))
  ------------------
 2043|     32|  point_free (&p1inv);
  ------------------
  |  |   36|     32|#define point_free(a)  _gcry_mpi_point_free_parts ((a))
  ------------------
 2044|     32|  mpi_free (h);
  ------------------
  |  |   99|     32|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 2045|     32|  mpi_free (k);
  ------------------
  |  |   99|     32|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
 2046|     32|}
_gcry_mpi_ec_curve_point:
 2052|     16|{
 2053|     16|  int res = 0;
 2054|     16|  gcry_mpi_t x, y, w;
 2055|       |
 2056|     16|  x = mpi_new (0);
  ------------------
  |  |  491|     16|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
 2057|     16|  y = mpi_new (0);
  ------------------
  |  |  491|     16|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
 2058|     16|  w = mpi_new (0);
  ------------------
  |  |  491|     16|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
 2059|       |
 2060|       |  /* Check that the point is in range.  This needs to be done here and
 2061|       |   * not after conversion to affine coordinates.  */
 2062|     16|  if (mpi_cmpabs (point->x, ctx->p) >= 0)
  ------------------
  |  |  511|     16|#define mpi_cmpabs( u, v )     _gcry_mpi_cmpabs( (u), (v) )
  ------------------
  |  Branch (2062:7): [True: 0, False: 16]
  ------------------
 2063|      0|    goto leave;
 2064|     16|  if (mpi_cmpabs (point->y, ctx->p) >= 0)
  ------------------
  |  |  511|     16|#define mpi_cmpabs( u, v )     _gcry_mpi_cmpabs( (u), (v) )
  ------------------
  |  Branch (2064:7): [True: 0, False: 16]
  ------------------
 2065|      0|    goto leave;
 2066|     16|  if (mpi_cmpabs (point->z, ctx->p) >= 0)
  ------------------
  |  |  511|     16|#define mpi_cmpabs( u, v )     _gcry_mpi_cmpabs( (u), (v) )
  ------------------
  |  Branch (2066:7): [True: 0, False: 16]
  ------------------
 2067|      0|    goto leave;
 2068|       |
 2069|     16|  switch (ctx->model)
  ------------------
  |  Branch (2069:11): [True: 0, False: 16]
  ------------------
 2070|     16|    {
 2071|     16|    case MPI_EC_WEIERSTRASS:
  ------------------
  |  Branch (2071:5): [True: 16, False: 0]
  ------------------
 2072|     16|      {
 2073|     16|        gcry_mpi_t xxx;
 2074|       |
 2075|     16|        if (_gcry_mpi_ec_get_affine (x, y, point, ctx))
  ------------------
  |  Branch (2075:13): [True: 0, False: 16]
  ------------------
 2076|      0|          goto leave;
 2077|       |
 2078|     16|        xxx = mpi_new (0);
  ------------------
  |  |  491|     16|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
 2079|       |
 2080|       |        /* y^2 == x^3 + a·x + b */
 2081|     16|        ec_pow2 (y, y, ctx);
 2082|       |
 2083|     16|        ec_pow3 (xxx, x, ctx);
 2084|     16|        ec_mulm (w, ctx->a, x, ctx);
 2085|     16|        ec_addm (w, w, ctx->b, ctx);
 2086|     16|        ec_addm (w, w, xxx, ctx);
 2087|       |
 2088|     16|        if (!mpi_cmp (y, w))
  ------------------
  |  |  510|     16|#define mpi_cmp( u, v )        _gcry_mpi_cmp( (u), (v) )
  ------------------
  |  Branch (2088:13): [True: 16, False: 0]
  ------------------
 2089|     16|          res = 1;
 2090|       |
 2091|     16|        _gcry_mpi_release (xxx);
 2092|     16|      }
 2093|      0|      break;
 2094|      0|    case MPI_EC_MONTGOMERY:
  ------------------
  |  Branch (2094:5): [True: 0, False: 16]
  ------------------
 2095|      0|      {
 2096|      0|#define xx y
 2097|       |        /* With Montgomery curve, only X-coordinate is valid.  */
 2098|      0|        if (_gcry_mpi_ec_get_affine (x, NULL, point, ctx))
  ------------------
  |  Branch (2098:13): [True: 0, False: 0]
  ------------------
 2099|      0|          goto leave;
 2100|       |
 2101|       |        /* The equation is: b * y^2 == x^3 + a · x^2 + x */
 2102|       |        /* We check if right hand is quadratic residue or not by
 2103|       |           Euler's criterion.  */
 2104|       |        /* CTX->A has (a-2)/4 and CTX->B has b^-1 */
 2105|      0|        ec_mulm (w, ctx->a, mpi_const (MPI_C_FOUR), ctx);
  ------------------
  |  |  120|      0|#define mpi_const(n)          _gcry_mpi_const ((n))
  ------------------
 2106|      0|        ec_addm (w, w, mpi_const (MPI_C_TWO), ctx);
  ------------------
  |  |  120|      0|#define mpi_const(n)          _gcry_mpi_const ((n))
  ------------------
 2107|      0|        ec_mulm (w, w, x, ctx);
 2108|      0|        ec_pow2 (xx, x, ctx);
  ------------------
  |  | 2096|      0|#define xx y
  ------------------
 2109|      0|        ec_addm (w, w, xx, ctx);
  ------------------
  |  | 2096|      0|#define xx y
  ------------------
 2110|      0|        ec_addm (w, w, mpi_const (MPI_C_ONE), ctx);
  ------------------
  |  |  120|      0|#define mpi_const(n)          _gcry_mpi_const ((n))
  ------------------
 2111|      0|        ec_mulm (w, w, x, ctx);
 2112|      0|        ec_mulm (w, w, ctx->b, ctx);
 2113|      0|#undef xx
 2114|       |        /* Compute Euler's criterion: w^(p-1)/2 */
 2115|      0|#define p_minus1 y
 2116|      0|        ec_subm (p_minus1, ctx->p, mpi_const (MPI_C_ONE), ctx);
  ------------------
  |  | 2115|      0|#define p_minus1 y
  ------------------
                      ec_subm (p_minus1, ctx->p, mpi_const (MPI_C_ONE), ctx);
  ------------------
  |  |  120|      0|#define mpi_const(n)          _gcry_mpi_const ((n))
  ------------------
 2117|      0|        mpi_rshift (p_minus1, p_minus1, 1);
  ------------------
  |  |  558|      0|#define mpi_rshift(a,b,c)      _gcry_mpi_rshift ((a),(b),(c))
  ------------------
 2118|      0|        ec_powm (w, w, p_minus1, ctx);
  ------------------
  |  | 2115|      0|#define p_minus1 y
  ------------------
 2119|       |
 2120|      0|        res = !mpi_cmp_ui (w, 1);
  ------------------
  |  |  512|      0|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
 2121|      0|#undef p_minus1
 2122|      0|      }
 2123|      0|      break;
 2124|      0|    case MPI_EC_EDWARDS:
  ------------------
  |  Branch (2124:5): [True: 0, False: 16]
  ------------------
 2125|      0|      {
 2126|      0|        if (_gcry_mpi_ec_get_affine (x, y, point, ctx))
  ------------------
  |  Branch (2126:13): [True: 0, False: 0]
  ------------------
 2127|      0|          goto leave;
 2128|       |
 2129|      0|        mpi_resize (w, ctx->p->nlimbs);
  ------------------
  |  |  100|      0|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  ------------------
 2130|      0|        w->nlimbs = ctx->p->nlimbs;
 2131|       |
 2132|       |        /* a · x^2 + y^2 - 1 - b · x^2 · y^2 == 0 */
 2133|      0|        ctx->pow2 (x, x, ctx);
 2134|      0|        ctx->pow2 (y, y, ctx);
 2135|      0|        if (ctx->dialect == ECC_DIALECT_ED25519)
  ------------------
  |  Branch (2135:13): [True: 0, False: 0]
  ------------------
 2136|      0|          ctx->subm (w, ctx->p, x, ctx);
 2137|      0|        else
 2138|      0|          ctx->mulm (w, ctx->a, x, ctx);
 2139|      0|        ctx->addm (w, w, y, ctx);
 2140|      0|        ctx->mulm (x, x, y, ctx);
 2141|      0|        ctx->mulm (x, x, ctx->b, ctx);
 2142|      0|        ctx->subm (w, w, x, ctx);
 2143|      0|        if (!mpi_cmp_ui (w, 1))
  ------------------
  |  |  512|      0|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
  |  Branch (2143:13): [True: 0, False: 0]
  ------------------
 2144|      0|          res = 1;
 2145|      0|      }
 2146|      0|      break;
 2147|     16|    }
 2148|       |
 2149|     16| leave:
 2150|     16|  _gcry_mpi_release (w);
 2151|     16|  _gcry_mpi_release (x);
 2152|     16|  _gcry_mpi_release (y);
 2153|       |
 2154|     16|  return res;
 2155|     16|}
ec.c:point_set:
  136|  2.86k|{
  137|  2.86k|  mpi_set (d->x, s->x);
  ------------------
  |  |  504|  2.86k|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
  138|  2.86k|  mpi_set (d->y, s->y);
  ------------------
  |  |  504|  2.86k|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
  139|  2.86k|  mpi_set (d->z, s->z);
  ------------------
  |  |  504|  2.86k|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
  140|  2.86k|}
ec.c:ec_p_init:
  821|     16|{
  822|     16|  int i;
  823|     16|  static int use_barrett;
  824|       |
  825|     16|  if (!use_barrett)
  ------------------
  |  Branch (825:7): [True: 1, False: 15]
  ------------------
  826|      1|    {
  827|      1|      if (getenv ("GCRYPT_BARRETT"))
  ------------------
  |  Branch (827:11): [True: 0, False: 1]
  ------------------
  828|      0|        use_barrett = 1;
  829|      1|      else
  830|      1|        use_barrett = -1;
  831|      1|    }
  832|       |
  833|       |  /* Fixme: Do we want to check some constraints? e.g.  a < p  */
  834|       |
  835|     16|  ctx->model = model;
  836|     16|  ctx->dialect = dialect;
  837|     16|  ctx->flags = flags;
  838|     16|  ctx->nbits = mpi_get_nbits (p);
  ------------------
  |  |  552|     16|#define mpi_get_nbits(a)       _gcry_mpi_get_nbits ((a))
  ------------------
  839|     16|  ctx->p = mpi_copy (p);
  ------------------
  |  |  101|     16|# define mpi_copy(a)	       _gcry_mpi_copy((a))
  ------------------
  840|     16|  ctx->a = mpi_copy (a);
  ------------------
  |  |  101|     16|# define mpi_copy(a)	       _gcry_mpi_copy((a))
  ------------------
  841|     16|  ctx->b = mpi_copy (b);
  ------------------
  |  |  101|     16|# define mpi_copy(a)	       _gcry_mpi_copy((a))
  ------------------
  842|       |
  843|     16|  ctx->t.p_barrett = use_barrett > 0? _gcry_mpi_barrett_init (ctx->p, 0):NULL;
  ------------------
  |  Branch (843:22): [True: 0, False: 16]
  ------------------
  844|       |
  845|     16|  _gcry_mpi_ec_get_reset (ctx);
  846|       |
  847|     16|  if (model == MPI_EC_MONTGOMERY)
  ------------------
  |  Branch (847:7): [True: 0, False: 16]
  ------------------
  848|      0|    {
  849|      0|      for (i=0; i< DIM(bad_points_table); i++)
  ------------------
  |  |  104|      0|#define DIM(v) (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (849:17): [True: 0, False: 0]
  ------------------
  850|      0|        {
  851|      0|          gcry_mpi_t p_candidate = scanval (bad_points_table[i][0]);
  852|      0|          int match_p = !mpi_cmp (ctx->p, p_candidate);
  ------------------
  |  |  510|      0|#define mpi_cmp( u, v )        _gcry_mpi_cmp( (u), (v) )
  ------------------
  853|      0|          int j;
  854|       |
  855|      0|          mpi_free (p_candidate);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  856|      0|          if (!match_p)
  ------------------
  |  Branch (856:15): [True: 0, False: 0]
  ------------------
  857|      0|            continue;
  858|       |
  859|      0|          for (j=0; i< DIM(ctx->t.scratch) && bad_points_table[i][j]; j++)
  ------------------
  |  |  104|      0|#define DIM(v) (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (859:21): [True: 0, False: 0]
  |  Branch (859:47): [True: 0, False: 0]
  ------------------
  860|      0|            ctx->t.scratch[j] = scanval (bad_points_table[i][j]);
  861|      0|        }
  862|      0|    }
  863|     16|  else
  864|     16|    {
  865|       |      /* Allocate scratch variables.  */
  866|    192|      for (i=0; i< DIM(ctx->t.scratch); i++)
  ------------------
  |  |  104|    192|#define DIM(v) (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (866:17): [True: 176, False: 16]
  ------------------
  867|    176|        ctx->t.scratch[i] = mpi_alloc_like (ctx->p);
  ------------------
  |  |  117|    176|#define mpi_alloc_like(a)     _gcry_mpi_alloc_like((a))
  ------------------
  868|     16|    }
  869|       |
  870|     16|  ctx->addm = ec_addm;
  871|     16|  ctx->subm = ec_subm;
  872|     16|  ctx->mulm = ec_mulm;
  873|     16|  ctx->mul2 = ec_mul2;
  874|     16|  ctx->pow2 = ec_pow2;
  875|     16|  ctx->mod = ec_mod;
  876|       |
  877|     80|  for (i=0; field_table[i].p; i++)
  ------------------
  |  Branch (877:13): [True: 80, False: 0]
  ------------------
  878|     80|    {
  879|     80|      gcry_mpi_t f_p;
  880|     80|      gpg_err_code_t rc;
  881|       |
  882|     80|      if (field_table_mpis[i] == NULL)
  ------------------
  |  Branch (882:11): [True: 5, False: 75]
  ------------------
  883|      5|	{
  884|      5|	  rc = _gcry_mpi_scan (&f_p, GCRYMPI_FMT_HEX, field_table[i].p, 0,
  885|      5|			       NULL);
  886|      5|	  if (rc)
  ------------------
  |  Branch (886:8): [True: 0, False: 5]
  ------------------
  887|      0|	    log_fatal ("scanning ECC parameter failed: %s\n",
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
  888|      0|		       gpg_strerror (rc));
  889|      5|	  field_table_mpis[i] = f_p; /* cache */
  890|      5|	}
  891|     75|      else
  892|     75|	{
  893|     75|	  f_p = field_table_mpis[i];
  894|     75|	}
  895|       |
  896|     80|      if (!mpi_cmp (p, f_p))
  ------------------
  |  |  510|     80|#define mpi_cmp( u, v )        _gcry_mpi_cmp( (u), (v) )
  ------------------
  |  Branch (896:11): [True: 16, False: 64]
  ------------------
  897|     16|        {
  898|     16|          ctx->addm = field_table[i].addm ? field_table[i].addm : ctx->addm;
  ------------------
  |  Branch (898:23): [True: 0, False: 16]
  ------------------
  899|     16|          ctx->subm = field_table[i].subm ? field_table[i].subm : ctx->subm;
  ------------------
  |  Branch (899:23): [True: 0, False: 16]
  ------------------
  900|     16|          ctx->mulm = field_table[i].mulm ? field_table[i].mulm : ctx->mulm;
  ------------------
  |  Branch (900:23): [True: 0, False: 16]
  ------------------
  901|     16|          ctx->mul2 = field_table[i].mul2 ? field_table[i].mul2 : ctx->mul2;
  ------------------
  |  Branch (901:23): [True: 0, False: 16]
  ------------------
  902|     16|          ctx->pow2 = field_table[i].pow2 ? field_table[i].pow2 : ctx->pow2;
  ------------------
  |  Branch (902:23): [True: 0, False: 16]
  ------------------
  903|     16|          ctx->mod = field_table[i].mod ? field_table[i].mod : ctx->mod;
  ------------------
  |  Branch (903:22): [True: 16, False: 0]
  ------------------
  904|       |
  905|     16|	  if (ctx->a)
  ------------------
  |  Branch (905:8): [True: 16, False: 0]
  ------------------
  906|     16|	    {
  907|     16|	      mpi_resize (ctx->a, ctx->p->nlimbs);
  ------------------
  |  |  100|     16|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  ------------------
  908|     16|	      ctx->a->nlimbs = ctx->p->nlimbs;
  909|     16|	    }
  910|       |
  911|     16|	  if (ctx->b)
  ------------------
  |  Branch (911:8): [True: 16, False: 0]
  ------------------
  912|     16|	    {
  913|     16|	      mpi_resize (ctx->b, ctx->p->nlimbs);
  ------------------
  |  |  100|     16|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  ------------------
  914|     16|	      ctx->b->nlimbs = ctx->p->nlimbs;
  915|     16|	    }
  916|       |
  917|    192|          for (i=0; i< DIM(ctx->t.scratch) && ctx->t.scratch[i]; i++)
  ------------------
  |  |  104|    384|#define DIM(v) (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (917:21): [True: 176, False: 16]
  |  Branch (917:47): [True: 176, False: 0]
  ------------------
  918|    176|            ctx->t.scratch[i]->nlimbs = ctx->p->nlimbs;
  919|       |
  920|     16|          break;
  921|     16|        }
  922|     80|    }
  923|       |
  924|       |  /* Prepare for fast reduction.  */
  925|       |  /* FIXME: need a test for NIST values.  However it does not gain us
  926|       |     any real advantage, for 384 bits it is actually slower than using
  927|       |     mpi_mulm.  */
  928|       |/*   ctx->nist_nbits = mpi_get_nbits (ctx->p); */
  929|       |/*   if (ctx->nist_nbits == 192) */
  930|       |/*     { */
  931|       |/*       for (i=0; i < 4; i++) */
  932|       |/*         ctx->s[i] = mpi_new (192); */
  933|       |/*       ctx->c    = mpi_new (192*2); */
  934|       |/*     } */
  935|       |/*   else if (ctx->nist_nbits == 384) */
  936|       |/*     { */
  937|       |/*       for (i=0; i < 10; i++) */
  938|       |/*         ctx->s[i] = mpi_new (384); */
  939|       |/*       ctx->c    = mpi_new (384*2); */
  940|       |/*     } */
  941|     16|}
ec.c:ec_mul2:
  310|  19.1k|{
  311|  19.1k|  mpi_lshift (w, u, 1);
  ------------------
  |  |  559|  19.1k|#define mpi_lshift(a,b,c)      _gcry_mpi_lshift ((a),(b),(c))
  ------------------
  312|  19.1k|  ctx->mod (w, ctx);
  313|  19.1k|}
ec.c:ec_deinit:
  946|     16|{
  947|     16|  mpi_ec_t ctx = opaque;
  948|     16|  int i;
  949|       |
  950|     16|  _gcry_mpi_barrett_free (ctx->t.p_barrett);
  951|       |
  952|       |  /* Domain parameter.  */
  953|     16|  mpi_free (ctx->p);
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  954|     16|  mpi_free (ctx->a);
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  955|     16|  mpi_free (ctx->b);
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  956|     16|  _gcry_mpi_point_release (ctx->G);
  957|     16|  mpi_free (ctx->n);
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  958|       |
  959|       |  /* The key.  */
  960|     16|  _gcry_mpi_point_release (ctx->Q);
  961|     16|  mpi_free (ctx->d);
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  962|       |
  963|       |  /* Private data of ec.c.  */
  964|     16|  mpi_free (ctx->t.two_inv_p);
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  965|       |
  966|    192|  for (i=0; i< DIM(ctx->t.scratch); i++)
  ------------------
  |  |  104|    192|#define DIM(v) (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (966:13): [True: 176, False: 16]
  ------------------
  967|    176|    mpi_free (ctx->t.scratch[i]);
  ------------------
  |  |   99|    176|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  968|       |
  969|       |/*   if (ctx->nist_nbits == 192) */
  970|       |/*     { */
  971|       |/*       for (i=0; i < 4; i++) */
  972|       |/*         mpi_free (ctx->s[i]); */
  973|       |/*       mpi_free (ctx->c); */
  974|       |/*     } */
  975|       |/*   else if (ctx->nist_nbits == 384) */
  976|       |/*     { */
  977|       |/*       for (i=0; i < 10; i++) */
  978|       |/*         mpi_free (ctx->s[i]); */
  979|       |/*       mpi_free (ctx->c); */
  980|       |/*     } */
  981|     16|}
ec.c:ec_invm:
  348|     32|{
  349|     32|  if (!mpi_invm (x, a, ctx->p))
  ------------------
  |  |  530|     32|#define mpi_invm(g,a,b)        _gcry_mpi_invm ( (g), (a), (b) )
  ------------------
  |  Branch (349:7): [True: 0, False: 32]
  ------------------
  350|      0|    {
  351|      0|      log_error ("ec_invm: inverse does not exist:\n");
  ------------------
  |  |  203|      0|#define log_error   _gcry_log_error
  ------------------
  352|      0|      log_mpidump ("  a", a);
  ------------------
  |  |  212|      0|#define log_mpidump _gcry_log_printmpi
  ------------------
  353|      0|      log_mpidump ("  p", ctx->p);
  ------------------
  |  |  212|      0|#define log_mpidump _gcry_log_printmpi
  ------------------
  354|      0|    }
  355|     32|}
ec.c:ec_mulm:
  302|   123k|{
  303|   123k|  mpi_mul (w, u, v);
  ------------------
  |  |  523|   123k|#define mpi_mul(w,u,v)         _gcry_mpi_mul ((w),(u),(v))
  ------------------
  304|   123k|  ctx->mod (w, ctx);
  305|   123k|}
ec.c:dup_point_weierstrass:
 1220|  8.12k|{
 1221|  8.12k|#define x3 (result->x)
 1222|  8.12k|#define y3 (result->y)
 1223|  8.12k|#define z3 (result->z)
 1224|  8.12k|#define t1 (ctx->t.scratch[0])
 1225|  8.12k|#define t2 (ctx->t.scratch[1])
 1226|  8.12k|#define t3 (ctx->t.scratch[2])
 1227|  8.12k|#define l1 (ctx->t.scratch[3])
 1228|  8.12k|#define l2 (ctx->t.scratch[4])
 1229|  8.12k|#define l3 (ctx->t.scratch[5])
 1230|       |
 1231|  8.12k|  if (!mpi_cmp_ui (point->y, 0) || !mpi_cmp_ui (point->z, 0))
  ------------------
  |  |  512|  16.2k|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
                if (!mpi_cmp_ui (point->y, 0) || !mpi_cmp_ui (point->z, 0))
  ------------------
  |  |  512|  8.12k|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
  |  Branch (1231:7): [True: 0, False: 8.12k]
  |  Branch (1231:36): [True: 0, False: 8.12k]
  ------------------
 1232|      0|    {
 1233|       |      /* P_y == 0 || P_z == 0 => [1:1:0] */
 1234|      0|      mpi_set_ui (x3, 1);
  ------------------
  |  |  505|      0|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
 1235|      0|      mpi_set_ui (y3, 1);
  ------------------
  |  |  505|      0|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
 1236|      0|      mpi_set_ui (z3, 0);
  ------------------
  |  |  505|      0|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
 1237|      0|    }
 1238|  8.12k|  else
 1239|  8.12k|    {
 1240|  8.12k|      if (ec_get_a_is_pminus3 (ctx))  /* Use the faster case.  */
  ------------------
  |  Branch (1240:11): [True: 8.12k, False: 0]
  ------------------
 1241|  8.12k|        {
 1242|       |          /* L1 = 3(X - Z^2)(X + Z^2) */
 1243|       |          /*                          T1: used for Z^2. */
 1244|       |          /*                          T2: used for the right term.  */
 1245|  8.12k|          ec_pow2 (t1, point->z, ctx);
  ------------------
  |  | 1224|  8.12k|#define t1 (ctx->t.scratch[0])
  ------------------
 1246|  8.12k|          ec_subm (l1, point->x, t1, ctx);
  ------------------
  |  | 1227|  8.12k|#define l1 (ctx->t.scratch[3])
  ------------------
                        ec_subm (l1, point->x, t1, ctx);
  ------------------
  |  | 1224|  8.12k|#define t1 (ctx->t.scratch[0])
  ------------------
 1247|  8.12k|          ec_mulm (l1, l1, mpi_const (MPI_C_THREE), ctx);
  ------------------
  |  | 1227|  8.12k|#define l1 (ctx->t.scratch[3])
  ------------------
                        ec_mulm (l1, l1, mpi_const (MPI_C_THREE), ctx);
  ------------------
  |  | 1227|  8.12k|#define l1 (ctx->t.scratch[3])
  ------------------
                        ec_mulm (l1, l1, mpi_const (MPI_C_THREE), ctx);
  ------------------
  |  |  120|  8.12k|#define mpi_const(n)          _gcry_mpi_const ((n))
  ------------------
 1248|  8.12k|          ec_addm (t2, point->x, t1, ctx);
  ------------------
  |  | 1225|  8.12k|#define t2 (ctx->t.scratch[1])
  ------------------
                        ec_addm (t2, point->x, t1, ctx);
  ------------------
  |  | 1224|  8.12k|#define t1 (ctx->t.scratch[0])
  ------------------
 1249|  8.12k|          ec_mulm (l1, l1, t2, ctx);
  ------------------
  |  | 1227|  8.12k|#define l1 (ctx->t.scratch[3])
  ------------------
                        ec_mulm (l1, l1, t2, ctx);
  ------------------
  |  | 1227|  8.12k|#define l1 (ctx->t.scratch[3])
  ------------------
                        ec_mulm (l1, l1, t2, ctx);
  ------------------
  |  | 1225|  8.12k|#define t2 (ctx->t.scratch[1])
  ------------------
 1250|  8.12k|        }
 1251|      0|      else /* Standard case. */
 1252|      0|        {
 1253|       |          /* L1 = 3X^2 + aZ^4 */
 1254|       |          /*                          T1: used for aZ^4. */
 1255|      0|          ec_pow2 (l1, point->x, ctx);
  ------------------
  |  | 1227|      0|#define l1 (ctx->t.scratch[3])
  ------------------
 1256|      0|          ec_mulm (l1, l1, mpi_const (MPI_C_THREE), ctx);
  ------------------
  |  | 1227|      0|#define l1 (ctx->t.scratch[3])
  ------------------
                        ec_mulm (l1, l1, mpi_const (MPI_C_THREE), ctx);
  ------------------
  |  | 1227|      0|#define l1 (ctx->t.scratch[3])
  ------------------
                        ec_mulm (l1, l1, mpi_const (MPI_C_THREE), ctx);
  ------------------
  |  |  120|      0|#define mpi_const(n)          _gcry_mpi_const ((n))
  ------------------
 1257|      0|          ec_powm (t1, point->z, mpi_const (MPI_C_FOUR), ctx);
  ------------------
  |  | 1224|      0|#define t1 (ctx->t.scratch[0])
  ------------------
                        ec_powm (t1, point->z, mpi_const (MPI_C_FOUR), ctx);
  ------------------
  |  |  120|      0|#define mpi_const(n)          _gcry_mpi_const ((n))
  ------------------
 1258|      0|          ec_mulm (t1, t1, ctx->a, ctx);
  ------------------
  |  | 1224|      0|#define t1 (ctx->t.scratch[0])
  ------------------
                        ec_mulm (t1, t1, ctx->a, ctx);
  ------------------
  |  | 1224|      0|#define t1 (ctx->t.scratch[0])
  ------------------
 1259|      0|          ec_addm (l1, l1, t1, ctx);
  ------------------
  |  | 1227|      0|#define l1 (ctx->t.scratch[3])
  ------------------
                        ec_addm (l1, l1, t1, ctx);
  ------------------
  |  | 1227|      0|#define l1 (ctx->t.scratch[3])
  ------------------
                        ec_addm (l1, l1, t1, ctx);
  ------------------
  |  | 1224|      0|#define t1 (ctx->t.scratch[0])
  ------------------
 1260|      0|        }
 1261|       |      /* Z3 = 2YZ */
 1262|  8.12k|      ec_mulm (z3, point->y, point->z, ctx);
  ------------------
  |  | 1223|  8.12k|#define z3 (result->z)
  ------------------
 1263|  8.12k|      ec_mul2 (z3, z3, ctx);
  ------------------
  |  | 1223|  8.12k|#define z3 (result->z)
  ------------------
                    ec_mul2 (z3, z3, ctx);
  ------------------
  |  | 1223|  8.12k|#define z3 (result->z)
  ------------------
 1264|       |
 1265|       |      /* L2 = 4XY^2 */
 1266|       |      /*                              T2: used for Y2; required later. */
 1267|  8.12k|      ec_pow2 (t2, point->y, ctx);
  ------------------
  |  | 1225|  8.12k|#define t2 (ctx->t.scratch[1])
  ------------------
 1268|  8.12k|      ec_mulm (l2, t2, point->x, ctx);
  ------------------
  |  | 1228|  8.12k|#define l2 (ctx->t.scratch[4])
  ------------------
                    ec_mulm (l2, t2, point->x, ctx);
  ------------------
  |  | 1225|  8.12k|#define t2 (ctx->t.scratch[1])
  ------------------
 1269|  8.12k|      ec_mulm (l2, l2, mpi_const (MPI_C_FOUR), ctx);
  ------------------
  |  | 1228|  8.12k|#define l2 (ctx->t.scratch[4])
  ------------------
                    ec_mulm (l2, l2, mpi_const (MPI_C_FOUR), ctx);
  ------------------
  |  | 1228|  8.12k|#define l2 (ctx->t.scratch[4])
  ------------------
                    ec_mulm (l2, l2, mpi_const (MPI_C_FOUR), ctx);
  ------------------
  |  |  120|  8.12k|#define mpi_const(n)          _gcry_mpi_const ((n))
  ------------------
 1270|       |
 1271|       |      /* X3 = L1^2 - 2L2 */
 1272|       |      /*                              T1: used for L2^2. */
 1273|  8.12k|      ec_pow2 (x3, l1, ctx);
  ------------------
  |  | 1221|  8.12k|#define x3 (result->x)
  ------------------
                    ec_pow2 (x3, l1, ctx);
  ------------------
  |  | 1227|  8.12k|#define l1 (ctx->t.scratch[3])
  ------------------
 1274|  8.12k|      ec_mul2 (t1, l2, ctx);
  ------------------
  |  | 1224|  8.12k|#define t1 (ctx->t.scratch[0])
  ------------------
                    ec_mul2 (t1, l2, ctx);
  ------------------
  |  | 1228|  8.12k|#define l2 (ctx->t.scratch[4])
  ------------------
 1275|  8.12k|      ec_subm (x3, x3, t1, ctx);
  ------------------
  |  | 1221|  8.12k|#define x3 (result->x)
  ------------------
                    ec_subm (x3, x3, t1, ctx);
  ------------------
  |  | 1221|  8.12k|#define x3 (result->x)
  ------------------
                    ec_subm (x3, x3, t1, ctx);
  ------------------
  |  | 1224|  8.12k|#define t1 (ctx->t.scratch[0])
  ------------------
 1276|       |
 1277|       |      /* L3 = 8Y^4 */
 1278|       |      /*                              T2: taken from above. */
 1279|  8.12k|      ec_pow2 (t2, t2, ctx);
  ------------------
  |  | 1225|  8.12k|#define t2 (ctx->t.scratch[1])
  ------------------
                    ec_pow2 (t2, t2, ctx);
  ------------------
  |  | 1225|  8.12k|#define t2 (ctx->t.scratch[1])
  ------------------
 1280|  8.12k|      ec_mulm (l3, t2, mpi_const (MPI_C_EIGHT), ctx);
  ------------------
  |  | 1229|  8.12k|#define l3 (ctx->t.scratch[5])
  ------------------
                    ec_mulm (l3, t2, mpi_const (MPI_C_EIGHT), ctx);
  ------------------
  |  | 1225|  8.12k|#define t2 (ctx->t.scratch[1])
  ------------------
                    ec_mulm (l3, t2, mpi_const (MPI_C_EIGHT), ctx);
  ------------------
  |  |  120|  8.12k|#define mpi_const(n)          _gcry_mpi_const ((n))
  ------------------
 1281|       |
 1282|       |      /* Y3 = L1(L2 - X3) - L3 */
 1283|  8.12k|      ec_subm (y3, l2, x3, ctx);
  ------------------
  |  | 1222|  8.12k|#define y3 (result->y)
  ------------------
                    ec_subm (y3, l2, x3, ctx);
  ------------------
  |  | 1228|  8.12k|#define l2 (ctx->t.scratch[4])
  ------------------
                    ec_subm (y3, l2, x3, ctx);
  ------------------
  |  | 1221|  8.12k|#define x3 (result->x)
  ------------------
 1284|  8.12k|      ec_mulm (y3, y3, l1, ctx);
  ------------------
  |  | 1222|  8.12k|#define y3 (result->y)
  ------------------
                    ec_mulm (y3, y3, l1, ctx);
  ------------------
  |  | 1222|  8.12k|#define y3 (result->y)
  ------------------
                    ec_mulm (y3, y3, l1, ctx);
  ------------------
  |  | 1227|  8.12k|#define l1 (ctx->t.scratch[3])
  ------------------
 1285|  8.12k|      ec_subm (y3, y3, l3, ctx);
  ------------------
  |  | 1222|  8.12k|#define y3 (result->y)
  ------------------
                    ec_subm (y3, y3, l3, ctx);
  ------------------
  |  | 1222|  8.12k|#define y3 (result->y)
  ------------------
                    ec_subm (y3, y3, l3, ctx);
  ------------------
  |  | 1229|  8.12k|#define l3 (ctx->t.scratch[5])
  ------------------
 1286|  8.12k|    }
 1287|       |
 1288|  8.12k|#undef x3
 1289|  8.12k|#undef y3
 1290|  8.12k|#undef z3
 1291|  8.12k|#undef t1
 1292|  8.12k|#undef t2
 1293|  8.12k|#undef t3
 1294|  8.12k|#undef l1
 1295|  8.12k|#undef l2
 1296|  8.12k|#undef l3
 1297|  8.12k|}
ec.c:ec_get_a_is_pminus3:
  738|  8.12k|{
  739|  8.12k|  gcry_mpi_t tmp;
  740|       |
  741|  8.12k|  if (!ec->t.valid.a_is_pminus3)
  ------------------
  |  Branch (741:7): [True: 16, False: 8.11k]
  ------------------
  742|     16|    {
  743|     16|      ec->t.valid.a_is_pminus3 = 1;
  744|     16|      tmp = mpi_alloc_like (ec->p);
  ------------------
  |  |  117|     16|#define mpi_alloc_like(a)     _gcry_mpi_alloc_like((a))
  ------------------
  745|     16|      mpi_sub_ui (tmp, ec->p, 3);
  ------------------
  |  |  518|     16|#define mpi_sub_ui(w,u,v)      _gcry_mpi_sub_ui ((w),(u),(v))
  ------------------
  746|     16|      ec->t.a_is_pminus3 = !mpi_cmp (ec->a, tmp);
  ------------------
  |  |  510|     16|#define mpi_cmp( u, v )        _gcry_mpi_cmp( (u), (v) )
  ------------------
  747|     16|      mpi_free (tmp);
  ------------------
  |  |   99|     16|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  748|     16|    }
  749|       |
  750|  8.12k|  return ec->t.a_is_pminus3;
  751|  8.12k|}
ec.c:add_points_weierstrass:
 1409|  2.84k|{
 1410|  2.84k|#define x1 (p1->x    )
 1411|  2.84k|#define y1 (p1->y    )
 1412|  2.84k|#define z1 (p1->z    )
 1413|  2.84k|#define x2 (p2->x    )
 1414|  2.84k|#define y2 (p2->y    )
 1415|  2.84k|#define z2 (p2->z    )
 1416|  2.84k|#define x3 (result->x)
 1417|  2.84k|#define y3 (result->y)
 1418|  2.84k|#define z3 (result->z)
 1419|  2.84k|#define l1 (ctx->t.scratch[0])
 1420|  2.84k|#define l2 (ctx->t.scratch[1])
 1421|  2.84k|#define l3 (ctx->t.scratch[2])
 1422|  2.84k|#define l4 (ctx->t.scratch[3])
 1423|  2.84k|#define l5 (ctx->t.scratch[4])
 1424|  2.84k|#define l6 (ctx->t.scratch[5])
 1425|  2.84k|#define l7 (ctx->t.scratch[6])
 1426|  2.84k|#define l8 (ctx->t.scratch[7])
 1427|  2.84k|#define l9 (ctx->t.scratch[8])
 1428|  2.84k|#define t1 (ctx->t.scratch[9])
 1429|  2.84k|#define t2 (ctx->t.scratch[10])
 1430|       |
 1431|  2.84k|  if ( (!mpi_cmp (x1, x2)) && (!mpi_cmp (y1, y2)) && (!mpi_cmp (z1, z2)) )
  ------------------
  |  |  510|  2.84k|#define mpi_cmp( u, v )        _gcry_mpi_cmp( (u), (v) )
  ------------------
                if ( (!mpi_cmp (x1, x2)) && (!mpi_cmp (y1, y2)) && (!mpi_cmp (z1, z2)) )
  ------------------
  |  |  510|      0|#define mpi_cmp( u, v )        _gcry_mpi_cmp( (u), (v) )
  ------------------
                if ( (!mpi_cmp (x1, x2)) && (!mpi_cmp (y1, y2)) && (!mpi_cmp (z1, z2)) )
  ------------------
  |  |  510|      0|#define mpi_cmp( u, v )        _gcry_mpi_cmp( (u), (v) )
  ------------------
  |  Branch (1431:8): [True: 0, False: 2.84k]
  |  Branch (1431:31): [True: 0, False: 0]
  |  Branch (1431:54): [True: 0, False: 0]
  ------------------
 1432|      0|    {
 1433|       |      /* Same point; need to call the duplicate function.  */
 1434|      0|      _gcry_mpi_ec_dup_point (result, p1, ctx);
 1435|      0|    }
 1436|  2.84k|  else if (!mpi_cmp_ui (z1, 0))
  ------------------
  |  |  512|  2.84k|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
  |  Branch (1436:12): [True: 0, False: 2.84k]
  ------------------
 1437|      0|    {
 1438|       |      /* P1 is at infinity.  */
 1439|      0|      mpi_set (x3, p2->x);
  ------------------
  |  |  504|      0|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
 1440|      0|      mpi_set (y3, p2->y);
  ------------------
  |  |  504|      0|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
 1441|      0|      mpi_set (z3, p2->z);
  ------------------
  |  |  504|      0|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
 1442|      0|    }
 1443|  2.84k|  else if (!mpi_cmp_ui (z2, 0))
  ------------------
  |  |  512|  2.84k|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
  |  Branch (1443:12): [True: 0, False: 2.84k]
  ------------------
 1444|      0|    {
 1445|       |      /* P2 is at infinity.  */
 1446|      0|      mpi_set (x3, p1->x);
  ------------------
  |  |  504|      0|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
 1447|      0|      mpi_set (y3, p1->y);
  ------------------
  |  |  504|      0|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
 1448|      0|      mpi_set (z3, p1->z);
  ------------------
  |  |  504|      0|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
 1449|      0|    }
 1450|  2.84k|  else
 1451|  2.84k|    {
 1452|  2.84k|      int z1_is_one = !mpi_cmp_ui (z1, 1);
  ------------------
  |  |  512|  2.84k|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
 1453|  2.84k|      int z2_is_one = !mpi_cmp_ui (z2, 1);
  ------------------
  |  |  512|  2.84k|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
 1454|       |
 1455|       |      /* l1 = x1 z2^2  */
 1456|       |      /* l2 = x2 z1^2  */
 1457|  2.84k|      if (z2_is_one)
  ------------------
  |  Branch (1457:11): [True: 2.83k, False: 16]
  ------------------
 1458|  2.83k|        mpi_set (l1, x1);
  ------------------
  |  |  504|  2.83k|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
 1459|     16|      else
 1460|     16|        {
 1461|     16|          ec_pow2 (l1, z2, ctx);
  ------------------
  |  | 1419|     16|#define l1 (ctx->t.scratch[0])
  ------------------
                        ec_pow2 (l1, z2, ctx);
  ------------------
  |  | 1415|     16|#define z2 (p2->z    )
  ------------------
 1462|     16|          ec_mulm (l1, l1, x1, ctx);
  ------------------
  |  | 1419|     16|#define l1 (ctx->t.scratch[0])
  ------------------
                        ec_mulm (l1, l1, x1, ctx);
  ------------------
  |  | 1419|     16|#define l1 (ctx->t.scratch[0])
  ------------------
                        ec_mulm (l1, l1, x1, ctx);
  ------------------
  |  | 1410|     16|#define x1 (p1->x    )
  ------------------
 1463|     16|        }
 1464|  2.84k|      if (z1_is_one)
  ------------------
  |  Branch (1464:11): [True: 0, False: 2.84k]
  ------------------
 1465|      0|        mpi_set (l2, x2);
  ------------------
  |  |  504|      0|#define mpi_set( w, u)         _gcry_mpi_set( (w), (u) )
  ------------------
 1466|  2.84k|      else
 1467|  2.84k|        {
 1468|  2.84k|          ec_pow2 (l2, z1, ctx);
  ------------------
  |  | 1420|  2.84k|#define l2 (ctx->t.scratch[1])
  ------------------
                        ec_pow2 (l2, z1, ctx);
  ------------------
  |  | 1412|  2.84k|#define z1 (p1->z    )
  ------------------
 1469|  2.84k|          ec_mulm (l2, l2, x2, ctx);
  ------------------
  |  | 1420|  2.84k|#define l2 (ctx->t.scratch[1])
  ------------------
                        ec_mulm (l2, l2, x2, ctx);
  ------------------
  |  | 1420|  2.84k|#define l2 (ctx->t.scratch[1])
  ------------------
                        ec_mulm (l2, l2, x2, ctx);
  ------------------
  |  | 1413|  2.84k|#define x2 (p2->x    )
  ------------------
 1470|  2.84k|        }
 1471|       |      /* l3 = l1 - l2 */
 1472|  2.84k|      ec_subm (l3, l1, l2, ctx);
  ------------------
  |  | 1421|  2.84k|#define l3 (ctx->t.scratch[2])
  ------------------
                    ec_subm (l3, l1, l2, ctx);
  ------------------
  |  | 1419|  2.84k|#define l1 (ctx->t.scratch[0])
  ------------------
                    ec_subm (l3, l1, l2, ctx);
  ------------------
  |  | 1420|  2.84k|#define l2 (ctx->t.scratch[1])
  ------------------
 1473|       |      /* l4 = y1 z2^3  */
 1474|  2.84k|      ec_powm (l4, z2, mpi_const (MPI_C_THREE), ctx);
  ------------------
  |  | 1422|  2.84k|#define l4 (ctx->t.scratch[3])
  ------------------
                    ec_powm (l4, z2, mpi_const (MPI_C_THREE), ctx);
  ------------------
  |  | 1415|  2.84k|#define z2 (p2->z    )
  ------------------
                    ec_powm (l4, z2, mpi_const (MPI_C_THREE), ctx);
  ------------------
  |  |  120|  2.84k|#define mpi_const(n)          _gcry_mpi_const ((n))
  ------------------
 1475|  2.84k|      ec_mulm (l4, l4, y1, ctx);
  ------------------
  |  | 1422|  2.84k|#define l4 (ctx->t.scratch[3])
  ------------------
                    ec_mulm (l4, l4, y1, ctx);
  ------------------
  |  | 1422|  2.84k|#define l4 (ctx->t.scratch[3])
  ------------------
                    ec_mulm (l4, l4, y1, ctx);
  ------------------
  |  | 1411|  2.84k|#define y1 (p1->y    )
  ------------------
 1476|       |      /* l5 = y2 z1^3  */
 1477|  2.84k|      ec_powm (l5, z1, mpi_const (MPI_C_THREE), ctx);
  ------------------
  |  | 1423|  2.84k|#define l5 (ctx->t.scratch[4])
  ------------------
                    ec_powm (l5, z1, mpi_const (MPI_C_THREE), ctx);
  ------------------
  |  | 1412|  2.84k|#define z1 (p1->z    )
  ------------------
                    ec_powm (l5, z1, mpi_const (MPI_C_THREE), ctx);
  ------------------
  |  |  120|  2.84k|#define mpi_const(n)          _gcry_mpi_const ((n))
  ------------------
 1478|  2.84k|      ec_mulm (l5, l5, y2, ctx);
  ------------------
  |  | 1423|  2.84k|#define l5 (ctx->t.scratch[4])
  ------------------
                    ec_mulm (l5, l5, y2, ctx);
  ------------------
  |  | 1423|  2.84k|#define l5 (ctx->t.scratch[4])
  ------------------
                    ec_mulm (l5, l5, y2, ctx);
  ------------------
  |  | 1414|  2.84k|#define y2 (p2->y    )
  ------------------
 1479|       |      /* l6 = l4 - l5  */
 1480|  2.84k|      ec_subm (l6, l4, l5, ctx);
  ------------------
  |  | 1424|  2.84k|#define l6 (ctx->t.scratch[5])
  ------------------
                    ec_subm (l6, l4, l5, ctx);
  ------------------
  |  | 1422|  2.84k|#define l4 (ctx->t.scratch[3])
  ------------------
                    ec_subm (l6, l4, l5, ctx);
  ------------------
  |  | 1423|  2.84k|#define l5 (ctx->t.scratch[4])
  ------------------
 1481|       |
 1482|  2.84k|      if (!mpi_cmp_ui (l3, 0))
  ------------------
  |  |  512|  2.84k|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
  |  Branch (1482:11): [True: 0, False: 2.84k]
  ------------------
 1483|      0|        {
 1484|      0|          if (!mpi_cmp_ui (l6, 0))
  ------------------
  |  |  512|      0|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
  |  Branch (1484:15): [True: 0, False: 0]
  ------------------
 1485|      0|            {
 1486|       |              /* P1 and P2 are the same - use duplicate function.  */
 1487|      0|              _gcry_mpi_ec_dup_point (result, p1, ctx);
 1488|      0|            }
 1489|      0|          else
 1490|      0|            {
 1491|       |              /* P1 is the inverse of P2.  */
 1492|      0|              mpi_set_ui (x3, 1);
  ------------------
  |  |  505|      0|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
 1493|      0|              mpi_set_ui (y3, 1);
  ------------------
  |  |  505|      0|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
 1494|      0|              mpi_set_ui (z3, 0);
  ------------------
  |  |  505|      0|#define mpi_set_ui( w, u)      _gcry_mpi_set_ui( (w), (u) )
  ------------------
 1495|      0|            }
 1496|      0|        }
 1497|  2.84k|      else
 1498|  2.84k|        {
 1499|       |          /* l7 = l1 + l2  */
 1500|  2.84k|          ec_addm (l7, l1, l2, ctx);
  ------------------
  |  | 1425|  2.84k|#define l7 (ctx->t.scratch[6])
  ------------------
                        ec_addm (l7, l1, l2, ctx);
  ------------------
  |  | 1419|  2.84k|#define l1 (ctx->t.scratch[0])
  ------------------
                        ec_addm (l7, l1, l2, ctx);
  ------------------
  |  | 1420|  2.84k|#define l2 (ctx->t.scratch[1])
  ------------------
 1501|       |          /* l8 = l4 + l5  */
 1502|  2.84k|          ec_addm (l8, l4, l5, ctx);
  ------------------
  |  | 1426|  2.84k|#define l8 (ctx->t.scratch[7])
  ------------------
                        ec_addm (l8, l4, l5, ctx);
  ------------------
  |  | 1422|  2.84k|#define l4 (ctx->t.scratch[3])
  ------------------
                        ec_addm (l8, l4, l5, ctx);
  ------------------
  |  | 1423|  2.84k|#define l5 (ctx->t.scratch[4])
  ------------------
 1503|       |          /* z3 = z1 z2 l3  */
 1504|  2.84k|          ec_mulm (z3, z1, z2, ctx);
  ------------------
  |  | 1418|  2.84k|#define z3 (result->z)
  ------------------
                        ec_mulm (z3, z1, z2, ctx);
  ------------------
  |  | 1412|  2.84k|#define z1 (p1->z    )
  ------------------
                        ec_mulm (z3, z1, z2, ctx);
  ------------------
  |  | 1415|  2.84k|#define z2 (p2->z    )
  ------------------
 1505|  2.84k|          ec_mulm (z3, z3, l3, ctx);
  ------------------
  |  | 1418|  2.84k|#define z3 (result->z)
  ------------------
                        ec_mulm (z3, z3, l3, ctx);
  ------------------
  |  | 1418|  2.84k|#define z3 (result->z)
  ------------------
                        ec_mulm (z3, z3, l3, ctx);
  ------------------
  |  | 1421|  2.84k|#define l3 (ctx->t.scratch[2])
  ------------------
 1506|       |          /* x3 = l6^2 - l7 l3^2  */
 1507|  2.84k|          ec_pow2 (t1, l6, ctx);
  ------------------
  |  | 1428|  2.84k|#define t1 (ctx->t.scratch[9])
  ------------------
                        ec_pow2 (t1, l6, ctx);
  ------------------
  |  | 1424|  2.84k|#define l6 (ctx->t.scratch[5])
  ------------------
 1508|  2.84k|          ec_pow2 (t2, l3, ctx);
  ------------------
  |  | 1429|  2.84k|#define t2 (ctx->t.scratch[10])
  ------------------
                        ec_pow2 (t2, l3, ctx);
  ------------------
  |  | 1421|  2.84k|#define l3 (ctx->t.scratch[2])
  ------------------
 1509|  2.84k|          ec_mulm (t2, t2, l7, ctx);
  ------------------
  |  | 1429|  2.84k|#define t2 (ctx->t.scratch[10])
  ------------------
                        ec_mulm (t2, t2, l7, ctx);
  ------------------
  |  | 1429|  2.84k|#define t2 (ctx->t.scratch[10])
  ------------------
                        ec_mulm (t2, t2, l7, ctx);
  ------------------
  |  | 1425|  2.84k|#define l7 (ctx->t.scratch[6])
  ------------------
 1510|  2.84k|          ec_subm (x3, t1, t2, ctx);
  ------------------
  |  | 1416|  2.84k|#define x3 (result->x)
  ------------------
                        ec_subm (x3, t1, t2, ctx);
  ------------------
  |  | 1428|  2.84k|#define t1 (ctx->t.scratch[9])
  ------------------
                        ec_subm (x3, t1, t2, ctx);
  ------------------
  |  | 1429|  2.84k|#define t2 (ctx->t.scratch[10])
  ------------------
 1511|       |          /* l9 = l7 l3^2 - 2 x3  */
 1512|  2.84k|          ec_mul2 (t1, x3, ctx);
  ------------------
  |  | 1428|  2.84k|#define t1 (ctx->t.scratch[9])
  ------------------
                        ec_mul2 (t1, x3, ctx);
  ------------------
  |  | 1416|  2.84k|#define x3 (result->x)
  ------------------
 1513|  2.84k|          ec_subm (l9, t2, t1, ctx);
  ------------------
  |  | 1427|  2.84k|#define l9 (ctx->t.scratch[8])
  ------------------
                        ec_subm (l9, t2, t1, ctx);
  ------------------
  |  | 1429|  2.84k|#define t2 (ctx->t.scratch[10])
  ------------------
                        ec_subm (l9, t2, t1, ctx);
  ------------------
  |  | 1428|  2.84k|#define t1 (ctx->t.scratch[9])
  ------------------
 1514|       |          /* y3 = (l9 l6 - l8 l3^3)/2  */
 1515|  2.84k|          ec_mulm (l9, l9, l6, ctx);
  ------------------
  |  | 1427|  2.84k|#define l9 (ctx->t.scratch[8])
  ------------------
                        ec_mulm (l9, l9, l6, ctx);
  ------------------
  |  | 1427|  2.84k|#define l9 (ctx->t.scratch[8])
  ------------------
                        ec_mulm (l9, l9, l6, ctx);
  ------------------
  |  | 1424|  2.84k|#define l6 (ctx->t.scratch[5])
  ------------------
 1516|  2.84k|          ec_powm (t1, l3, mpi_const (MPI_C_THREE), ctx); /* fixme: Use saved value*/
  ------------------
  |  | 1428|  2.84k|#define t1 (ctx->t.scratch[9])
  ------------------
                        ec_powm (t1, l3, mpi_const (MPI_C_THREE), ctx); /* fixme: Use saved value*/
  ------------------
  |  | 1421|  2.84k|#define l3 (ctx->t.scratch[2])
  ------------------
                        ec_powm (t1, l3, mpi_const (MPI_C_THREE), ctx); /* fixme: Use saved value*/
  ------------------
  |  |  120|  2.84k|#define mpi_const(n)          _gcry_mpi_const ((n))
  ------------------
 1517|  2.84k|          ec_mulm (t1, t1, l8, ctx);
  ------------------
  |  | 1428|  2.84k|#define t1 (ctx->t.scratch[9])
  ------------------
                        ec_mulm (t1, t1, l8, ctx);
  ------------------
  |  | 1428|  2.84k|#define t1 (ctx->t.scratch[9])
  ------------------
                        ec_mulm (t1, t1, l8, ctx);
  ------------------
  |  | 1426|  2.84k|#define l8 (ctx->t.scratch[7])
  ------------------
 1518|  2.84k|          ec_subm (y3, l9, t1, ctx);
  ------------------
  |  | 1417|  2.84k|#define y3 (result->y)
  ------------------
                        ec_subm (y3, l9, t1, ctx);
  ------------------
  |  | 1427|  2.84k|#define l9 (ctx->t.scratch[8])
  ------------------
                        ec_subm (y3, l9, t1, ctx);
  ------------------
  |  | 1428|  2.84k|#define t1 (ctx->t.scratch[9])
  ------------------
 1519|  2.84k|          ec_mulm (y3, y3, ec_get_two_inv_p (ctx), ctx);
  ------------------
  |  | 1417|  2.84k|#define y3 (result->y)
  ------------------
                        ec_mulm (y3, y3, ec_get_two_inv_p (ctx), ctx);
  ------------------
  |  | 1417|  2.84k|#define y3 (result->y)
  ------------------
 1520|  2.84k|        }
 1521|  2.84k|    }
 1522|       |
 1523|  2.84k|#undef x1
 1524|  2.84k|#undef y1
 1525|  2.84k|#undef z1
 1526|  2.84k|#undef x2
 1527|  2.84k|#undef y2
 1528|  2.84k|#undef z2
 1529|  2.84k|#undef x3
 1530|  2.84k|#undef y3
 1531|  2.84k|#undef z3
 1532|  2.84k|#undef l1
 1533|  2.84k|#undef l2
 1534|  2.84k|#undef l3
 1535|  2.84k|#undef l4
 1536|  2.84k|#undef l5
 1537|  2.84k|#undef l6
 1538|  2.84k|#undef l7
 1539|  2.84k|#undef l8
 1540|  2.84k|#undef l9
 1541|  2.84k|#undef t1
 1542|  2.84k|#undef t2
 1543|  2.84k|}
ec.c:ec_get_two_inv_p:
  757|  2.84k|{
  758|  2.84k|  if (!ec->t.valid.two_inv_p)
  ------------------
  |  Branch (758:7): [True: 16, False: 2.83k]
  ------------------
  759|     16|    {
  760|     16|      ec->t.valid.two_inv_p = 1;
  761|     16|      if (!ec->t.two_inv_p)
  ------------------
  |  Branch (761:11): [True: 16, False: 0]
  ------------------
  762|     16|        ec->t.two_inv_p = mpi_alloc (0);
  ------------------
  |  |   97|     16|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  763|     16|      ec_invm (ec->t.two_inv_p, mpi_const (MPI_C_TWO), ec);
  ------------------
  |  |  120|     16|#define mpi_const(n)          _gcry_mpi_const ((n))
  ------------------
  764|     16|    }
  765|  2.84k|  return ec->t.two_inv_p;
  766|  2.84k|}
ec.c:ec_subm:
  293|  46.7k|{
  294|  46.7k|  mpi_sub (w, u, v);
  ------------------
  |  |  519|  46.7k|#define mpi_sub(w,u,v)         _gcry_mpi_sub ((w),(u),(v))
  ------------------
  295|  70.8k|  while (w->sign)
  ------------------
  |  Branch (295:10): [True: 24.0k, False: 46.7k]
  ------------------
  296|  24.0k|    mpi_add (w, w, ec->p);
  ------------------
  |  |  516|  24.0k|#define mpi_add(w,u,v)         _gcry_mpi_add ((w),(u),(v))
  ------------------
  297|       |  /*ctx->mod (w, ec);*/
  298|  46.7k|}
ec.c:ec_pow2:
  329|  41.0k|{
  330|       |  /* Using mpi_mul is slightly faster (at least on amd64).  */
  331|       |  /* mpi_powm (w, b, mpi_const (MPI_C_TWO), ctx->p); */
  332|  41.0k|  ec_mulm (w, b, b, ctx);
  333|  41.0k|}
ec.c:ec_pow3:
  341|     16|{
  342|     16|  mpi_powm (w, b, mpi_const (MPI_C_THREE), ctx->p);
  ------------------
  |  |  525|     16|#define mpi_powm(w,b,e,m)      _gcry_mpi_powm ( (w), (b), (e), (m) )
  ------------------
  343|     16|}
ec.c:ec_addm:
  286|  13.8k|{
  287|  13.8k|  mpi_add (w, u, v);
  ------------------
  |  |  516|  13.8k|#define mpi_add(w,u,v)         _gcry_mpi_add ((w),(u),(v))
  ------------------
  288|  13.8k|  ctx->mod (w, ctx);
  289|  13.8k|}
ec.c:ec_powm:
  318|  8.54k|{
  319|  8.54k|  mpi_powm (w, b, e, ctx->p);
  ------------------
  |  |  525|  8.54k|#define mpi_powm(w,b,e,m)      _gcry_mpi_powm ( (w), (b), (e), (m) )
  ------------------
  320|       |  /* _gcry_mpi_abs (w); */
  321|  8.54k|}

_gcry_mpi_add:
   89|  84.7k|{
   90|  84.7k|    mpi_ptr_t wp, up, vp;
   91|  84.7k|    mpi_size_t usize, vsize, wsize;
   92|  84.7k|    int usign, vsign, wsign;
   93|       |
   94|  84.7k|    if( u->nlimbs < v->nlimbs ) { /* Swap U and V. */
  ------------------
  |  Branch (94:9): [True: 0, False: 84.7k]
  ------------------
   95|      0|	usize = v->nlimbs;
   96|      0|	usign = v->sign;
   97|      0|	vsize = u->nlimbs;
   98|      0|	vsign = u->sign;
   99|      0|	wsize = usize + 1;
  100|      0|	RESIZE_IF_NEEDED(w, wsize);
  ------------------
  |  |   78|      0|    do {			   \
  |  |   79|      0|	if( (a)->alloced < (b) )   \
  |  |  ------------------
  |  |  |  Branch (79:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   80|      0|	    mpi_resize((a), (b));  \
  |  |  ------------------
  |  |  |  |  100|      0|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  |  |  ------------------
  |  |   81|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (81:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  101|       |	/* These must be after realloc (u or v may be the same as w).  */
  102|      0|	up    = v->d;
  103|      0|	vp    = u->d;
  104|      0|    }
  105|  84.7k|    else {
  106|  84.7k|	usize = u->nlimbs;
  107|  84.7k|	usign = u->sign;
  108|  84.7k|	vsize = v->nlimbs;
  109|  84.7k|	vsign = v->sign;
  110|  84.7k|	wsize = usize + 1;
  111|  84.7k|	RESIZE_IF_NEEDED(w, wsize);
  ------------------
  |  |   78|  84.7k|    do {			   \
  |  |   79|  84.7k|	if( (a)->alloced < (b) )   \
  |  |  ------------------
  |  |  |  Branch (79:6): [True: 192, False: 84.5k]
  |  |  ------------------
  |  |   80|  84.7k|	    mpi_resize((a), (b));  \
  |  |  ------------------
  |  |  |  |  100|    192|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  |  |  ------------------
  |  |   81|  84.7k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (81:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  112|       |	/* These must be after realloc (u or v may be the same as w).  */
  113|  84.7k|	up    = u->d;
  114|  84.7k|	vp    = v->d;
  115|  84.7k|    }
  116|  84.7k|    wp = w->d;
  117|  84.7k|    wsign = 0;
  118|       |
  119|  84.7k|    if( !vsize ) {  /* simple */
  ------------------
  |  Branch (119:9): [True: 0, False: 84.7k]
  ------------------
  120|      0|	MPN_COPY(wp, up, usize );
  ------------------
  |  |   90|      0|    do {				\
  |  |   91|      0|	mpi_size_t _i;			\
  |  |   92|      0|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 0, False: 0]
  |  |  ------------------
  |  |   93|      0|	    (d)[_i] = (s)[_i];		\
  |  |   94|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  121|      0|	wsize = usize;
  122|      0|	wsign = usign;
  123|      0|    }
  124|  84.7k|    else if( usign != vsign ) { /* different sign */
  ------------------
  |  Branch (124:14): [True: 70.8k, False: 13.8k]
  ------------------
  125|       |	/* This test is right since USIZE >= VSIZE */
  126|  70.8k|	if( usize != vsize ) {
  ------------------
  |  Branch (126:6): [True: 32, False: 70.8k]
  ------------------
  127|     32|	    _gcry_mpih_sub(wp, up, usize, vp, vsize);
  128|     32|	    wsize = usize;
  129|     32|	    MPN_NORMALIZE(wp, wsize);
  ------------------
  |  |  119|     32|    do {		       \
  |  |  120|     32|	while( (n) > 0 ) {     \
  |  |  ------------------
  |  |  |  Branch (120:9): [True: 32, False: 0]
  |  |  ------------------
  |  |  121|     32|	    if( (d)[(n)-1] ) \
  |  |  ------------------
  |  |  |  Branch (121:10): [True: 32, False: 0]
  |  |  ------------------
  |  |  122|     32|		break;	       \
  |  |  123|     32|	    (n)--;	       \
  |  |  124|      0|	}		       \
  |  |  125|     32|    } while(0)
  |  |  ------------------
  |  |  |  Branch (125:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  130|     32|	    wsign = usign;
  131|     32|	}
  132|  70.8k|	else if( _gcry_mpih_cmp(up, vp, usize) < 0 ) {
  ------------------
  |  Branch (132:11): [True: 48.1k, False: 22.6k]
  ------------------
  133|  48.1k|	    _gcry_mpih_sub_n(wp, vp, up, usize);
  134|  48.1k|	    wsize = usize;
  135|  48.1k|	    MPN_NORMALIZE(wp, wsize);
  ------------------
  |  |  119|  48.1k|    do {		       \
  |  |  120|  48.1k|	while( (n) > 0 ) {     \
  |  |  ------------------
  |  |  |  Branch (120:9): [True: 48.1k, False: 0]
  |  |  ------------------
  |  |  121|  48.1k|	    if( (d)[(n)-1] ) \
  |  |  ------------------
  |  |  |  Branch (121:10): [True: 48.1k, False: 0]
  |  |  ------------------
  |  |  122|  48.1k|		break;	       \
  |  |  123|  48.1k|	    (n)--;	       \
  |  |  124|      0|	}		       \
  |  |  125|  48.1k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (125:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  136|  48.1k|	    if( !usign )
  ------------------
  |  Branch (136:10): [True: 24.0k, False: 24.0k]
  ------------------
  137|  24.0k|		wsign = 1;
  138|  48.1k|	}
  139|  22.6k|	else {
  140|  22.6k|	    _gcry_mpih_sub_n(wp, up, vp, usize);
  141|  22.6k|	    wsize = usize;
  142|  22.6k|	    MPN_NORMALIZE(wp, wsize);
  ------------------
  |  |  119|  22.6k|    do {		       \
  |  |  120|  22.6k|	while( (n) > 0 ) {     \
  |  |  ------------------
  |  |  |  Branch (120:9): [True: 22.6k, False: 0]
  |  |  ------------------
  |  |  121|  22.6k|	    if( (d)[(n)-1] ) \
  |  |  ------------------
  |  |  |  Branch (121:10): [True: 22.6k, False: 0]
  |  |  ------------------
  |  |  122|  22.6k|		break;	       \
  |  |  123|  22.6k|	    (n)--;	       \
  |  |  124|      0|	}		       \
  |  |  125|  22.6k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (125:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  143|  22.6k|	    if( usign )
  ------------------
  |  Branch (143:10): [True: 0, False: 22.6k]
  ------------------
  144|      0|		wsign = 1;
  145|  22.6k|	}
  146|  70.8k|    }
  147|  13.8k|    else { /* U and V have same sign. Add them. */
  148|  13.8k|	mpi_limb_t cy = _gcry_mpih_add(wp, up, usize, vp, vsize);
  149|  13.8k|	wp[usize] = cy;
  150|  13.8k|	wsize = usize + cy;
  151|  13.8k|	if( usign )
  ------------------
  |  Branch (151:6): [True: 0, False: 13.8k]
  ------------------
  152|      0|	    wsign = 1;
  153|  13.8k|    }
  154|       |
  155|  84.7k|    w->nlimbs = wsize;
  156|  84.7k|    w->sign = wsign;
  157|  84.7k|}
_gcry_mpi_sub_ui:
  166|     16|{
  167|     16|    mpi_ptr_t wp, up;
  168|     16|    mpi_size_t usize, wsize;
  169|     16|    int usign, wsign;
  170|       |
  171|     16|    usize = u->nlimbs;
  172|     16|    usign = u->sign;
  173|     16|    wsign = 0;
  174|       |
  175|       |    /* If not space for W (and possible carry), increase space.  */
  176|     16|    wsize = usize + 1;
  177|     16|    if( w->alloced < wsize )
  ------------------
  |  Branch (177:9): [True: 16, False: 0]
  ------------------
  178|     16|	mpi_resize(w, wsize);
  ------------------
  |  |  100|     16|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  ------------------
  179|       |
  180|       |    /* These must be after realloc (U may be the same as W).  */
  181|     16|    up = u->d;
  182|     16|    wp = w->d;
  183|       |
  184|     16|    if( !usize ) {  /* simple */
  ------------------
  |  Branch (184:9): [True: 0, False: 16]
  ------------------
  185|      0|	wp[0] = v;
  186|      0|	wsize = v? 1:0;
  ------------------
  |  Branch (186:10): [True: 0, False: 0]
  ------------------
  187|      0|	wsign = 1;
  188|      0|    }
  189|     16|    else if( usign ) {	/* mpi and v are negative */
  ------------------
  |  Branch (189:14): [True: 0, False: 16]
  ------------------
  190|      0|	mpi_limb_t cy;
  191|      0|	cy = _gcry_mpih_add_1(wp, up, usize, v);
  192|      0|	wp[usize] = cy;
  193|      0|	wsize = usize + cy;
  194|      0|	wsign = 1;
  195|      0|    }
  196|     16|    else {  /* The signs are different.  Need exact comparison to determine
  197|       |	     * which operand to subtract from which.  */
  198|     16|	if( usize == 1 && up[0] < v ) {
  ------------------
  |  Branch (198:6): [True: 0, False: 16]
  |  Branch (198:20): [True: 0, False: 0]
  ------------------
  199|      0|	    wp[0] = v - up[0];
  200|      0|	    wsize = 1;
  201|      0|	    wsign = 1;
  202|      0|	}
  203|     16|	else {
  204|     16|	    _gcry_mpih_sub_1(wp, up, usize, v);
  205|       |	    /* Size can decrease with at most one limb. */
  206|     16|	    wsize = usize - (wp[usize-1]==0);
  207|     16|	}
  208|     16|    }
  209|       |
  210|     16|    w->nlimbs = wsize;
  211|     16|    w->sign   = wsign;
  212|     16|}
_gcry_mpi_sub:
  216|  46.7k|{
  217|  46.7k|  gcry_mpi_t vv = mpi_copy (v);
  ------------------
  |  |  101|  46.7k|# define mpi_copy(a)	       _gcry_mpi_copy((a))
  ------------------
  218|  46.7k|  vv->sign = ! vv->sign;
  219|  46.7k|  mpi_add (w, u, vv);
  ------------------
  |  |  516|  46.7k|#define mpi_add(w,u,v)         _gcry_mpi_add ((w),(u),(v))
  ------------------
  220|  46.7k|  mpi_free (vv);
  ------------------
  |  |   99|  46.7k|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  221|  46.7k|}

_gcry_mpi_normalize:
   57|  39.1k|{
   58|  39.1k|    if( mpi_is_opaque(a) )
  ------------------
  |  |  114|  39.1k|#define mpi_is_opaque(a)      ((a) && ((a)->flags&4))
  |  |  ------------------
  |  |  |  Branch (114:32): [True: 39.1k, False: 0]
  |  |  |  Branch (114:39): [True: 8, False: 39.1k]
  |  |  ------------------
  ------------------
   59|      8|	return;
   60|       |
   61|  39.2k|    for( ; a->nlimbs && !a->d[a->nlimbs-1]; a->nlimbs-- )
  ------------------
  |  Branch (61:12): [True: 38.1k, False: 1.07k]
  |  Branch (61:25): [True: 61, False: 38.1k]
  ------------------
   62|     61|	;
   63|  39.1k|}
_gcry_mpi_get_nbits:
   72|  1.13k|{
   73|  1.13k|    unsigned n;
   74|       |
   75|  1.13k|    if( mpi_is_opaque(a) ) {
  ------------------
  |  |  114|  1.13k|#define mpi_is_opaque(a)      ((a) && ((a)->flags&4))
  |  |  ------------------
  |  |  |  Branch (114:32): [True: 1.13k, False: 0]
  |  |  |  Branch (114:39): [True: 143, False: 989]
  |  |  ------------------
  ------------------
   76|    143|	return a->sign; /* which holds the number of bits */
   77|    143|    }
   78|       |
   79|    989|    _gcry_mpi_normalize( a );
   80|    989|    if( a->nlimbs ) {
  ------------------
  |  Branch (80:9): [True: 417, False: 572]
  ------------------
   81|    417|	mpi_limb_t alimb = a->d[a->nlimbs-1];
   82|    417|	if( alimb )
  ------------------
  |  Branch (82:6): [True: 417, False: 0]
  ------------------
   83|    417|	    count_leading_zeros( n, alimb );
  ------------------
  |  |  617|    417|  do {                                                                  \
  |  |  618|    417|    UDItype __cbtmp;                                                    \
  |  |  619|    417|    __asm__ ("bsrq %1,%0"                                               \
  |  |  620|    417|             : "=r" (__cbtmp) : "rm" ((UDItype)(x))                     \
  |  |  621|    417|             __CLOBBER_CC);                                             \
  |  |  622|    417|    (count) = __cbtmp ^ 63;                                             \
  |  |  623|    417|  } while (0)
  |  |  ------------------
  |  |  |  Branch (623:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
   84|      0|	else
   85|      0|	    n = BITS_PER_MPI_LIMB;
  ------------------
  |  |   49|      0|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   86|    417|	n = BITS_PER_MPI_LIMB - n + (a->nlimbs-1) * BITS_PER_MPI_LIMB;
  ------------------
  |  |   49|    417|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|    417|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|    417|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
              	n = BITS_PER_MPI_LIMB - n + (a->nlimbs-1) * BITS_PER_MPI_LIMB;
  ------------------
  |  |   49|    417|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|    417|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|    417|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   87|    417|    }
   88|    572|    else
   89|    572|	n = 0;
   90|    989|    return n;
   91|  1.13k|}
_gcry_mpi_test_bit:
   99|  24.4k|{
  100|  24.4k|    unsigned int limbno, bitno;
  101|  24.4k|    mpi_limb_t limb;
  102|       |
  103|  24.4k|    limbno = n / BITS_PER_MPI_LIMB;
  ------------------
  |  |   49|  24.4k|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|  24.4k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|  24.4k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  104|  24.4k|    bitno  = n % BITS_PER_MPI_LIMB;
  ------------------
  |  |   49|  24.4k|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|  24.4k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|  24.4k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  105|       |
  106|  24.4k|    if( limbno >= a->nlimbs )
  ------------------
  |  Branch (106:9): [True: 16, False: 24.4k]
  ------------------
  107|     16|	return 0; /* too far left: this is a 0 */
  108|  24.4k|    limb = a->d[limbno];
  109|  24.4k|    return (limb & (A_LIMB_1 << bitno))? 1: 0;
  ------------------
  |  |   48|  24.4k|#define A_LIMB_1 ((mpi_limb_t)1)
  ------------------
  |  Branch (109:12): [True: 12.1k, False: 12.2k]
  ------------------
  110|  24.4k|}
_gcry_mpi_rshift:
  253|  19.1k|{
  254|  19.1k|  mpi_size_t xsize;
  255|  19.1k|  unsigned int i;
  256|  19.1k|  unsigned int nlimbs = (n/BITS_PER_MPI_LIMB);
  ------------------
  |  |   49|  19.1k|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|  19.1k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|  19.1k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  257|  19.1k|  unsigned int nbits = (n%BITS_PER_MPI_LIMB);
  ------------------
  |  |   49|  19.1k|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|  19.1k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|  19.1k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  258|       |
  259|  19.1k|  if (mpi_is_immutable (x))
  ------------------
  |  |  113|  19.1k|#define mpi_is_immutable(a)   ((a)->flags&16)
  |  |  ------------------
  |  |  |  Branch (113:31): [True: 0, False: 19.1k]
  |  |  ------------------
  ------------------
  260|      0|    {
  261|      0|      mpi_immutable_failed ();
  ------------------
  |  |  110|      0|#define mpi_immutable_failed() _gcry_mpi_immutable_failed ()
  ------------------
  262|      0|      return;
  263|      0|    }
  264|       |
  265|  19.1k|  if ( x == a )
  ------------------
  |  Branch (265:8): [True: 19.1k, False: 0]
  ------------------
  266|  19.1k|    {
  267|       |      /* In-place operation.  */
  268|  19.1k|      if ( nlimbs >= x->nlimbs )
  ------------------
  |  Branch (268:12): [True: 0, False: 19.1k]
  ------------------
  269|      0|        {
  270|      0|          x->nlimbs = 0;
  271|      0|          return;
  272|      0|        }
  273|       |
  274|  19.1k|      if (nlimbs)
  ------------------
  |  Branch (274:11): [True: 0, False: 19.1k]
  ------------------
  275|      0|        {
  276|      0|          for (i=0; i < x->nlimbs - nlimbs; i++ )
  ------------------
  |  Branch (276:21): [True: 0, False: 0]
  ------------------
  277|      0|            x->d[i] = x->d[i+nlimbs];
  278|      0|          x->d[i] = 0;
  279|      0|          x->nlimbs -= nlimbs;
  280|       |
  281|      0|        }
  282|  19.1k|      if ( x->nlimbs && nbits )
  ------------------
  |  Branch (282:12): [True: 19.1k, False: 0]
  |  Branch (282:25): [True: 19.1k, False: 0]
  ------------------
  283|  19.1k|        _gcry_mpih_rshift ( x->d, x->d, x->nlimbs, nbits );
  284|  19.1k|    }
  285|      0|  else if ( nlimbs )
  ------------------
  |  Branch (285:13): [True: 0, False: 0]
  ------------------
  286|      0|    {
  287|       |      /* Copy and shift by more or equal bits than in a limb. */
  288|      0|      xsize = a->nlimbs;
  289|      0|      x->sign = a->sign;
  290|      0|      RESIZE_IF_NEEDED (x, xsize);
  ------------------
  |  |   78|      0|    do {			   \
  |  |   79|      0|	if( (a)->alloced < (b) )   \
  |  |  ------------------
  |  |  |  Branch (79:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   80|      0|	    mpi_resize((a), (b));  \
  |  |  ------------------
  |  |  |  |  100|      0|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  |  |  ------------------
  |  |   81|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (81:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  291|      0|      x->nlimbs = xsize;
  292|      0|      for (i=0; i < a->nlimbs; i++ )
  ------------------
  |  Branch (292:17): [True: 0, False: 0]
  ------------------
  293|      0|        x->d[i] = a->d[i];
  294|      0|      x->nlimbs = i;
  295|       |
  296|      0|      if ( nlimbs >= x->nlimbs )
  ------------------
  |  Branch (296:12): [True: 0, False: 0]
  ------------------
  297|      0|        {
  298|      0|          x->nlimbs = 0;
  299|      0|          return;
  300|      0|        }
  301|       |
  302|      0|      if (nlimbs)
  ------------------
  |  Branch (302:11): [True: 0, False: 0]
  ------------------
  303|      0|        {
  304|      0|          for (i=0; i < x->nlimbs - nlimbs; i++ )
  ------------------
  |  Branch (304:21): [True: 0, False: 0]
  ------------------
  305|      0|            x->d[i] = x->d[i+nlimbs];
  306|      0|          x->d[i] = 0;
  307|      0|          x->nlimbs -= nlimbs;
  308|      0|        }
  309|       |
  310|      0|      if ( x->nlimbs && nbits )
  ------------------
  |  Branch (310:12): [True: 0, False: 0]
  |  Branch (310:25): [True: 0, False: 0]
  ------------------
  311|      0|        _gcry_mpih_rshift ( x->d, x->d, x->nlimbs, nbits );
  312|      0|    }
  313|      0|  else
  314|      0|    {
  315|       |      /* Copy and shift by less than bits in a limb.  */
  316|      0|      xsize = a->nlimbs;
  317|      0|      x->sign = a->sign;
  318|      0|      RESIZE_IF_NEEDED (x, xsize);
  ------------------
  |  |   78|      0|    do {			   \
  |  |   79|      0|	if( (a)->alloced < (b) )   \
  |  |  ------------------
  |  |  |  Branch (79:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   80|      0|	    mpi_resize((a), (b));  \
  |  |  ------------------
  |  |  |  |  100|      0|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  |  |  ------------------
  |  |   81|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (81:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  319|      0|      x->nlimbs = xsize;
  320|       |
  321|      0|      if ( xsize )
  ------------------
  |  Branch (321:12): [True: 0, False: 0]
  ------------------
  322|      0|        {
  323|      0|          if (nbits )
  ------------------
  |  Branch (323:15): [True: 0, False: 0]
  ------------------
  324|      0|            _gcry_mpih_rshift (x->d, a->d, x->nlimbs, nbits );
  325|      0|          else
  326|      0|            {
  327|       |              /* The rshift helper function is not specified for
  328|       |                 NBITS==0, thus we do a plain copy here. */
  329|      0|              for (i=0; i < x->nlimbs; i++ )
  ------------------
  |  Branch (329:25): [True: 0, False: 0]
  ------------------
  330|      0|                x->d[i] = a->d[i];
  331|      0|            }
  332|      0|        }
  333|      0|    }
  334|  19.1k|  MPN_NORMALIZE (x->d, x->nlimbs);
  ------------------
  |  |  119|  19.1k|    do {		       \
  |  |  120|  28.8k|	while( (n) > 0 ) {     \
  |  |  ------------------
  |  |  |  Branch (120:9): [True: 28.8k, False: 0]
  |  |  ------------------
  |  |  121|  28.8k|	    if( (d)[(n)-1] ) \
  |  |  ------------------
  |  |  |  Branch (121:10): [True: 19.1k, False: 9.74k]
  |  |  ------------------
  |  |  122|  28.8k|		break;	       \
  |  |  123|  28.8k|	    (n)--;	       \
  |  |  124|  9.74k|	}		       \
  |  |  125|  19.1k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (125:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  335|  19.1k|}
_gcry_mpi_lshift_limbs:
  344|  19.1k|{
  345|  19.1k|  mpi_ptr_t ap;
  346|  19.1k|  int n = a->nlimbs;
  347|  19.1k|  int i;
  348|       |
  349|  19.1k|  if (!count || !n)
  ------------------
  |  Branch (349:7): [True: 0, False: 19.1k]
  |  Branch (349:17): [True: 0, False: 19.1k]
  ------------------
  350|      0|    return;
  351|       |
  352|  19.1k|  RESIZE_IF_NEEDED (a, n+count);
  ------------------
  |  |   78|  19.1k|    do {			   \
  |  |   79|  19.1k|	if( (a)->alloced < (b) )   \
  |  |  ------------------
  |  |  |  Branch (79:6): [True: 0, False: 19.1k]
  |  |  ------------------
  |  |   80|  19.1k|	    mpi_resize((a), (b));  \
  |  |  ------------------
  |  |  |  |  100|      0|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  |  |  ------------------
  |  |   81|  19.1k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (81:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  353|       |
  354|  19.1k|  ap = a->d;
  355|  95.5k|  for (i = n-1; i >= 0; i--)
  ------------------
  |  Branch (355:17): [True: 76.4k, False: 19.1k]
  ------------------
  356|  76.4k|    ap[i+count] = ap[i];
  357|  38.2k|  for (i=0; i < count; i++ )
  ------------------
  |  Branch (357:13): [True: 19.1k, False: 19.1k]
  ------------------
  358|  19.1k|    ap[i] = 0;
  359|  19.1k|  a->nlimbs += count;
  360|  19.1k|}
_gcry_mpi_lshift:
  368|  19.1k|{
  369|  19.1k|  unsigned int nlimbs = (n/BITS_PER_MPI_LIMB);
  ------------------
  |  |   49|  19.1k|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|  19.1k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|  19.1k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  370|  19.1k|  unsigned int nbits = (n%BITS_PER_MPI_LIMB);
  ------------------
  |  |   49|  19.1k|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|  19.1k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|  19.1k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  371|       |
  372|  19.1k|  if (mpi_is_immutable (x))
  ------------------
  |  |  113|  19.1k|#define mpi_is_immutable(a)   ((a)->flags&16)
  |  |  ------------------
  |  |  |  Branch (113:31): [True: 0, False: 19.1k]
  |  |  ------------------
  ------------------
  373|      0|    {
  374|      0|      mpi_immutable_failed ();
  ------------------
  |  |  110|      0|#define mpi_immutable_failed() _gcry_mpi_immutable_failed ()
  ------------------
  375|      0|      return;
  376|      0|    }
  377|       |
  378|  19.1k|  if (x == a && !n)
  ------------------
  |  Branch (378:7): [True: 8.12k, False: 10.9k]
  |  Branch (378:17): [True: 0, False: 8.12k]
  ------------------
  379|      0|    return;  /* In-place shift with an amount of zero.  */
  380|       |
  381|  19.1k|  if ( x != a )
  ------------------
  |  Branch (381:8): [True: 10.9k, False: 8.12k]
  ------------------
  382|  10.9k|    {
  383|       |      /* Copy A to X.  */
  384|  10.9k|      unsigned int alimbs = a->nlimbs;
  385|  10.9k|      int asign  = a->sign;
  386|  10.9k|      mpi_ptr_t xp, ap;
  387|       |
  388|  10.9k|      RESIZE_IF_NEEDED (x, alimbs+nlimbs+1);
  ------------------
  |  |   78|  10.9k|    do {			   \
  |  |   79|  10.9k|	if( (a)->alloced < (b) )   \
  |  |  ------------------
  |  |  |  Branch (79:6): [True: 0, False: 10.9k]
  |  |  ------------------
  |  |   80|  10.9k|	    mpi_resize((a), (b));  \
  |  |  ------------------
  |  |  |  |  100|      0|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  |  |  ------------------
  |  |   81|  10.9k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (81:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  389|  10.9k|      xp = x->d;
  390|  10.9k|      ap = a->d;
  391|  10.9k|      MPN_COPY (xp, ap, alimbs);
  ------------------
  |  |   90|  10.9k|    do {				\
  |  |   91|  10.9k|	mpi_size_t _i;			\
  |  |   92|  54.8k|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 43.9k, False: 10.9k]
  |  |  ------------------
  |  |   93|  43.9k|	    (d)[_i] = (s)[_i];		\
  |  |   94|  10.9k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  392|  10.9k|      x->nlimbs = alimbs;
  393|  10.9k|      x->flags = a->flags;
  394|  10.9k|      x->sign = asign;
  395|  10.9k|    }
  396|       |
  397|  19.1k|  if (nlimbs && !nbits)
  ------------------
  |  Branch (397:7): [True: 0, False: 19.1k]
  |  Branch (397:17): [True: 0, False: 0]
  ------------------
  398|      0|    {
  399|       |      /* Shift a full number of limbs.  */
  400|      0|      _gcry_mpi_lshift_limbs (x, nlimbs);
  401|      0|    }
  402|  19.1k|  else if (n)
  ------------------
  |  Branch (402:12): [True: 19.1k, False: 0]
  ------------------
  403|  19.1k|    {
  404|       |      /* We use a very dump approach: Shift left by the number of
  405|       |         limbs plus one and than fix it up by an rshift.  */
  406|  19.1k|      _gcry_mpi_lshift_limbs (x, nlimbs+1);
  407|  19.1k|      mpi_rshift (x, x, BITS_PER_MPI_LIMB - nbits);
  ------------------
  |  |  558|  19.1k|#define mpi_rshift(a,b,c)      _gcry_mpi_rshift ((a),(b),(c))
  ------------------
  408|  19.1k|    }
  409|       |
  410|  19.1k|  MPN_NORMALIZE (x->d, x->nlimbs);
  ------------------
  |  |  119|  19.1k|    do {		       \
  |  |  120|  19.1k|	while( (n) > 0 ) {     \
  |  |  ------------------
  |  |  |  Branch (120:9): [True: 19.1k, False: 0]
  |  |  ------------------
  |  |  121|  19.1k|	    if( (d)[(n)-1] ) \
  |  |  ------------------
  |  |  |  Branch (121:10): [True: 19.1k, False: 0]
  |  |  ------------------
  |  |  122|  19.1k|		break;	       \
  |  |  123|  19.1k|	    (n)--;	       \
  |  |  124|      0|	}		       \
  |  |  125|  19.1k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (125:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  411|  19.1k|}

_gcry_mpi_cmp_ui:
   28|  30.7k|{
   29|  30.7k|  mpi_limb_t limb = v;
   30|       |
   31|  30.7k|  _gcry_mpi_normalize (u);
   32|       |
   33|       |  /* Handle the case that U contains no limb.  */
   34|  30.7k|  if (u->nlimbs == 0)
  ------------------
  |  Branch (34:7): [True: 0, False: 30.7k]
  ------------------
   35|      0|    return -(limb != 0);
   36|       |
   37|       |  /* Handle the case that U is negative.  */
   38|  30.7k|  if (u->sign)
  ------------------
  |  Branch (38:7): [True: 0, False: 30.7k]
  ------------------
   39|      0|    return -1;
   40|       |
   41|  30.7k|  if (u->nlimbs == 1)
  ------------------
  |  Branch (41:7): [True: 5.77k, False: 24.9k]
  ------------------
   42|  5.77k|    {
   43|       |      /* Handle the case that U contains exactly one limb.  */
   44|       |
   45|  5.77k|      if (u->d[0] > limb)
  ------------------
  |  Branch (45:11): [True: 2.89k, False: 2.88k]
  ------------------
   46|  2.89k|	return 1;
   47|  2.88k|      if (u->d[0] < limb)
  ------------------
  |  Branch (47:11): [True: 0, False: 2.88k]
  ------------------
   48|      0|	return -1;
   49|  2.88k|      return 0;
   50|  2.88k|    }
   51|  24.9k|  else
   52|       |    /* Handle the case that U contains more than one limb.  */
   53|  24.9k|    return 1;
   54|  30.7k|}
_gcry_mpi_cmp:
  121|  3.07k|{
  122|  3.07k|  return do_mpi_cmp (u, v, 0);
  123|  3.07k|}
_gcry_mpi_cmpabs:
  128|     48|{
  129|     48|  return do_mpi_cmp (u, v, 1);
  130|     48|}
mpi-cmp.c:do_mpi_cmp:
   60|  3.12k|{
   61|  3.12k|  mpi_size_t usize;
   62|  3.12k|  mpi_size_t vsize;
   63|  3.12k|  int usign;
   64|  3.12k|  int vsign;
   65|  3.12k|  int cmp;
   66|       |
   67|  3.12k|  if (mpi_is_opaque (u) || mpi_is_opaque (v))
  ------------------
  |  |  114|  6.25k|#define mpi_is_opaque(a)      ((a) && ((a)->flags&4))
  |  |  ------------------
  |  |  |  Branch (114:32): [True: 3.12k, False: 0]
  |  |  |  Branch (114:39): [True: 42, False: 3.08k]
  |  |  ------------------
  ------------------
                if (mpi_is_opaque (u) || mpi_is_opaque (v))
  ------------------
  |  |  114|  3.08k|#define mpi_is_opaque(a)      ((a) && ((a)->flags&4))
  |  |  ------------------
  |  |  |  Branch (114:32): [True: 3.08k, False: 0]
  |  |  |  Branch (114:39): [True: 0, False: 3.08k]
  |  |  ------------------
  ------------------
   68|     42|    {
   69|       |      /* We have no signan and thus ABSMODE has no efeect here.  */
   70|     42|      if (mpi_is_opaque (u) && !mpi_is_opaque (v))
  ------------------
  |  |  114|     84|#define mpi_is_opaque(a)      ((a) && ((a)->flags&4))
  |  |  ------------------
  |  |  |  Branch (114:32): [True: 42, False: 0]
  |  |  |  Branch (114:39): [True: 42, False: 0]
  |  |  ------------------
  ------------------
                    if (mpi_is_opaque (u) && !mpi_is_opaque (v))
  ------------------
  |  |  114|     42|#define mpi_is_opaque(a)      ((a) && ((a)->flags&4))
  |  |  ------------------
  |  |  |  Branch (114:32): [True: 42, False: 0]
  |  |  |  Branch (114:39): [True: 42, False: 0]
  |  |  ------------------
  ------------------
   71|      0|        return -1;
   72|     42|      if (!mpi_is_opaque (u) && mpi_is_opaque (v))
  ------------------
  |  |  114|     84|#define mpi_is_opaque(a)      ((a) && ((a)->flags&4))
  |  |  ------------------
  |  |  |  Branch (114:32): [True: 42, False: 0]
  |  |  |  Branch (114:39): [True: 42, False: 0]
  |  |  ------------------
  ------------------
                    if (!mpi_is_opaque (u) && mpi_is_opaque (v))
  ------------------
  |  |  114|      0|#define mpi_is_opaque(a)      ((a) && ((a)->flags&4))
  |  |  ------------------
  |  |  |  Branch (114:32): [True: 0, False: 0]
  |  |  |  Branch (114:39): [True: 0, False: 0]
  |  |  ------------------
  ------------------
   73|      0|        return 1;
   74|     42|      if (!u->sign && !v->sign)
  ------------------
  |  Branch (74:11): [True: 0, False: 42]
  |  Branch (74:23): [True: 0, False: 0]
  ------------------
   75|      0|        return 0; /* Empty buffers are identical.  */
   76|     42|      if (u->sign < v->sign)
  ------------------
  |  Branch (76:11): [True: 0, False: 42]
  ------------------
   77|      0|        return -1;
   78|     42|      if (u->sign > v->sign)
  ------------------
  |  Branch (78:11): [True: 28, False: 14]
  ------------------
   79|     28|        return 1;
   80|     14|      return memcmp (u->d, v->d, (u->sign+7)/8);
   81|     42|    }
   82|  3.08k|  else
   83|  3.08k|    {
   84|  3.08k|      _gcry_mpi_normalize (u);
   85|  3.08k|      _gcry_mpi_normalize (v);
   86|       |
   87|  3.08k|      usize = u->nlimbs;
   88|  3.08k|      vsize = v->nlimbs;
   89|  3.08k|      usign = absmode? 0 : u->sign;
  ------------------
  |  Branch (89:15): [True: 48, False: 3.03k]
  ------------------
   90|  3.08k|      vsign = absmode? 0 : v->sign;
  ------------------
  |  Branch (90:15): [True: 48, False: 3.03k]
  ------------------
   91|       |
   92|       |      /* Special treatment for +0 == -0 */
   93|  3.08k|      if (!usize && !vsize)
  ------------------
  |  Branch (93:11): [True: 0, False: 3.08k]
  |  Branch (93:21): [True: 0, False: 0]
  ------------------
   94|      0|        return 0;
   95|       |
   96|       |      /* Compare sign bits.  */
   97|  3.08k|      if (!usign && vsign)
  ------------------
  |  Branch (97:11): [True: 3.08k, False: 0]
  |  Branch (97:21): [True: 0, False: 3.08k]
  ------------------
   98|      0|        return 1;
   99|  3.08k|      if (usign && !vsign)
  ------------------
  |  Branch (99:11): [True: 0, False: 3.08k]
  |  Branch (99:20): [True: 0, False: 0]
  ------------------
  100|      0|        return -1;
  101|       |
  102|       |      /* U and V are either both positive or both negative.  */
  103|       |
  104|  3.08k|      if (usize != vsize && !usign && !vsign)
  ------------------
  |  Branch (104:11): [True: 48, False: 3.03k]
  |  Branch (104:29): [True: 48, False: 0]
  |  Branch (104:39): [True: 48, False: 0]
  ------------------
  105|     48|        return usize - vsize;
  106|  3.03k|      if (usize != vsize && usign && vsign)
  ------------------
  |  Branch (106:11): [True: 0, False: 3.03k]
  |  Branch (106:29): [True: 0, False: 0]
  |  Branch (106:38): [True: 0, False: 0]
  ------------------
  107|      0|        return vsize + usize;
  108|  3.03k|      if (!usize )
  ------------------
  |  Branch (108:11): [True: 0, False: 3.03k]
  ------------------
  109|      0|        return 0;
  110|  3.03k|      if (!(cmp = _gcry_mpih_cmp (u->d, v->d, usize)))
  ------------------
  |  Branch (110:11): [True: 93, False: 2.94k]
  ------------------
  111|     93|        return 0;
  112|  2.94k|      if ((cmp < 0?1:0) == (usign?1:0))
  ------------------
  |  Branch (112:11): [True: 1.69k, False: 1.24k]
  |  Branch (112:12): [True: 1.24k, False: 1.69k]
  |  Branch (112:29): [True: 0, False: 2.94k]
  ------------------
  113|  1.69k|        return 1;
  114|  2.94k|    }
  115|  1.24k|  return -1;
  116|  3.12k|}

_gcry_mpi_fdiv_r:
   38|     16|{
   39|     16|    int divisor_sign = divisor->sign;
   40|     16|    gcry_mpi_t temp_divisor = NULL;
   41|       |
   42|       |    /* We need the original value of the divisor after the remainder has been
   43|       |     * preliminary calculated.	We have to copy it to temporary space if it's
   44|       |     * the same variable as REM.  */
   45|     16|    if( rem == divisor ) {
  ------------------
  |  Branch (45:9): [True: 0, False: 16]
  ------------------
   46|      0|	temp_divisor = mpi_copy( divisor );
  ------------------
  |  |  101|      0|# define mpi_copy(a)	       _gcry_mpi_copy((a))
  ------------------
   47|      0|	divisor = temp_divisor;
   48|      0|    }
   49|       |
   50|     16|    _gcry_mpi_tdiv_r( rem, dividend, divisor );
   51|       |
   52|     16|    if( ((divisor_sign?1:0) ^ (dividend->sign?1:0)) && rem->nlimbs )
  ------------------
  |  Branch (52:9): [True: 0, False: 16]
  |  Branch (52:11): [True: 0, False: 16]
  |  Branch (52:32): [True: 0, False: 16]
  |  Branch (52:56): [True: 0, False: 0]
  ------------------
   53|      0|	mpi_add (rem, rem, divisor);
  ------------------
  |  |  516|      0|#define mpi_add(w,u,v)         _gcry_mpi_add ((w),(u),(v))
  ------------------
   54|       |
   55|     16|    if( temp_divisor )
  ------------------
  |  Branch (55:9): [True: 0, False: 16]
  ------------------
   56|      0|	mpi_free(temp_divisor);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
   57|     16|}
_gcry_mpi_tdiv_r:
  125|     48|{
  126|     48|    _gcry_mpi_tdiv_qr(NULL, rem, num, den );
  127|     48|}
_gcry_mpi_tdiv_qr:
  131|     48|{
  132|     48|    mpi_ptr_t np, dp;
  133|     48|    mpi_ptr_t qp, rp;
  134|     48|    mpi_size_t nsize = num->nlimbs;
  135|     48|    mpi_size_t dsize = den->nlimbs;
  136|     48|    mpi_size_t qsize, rsize;
  137|     48|    mpi_size_t sign_remainder = num->sign;
  138|     48|    mpi_size_t sign_quotient = num->sign ^ den->sign;
  139|     48|    unsigned normalization_steps;
  140|     48|    mpi_limb_t q_limb;
  141|     48|    mpi_ptr_t marker[5];
  142|     48|    unsigned int marker_nlimbs[5];
  143|     48|    int markidx=0;
  144|       |
  145|       |    /* Ensure space is enough for quotient and remainder.
  146|       |     * We need space for an extra limb in the remainder, because it's
  147|       |     * up-shifted (normalized) below.  */
  148|     48|    rsize = nsize + 1;
  149|     48|    mpi_resize( rem, rsize);
  ------------------
  |  |  100|     48|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  ------------------
  150|       |
  151|     48|    qsize = rsize - dsize;	  /* qsize cannot be bigger than this.	*/
  152|     48|    if( qsize <= 0 ) {
  ------------------
  |  Branch (152:9): [True: 0, False: 48]
  ------------------
  153|      0|	if( num != rem ) {
  ------------------
  |  Branch (153:6): [True: 0, False: 0]
  ------------------
  154|      0|	    rem->nlimbs = num->nlimbs;
  155|      0|	    rem->sign = num->sign;
  156|      0|	    MPN_COPY(rem->d, num->d, nsize);
  ------------------
  |  |   90|      0|    do {				\
  |  |   91|      0|	mpi_size_t _i;			\
  |  |   92|      0|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 0, False: 0]
  |  |  ------------------
  |  |   93|      0|	    (d)[_i] = (s)[_i];		\
  |  |   94|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  157|      0|	}
  158|      0|	if( quot ) {
  ------------------
  |  Branch (158:6): [True: 0, False: 0]
  ------------------
  159|       |	    /* This needs to follow the assignment to rem, in case the
  160|       |	     * numerator and quotient are the same.  */
  161|      0|	    quot->nlimbs = 0;
  162|      0|	    quot->sign = 0;
  163|      0|	}
  164|      0|	return;
  165|      0|    }
  166|       |
  167|     48|    if( quot )
  ------------------
  |  Branch (167:9): [True: 0, False: 48]
  ------------------
  168|      0|	mpi_resize( quot, qsize);
  ------------------
  |  |  100|      0|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  ------------------
  169|       |
  170|     48|    if (!dsize)
  ------------------
  |  Branch (170:9): [True: 0, False: 48]
  ------------------
  171|      0|      _gcry_divide_by_zero();
  172|       |
  173|       |    /* Read pointers here, when reallocation is finished.  */
  174|     48|    np = num->d;
  175|     48|    dp = den->d;
  176|     48|    rp = rem->d;
  177|       |
  178|       |    /* Optimize division by a single-limb divisor.  */
  179|     48|    if( dsize == 1 ) {
  ------------------
  |  Branch (179:9): [True: 0, False: 48]
  ------------------
  180|      0|	mpi_limb_t rlimb;
  181|      0|	if( quot ) {
  ------------------
  |  Branch (181:6): [True: 0, False: 0]
  ------------------
  182|      0|	    qp = quot->d;
  183|      0|	    rlimb = _gcry_mpih_divmod_1( qp, np, nsize, dp[0] );
  184|      0|	    qsize -= qp[qsize - 1] == 0;
  185|      0|	    quot->nlimbs = qsize;
  186|      0|	    quot->sign = sign_quotient;
  187|      0|	}
  188|      0|	else
  189|      0|	    rlimb = _gcry_mpih_mod_1( np, nsize, dp[0] );
  190|      0|	rp[0] = rlimb;
  191|      0|	rsize = rlimb != 0?1:0;
  ------------------
  |  Branch (191:10): [True: 0, False: 0]
  ------------------
  192|      0|	rem->nlimbs = rsize;
  193|      0|	rem->sign = sign_remainder;
  194|      0|	return;
  195|      0|    }
  196|       |
  197|       |
  198|     48|    if( quot ) {
  ------------------
  |  Branch (198:9): [True: 0, False: 48]
  ------------------
  199|      0|	qp = quot->d;
  200|       |	/* Make sure QP and NP point to different objects.  Otherwise the
  201|       |	 * numerator would be gradually overwritten by the quotient limbs.  */
  202|      0|	if(qp == np) { /* Copy NP object to temporary space.  */
  ------------------
  |  Branch (202:5): [True: 0, False: 0]
  ------------------
  203|      0|            marker_nlimbs[markidx] = nsize;
  204|      0|	    np = marker[markidx++] = mpi_alloc_limb_space(nsize,
  ------------------
  |  |  178|      0|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  |  |  ------------------
  |  |  |  Branch (178:68): [True: 0, False: 0]
  |  |  |  Branch (178:68): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  205|      0|							  mpi_is_secure(quot));
  206|      0|	    MPN_COPY(np, qp, nsize);
  ------------------
  |  |   90|      0|    do {				\
  |  |   91|      0|	mpi_size_t _i;			\
  |  |   92|      0|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 0, False: 0]
  |  |  ------------------
  |  |   93|      0|	    (d)[_i] = (s)[_i];		\
  |  |   94|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  207|      0|	}
  208|      0|    }
  209|     48|    else /* Put quotient at top of remainder. */
  210|     48|	qp = rp + dsize;
  211|       |
  212|     48|    count_leading_zeros( normalization_steps, dp[dsize - 1] );
  ------------------
  |  |  617|     48|  do {                                                                  \
  |  |  618|     48|    UDItype __cbtmp;                                                    \
  |  |  619|     48|    __asm__ ("bsrq %1,%0"                                               \
  |  |  620|     48|             : "=r" (__cbtmp) : "rm" ((UDItype)(x))                     \
  |  |  621|     48|             __CLOBBER_CC);                                             \
  |  |  622|     48|    (count) = __cbtmp ^ 63;                                             \
  |  |  623|     48|  } while (0)
  |  |  ------------------
  |  |  |  Branch (623:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
  213|       |
  214|       |    /* Normalize the denominator, i.e. make its most significant bit set by
  215|       |     * shifting it NORMALIZATION_STEPS bits to the left.  Also shift the
  216|       |     * numerator the same number of steps (to keep the quotient the same!).
  217|       |     */
  218|     48|    if( normalization_steps ) {
  ------------------
  |  Branch (218:9): [True: 0, False: 48]
  ------------------
  219|      0|	mpi_ptr_t tp;
  220|      0|	mpi_limb_t nlimb;
  221|       |
  222|       |	/* Shift up the denominator setting the most significant bit of
  223|       |	 * the most significant word.  Use temporary storage not to clobber
  224|       |	 * the original contents of the denominator.  */
  225|      0|        marker_nlimbs[markidx] = dsize;
  226|      0|	tp = marker[markidx++] = mpi_alloc_limb_space(dsize,mpi_is_secure(den));
  ------------------
  |  |  178|      0|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  |  |  ------------------
  |  |  |  Branch (178:68): [True: 0, False: 0]
  |  |  |  Branch (178:68): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  227|      0|	_gcry_mpih_lshift( tp, dp, dsize, normalization_steps );
  228|      0|	dp = tp;
  229|       |
  230|       |	/* Shift up the numerator, possibly introducing a new most
  231|       |	 * significant word.  Move the shifted numerator in the remainder
  232|       |	 * meanwhile.  */
  233|      0|	nlimb = _gcry_mpih_lshift(rp, np, nsize, normalization_steps);
  234|      0|	if( nlimb ) {
  ------------------
  |  Branch (234:6): [True: 0, False: 0]
  ------------------
  235|      0|	    rp[nsize] = nlimb;
  236|      0|	    rsize = nsize + 1;
  237|      0|	}
  238|      0|	else
  239|      0|	    rsize = nsize;
  240|      0|    }
  241|     48|    else {
  242|       |	/* The denominator is already normalized, as required.	Copy it to
  243|       |	 * temporary space if it overlaps with the quotient or remainder.  */
  244|     48|	if( dp == rp || (quot && (dp == qp))) {
  ------------------
  |  Branch (244:6): [True: 0, False: 48]
  |  Branch (244:19): [True: 0, False: 48]
  |  Branch (244:27): [True: 0, False: 0]
  ------------------
  245|      0|	    mpi_ptr_t tp;
  246|       |
  247|      0|            marker_nlimbs[markidx] = dsize;
  248|      0|	    tp = marker[markidx++] = mpi_alloc_limb_space(dsize,
  ------------------
  |  |  178|      0|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  |  |  ------------------
  |  |  |  Branch (178:68): [True: 0, False: 0]
  |  |  |  Branch (178:68): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  249|      0|                                                          mpi_is_secure(den));
  250|      0|	    MPN_COPY( tp, dp, dsize );
  ------------------
  |  |   90|      0|    do {				\
  |  |   91|      0|	mpi_size_t _i;			\
  |  |   92|      0|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 0, False: 0]
  |  |  ------------------
  |  |   93|      0|	    (d)[_i] = (s)[_i];		\
  |  |   94|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  251|      0|	    dp = tp;
  252|      0|	}
  253|       |
  254|       |	/* Move the numerator to the remainder.  */
  255|     48|	if( rp != np )
  ------------------
  |  Branch (255:6): [True: 0, False: 48]
  ------------------
  256|      0|	    MPN_COPY(rp, np, nsize);
  ------------------
  |  |   90|      0|    do {				\
  |  |   91|      0|	mpi_size_t _i;			\
  |  |   92|      0|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 0, False: 0]
  |  |  ------------------
  |  |   93|      0|	    (d)[_i] = (s)[_i];		\
  |  |   94|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  257|       |
  258|     48|	rsize = nsize;
  259|     48|    }
  260|       |
  261|     48|    q_limb = _gcry_mpih_divrem( qp, 0, rp, rsize, dp, dsize );
  262|       |
  263|     48|    if( quot ) {
  ------------------
  |  Branch (263:9): [True: 0, False: 48]
  ------------------
  264|      0|	qsize = rsize - dsize;
  265|      0|	if(q_limb) {
  ------------------
  |  Branch (265:5): [True: 0, False: 0]
  ------------------
  266|      0|	    qp[qsize] = q_limb;
  267|      0|	    qsize += 1;
  268|      0|	}
  269|       |
  270|      0|	quot->nlimbs = qsize;
  271|      0|	quot->sign = sign_quotient;
  272|      0|    }
  273|       |
  274|     48|    rsize = dsize;
  275|     48|    MPN_NORMALIZE (rp, rsize);
  ------------------
  |  |  119|     48|    do {		       \
  |  |  120|     48|	while( (n) > 0 ) {     \
  |  |  ------------------
  |  |  |  Branch (120:9): [True: 48, False: 0]
  |  |  ------------------
  |  |  121|     48|	    if( (d)[(n)-1] ) \
  |  |  ------------------
  |  |  |  Branch (121:10): [True: 48, False: 0]
  |  |  ------------------
  |  |  122|     48|		break;	       \
  |  |  123|     48|	    (n)--;	       \
  |  |  124|      0|	}		       \
  |  |  125|     48|    } while(0)
  |  |  ------------------
  |  |  |  Branch (125:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  276|       |
  277|     48|    if( normalization_steps && rsize ) {
  ------------------
  |  Branch (277:9): [True: 0, False: 48]
  |  Branch (277:32): [True: 0, False: 0]
  ------------------
  278|      0|	_gcry_mpih_rshift(rp, rp, rsize, normalization_steps);
  279|      0|	rsize -= rp[rsize - 1] == 0?1:0;
  ------------------
  |  Branch (279:11): [True: 0, False: 0]
  ------------------
  280|      0|    }
  281|       |
  282|     48|    rem->nlimbs = rsize;
  283|     48|    rem->sign	= sign_remainder;
  284|     48|    while( markidx )
  ------------------
  |  Branch (284:12): [True: 0, False: 48]
  ------------------
  285|      0|      {
  286|      0|        markidx--;
  287|      0|	_gcry_mpi_free_limb_space (marker[markidx], marker_nlimbs[markidx]);
  288|      0|      }
  289|     48|}

_gcry_mpih_add_1:
   45|    899|{
   46|    899|    mpi_limb_t x;
   47|       |
   48|    899|    x = *s1_ptr++;
   49|    899|    s2_limb += x;
   50|    899|    *res_ptr++ = s2_limb;
   51|    899|    if( s2_limb < x ) { /* sum is less than the left operand: handle carry */
  ------------------
  |  Branch (51:9): [True: 32, False: 867]
  ------------------
   52|     32|	while( --s1_size ) {
  ------------------
  |  Branch (52:9): [True: 32, False: 0]
  ------------------
   53|     32|	    x = *s1_ptr++ + 1;	/* add carry */
   54|     32|	    *res_ptr++ = x;	/* and store */
   55|     32|	    if( x )		/* not 0 (no overflow): we can stop */
  ------------------
  |  Branch (55:10): [True: 32, False: 0]
  ------------------
   56|     32|		goto leave;
   57|     32|	}
   58|      0|	return 1; /* return carry (size of s1 to small) */
   59|     32|    }
   60|       |
   61|    899|  leave:
   62|    899|    if( res_ptr != s1_ptr ) { /* not the same variable */
  ------------------
  |  Branch (62:9): [True: 32, False: 867]
  ------------------
   63|     32|	mpi_size_t i;	       /* copy the rest */
   64|     96|	for( i=0; i < s1_size-1; i++ )
  ------------------
  |  Branch (64:12): [True: 64, False: 32]
  ------------------
   65|     64|	    res_ptr[i] = s1_ptr[i];
   66|     32|    }
   67|    899|    return 0; /* no carry */
   68|    899|}
_gcry_mpih_add:
   75|  13.8k|{
   76|  13.8k|    mpi_limb_t cy = 0;
   77|       |
   78|  13.8k|    if( s2_size )
  ------------------
  |  Branch (78:9): [True: 13.8k, False: 0]
  ------------------
   79|  13.8k|	cy = _gcry_mpih_add_n( res_ptr, s1_ptr, s2_ptr, s2_size );
   80|       |
   81|  13.8k|    if( s1_size - s2_size )
  ------------------
  |  Branch (81:9): [True: 32, False: 13.8k]
  ------------------
   82|     32|	cy = _gcry_mpih_add_1( res_ptr + s2_size, s1_ptr + s2_size,
   83|     32|			    s1_size - s2_size, cy);
   84|  13.8k|    return cy;
   85|  13.8k|}
_gcry_mpih_sub_1:
   91|     48|{
   92|     48|    mpi_limb_t x;
   93|       |
   94|     48|    x = *s1_ptr++;
   95|     48|    s2_limb = x - s2_limb;
   96|     48|    *res_ptr++ = s2_limb;
   97|     48|    if( s2_limb > x ) {
  ------------------
  |  Branch (97:9): [True: 0, False: 48]
  ------------------
   98|      0|	while( --s1_size ) {
  ------------------
  |  Branch (98:9): [True: 0, False: 0]
  ------------------
   99|      0|	    x = *s1_ptr++;
  100|      0|	    *res_ptr++ = x - 1;
  101|      0|	    if( x )
  ------------------
  |  Branch (101:10): [True: 0, False: 0]
  ------------------
  102|      0|		goto leave;
  103|      0|	}
  104|      0|	return 1;
  105|      0|    }
  106|       |
  107|     48|  leave:
  108|     48|    if( res_ptr != s1_ptr ) {
  ------------------
  |  Branch (108:9): [True: 48, False: 0]
  ------------------
  109|     48|	mpi_size_t i;
  110|    160|	for( i=0; i < s1_size-1; i++ )
  ------------------
  |  Branch (110:12): [True: 112, False: 48]
  ------------------
  111|    112|	    res_ptr[i] = s1_ptr[i];
  112|     48|    }
  113|     48|    return 0;
  114|     48|}
_gcry_mpih_sub:
  121|     32|{
  122|     32|    mpi_limb_t cy = 0;
  123|       |
  124|     32|    if( s2_size )
  ------------------
  |  Branch (124:9): [True: 32, False: 0]
  ------------------
  125|     32|	cy = _gcry_mpih_sub_n(res_ptr, s1_ptr, s2_ptr, s2_size);
  126|       |
  127|     32|    if( s1_size - s2_size )
  ------------------
  |  Branch (127:9): [True: 32, False: 0]
  ------------------
  128|     32|	cy = _gcry_mpih_sub_1(res_ptr + s2_size, s1_ptr + s2_size,
  129|     32|				      s1_size - s2_size, cy);
  130|     32|    return cy;
  131|     32|}
_gcry_mpih_cmp:
  141|  75.8k|{
  142|  75.8k|    mpi_size_t i;
  143|  75.8k|    mpi_limb_t op1_word, op2_word;
  144|       |
  145|  76.8k|    for( i = size - 1; i >= 0 ; i--) {
  ------------------
  |  Branch (145:24): [True: 76.7k, False: 93]
  ------------------
  146|  76.7k|	op1_word = op1_ptr[i];
  147|  76.7k|	op2_word = op2_ptr[i];
  148|  76.7k|	if( op1_word != op2_word )
  ------------------
  |  Branch (148:6): [True: 75.8k, False: 998]
  ------------------
  149|  75.8k|	    goto diff;
  150|  76.7k|    }
  151|     93|    return 0;
  152|       |
  153|  75.8k|  diff:
  154|       |    /* This can *not* be simplified to
  155|       |     *	 op2_word - op2_word
  156|       |     * since that expression might give signed overflow.  */
  157|  75.8k|    return (op1_word > op2_word) ? 1 : -1;
  ------------------
  |  Branch (157:12): [True: 25.2k, False: 50.5k]
  ------------------
  158|  75.8k|}

_gcry_mpi_invm:
  438|     48|{
  439|     48|  mpi_ptr_t ap, xp;
  440|       |
  441|     48|  if (!mpi_cmp_ui (a, 0))
  ------------------
  |  |  512|     48|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
  |  Branch (441:7): [True: 0, False: 48]
  ------------------
  442|      0|    return 0; /* Inverse does not exists.  */
  443|     48|  if (!mpi_cmp_ui (n, 1))
  ------------------
  |  |  512|     48|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
  |  Branch (443:7): [True: 0, False: 48]
  ------------------
  444|      0|    return 0; /* Inverse does not exists.  */
  445|       |
  446|     48|  if (mpi_test_bit (n, 0))
  ------------------
  |  |  553|     48|#define mpi_test_bit(a,b)      _gcry_mpi_test_bit ((a),(b))
  |  |  ------------------
  |  |  |  Branch (553:32): [True: 48, False: 0]
  |  |  ------------------
  ------------------
  447|     48|    {
  448|     48|      if (a->nlimbs <= n->nlimbs)
  ------------------
  |  Branch (448:11): [True: 48, False: 0]
  ------------------
  449|     48|        {
  450|     48|          ap = mpi_alloc_limb_space (n->nlimbs, _gcry_is_secure (a->d));
  ------------------
  |  |  178|     48|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
  451|     48|          MPN_ZERO (ap, n->nlimbs);
  ------------------
  |  |  112|     48|    do {				  \
  |  |  113|     48|	int  _i;			  \
  |  |  114|    240|	for( _i = 0; _i < (n); _i++ )  \
  |  |  ------------------
  |  |  |  Branch (114:15): [True: 192, False: 48]
  |  |  ------------------
  |  |  115|    192|	    (d)[_i] = 0;		    \
  |  |  116|     48|    } while (0)
  |  |  ------------------
  |  |  |  Branch (116:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  452|     48|          MPN_COPY (ap, a->d, a->nlimbs);
  ------------------
  |  |   90|     48|    do {				\
  |  |   91|     48|	mpi_size_t _i;			\
  |  |   92|    192|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 144, False: 48]
  |  |  ------------------
  |  |   93|    144|	    (d)[_i] = (s)[_i];		\
  |  |   94|     48|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  453|     48|        }
  454|      0|      else
  455|      0|        ap = _gcry_mpih_mod (a->d, a->nlimbs, n->d, n->nlimbs);
  456|       |
  457|     48|      xp = mpih_invm_odd (ap, n->d, n->nlimbs);
  458|     48|      _gcry_mpi_free_limb_space (ap, n->nlimbs);
  459|       |
  460|     48|      if (xp)
  ------------------
  |  Branch (460:11): [True: 48, False: 0]
  ------------------
  461|     48|        {
  462|     48|          _gcry_mpi_assign_limb_space (x, xp, n->nlimbs);
  463|     48|          x->nlimbs = n->nlimbs;
  464|     48|          return 1;
  465|     48|        }
  466|      0|      else
  467|      0|        return 0; /* Inverse does not exists.  */
  468|     48|    }
  469|      0|  else if (!a->sign && !n->sign)
  ------------------
  |  Branch (469:12): [True: 0, False: 0]
  |  Branch (469:24): [True: 0, False: 0]
  ------------------
  470|      0|    {
  471|      0|      unsigned int k = mpi_trailing_zeros (n);
  ------------------
  |  |  217|      0|#define mpi_trailing_zeros(a) _gcry_mpi_trailing_zeros ((a))
  ------------------
  472|      0|      mpi_size_t x1size = ((k + BITS_PER_MPI_LIMB - 1) / BITS_PER_MPI_LIMB);
  ------------------
  |  |   49|      0|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                    mpi_size_t x1size = ((k + BITS_PER_MPI_LIMB - 1) / BITS_PER_MPI_LIMB);
  ------------------
  |  |   49|      0|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  473|      0|      mpi_size_t hsize;
  474|      0|      gcry_mpi_t q;
  475|      0|      mpi_ptr_t x1p, x2p, q_invp, hp, diffp;
  476|      0|      mpi_size_t i;
  477|       |
  478|      0|      if (k == _gcry_mpi_get_nbits (n) - 1)
  ------------------
  |  Branch (478:11): [True: 0, False: 0]
  ------------------
  479|      0|        {
  480|      0|          x1p = mpih_invm_pow2 (a->d, a->nlimbs, k);
  481|       |
  482|      0|          if (x1p)
  ------------------
  |  Branch (482:15): [True: 0, False: 0]
  ------------------
  483|      0|            {
  484|      0|              _gcry_mpi_assign_limb_space (x, x1p, x1size);
  485|      0|              x->nlimbs = x1size;
  486|      0|              return 1;
  487|      0|            }
  488|      0|          else
  489|      0|            return 0; /* Inverse does not exists.  */
  490|      0|        }
  491|       |
  492|       |      /* N can be expressed as P * Q, where P = 2^K.  P and Q are coprime.  */
  493|       |      /*
  494|       |       * Compute X1 = invm (A, P) and X2 = invm (A, Q), and combine
  495|       |       * them by Garner's formula, to get X = invm (A, P*Q).
  496|       |       * A special case of Chinese Remainder Theorem.
  497|       |       */
  498|       |
  499|       |      /* X1 = invm (A, P) */
  500|      0|      x1p = mpih_invm_pow2 (a->d, a->nlimbs, k);
  501|      0|      if (!x1p)
  ------------------
  |  Branch (501:11): [True: 0, False: 0]
  ------------------
  502|      0|        return 0;               /* Inverse does not exists.  */
  503|       |
  504|       |      /* Q = N / P          */
  505|      0|      q = mpi_new (0);
  ------------------
  |  |  491|      0|#define mpi_new(n)             _gcry_mpi_new ((n))
  ------------------
  506|      0|      mpi_rshift (q, n, k);
  ------------------
  |  |  558|      0|#define mpi_rshift(a,b,c)      _gcry_mpi_rshift ((a),(b),(c))
  ------------------
  507|       |
  508|       |      /* X2 = invm (A%Q, Q) */
  509|      0|      ap = _gcry_mpih_mod (a->d, a->nlimbs, q->d, q->nlimbs);
  510|      0|      x2p = mpih_invm_odd (ap, q->d, q->nlimbs);
  511|      0|      _gcry_mpi_free_limb_space (ap, q->nlimbs);
  512|      0|      if (!x2p)
  ------------------
  |  Branch (512:11): [True: 0, False: 0]
  ------------------
  513|      0|        {
  514|      0|          _gcry_mpi_free_limb_space (x1p, x1size);
  515|      0|          mpi_free (q);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  516|      0|          return 0;             /* Inverse does not exists.  */
  517|      0|        }
  518|       |
  519|       |      /* Q_inv = Q^(-1) = invm (Q, P) */
  520|      0|      q_invp = mpih_invm_pow2 (q->d, q->nlimbs, k);
  521|       |
  522|       |      /* H = (X1 - X2) * Q_inv % P */
  523|      0|      diffp = mpi_alloc_limb_space (x1size, _gcry_is_secure (a->d));
  ------------------
  |  |  178|      0|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
  524|      0|      if (x1size >= q->nlimbs)
  ------------------
  |  Branch (524:11): [True: 0, False: 0]
  ------------------
  525|      0|        _gcry_mpih_sub (diffp, x1p, x1size, x2p, q->nlimbs);
  526|      0|      else
  527|      0|	_gcry_mpih_sub_n (diffp, x1p, x2p, x1size);
  528|      0|      _gcry_mpi_free_limb_space (x1p, x1size);
  529|      0|      if ((k % BITS_PER_MPI_LIMB))
  ------------------
  |  |   49|      0|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (529:11): [True: 0, False: 0]
  ------------------
  530|      0|        for (i = k % BITS_PER_MPI_LIMB; i < BITS_PER_MPI_LIMB; i++)
  ------------------
  |  |   49|      0|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      for (i = k % BITS_PER_MPI_LIMB; i < BITS_PER_MPI_LIMB; i++)
  ------------------
  |  |   49|      0|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (530:41): [True: 0, False: 0]
  ------------------
  531|      0|          diffp[k/BITS_PER_MPI_LIMB] &= ~(((mpi_limb_t)1) << i);
  ------------------
  |  |   49|      0|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  532|       |
  533|      0|      hsize = x1size * 2;
  534|      0|      hp = mpi_alloc_limb_space (hsize, _gcry_is_secure (a->d));
  ------------------
  |  |  178|      0|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
  535|      0|      _gcry_mpih_mul_n (hp, diffp, q_invp, x1size);
  536|      0|      _gcry_mpi_free_limb_space (diffp, x1size);
  537|      0|      _gcry_mpi_free_limb_space (q_invp, x1size);
  538|       |
  539|      0|      for (i = x1size; i < hsize; i++)
  ------------------
  |  Branch (539:24): [True: 0, False: 0]
  ------------------
  540|      0|        hp[i] = 0;
  541|      0|      if ((k % BITS_PER_MPI_LIMB))
  ------------------
  |  |   49|      0|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (541:11): [True: 0, False: 0]
  ------------------
  542|      0|        for (i = k % BITS_PER_MPI_LIMB; i < BITS_PER_MPI_LIMB; i++)
  ------------------
  |  |   49|      0|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      for (i = k % BITS_PER_MPI_LIMB; i < BITS_PER_MPI_LIMB; i++)
  ------------------
  |  |   49|      0|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (542:41): [True: 0, False: 0]
  ------------------
  543|      0|          hp[k/BITS_PER_MPI_LIMB] &= ~(((mpi_limb_t)1) << i);
  ------------------
  |  |   49|      0|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  544|       |
  545|      0|      xp = mpi_alloc_limb_space (x1size + q->nlimbs, _gcry_is_secure (a->d));
  ------------------
  |  |  178|      0|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
  546|      0|      if (x1size >= q->nlimbs)
  ------------------
  |  Branch (546:11): [True: 0, False: 0]
  ------------------
  547|      0|        _gcry_mpih_mul (xp, hp, x1size, q->d, q->nlimbs);
  548|      0|      else
  549|      0|        _gcry_mpih_mul (xp, q->d, q->nlimbs, hp, x1size);
  550|       |
  551|      0|      _gcry_mpi_free_limb_space (hp, hsize);
  552|       |
  553|      0|      _gcry_mpih_add (xp, xp, x1size + q->nlimbs, x2p, q->nlimbs);
  554|      0|      _gcry_mpi_free_limb_space (x2p, q->nlimbs);
  555|       |
  556|      0|      _gcry_mpi_assign_limb_space (x, xp, x1size + q->nlimbs);
  557|      0|      x->nlimbs = x1size + q->nlimbs;
  558|       |
  559|      0|      mpi_free (q);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  560|       |
  561|      0|      return 1;
  562|      0|    }
  563|      0|  else
  564|      0|    return mpi_invm_generic (x, a, n);
  565|     48|}
mpi-inv.c:mpih_invm_odd:
   42|     48|{
   43|     48|  int secure;
   44|     48|  unsigned int iterations;
   45|     48|  mpi_ptr_t n1hp;
   46|     48|  mpi_ptr_t bp;
   47|     48|  mpi_ptr_t up, vp;
   48|       |
   49|     48|  secure = _gcry_is_secure (ap);
   50|     48|  up = mpi_alloc_limb_space (nsize, secure);
  ------------------
  |  |  178|     48|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
   51|     48|  MPN_ZERO (up, nsize);
  ------------------
  |  |  112|     48|    do {				  \
  |  |  113|     48|	int  _i;			  \
  |  |  114|    240|	for( _i = 0; _i < (n); _i++ )  \
  |  |  ------------------
  |  |  |  Branch (114:15): [True: 192, False: 48]
  |  |  ------------------
  |  |  115|    192|	    (d)[_i] = 0;		    \
  |  |  116|     48|    } while (0)
  |  |  ------------------
  |  |  |  Branch (116:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
   52|     48|  up[0] = 1;
   53|       |
   54|     48|  vp = mpi_alloc_limb_space (nsize, secure);
  ------------------
  |  |  178|     48|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
   55|     48|  MPN_ZERO (vp, nsize);
  ------------------
  |  |  112|     48|    do {				  \
  |  |  113|     48|	int  _i;			  \
  |  |  114|    240|	for( _i = 0; _i < (n); _i++ )  \
  |  |  ------------------
  |  |  |  Branch (114:15): [True: 192, False: 48]
  |  |  ------------------
  |  |  115|    192|	    (d)[_i] = 0;		    \
  |  |  116|     48|    } while (0)
  |  |  ------------------
  |  |  |  Branch (116:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
   56|       |
   57|     48|  secure = _gcry_is_secure (np);
   58|     48|  bp = mpi_alloc_limb_space (nsize, secure);
  ------------------
  |  |  178|     48|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
   59|     48|  MPN_COPY (bp, np, nsize);
  ------------------
  |  |   90|     48|    do {				\
  |  |   91|     48|	mpi_size_t _i;			\
  |  |   92|    240|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 192, False: 48]
  |  |  ------------------
  |  |   93|    192|	    (d)[_i] = (s)[_i];		\
  |  |   94|     48|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
   60|       |
   61|     48|  n1hp = mpi_alloc_limb_space (nsize, secure);
  ------------------
  |  |  178|     48|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
   62|     48|  MPN_COPY (n1hp, np, nsize);
  ------------------
  |  |   90|     48|    do {				\
  |  |   91|     48|	mpi_size_t _i;			\
  |  |   92|    240|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 192, False: 48]
  |  |  ------------------
  |  |   93|    192|	    (d)[_i] = (s)[_i];		\
  |  |   94|     48|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
   63|     48|  _gcry_mpih_rshift (n1hp, n1hp, nsize, 1);
   64|     48|  _gcry_mpih_add_1 (n1hp, n1hp, nsize, 1);
   65|       |
   66|     48|  iterations = 2 * nsize * BITS_PER_MPI_LIMB;
  ------------------
  |  |   49|     48|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|     48|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|     48|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   67|       |
   68|  24.6k|  while (iterations-- > 0)
  ------------------
  |  Branch (68:10): [True: 24.5k, False: 48]
  ------------------
   69|  24.5k|    {
   70|  24.5k|      mpi_limb_t odd_a, odd_u, underflow, borrow;
   71|       |
   72|  24.5k|      odd_a = ap[0] & 1;
   73|       |
   74|  24.5k|      underflow = mpih_sub_n_cond (ap, ap, bp, nsize, odd_a);
  ------------------
  |  |  265|  24.5k|#define mpih_sub_n_cond(w,u,v,s,o) _gcry_mpih_sub_n_cond ((w),(u),(v),(s),(o))
  ------------------
   75|  24.5k|      mpih_add_n_cond (bp, bp, ap, nsize, underflow);
  ------------------
  |  |  264|  24.5k|#define mpih_add_n_cond(w,u,v,s,o) _gcry_mpih_add_n_cond ((w),(u),(v),(s),(o))
  ------------------
   76|  24.5k|      mpih_abs_cond (ap, ap, nsize, underflow);
  ------------------
  |  |  267|  24.5k|#define mpih_abs_cond(w,u,s,o) _gcry_mpih_abs_cond ((w),(u),(s),(o))
  ------------------
   77|  24.5k|      mpih_swap_cond (up, vp, nsize, underflow);
  ------------------
  |  |  266|  24.5k|#define mpih_swap_cond(u,v,s,o) _gcry_mpih_swap_cond ((u),(v),(s),(o))
  ------------------
   78|       |
   79|  24.5k|      _gcry_mpih_rshift (ap, ap, nsize, 1);
   80|       |
   81|  24.5k|      borrow = mpih_sub_n_cond (up, up, vp, nsize, odd_a);
  ------------------
  |  |  265|  24.5k|#define mpih_sub_n_cond(w,u,v,s,o) _gcry_mpih_sub_n_cond ((w),(u),(v),(s),(o))
  ------------------
   82|  24.5k|      mpih_add_n_cond (up, up, np, nsize, borrow);
  ------------------
  |  |  264|  24.5k|#define mpih_add_n_cond(w,u,v,s,o) _gcry_mpih_add_n_cond ((w),(u),(v),(s),(o))
  ------------------
   83|       |
   84|  24.5k|      odd_u = _gcry_mpih_rshift (up, up, nsize, 1) != 0;
   85|  24.5k|      mpih_add_n_cond (up, up, n1hp, nsize, odd_u);
  ------------------
  |  |  264|  24.5k|#define mpih_add_n_cond(w,u,v,s,o) _gcry_mpih_add_n_cond ((w),(u),(v),(s),(o))
  ------------------
   86|  24.5k|    }
   87|       |
   88|     48|  _gcry_mpi_free_limb_space (n1hp, nsize);
   89|     48|  _gcry_mpi_free_limb_space (up, nsize);
   90|       |
   91|     48|  if (_gcry_mpih_cmp_ui (bp, nsize, 1) == 0)
  ------------------
  |  Branch (91:7): [True: 48, False: 0]
  ------------------
   92|     48|    {
   93|       |      /* Inverse exists.  */
   94|     48|      _gcry_mpi_free_limb_space (bp, nsize);
   95|     48|      return vp;
   96|     48|    }
   97|      0|  else
   98|      0|    {
   99|      0|      _gcry_mpi_free_limb_space (bp, nsize);
  100|      0|      _gcry_mpi_free_limb_space (vp, nsize);
  101|      0|      return NULL;
  102|      0|    }
  103|     48|}

_gcry_mpi_mod:
   48|     16|{
   49|     16|  _gcry_mpi_fdiv_r (rem, dividend, divisor);
   50|     16|}
_gcry_mpi_barrett_free:
   92|     16|{
   93|     16|  if (ctx)
  ------------------
  |  Branch (93:7): [True: 0, False: 16]
  ------------------
   94|      0|    {
   95|      0|      mpi_free (ctx->y);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
   96|      0|      mpi_free (ctx->r1);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
   97|      0|      mpi_free (ctx->r2);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
   98|      0|      if (ctx->r3)
  ------------------
  |  Branch (98:11): [True: 0, False: 0]
  ------------------
   99|      0|        mpi_free (ctx->r3);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  100|      0|      if (ctx->m_copied)
  ------------------
  |  Branch (100:11): [True: 0, False: 0]
  ------------------
  101|      0|        mpi_free (ctx->m);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  102|      0|      xfree (ctx);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  103|      0|    }
  104|     16|}

_gcry_mpi_mul:
  111|   123k|{
  112|   123k|    mpi_size_t usize, vsize, wsize;
  113|   123k|    mpi_ptr_t up, vp, wp;
  114|   123k|    mpi_limb_t cy;
  115|   123k|    int usign, vsign, usecure, vsecure, sign_product;
  116|   123k|    int assign_wp=0;
  117|   123k|    mpi_ptr_t tmp_limb=NULL;
  118|   123k|    unsigned int tmp_limb_nlimbs = 0;
  119|       |
  120|   123k|    if( u->nlimbs < v->nlimbs ) { /* Swap U and V. */
  ------------------
  |  Branch (120:9): [True: 2.83k, False: 120k]
  ------------------
  121|  2.83k|	usize = v->nlimbs;
  122|  2.83k|	usign = v->sign;
  123|  2.83k|	usecure = mpi_is_secure(v);
  ------------------
  |  |  115|  2.83k|#define mpi_is_secure(a)      ((a) && ((a)->flags&1))
  |  |  ------------------
  |  |  |  Branch (115:32): [True: 2.83k, False: 0]
  |  |  |  Branch (115:39): [True: 0, False: 2.83k]
  |  |  ------------------
  ------------------
  124|  2.83k|	up    = v->d;
  125|  2.83k|	vsize = u->nlimbs;
  126|  2.83k|	vsign = u->sign;
  127|  2.83k|	vsecure = mpi_is_secure(u);
  ------------------
  |  |  115|  2.83k|#define mpi_is_secure(a)      ((a) && ((a)->flags&1))
  |  |  ------------------
  |  |  |  Branch (115:32): [True: 2.83k, False: 0]
  |  |  |  Branch (115:39): [True: 0, False: 2.83k]
  |  |  ------------------
  ------------------
  128|  2.83k|	vp    = u->d;
  129|  2.83k|    }
  130|   120k|    else {
  131|   120k|	usize = u->nlimbs;
  132|   120k|	usign = u->sign;
  133|   120k|	usecure = mpi_is_secure(u);
  ------------------
  |  |  115|   120k|#define mpi_is_secure(a)      ((a) && ((a)->flags&1))
  |  |  ------------------
  |  |  |  Branch (115:32): [True: 120k, False: 0]
  |  |  |  Branch (115:39): [True: 0, False: 120k]
  |  |  ------------------
  ------------------
  134|   120k|	up    = u->d;
  135|   120k|	vsize = v->nlimbs;
  136|   120k|	vsign = v->sign;
  137|   120k|	vsecure = mpi_is_secure(v);
  ------------------
  |  |  115|   120k|#define mpi_is_secure(a)      ((a) && ((a)->flags&1))
  |  |  ------------------
  |  |  |  Branch (115:32): [True: 120k, False: 0]
  |  |  |  Branch (115:39): [True: 0, False: 120k]
  |  |  ------------------
  ------------------
  138|   120k|	vp    = v->d;
  139|   120k|    }
  140|   123k|    sign_product = usign ^ vsign;
  141|   123k|    wp = w->d;
  142|       |
  143|       |    /* Ensure W has space enough to store the result.  */
  144|   123k|    wsize = usize + vsize;
  145|   123k|    if ( !mpi_is_secure (w) && (mpi_is_secure (u) || mpi_is_secure (v)) ) {
  ------------------
  |  |  115|   247k|#define mpi_is_secure(a)      ((a) && ((a)->flags&1))
  |  |  ------------------
  |  |  |  Branch (115:32): [True: 123k, False: 0]
  |  |  |  Branch (115:39): [True: 0, False: 123k]
  |  |  ------------------
  ------------------
                  if ( !mpi_is_secure (w) && (mpi_is_secure (u) || mpi_is_secure (v)) ) {
  ------------------
  |  |  115|   247k|#define mpi_is_secure(a)      ((a) && ((a)->flags&1))
  |  |  ------------------
  |  |  |  Branch (115:32): [True: 123k, False: 0]
  |  |  |  Branch (115:39): [True: 0, False: 123k]
  |  |  ------------------
  ------------------
                  if ( !mpi_is_secure (w) && (mpi_is_secure (u) || mpi_is_secure (v)) ) {
  ------------------
  |  |  115|   123k|#define mpi_is_secure(a)      ((a) && ((a)->flags&1))
  |  |  ------------------
  |  |  |  Branch (115:32): [True: 123k, False: 0]
  |  |  |  Branch (115:39): [True: 0, False: 123k]
  |  |  ------------------
  ------------------
  146|       |        /* w is not allocated in secure space but u or v is.  To make sure
  147|       |         * that no temporray results are stored in w, we temporary use
  148|       |         * a newly allocated limb space for w */
  149|      0|        wp = mpi_alloc_limb_space( wsize, 1 );
  ------------------
  |  |  178|      0|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
  150|      0|        assign_wp = 2; /* mark it as 2 so that we can later copy it back to
  151|       |                        * mormal memory */
  152|      0|    }
  153|   123k|    else if( w->alloced < wsize ) {
  ------------------
  |  Branch (153:14): [True: 336, False: 123k]
  ------------------
  154|    336|	if( wp == up || wp == vp ) {
  ------------------
  |  Branch (154:6): [True: 80, False: 256]
  |  Branch (154:18): [True: 32, False: 224]
  ------------------
  155|    112|	    wp = mpi_alloc_limb_space( wsize, mpi_is_secure(w) );
  ------------------
  |  |  178|    224|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  |  |  ------------------
  |  |  |  Branch (178:68): [True: 112, False: 0]
  |  |  |  Branch (178:68): [True: 0, False: 112]
  |  |  ------------------
  ------------------
  156|    112|	    assign_wp = 1;
  157|    112|	}
  158|    224|	else {
  159|    224|	    mpi_resize(w, wsize );
  ------------------
  |  |  100|    224|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  ------------------
  160|    224|	    wp = w->d;
  161|    224|	}
  162|    336|    }
  163|   123k|    else { /* Make U and V not overlap with W.	*/
  164|   123k|	if( wp == up ) {
  ------------------
  |  Branch (164:6): [True: 60.5k, False: 62.8k]
  ------------------
  165|       |	    /* W and U are identical.  Allocate temporary space for U.	*/
  166|  60.5k|            tmp_limb_nlimbs = usize;
  167|  60.5k|	    up = tmp_limb = mpi_alloc_limb_space( usize, usecure  );
  ------------------
  |  |  178|  60.5k|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
  168|       |	    /* Is V identical too?  Keep it identical with U.  */
  169|  60.5k|	    if( wp == vp )
  ------------------
  |  Branch (169:10): [True: 8.12k, False: 52.4k]
  ------------------
  170|  8.12k|		vp = up;
  171|       |	    /* Copy to the temporary space.  */
  172|  60.5k|	    MPN_COPY( up, wp, usize );
  ------------------
  |  |   90|  60.5k|    do {				\
  |  |   91|  60.5k|	mpi_size_t _i;			\
  |  |   92|   302k|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 242k, False: 60.5k]
  |  |  ------------------
  |  |   93|   242k|	    (d)[_i] = (s)[_i];		\
  |  |   94|  60.5k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  173|  60.5k|	}
  174|  62.8k|	else if( wp == vp ) {
  ------------------
  |  Branch (174:11): [True: 10.9k, False: 51.9k]
  ------------------
  175|       |	    /* W and V are identical.  Allocate temporary space for V.	*/
  176|  10.9k|            tmp_limb_nlimbs = vsize;
  177|  10.9k|	    vp = tmp_limb = mpi_alloc_limb_space( vsize, vsecure );
  ------------------
  |  |  178|  10.9k|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
  178|       |	    /* Copy to the temporary space.  */
  179|  10.9k|	    MPN_COPY( vp, wp, vsize );
  ------------------
  |  |   90|  10.9k|    do {				\
  |  |   91|  10.9k|	mpi_size_t _i;			\
  |  |   92|  46.1k|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 35.2k, False: 10.9k]
  |  |  ------------------
  |  |   93|  35.2k|	    (d)[_i] = (s)[_i];		\
  |  |   94|  10.9k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  180|  10.9k|	}
  181|   123k|    }
  182|       |
  183|   123k|    if( !vsize )
  ------------------
  |  Branch (183:9): [True: 0, False: 123k]
  ------------------
  184|      0|	wsize = 0;
  185|   123k|    else {
  186|   123k|	cy = _gcry_mpih_mul( wp, up, usize, vp, vsize );
  187|   123k|	wsize -= cy? 0:1;
  ------------------
  |  Branch (187:11): [True: 112k, False: 11.3k]
  ------------------
  188|   123k|    }
  189|       |
  190|   123k|    if( assign_wp ) {
  ------------------
  |  Branch (190:9): [True: 112, False: 123k]
  ------------------
  191|    112|        if (assign_wp == 2) {
  ------------------
  |  Branch (191:13): [True: 0, False: 112]
  ------------------
  192|       |            /* copy the temp wp from secure memory back to normal memory */
  193|      0|	    mpi_ptr_t tmp_wp = mpi_alloc_limb_space (wsize, 0);
  ------------------
  |  |  178|      0|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
  194|      0|	    MPN_COPY (tmp_wp, wp, wsize);
  ------------------
  |  |   90|      0|    do {				\
  |  |   91|      0|	mpi_size_t _i;			\
  |  |   92|      0|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 0, False: 0]
  |  |  ------------------
  |  |   93|      0|	    (d)[_i] = (s)[_i];		\
  |  |   94|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  195|      0|            _gcry_mpi_free_limb_space (wp, 0);
  196|      0|            wp = tmp_wp;
  197|      0|        }
  198|    112|	_gcry_mpi_assign_limb_space( w, wp, wsize );
  199|    112|    }
  200|   123k|    w->nlimbs = wsize;
  201|   123k|    w->sign = sign_product;
  202|   123k|    if( tmp_limb )
  ------------------
  |  Branch (202:9): [True: 71.4k, False: 52.2k]
  ------------------
  203|  71.4k|	_gcry_mpi_free_limb_space (tmp_limb, tmp_limb_nlimbs);
  204|   123k|}
_gcry_mpi_mulm:
  209|     32|{
  210|     32|  mpi_mul (w, u, v);
  ------------------
  |  |  523|     32|#define mpi_mul(w,u,v)         _gcry_mpi_mul ((w),(u),(v))
  ------------------
  211|     32|  _gcry_mpi_tdiv_r (w, w, m);
  212|     32|}

_gcry_mpi_powm:
  407|  8.57k|{
  408|       |  /* Pointer to the limbs of the arguments, their size and signs. */
  409|  8.57k|  mpi_ptr_t  rp, ep, mp, bp;
  410|  8.57k|  mpi_size_t esize, msize, bsize, rsize;
  411|  8.57k|  int               msign, bsign, rsign;
  412|       |  /* Flags telling the secure allocation status of the arguments.  */
  413|  8.57k|  int        esec,  msec,  bsec;
  414|       |  /* Size of the result including space for temporary values.  */
  415|  8.57k|  mpi_size_t size;
  416|       |  /* Helper.  */
  417|  8.57k|  int mod_shift_cnt;
  418|  8.57k|  int negative_result;
  419|  8.57k|  mpi_ptr_t mp_marker = NULL;
  420|  8.57k|  mpi_ptr_t bp_marker = NULL;
  421|  8.57k|  mpi_ptr_t ep_marker = NULL;
  422|  8.57k|  mpi_ptr_t xp_marker = NULL;
  423|  8.57k|  unsigned int mp_nlimbs = 0;
  424|  8.57k|  unsigned int bp_nlimbs = 0;
  425|  8.57k|  unsigned int ep_nlimbs = 0;
  426|  8.57k|  unsigned int xp_nlimbs = 0;
  427|  8.57k|  mpi_ptr_t precomp[SIZE_PRECOMP]; /* Pre-computed array: BASE^1, ^3, ^5, ... */
  428|  8.57k|  mpi_size_t precomp_size[SIZE_PRECOMP];
  429|  8.57k|  mpi_size_t W;
  430|  8.57k|  mpi_ptr_t base_u;
  431|  8.57k|  mpi_size_t base_u_size;
  432|  8.57k|  mpi_size_t max_u_size;
  433|       |
  434|  8.57k|  esize = expo->nlimbs;
  435|  8.57k|  msize = mod->nlimbs;
  436|  8.57k|  size = 2 * msize;
  437|  8.57k|  msign = mod->sign;
  438|       |
  439|  8.57k|  ep = expo->d;
  440|  8.57k|  MPN_NORMALIZE(ep, esize);
  ------------------
  |  |  119|  8.57k|    do {		       \
  |  |  120|  8.57k|	while( (n) > 0 ) {     \
  |  |  ------------------
  |  |  |  Branch (120:9): [True: 8.57k, False: 0]
  |  |  ------------------
  |  |  121|  8.57k|	    if( (d)[(n)-1] ) \
  |  |  ------------------
  |  |  |  Branch (121:10): [True: 8.57k, False: 0]
  |  |  ------------------
  |  |  122|  8.57k|		break;	       \
  |  |  123|  8.57k|	    (n)--;	       \
  |  |  124|      0|	}		       \
  |  |  125|  8.57k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (125:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  441|       |
  442|  8.57k|  if (esize * BITS_PER_MPI_LIMB > 512)
  ------------------
  |  |   49|  8.57k|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|  8.57k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|  8.57k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (442:7): [True: 0, False: 8.57k]
  ------------------
  443|      0|    W = 5;
  444|  8.57k|  else if (esize * BITS_PER_MPI_LIMB > 256)
  ------------------
  |  |   49|  8.57k|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|  8.57k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|  8.57k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (444:12): [True: 0, False: 8.57k]
  ------------------
  445|      0|    W = 4;
  446|  8.57k|  else if (esize * BITS_PER_MPI_LIMB > 128)
  ------------------
  |  |   49|  8.57k|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|  8.57k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|  8.57k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (446:12): [True: 0, False: 8.57k]
  ------------------
  447|      0|    W = 3;
  448|  8.57k|  else if (esize * BITS_PER_MPI_LIMB > 64)
  ------------------
  |  |   49|  8.57k|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|  8.57k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|  8.57k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (448:12): [True: 0, False: 8.57k]
  ------------------
  449|      0|    W = 2;
  450|  8.57k|  else
  451|  8.57k|    W = 1;
  452|       |
  453|  8.57k|  esec = mpi_is_secure(expo);
  ------------------
  |  |  115|  8.57k|#define mpi_is_secure(a)      ((a) && ((a)->flags&1))
  |  |  ------------------
  |  |  |  Branch (115:32): [True: 8.57k, False: 0]
  |  |  |  Branch (115:39): [True: 0, False: 8.57k]
  |  |  ------------------
  ------------------
  454|  8.57k|  msec = mpi_is_secure(mod);
  ------------------
  |  |  115|  8.57k|#define mpi_is_secure(a)      ((a) && ((a)->flags&1))
  |  |  ------------------
  |  |  |  Branch (115:32): [True: 8.57k, False: 0]
  |  |  |  Branch (115:39): [True: 0, False: 8.57k]
  |  |  ------------------
  ------------------
  455|  8.57k|  bsec = mpi_is_secure(base);
  ------------------
  |  |  115|  8.57k|#define mpi_is_secure(a)      ((a) && ((a)->flags&1))
  |  |  ------------------
  |  |  |  Branch (115:32): [True: 8.57k, False: 0]
  |  |  |  Branch (115:39): [True: 0, False: 8.57k]
  |  |  ------------------
  ------------------
  456|       |
  457|  8.57k|  rp = res->d;
  458|       |
  459|  8.57k|  if (!msize)
  ------------------
  |  Branch (459:7): [True: 0, False: 8.57k]
  ------------------
  460|      0|    _gcry_divide_by_zero();
  461|       |
  462|  8.57k|  if (!esize)
  ------------------
  |  Branch (462:7): [True: 0, False: 8.57k]
  ------------------
  463|      0|    {
  464|       |      /* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0 depending
  465|       |         on if MOD equals 1.  */
  466|      0|      res->nlimbs = (msize == 1 && mod->d[0] == 1) ? 0 : 1;
  ------------------
  |  Branch (466:22): [True: 0, False: 0]
  |  Branch (466:36): [True: 0, False: 0]
  ------------------
  467|      0|      if (res->nlimbs)
  ------------------
  |  Branch (467:11): [True: 0, False: 0]
  ------------------
  468|      0|        {
  469|      0|          RESIZE_IF_NEEDED (res, 1);
  ------------------
  |  |   78|      0|    do {			   \
  |  |   79|      0|	if( (a)->alloced < (b) )   \
  |  |  ------------------
  |  |  |  Branch (79:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   80|      0|	    mpi_resize((a), (b));  \
  |  |  ------------------
  |  |  |  |  100|      0|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  |  |  ------------------
  |  |   81|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (81:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  470|      0|          rp = res->d;
  471|      0|          rp[0] = 1;
  472|      0|        }
  473|      0|      res->sign = 0;
  474|      0|      goto leave;
  475|      0|    }
  476|       |
  477|       |  /* Normalize MOD (i.e. make its most significant bit set) as
  478|       |     required by mpn_divrem.  This will make the intermediate values
  479|       |     in the calculation slightly larger, but the correct result is
  480|       |     obtained after a final reduction using the original MOD value. */
  481|  8.57k|  mp_nlimbs = msec? msize:0;
  ------------------
  |  Branch (481:15): [True: 0, False: 8.57k]
  ------------------
  482|  8.57k|  mp = mp_marker = mpi_alloc_limb_space(msize, msec);
  ------------------
  |  |  178|  8.57k|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
  483|  8.57k|  count_leading_zeros (mod_shift_cnt, mod->d[msize-1]);
  ------------------
  |  |  617|  8.57k|  do {                                                                  \
  |  |  618|  8.57k|    UDItype __cbtmp;                                                    \
  |  |  619|  8.57k|    __asm__ ("bsrq %1,%0"                                               \
  |  |  620|  8.57k|             : "=r" (__cbtmp) : "rm" ((UDItype)(x))                     \
  |  |  621|  8.57k|             __CLOBBER_CC);                                             \
  |  |  622|  8.57k|    (count) = __cbtmp ^ 63;                                             \
  |  |  623|  8.57k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (623:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
  484|  8.57k|  if (mod_shift_cnt)
  ------------------
  |  Branch (484:7): [True: 0, False: 8.57k]
  ------------------
  485|      0|    _gcry_mpih_lshift (mp, mod->d, msize, mod_shift_cnt);
  486|  8.57k|  else
  487|  8.57k|    MPN_COPY( mp, mod->d, msize );
  ------------------
  |  |   90|  8.57k|    do {				\
  |  |   91|  8.57k|	mpi_size_t _i;			\
  |  |   92|  43.2k|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 34.7k, False: 8.57k]
  |  |  ------------------
  |  |   93|  34.7k|	    (d)[_i] = (s)[_i];		\
  |  |   94|  8.57k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  488|       |
  489|  8.57k|  bsize = base->nlimbs;
  490|  8.57k|  bsign = base->sign;
  491|  8.57k|  if (bsize > msize)
  ------------------
  |  Branch (491:7): [True: 0, False: 8.57k]
  ------------------
  492|      0|    {
  493|       |      /* The base is larger than the module.  Reduce it.
  494|       |
  495|       |         Allocate (BSIZE + 1) with space for remainder and quotient.
  496|       |         (The quotient is (bsize - msize + 1) limbs.)  */
  497|      0|      bp_nlimbs = bsec ? (bsize + 1):0;
  ------------------
  |  Branch (497:19): [True: 0, False: 0]
  ------------------
  498|      0|      bp = bp_marker = mpi_alloc_limb_space( bsize + 1, bsec );
  ------------------
  |  |  178|      0|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
  499|      0|      MPN_COPY ( bp, base->d, bsize );
  ------------------
  |  |   90|      0|    do {				\
  |  |   91|      0|	mpi_size_t _i;			\
  |  |   92|      0|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 0, False: 0]
  |  |  ------------------
  |  |   93|      0|	    (d)[_i] = (s)[_i];		\
  |  |   94|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  500|       |      /* We don't care about the quotient, store it above the
  501|       |       * remainder, at BP + MSIZE.  */
  502|      0|      _gcry_mpih_divrem( bp + msize, 0, bp, bsize, mp, msize );
  503|      0|      bsize = msize;
  504|       |      /* Canonicalize the base, since we are going to multiply with it
  505|       |         quite a few times.  */
  506|      0|      MPN_NORMALIZE( bp, bsize );
  ------------------
  |  |  119|      0|    do {		       \
  |  |  120|      0|	while( (n) > 0 ) {     \
  |  |  ------------------
  |  |  |  Branch (120:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  121|      0|	    if( (d)[(n)-1] ) \
  |  |  ------------------
  |  |  |  Branch (121:10): [True: 0, False: 0]
  |  |  ------------------
  |  |  122|      0|		break;	       \
  |  |  123|      0|	    (n)--;	       \
  |  |  124|      0|	}		       \
  |  |  125|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (125:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  507|      0|    }
  508|  8.57k|  else
  509|  8.57k|    bp = base->d;
  510|       |
  511|  8.57k|  if (!bsize)
  ------------------
  |  Branch (511:7): [True: 0, False: 8.57k]
  ------------------
  512|      0|    {
  513|      0|      res->nlimbs = 0;
  514|      0|      res->sign = 0;
  515|      0|      goto leave;
  516|      0|    }
  517|       |
  518|       |
  519|       |  /* Make BASE, EXPO not overlap with RES.  We don't need to check MOD
  520|       |     because that has already been copied to the MP var.  */
  521|  8.57k|  if ( rp == bp )
  ------------------
  |  Branch (521:8): [True: 0, False: 8.57k]
  ------------------
  522|      0|    {
  523|       |      /* RES and BASE are identical.  Allocate temp. space for BASE.  */
  524|      0|      gcry_assert (!bp_marker);
  ------------------
  |  |  188|      0|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|      0|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|      0|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
  525|      0|      bp_nlimbs = bsec? bsize:0;
  ------------------
  |  Branch (525:19): [True: 0, False: 0]
  ------------------
  526|      0|      bp = bp_marker = mpi_alloc_limb_space( bsize, bsec );
  ------------------
  |  |  178|      0|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
  527|      0|      MPN_COPY(bp, rp, bsize);
  ------------------
  |  |   90|      0|    do {				\
  |  |   91|      0|	mpi_size_t _i;			\
  |  |   92|      0|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 0, False: 0]
  |  |  ------------------
  |  |   93|      0|	    (d)[_i] = (s)[_i];		\
  |  |   94|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  528|      0|    }
  529|  8.57k|  if ( rp == ep )
  ------------------
  |  Branch (529:8): [True: 0, False: 8.57k]
  ------------------
  530|      0|    {
  531|       |      /* RES and EXPO are identical.  Allocate temp. space for EXPO.  */
  532|      0|      ep_nlimbs = esec? esize:0;
  ------------------
  |  Branch (532:19): [True: 0, False: 0]
  ------------------
  533|      0|      ep = ep_marker = mpi_alloc_limb_space( esize, esec );
  ------------------
  |  |  178|      0|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
  534|      0|      MPN_COPY(ep, rp, esize);
  ------------------
  |  |   90|      0|    do {				\
  |  |   91|      0|	mpi_size_t _i;			\
  |  |   92|      0|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 0, False: 0]
  |  |  ------------------
  |  |   93|      0|	    (d)[_i] = (s)[_i];		\
  |  |   94|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  535|      0|    }
  536|       |
  537|       |  /* Copy base to the result.  */
  538|  8.57k|  if (res->alloced < size)
  ------------------
  |  Branch (538:7): [True: 31, False: 8.54k]
  ------------------
  539|     31|    {
  540|     31|      mpi_resize (res, size);
  ------------------
  |  |  100|     31|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  ------------------
  541|     31|      rp = res->d;
  542|     31|    }
  543|       |
  544|       |  /* Main processing.  */
  545|  8.57k|  {
  546|  8.57k|    mpi_size_t i, j, k;
  547|  8.57k|    mpi_ptr_t xp;
  548|  8.57k|    mpi_size_t xsize = 0;
  549|  8.57k|    int c;
  550|  8.57k|    mpi_limb_t e;
  551|  8.57k|    mpi_limb_t carry_limb;
  552|  8.57k|    struct karatsuba_ctx karactx;
  553|  8.57k|    mpi_ptr_t tp;
  554|       |
  555|  8.57k|    xp_nlimbs = msec? size:0;
  ------------------
  |  Branch (555:17): [True: 0, False: 8.57k]
  ------------------
  556|  8.57k|    xp = xp_marker = mpi_alloc_limb_space( size, msec );
  ------------------
  |  |  178|  8.57k|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
  557|       |
  558|  8.57k|    memset( &karactx, 0, sizeof karactx );
  559|  8.57k|    negative_result = (ep[0] & 1) && bsign;
  ------------------
  |  Branch (559:23): [True: 8.57k, False: 0]
  |  Branch (559:38): [True: 0, False: 8.57k]
  ------------------
  560|       |
  561|       |    /* Precompute PRECOMP[], BASE^(2 * i + 1), BASE^1, ^3, ^5, ... */
  562|  8.57k|    if (W > 1)                  /* X := BASE^2 */
  ------------------
  |  Branch (562:9): [True: 0, False: 8.57k]
  ------------------
  563|      0|      mul_mod (xp, &xsize, bp, bsize, bp, bsize, mp, msize, &karactx);
  564|  8.57k|    base_u = precomp[0] = mpi_alloc_limb_space (bsize, esec);
  ------------------
  |  |  178|  8.57k|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
  565|  8.57k|    base_u_size = max_u_size = precomp_size[0] = bsize;
  566|  8.57k|    MPN_COPY (precomp[0], bp, bsize);
  ------------------
  |  |   90|  8.57k|    do {				\
  |  |   91|  8.57k|	mpi_size_t _i;			\
  |  |   92|  34.7k|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 26.2k, False: 8.57k]
  |  |  ------------------
  |  |   93|  26.2k|	    (d)[_i] = (s)[_i];		\
  |  |   94|  8.57k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  567|  8.57k|    for (i = 1; i < (1 << (W - 1)); i++)
  ------------------
  |  Branch (567:17): [True: 0, False: 8.57k]
  ------------------
  568|      0|      {                         /* PRECOMP[i] = BASE^(2 * i + 1) */
  569|      0|        if (xsize >= base_u_size)
  ------------------
  |  Branch (569:13): [True: 0, False: 0]
  ------------------
  570|      0|          mul_mod (rp, &rsize, xp, xsize, base_u, base_u_size,
  571|      0|                   mp, msize, &karactx);
  572|      0|        else
  573|      0|          mul_mod (rp, &rsize, base_u, base_u_size, xp, xsize,
  574|      0|                   mp, msize, &karactx);
  575|      0|        base_u = precomp[i] = mpi_alloc_limb_space (rsize, esec);
  ------------------
  |  |  178|      0|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
  576|      0|        base_u_size = precomp_size[i] = rsize;
  577|      0|        if (max_u_size < base_u_size)
  ------------------
  |  Branch (577:13): [True: 0, False: 0]
  ------------------
  578|      0|          max_u_size = base_u_size;
  579|      0|        MPN_COPY (precomp[i], rp, rsize);
  ------------------
  |  |   90|      0|    do {				\
  |  |   91|      0|	mpi_size_t _i;			\
  |  |   92|      0|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 0, False: 0]
  |  |  ------------------
  |  |   93|      0|	    (d)[_i] = (s)[_i];		\
  |  |   94|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  580|      0|      }
  581|       |
  582|  8.57k|    if (msize > max_u_size)
  ------------------
  |  Branch (582:9): [True: 2.83k, False: 5.74k]
  ------------------
  583|  2.83k|      max_u_size = msize;
  584|  8.57k|    base_u = mpi_alloc_limb_space (max_u_size, esec);
  ------------------
  |  |  178|  8.57k|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
  585|  8.57k|    MPN_ZERO (base_u, max_u_size);
  ------------------
  |  |  112|  8.57k|    do {				  \
  |  |  113|  8.57k|	int  _i;			  \
  |  |  114|  43.2k|	for( _i = 0; _i < (n); _i++ )  \
  |  |  ------------------
  |  |  |  Branch (114:15): [True: 34.7k, False: 8.57k]
  |  |  ------------------
  |  |  115|  34.7k|	    (d)[_i] = 0;		    \
  |  |  116|  8.57k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (116:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  586|       |
  587|  8.57k|    i = esize - 1;
  588|       |
  589|       |    /* Main loop.
  590|       |
  591|       |       Make the result be pointed to alternately by XP and RP.  This
  592|       |       helps us avoid block copying, which would otherwise be
  593|       |       necessary with the overlap restrictions of
  594|       |       _gcry_mpih_divmod. With 50% probability the result after this
  595|       |       loop will be in the area originally pointed by RP (==RES->d),
  596|       |       and with 50% probability in the area originally pointed to by XP. */
  597|  8.57k|    rsign = 0;
  598|  8.57k|    if (W == 1)
  ------------------
  |  Branch (598:9): [True: 8.57k, False: 0]
  ------------------
  599|  8.57k|      {
  600|  8.57k|        rsize = bsize;
  601|  8.57k|      }
  602|      0|    else
  603|      0|      {
  604|      0|        rsize = msize;
  605|      0|        MPN_ZERO (rp, rsize);
  ------------------
  |  |  112|      0|    do {				  \
  |  |  113|      0|	int  _i;			  \
  |  |  114|      0|	for( _i = 0; _i < (n); _i++ )  \
  |  |  ------------------
  |  |  |  Branch (114:15): [True: 0, False: 0]
  |  |  ------------------
  |  |  115|      0|	    (d)[_i] = 0;		    \
  |  |  116|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (116:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  606|      0|      }
  607|  8.57k|    MPN_COPY ( rp, bp, bsize );
  ------------------
  |  |   90|  8.57k|    do {				\
  |  |   91|  8.57k|	mpi_size_t _i;			\
  |  |   92|  34.7k|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 26.2k, False: 8.57k]
  |  |  ------------------
  |  |   93|  26.2k|	    (d)[_i] = (s)[_i];		\
  |  |   94|  8.57k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  608|       |
  609|  8.57k|    e = ep[i];
  610|  8.57k|    count_leading_zeros (c, e);
  ------------------
  |  |  617|  8.57k|  do {                                                                  \
  |  |  618|  8.57k|    UDItype __cbtmp;                                                    \
  |  |  619|  8.57k|    __asm__ ("bsrq %1,%0"                                               \
  |  |  620|  8.57k|             : "=r" (__cbtmp) : "rm" ((UDItype)(x))                     \
  |  |  621|  8.57k|             __CLOBBER_CC);                                             \
  |  |  622|  8.57k|    (count) = __cbtmp ^ 63;                                             \
  |  |  623|  8.57k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (623:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
  611|  8.57k|    e = (e << c) << 1;
  612|  8.57k|    c = BITS_PER_MPI_LIMB - 1 - c;
  ------------------
  |  |   49|  8.57k|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|  8.57k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|  8.57k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  613|       |
  614|  8.57k|    j = 0;
  615|       |
  616|  8.57k|    for (;;)
  617|  17.1k|      if (e == 0)
  ------------------
  |  Branch (617:11): [True: 8.57k, False: 8.57k]
  ------------------
  618|  8.57k|        {
  619|  8.57k|          j += c;
  620|  8.57k|          if ( --i < 0 )
  ------------------
  |  Branch (620:16): [True: 8.57k, False: 0]
  ------------------
  621|  8.57k|            break;
  622|       |
  623|      0|          e = ep[i];
  624|      0|          c = BITS_PER_MPI_LIMB;
  ------------------
  |  |   49|      0|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  625|      0|        }
  626|  8.57k|      else
  627|  8.57k|        {
  628|  8.57k|          int c0;
  629|  8.57k|          mpi_limb_t e0;
  630|  8.57k|          struct gcry_mpi w, u;
  631|  8.57k|          w.sign = u.sign = 0;
  632|  8.57k|          w.flags = u.flags = 0;
  633|  8.57k|          w.d = base_u;
  634|       |
  635|  8.57k|          count_leading_zeros (c0, e);
  ------------------
  |  |  617|  8.57k|  do {                                                                  \
  |  |  618|  8.57k|    UDItype __cbtmp;                                                    \
  |  |  619|  8.57k|    __asm__ ("bsrq %1,%0"                                               \
  |  |  620|  8.57k|             : "=r" (__cbtmp) : "rm" ((UDItype)(x))                     \
  |  |  621|  8.57k|             __CLOBBER_CC);                                             \
  |  |  622|  8.57k|    (count) = __cbtmp ^ 63;                                             \
  |  |  623|  8.57k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (623:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
  636|  8.57k|          e = (e << c0);
  637|  8.57k|          c -= c0;
  638|  8.57k|          j += c0;
  639|       |
  640|  8.57k|          e0 = (e >> (BITS_PER_MPI_LIMB - W));
  ------------------
  |  |   49|  8.57k|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|  8.57k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|  8.57k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  641|  8.57k|          if (c >= W)
  ------------------
  |  Branch (641:15): [True: 8.57k, False: 0]
  ------------------
  642|  8.57k|            c0 = 0;
  643|      0|          else
  644|      0|            {
  645|      0|              if ( --i < 0 )
  ------------------
  |  Branch (645:20): [True: 0, False: 0]
  ------------------
  646|      0|                {
  647|      0|                  e0 = (e >> (BITS_PER_MPI_LIMB - c));
  ------------------
  |  |   49|      0|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  648|      0|                  j += c - W;
  649|      0|                  goto last_step;
  650|      0|                }
  651|      0|              else
  652|      0|                {
  653|      0|                  c0 = c;
  654|      0|                  e = ep[i];
  655|      0|                  c = BITS_PER_MPI_LIMB;
  ------------------
  |  |   49|      0|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  656|      0|                  e0 |= (e >> (BITS_PER_MPI_LIMB - (W - c0)));
  ------------------
  |  |   49|      0|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  657|      0|                }
  658|      0|            }
  659|       |
  660|  8.57k|          e = e << (W - c0);
  661|  8.57k|          c -= (W - c0);
  662|       |
  663|  8.57k|        last_step:
  664|  8.57k|          count_trailing_zeros (c0, e0);
  ------------------
  |  |  625|  8.57k|  do {                                                                  \
  |  |  626|  8.57k|    UDItype __cbtmp;                                                    \
  |  |  627|  8.57k|    __asm__ ("rep;bsfq %1,%0"                                           \
  |  |  628|  8.57k|             : "=r" (__cbtmp) : "rm" ((UDItype)(x))                     \
  |  |  629|  8.57k|             __CLOBBER_CC);                                             \
  |  |  630|  8.57k|    (count) = __cbtmp;                                                  \
  |  |  631|  8.57k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (631:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
  665|  8.57k|          e0 = (e0 >> c0) >> 1;
  666|       |
  667|  25.9k|          for (j += W - c0; j >= 0; j--)
  ------------------
  |  Branch (667:29): [True: 17.3k, False: 8.57k]
  ------------------
  668|  17.3k|            {
  669|       |
  670|       |              /*
  671|       |               *  base_u <= precomp[e0]
  672|       |               *  base_u_size <= precomp_size[e0]
  673|       |               */
  674|  17.3k|              base_u_size = 0;
  675|  34.7k|              for (k = 0; k < (1<< (W - 1)); k++)
  ------------------
  |  Branch (675:27): [True: 17.3k, False: 17.3k]
  ------------------
  676|  17.3k|                {
  677|  17.3k|                  w.alloced = w.nlimbs = precomp_size[k];
  678|  17.3k|                  u.alloced = u.nlimbs = precomp_size[k];
  679|  17.3k|                  u.d = precomp[k];
  680|       |
  681|  17.3k|                  mpi_set_cond (&w, &u, k == e0);
  ------------------
  |  |  122|  17.3k|#define mpi_set_cond(w,u,set)  _gcry_mpi_set_cond ((w),(u),(set))
  ------------------
  682|  17.3k|                  base_u_size |= ( precomp_size[k] & (0UL - (k == e0)) );
  683|  17.3k|                }
  684|       |
  685|  17.3k|              w.alloced = w.nlimbs = rsize;
  686|  17.3k|              u.alloced = u.nlimbs = rsize;
  687|  17.3k|              u.d = rp;
  688|  17.3k|              mpi_set_cond (&w, &u, j != 0);
  ------------------
  |  |  122|  17.3k|#define mpi_set_cond(w,u,set)  _gcry_mpi_set_cond ((w),(u),(set))
  ------------------
  689|  17.3k|              base_u_size ^= ((base_u_size ^ rsize)  & (0UL - (j != 0)));
  690|       |
  691|  17.3k|              mul_mod (xp, &xsize, rp, rsize, base_u, base_u_size,
  692|  17.3k|                       mp, msize, &karactx);
  693|  17.3k|              tp = rp; rp = xp; xp = tp;
  694|  17.3k|              rsize = xsize;
  695|  17.3k|            }
  696|       |
  697|  8.57k|          j = c0;
  698|  8.57k|          if ( i < 0 )
  ------------------
  |  Branch (698:16): [True: 0, False: 8.57k]
  ------------------
  699|      0|            break;
  700|  8.57k|        }
  701|       |
  702|  8.57k|    while (j--)
  ------------------
  |  Branch (702:12): [True: 0, False: 8.57k]
  ------------------
  703|      0|      {
  704|      0|        mul_mod (xp, &xsize, rp, rsize, rp, rsize, mp, msize, &karactx);
  705|      0|        tp = rp; rp = xp; xp = tp;
  706|      0|        rsize = xsize;
  707|      0|      }
  708|       |
  709|       |    /* We shifted MOD, the modulo reduction argument, left
  710|       |       MOD_SHIFT_CNT steps.  Adjust the result by reducing it with the
  711|       |       original MOD.
  712|       |
  713|       |       Also make sure the result is put in RES->d (where it already
  714|       |       might be, see above).  */
  715|  8.57k|    if ( mod_shift_cnt )
  ------------------
  |  Branch (715:10): [True: 0, False: 8.57k]
  ------------------
  716|      0|      {
  717|      0|        carry_limb = _gcry_mpih_lshift( res->d, rp, rsize, mod_shift_cnt);
  718|      0|        rp = res->d;
  719|      0|        if ( carry_limb )
  ------------------
  |  Branch (719:14): [True: 0, False: 0]
  ------------------
  720|      0|          {
  721|      0|            rp[rsize] = carry_limb;
  722|      0|            rsize++;
  723|      0|          }
  724|      0|      }
  725|  8.57k|    else if (res->d != rp)
  ------------------
  |  Branch (725:14): [True: 15, False: 8.56k]
  ------------------
  726|     15|      {
  727|     15|        MPN_COPY (res->d, rp, rsize);
  ------------------
  |  |   90|     15|    do {				\
  |  |   91|     15|	mpi_size_t _i;			\
  |  |   92|    495|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 480, False: 15]
  |  |  ------------------
  |  |   93|    480|	    (d)[_i] = (s)[_i];		\
  |  |   94|     15|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  728|     15|        rp = res->d;
  729|     15|      }
  730|       |
  731|  8.57k|    if ( rsize >= msize )
  ------------------
  |  Branch (731:10): [True: 5.74k, False: 2.83k]
  ------------------
  732|  5.74k|      {
  733|  5.74k|        _gcry_mpih_divrem(rp + msize, 0, rp, rsize, mp, msize);
  734|  5.74k|        rsize = msize;
  735|  5.74k|      }
  736|       |
  737|       |    /* Remove any leading zero words from the result.  */
  738|  8.57k|    if ( mod_shift_cnt )
  ------------------
  |  Branch (738:10): [True: 0, False: 8.57k]
  ------------------
  739|      0|      _gcry_mpih_rshift( rp, rp, rsize, mod_shift_cnt);
  740|  8.57k|    MPN_NORMALIZE (rp, rsize);
  ------------------
  |  |  119|  8.57k|    do {		       \
  |  |  120|  14.2k|	while( (n) > 0 ) {     \
  |  |  ------------------
  |  |  |  Branch (120:9): [True: 14.2k, False: 0]
  |  |  ------------------
  |  |  121|  14.2k|	    if( (d)[(n)-1] ) \
  |  |  ------------------
  |  |  |  Branch (121:10): [True: 8.57k, False: 5.66k]
  |  |  ------------------
  |  |  122|  14.2k|		break;	       \
  |  |  123|  14.2k|	    (n)--;	       \
  |  |  124|  5.66k|	}		       \
  |  |  125|  8.57k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (125:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  741|       |
  742|  8.57k|    _gcry_mpih_release_karatsuba_ctx (&karactx );
  743|  17.1k|    for (i = 0; i < (1 << (W - 1)); i++)
  ------------------
  |  Branch (743:17): [True: 8.57k, False: 8.57k]
  ------------------
  744|  8.57k|      _gcry_mpi_free_limb_space( precomp[i], esec ? precomp_size[i] : 0 );
  ------------------
  |  Branch (744:46): [True: 0, False: 8.57k]
  ------------------
  745|  8.57k|    _gcry_mpi_free_limb_space (base_u, esec ? max_u_size : 0);
  ------------------
  |  Branch (745:40): [True: 0, False: 8.57k]
  ------------------
  746|  8.57k|  }
  747|       |
  748|       |  /* Fixup for negative results.  */
  749|  8.57k|  if ( negative_result && rsize )
  ------------------
  |  Branch (749:8): [True: 0, False: 8.57k]
  |  Branch (749:27): [True: 0, False: 0]
  ------------------
  750|      0|    {
  751|      0|      if ( mod_shift_cnt )
  ------------------
  |  Branch (751:12): [True: 0, False: 0]
  ------------------
  752|      0|        _gcry_mpih_rshift( mp, mp, msize, mod_shift_cnt);
  753|      0|      _gcry_mpih_sub( rp, mp, msize, rp, rsize);
  754|      0|      rsize = msize;
  755|      0|      rsign = msign;
  756|      0|      MPN_NORMALIZE(rp, rsize);
  ------------------
  |  |  119|      0|    do {		       \
  |  |  120|      0|	while( (n) > 0 ) {     \
  |  |  ------------------
  |  |  |  Branch (120:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  121|      0|	    if( (d)[(n)-1] ) \
  |  |  ------------------
  |  |  |  Branch (121:10): [True: 0, False: 0]
  |  |  ------------------
  |  |  122|      0|		break;	       \
  |  |  123|      0|	    (n)--;	       \
  |  |  124|      0|	}		       \
  |  |  125|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (125:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  757|      0|    }
  758|  8.57k|  gcry_assert (res->d == rp);
  ------------------
  |  |  188|  8.57k|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|  8.57k|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [True: 8.57k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|  8.57k|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
  759|      0|  res->nlimbs = rsize;
  760|  8.57k|  res->sign = rsign;
  761|       |
  762|  8.57k| leave:
  763|  8.57k|  if (mp_marker)
  ------------------
  |  Branch (763:7): [True: 8.57k, False: 0]
  ------------------
  764|  8.57k|    _gcry_mpi_free_limb_space( mp_marker, mp_nlimbs );
  765|  8.57k|  if (bp_marker)
  ------------------
  |  Branch (765:7): [True: 0, False: 8.57k]
  ------------------
  766|      0|    _gcry_mpi_free_limb_space( bp_marker, bp_nlimbs );
  767|  8.57k|  if (ep_marker)
  ------------------
  |  Branch (767:7): [True: 0, False: 8.57k]
  ------------------
  768|      0|    _gcry_mpi_free_limb_space( ep_marker, ep_nlimbs );
  769|  8.57k|  if (xp_marker)
  ------------------
  |  Branch (769:7): [True: 8.57k, False: 0]
  ------------------
  770|  8.57k|    _gcry_mpi_free_limb_space( xp_marker, xp_nlimbs );
  771|  8.57k|}
mpi-pow.c:mul_mod:
  376|  17.3k|{
  377|  17.3k|  if( ssize < KARATSUBA_THRESHOLD )
  ------------------
  |  |   61|  17.3k|#define KARATSUBA_THRESHOLD 16
  ------------------
  |  Branch (377:7): [True: 17.1k, False: 255]
  ------------------
  378|  17.1k|    _gcry_mpih_mul ( xp, rp, rsize, sp, ssize );
  379|    255|  else
  380|    255|    _gcry_mpih_mul_karatsuba_case (xp, rp, rsize, sp, ssize, karactx_p);
  381|       |
  382|  17.3k|   if (rsize + ssize > msize)
  ------------------
  |  Branch (382:8): [True: 11.7k, False: 5.66k]
  ------------------
  383|  11.7k|    {
  384|  11.7k|      _gcry_mpih_divrem (xp + msize, 0, xp, rsize + ssize, mp, msize);
  385|  11.7k|      *xsize_p = msize;
  386|  11.7k|    }
  387|  5.66k|   else
  388|  5.66k|     *xsize_p = rsize + ssize;
  389|  17.3k|}

_gcry_mpi_get_buffer:
  383|    579|{
  384|    579|  if (mpi_get_flag (a, GCRYMPI_FLAG_OPAQUE))
  ------------------
  |  |  566|    579|#define mpi_get_flag(a,f)      _gcry_mpi_get_flag ((a), (f))
  |  |  ------------------
  |  |  |  Branch (566:32): [True: 0, False: 579]
  |  |  ------------------
  ------------------
  385|      0|    {
  386|      0|      unsigned int nbits;
  387|      0|      byte *p = _gcry_mpi_get_opaque_copy (a, &nbits);
  388|       |
  389|      0|      if (r_nbytes)
  ------------------
  |  Branch (389:11): [True: 0, False: 0]
  ------------------
  390|      0|        *r_nbytes = (nbits+7)/8;
  391|       |
  392|      0|      return p;
  393|      0|    }
  394|    579|  else
  395|    579|    return do_get_buffer (a, fill_le, 0, r_nbytes, sign, 0);
  396|    579|}
_gcry_mpi_set_buffer:
  420|    186|{
  421|    186|  const unsigned char *buffer = (const unsigned char*)buffer_arg;
  422|    186|  const unsigned char *p;
  423|    186|  mpi_limb_t alimb;
  424|    186|  int nlimbs;
  425|    186|  int i;
  426|       |
  427|    186|  if (mpi_is_immutable (a))
  ------------------
  |  |  113|    186|#define mpi_is_immutable(a)   ((a)->flags&16)
  |  |  ------------------
  |  |  |  Branch (113:31): [True: 0, False: 186]
  |  |  ------------------
  ------------------
  428|      0|    {
  429|      0|      mpi_immutable_failed ();
  ------------------
  |  |  110|      0|#define mpi_immutable_failed() _gcry_mpi_immutable_failed ()
  ------------------
  430|      0|      return;
  431|      0|    }
  432|       |
  433|    186|  nlimbs = (nbytes + BYTES_PER_MPI_LIMB - 1) / BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|    186|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|    186|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
                nlimbs = (nbytes + BYTES_PER_MPI_LIMB - 1) / BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|    186|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|    186|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
  434|    186|  RESIZE_IF_NEEDED(a, nlimbs);
  ------------------
  |  |   78|    186|    do {			   \
  |  |   79|    186|	if( (a)->alloced < (b) )   \
  |  |  ------------------
  |  |  |  Branch (79:6): [True: 0, False: 186]
  |  |  ------------------
  |  |   80|    186|	    mpi_resize((a), (b));  \
  |  |  ------------------
  |  |  |  |  100|      0|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  |  |  ------------------
  |  |   81|    186|    } while(0)
  |  |  ------------------
  |  |  |  Branch (81:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  435|    186|  a->sign = sign;
  436|       |
  437|  2.86k|  for (i=0, p = buffer+nbytes-1; p >= buffer+BYTES_PER_MPI_LIMB; )
  ------------------
  |  |    4|  2.86k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|  2.86k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
  |  Branch (437:34): [True: 2.67k, False: 186]
  ------------------
  438|  2.67k|    {
  439|       |#if BYTES_PER_MPI_LIMB == 4
  440|       |      alimb = buf_get_be32(p - 4 + 1);
  441|       |      p -= 4;
  442|       |#elif BYTES_PER_MPI_LIMB == 8
  443|  2.67k|      alimb = buf_get_be64(p - 8 + 1);
  444|  2.67k|      p -= 8;
  445|       |#else
  446|       |#     error please implement for this limb size.
  447|       |#endif
  448|  2.67k|      a->d[i++] = alimb;
  449|  2.67k|    }
  450|    186|  if ( p >= buffer )
  ------------------
  |  Branch (450:8): [True: 186, False: 0]
  ------------------
  451|    186|    {
  452|    186|      byte last[BYTES_PER_MPI_LIMB] = { 0 };
  453|    186|      unsigned int n = (p - buffer) + 1;
  454|       |
  455|    186|      n = n > BYTES_PER_MPI_LIMB ? BYTES_PER_MPI_LIMB : n;
  ------------------
  |  |    4|    186|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|    186|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
                    n = n > BYTES_PER_MPI_LIMB ? BYTES_PER_MPI_LIMB : n;
  ------------------
  |  |    4|      0|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|      0|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
  |  Branch (455:11): [True: 0, False: 186]
  ------------------
  456|    186|      memcpy (last + BYTES_PER_MPI_LIMB - n, p - n + 1, n);
  ------------------
  |  |    4|    186|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|    186|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
  457|    186|      p -= n;
  458|       |
  459|       |#if BYTES_PER_MPI_LIMB == 4
  460|       |      alimb = buf_get_be32(last);
  461|       |#elif BYTES_PER_MPI_LIMB == 8
  462|    186|      alimb = buf_get_be64(last);
  463|       |#else
  464|       |#     error please implement for this limb size.
  465|       |#endif
  466|       |
  467|    186|      a->d[i++] = alimb;
  468|    186|    }
  469|    186|  a->nlimbs = i;
  470|    186|  gcry_assert (i == nlimbs);
  ------------------
  |  |  188|    186|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|    186|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [True: 186, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|    186|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
  471|    186|}
_gcry_mpi_scan:
  541|  1.24k|{
  542|  1.24k|  const unsigned char *buffer = (const unsigned char*)buffer_arg;
  543|  1.24k|  struct gcry_mpi *a = NULL;
  544|  1.24k|  unsigned int len;
  545|  1.24k|  int secure = (buffer && _gcry_is_secure (buffer));
  ------------------
  |  Branch (545:17): [True: 1.24k, False: 0]
  |  Branch (545:27): [True: 0, False: 1.24k]
  ------------------
  546|       |
  547|  1.24k|  if (buflen > MAX_EXTERN_SCAN_BYTES)
  ------------------
  |  |   37|  1.24k|#define MAX_EXTERN_SCAN_BYTES (16*1024*1024)
  ------------------
  |  Branch (547:7): [True: 0, False: 1.24k]
  ------------------
  548|      0|    {
  549|      0|      if (nscanned)
  ------------------
  |  Branch (549:11): [True: 0, False: 0]
  ------------------
  550|      0|        *nscanned = 0;
  551|      0|      return GPG_ERR_INV_OBJ;
  552|      0|    }
  553|       |
  554|  1.24k|  if (format == GCRYMPI_FMT_SSH)
  ------------------
  |  Branch (554:7): [True: 0, False: 1.24k]
  ------------------
  555|      0|    len = 0;
  556|  1.24k|  else
  557|  1.24k|    len = buflen;
  558|       |
  559|  1.24k|  if (format == GCRYMPI_FMT_STD)
  ------------------
  |  Branch (559:7): [True: 31, False: 1.21k]
  ------------------
  560|     31|    {
  561|     31|      const unsigned char *s = buffer;
  562|       |
  563|     31|      a = secure? mpi_alloc_secure ((len+BYTES_PER_MPI_LIMB-1)
  ------------------
  |  |   98|      0|# define mpi_alloc_secure(n)  _gcry_mpi_alloc_secure((n) )
  ------------------
  |  Branch (563:11): [True: 0, False: 31]
  ------------------
  564|     31|                                    /BYTES_PER_MPI_LIMB)
  565|     31|                : mpi_alloc ((len+BYTES_PER_MPI_LIMB-1)/BYTES_PER_MPI_LIMB);
  ------------------
  |  |   97|     62|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  566|     31|      if (len)
  ------------------
  |  Branch (566:11): [True: 31, False: 0]
  ------------------
  567|     31|        {
  568|     31|          _gcry_mpi_set_buffer (a, s, len, 0);
  569|     31|          a->sign = !!(*s & 0x80);
  570|     31|          if (a->sign)
  ------------------
  |  Branch (570:15): [True: 0, False: 31]
  ------------------
  571|      0|            {
  572|      0|              onecompl (a);
  573|      0|              mpi_add_ui (a, a, 1);
  ------------------
  |  |  515|      0|#define mpi_add_ui(w,u,v)      _gcry_mpi_add_ui((w),(u),(v))
  ------------------
  574|      0|              a->sign = 1;
  575|      0|	    }
  576|     31|	}
  577|     31|      if (ret_mpi)
  ------------------
  |  Branch (577:11): [True: 31, False: 0]
  ------------------
  578|     31|        {
  579|     31|          mpi_normalize ( a );
  ------------------
  |  |  223|     31|#define mpi_normalize(a)       _gcry_mpi_normalize ((a))
  ------------------
  580|     31|          *ret_mpi = a;
  581|     31|	}
  582|      0|      else
  583|      0|        mpi_free(a);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  584|     31|      if (nscanned)
  ------------------
  |  Branch (584:11): [True: 0, False: 31]
  ------------------
  585|      0|        *nscanned = len;
  586|     31|      return 0;
  587|     31|    }
  588|  1.21k|  else if (format == GCRYMPI_FMT_USG)
  ------------------
  |  Branch (588:12): [True: 155, False: 1.06k]
  ------------------
  589|    155|    {
  590|    155|      a = secure? mpi_alloc_secure ((len+BYTES_PER_MPI_LIMB-1)
  ------------------
  |  |   98|      0|# define mpi_alloc_secure(n)  _gcry_mpi_alloc_secure((n) )
  ------------------
  |  Branch (590:11): [True: 0, False: 155]
  ------------------
  591|    155|                                    /BYTES_PER_MPI_LIMB)
  592|    155|                : mpi_alloc ((len+BYTES_PER_MPI_LIMB-1)/BYTES_PER_MPI_LIMB);
  ------------------
  |  |   97|    310|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  593|       |
  594|    155|      if (len)
  ------------------
  |  Branch (594:11): [True: 155, False: 0]
  ------------------
  595|    155|        _gcry_mpi_set_buffer (a, buffer, len, 0);
  596|    155|      if (ret_mpi)
  ------------------
  |  Branch (596:11): [True: 155, False: 0]
  ------------------
  597|    155|        {
  598|    155|          mpi_normalize ( a );
  ------------------
  |  |  223|    155|#define mpi_normalize(a)       _gcry_mpi_normalize ((a))
  ------------------
  599|    155|          *ret_mpi = a;
  600|    155|	}
  601|      0|      else
  602|      0|        mpi_free(a);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  603|    155|      if (nscanned)
  ------------------
  |  Branch (603:11): [True: 15, False: 140]
  ------------------
  604|     15|        *nscanned = len;
  605|    155|      return 0;
  606|    155|    }
  607|  1.06k|  else if (format == GCRYMPI_FMT_PGP)
  ------------------
  |  Branch (607:12): [True: 921, False: 141]
  ------------------
  608|    921|    {
  609|    921|      a = mpi_read_from_buffer (buffer, &len, secure);
  610|    921|      if (nscanned)
  ------------------
  |  Branch (610:11): [True: 921, False: 0]
  ------------------
  611|    921|        *nscanned = len;
  612|    921|      if (ret_mpi && a)
  ------------------
  |  Branch (612:11): [True: 921, False: 0]
  |  Branch (612:22): [True: 921, False: 0]
  ------------------
  613|    921|        {
  614|    921|          mpi_normalize (a);
  ------------------
  |  |  223|    921|#define mpi_normalize(a)       _gcry_mpi_normalize ((a))
  ------------------
  615|    921|          *ret_mpi = a;
  616|    921|	}
  617|      0|      else if (a)
  ------------------
  |  Branch (617:16): [True: 0, False: 0]
  ------------------
  618|      0|        {
  619|      0|          mpi_free(a);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  620|      0|          a = NULL;
  621|      0|        }
  622|    921|      return a? 0 : GPG_ERR_INV_OBJ;
  ------------------
  |  Branch (622:14): [True: 921, False: 0]
  ------------------
  623|    921|    }
  624|    141|  else if (format == GCRYMPI_FMT_SSH)
  ------------------
  |  Branch (624:12): [True: 0, False: 141]
  ------------------
  625|      0|    {
  626|      0|      const unsigned char *s = buffer;
  627|      0|      size_t n;
  628|       |
  629|       |      /* This test is not strictly necessary and an assert (!len)
  630|       |         would be sufficient.  We keep this test in case we later
  631|       |         allow the BUFLEN argument to act as a sanitiy check.  Same
  632|       |         below. */
  633|      0|      if (len && len < 4)
  ------------------
  |  Branch (633:11): [True: 0, False: 0]
  |  Branch (633:18): [True: 0, False: 0]
  ------------------
  634|      0|        return GPG_ERR_TOO_SHORT;
  635|       |
  636|      0|      n = buf_get_be32 (s);
  637|      0|      s += 4;
  638|      0|      if (len)
  ------------------
  |  Branch (638:11): [True: 0, False: 0]
  ------------------
  639|      0|        len -= 4;
  640|      0|      if (len && n > len)
  ------------------
  |  Branch (640:11): [True: 0, False: 0]
  |  Branch (640:18): [True: 0, False: 0]
  ------------------
  641|      0|        return GPG_ERR_TOO_LARGE;
  642|       |
  643|      0|      a = secure? mpi_alloc_secure ((n+BYTES_PER_MPI_LIMB-1)
  ------------------
  |  |   98|      0|# define mpi_alloc_secure(n)  _gcry_mpi_alloc_secure((n) )
  ------------------
  |  Branch (643:11): [True: 0, False: 0]
  ------------------
  644|      0|                                    /BYTES_PER_MPI_LIMB)
  645|      0|                : mpi_alloc ((n+BYTES_PER_MPI_LIMB-1)/BYTES_PER_MPI_LIMB);
  ------------------
  |  |   97|      0|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  646|      0|      if (n)
  ------------------
  |  Branch (646:11): [True: 0, False: 0]
  ------------------
  647|      0|        {
  648|      0|          _gcry_mpi_set_buffer( a, s, n, 0 );
  649|      0|          a->sign = !!(*s & 0x80);
  650|      0|          if (a->sign)
  ------------------
  |  Branch (650:15): [True: 0, False: 0]
  ------------------
  651|      0|            {
  652|      0|              onecompl (a);
  653|      0|              mpi_add_ui (a, a, 1);
  ------------------
  |  |  515|      0|#define mpi_add_ui(w,u,v)      _gcry_mpi_add_ui((w),(u),(v))
  ------------------
  654|      0|              a->sign = 1;
  655|      0|	    }
  656|      0|	}
  657|      0|      if (nscanned)
  ------------------
  |  Branch (657:11): [True: 0, False: 0]
  ------------------
  658|      0|        *nscanned = n+4;
  659|      0|      if (ret_mpi)
  ------------------
  |  Branch (659:11): [True: 0, False: 0]
  ------------------
  660|      0|        {
  661|      0|          mpi_normalize ( a );
  ------------------
  |  |  223|      0|#define mpi_normalize(a)       _gcry_mpi_normalize ((a))
  ------------------
  662|      0|          *ret_mpi = a;
  663|      0|        }
  664|      0|      else
  665|      0|        mpi_free(a);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  666|      0|      return 0;
  667|      0|    }
  668|    141|  else if (format == GCRYMPI_FMT_HEX)
  ------------------
  |  Branch (668:12): [True: 141, False: 0]
  ------------------
  669|    141|    {
  670|    141|      size_t slen;
  671|       |      /* We can only handle C strings for now.  */
  672|    141|      if (buflen)
  ------------------
  |  Branch (672:11): [True: 0, False: 141]
  ------------------
  673|      0|        return GPG_ERR_INV_ARG;
  674|       |
  675|    141|      slen = strlen ((const char *)buffer);
  676|    141|      if (slen > MAX_EXTERN_SCAN_BYTES)
  ------------------
  |  |   37|    141|#define MAX_EXTERN_SCAN_BYTES (16*1024*1024)
  ------------------
  |  Branch (676:11): [True: 0, False: 141]
  ------------------
  677|      0|	return GPG_ERR_INV_OBJ;
  678|    141|      a = secure? mpi_alloc_secure ((((slen+1)/2)+BYTES_PER_MPI_LIMB-1)
  ------------------
  |  |   98|      0|# define mpi_alloc_secure(n)  _gcry_mpi_alloc_secure((n) )
  ------------------
  |  Branch (678:11): [True: 0, False: 141]
  ------------------
  679|    141|				    /BYTES_PER_MPI_LIMB)
  680|    141|		: mpi_alloc((((slen+1)/2)+BYTES_PER_MPI_LIMB-1)
  ------------------
  |  |   97|    282|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  681|    141|			    /BYTES_PER_MPI_LIMB);
  682|    141|      if (mpi_fromstr (a, (const char *)buffer, slen))
  ------------------
  |  Branch (682:11): [True: 0, False: 141]
  ------------------
  683|      0|        {
  684|      0|          mpi_free (a);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  685|      0|          return GPG_ERR_INV_OBJ;
  686|      0|        }
  687|    141|      if (ret_mpi)
  ------------------
  |  Branch (687:11): [True: 141, False: 0]
  ------------------
  688|    141|        {
  689|    141|          mpi_normalize ( a );
  ------------------
  |  |  223|    141|#define mpi_normalize(a)       _gcry_mpi_normalize ((a))
  ------------------
  690|    141|          *ret_mpi = a;
  691|    141|	}
  692|      0|      else
  693|      0|        mpi_free(a);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
  694|    141|      if (nscanned)
  ------------------
  |  Branch (694:11): [True: 0, False: 141]
  ------------------
  695|      0|        *nscanned = strlen ((const char*)buffer);
  696|    141|      return 0;
  697|    141|    }
  698|      0|  else
  699|      0|    return GPG_ERR_INV_ARG;
  700|  1.24k|}
_gcry_mpi_print:
  713|    895|{
  714|    895|  unsigned int nbits = mpi_get_nbits (a);
  ------------------
  |  |  552|    895|#define mpi_get_nbits(a)       _gcry_mpi_get_nbits ((a))
  ------------------
  715|    895|  size_t len;
  716|    895|  size_t dummy_nwritten;
  717|    895|  int negative;
  718|       |
  719|    895|  if (!nwritten)
  ------------------
  |  Branch (719:7): [True: 0, False: 895]
  ------------------
  720|      0|    nwritten = &dummy_nwritten;
  721|       |
  722|       |  /* Libgcrypt does no always care to set clear the sign if the value
  723|       |     is 0.  For printing this is a bit of a surprise, in particular
  724|       |     because if some of the formats don't support negative numbers but
  725|       |     should be able to print a zero.  Thus we need this extra test
  726|       |     for a negative number.  */
  727|    895|  if (a->sign && _gcry_mpi_cmp_ui (a, 0))
  ------------------
  |  Branch (727:7): [True: 0, False: 895]
  |  Branch (727:18): [True: 0, False: 0]
  ------------------
  728|      0|    negative = 1;
  729|    895|  else
  730|    895|    negative = 0;
  731|       |
  732|    895|  len = buflen;
  733|    895|  *nwritten = 0;
  734|    895|  if (format == GCRYMPI_FMT_STD)
  ------------------
  |  Branch (734:7): [True: 152, False: 743]
  ------------------
  735|    152|    {
  736|    152|      unsigned char *tmp;
  737|    152|      int extra = 0;
  738|    152|      unsigned int n;
  739|       |
  740|    152|      tmp = _gcry_mpi_get_buffer (a, 0, &n, NULL);
  741|    152|      if (!tmp)
  ------------------
  |  Branch (741:11): [True: 0, False: 152]
  ------------------
  742|      0|        return gpg_err_code_from_syserror ();
  743|       |
  744|    152|      if (negative)
  ------------------
  |  Branch (744:11): [True: 0, False: 152]
  ------------------
  745|      0|        {
  746|      0|          twocompl (tmp, n);
  747|      0|          if (!(*tmp & 0x80))
  ------------------
  |  Branch (747:15): [True: 0, False: 0]
  ------------------
  748|      0|            {
  749|       |              /* Need to extend the sign.  */
  750|      0|              n++;
  751|      0|              extra = 2;
  752|      0|            }
  753|      0|        }
  754|    152|      else if (n && (*tmp & 0x80))
  ------------------
  |  Branch (754:16): [True: 152, False: 0]
  |  Branch (754:21): [True: 92, False: 60]
  ------------------
  755|     92|        {
  756|       |          /* Positive but the high bit of the returned buffer is set.
  757|       |             Thus we need to print an extra leading 0x00 so that the
  758|       |             output is interpreted as a positive number.  */
  759|     92|          n++;
  760|     92|          extra = 1;
  761|     92|	}
  762|       |
  763|    152|      if (buffer && n > len)
  ------------------
  |  Branch (763:11): [True: 76, False: 76]
  |  Branch (763:21): [True: 0, False: 76]
  ------------------
  764|      0|        {
  765|       |          /* The provided buffer is too short. */
  766|      0|          xfree (tmp);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  767|      0|          return GPG_ERR_TOO_SHORT;
  768|      0|	}
  769|    152|      if (buffer)
  ------------------
  |  Branch (769:11): [True: 76, False: 76]
  ------------------
  770|     76|        {
  771|     76|          unsigned char *s = buffer;
  772|       |
  773|     76|          if (extra == 1)
  ------------------
  |  Branch (773:15): [True: 46, False: 30]
  ------------------
  774|     46|            *s++ = 0;
  775|     30|          else if (extra)
  ------------------
  |  Branch (775:20): [True: 0, False: 30]
  ------------------
  776|      0|            *s++ = 0xff;
  777|     76|          memcpy (s, tmp, n-!!extra);
  778|     76|	}
  779|    152|      xfree (tmp);
  ------------------
  |  |  150|    152|#define xfree(a)         _gcry_free ((a))
  ------------------
  780|    152|      *nwritten = n;
  781|    152|      return 0;
  782|    152|    }
  783|    743|  else if (format == GCRYMPI_FMT_USG)
  ------------------
  |  Branch (783:12): [True: 0, False: 743]
  ------------------
  784|      0|    {
  785|      0|      unsigned int n = (nbits + 7)/8;
  786|       |
  787|       |      /* Note:  We ignore the sign for this format.  */
  788|       |      /* FIXME: for performance reasons we should put this into
  789|       |	 mpi_aprint because we can then use the buffer directly.  */
  790|       |
  791|      0|      if (buffer && n > len)
  ------------------
  |  Branch (791:11): [True: 0, False: 0]
  |  Branch (791:21): [True: 0, False: 0]
  ------------------
  792|      0|        return GPG_ERR_TOO_SHORT;
  793|      0|      if (buffer)
  ------------------
  |  Branch (793:11): [True: 0, False: 0]
  ------------------
  794|      0|        {
  795|      0|          unsigned char *tmp;
  796|       |
  797|      0|          tmp = _gcry_mpi_get_buffer (a, 0, &n, NULL);
  798|      0|          if (!tmp)
  ------------------
  |  Branch (798:15): [True: 0, False: 0]
  ------------------
  799|      0|            return gpg_err_code_from_syserror ();
  800|      0|          memcpy (buffer, tmp, n);
  801|      0|          xfree (tmp);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  802|      0|	}
  803|      0|      *nwritten = n;
  804|      0|      return 0;
  805|      0|    }
  806|    743|  else if (format == GCRYMPI_FMT_PGP)
  ------------------
  |  Branch (806:12): [True: 743, False: 0]
  ------------------
  807|    743|    {
  808|    743|      unsigned int n = (nbits + 7)/8;
  809|       |
  810|       |      /* The PGP format can only handle unsigned integers.  */
  811|    743|      if (negative)
  ------------------
  |  Branch (811:11): [True: 0, False: 743]
  ------------------
  812|      0|        return GPG_ERR_INV_ARG;
  813|       |
  814|    743|      if (buffer && n+2 > len)
  ------------------
  |  Branch (814:11): [True: 387, False: 356]
  |  Branch (814:21): [True: 0, False: 387]
  ------------------
  815|      0|        return GPG_ERR_TOO_SHORT;
  816|       |
  817|    743|      if (buffer)
  ------------------
  |  Branch (817:11): [True: 387, False: 356]
  ------------------
  818|    387|        {
  819|    387|          unsigned char *tmp;
  820|    387|          unsigned char *s = buffer;
  821|       |
  822|    387|          s[0] = nbits >> 8;
  823|    387|          s[1] = nbits;
  824|       |
  825|    387|          tmp = _gcry_mpi_get_buffer (a, 0, &n, NULL);
  826|    387|          if (!tmp)
  ------------------
  |  Branch (826:15): [True: 0, False: 387]
  ------------------
  827|      0|            return gpg_err_code_from_syserror ();
  828|    387|          memcpy (s+2, tmp, n);
  829|    387|          xfree (tmp);
  ------------------
  |  |  150|    387|#define xfree(a)         _gcry_free ((a))
  ------------------
  830|    387|	}
  831|    743|      *nwritten = n+2;
  832|    743|      return 0;
  833|    743|    }
  834|      0|  else if (format == GCRYMPI_FMT_SSH)
  ------------------
  |  Branch (834:12): [True: 0, False: 0]
  ------------------
  835|      0|    {
  836|      0|      unsigned char *tmp;
  837|      0|      int extra = 0;
  838|      0|      unsigned int n;
  839|       |
  840|      0|      tmp = _gcry_mpi_get_buffer (a, 0, &n, NULL);
  841|      0|      if (!tmp)
  ------------------
  |  Branch (841:11): [True: 0, False: 0]
  ------------------
  842|      0|        return gpg_err_code_from_syserror ();
  843|       |
  844|      0|      if (negative)
  ------------------
  |  Branch (844:11): [True: 0, False: 0]
  ------------------
  845|      0|        {
  846|      0|          twocompl (tmp, n);
  847|      0|          if (!(*tmp & 0x80))
  ------------------
  |  Branch (847:15): [True: 0, False: 0]
  ------------------
  848|      0|            {
  849|       |              /* Need to extend the sign.  */
  850|      0|              n++;
  851|      0|              extra = 2;
  852|      0|            }
  853|      0|        }
  854|      0|      else if (n && (*tmp & 0x80))
  ------------------
  |  Branch (854:16): [True: 0, False: 0]
  |  Branch (854:21): [True: 0, False: 0]
  ------------------
  855|      0|        {
  856|      0|          n++;
  857|      0|          extra=1;
  858|      0|	}
  859|       |
  860|      0|      if (buffer && n+4 > len)
  ------------------
  |  Branch (860:11): [True: 0, False: 0]
  |  Branch (860:21): [True: 0, False: 0]
  ------------------
  861|      0|        {
  862|      0|          xfree(tmp);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  863|      0|          return GPG_ERR_TOO_SHORT;
  864|      0|	}
  865|       |
  866|      0|      if (buffer)
  ------------------
  |  Branch (866:11): [True: 0, False: 0]
  ------------------
  867|      0|        {
  868|      0|          unsigned char *s = buffer;
  869|       |
  870|      0|	  buf_put_be32 (s, n);
  871|      0|	  s += 4;
  872|      0|          if (extra == 1)
  ------------------
  |  Branch (872:15): [True: 0, False: 0]
  ------------------
  873|      0|            *s++ = 0;
  874|      0|          else if (extra)
  ------------------
  |  Branch (874:20): [True: 0, False: 0]
  ------------------
  875|      0|            *s++ = 0xff;
  876|      0|          memcpy (s, tmp, n-!!extra);
  877|      0|	}
  878|      0|      xfree (tmp);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  879|      0|      *nwritten = 4+n;
  880|      0|      return 0;
  881|      0|    }
  882|      0|  else if (format == GCRYMPI_FMT_HEX)
  ------------------
  |  Branch (882:12): [True: 0, False: 0]
  ------------------
  883|      0|    {
  884|      0|      unsigned char *tmp;
  885|      0|      int i;
  886|      0|      int extra = 0;
  887|      0|      unsigned int n = 0;
  888|       |
  889|      0|      tmp = _gcry_mpi_get_buffer (a, 0, &n, NULL);
  890|      0|      if (!tmp)
  ------------------
  |  Branch (890:11): [True: 0, False: 0]
  ------------------
  891|      0|        return gpg_err_code_from_syserror ();
  892|      0|      if (!n || (*tmp & 0x80))
  ------------------
  |  Branch (892:11): [True: 0, False: 0]
  |  Branch (892:17): [True: 0, False: 0]
  ------------------
  893|      0|        extra = 2;
  894|       |
  895|      0|      if (buffer && 2*n + extra + negative + 1 > len)
  ------------------
  |  Branch (895:11): [True: 0, False: 0]
  |  Branch (895:21): [True: 0, False: 0]
  ------------------
  896|      0|        {
  897|      0|          xfree(tmp);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  898|      0|          return GPG_ERR_TOO_SHORT;
  899|      0|	}
  900|      0|      if (buffer)
  ------------------
  |  Branch (900:11): [True: 0, False: 0]
  ------------------
  901|      0|        {
  902|      0|	  static const u32 nibble2hex[] =
  903|      0|	  {
  904|      0|	    '0', '1', '2', '3', '4', '5', '6', '7',
  905|      0|	    '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
  906|      0|	  };
  907|      0|          unsigned char *s = buffer;
  908|       |
  909|      0|          if (negative)
  ------------------
  |  Branch (909:15): [True: 0, False: 0]
  ------------------
  910|      0|            *s++ = '-';
  911|      0|          if (extra)
  ------------------
  |  Branch (911:15): [True: 0, False: 0]
  ------------------
  912|      0|            {
  913|      0|              *s++ = '0';
  914|      0|              *s++ = '0';
  915|      0|	    }
  916|       |
  917|      0|	  for (i = 0; i + 4 < n; i += 4)
  ------------------
  |  Branch (917:16): [True: 0, False: 0]
  ------------------
  918|      0|	    {
  919|      0|	      u32 c = buf_get_be32(tmp + i);
  920|      0|	      u32 o1, o2;
  921|       |
  922|      0|	      o1 = nibble2hex[(c >> 28) & 0xF];
  923|      0|	      o1 <<= 8;
  924|      0|	      o1 |= nibble2hex[(c >> 24) & 0xF];
  925|      0|	      o1 <<= 8;
  926|      0|	      o1 |= nibble2hex[(c >> 20) & 0xF];
  927|      0|	      o1 <<= 8;
  928|      0|	      o1 |= nibble2hex[(c >> 16) & 0xF];
  929|       |
  930|      0|	      o2 = nibble2hex[(c >> 12) & 0xF];
  931|      0|	      o2 <<= 8;
  932|      0|	      o2 |= (u64)nibble2hex[(c >> 8) & 0xF];
  933|      0|	      o2 <<= 8;
  934|      0|	      o2 |= (u64)nibble2hex[(c >> 4) & 0xF];
  935|      0|	      o2 <<= 8;
  936|      0|	      o2 |= (u64)nibble2hex[(c >> 0) & 0xF];
  937|       |
  938|      0|	      buf_put_be32 (s + 0, o1);
  939|      0|	      buf_put_be32 (s + 4, o2);
  940|      0|	      s += 8;
  941|      0|	    }
  942|      0|          for (; i < n; i++)
  ------------------
  |  Branch (942:18): [True: 0, False: 0]
  ------------------
  943|      0|            {
  944|      0|              unsigned int c = tmp[i];
  945|       |
  946|      0|              *s++ = nibble2hex[c >> 4];
  947|      0|              *s++ = nibble2hex[c & 0xF];
  948|      0|	    }
  949|      0|          *s++ = 0;
  950|      0|          *nwritten = s - buffer;
  951|      0|	}
  952|      0|      else
  953|      0|        {
  954|      0|          *nwritten = 2*n + extra + negative + 1;
  955|      0|	}
  956|      0|      xfree (tmp);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  957|      0|      return 0;
  958|      0|    }
  959|      0|  else
  960|      0|    return GPG_ERR_INV_ARG;
  961|    895|}
mpicoder.c:do_get_buffer:
  294|    579|{
  295|    579|  unsigned char *p, *buffer, *retbuffer;
  296|    579|  unsigned int length, tmp;
  297|    579|  mpi_limb_t alimb;
  298|    579|  int i;
  299|    579|  size_t n, n2;
  300|       |
  301|    579|  if (sign)
  ------------------
  |  Branch (301:7): [True: 0, False: 579]
  ------------------
  302|      0|    *sign = a->sign;
  303|       |
  304|    579|  *nbytes = a->nlimbs * BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|    579|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|    579|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
  305|    579|  n = *nbytes? *nbytes:1; /* Allocate at least one byte.  */
  ------------------
  |  Branch (305:7): [True: 293, False: 286]
  ------------------
  306|    579|  if (n < fill_le)
  ------------------
  |  Branch (306:7): [True: 0, False: 579]
  ------------------
  307|      0|    n = fill_le;
  308|    579|  if (extraalloc < 0)
  ------------------
  |  Branch (308:7): [True: 0, False: 579]
  ------------------
  309|      0|    n2 = n + -extraalloc;
  310|    579|  else
  311|    579|    n2 = n + extraalloc;
  312|       |
  313|    579|  retbuffer = (force_secure || mpi_is_secure(a))? xtrymalloc_secure (n2)
  ------------------
  |  |  115|    579|#define mpi_is_secure(a)      ((a) && ((a)->flags&1))
  |  |  ------------------
  |  |  |  Branch (115:32): [True: 579, False: 0]
  |  |  |  Branch (115:39): [True: 0, False: 579]
  |  |  ------------------
  ------------------
                retbuffer = (force_secure || mpi_is_secure(a))? xtrymalloc_secure (n2)
  ------------------
  |  |  140|      0|#define xtrymalloc_secure(a)   _gcry_malloc_secure ((a))
  ------------------
  |  Branch (313:16): [True: 0, False: 579]
  ------------------
  314|    579|                                                : xtrymalloc (n2);
  ------------------
  |  |  138|  1.15k|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  315|    579|  if (!retbuffer)
  ------------------
  |  Branch (315:7): [True: 0, False: 579]
  ------------------
  316|      0|    return NULL;
  317|    579|  if (extraalloc < 0)
  ------------------
  |  Branch (317:7): [True: 0, False: 579]
  ------------------
  318|      0|    buffer = retbuffer + -extraalloc;
  319|    579|  else
  320|    579|    buffer = retbuffer;
  321|    579|  p = buffer;
  322|       |
  323|  5.47k|  for (i=a->nlimbs-1; i >= 0; i--)
  ------------------
  |  Branch (323:23): [True: 4.89k, False: 579]
  ------------------
  324|  4.89k|    {
  325|  4.89k|      alimb = a->d[i];
  326|       |#if BYTES_PER_MPI_LIMB == 4
  327|       |      buf_put_be32 (p, alimb);
  328|       |      p += 4;
  329|       |#elif BYTES_PER_MPI_LIMB == 8
  330|  4.89k|      buf_put_be64 (p, alimb);
  331|  4.89k|      p += 8;
  332|       |#else
  333|       |#     error please implement for this limb size.
  334|       |#endif
  335|  4.89k|    }
  336|       |
  337|    579|  if (fill_le)
  ------------------
  |  Branch (337:7): [True: 0, False: 579]
  ------------------
  338|      0|    {
  339|      0|      length = *nbytes;
  340|       |      /* Reverse buffer and pad with zeroes.  */
  341|      0|      for (i = 0; i + 8 < length / 2; i += 8)
  ------------------
  |  Branch (341:19): [True: 0, False: 0]
  ------------------
  342|      0|	{
  343|      0|	  u64 head = buf_get_be64 (buffer + i);
  344|      0|	  u64 tail = buf_get_be64 (buffer + length - 8 - i);
  345|      0|	  buf_put_le64 (buffer + length - 8 - i, head);
  346|      0|	  buf_put_le64 (buffer + i, tail);
  347|      0|	}
  348|      0|      if (i + 4 < length / 2)
  ------------------
  |  Branch (348:11): [True: 0, False: 0]
  ------------------
  349|      0|	{
  350|      0|	  u32 head = buf_get_be32 (buffer + i);
  351|      0|	  u32 tail = buf_get_be32 (buffer + length - 4 - i);
  352|      0|	  buf_put_le32 (buffer + length - 4 - i, head);
  353|      0|	  buf_put_le32 (buffer + i, tail);
  354|      0|	  i += 4;
  355|      0|	}
  356|      0|      for (; i < length/2; i++)
  ------------------
  |  Branch (356:14): [True: 0, False: 0]
  ------------------
  357|      0|        {
  358|      0|          tmp = buffer[i];
  359|      0|          buffer[i] = buffer[length-1-i];
  360|      0|          buffer[length-1-i] = tmp;
  361|      0|        }
  362|       |      /* Pad with zeroes.  */
  363|      0|      for (p = buffer + length; length < fill_le; length++)
  ------------------
  |  Branch (363:33): [True: 0, False: 0]
  ------------------
  364|      0|        *p++ = 0;
  365|      0|      *nbytes = length;
  366|       |
  367|      0|      return retbuffer;
  368|      0|    }
  369|       |
  370|       |  /* This is sub-optimal but we need to do the shift operation because
  371|       |     the caller has to free the returned buffer.  */
  372|  1.09k|  for (p=buffer; *nbytes && !*p; p++, --*nbytes)
  ------------------
  |  Branch (372:18): [True: 808, False: 286]
  |  Branch (372:29): [True: 515, False: 293]
  ------------------
  373|    515|    ;
  374|    579|  if (p != buffer)
  ------------------
  |  Branch (374:7): [True: 120, False: 459]
  ------------------
  375|    120|    memmove (buffer, p, *nbytes);
  376|    579|  return retbuffer;
  377|    579|}
mpicoder.c:mpi_read_from_buffer:
   50|    921|{
   51|    921|  int i, j;
   52|    921|  unsigned int nbits, nbytes, nlimbs, nread=0;
   53|    921|  mpi_limb_t a;
   54|    921|  gcry_mpi_t val = MPI_NULL;
  ------------------
  |  |   78|    921|#define MPI_NULL NULL
  ------------------
   55|    921|  unsigned int max_nread = *ret_nread;
   56|       |
   57|    921|  if ( max_nread < 2 )
  ------------------
  |  Branch (57:8): [True: 0, False: 921]
  ------------------
   58|      0|    goto leave;
   59|    921|  nbits = buffer[0] << 8 | buffer[1];
   60|    921|  if ( nbits > MAX_EXTERN_MPI_BITS )
  ------------------
  |  |   43|    921|#define MAX_EXTERN_MPI_BITS 16384
  ------------------
  |  Branch (60:8): [True: 0, False: 921]
  ------------------
   61|      0|    {
   62|       |/*       log_debug ("mpi too large (%u bits)\n", nbits); */
   63|      0|      goto leave;
   64|      0|    }
   65|    921|  buffer += 2;
   66|    921|  nread = 2;
   67|       |
   68|    921|  nbytes = (nbits+7) / 8;
   69|    921|  nlimbs = (nbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|    921|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|    921|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
                nlimbs = (nbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|    921|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|    921|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
   70|    921|  val = secure? mpi_alloc_secure (nlimbs) : mpi_alloc (nlimbs);
  ------------------
  |  |   98|      0|# define mpi_alloc_secure(n)  _gcry_mpi_alloc_secure((n) )
  ------------------
                val = secure? mpi_alloc_secure (nlimbs) : mpi_alloc (nlimbs);
  ------------------
  |  |   97|  1.84k|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  |  Branch (70:9): [True: 0, False: 921]
  ------------------
   71|    921|  i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|    921|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|    921|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
                i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|    921|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|    921|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
   72|    921|  i %= BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|    921|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|    921|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
   73|    921|  j= val->nlimbs = nlimbs;
   74|    921|  val->sign = 0;
   75|  3.56k|  for ( ; j > 0; j-- )
  ------------------
  |  Branch (75:11): [True: 2.64k, False: 921]
  ------------------
   76|  2.64k|    {
   77|  2.64k|      a = 0;
   78|  2.64k|      if (i == 0 && nread + BYTES_PER_MPI_LIMB <= max_nread)
  ------------------
  |  |    4|  2.29k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|  2.29k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
  |  Branch (78:11): [True: 2.29k, False: 351]
  |  Branch (78:21): [True: 2.29k, False: 0]
  ------------------
   79|  2.29k|	{
   80|       |#if BYTES_PER_MPI_LIMB == 4
   81|       |	  a = buf_get_be32 (buffer);
   82|       |#elif BYTES_PER_MPI_LIMB == 8
   83|  2.29k|	  a = buf_get_be64 (buffer);
   84|       |#else
   85|       |#     error please implement for this limb size.
   86|       |#endif
   87|  2.29k|	  buffer += BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|  2.29k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|  2.29k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
   88|  2.29k|	  nread += BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|  2.29k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|  2.29k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
   89|  2.29k|	  i += BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|  2.29k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|  2.29k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
   90|  2.29k|	}
   91|  3.29k|      for (; i < BYTES_PER_MPI_LIMB; i++ )
  ------------------
  |  |    4|  3.29k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|  3.29k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
  |  Branch (91:14): [True: 657, False: 2.64k]
  ------------------
   92|    657|        {
   93|    657|          if ( ++nread > max_nread )
  ------------------
  |  Branch (93:16): [True: 0, False: 657]
  ------------------
   94|      0|            {
   95|       |/*               log_debug ("mpi larger than buffer"); */
   96|      0|              mpi_free (val);
  ------------------
  |  |   99|      0|# define mpi_free(a)	       _gcry_mpi_free((a) )
  ------------------
   97|      0|              val = NULL;
   98|      0|              goto leave;
   99|      0|            }
  100|    657|          a <<= 8;
  101|    657|          a |= *buffer++;
  102|    657|	}
  103|  2.64k|      i = 0;
  104|  2.64k|      val->d[j-1] = a;
  105|  2.64k|    }
  106|       |
  107|    921| leave:
  108|    921|  *ret_nread = nread;
  109|    921|  return val;
  110|    921|}
mpicoder.c:mpi_fromstr:
  118|    141|{
  119|    141|  static const int hex2int[2][256] =
  120|    141|  {
  121|    141|    {
  122|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  123|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  124|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0x00, 0x10, 0x20, 0x30,
  125|    141|      0x40, 0x50, 0x60, 0x70, 0x80, 0x90, -1, -1, -1, -1, -1, -1, -1, 0xa0,
  126|    141|      0xb0, 0xc0, 0xd0, 0xe0, 0xf0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  127|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0xa0,
  128|    141|      0xb0, 0xc0, 0xd0, 0xe0, 0xf0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  129|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  130|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  131|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  132|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  133|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  134|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  135|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  136|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  137|    141|    },
  138|    141|    {
  139|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  140|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  141|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0x00, 0x01, 0x02, 0x03,
  142|    141|      0x04, 0x05, 0x06, 0x07, 0x08, 0x09, -1, -1, -1, -1, -1, -1, -1, 0x0a,
  143|    141|      0x0b, 0x0c, 0x0d, 0x0e, 0x0f, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  144|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0x0a,
  145|    141|      0x0b, 0x0c, 0x0d, 0x0e, 0x0f, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  146|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  147|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  148|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  149|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  150|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  151|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  152|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  153|    141|      -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
  154|    141|    }
  155|    141|  };
  156|    141|  int sign = 0;
  157|    141|  int prepend_zero = 0;
  158|    141|  int i, j, c, c1, c2;
  159|    141|  unsigned int nbits, nbytes, nlimbs;
  160|    141|  mpi_limb_t a;
  161|       |
  162|    141|  if ( *str == '-' )
  ------------------
  |  Branch (162:8): [True: 0, False: 141]
  ------------------
  163|      0|    {
  164|      0|      sign = 1;
  165|      0|      str++;
  166|      0|      slen--;
  167|      0|    }
  168|       |
  169|       |  /* Skip optional hex prefix.  */
  170|    141|  if ( *str == '0' && str[1] == 'x' )
  ------------------
  |  Branch (170:8): [True: 141, False: 0]
  |  Branch (170:23): [True: 141, False: 0]
  ------------------
  171|    141|    {
  172|    141|      str += 2;
  173|    141|      slen -= 2;
  174|    141|    }
  175|       |
  176|    141|  nbits = slen * 4;
  177|    141|  if ((nbits % 8))
  ------------------
  |  Branch (177:7): [True: 0, False: 141]
  ------------------
  178|      0|    prepend_zero = 1;
  179|       |
  180|    141|  nbytes = (nbits+7) / 8;
  181|    141|  nlimbs = (nbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|    141|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|    141|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
                nlimbs = (nbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|    141|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|    141|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
  182|       |
  183|    141|  if ( val->alloced < nlimbs )
  ------------------
  |  Branch (183:8): [True: 0, False: 141]
  ------------------
  184|      0|    mpi_resize (val, nlimbs);
  ------------------
  |  |  100|      0|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  ------------------
  185|       |
  186|    141|  i = BYTES_PER_MPI_LIMB - (nbytes % BYTES_PER_MPI_LIMB);
  ------------------
  |  |    4|    141|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|    141|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
                i = BYTES_PER_MPI_LIMB - (nbytes % BYTES_PER_MPI_LIMB);
  ------------------
  |  |    4|    141|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|    141|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
  187|    141|  i %= BYTES_PER_MPI_LIMB;
  ------------------
  |  |    4|    141|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|    141|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
  188|    141|  j = val->nlimbs = nlimbs;
  189|    141|  val->sign = sign;
  190|    747|  for (; j > 0; j--)
  ------------------
  |  Branch (190:10): [True: 606, False: 141]
  ------------------
  191|    606|    {
  192|    606|      a = 0;
  193|       |
  194|    606|      if (prepend_zero == 0 && (i & 31) == 0)
  ------------------
  |  Branch (194:11): [True: 606, False: 0]
  |  Branch (194:32): [True: 597, False: 9]
  ------------------
  195|    597|	{
  196|  1.19k|	  while (slen >= sizeof(u32) * 2)
  ------------------
  |  Branch (196:11): [True: 1.19k, False: 0]
  ------------------
  197|  1.19k|	    {
  198|  1.19k|	      u32 n, m;
  199|  1.19k|	      u32 x, y;
  200|       |
  201|  1.19k|	      x = buf_get_le32(str);
  202|  1.19k|	      y = buf_get_le32(str + 4);
  203|  1.19k|	      str += 8;
  204|  1.19k|	      slen -= 8;
  205|       |
  206|  1.19k|	      a <<= 31; /* Two step to avoid compiler warning on 32-bit. */
  207|  1.19k|	      a <<= 1;
  208|       |
  209|  1.19k|	      n = (hex2int[0][(x >> 0) & 0xff]
  210|  1.19k|		   | hex2int[1][(x >> 8) & 0xff]) << 8;
  211|  1.19k|	      m = (hex2int[0][(y >> 0) & 0xff]
  212|  1.19k|		   | hex2int[1][(y >> 8) & 0xff]) << 8;
  213|  1.19k|	      n |= hex2int[0][(x >> 16) & 0xff];
  214|  1.19k|	      n |= hex2int[1][(x >> 24) & 0xff];
  215|  1.19k|	      m |= hex2int[0][(y >> 16) & 0xff];
  216|  1.19k|	      m |= hex2int[1][(y >> 24) & 0xff];
  217|       |
  218|  1.19k|	      a |= (n << 16) | m;
  219|  1.19k|	      i += 32;
  220|  1.19k|	      if ((int)(n | m) < 0)
  ------------------
  |  Branch (220:12): [True: 0, False: 1.19k]
  ------------------
  221|      0|		{
  222|       |		  /* Invalid character. */
  223|      0|		  mpi_clear (val);
  ------------------
  |  |  116|      0|#define mpi_clear(a)          _gcry_mpi_clear ((a))
  ------------------
  224|      0|		  return 1;  /* Error.  */
  225|      0|		}
  226|  1.19k|	      if (i == BITS_PER_MPI_LIMB)
  ------------------
  |  |   49|  1.19k|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|  1.19k|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|  1.19k|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (226:12): [True: 597, False: 597]
  ------------------
  227|    597|		break;
  228|  1.19k|	    }
  229|    597|	}
  230|       |
  231|    618|      for (; i < BYTES_PER_MPI_LIMB; i++)
  ------------------
  |  |    4|    618|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  ------------------
  |  |  |  |  524|    618|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  ------------------
  ------------------
  |  Branch (231:14): [True: 12, False: 606]
  ------------------
  232|     12|        {
  233|     12|          if (prepend_zero)
  ------------------
  |  Branch (233:15): [True: 0, False: 12]
  ------------------
  234|      0|            {
  235|      0|              c1 = '0';
  236|      0|              prepend_zero = 0;
  237|      0|	    }
  238|     12|          else
  239|     12|	    {
  240|     12|	      c1 = *str++;
  241|     12|	      slen--;
  242|     12|	    }
  243|       |
  244|     12|          if (!c1)
  ------------------
  |  Branch (244:15): [True: 0, False: 12]
  ------------------
  245|      0|            {
  246|      0|              mpi_clear (val);
  ------------------
  |  |  116|      0|#define mpi_clear(a)          _gcry_mpi_clear ((a))
  ------------------
  247|      0|              return 1;  /* Error.  */
  248|      0|	    }
  249|     12|          c2 = *str++;
  250|     12|	  slen--;
  251|     12|          if (!c2)
  ------------------
  |  Branch (251:15): [True: 0, False: 12]
  ------------------
  252|      0|            {
  253|      0|              mpi_clear (val);
  ------------------
  |  |  116|      0|#define mpi_clear(a)          _gcry_mpi_clear ((a))
  ------------------
  254|      0|              return 1;  /* Error.  */
  255|      0|	    }
  256|     12|	  c = hex2int[0][c1 & 0xff];
  257|     12|	  c |= hex2int[1][c2 & 0xff];
  258|     12|          if (c < 0)
  ------------------
  |  Branch (258:15): [True: 0, False: 12]
  ------------------
  259|      0|            {
  260|      0|              mpi_clear(val);
  ------------------
  |  |  116|      0|#define mpi_clear(a)          _gcry_mpi_clear ((a))
  ------------------
  261|      0|              return 1;  /* Error. */
  262|      0|	    }
  263|     12|          a <<= 8;
  264|     12|          a |= c;
  265|     12|	}
  266|    606|      i = 0;
  267|    606|      val->d[j-1] = a;
  268|    606|    }
  269|       |
  270|    141|  return 0;  /* Okay.  */
  271|    141|}

_gcry_mpih_add_n_cond:
   60|  73.7k|{
   61|  73.7k|  mpi_size_t i;
   62|  73.7k|  mpi_limb_t cy;
   63|  73.7k|  mpi_limb_t mask1 = vzero - op_enable;
   64|  73.7k|  mpi_limb_t mask2 = op_enable - vone;
   65|       |
   66|  73.7k|  cy = 0;
   67|   368k|  for (i = 0; i < usize; i++)
  ------------------
  |  Branch (67:15): [True: 294k, False: 73.7k]
  ------------------
   68|   294k|    {
   69|   294k|      mpi_limb_t u = up[i];
   70|   294k|      mpi_limb_t x = u + vp[i];
   71|   294k|      mpi_limb_t cy1 = x < u;
   72|   294k|      mpi_limb_t cy2;
   73|       |
   74|   294k|      x = x + cy;
   75|   294k|      cy2 = x < cy;
   76|   294k|      cy = cy1 | cy2;
   77|   294k|      wp[i] = (u & mask2) | (x & mask1);
   78|   294k|    }
   79|       |
   80|  73.7k|  return cy & mask1;
   81|  73.7k|}
_gcry_mpih_sub_n_cond:
   91|  49.1k|{
   92|  49.1k|  mpi_size_t i;
   93|  49.1k|  mpi_limb_t cy;
   94|  49.1k|  mpi_limb_t mask1 = vzero - op_enable;
   95|  49.1k|  mpi_limb_t mask2 = op_enable - vone;
   96|       |
   97|  49.1k|  cy = 0;
   98|   245k|  for (i = 0; i < usize; i++)
  ------------------
  |  Branch (98:15): [True: 196k, False: 49.1k]
  ------------------
   99|   196k|    {
  100|   196k|      mpi_limb_t u = up[i];
  101|   196k|      mpi_limb_t x = u - vp[i];
  102|   196k|      mpi_limb_t cy1 = x > u;
  103|   196k|      mpi_limb_t cy2;
  104|       |
  105|   196k|      cy2 = x < cy;
  106|   196k|      x = x - cy;
  107|   196k|      cy = cy1 | cy2;
  108|   196k|      wp[i] = (u & mask2) | (x & mask1);
  109|   196k|    }
  110|       |
  111|  49.1k|  return cy & mask1;
  112|  49.1k|}
_gcry_mpih_swap_cond:
  122|  24.5k|{
  123|  24.5k|  mpi_size_t i;
  124|  24.5k|  mpi_limb_t mask1 = vzero - op_enable;
  125|  24.5k|  mpi_limb_t mask2 = op_enable - vone;
  126|       |
  127|   122k|  for (i = 0; i < usize; i++)
  ------------------
  |  Branch (127:15): [True: 98.3k, False: 24.5k]
  ------------------
  128|  98.3k|    {
  129|  98.3k|      mpi_limb_t u = up[i];
  130|  98.3k|      mpi_limb_t v = vp[i];
  131|  98.3k|      up[i] = (u & mask2) | (v & mask1);
  132|  98.3k|      vp[i] = (u & mask1) | (v & mask2);
  133|  98.3k|    }
  134|  24.5k|}
_gcry_mpih_abs_cond:
  144|  24.5k|{
  145|  24.5k|  mpi_size_t i;
  146|  24.5k|  mpi_limb_t mask1 = vzero - op_enable;
  147|  24.5k|  mpi_limb_t mask2 = op_enable - vone;
  148|  24.5k|  mpi_limb_t cy = op_enable;
  149|       |
  150|   122k|  for (i = 0; i < usize; i++)
  ------------------
  |  Branch (150:15): [True: 98.3k, False: 24.5k]
  ------------------
  151|  98.3k|    {
  152|  98.3k|      mpi_limb_t u = up[i];
  153|  98.3k|      mpi_limb_t x = ~u + cy;
  154|       |
  155|  98.3k|      cy = (x < ~u);
  156|  98.3k|      wp[i] = (u & mask2) | (x & mask1);
  157|  98.3k|    }
  158|  24.5k|}
_gcry_mpih_cmp_ui:
  199|     48|{
  200|     48|  int is_all_zero = 1;
  201|     48|  mpi_size_t i;
  202|       |
  203|    192|  for (i = 1; i < usize; i++)
  ------------------
  |  Branch (203:15): [True: 144, False: 48]
  ------------------
  204|    144|    is_all_zero &= (up[i] == 0);
  205|       |
  206|     48|  if (is_all_zero)
  ------------------
  |  Branch (206:7): [True: 48, False: 0]
  ------------------
  207|     48|    {
  208|     48|      if (up[0] < v)
  ------------------
  |  Branch (208:11): [True: 0, False: 48]
  ------------------
  209|      0|        return -1;
  210|     48|      else if (up[0] > v)
  ------------------
  |  Branch (210:16): [True: 0, False: 48]
  ------------------
  211|      0|        return 1;
  212|     48|      else
  213|     48|        return 0;
  214|     48|    }
  215|      0|  return 1;
  216|     48|}

_gcry_mpih_divrem:
  210|  17.5k|{
  211|  17.5k|    mpi_limb_t most_significant_q_limb = 0;
  212|       |
  213|  17.5k|    switch(dsize) {
  214|      0|      case 0:
  ------------------
  |  Branch (214:7): [True: 0, False: 17.5k]
  ------------------
  215|      0|	_gcry_divide_by_zero();
  216|      0|	break;
  217|       |
  218|      0|      case 1:
  ------------------
  |  Branch (218:7): [True: 0, False: 17.5k]
  ------------------
  219|      0|	{
  220|      0|	    mpi_size_t i;
  221|      0|	    mpi_limb_t n1;
  222|      0|	    mpi_limb_t d;
  223|       |
  224|      0|	    d = dp[0];
  225|      0|	    n1 = np[nsize - 1];
  226|       |
  227|      0|	    if( n1 >= d ) {
  ------------------
  |  Branch (227:10): [True: 0, False: 0]
  ------------------
  228|      0|		n1 -= d;
  229|      0|		most_significant_q_limb = 1;
  230|      0|	    }
  231|       |
  232|      0|	    qp += qextra_limbs;
  233|      0|	    for( i = nsize - 2; i >= 0; i--)
  ------------------
  |  Branch (233:26): [True: 0, False: 0]
  ------------------
  234|      0|		udiv_qrnnd( qp[i], n1, n1, np[i], d );
  ------------------
  |  |  609|      0|  __asm__ ("divq %4"                                                    \
  |  |  610|      0|	   : "=a" ((q)),                                                \
  |  |  611|      0|	     "=d" ((r))                                                 \
  |  |  612|      0|	   : "0" ((UDItype)(n0)),                                       \
  |  |  613|      0|	     "1" ((UDItype)(n1)),                                       \
  |  |  614|      0|	     "rm" ((UDItype)(d))                                        \
  |  |  615|      0|	   __CLOBBER_CC)
  ------------------
  235|      0|	    qp -= qextra_limbs;
  236|       |
  237|      0|	    for( i = qextra_limbs - 1; i >= 0; i-- )
  ------------------
  |  Branch (237:33): [True: 0, False: 0]
  ------------------
  238|      0|		udiv_qrnnd (qp[i], n1, n1, 0, d);
  ------------------
  |  |  609|      0|  __asm__ ("divq %4"                                                    \
  |  |  610|      0|	   : "=a" ((q)),                                                \
  |  |  611|      0|	     "=d" ((r))                                                 \
  |  |  612|      0|	   : "0" ((UDItype)(n0)),                                       \
  |  |  613|      0|	     "1" ((UDItype)(n1)),                                       \
  |  |  614|      0|	     "rm" ((UDItype)(d))                                        \
  |  |  615|      0|	   __CLOBBER_CC)
  ------------------
  239|       |
  240|      0|	    np[0] = n1;
  241|      0|	}
  242|      0|	break;
  243|       |
  244|      0|      case 2:
  ------------------
  |  Branch (244:7): [True: 0, False: 17.5k]
  ------------------
  245|      0|	{
  246|      0|	    mpi_size_t i;
  247|      0|	    mpi_limb_t n1, n0, n2;
  248|      0|	    mpi_limb_t d1, d0;
  249|       |
  250|      0|	    np += nsize - 2;
  251|      0|	    d1 = dp[1];
  252|      0|	    d0 = dp[0];
  253|      0|	    n1 = np[1];
  254|      0|	    n0 = np[0];
  255|       |
  256|      0|	    if( n1 >= d1 && (n1 > d1 || n0 >= d0) ) {
  ------------------
  |  Branch (256:10): [True: 0, False: 0]
  |  Branch (256:23): [True: 0, False: 0]
  |  Branch (256:34): [True: 0, False: 0]
  ------------------
  257|      0|		sub_ddmmss (n1, n0, n1, n0, d1, d0);
  ------------------
  |  |  592|      0|  __asm__ ("subq %5,%1\n"                                               \
  |  |  593|      0|	   "sbbq %3,%0"                                                 \
  |  |  594|      0|	   : "=r" ((sh)),                                               \
  |  |  595|      0|	     "=&r" ((sl))                                               \
  |  |  596|      0|	   : "0" ((UDItype)(ah)),                                       \
  |  |  597|      0|	     "g" ((UDItype)(bh)),                                       \
  |  |  598|      0|	     "1" ((UDItype)(al)),                                       \
  |  |  599|      0|	     "g" ((UDItype)(bl))                                        \
  |  |  600|      0|	   __CLOBBER_CC)
  ------------------
  258|      0|		most_significant_q_limb = 1;
  259|      0|	    }
  260|       |
  261|      0|	    for( i = qextra_limbs + nsize - 2 - 1; i >= 0; i-- ) {
  ------------------
  |  Branch (261:45): [True: 0, False: 0]
  ------------------
  262|      0|		mpi_limb_t q;
  263|      0|		mpi_limb_t r;
  264|       |
  265|      0|		if( i >= qextra_limbs )
  ------------------
  |  Branch (265:7): [True: 0, False: 0]
  ------------------
  266|      0|		    np--;
  267|      0|		else
  268|      0|		    np[0] = 0;
  269|       |
  270|      0|		if( n1 == d1 ) {
  ------------------
  |  Branch (270:7): [True: 0, False: 0]
  ------------------
  271|       |		    /* Q should be either 111..111 or 111..110.  Need special
  272|       |		     * treatment of this rare case as normal division would
  273|       |		     * give overflow.  */
  274|      0|		    q = ~(mpi_limb_t)0;
  275|       |
  276|      0|		    r = n0 + d1;
  277|      0|		    if( r < d1 ) {   /* Carry in the addition? */
  ------------------
  |  Branch (277:11): [True: 0, False: 0]
  ------------------
  278|      0|			add_ssaaaa( n1, n0, r - d0, np[0], 0, d0 );
  ------------------
  |  |  582|      0|  __asm__ ("addq %5,%1\n"                                               \
  |  |  583|      0|	   "adcq %3,%0"                                                 \
  |  |  584|      0|	   : "=r" ((sh)),                                               \
  |  |  585|      0|	     "=&r" ((sl))                                               \
  |  |  586|      0|	   : "0" ((UDItype)(ah)),                                       \
  |  |  587|      0|	     "g"  ((UDItype)(bh)),                                      \
  |  |  588|      0|	     "1" ((UDItype)(al)),                                       \
  |  |  589|      0|	     "g"  ((UDItype)(bl))                                       \
  |  |  590|      0|	   __CLOBBER_CC)
  ------------------
  279|      0|			qp[i] = q;
  280|      0|			continue;
  281|      0|		    }
  282|      0|		    n1 = d0 - (d0 != 0?1:0);
  ------------------
  |  Branch (282:18): [True: 0, False: 0]
  ------------------
  283|      0|		    n0 = -d0;
  284|      0|		}
  285|      0|		else {
  286|      0|		    udiv_qrnnd (q, r, n1, n0, d1);
  ------------------
  |  |  609|      0|  __asm__ ("divq %4"                                                    \
  |  |  610|      0|	   : "=a" ((q)),                                                \
  |  |  611|      0|	     "=d" ((r))                                                 \
  |  |  612|      0|	   : "0" ((UDItype)(n0)),                                       \
  |  |  613|      0|	     "1" ((UDItype)(n1)),                                       \
  |  |  614|      0|	     "rm" ((UDItype)(d))                                        \
  |  |  615|      0|	   __CLOBBER_CC)
  ------------------
  287|      0|		    umul_ppmm (n1, n0, d0, q);
  ------------------
  |  |  602|      0|  __asm__ ("mulq %3"                                                    \
  |  |  603|      0|	   : "=a" ((w0)),                                               \
  |  |  604|      0|	     "=d" ((w1))                                                \
  |  |  605|      0|	   : "0" ((UDItype)(u)),                                        \
  |  |  606|      0|	     "rm" ((UDItype)(v))                                        \
  |  |  607|      0|	   __CLOBBER_CC)
  ------------------
  288|      0|		}
  289|       |
  290|      0|		n2 = np[0];
  291|      0|	      q_test:
  292|      0|		if( n1 > r || (n1 == r && n0 > n2) ) {
  ------------------
  |  Branch (292:7): [True: 0, False: 0]
  |  Branch (292:18): [True: 0, False: 0]
  |  Branch (292:29): [True: 0, False: 0]
  ------------------
  293|       |		    /* The estimated Q was too large.  */
  294|      0|		    q--;
  295|      0|		    sub_ddmmss (n1, n0, n1, n0, 0, d0);
  ------------------
  |  |  592|      0|  __asm__ ("subq %5,%1\n"                                               \
  |  |  593|      0|	   "sbbq %3,%0"                                                 \
  |  |  594|      0|	   : "=r" ((sh)),                                               \
  |  |  595|      0|	     "=&r" ((sl))                                               \
  |  |  596|      0|	   : "0" ((UDItype)(ah)),                                       \
  |  |  597|      0|	     "g" ((UDItype)(bh)),                                       \
  |  |  598|      0|	     "1" ((UDItype)(al)),                                       \
  |  |  599|      0|	     "g" ((UDItype)(bl))                                        \
  |  |  600|      0|	   __CLOBBER_CC)
  ------------------
  296|      0|		    r += d1;
  297|      0|		    if( r >= d1 )    /* If not carry, test Q again.  */
  ------------------
  |  Branch (297:11): [True: 0, False: 0]
  ------------------
  298|      0|			goto q_test;
  299|      0|		}
  300|       |
  301|      0|		qp[i] = q;
  302|      0|		sub_ddmmss (n1, n0, r, n2, n1, n0);
  ------------------
  |  |  592|      0|  __asm__ ("subq %5,%1\n"                                               \
  |  |  593|      0|	   "sbbq %3,%0"                                                 \
  |  |  594|      0|	   : "=r" ((sh)),                                               \
  |  |  595|      0|	     "=&r" ((sl))                                               \
  |  |  596|      0|	   : "0" ((UDItype)(ah)),                                       \
  |  |  597|      0|	     "g" ((UDItype)(bh)),                                       \
  |  |  598|      0|	     "1" ((UDItype)(al)),                                       \
  |  |  599|      0|	     "g" ((UDItype)(bl))                                        \
  |  |  600|      0|	   __CLOBBER_CC)
  ------------------
  303|      0|	    }
  304|      0|	    np[1] = n1;
  305|      0|	    np[0] = n0;
  306|      0|	}
  307|      0|	break;
  308|       |
  309|  17.5k|      default:
  ------------------
  |  Branch (309:7): [True: 17.5k, False: 0]
  ------------------
  310|  17.5k|	{
  311|  17.5k|	    mpi_size_t i;
  312|  17.5k|	    mpi_limb_t dX, d1, n0;
  313|       |
  314|  17.5k|	    np += nsize - dsize;
  315|  17.5k|	    dX = dp[dsize - 1];
  316|  17.5k|	    d1 = dp[dsize - 2];
  317|  17.5k|	    n0 = np[dsize - 1];
  318|       |
  319|  17.5k|	    if( n0 >= dX ) {
  ------------------
  |  Branch (319:10): [True: 0, False: 17.5k]
  ------------------
  320|      0|		if(n0 > dX || _gcry_mpih_cmp(np, dp, dsize - 1) >= 0 ) {
  ------------------
  |  Branch (320:6): [True: 0, False: 0]
  |  Branch (320:17): [True: 0, False: 0]
  ------------------
  321|      0|		    _gcry_mpih_sub_n(np, np, dp, dsize);
  322|      0|		    n0 = np[dsize - 1];
  323|      0|		    most_significant_q_limb = 1;
  324|      0|		}
  325|      0|	    }
  326|       |
  327|  71.6k|	    for( i = qextra_limbs + nsize - dsize - 1; i >= 0; i--) {
  ------------------
  |  Branch (327:49): [True: 54.1k, False: 17.5k]
  ------------------
  328|  54.1k|		mpi_limb_t q;
  329|  54.1k|		mpi_limb_t n1, n2;
  330|  54.1k|		mpi_limb_t cy_limb;
  331|       |
  332|  54.1k|		if( i >= qextra_limbs ) {
  ------------------
  |  Branch (332:7): [True: 54.1k, False: 0]
  ------------------
  333|  54.1k|		    np--;
  334|  54.1k|		    n2 = np[dsize];
  335|  54.1k|		}
  336|      0|		else {
  337|      0|		    n2 = np[dsize - 1];
  338|      0|		    MPN_COPY_DECR (np + 1, np, dsize - 1);
  ------------------
  |  |  104|      0|    do {				\
  |  |  105|      0|	mpi_size_t _i;			\
  |  |  106|      0|	for( _i = (n)-1; _i >= 0; _i--) \
  |  |  ------------------
  |  |  |  Branch (106:19): [True: 0, False: 0]
  |  |  ------------------
  |  |  107|      0|	   (d)[_i] = (s)[_i];		\
  |  |  108|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (108:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  339|      0|		    np[0] = 0;
  340|      0|		}
  341|       |
  342|  54.1k|		if( n0 == dX ) {
  ------------------
  |  Branch (342:7): [True: 0, False: 54.1k]
  ------------------
  343|       |		    /* This might over-estimate q, but it's probably not worth
  344|       |		     * the extra code here to find out.  */
  345|      0|		    q = ~(mpi_limb_t)0;
  346|      0|		}
  347|  54.1k|		else {
  348|  54.1k|		    mpi_limb_t r;
  349|       |
  350|  54.1k|		    udiv_qrnnd(q, r, n0, np[dsize - 1], dX);
  ------------------
  |  |  609|  54.1k|  __asm__ ("divq %4"                                                    \
  |  |  610|  54.1k|	   : "=a" ((q)),                                                \
  |  |  611|  54.1k|	     "=d" ((r))                                                 \
  |  |  612|  54.1k|	   : "0" ((UDItype)(n0)),                                       \
  |  |  613|  54.1k|	     "1" ((UDItype)(n1)),                                       \
  |  |  614|  54.1k|	     "rm" ((UDItype)(d))                                        \
  |  |  615|  54.1k|	   __CLOBBER_CC)
  ------------------
  351|  54.1k|		    umul_ppmm(n1, n0, d1, q);
  ------------------
  |  |  602|  54.1k|  __asm__ ("mulq %3"                                                    \
  |  |  603|  54.1k|	   : "=a" ((w0)),                                               \
  |  |  604|  54.1k|	     "=d" ((w1))                                                \
  |  |  605|  54.1k|	   : "0" ((UDItype)(u)),                                        \
  |  |  606|  54.1k|	     "rm" ((UDItype)(v))                                        \
  |  |  607|  54.1k|	   __CLOBBER_CC)
  ------------------
  352|       |
  353|  56.9k|		    while( n1 > r || (n1 == r && n0 > np[dsize - 2])) {
  ------------------
  |  Branch (353:14): [True: 4.08k, False: 52.8k]
  |  Branch (353:25): [True: 0, False: 52.8k]
  |  Branch (353:36): [True: 0, False: 0]
  ------------------
  354|  4.08k|			q--;
  355|  4.08k|			r += dX;
  356|  4.08k|			if( r < dX ) /* I.e. "carry in previous addition?" */
  ------------------
  |  Branch (356:8): [True: 1.29k, False: 2.79k]
  ------------------
  357|  1.29k|			    break;
  358|  2.79k|			n1 -= n0 < d1;
  359|  2.79k|			n0 -= d1;
  360|  2.79k|		    }
  361|  54.1k|		}
  362|       |
  363|       |		/* Possible optimization: We already have (q * n0) and (1 * n1)
  364|       |		 * after the calculation of q.	Taking advantage of that, we
  365|       |		 * could make this loop make two iterations less.  */
  366|  54.1k|		cy_limb = _gcry_mpih_submul_1(np, dp, dsize, q);
  367|       |
  368|  54.1k|		if( n2 != cy_limb ) {
  ------------------
  |  Branch (368:7): [True: 0, False: 54.1k]
  ------------------
  369|      0|		    _gcry_mpih_add_n(np, np, dp, dsize);
  370|      0|		    q--;
  371|      0|		}
  372|       |
  373|  54.1k|		qp[i] = q;
  374|  54.1k|		n0 = np[dsize - 1];
  375|  54.1k|	    }
  376|  17.5k|	}
  377|  17.5k|    }
  378|       |
  379|  17.5k|    return most_significant_q_limb;
  380|  17.5k|}

_gcry_mpih_mul_karatsuba_case:
  382|    255|{
  383|    255|    mpi_limb_t cy;
  384|       |
  385|    255|    if( !ctx->tspace || ctx->tspace_size < vsize ) {
  ------------------
  |  Branch (385:9): [True: 15, False: 240]
  |  Branch (385:25): [True: 0, False: 240]
  ------------------
  386|     15|	if( ctx->tspace )
  ------------------
  |  Branch (386:6): [True: 0, False: 15]
  ------------------
  387|      0|	    _gcry_mpi_free_limb_space( ctx->tspace, ctx->tspace_nlimbs );
  388|     15|        ctx->tspace_nlimbs = 2 * vsize;
  389|     15|	ctx->tspace = mpi_alloc_limb_space (2 * vsize,
  ------------------
  |  |  178|     30|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  |  |  ------------------
  |  |  |  Branch (178:68): [True: 0, False: 15]
  |  |  |  Branch (178:68): [True: 0, False: 15]
  |  |  ------------------
  ------------------
  390|     15|				            (_gcry_is_secure (up)
  391|     15|                                             || _gcry_is_secure (vp)));
  392|     15|	ctx->tspace_size = vsize;
  393|     15|    }
  394|       |
  395|    255|    MPN_MUL_N_RECURSE( prodp, up, vp, vsize, ctx->tspace );
  ------------------
  |  |   37|    255|    do {						\
  |  |   38|    255|	if( (size) < KARATSUBA_THRESHOLD )		\
  |  |  ------------------
  |  |  |  |   61|    255|#define KARATSUBA_THRESHOLD 16
  |  |  ------------------
  |  |  |  Branch (38:6): [True: 0, False: 255]
  |  |  ------------------
  |  |   39|    255|	    mul_n_basecase (prodp, up, vp, size);	\
  |  |   40|    255|	else						\
  |  |   41|    255|	    mul_n (prodp, up, vp, size, tspace);	\
  |  |   42|    255|    } while (0)
  |  |  ------------------
  |  |  |  Branch (42:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  396|       |
  397|    255|    prodp += vsize;
  398|    255|    up += vsize;
  399|    255|    usize -= vsize;
  400|    255|    if( usize >= vsize ) {
  ------------------
  |  Branch (400:9): [True: 0, False: 255]
  ------------------
  401|      0|	if( !ctx->tp || ctx->tp_size < vsize ) {
  ------------------
  |  Branch (401:6): [True: 0, False: 0]
  |  Branch (401:18): [True: 0, False: 0]
  ------------------
  402|      0|	    if( ctx->tp )
  ------------------
  |  Branch (402:10): [True: 0, False: 0]
  ------------------
  403|      0|		_gcry_mpi_free_limb_space( ctx->tp, ctx->tp_nlimbs );
  404|      0|            ctx->tp_nlimbs = 2 * vsize;
  405|      0|	    ctx->tp = mpi_alloc_limb_space (2 * vsize,
  ------------------
  |  |  178|      0|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  |  |  ------------------
  |  |  |  Branch (178:68): [True: 0, False: 0]
  |  |  |  Branch (178:68): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  406|      0|                                            (_gcry_is_secure (up)
  407|      0|                                             || _gcry_is_secure (vp)));
  408|      0|	    ctx->tp_size = vsize;
  409|      0|	}
  410|       |
  411|      0|	do {
  412|      0|	    MPN_MUL_N_RECURSE( ctx->tp, up, vp, vsize, ctx->tspace );
  ------------------
  |  |   37|      0|    do {						\
  |  |   38|      0|	if( (size) < KARATSUBA_THRESHOLD )		\
  |  |  ------------------
  |  |  |  |   61|      0|#define KARATSUBA_THRESHOLD 16
  |  |  ------------------
  |  |  |  Branch (38:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   39|      0|	    mul_n_basecase (prodp, up, vp, size);	\
  |  |   40|      0|	else						\
  |  |   41|      0|	    mul_n (prodp, up, vp, size, tspace);	\
  |  |   42|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (42:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  413|      0|	    cy = _gcry_mpih_add_n( prodp, prodp, ctx->tp, vsize );
  414|      0|	    _gcry_mpih_add_1( prodp + vsize, ctx->tp + vsize, vsize, cy );
  415|      0|	    prodp += vsize;
  416|      0|	    up += vsize;
  417|      0|	    usize -= vsize;
  418|      0|	} while( usize >= vsize );
  ------------------
  |  Branch (418:11): [True: 0, False: 0]
  ------------------
  419|      0|    }
  420|       |
  421|    255|    if( usize ) {
  ------------------
  |  Branch (421:9): [True: 0, False: 255]
  ------------------
  422|      0|	if( usize < KARATSUBA_THRESHOLD ) {
  ------------------
  |  |   61|      0|#define KARATSUBA_THRESHOLD 16
  ------------------
  |  Branch (422:6): [True: 0, False: 0]
  ------------------
  423|      0|	    _gcry_mpih_mul( ctx->tspace, vp, vsize, up, usize );
  424|      0|	}
  425|      0|	else {
  426|      0|	    if( !ctx->next ) {
  ------------------
  |  Branch (426:10): [True: 0, False: 0]
  ------------------
  427|      0|		ctx->next = xcalloc( 1, sizeof *ctx );
  ------------------
  |  |  145|      0|#define xcalloc(a,b)     _gcry_xcalloc ((a),(b))
  ------------------
  428|      0|	    }
  429|      0|	    _gcry_mpih_mul_karatsuba_case( ctx->tspace,
  430|      0|					vp, vsize,
  431|      0|					up, usize,
  432|      0|					ctx->next );
  433|      0|	}
  434|       |
  435|      0|	cy = _gcry_mpih_add_n( prodp, prodp, ctx->tspace, vsize);
  436|      0|	_gcry_mpih_add_1( prodp + vsize, ctx->tspace + vsize, usize, cy );
  437|      0|    }
  438|    255|}
_gcry_mpih_release_karatsuba_ctx:
  443|  8.57k|{
  444|  8.57k|    struct karatsuba_ctx *ctx2;
  445|       |
  446|  8.57k|    if( ctx->tp )
  ------------------
  |  Branch (446:9): [True: 0, False: 8.57k]
  ------------------
  447|      0|	_gcry_mpi_free_limb_space( ctx->tp, ctx->tp_nlimbs );
  448|  8.57k|    if( ctx->tspace )
  ------------------
  |  Branch (448:9): [True: 15, False: 8.56k]
  ------------------
  449|     15|	_gcry_mpi_free_limb_space( ctx->tspace, ctx->tspace_nlimbs );
  450|  8.57k|    for( ctx=ctx->next; ctx; ctx = ctx2 ) {
  ------------------
  |  Branch (450:25): [True: 0, False: 8.57k]
  ------------------
  451|      0|	ctx2 = ctx->next;
  452|      0|	if( ctx->tp )
  ------------------
  |  Branch (452:6): [True: 0, False: 0]
  ------------------
  453|      0|            _gcry_mpi_free_limb_space( ctx->tp, ctx->tp_nlimbs );
  454|      0|	if( ctx->tspace )
  ------------------
  |  Branch (454:6): [True: 0, False: 0]
  ------------------
  455|      0|	    _gcry_mpi_free_limb_space( ctx->tspace, ctx->tspace_nlimbs );
  456|      0|	xfree( ctx );
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  457|      0|    }
  458|  8.57k|}
_gcry_mpih_mul:
  478|   140k|{
  479|   140k|    mpi_ptr_t prod_endp = prodp + usize + vsize - 1;
  480|   140k|    mpi_limb_t cy;
  481|   140k|    struct karatsuba_ctx ctx;
  482|       |
  483|   140k|    if( vsize < KARATSUBA_THRESHOLD ) {
  ------------------
  |  |   61|   140k|#define KARATSUBA_THRESHOLD 16
  ------------------
  |  Branch (483:9): [True: 140k, False: 0]
  ------------------
  484|   140k|	mpi_size_t i;
  485|   140k|	mpi_limb_t v_limb;
  486|       |
  487|   140k|	if( !vsize )
  ------------------
  |  Branch (487:6): [True: 0, False: 140k]
  ------------------
  488|      0|	    return 0;
  489|       |
  490|       |	/* Multiply by the first limb in V separately, as the result can be
  491|       |	 * stored (not added) to PROD.	We also avoid a loop for zeroing.  */
  492|   140k|	v_limb = vp[0];
  493|   140k|	if( v_limb <= 1 ) {
  ------------------
  |  Branch (493:6): [True: 14.2k, False: 126k]
  ------------------
  494|  14.2k|	    if( v_limb == 1 )
  ------------------
  |  Branch (494:10): [True: 11.3k, False: 2.84k]
  ------------------
  495|  11.3k|		MPN_COPY( prodp, up, usize );
  ------------------
  |  |   90|  11.3k|    do {				\
  |  |   91|  11.3k|	mpi_size_t _i;			\
  |  |   92|  42.7k|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 31.3k, False: 11.3k]
  |  |  ------------------
  |  |   93|  31.3k|	    (d)[_i] = (s)[_i];		\
  |  |   94|  11.3k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  496|  2.84k|	    else
  497|  2.84k|		MPN_ZERO( prodp, usize );
  ------------------
  |  |  112|  2.84k|    do {				  \
  |  |  113|  2.84k|	int  _i;			  \
  |  |  114|  14.2k|	for( _i = 0; _i < (n); _i++ )  \
  |  |  ------------------
  |  |  |  Branch (114:15): [True: 11.3k, False: 2.84k]
  |  |  ------------------
  |  |  115|  11.3k|	    (d)[_i] = 0;		    \
  |  |  116|  2.84k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (116:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  498|  14.2k|	    cy = 0;
  499|  14.2k|	}
  500|   126k|	else
  501|   126k|	    cy = _gcry_mpih_mul_1( prodp, up, usize, v_limb );
  502|       |
  503|   140k|	prodp[usize] = cy;
  504|   140k|	prodp++;
  505|       |
  506|       |	/* For each iteration in the outer loop, multiply one limb from
  507|       |	 * U with one limb from V, and add it to PROD.	*/
  508|   456k|	for( i = 1; i < vsize; i++ ) {
  ------------------
  |  Branch (508:14): [True: 315k, False: 140k]
  ------------------
  509|   315k|	    v_limb = vp[i];
  510|   315k|	    if( v_limb <= 1 ) {
  ------------------
  |  Branch (510:10): [True: 0, False: 315k]
  ------------------
  511|      0|		cy = 0;
  512|      0|		if( v_limb == 1 )
  ------------------
  |  Branch (512:7): [True: 0, False: 0]
  ------------------
  513|      0|		   cy = _gcry_mpih_add_n(prodp, prodp, up, usize);
  514|      0|	    }
  515|   315k|	    else
  516|   315k|		cy = _gcry_mpih_addmul_1(prodp, up, usize, v_limb);
  517|       |
  518|   315k|	    prodp[usize] = cy;
  519|   315k|	    prodp++;
  520|   315k|	}
  521|       |
  522|   140k|	return cy;
  523|   140k|    }
  524|       |
  525|      0|    memset( &ctx, 0, sizeof ctx );
  526|      0|    _gcry_mpih_mul_karatsuba_case( prodp, up, usize, vp, vsize, &ctx );
  527|      0|    _gcry_mpih_release_karatsuba_ctx( &ctx );
  528|      0|    return *prod_endp;
  529|   140k|}
mpih-mul.c:mul_n_basecase:
   75|  2.29k|{
   76|  2.29k|    mpi_size_t i;
   77|  2.29k|    mpi_limb_t cy;
   78|  2.29k|    mpi_limb_t v_limb;
   79|       |
   80|       |    /* Multiply by the first limb in V separately, as the result can be
   81|       |     * stored (not added) to PROD.  We also avoid a loop for zeroing.  */
   82|  2.29k|    v_limb = vp[0];
   83|  2.29k|    if( v_limb <= 1 ) {
  ------------------
  |  Branch (83:9): [True: 0, False: 2.29k]
  ------------------
   84|      0|	if( v_limb == 1 )
  ------------------
  |  Branch (84:6): [True: 0, False: 0]
  ------------------
   85|      0|	    MPN_COPY( prodp, up, size );
  ------------------
  |  |   90|      0|    do {				\
  |  |   91|      0|	mpi_size_t _i;			\
  |  |   92|      0|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 0, False: 0]
  |  |  ------------------
  |  |   93|      0|	    (d)[_i] = (s)[_i];		\
  |  |   94|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
   86|      0|	else
   87|      0|	    MPN_ZERO( prodp, size );
  ------------------
  |  |  112|      0|    do {				  \
  |  |  113|      0|	int  _i;			  \
  |  |  114|      0|	for( _i = 0; _i < (n); _i++ )  \
  |  |  ------------------
  |  |  |  Branch (114:15): [True: 0, False: 0]
  |  |  ------------------
  |  |  115|      0|	    (d)[_i] = 0;		    \
  |  |  116|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (116:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
   88|      0|	cy = 0;
   89|      0|    }
   90|  2.29k|    else
   91|  2.29k|	cy = _gcry_mpih_mul_1( prodp, up, size, v_limb );
   92|       |
   93|  2.29k|    prodp[size] = cy;
   94|  2.29k|    prodp++;
   95|       |
   96|       |    /* For each iteration in the outer loop, multiply one limb from
   97|       |     * U with one limb from V, and add it to PROD.  */
   98|  18.3k|    for( i = 1; i < size; i++ ) {
  ------------------
  |  Branch (98:17): [True: 16.0k, False: 2.29k]
  ------------------
   99|  16.0k|	v_limb = vp[i];
  100|  16.0k|	if( v_limb <= 1 ) {
  ------------------
  |  Branch (100:6): [True: 0, False: 16.0k]
  ------------------
  101|      0|	    cy = 0;
  102|      0|	    if( v_limb == 1 )
  ------------------
  |  Branch (102:10): [True: 0, False: 0]
  ------------------
  103|      0|	       cy = _gcry_mpih_add_n(prodp, prodp, up, size);
  104|      0|	}
  105|  16.0k|	else
  106|  16.0k|	    cy = _gcry_mpih_addmul_1(prodp, up, size, v_limb);
  107|       |
  108|  16.0k|	prodp[size] = cy;
  109|  16.0k|	prodp++;
  110|  16.0k|    }
  111|       |
  112|  2.29k|    return cy;
  113|  2.29k|}
mpih-mul.c:mul_n:
  119|  1.02k|{
  120|  1.02k|    if( size & 1 ) {
  ------------------
  |  Branch (120:9): [True: 0, False: 1.02k]
  ------------------
  121|       |      /* The size is odd, and the code below doesn't handle that.
  122|       |       * Multiply the least significant (size - 1) limbs with a recursive
  123|       |       * call, and handle the most significant limb of S1 and S2
  124|       |       * separately.
  125|       |       * A slightly faster way to do this would be to make the Karatsuba
  126|       |       * code below behave as if the size were even, and let it check for
  127|       |       * odd size in the end.  I.e., in essence move this code to the end.
  128|       |       * Doing so would save us a recursive call, and potentially make the
  129|       |       * stack grow a lot less.
  130|       |       */
  131|      0|      mpi_size_t esize = size - 1;	 /* even size */
  132|      0|      mpi_limb_t cy_limb;
  133|       |
  134|      0|      MPN_MUL_N_RECURSE( prodp, up, vp, esize, tspace );
  ------------------
  |  |   37|      0|    do {						\
  |  |   38|      0|	if( (size) < KARATSUBA_THRESHOLD )		\
  |  |  ------------------
  |  |  |  |   61|      0|#define KARATSUBA_THRESHOLD 16
  |  |  ------------------
  |  |  |  Branch (38:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   39|      0|	    mul_n_basecase (prodp, up, vp, size);	\
  |  |   40|      0|	else						\
  |  |   41|      0|	    mul_n (prodp, up, vp, size, tspace);	\
  |  |   42|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (42:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  135|      0|      cy_limb = _gcry_mpih_addmul_1( prodp + esize, up, esize, vp[esize] );
  136|      0|      prodp[esize + esize] = cy_limb;
  137|      0|      cy_limb = _gcry_mpih_addmul_1( prodp + esize, vp, size, up[esize] );
  138|      0|      prodp[esize + size] = cy_limb;
  139|      0|    }
  140|  1.02k|    else {
  141|       |	/* Anatolij Alekseevich Karatsuba's divide-and-conquer algorithm.
  142|       |	 *
  143|       |	 * Split U in two pieces, U1 and U0, such that
  144|       |	 * U = U0 + U1*(B**n),
  145|       |	 * and V in V1 and V0, such that
  146|       |	 * V = V0 + V1*(B**n).
  147|       |	 *
  148|       |	 * UV is then computed recursively using the identity
  149|       |	 *
  150|       |	 *	  2n   n	  n			n
  151|       |	 * UV = (B  + B )U V  +  B (U -U )(V -V )  +  (B + 1)U V
  152|       |	 *		  1 1	     1	0   0  1	      0 0
  153|       |	 *
  154|       |	 * Where B = 2**BITS_PER_MP_LIMB.
  155|       |	 */
  156|  1.02k|	mpi_size_t hsize = size >> 1;
  157|  1.02k|	mpi_limb_t cy;
  158|  1.02k|	int negflg;
  159|       |
  160|       |	/* Product H.	   ________________  ________________
  161|       |	 *		  |_____U1 x V1____||____U0 x V0_____|
  162|       |	 * Put result in upper part of PROD and pass low part of TSPACE
  163|       |	 * as new TSPACE.
  164|       |	 */
  165|  1.02k|	MPN_MUL_N_RECURSE(prodp + size, up + hsize, vp + hsize, hsize, tspace);
  ------------------
  |  |   37|  1.02k|    do {						\
  |  |   38|  1.02k|	if( (size) < KARATSUBA_THRESHOLD )		\
  |  |  ------------------
  |  |  |  |   61|  1.02k|#define KARATSUBA_THRESHOLD 16
  |  |  ------------------
  |  |  |  Branch (38:6): [True: 765, False: 255]
  |  |  ------------------
  |  |   39|  1.02k|	    mul_n_basecase (prodp, up, vp, size);	\
  |  |   40|  1.02k|	else						\
  |  |   41|  1.02k|	    mul_n (prodp, up, vp, size, tspace);	\
  |  |   42|  1.02k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (42:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  166|       |
  167|       |	/* Product M.	   ________________
  168|       |	 *		  |_(U1-U0)(V0-V1)_|
  169|       |	 */
  170|  1.02k|	if( _gcry_mpih_cmp(up + hsize, up, hsize) >= 0 ) {
  ------------------
  |  Branch (170:6): [True: 441, False: 579]
  ------------------
  171|    441|	    _gcry_mpih_sub_n(prodp, up + hsize, up, hsize);
  172|    441|	    negflg = 0;
  173|    441|	}
  174|    579|	else {
  175|    579|	    _gcry_mpih_sub_n(prodp, up, up + hsize, hsize);
  176|    579|	    negflg = 1;
  177|    579|	}
  178|  1.02k|	if( _gcry_mpih_cmp(vp + hsize, vp, hsize) >= 0 ) {
  ------------------
  |  Branch (178:6): [True: 465, False: 555]
  ------------------
  179|    465|	    _gcry_mpih_sub_n(prodp + hsize, vp + hsize, vp, hsize);
  180|    465|	    negflg ^= 1;
  181|    465|	}
  182|    555|	else {
  183|    555|	    _gcry_mpih_sub_n(prodp + hsize, vp, vp + hsize, hsize);
  184|       |	    /* No change of NEGFLG.  */
  185|    555|	}
  186|       |	/* Read temporary operands from low part of PROD.
  187|       |	 * Put result in low part of TSPACE using upper part of TSPACE
  188|       |	 * as new TSPACE.
  189|       |	 */
  190|  1.02k|	MPN_MUL_N_RECURSE(tspace, prodp, prodp + hsize, hsize, tspace + size);
  ------------------
  |  |   37|  1.02k|    do {						\
  |  |   38|  1.02k|	if( (size) < KARATSUBA_THRESHOLD )		\
  |  |  ------------------
  |  |  |  |   61|  1.02k|#define KARATSUBA_THRESHOLD 16
  |  |  ------------------
  |  |  |  Branch (38:6): [True: 765, False: 255]
  |  |  ------------------
  |  |   39|  1.02k|	    mul_n_basecase (prodp, up, vp, size);	\
  |  |   40|  1.02k|	else						\
  |  |   41|  1.02k|	    mul_n (prodp, up, vp, size, tspace);	\
  |  |   42|  1.02k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (42:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  191|       |
  192|       |	/* Add/copy product H. */
  193|  1.02k|	MPN_COPY (prodp + hsize, prodp + size, hsize);
  ------------------
  |  |   90|  1.02k|    do {				\
  |  |   91|  1.02k|	mpi_size_t _i;			\
  |  |   92|  11.2k|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 10.2k, False: 1.02k]
  |  |  ------------------
  |  |   93|  10.2k|	    (d)[_i] = (s)[_i];		\
  |  |   94|  1.02k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  194|  1.02k|	cy = _gcry_mpih_add_n( prodp + size, prodp + size,
  195|  1.02k|			    prodp + size + hsize, hsize);
  196|       |
  197|       |	/* Add product M (if NEGFLG M is a negative number) */
  198|  1.02k|	if(negflg)
  ------------------
  |  Branch (198:5): [True: 978, False: 42]
  ------------------
  199|    978|	    cy -= _gcry_mpih_sub_n(prodp + hsize, prodp + hsize, tspace, size);
  200|     42|	else
  201|     42|	    cy += _gcry_mpih_add_n(prodp + hsize, prodp + hsize, tspace, size);
  202|       |
  203|       |	/* Product L.	   ________________  ________________
  204|       |	 *		  |________________||____U0 x V0_____|
  205|       |	 * Read temporary operands from low part of PROD.
  206|       |	 * Put result in low part of TSPACE using upper part of TSPACE
  207|       |	 * as new TSPACE.
  208|       |	 */
  209|  1.02k|	MPN_MUL_N_RECURSE(tspace, up, vp, hsize, tspace + size);
  ------------------
  |  |   37|  1.02k|    do {						\
  |  |   38|  1.02k|	if( (size) < KARATSUBA_THRESHOLD )		\
  |  |  ------------------
  |  |  |  |   61|  1.02k|#define KARATSUBA_THRESHOLD 16
  |  |  ------------------
  |  |  |  Branch (38:6): [True: 765, False: 255]
  |  |  ------------------
  |  |   39|  1.02k|	    mul_n_basecase (prodp, up, vp, size);	\
  |  |   40|  1.02k|	else						\
  |  |   41|  1.02k|	    mul_n (prodp, up, vp, size, tspace);	\
  |  |   42|  1.02k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (42:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  210|       |
  211|       |	/* Add/copy Product L (twice) */
  212|       |
  213|  1.02k|	cy += _gcry_mpih_add_n(prodp + hsize, prodp + hsize, tspace, size);
  214|  1.02k|	if( cy )
  ------------------
  |  Branch (214:6): [True: 474, False: 546]
  ------------------
  215|    474|	  _gcry_mpih_add_1(prodp + hsize + size, prodp + hsize + size, hsize, cy);
  216|       |
  217|  1.02k|	MPN_COPY(prodp, tspace, hsize);
  ------------------
  |  |   90|  1.02k|    do {				\
  |  |   91|  1.02k|	mpi_size_t _i;			\
  |  |   92|  11.2k|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 10.2k, False: 1.02k]
  |  |  ------------------
  |  |   93|  10.2k|	    (d)[_i] = (s)[_i];		\
  |  |   94|  1.02k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  218|  1.02k|	cy = _gcry_mpih_add_n(prodp + hsize, prodp + hsize, tspace + hsize, hsize);
  219|  1.02k|	if( cy )
  ------------------
  |  Branch (219:6): [True: 345, False: 675]
  ------------------
  220|    345|	    _gcry_mpih_add_1(prodp + size, prodp + size, size, 1);
  221|  1.02k|    }
  222|  1.02k|}

_gcry_mpi_init:
   67|      1|{
   68|      1|  int idx;
   69|      1|  unsigned long value;
   70|       |
   71|      7|  for (idx=0; idx < MPI_NUMBER_OF_CONSTANTS; idx++)
  ------------------
  |  |  144|      7|#define MPI_NUMBER_OF_CONSTANTS 6
  ------------------
  |  Branch (71:15): [True: 6, False: 1]
  ------------------
   72|      6|    {
   73|      6|      switch (idx)
   74|      6|        {
   75|      1|        case MPI_C_ZERO:  value = 0; break;
  ------------------
  |  Branch (75:9): [True: 1, False: 5]
  ------------------
   76|      1|        case MPI_C_ONE:   value = 1; break;
  ------------------
  |  Branch (76:9): [True: 1, False: 5]
  ------------------
   77|      1|        case MPI_C_TWO:   value = 2; break;
  ------------------
  |  Branch (77:9): [True: 1, False: 5]
  ------------------
   78|      1|        case MPI_C_THREE: value = 3; break;
  ------------------
  |  Branch (78:9): [True: 1, False: 5]
  ------------------
   79|      1|        case MPI_C_FOUR:  value = 4; break;
  ------------------
  |  Branch (79:9): [True: 1, False: 5]
  ------------------
   80|      1|        case MPI_C_EIGHT: value = 8; break;
  ------------------
  |  Branch (80:9): [True: 1, False: 5]
  ------------------
   81|      0|        default: log_bug ("invalid mpi_const selector %d\n", idx);
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
  |  Branch (81:9): [True: 0, False: 6]
  ------------------
   82|      6|        }
   83|      6|      constants[idx] = mpi_alloc_set_ui (value);
  ------------------
  |  |  119|      6|#define mpi_alloc_set_ui(a)   _gcry_mpi_alloc_set_ui ((a))
  ------------------
   84|      6|      constants[idx]->flags = (16|32);
   85|      6|    }
   86|       |
   87|      1|  return 0;
   88|      1|}
_gcry_mpi_alloc:
  101|  53.3k|{
  102|  53.3k|    gcry_mpi_t a;
  103|       |
  104|  53.3k|    a = xmalloc( sizeof *a );
  ------------------
  |  |  144|  53.3k|#define xmalloc(a)       _gcry_xmalloc ((a))
  ------------------
  105|  53.3k|    a->d = nlimbs? mpi_alloc_limb_space( nlimbs, 0 ) : NULL;
  ------------------
  |  |  178|  47.9k|#define mpi_alloc_limb_space(n,f)  _gcry_mpi_alloc_limb_space((n),(f))
  ------------------
  |  Branch (105:12): [True: 47.9k, False: 5.40k]
  ------------------
  106|  53.3k|    a->alloced = nlimbs;
  107|  53.3k|    a->nlimbs = 0;
  108|  53.3k|    a->sign = 0;
  109|  53.3k|    a->flags = 0;
  110|  53.3k|    return a;
  111|  53.3k|}
_gcry_mpi_alloc_limb_space:
  131|   154k|{
  132|   154k|    mpi_ptr_t p;
  133|   154k|    size_t len;
  134|       |
  135|   154k|    len = (nlimbs ? nlimbs : 1) * sizeof (mpi_limb_t);
  ------------------
  |  Branch (135:12): [True: 154k, False: 0]
  ------------------
  136|   154k|    p = secure ? xmalloc_secure (len) : xmalloc (len);
  ------------------
  |  |  146|      0|#define xmalloc_secure(a)   _gcry_xmalloc_secure ((a))
  ------------------
                  p = secure ? xmalloc_secure (len) : xmalloc (len);
  ------------------
  |  |  144|   308k|#define xmalloc(a)       _gcry_xmalloc ((a))
  ------------------
  |  Branch (136:9): [True: 0, False: 154k]
  ------------------
  137|   154k|    if (! nlimbs)
  ------------------
  |  Branch (137:9): [True: 0, False: 154k]
  ------------------
  138|      0|      *p = 0;
  139|       |
  140|   154k|    return p;
  141|   154k|}
_gcry_mpi_free_limb_space:
  145|   159k|{
  146|   159k|  if (a)
  ------------------
  |  Branch (146:7): [True: 154k, False: 4.92k]
  ------------------
  147|   154k|    {
  148|   154k|      size_t len = nlimbs * sizeof(mpi_limb_t);
  149|       |
  150|       |      /* If we have information on the number of allocated limbs, we
  151|       |         better wipe that space out.  This is a failsafe feature if
  152|       |         secure memory has been disabled or was not properly
  153|       |         implemented in user provided allocation functions. */
  154|   154k|      if (len)
  ------------------
  |  Branch (154:11): [True: 120k, False: 34.3k]
  ------------------
  155|   154k|        wipememory (a, len);
  ------------------
  |  |  398|   120k|#define wipememory(_ptr,_len) wipememory2((_ptr),0,(_len))
  |  |  ------------------
  |  |  |  |  388|   120k|#define wipememory2(_ptr,_set,_len) do { \
  |  |  |  |  389|   120k|	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|   240k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |               	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (389:12): [True: 120k, False: 0]
  |  |  |  |  |  Branch (389:33): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  390|   120k|		if (CONSTANT_P(_set) && (_set) == 0) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|   240k|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (87:27): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  391|   120k|		  _gcry_fast_wipememory((void *)(_ptr), (_len)); \
  |  |  |  |  392|   120k|		else \
  |  |  |  |  393|   120k|		  _gcry_fast_wipememory2((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  394|   120k|	      } else { \
  |  |  |  |  395|      0|		fast_wipememory2_inline((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  380|      0|#define fast_wipememory2_inline(_ptr,_set,_len) do { \
  |  |  |  |  |  |  381|      0|	      memset((_ptr), (_set), (_len)); \
  |  |  |  |  |  |  382|      0|	      asm volatile ("\n" :: "r" (_ptr) : "memory"); \
  |  |  |  |  |  |  383|      0|	    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (383:14): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  396|      0|	      } \
  |  |  |  |  397|   120k|	    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (397:14): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  156|   154k|      xfree(a);
  ------------------
  |  |  150|   154k|#define xfree(a)         _gcry_free ((a))
  ------------------
  157|   154k|    }
  158|   159k|}
_gcry_mpi_assign_limb_space:
  163|    208|{
  164|    208|  _gcry_mpi_free_limb_space (a->d, a->alloced);
  165|    208|  a->d = ap;
  166|    208|  a->alloced = nlimbs;
  167|    208|}
_gcry_mpi_resize:
  177|  63.9k|{
  178|  63.9k|  size_t i;
  179|       |
  180|  63.9k|  if (nlimbs <= a->alloced)
  ------------------
  |  Branch (180:7): [True: 62.9k, False: 991]
  ------------------
  181|  62.9k|    {
  182|       |      /* We only need to clear the new space (this is a nop if the
  183|       |         limb space is already of the correct size. */
  184|   279k|      for (i=a->nlimbs; i < a->alloced; i++)
  ------------------
  |  Branch (184:25): [True: 216k, False: 62.9k]
  ------------------
  185|   216k|        a->d[i] = 0;
  186|  62.9k|      return;
  187|  62.9k|    }
  188|       |
  189|       |  /* Actually resize the limb space.  */
  190|    991|  if (a->d)
  ------------------
  |  Branch (190:7): [True: 464, False: 527]
  ------------------
  191|    464|    {
  192|    464|      a->d = xrealloc (a->d, nlimbs * sizeof (mpi_limb_t));
  ------------------
  |  |  148|    464|#define xrealloc(a,b)    _gcry_xrealloc ((a),(b))
  ------------------
  193|  1.74k|      for (i=a->nlimbs; i < nlimbs; i++)
  ------------------
  |  Branch (193:25): [True: 1.28k, False: 464]
  ------------------
  194|  1.28k|        a->d[i] = 0;
  195|    464|    }
  196|    527|  else
  197|    527|    {
  198|    527|      if (a->flags & 1)
  ------------------
  |  Branch (198:11): [True: 0, False: 527]
  ------------------
  199|       |	/* Secure memory is wanted.  */
  200|      0|	a->d = xcalloc_secure (nlimbs , sizeof (mpi_limb_t));
  ------------------
  |  |  147|      0|#define xcalloc_secure(a,b) _gcry_xcalloc_secure ((a),(b))
  ------------------
  201|    527|      else
  202|       |	/* Standard memory.  */
  203|    527|	a->d = xcalloc (nlimbs , sizeof (mpi_limb_t));
  ------------------
  |  |  145|    527|#define xcalloc(a,b)     _gcry_xcalloc ((a),(b))
  ------------------
  204|    527|    }
  205|    991|  a->alloced = nlimbs;
  206|    991|}
_gcry_mpi_free:
  223|  55.1k|{
  224|  55.1k|  if (!a )
  ------------------
  |  Branch (224:7): [True: 1.75k, False: 53.3k]
  ------------------
  225|  1.75k|    return;
  226|  53.3k|  if ((a->flags & 32))
  ------------------
  |  Branch (226:7): [True: 0, False: 53.3k]
  ------------------
  227|      0|  {
  228|      0|#if GPGRT_VERSION_NUMBER >= 0x011600  /* 1.22 */
  229|      0|    gpgrt_annotate_leaked_object(a);
  230|      0|#endif
  231|      0|    return; /* Never release a constant. */
  232|      0|  }
  233|  53.3k|  if ((a->flags & 4))
  ------------------
  |  Branch (233:7): [True: 3.99k, False: 49.3k]
  ------------------
  234|  3.99k|    xfree( a->d );
  ------------------
  |  |  150|  3.99k|#define xfree(a)         _gcry_free ((a))
  ------------------
  235|  49.3k|  else
  236|  49.3k|    {
  237|  49.3k|      _gcry_mpi_free_limb_space(a->d, a->alloced);
  238|  49.3k|    }
  239|       |  /* Check that the flags makes sense.  We better allow for bit 1
  240|       |     (value 2) for backward ABI compatibility.  */
  241|  53.3k|  if ((a->flags & ~(1|2|4|16
  ------------------
  |  Branch (241:7): [True: 0, False: 53.3k]
  ------------------
  242|  53.3k|                    |GCRYMPI_FLAG_USER1
  243|  53.3k|                    |GCRYMPI_FLAG_USER2
  244|  53.3k|                    |GCRYMPI_FLAG_USER3
  245|  53.3k|                    |GCRYMPI_FLAG_USER4)))
  246|      0|    log_bug("invalid flag value in mpi_free\n");
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
  247|  53.3k|  xfree (a);
  ------------------
  |  |  150|  53.3k|#define xfree(a)         _gcry_free ((a))
  ------------------
  248|  53.3k|}
_gcry_mpi_set_opaque:
  281|  3.99k|{
  282|  3.99k|  if (!a)
  ------------------
  |  Branch (282:7): [True: 3.96k, False: 24]
  ------------------
  283|  3.96k|    a = mpi_alloc(0);
  ------------------
  |  |   97|  3.96k|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  284|       |
  285|  3.99k|  if (mpi_is_immutable (a))
  ------------------
  |  |  113|  3.99k|#define mpi_is_immutable(a)   ((a)->flags&16)
  |  |  ------------------
  |  |  |  Branch (113:31): [True: 0, False: 3.99k]
  |  |  ------------------
  ------------------
  286|      0|    {
  287|      0|      mpi_immutable_failed ();
  ------------------
  |  |  110|      0|#define mpi_immutable_failed() _gcry_mpi_immutable_failed ()
  ------------------
  288|      0|      return a;
  289|      0|    }
  290|       |
  291|  3.99k|  if( a->flags & 4 )
  ------------------
  |  Branch (291:7): [True: 0, False: 3.99k]
  ------------------
  292|      0|    xfree (a->d);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  293|  3.99k|  else
  294|  3.99k|    _gcry_mpi_free_limb_space (a->d, a->alloced);
  295|       |
  296|  3.99k|  a->d = p;
  297|  3.99k|  a->alloced = 0;
  298|  3.99k|  a->nlimbs = 0;
  299|  3.99k|  a->sign  = nbits;
  300|  3.99k|  a->flags = 4 | (a->flags & (GCRYMPI_FLAG_USER1|GCRYMPI_FLAG_USER2
  301|  3.99k|                              |GCRYMPI_FLAG_USER3|GCRYMPI_FLAG_USER4));
  302|  3.99k|  if (_gcry_is_secure (a->d))
  ------------------
  |  Branch (302:7): [True: 0, False: 3.99k]
  ------------------
  303|      0|    a->flags |= 1;
  304|  3.99k|  return a;
  305|  3.99k|}
_gcry_mpi_get_opaque:
  325|  1.80k|{
  326|  1.80k|    if( !(a->flags & 4) )
  ------------------
  |  Branch (326:9): [True: 0, False: 1.80k]
  ------------------
  327|      0|	log_bug("mpi_get_opaque on normal mpi\n");
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
  328|  1.80k|    if( nbits )
  ------------------
  |  Branch (328:9): [True: 1.25k, False: 543]
  ------------------
  329|  1.25k|	*nbits = a->sign;
  330|  1.80k|    return a->d;
  331|  1.80k|}
_gcry_mpi_copy:
  357|  47.7k|{
  358|  47.7k|    int i;
  359|  47.7k|    gcry_mpi_t b;
  360|       |
  361|  47.7k|    if( a && (a->flags & 4) ) {
  ------------------
  |  Branch (361:9): [True: 47.7k, False: 0]
  |  Branch (361:14): [True: 543, False: 47.2k]
  ------------------
  362|    543|        void *p = NULL;
  363|    543|        if (a->sign) {
  ------------------
  |  Branch (363:13): [True: 543, False: 0]
  ------------------
  364|    543|            p = _gcry_is_secure(a->d)? xmalloc_secure ((a->sign+7)/8)
  ------------------
  |  |  146|      0|#define xmalloc_secure(a)   _gcry_xmalloc_secure ((a))
  ------------------
  |  Branch (364:17): [True: 0, False: 543]
  ------------------
  365|    543|                                     : xmalloc ((a->sign+7)/8);
  ------------------
  |  |  144|  1.08k|#define xmalloc(a)       _gcry_xmalloc ((a))
  ------------------
  366|    543|            if (a->d)
  ------------------
  |  Branch (366:17): [True: 543, False: 0]
  ------------------
  367|    543|                memcpy( p, a->d, (a->sign+7)/8 );
  368|    543|        }
  369|    543|        b = mpi_set_opaque( NULL, p, a->sign );
  ------------------
  |  |  561|    543|#define mpi_set_opaque(a,b,c)  _gcry_mpi_set_opaque ((a), (b), (c))
  ------------------
  370|    543|        b->flags = a->flags;
  371|    543|        b->flags &= ~(16|32); /* Reset the immutable and constant flags.  */
  372|    543|    }
  373|  47.2k|    else if( a ) {
  ------------------
  |  Branch (373:14): [True: 47.2k, False: 0]
  ------------------
  374|  47.2k|	b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs )
  ------------------
  |  |  115|  47.2k|#define mpi_is_secure(a)      ((a) && ((a)->flags&1))
  |  |  ------------------
  |  |  |  Branch (115:32): [True: 47.2k, False: 0]
  |  |  |  Branch (115:39): [True: 0, False: 47.2k]
  |  |  ------------------
  ------------------
              	b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs )
  ------------------
  |  |   98|      0|# define mpi_alloc_secure(n)  _gcry_mpi_alloc_secure((n) )
  ------------------
  375|  47.2k|			    : mpi_alloc( a->nlimbs );
  ------------------
  |  |   97|  94.4k|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  376|  47.2k|	b->nlimbs = a->nlimbs;
  377|  47.2k|	b->sign = a->sign;
  378|  47.2k|	b->flags  = a->flags;
  379|  47.2k|        b->flags &= ~(16|32); /* Reset the immutable and constant flags.  */
  380|   234k|	for(i=0; i < b->nlimbs; i++ )
  ------------------
  |  Branch (380:11): [True: 187k, False: 47.2k]
  ------------------
  381|   187k|	    b->d[i] = a->d[i];
  382|  47.2k|    }
  383|      0|    else
  384|      0|	b = NULL;
  385|  47.7k|    return b;
  386|  47.7k|}
_gcry_mpi_alloc_like:
  437|    288|{
  438|    288|    gcry_mpi_t b;
  439|       |
  440|    288|    if( a && (a->flags & 4) ) {
  ------------------
  |  Branch (440:9): [True: 288, False: 0]
  |  Branch (440:14): [True: 0, False: 288]
  ------------------
  441|      0|	int n = (a->sign+7)/8;
  442|      0|	void *p = _gcry_is_secure(a->d)? xtrymalloc_secure (n)
  ------------------
  |  |  140|      0|#define xtrymalloc_secure(a)   _gcry_malloc_secure ((a))
  ------------------
  |  Branch (442:12): [True: 0, False: 0]
  ------------------
  443|      0|                                       : xtrymalloc (n);
  ------------------
  |  |  138|      0|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  444|      0|	memcpy( p, a->d, n );
  445|      0|	b = mpi_set_opaque( NULL, p, a->sign );
  ------------------
  |  |  561|      0|#define mpi_set_opaque(a,b,c)  _gcry_mpi_set_opaque ((a), (b), (c))
  ------------------
  446|      0|    }
  447|    288|    else if( a ) {
  ------------------
  |  Branch (447:14): [True: 288, False: 0]
  ------------------
  448|    288|	b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs )
  ------------------
  |  |  115|    288|#define mpi_is_secure(a)      ((a) && ((a)->flags&1))
  |  |  ------------------
  |  |  |  Branch (115:32): [True: 288, False: 0]
  |  |  |  Branch (115:39): [True: 0, False: 288]
  |  |  ------------------
  ------------------
              	b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs )
  ------------------
  |  |   98|      0|# define mpi_alloc_secure(n)  _gcry_mpi_alloc_secure((n) )
  ------------------
  449|    288|			    : mpi_alloc( a->nlimbs );
  ------------------
  |  |   97|    576|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  450|    288|	b->nlimbs = 0;
  451|    288|	b->sign = 0;
  452|    288|	b->flags = a->flags;
  453|    288|    }
  454|      0|    else
  455|      0|	b = NULL;
  456|    288|    return b;
  457|    288|}
_gcry_mpi_snatch:
  463|     48|{
  464|     48|  if (w)
  ------------------
  |  Branch (464:7): [True: 48, False: 0]
  ------------------
  465|     48|    {
  466|     48|      if (mpi_is_immutable (w))
  ------------------
  |  |  113|     48|#define mpi_is_immutable(a)   ((a)->flags&16)
  |  |  ------------------
  |  |  |  Branch (113:31): [True: 0, False: 48]
  |  |  ------------------
  ------------------
  467|      0|        {
  468|      0|          mpi_immutable_failed ();
  ------------------
  |  |  110|      0|#define mpi_immutable_failed() _gcry_mpi_immutable_failed ()
  ------------------
  469|      0|          return;
  470|      0|        }
  471|     48|      _gcry_mpi_assign_limb_space (w, u->d, u->alloced);
  472|     48|      w->nlimbs = u->nlimbs;
  473|     48|      w->sign   = u->sign;
  474|     48|      w->flags  = u->flags;
  475|     48|      u->alloced = 0;
  476|     48|      u->nlimbs = 0;
  477|     48|      u->d = NULL;
  478|     48|    }
  479|     48|  _gcry_mpi_free (u);
  480|     48|}
_gcry_mpi_set:
  485|  11.6k|{
  486|  11.6k|  mpi_ptr_t wp, up;
  487|  11.6k|  mpi_size_t usize = u->nlimbs;
  488|  11.6k|  int usign = u->sign;
  489|       |
  490|  11.6k|  if (!w)
  ------------------
  |  Branch (490:7): [True: 0, False: 11.6k]
  ------------------
  491|      0|    w = _gcry_mpi_alloc( mpi_get_nlimbs(u) );
  ------------------
  |  |   80|      0|#define mpi_get_nlimbs(a)     ((a)->nlimbs)
  ------------------
  492|  11.6k|  if (mpi_is_immutable (w))
  ------------------
  |  |  113|  11.6k|#define mpi_is_immutable(a)   ((a)->flags&16)
  |  |  ------------------
  |  |  |  Branch (113:31): [True: 0, False: 11.6k]
  |  |  ------------------
  ------------------
  493|      0|    {
  494|      0|      mpi_immutable_failed ();
  ------------------
  |  |  110|      0|#define mpi_immutable_failed() _gcry_mpi_immutable_failed ()
  ------------------
  495|      0|      return w;
  496|      0|    }
  497|  11.6k|  RESIZE_IF_NEEDED(w, usize);
  ------------------
  |  |   78|  11.6k|    do {			   \
  |  |   79|  11.6k|	if( (a)->alloced < (b) )   \
  |  |  ------------------
  |  |  |  Branch (79:6): [True: 352, False: 11.2k]
  |  |  ------------------
  |  |   80|  11.6k|	    mpi_resize((a), (b));  \
  |  |  ------------------
  |  |  |  |  100|    352|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  |  |  ------------------
  |  |   81|  11.6k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (81:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  498|  11.6k|  wp = w->d;
  499|  11.6k|  up = u->d;
  500|  11.6k|  MPN_COPY( wp, up, usize );
  ------------------
  |  |   90|  11.6k|    do {				\
  |  |   91|  11.6k|	mpi_size_t _i;			\
  |  |   92|  58.0k|	for( _i = 0; _i < (n); _i++ )	\
  |  |  ------------------
  |  |  |  Branch (92:15): [True: 46.4k, False: 11.6k]
  |  |  ------------------
  |  |   93|  46.4k|	    (d)[_i] = (s)[_i];		\
  |  |   94|  11.6k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (94:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  501|  11.6k|  w->nlimbs = usize;
  502|  11.6k|  w->flags = u->flags;
  503|  11.6k|  w->flags &= ~(16|32); /* Reset the immutable and constant flags.  */
  504|  11.6k|  w->sign = usign;
  505|  11.6k|  return w;
  506|  11.6k|}
_gcry_mpi_set_cond:
  515|  34.7k|{
  516|  34.7k|  mpi_size_t i;
  517|  34.7k|  mpi_size_t nlimbs = u->alloced;
  518|  34.7k|  mpi_limb_t mask1 = vzero - set;
  519|  34.7k|  mpi_limb_t mask2 = set - vone;
  520|  34.7k|  mpi_limb_t xu;
  521|  34.7k|  mpi_limb_t xw;
  522|  34.7k|  mpi_limb_t *uu = u->d;
  523|  34.7k|  mpi_limb_t *uw = w->d;
  524|       |
  525|  34.7k|  if (w->alloced != u->alloced)
  ------------------
  |  Branch (525:7): [True: 0, False: 34.7k]
  ------------------
  526|      0|    log_bug ("mpi_set_cond: different sizes\n");
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
  527|       |
  528|   156k|  for (i = 0; i < nlimbs; i++)
  ------------------
  |  Branch (528:15): [True: 122k, False: 34.7k]
  ------------------
  529|   122k|    {
  530|   122k|      xu = uu[i];
  531|   122k|      xw = uw[i];
  532|   122k|      uw[i] = (xw & mask2) | (xu & mask1);
  533|   122k|    }
  534|       |
  535|  34.7k|  xu = u->nlimbs;
  536|  34.7k|  xw = w->nlimbs;
  537|  34.7k|  w->nlimbs = (xw & mask2) | (xu & mask1);
  538|       |
  539|  34.7k|  xu = u->sign;
  540|  34.7k|  xw = w->sign;
  541|  34.7k|  w->sign = (xw & mask2) | (xu & mask1);
  542|  34.7k|  return w;
  543|  34.7k|}
_gcry_mpi_set_ui:
  548|     16|{
  549|     16|  if (!w)
  ------------------
  |  Branch (549:7): [True: 0, False: 16]
  ------------------
  550|      0|    w = _gcry_mpi_alloc (1);
  551|       |  /* FIXME: If U is 0 we have no need to resize and thus possible
  552|       |     allocating the the limbs. */
  553|     16|  if (mpi_is_immutable (w))
  ------------------
  |  |  113|     16|#define mpi_is_immutable(a)   ((a)->flags&16)
  |  |  ------------------
  |  |  |  Branch (113:31): [True: 0, False: 16]
  |  |  ------------------
  ------------------
  554|      0|    {
  555|      0|      mpi_immutable_failed ();
  ------------------
  |  |  110|      0|#define mpi_immutable_failed() _gcry_mpi_immutable_failed ()
  ------------------
  556|      0|      return w;
  557|      0|    }
  558|     16|  RESIZE_IF_NEEDED(w, 1);
  ------------------
  |  |   78|     16|    do {			   \
  |  |   79|     16|	if( (a)->alloced < (b) )   \
  |  |  ------------------
  |  |  |  Branch (79:6): [True: 16, False: 0]
  |  |  ------------------
  |  |   80|     16|	    mpi_resize((a), (b));  \
  |  |  ------------------
  |  |  |  |  100|     16|# define mpi_resize(a,b)      _gcry_mpi_resize((a),(b))
  |  |  ------------------
  |  |   81|     16|    } while(0)
  |  |  ------------------
  |  |  |  Branch (81:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  559|     16|  w->d[0] = u;
  560|     16|  w->nlimbs = u? 1:0;
  ------------------
  |  Branch (560:15): [True: 16, False: 0]
  ------------------
  561|     16|  w->sign = 0;
  562|     16|  w->flags = 0;
  563|     16|  return w;
  564|     16|}
_gcry_mpi_alloc_set_ui:
  592|     22|{
  593|     22|    gcry_mpi_t w = mpi_alloc(1);
  ------------------
  |  |   97|     22|# define mpi_alloc(n)	       _gcry_mpi_alloc((n) )
  ------------------
  594|     22|    w->d[0] = u;
  595|     22|    w->nlimbs = u? 1:0;
  ------------------
  |  Branch (595:17): [True: 21, False: 1]
  ------------------
  596|     22|    w->sign = 0;
  597|     22|    return w;
  598|     22|}
_gcry_mpi_new:
  672|    567|{
  673|    567|    return _gcry_mpi_alloc ( (nbits+BITS_PER_MPI_LIMB-1)
  ------------------
  |  |   49|    567|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|    567|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|    567|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  674|    567|                             / BITS_PER_MPI_LIMB );
  ------------------
  |  |   49|    567|#define BITS_PER_MPI_LIMB    (8*BYTES_PER_MPI_LIMB)
  |  |  ------------------
  |  |  |  |    4|    567|#define BYTES_PER_MPI_LIMB  (SIZEOF_UNSIGNED_LONG_LONG)
  |  |  |  |  ------------------
  |  |  |  |  |  |  524|    567|#define SIZEOF_UNSIGNED_LONG_LONG 8
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  675|    567|}
_gcry_mpi_release:
  687|  7.11k|{
  688|  7.11k|    _gcry_mpi_free( a );
  689|  7.11k|}
_gcry_mpi_set_flag:
  721|    669|{
  722|    669|  switch (flag)
  723|    669|    {
  724|      0|    case GCRYMPI_FLAG_SECURE:     mpi_set_secure(a); break;
  ------------------
  |  Branch (724:5): [True: 0, False: 669]
  ------------------
  725|      0|    case GCRYMPI_FLAG_CONST:      a->flags |= (16|32); break;
  ------------------
  |  Branch (725:5): [True: 0, False: 669]
  ------------------
  726|      0|    case GCRYMPI_FLAG_IMMUTABLE:  a->flags |= 16; break;
  ------------------
  |  Branch (726:5): [True: 0, False: 669]
  ------------------
  727|       |
  728|    364|    case GCRYMPI_FLAG_USER1:
  ------------------
  |  Branch (728:5): [True: 364, False: 305]
  ------------------
  729|    669|    case GCRYMPI_FLAG_USER2:
  ------------------
  |  Branch (729:5): [True: 305, False: 364]
  ------------------
  730|    669|    case GCRYMPI_FLAG_USER3:
  ------------------
  |  Branch (730:5): [True: 0, False: 669]
  ------------------
  731|    669|    case GCRYMPI_FLAG_USER4:      a->flags |= flag; break;
  ------------------
  |  Branch (731:5): [True: 0, False: 669]
  ------------------
  732|       |
  733|      0|    case GCRYMPI_FLAG_OPAQUE:
  ------------------
  |  Branch (733:5): [True: 0, False: 669]
  ------------------
  734|      0|    default: log_bug("invalid flag value\n");
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
  |  Branch (734:5): [True: 0, False: 669]
  ------------------
  735|    669|    }
  736|    669|}
_gcry_mpi_get_flag:
  766|  4.30k|{
  767|  4.30k|  switch (flag)
  768|  4.30k|    {
  769|    124|    case GCRYMPI_FLAG_SECURE:    return !!(a->flags & 1);
  ------------------
  |  Branch (769:5): [True: 124, False: 4.18k]
  ------------------
  770|  4.01k|    case GCRYMPI_FLAG_OPAQUE:    return !!(a->flags & 4);
  ------------------
  |  Branch (770:5): [True: 4.01k, False: 286]
  ------------------
  771|      0|    case GCRYMPI_FLAG_IMMUTABLE: return !!(a->flags & 16);
  ------------------
  |  Branch (771:5): [True: 0, False: 4.30k]
  ------------------
  772|      0|    case GCRYMPI_FLAG_CONST:     return !!(a->flags & 32);
  ------------------
  |  Branch (772:5): [True: 0, False: 4.30k]
  ------------------
  773|      0|    case GCRYMPI_FLAG_USER1:
  ------------------
  |  Branch (773:5): [True: 0, False: 4.30k]
  ------------------
  774|    162|    case GCRYMPI_FLAG_USER2:
  ------------------
  |  Branch (774:5): [True: 162, False: 4.14k]
  ------------------
  775|    162|    case GCRYMPI_FLAG_USER3:
  ------------------
  |  Branch (775:5): [True: 0, False: 4.30k]
  ------------------
  776|    162|    case GCRYMPI_FLAG_USER4:     return !!(a->flags & flag);
  ------------------
  |  Branch (776:5): [True: 0, False: 4.30k]
  ------------------
  777|      0|    default: log_bug("invalid flag value\n");
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
  |  Branch (777:5): [True: 0, False: 4.30k]
  ------------------
  778|  4.30k|    }
  779|       |  /*NOTREACHED*/
  780|      0|  return 0;
  781|  4.30k|}
_gcry_mpi_const:
  789|  33.0k|{
  790|  33.0k|  if ((int)no < 0 || no > MPI_NUMBER_OF_CONSTANTS)
  ------------------
  |  |  144|  33.0k|#define MPI_NUMBER_OF_CONSTANTS 6
  ------------------
  |  Branch (790:7): [True: 0, False: 33.0k]
  |  Branch (790:22): [True: 0, False: 33.0k]
  ------------------
  791|      0|    log_bug("invalid mpi_const selector %d\n", no);
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
  792|  33.0k|  if (!constants[no])
  ------------------
  |  Branch (792:7): [True: 0, False: 33.0k]
  ------------------
  793|      0|    log_bug("MPI subsystem not initialized\n");
  ------------------
  |  |  201|      0|#define log_bug     _gcry_log_bug
  ------------------
  794|  33.0k|  return constants[no];
  795|  33.0k|}

_gcry_rngcsprng_fast_poll:
 1296|  1.23k|{
 1297|  1.23k|  initialize_basics ();
 1298|       |
 1299|  1.23k|  lock_pool ();
 1300|  1.23k|  if (rndpool)
  ------------------
  |  Branch (1300:7): [True: 0, False: 1.23k]
  ------------------
 1301|      0|    {
 1302|       |      /* Yes, we are fully initialized. */
 1303|      0|      do_fast_random_poll ();
 1304|      0|    }
 1305|  1.23k|  unlock_pool ();
 1306|  1.23k|}
random-csprng.c:initialize_basics:
  234|  1.23k|{
  235|  1.23k|  static int initialized;
  236|       |
  237|  1.23k|  if (!initialized)
  ------------------
  |  Branch (237:7): [True: 1, False: 1.23k]
  ------------------
  238|      1|    {
  239|      1|      initialized = 1;
  240|       |
  241|       |      /* Make sure that we are still using the values we have
  242|       |         traditionally used for the random levels.  */
  243|      1|      gcry_assert (GCRY_WEAK_RANDOM == 0
  ------------------
  |  |  188|      1|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|      2|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [Folded - Ignored]
  |  |  |  |  |  Branch (85:48): [Folded - Ignored]
  |  |  |  |  |  Branch (85:48): [Folded - Ignored]
  |  |  |  |  |  Branch (85:48): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|      1|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
  244|      1|                   && GCRY_STRONG_RANDOM == 1
  245|      1|                   && GCRY_VERY_STRONG_RANDOM == 2);
  246|      1|    }
  247|  1.23k|}
random-csprng.c:lock_pool:
  252|  1.23k|{
  253|  1.23k|  int err;
  254|       |
  255|  1.23k|  err = gpgrt_lock_lock (&pool_lock);
  256|  1.23k|  if (err)
  ------------------
  |  Branch (256:7): [True: 0, False: 1.23k]
  ------------------
  257|      0|    log_fatal ("failed to acquire the pool lock: %s\n", gpg_strerror (err));
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
  258|  1.23k|  pool_is_locked = 1;
  259|  1.23k|}
random-csprng.c:unlock_pool:
  264|  1.23k|{
  265|  1.23k|  int err;
  266|       |
  267|  1.23k|  pool_is_locked = 0;
  268|  1.23k|  err = gpgrt_lock_unlock (&pool_lock);
  269|  1.23k|  if (err)
  ------------------
  |  Branch (269:7): [True: 0, False: 1.23k]
  ------------------
  270|      0|    log_fatal ("failed to release the pool lock: %s\n", gpg_strerror (err));
  ------------------
  |  |  202|      0|#define log_fatal   _gcry_log_fatal
  ------------------
  271|  1.23k|}

_gcry_set_preferred_rng_type:
  166|      1|{
  167|      1|  static int any_init;
  168|       |
  169|      1|  if (!type)
  ------------------
  |  Branch (169:7): [True: 1, False: 0]
  ------------------
  170|      1|    {
  171|      1|      any_init = 1;
  172|      1|    }
  173|      0|  else if (type == GCRY_RNG_TYPE_STANDARD)
  ------------------
  |  Branch (173:12): [True: 0, False: 0]
  ------------------
  174|      0|    {
  175|      0|      rng_types.standard = 1;
  176|      0|    }
  177|      0|  else if (any_init)
  ------------------
  |  Branch (177:12): [True: 0, False: 0]
  ------------------
  178|      0|    {
  179|       |      /* After any initialization has been done we only allow to
  180|       |         upgrade to the standard RNG (handled above).  All other
  181|       |         requests are ignored.  The idea is that the application needs
  182|       |         to declare a preference for a weaker RNG as soon as possible
  183|       |         and before any library sets a preference.  We assume that a
  184|       |         library which uses Libgcrypt calls an init function very
  185|       |         early.  This way --- even if the library gets initialized
  186|       |         early by the application --- it is unlikely that it can
  187|       |         select a lower priority RNG.
  188|       |
  189|       |         This scheme helps to ensure that existing unmodified
  190|       |         applications (e.g. gpg2), which don't known about the new RNG
  191|       |         selection system, will continue to use the standard RNG and
  192|       |         not be tricked by some library to use a lower priority RNG.
  193|       |         There are some loopholes here but at least most GnuPG stuff
  194|       |         should be save because it calls src_c{gcry_control
  195|       |         (GCRYCTL_SUSPEND_SECMEM_WARN);} quite early and thus inhibits
  196|       |         switching to a low priority RNG.
  197|       |       */
  198|      0|    }
  199|      0|  else if (type == GCRY_RNG_TYPE_FIPS)
  ------------------
  |  Branch (199:12): [True: 0, False: 0]
  ------------------
  200|      0|    {
  201|      0|      rng_types.fips = 1;
  202|      0|    }
  203|      0|  else if (type == GCRY_RNG_TYPE_SYSTEM)
  ------------------
  |  Branch (203:12): [True: 0, False: 0]
  ------------------
  204|      0|    {
  205|      0|      rng_types.system = 1;
  206|      0|    }
  207|      1|}
_gcry_fast_random_poll:
  447|  1.23k|{
  448|  1.23k|  if (fips_mode ())
  ------------------
  |  |  449|  1.23k|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 1.23k]
  |  |  ------------------
  ------------------
  449|      0|    ; /* No need for this in fips mode.  */
  450|  1.23k|  else if (rng_types.standard)
  ------------------
  |  Branch (450:12): [True: 0, False: 1.23k]
  ------------------
  451|      0|    _gcry_rngcsprng_fast_poll ();
  452|  1.23k|  else if (rng_types.fips)
  ------------------
  |  Branch (452:12): [True: 0, False: 1.23k]
  ------------------
  453|      0|    ;
  454|  1.23k|  else if (rng_types.system)
  ------------------
  |  Branch (454:12): [True: 0, False: 1.23k]
  ------------------
  455|      0|    ;
  456|  1.23k|  else /* default */
  457|  1.23k|    _gcry_rngcsprng_fast_poll ();
  458|  1.23k|}

_gcry_initialize_fips_mode:
  165|      1|{
  166|      1|  static int done;
  167|      1|  gpg_error_t err;
  168|       |
  169|       |  /* Make sure we are not accidentally called twice.  */
  170|      1|  if (done)
  ------------------
  |  Branch (170:7): [True: 0, False: 1]
  ------------------
  171|      0|    {
  172|      0|      if ( fips_mode () )
  ------------------
  |  |  449|      0|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  173|      0|        {
  174|      0|          fips_new_state (STATE_FATALERROR);
  175|      0|          fips_noreturn ();
  ------------------
  |  |  489|      0|#define fips_noreturn()  (_gcry_fips_noreturn ())
  ------------------
  176|      0|        }
  177|       |      /* If not in fips mode an assert is sufficient.  */
  178|      0|      gcry_assert (!done);
  ------------------
  |  |  188|      0|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|      0|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|      0|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
  179|      0|    }
  180|      0|  done = 1;
  181|       |
  182|       |  /* If the calling application explicitly requested fipsmode, do so.  */
  183|      1|  if (force)
  ------------------
  |  Branch (183:7): [True: 0, False: 1]
  ------------------
  184|      0|    {
  185|      0|      gcry_assert (!_gcry_no_fips_mode_required);
  ------------------
  |  |  188|      0|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|      0|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|      0|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
  186|      0|      goto leave;
  187|      0|    }
  188|       |
  189|       |  /* If the system explicitly requested fipsmode, do so.  */
  190|      1|  if (check_fips_system_setting ())
  ------------------
  |  Branch (190:7): [True: 0, False: 1]
  ------------------
  191|      0|    {
  192|      0|      gcry_assert (!_gcry_no_fips_mode_required);
  ------------------
  |  |  188|      0|#define gcry_assert(expr) (LIKELY(expr)? (void)0 \
  |  |  ------------------
  |  |  |  |   85|      0|#define LIKELY(expr)      __builtin_expect( !!(expr), 1 )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:27): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  189|      0|         : _gcry_assert_failed (STR(expr), __FILE__, __LINE__, __FUNCTION__))
  |  |  ------------------
  |  |  |  |  101|      0|#define STR(v) #v
  |  |  ------------------
  ------------------
  193|      0|      goto leave;
  194|      0|    }
  195|       |
  196|       |  /* Fips not not requested, set flag.  */
  197|      1|  _gcry_no_fips_mode_required = 1;
  198|       |
  199|      1| leave:
  200|      1|  if (!_gcry_no_fips_mode_required)
  ------------------
  |  Branch (200:7): [True: 0, False: 1]
  ------------------
  201|      0|    {
  202|       |      /* Yes, we are in FIPS mode.  */
  203|       |
  204|       |      /* Intitialize the lock to protect the FSM.  */
  205|      0|      err = gpgrt_lock_init (&fsm_lock);
  206|      0|      if (err)
  ------------------
  |  Branch (206:11): [True: 0, False: 0]
  ------------------
  207|      0|        {
  208|       |          /* If that fails we can't do anything but abort the
  209|       |             process. We need to use log_info so that the FSM won't
  210|       |             get involved.  */
  211|      0|          log_info ("FATAL: failed to create the FSM lock in libgcrypt: %s\n",
  ------------------
  |  |  204|      0|#define log_info    _gcry_log_info
  ------------------
  212|      0|                    gpg_strerror (err));
  213|      0|#ifdef HAVE_SYSLOG
  214|      0|          syslog (LOG_USER|LOG_ERR, "Libgcrypt error: "
  215|      0|                  "creating FSM lock failed: %s - abort",
  216|      0|                  gpg_strerror (err));
  217|      0|#endif /*HAVE_SYSLOG*/
  218|      0|          abort ();
  219|      0|        }
  220|       |
  221|       |      /* Now get us into the INIT state.  */
  222|      0|      fips_new_state (STATE_INIT);
  223|      0|    }
  224|       |
  225|      1|  return;
  226|      1|}
_gcry_fips_is_operational:
  290|      1|{
  291|      1|  int result;
  292|       |
  293|      1|  if (!fips_mode ())
  ------------------
  |  |  449|      1|#define fips_mode() (!_gcry_no_fips_mode_required)
  ------------------
  |  Branch (293:7): [True: 1, False: 0]
  ------------------
  294|      1|    result = 1;
  295|      0|  else
  296|      0|    {
  297|      0|      lock_fsm ();
  298|      0|      if (current_state == STATE_INIT)
  ------------------
  |  Branch (298:11): [True: 0, False: 0]
  ------------------
  299|      0|        {
  300|       |          /* If we are still in the INIT state, we need to run the
  301|       |             selftests so that the FSM can eventually get into
  302|       |             operational state.  Given that we would need a 2-phase
  303|       |             initialization of libgcrypt, but that has traditionally
  304|       |             not been enforced, we use this on demand self-test
  305|       |             checking.  Note that Proper applications would do the
  306|       |             application specific libgcrypt initialization between a
  307|       |             gcry_check_version() and gcry_control
  308|       |             (GCRYCTL_INITIALIZATION_FINISHED) where the latter will
  309|       |             run the selftests.  The drawback of these on-demand
  310|       |             self-tests are a small chance that self-tests are
  311|       |             performed by several threads; that is no problem because
  312|       |             our FSM make sure that we won't oversee any error. */
  313|      0|          unlock_fsm ();
  314|      0|          _gcry_fips_run_selftests (0);
  315|       |
  316|       |          /* Release resources for random.  */
  317|      0|          _gcry_random_close_fds ();
  318|      0|          lock_fsm ();
  319|      0|        }
  320|       |
  321|      0|      result = (current_state == STATE_OPERATIONAL);
  322|      0|      unlock_fsm ();
  323|      0|    }
  324|      1|  return result;
  325|      1|}
fips.c:check_fips_system_setting:
   95|      1|{
   96|       |  /* Do we have the environment variable set?  */
   97|      1|  if (getenv ("LIBGCRYPT_FORCE_FIPS_MODE"))
  ------------------
  |  Branch (97:7): [True: 0, False: 1]
  ------------------
   98|      0|    return 1;
   99|       |
  100|       |  /* For testing the system it is useful to override the system
  101|       |     provided detection of the FIPS mode and force FIPS mode using a
  102|       |     file.  The filename is hardwired so that there won't be any
  103|       |     confusion on whether /etc/gcrypt/ or /usr/local/etc/gcrypt/ is
  104|       |     actually used.  The file itself may be empty.  */
  105|      1|  if ( !access (FIPS_FORCE_FILE, F_OK) )
  ------------------
  |  |   37|      1|#define FIPS_FORCE_FILE "/etc/gcrypt/fips_enabled"
  ------------------
  |  Branch (105:8): [True: 0, False: 1]
  ------------------
  106|      0|    return 1;
  107|       |
  108|       |  /* Checking based on /proc file properties.  */
  109|      1|  {
  110|      1|    static const char procfname[] = "/proc/sys/crypto/fips_enabled";
  111|      1|    FILE *fp;
  112|      1|    int saved_errno;
  113|       |
  114|      1|    fp = fopen (procfname, "r");
  115|      1|    if (fp)
  ------------------
  |  Branch (115:9): [True: 1, False: 0]
  ------------------
  116|      1|      {
  117|      1|        char line[256];
  118|       |
  119|      1|        if (fgets (line, sizeof line, fp) && atoi (line))
  ------------------
  |  Branch (119:13): [True: 1, False: 0]
  |  Branch (119:46): [True: 0, False: 1]
  ------------------
  120|      0|          {
  121|       |            /* System is in fips mode.  */
  122|      0|            fclose (fp);
  123|      0|            return 1;
  124|      0|          }
  125|      1|        fclose (fp);
  126|      1|      }
  127|      0|    else if ((saved_errno = errno) != ENOENT
  ------------------
  |  Branch (127:14): [True: 0, False: 0]
  ------------------
  128|      0|             && saved_errno != EACCES
  ------------------
  |  Branch (128:17): [True: 0, False: 0]
  ------------------
  129|      0|             && !access ("/proc/version", F_OK) )
  ------------------
  |  Branch (129:17): [True: 0, False: 0]
  ------------------
  130|      0|      {
  131|       |        /* Problem reading the fips file despite that we have the proc
  132|       |           file system.  We better stop right away. */
  133|      0|        log_info ("FATAL: error reading `%s' in libgcrypt: %s\n",
  ------------------
  |  |  204|      0|#define log_info    _gcry_log_info
  ------------------
  134|      0|                  procfname, strerror (saved_errno));
  135|      0|#ifdef HAVE_SYSLOG
  136|      0|        syslog (LOG_USER|LOG_ERR, "Libgcrypt error: "
  137|      0|                "reading `%s' failed: %s - abort",
  138|      0|                procfname, strerror (saved_errno));
  139|      0|#endif /*HAVE_SYSLOG*/
  140|      0|        abort ();
  141|      0|      }
  142|      1|  }
  143|       |
  144|      1|  return 0;
  145|      1|}

_gcry_global_is_operational:
  182|      1|{
  183|      1|  if (!_gcry_global_any_init_done)
  ------------------
  |  Branch (183:7): [True: 1, False: 0]
  ------------------
  184|      1|    {
  185|      1|#ifdef HAVE_SYSLOG
  186|      1|      syslog (LOG_USER|LOG_WARNING, "Libgcrypt warning: "
  187|      1|              "missing initialization - please fix the application");
  188|      1|#endif /*HAVE_SYSLOG*/
  189|      1|      global_init ();
  190|      1|    }
  191|      1|  return _gcry_fips_is_operational ();
  192|      1|}
_gcry_check_version:
  253|      1|{
  254|      1|    const char *ver = VERSION;
  ------------------
  |  |  693|      1|#define VERSION "1.11.0"
  ------------------
  255|      1|    int my_major, my_minor, my_micro;
  256|      1|    int rq_major, rq_minor, rq_micro;
  257|      1|    const char *my_plvl;
  258|       |
  259|      1|    if (req_version && req_version[0] == 1 && req_version[1] == 1)
  ------------------
  |  Branch (259:9): [True: 1, False: 0]
  |  Branch (259:24): [True: 0, False: 1]
  |  Branch (259:47): [True: 0, False: 0]
  ------------------
  260|      0|        return _gcry_compat_identification ();
  261|       |
  262|       |    /* Initialize library.  */
  263|      1|    global_init ();
  264|       |
  265|      1|    if ( !req_version )
  ------------------
  |  Branch (265:10): [True: 0, False: 1]
  ------------------
  266|       |        /* Caller wants our version number.  */
  267|      0|	return ver;
  268|       |
  269|       |    /* Parse own version number.  */
  270|      1|    my_plvl = parse_version_string( ver, &my_major, &my_minor, &my_micro );
  271|      1|    if ( !my_plvl )
  ------------------
  |  Branch (271:10): [True: 0, False: 1]
  ------------------
  272|       |        /* very strange our own version is bogus.  Shouldn't we use
  273|       |	   assert() here and bail out in case this happens?  -mo.  */
  274|      0|	return NULL;
  275|       |
  276|       |    /* Parse requested version number.  */
  277|      1|    if (!parse_version_string (req_version, &rq_major, &rq_minor, &rq_micro))
  ------------------
  |  Branch (277:9): [True: 0, False: 1]
  ------------------
  278|      0|      return NULL;  /* req version string is invalid, this can happen.  */
  279|       |
  280|       |    /* Compare version numbers.  */
  281|      1|    if ( my_major > rq_major
  ------------------
  |  Branch (281:10): [True: 0, False: 1]
  ------------------
  282|      1|	|| (my_major == rq_major && my_minor > rq_minor)
  ------------------
  |  Branch (282:6): [True: 1, False: 0]
  |  Branch (282:30): [True: 1, False: 0]
  ------------------
  283|      1|	|| (my_major == rq_major && my_minor == rq_minor
  ------------------
  |  Branch (283:6): [True: 0, False: 0]
  |  Branch (283:30): [True: 0, False: 0]
  ------------------
  284|      0|	    && my_micro > rq_micro)
  ------------------
  |  Branch (284:9): [True: 0, False: 0]
  ------------------
  285|      1|	|| (my_major == rq_major && my_minor == rq_minor
  ------------------
  |  Branch (285:6): [True: 0, False: 0]
  |  Branch (285:30): [True: 0, False: 0]
  ------------------
  286|      0|                                 && my_micro == rq_micro))
  ------------------
  |  Branch (286:37): [True: 0, False: 0]
  ------------------
  287|      1|      {
  288|      1|	return ver;
  289|      1|      }
  290|       |
  291|      0|    return NULL;
  292|      1|}
_gcry_malloc:
 1009|   236k|{
 1010|   236k|  void *mem = NULL;
 1011|       |
 1012|   236k|  do_malloc (n, 0, &mem);
 1013|       |
 1014|   236k|  return mem;
 1015|   236k|}
_gcry_is_secure:
 1036|  6.83k|{
 1037|  6.83k|  if (no_secure_memory)
  ------------------
  |  Branch (1037:7): [True: 0, False: 6.83k]
  ------------------
 1038|      0|    return 0;
 1039|  6.83k|  if (is_secure_func)
  ------------------
  |  Branch (1039:7): [True: 0, False: 6.83k]
  ------------------
 1040|      0|    return is_secure_func (a) ;
 1041|  6.83k|  return _gcry_private_is_secure (a);
 1042|  6.83k|}
_gcry_realloc:
 1071|    168|{
 1072|    168|  return _gcry_realloc_core (a, n, 0);
 1073|    168|}
_gcry_free:
 1078|   263k|{
 1079|   263k|  int save_errno;
 1080|       |
 1081|   263k|  if (!p)
  ------------------
  |  Branch (1081:7): [True: 25.5k, False: 237k]
  ------------------
 1082|  25.5k|    return;
 1083|       |
 1084|       |  /* In case ERRNO is set we better save it so that the free machinery
 1085|       |     may not accidentally change ERRNO.  We restore it only if it was
 1086|       |     already set to comply with the usual C semantic for ERRNO.  */
 1087|   237k|  save_errno = errno;
 1088|   237k|  if (free_func)
  ------------------
  |  Branch (1088:7): [True: 0, False: 237k]
  ------------------
 1089|      0|    free_func (p);
 1090|   237k|  else
 1091|   237k|    _gcry_private_free (p);
 1092|       |
 1093|   237k|  if (save_errno && save_errno != errno)
  ------------------
  |  Branch (1093:7): [True: 237k, False: 10]
  |  Branch (1093:21): [True: 0, False: 237k]
  ------------------
 1094|      0|    gpg_err_set_errno (save_errno);
 1095|   237k|}
_gcry_calloc:
 1099|  3.81k|{
 1100|  3.81k|  size_t bytes;
 1101|  3.81k|  void *p;
 1102|       |
 1103|  3.81k|  bytes = n * m; /* size_t is unsigned so the behavior on overflow is
 1104|       |                    defined. */
 1105|  3.81k|  if (m && bytes / m != n)
  ------------------
  |  Branch (1105:7): [True: 3.81k, False: 0]
  |  Branch (1105:12): [True: 0, False: 3.81k]
  ------------------
 1106|      0|    {
 1107|      0|      gpg_err_set_errno (ENOMEM);
 1108|      0|      return NULL;
 1109|      0|    }
 1110|       |
 1111|  3.81k|  p = _gcry_malloc (bytes);
 1112|  3.81k|  if (p)
  ------------------
  |  Branch (1112:7): [True: 3.81k, False: 0]
  ------------------
 1113|  3.81k|    memset (p, 0, bytes);
 1114|  3.81k|  return p;
 1115|  3.81k|}
_gcry_xmalloc:
 1169|   225k|{
 1170|   225k|  void *p;
 1171|       |
 1172|   225k|  while ( !(p = _gcry_malloc( n )) )
  ------------------
  |  Branch (1172:11): [True: 0, False: 225k]
  ------------------
 1173|      0|    {
 1174|      0|      if ( fips_mode ()
  ------------------
  |  |  449|      0|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1175|      0|           || !outofcore_handler
  ------------------
  |  Branch (1175:15): [True: 0, False: 0]
  ------------------
 1176|      0|           || !outofcore_handler (outofcore_handler_value, n, 0) )
  ------------------
  |  Branch (1176:15): [True: 0, False: 0]
  ------------------
 1177|      0|        {
 1178|      0|          _gcry_fatal_error (gpg_err_code_from_errno (errno), NULL);
 1179|      0|        }
 1180|      0|    }
 1181|   225k|    return p;
 1182|   225k|}
_gcry_xrealloc:
 1186|    886|{
 1187|    886|  void *p;
 1188|       |
 1189|    886|  while (!(p = _gcry_realloc_core (a, n, 1)))
  ------------------
  |  Branch (1189:10): [True: 0, False: 886]
  ------------------
 1190|      0|    {
 1191|      0|      if ( fips_mode ()
  ------------------
  |  |  449|      0|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1192|      0|           || !outofcore_handler
  ------------------
  |  Branch (1192:15): [True: 0, False: 0]
  ------------------
 1193|      0|           || !outofcore_handler (outofcore_handler_value, n,
  ------------------
  |  Branch (1193:15): [True: 0, False: 0]
  ------------------
 1194|      0|                                  _gcry_is_secure(a)? 3:2))
  ------------------
  |  Branch (1194:35): [True: 0, False: 0]
  ------------------
 1195|      0|        {
 1196|      0|          _gcry_fatal_error (gpg_err_code_from_errno (errno), NULL );
 1197|      0|	}
 1198|      0|    }
 1199|    886|    return p;
 1200|    886|}
_gcry_xcalloc:
 1223|  7.31k|{
 1224|  7.31k|  size_t nbytes;
 1225|  7.31k|  void *p;
 1226|       |
 1227|  7.31k|  nbytes = n * m;
 1228|  7.31k|  if (m && nbytes / m != n)
  ------------------
  |  Branch (1228:7): [True: 7.31k, False: 0]
  |  Branch (1228:12): [True: 0, False: 7.31k]
  ------------------
 1229|      0|    {
 1230|      0|      gpg_err_set_errno (ENOMEM);
 1231|      0|      _gcry_fatal_error(gpg_err_code_from_errno (errno), NULL );
 1232|      0|    }
 1233|       |
 1234|  7.31k|  p = _gcry_xmalloc ( nbytes );
 1235|  7.31k|  memset ( p, 0, nbytes );
 1236|  7.31k|  return p;
 1237|  7.31k|}
_gcry_xstrdup:
 1259|    114|{
 1260|    114|  char *p;
 1261|       |
 1262|    114|  while ( !(p = _gcry_strdup_core (string, 1)) )
  ------------------
  |  Branch (1262:11): [True: 0, False: 114]
  ------------------
 1263|      0|    {
 1264|      0|      size_t n = strlen (string);
 1265|      0|      int is_sec = !!_gcry_is_secure (string);
 1266|       |
 1267|      0|      if (fips_mode ()
  ------------------
  |  |  449|      0|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1268|      0|          || !outofcore_handler
  ------------------
  |  Branch (1268:14): [True: 0, False: 0]
  ------------------
 1269|      0|          || !outofcore_handler (outofcore_handler_value, n, is_sec) )
  ------------------
  |  Branch (1269:14): [True: 0, False: 0]
  ------------------
 1270|      0|        {
 1271|      0|          _gcry_fatal_error (gpg_err_code_from_errno (errno),
 1272|      0|                             is_sec? _("out of core in secure memory"):NULL);
  ------------------
  |  |   96|      0|#define _(a)  _gcry_gettext(a)
  ------------------
  |  Branch (1272:30): [True: 0, False: 0]
  ------------------
 1273|      0|	}
 1274|      0|    }
 1275|       |
 1276|    114|  return p;
 1277|    114|}
_gcry_get_debug_flag:
 1300|    139|{
 1301|    139|  if ( fips_mode () )
  ------------------
  |  |  449|    139|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (449:21): [True: 0, False: 139]
  |  |  ------------------
  ------------------
 1302|      0|    return 0;
 1303|    139|  return (debug_flags & mask);
 1304|    139|}
global.c:global_init:
   91|      2|{
   92|      2|  gcry_error_t err = 0;
   93|       |
   94|      2|  if (_gcry_global_any_init_done)
  ------------------
  |  Branch (94:7): [True: 1, False: 1]
  ------------------
   95|      1|    return;
   96|      1|  _gcry_global_any_init_done = 1;
   97|       |
   98|       |  /* Tell the random module that we have seen an init call.  */
   99|      1|  _gcry_set_preferred_rng_type (0);
  100|       |
  101|       |  /* Get the system call clamp functions.  */
  102|      1|  if (!pre_syscall_func)
  ------------------
  |  Branch (102:7): [True: 1, False: 0]
  ------------------
  103|      1|    gpgrt_get_syscall_clamp (&pre_syscall_func, &post_syscall_func);
  104|       |
  105|       |  /* See whether the system is in FIPS mode.  This needs to come as
  106|       |     early as possible but after ATH has been initialized.  */
  107|      1|  _gcry_initialize_fips_mode (force_fips_mode);
  108|       |
  109|       |  /* Before we do any other initialization we need to test available
  110|       |     hardware features.  */
  111|      1|  _gcry_detect_hw_features ();
  112|       |
  113|       |  /* Initialize the modules - this is mainly allocating some memory and
  114|       |     creating mutexes.  */
  115|      1|  err = _gcry_cipher_init ();
  116|      1|  if (err)
  ------------------
  |  Branch (116:7): [True: 0, False: 1]
  ------------------
  117|      0|    goto fail;
  118|      1|  err = _gcry_md_init ();
  119|      1|  if (err)
  ------------------
  |  Branch (119:7): [True: 0, False: 1]
  ------------------
  120|      0|    goto fail;
  121|      1|  err = _gcry_mac_init ();
  122|      1|  if (err)
  ------------------
  |  Branch (122:7): [True: 0, False: 1]
  ------------------
  123|      0|    goto fail;
  124|      1|  err = _gcry_pk_init ();
  125|      1|  if (err)
  ------------------
  |  Branch (125:7): [True: 0, False: 1]
  ------------------
  126|      0|    goto fail;
  127|      1|  err = _gcry_primegen_init ();
  128|      1|  if (err)
  ------------------
  |  Branch (128:7): [True: 0, False: 1]
  ------------------
  129|      0|    goto fail;
  130|      1|  err = _gcry_secmem_module_init ();
  131|      1|  if (err)
  ------------------
  |  Branch (131:7): [True: 0, False: 1]
  ------------------
  132|      0|    goto fail;
  133|      1|  err = _gcry_mpi_init ();
  134|      1|  if (err)
  ------------------
  |  Branch (134:7): [True: 0, False: 1]
  ------------------
  135|      0|    goto fail;
  136|       |
  137|      1|  return;
  138|       |
  139|      1| fail:
  140|      0|  BUG ();
  ------------------
  |  |  187|      0|#define BUG() _gcry_bug( __FILE__ , __LINE__, __FUNCTION__ )
  ------------------
  141|      1|}
global.c:parse_version_string:
  229|      2|{
  230|      2|    s = parse_version_number( s, major );
  231|      2|    if( !s || *s != '.' )
  ------------------
  |  Branch (231:9): [True: 0, False: 2]
  |  Branch (231:15): [True: 0, False: 2]
  ------------------
  232|      0|	return NULL;
  233|      2|    s++;
  234|      2|    s = parse_version_number( s, minor );
  235|      2|    if( !s || *s != '.' )
  ------------------
  |  Branch (235:9): [True: 0, False: 2]
  |  Branch (235:15): [True: 0, False: 2]
  ------------------
  236|      0|	return NULL;
  237|      2|    s++;
  238|      2|    s = parse_version_number( s, micro );
  239|      2|    if( !s )
  ------------------
  |  Branch (239:9): [True: 0, False: 2]
  ------------------
  240|      0|	return NULL;
  241|      2|    return s; /* patchlevel */
  242|      2|}
global.c:parse_version_number:
  205|      6|{
  206|      6|    int val = 0;
  207|       |
  208|      6|    if( *s == '0' && isdigit(s[1]) )
  ------------------
  |  Branch (208:9): [True: 1, False: 5]
  ------------------
  209|      0|	return NULL; /* leading zeros are not allowed */
  210|      7|    for ( ; isdigit(*s); s++ ) {
  211|      7|	val *= 10;
  212|      7|	val += *s - '0';
  213|      7|    }
  214|      6|    *number = val;
  215|      6|    return val < 0? NULL : s;
  ------------------
  |  Branch (215:12): [True: 0, False: 6]
  ------------------
  216|      6|}
global.c:do_malloc:
  974|   236k|{
  975|   236k|  gcry_err_code_t err = 0;
  976|   236k|  void *m;
  977|       |
  978|   236k|  if ((flags & GCRY_ALLOC_FLAG_SECURE) && !no_secure_memory)
  ------------------
  |  |  423|   236k|#define GCRY_ALLOC_FLAG_SECURE (1 << 0)
  ------------------
  |  Branch (978:7): [True: 0, False: 236k]
  |  Branch (978:43): [True: 0, False: 0]
  ------------------
  979|      0|    {
  980|      0|      if (alloc_secure_func)
  ------------------
  |  Branch (980:11): [True: 0, False: 0]
  ------------------
  981|      0|	m = (*alloc_secure_func) (n);
  982|      0|      else
  983|      0|	m = _gcry_private_malloc_secure (n, !!(flags & GCRY_ALLOC_FLAG_XHINT));
  ------------------
  |  |  424|      0|#define GCRY_ALLOC_FLAG_XHINT  (1 << 1)  /* Called from xmalloc.  */
  ------------------
  984|      0|    }
  985|   236k|  else
  986|   236k|    {
  987|   236k|      if (alloc_func)
  ------------------
  |  Branch (987:11): [True: 0, False: 236k]
  ------------------
  988|      0|	m = (*alloc_func) (n);
  989|   236k|      else
  990|   236k|	m = _gcry_private_malloc (n);
  991|   236k|    }
  992|       |
  993|   236k|  if (!m)
  ------------------
  |  Branch (993:7): [True: 198, False: 236k]
  ------------------
  994|    198|    {
  995|       |      /* Make sure that ERRNO has been set in case a user supplied
  996|       |         memory handler didn't it correctly. */
  997|    198|      if (!errno)
  ------------------
  |  Branch (997:11): [True: 0, False: 198]
  ------------------
  998|      0|        gpg_err_set_errno (ENOMEM);
  999|    198|      err = gpg_err_code_from_errno (errno);
 1000|    198|    }
 1001|   236k|  else
 1002|   236k|    *mem = m;
 1003|       |
 1004|   236k|  return err;
 1005|   236k|}
global.c:_gcry_realloc_core:
 1046|  1.05k|{
 1047|  1.05k|  void *p;
 1048|       |
 1049|       |  /* To avoid problems with non-standard realloc implementations and
 1050|       |     our own secmem_realloc, we divert to malloc and free here.  */
 1051|  1.05k|  if (!a)
  ------------------
  |  Branch (1051:7): [True: 107, False: 947]
  ------------------
 1052|    107|    return _gcry_malloc (n);
 1053|    947|  if (!n)
  ------------------
  |  Branch (1053:7): [True: 0, False: 947]
  ------------------
 1054|      0|    {
 1055|      0|      xfree (a);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1056|      0|      return NULL;
 1057|      0|    }
 1058|       |
 1059|    947|  if (realloc_func)
  ------------------
  |  Branch (1059:7): [True: 0, False: 947]
  ------------------
 1060|      0|    p = realloc_func (a, n);
 1061|    947|  else
 1062|    947|    p =  _gcry_private_realloc (a, n, xhint);
 1063|    947|  if (!p && !errno)
  ------------------
  |  Branch (1063:7): [True: 0, False: 947]
  |  Branch (1063:13): [True: 0, False: 0]
  ------------------
 1064|      0|    gpg_err_set_errno (ENOMEM);
 1065|    947|  return p;
 1066|    947|}
global.c:_gcry_strdup_core:
 1140|    114|{
 1141|    114|  char *string_cp = NULL;
 1142|    114|  size_t string_n = 0;
 1143|       |
 1144|    114|  string_n = strlen (string);
 1145|       |
 1146|    114|  if (_gcry_is_secure (string))
  ------------------
  |  Branch (1146:7): [True: 0, False: 114]
  ------------------
 1147|      0|    string_cp = _gcry_malloc_secure_core (string_n + 1, xhint);
 1148|    114|  else
 1149|    114|    string_cp = _gcry_malloc (string_n + 1);
 1150|       |
 1151|    114|  if (string_cp)
  ------------------
  |  Branch (1151:7): [True: 114, False: 0]
  ------------------
 1152|    114|    strcpy (string_cp, string);
 1153|       |
 1154|    114|  return string_cp;
 1155|    114|}

_gcry_hwf_detect_x86:
  465|      1|{
  466|      1|#if defined (HAS_X86_CPUID)
  467|      1|  return detect_x86_gnuc ();
  468|       |#else
  469|       |  return 0;
  470|       |#endif
  471|      1|}
hwf-x86.c:detect_x86_gnuc:
  177|      1|{
  178|      1|  union
  179|      1|  {
  180|      1|    char c[12+1];
  181|      1|    unsigned int ui[3];
  182|      1|  } vendor_id;
  183|      1|  unsigned int features, features2;
  184|      1|  unsigned int os_supports_avx_avx2_registers = 0;
  185|      1|  unsigned int os_supports_avx512_registers = 0;
  186|      1|  unsigned int max_cpuid_level;
  187|      1|  unsigned int fms, family, model;
  188|      1|  unsigned int result = 0;
  189|      1|  unsigned int avoid_vpgather = 0;
  190|      1|  unsigned int is_amd_cpu = 0;
  191|       |
  192|      1|  (void)os_supports_avx_avx2_registers;
  193|      1|  (void)os_supports_avx512_registers;
  194|       |
  195|      1|  if (!is_cpuid_available())
  ------------------
  |  Branch (195:7): [True: 0, False: 1]
  ------------------
  196|      0|    return 0;
  197|       |
  198|      1|  get_cpuid(0, &max_cpuid_level, &vendor_id.ui[0], &vendor_id.ui[2],
  199|      1|            &vendor_id.ui[1]);
  200|      1|  vendor_id.c[12] = 0;
  201|       |
  202|      1|  if (0)
  ------------------
  |  Branch (202:7): [Folded - Ignored]
  ------------------
  203|      0|    ; /* Just to make "else if" and ifdef macros look pretty.  */
  204|      1|#ifdef ENABLE_PADLOCK_SUPPORT
  205|      1|  else if (!strcmp (vendor_id.c, "CentaurHauls"))
  ------------------
  |  Branch (205:12): [True: 0, False: 1]
  ------------------
  206|      0|    {
  207|       |      /* This is a VIA CPU.  Check what PadLock features we have.  */
  208|       |
  209|       |      /* Check for extended centaur (EAX).  */
  210|      0|      get_cpuid(0xC0000000, &features, NULL, NULL, NULL);
  211|       |
  212|       |      /* Has extended centaur features? */
  213|      0|      if (features > 0xC0000000)
  ------------------
  |  Branch (213:11): [True: 0, False: 0]
  ------------------
  214|      0|        {
  215|       |           /* Ask for the extended feature flags (EDX). */
  216|      0|           get_cpuid(0xC0000001, NULL, NULL, NULL, &features);
  217|       |
  218|       |           /* Test bits 2 and 3 to see whether the RNG exists and is enabled. */
  219|      0|           if ((features & 0x0C) == 0x0C)
  ------------------
  |  Branch (219:16): [True: 0, False: 0]
  ------------------
  220|      0|             result |= HWF_PADLOCK_RNG;
  ------------------
  |  |  221|      0|#define HWF_PADLOCK_RNG         (1 << 0)
  ------------------
  221|       |
  222|       |           /* Test bits 6 and 7 to see whether the ACE exists and is enabled. */
  223|      0|           if ((features & 0xC0) == 0xC0)
  ------------------
  |  Branch (223:16): [True: 0, False: 0]
  ------------------
  224|      0|             result |= HWF_PADLOCK_AES;
  ------------------
  |  |  222|      0|#define HWF_PADLOCK_AES         (1 << 1)
  ------------------
  225|       |
  226|       |           /* Test bits 10 and 11 to see whether the PHE exists and is
  227|       |              enabled.  */
  228|      0|           if ((features & 0xC00) == 0xC00)
  ------------------
  |  Branch (228:16): [True: 0, False: 0]
  ------------------
  229|      0|             result |= HWF_PADLOCK_SHA;
  ------------------
  |  |  223|      0|#define HWF_PADLOCK_SHA         (1 << 2)
  ------------------
  230|       |
  231|       |           /* Test bits 12 and 13 to see whether the MONTMUL exists and is
  232|       |              enabled.  */
  233|      0|           if ((features & 0x3000) == 0x3000)
  ------------------
  |  Branch (233:16): [True: 0, False: 0]
  ------------------
  234|      0|             result |= HWF_PADLOCK_MMUL;
  ------------------
  |  |  224|      0|#define HWF_PADLOCK_MMUL        (1 << 3)
  ------------------
  235|      0|        }
  236|      0|    }
  237|      1|#endif /*ENABLE_PADLOCK_SUPPORT*/
  238|      1|  else if (!strcmp (vendor_id.c, "GenuineIntel"))
  ------------------
  |  Branch (238:12): [True: 1, False: 0]
  ------------------
  239|      1|    {
  240|       |      /* This is an Intel CPU.  */
  241|      1|      result |= HWF_INTEL_CPU;
  ------------------
  |  |  226|      1|#define HWF_INTEL_CPU           (1 << 4)
  ------------------
  242|      1|    }
  243|      0|  else if (!strcmp (vendor_id.c, "AuthenticAMD"))
  ------------------
  |  Branch (243:12): [True: 0, False: 0]
  ------------------
  244|      0|    {
  245|       |      /* This is an AMD CPU.  */
  246|      0|      is_amd_cpu = 1;
  247|      0|    }
  248|       |
  249|       |  /* Detect Intel features, that might also be supported by other
  250|       |     vendors.  */
  251|       |
  252|       |  /* Get CPU family/model/stepping (EAX) and Intel feature flags (ECX, EDX).  */
  253|      1|  get_cpuid(1, &fms, NULL, &features, &features2);
  254|       |
  255|      1|  family = ((fms & 0xf00) >> 8) + ((fms & 0xff00000) >> 20);
  256|      1|  model = ((fms & 0xf0) >> 4) + ((fms & 0xf0000) >> 12);
  257|       |
  258|      1|#ifdef ENABLE_PCLMUL_SUPPORT
  259|       |  /* Test bit 1 for PCLMUL.  */
  260|      1|  if (features & 0x00000002)
  ------------------
  |  Branch (260:7): [True: 1, False: 0]
  ------------------
  261|      1|     result |= HWF_INTEL_PCLMUL;
  ------------------
  |  |  231|      1|#define HWF_INTEL_PCLMUL        (1 << 9)
  ------------------
  262|      1|#endif
  263|       |  /* Test bit 9 for SSSE3.  */
  264|      1|  if (features & 0x00000200)
  ------------------
  |  Branch (264:7): [True: 1, False: 0]
  ------------------
  265|      1|     result |= HWF_INTEL_SSSE3;
  ------------------
  |  |  229|      1|#define HWF_INTEL_SSSE3         (1 << 7)
  ------------------
  266|       |  /* Test bit 19 for SSE4.1.  */
  267|      1|  if (features & 0x00080000)
  ------------------
  |  Branch (267:7): [True: 1, False: 0]
  ------------------
  268|      1|     result |= HWF_INTEL_SSE4_1;
  ------------------
  |  |  230|      1|#define HWF_INTEL_SSE4_1        (1 << 8)
  ------------------
  269|      1|#ifdef ENABLE_AESNI_SUPPORT
  270|       |  /* Test bit 25 for AES-NI.  */
  271|      1|  if (features & 0x02000000)
  ------------------
  |  Branch (271:7): [True: 1, False: 0]
  ------------------
  272|      1|     result |= HWF_INTEL_AESNI;
  ------------------
  |  |  232|      1|#define HWF_INTEL_AESNI         (1 << 10)
  ------------------
  273|      1|#endif /*ENABLE_AESNI_SUPPORT*/
  274|      1|#if defined(ENABLE_AVX_SUPPORT) || defined(ENABLE_AVX2_SUPPORT) \
  275|      1|    || defined(ENABLE_AVX512_SUPPORT)
  276|       |  /* Test bit 27 for OSXSAVE (required for AVX/AVX2/AVX512).  */
  277|      1|  if (features & 0x08000000)
  ------------------
  |  Branch (277:7): [True: 1, False: 0]
  ------------------
  278|      1|    {
  279|      1|      unsigned int xmm_ymm_mask = (1 << 2) | (1 << 1);
  280|      1|      unsigned int zmm15_ymm31_k7_mask = (1 << 7) | (1 << 6) | (1 << 5);
  281|      1|      unsigned int xgetbv = get_xgetbv();
  282|       |
  283|       |      /* Check that OS has enabled both XMM and YMM state support.  */
  284|      1|      if ((xgetbv & xmm_ymm_mask) == xmm_ymm_mask)
  ------------------
  |  Branch (284:11): [True: 1, False: 0]
  ------------------
  285|      1|        os_supports_avx_avx2_registers = 1;
  286|       |
  287|       |      /* Check that OS has enabled full AVX512 state support.  */
  288|      1|      if ((xgetbv & zmm15_ymm31_k7_mask) == zmm15_ymm31_k7_mask)
  ------------------
  |  Branch (288:11): [True: 0, False: 1]
  ------------------
  289|      0|        os_supports_avx512_registers = 1;
  290|      1|    }
  291|      1|#endif
  292|      1|#ifdef ENABLE_AVX_SUPPORT
  293|       |  /* Test bit 28 for AVX.  */
  294|      1|  if (features & 0x10000000)
  ------------------
  |  Branch (294:7): [True: 1, False: 0]
  ------------------
  295|      1|    if (os_supports_avx_avx2_registers)
  ------------------
  |  Branch (295:9): [True: 1, False: 0]
  ------------------
  296|      1|      result |= HWF_INTEL_AVX;
  ------------------
  |  |  234|      1|#define HWF_INTEL_AVX           (1 << 12)
  ------------------
  297|      1|#endif /*ENABLE_AVX_SUPPORT*/
  298|      1|#ifdef ENABLE_DRNG_SUPPORT
  299|       |  /* Test bit 30 for RDRAND.  */
  300|      1|  if (features & 0x40000000)
  ------------------
  |  Branch (300:7): [True: 1, False: 0]
  ------------------
  301|      1|     result |= HWF_INTEL_RDRAND;
  ------------------
  |  |  233|      1|#define HWF_INTEL_RDRAND        (1 << 11)
  ------------------
  302|      1|#endif /*ENABLE_DRNG_SUPPORT*/
  303|       |
  304|       |  /* Test bit 4 of EDX for TSC.  */
  305|      1|  if (features2 & 0x00000010)
  ------------------
  |  Branch (305:7): [True: 1, False: 0]
  ------------------
  306|      1|    result |= HWF_INTEL_RDTSC;
  ------------------
  |  |  237|      1|#define HWF_INTEL_RDTSC         (1 << 15)
  ------------------
  307|       |
  308|       |  /* Check additional Intel feature flags.  Early Intel P5 processors report
  309|       |   * too high max_cpuid_level, so don't check level 7 if processor does not
  310|       |   * support SSE3 (as cpuid:7 contains only features for newer processors).
  311|       |   * Source: http://www.sandpile.org/x86/cpuid.htm  */
  312|      1|  if (max_cpuid_level >= 7 && (features & 0x00000001))
  ------------------
  |  Branch (312:7): [True: 1, False: 0]
  |  Branch (312:31): [True: 1, False: 0]
  ------------------
  313|      1|    {
  314|       |      /* Get CPUID:7 contains further Intel feature flags. */
  315|      1|      get_cpuid(7, NULL, &features, &features2, NULL);
  316|       |
  317|       |      /* Test bit 8 for BMI2.  */
  318|      1|      if (features & 0x00000100)
  ------------------
  |  Branch (318:11): [True: 1, False: 0]
  ------------------
  319|      1|          result |= HWF_INTEL_BMI2;
  ------------------
  |  |  228|      1|#define HWF_INTEL_BMI2          (1 << 6)
  ------------------
  320|       |
  321|      1|#ifdef ENABLE_AVX2_SUPPORT
  322|       |      /* Test bit 5 for AVX2.  */
  323|      1|      if (features & 0x00000020)
  ------------------
  |  Branch (323:11): [True: 1, False: 0]
  ------------------
  324|      1|        if (os_supports_avx_avx2_registers)
  ------------------
  |  Branch (324:13): [True: 1, False: 0]
  ------------------
  325|      1|          result |= HWF_INTEL_AVX2;
  ------------------
  |  |  235|      1|#define HWF_INTEL_AVX2          (1 << 13)
  ------------------
  326|      1|#endif /*ENABLE_AVX_SUPPORT*/
  327|       |
  328|       |      /* Test bit 29 for SHA Extensions. */
  329|      1|      if (features & (1 << 29))
  ------------------
  |  Branch (329:11): [True: 0, False: 1]
  ------------------
  330|      0|        result |= HWF_INTEL_SHAEXT;
  ------------------
  |  |  238|      0|#define HWF_INTEL_SHAEXT        (1 << 16)
  ------------------
  331|       |
  332|      1|#if defined(ENABLE_AVX2_SUPPORT) && defined(ENABLE_AESNI_SUPPORT) && \
  333|      1|    defined(ENABLE_PCLMUL_SUPPORT)
  334|       |      /* Test features2 bit 9 for VAES and features2 bit 10 for VPCLMULDQD */
  335|      1|      if ((features2 & 0x00000200) && (features2 & 0x00000400))
  ------------------
  |  Branch (335:11): [True: 0, False: 1]
  |  Branch (335:39): [True: 0, False: 0]
  ------------------
  336|      0|        result |= HWF_INTEL_VAES_VPCLMUL;
  ------------------
  |  |  239|      0|#define HWF_INTEL_VAES_VPCLMUL  (1 << 17)
  ------------------
  337|      1|#endif
  338|       |
  339|      1|#ifdef ENABLE_AVX512_SUPPORT
  340|       |      /* Test for AVX512 features. List of features is selected so that
  341|       |       * supporting CPUs are new enough not to suffer from reduced clock
  342|       |       * frequencies when AVX512 is used, which was issue on early AVX512
  343|       |       * capable CPUs.
  344|       |       *  - AVX512F (features bit 16)
  345|       |       *  - AVX512DQ (features bit 17)
  346|       |       *  - AVX512IFMA (features bit 21)
  347|       |       *  - AVX512CD (features bit 28)
  348|       |       *  - AVX512BW (features bit 30)
  349|       |       *  - AVX512VL (features bit 31)
  350|       |       *  - AVX512_VBMI (features2 bit 1)
  351|       |       *  - AVX512_VBMI2 (features2 bit 6)
  352|       |       *  - AVX512_VNNI (features2 bit 11)
  353|       |       *  - AVX512_BITALG (features2 bit 12)
  354|       |       *  - AVX512_VPOPCNTDQ (features2 bit 14)
  355|       |       */
  356|      1|      if (os_supports_avx512_registers
  ------------------
  |  Branch (356:11): [True: 0, False: 1]
  ------------------
  357|      1|	  && (features & (1 << 16))
  ------------------
  |  Branch (357:7): [True: 0, False: 0]
  ------------------
  358|      1|	  && (features & (1 << 17))
  ------------------
  |  Branch (358:7): [True: 0, False: 0]
  ------------------
  359|      1|	  && (features & (1 << 21))
  ------------------
  |  Branch (359:7): [True: 0, False: 0]
  ------------------
  360|      1|	  && (features & (1 << 28))
  ------------------
  |  Branch (360:7): [True: 0, False: 0]
  ------------------
  361|      1|	  && (features & (1 << 30))
  ------------------
  |  Branch (361:7): [True: 0, False: 0]
  ------------------
  362|      1|	  && (features & (1U << 31))
  ------------------
  |  Branch (362:7): [True: 0, False: 0]
  ------------------
  363|      1|	  && (features2 & (1 << 1))
  ------------------
  |  Branch (363:7): [True: 0, False: 0]
  ------------------
  364|      1|	  && (features2 & (1 << 6))
  ------------------
  |  Branch (364:7): [True: 0, False: 0]
  ------------------
  365|      1|	  && (features2 & (1 << 11))
  ------------------
  |  Branch (365:7): [True: 0, False: 0]
  ------------------
  366|      1|	  && (features2 & (1 << 12))
  ------------------
  |  Branch (366:7): [True: 0, False: 0]
  ------------------
  367|      1|	  && (features2 & (1 << 14)))
  ------------------
  |  Branch (367:7): [True: 0, False: 0]
  ------------------
  368|      0|	result |= HWF_INTEL_AVX512;
  ------------------
  |  |  240|      0|#define HWF_INTEL_AVX512        (1 << 18)
  ------------------
  369|      1|#endif
  370|       |
  371|       |      /* Test features2 bit 6 for GFNI (Galois field new instructions).
  372|       |       * These instructions are available for SSE/AVX/AVX2/AVX512. */
  373|      1|      if (features2 & (1 << 6))
  ------------------
  |  Branch (373:11): [True: 0, False: 1]
  ------------------
  374|      0|        result |= HWF_INTEL_GFNI;
  ------------------
  |  |  241|      0|#define HWF_INTEL_GFNI          (1 << 19)
  ------------------
  375|      1|    }
  376|       |
  377|      1|  if ((result & HWF_INTEL_CPU) && family == 6)
  ------------------
  |  |  226|      1|#define HWF_INTEL_CPU           (1 << 4)
  ------------------
  |  Branch (377:7): [True: 1, False: 0]
  |  Branch (377:35): [True: 1, False: 0]
  ------------------
  378|      1|    {
  379|       |      /* These Intel Core processor models have SHLD/SHRD instruction that
  380|       |       * can do integer rotation faster actual ROL/ROR instructions. */
  381|      1|      switch (model)
  ------------------
  |  Branch (381:15): [True: 0, False: 1]
  ------------------
  382|      1|	{
  383|      0|	case 0x2A:
  ------------------
  |  Branch (383:2): [True: 0, False: 1]
  ------------------
  384|      0|	case 0x2D:
  ------------------
  |  Branch (384:2): [True: 0, False: 1]
  ------------------
  385|      0|	case 0x3A:
  ------------------
  |  Branch (385:2): [True: 0, False: 1]
  ------------------
  386|      0|	case 0x3C:
  ------------------
  |  Branch (386:2): [True: 0, False: 1]
  ------------------
  387|      0|	case 0x3F:
  ------------------
  |  Branch (387:2): [True: 0, False: 1]
  ------------------
  388|      0|	case 0x45:
  ------------------
  |  Branch (388:2): [True: 0, False: 1]
  ------------------
  389|      0|	case 0x46:
  ------------------
  |  Branch (389:2): [True: 0, False: 1]
  ------------------
  390|      0|	case 0x3D:
  ------------------
  |  Branch (390:2): [True: 0, False: 1]
  ------------------
  391|      1|	case 0x4F:
  ------------------
  |  Branch (391:2): [True: 1, False: 0]
  ------------------
  392|      1|	case 0x56:
  ------------------
  |  Branch (392:2): [True: 0, False: 1]
  ------------------
  393|      1|	case 0x47:
  ------------------
  |  Branch (393:2): [True: 0, False: 1]
  ------------------
  394|      1|	case 0x4E:
  ------------------
  |  Branch (394:2): [True: 0, False: 1]
  ------------------
  395|      1|	case 0x5E:
  ------------------
  |  Branch (395:2): [True: 0, False: 1]
  ------------------
  396|      1|	case 0x8E:
  ------------------
  |  Branch (396:2): [True: 0, False: 1]
  ------------------
  397|      1|	case 0x9E:
  ------------------
  |  Branch (397:2): [True: 0, False: 1]
  ------------------
  398|      1|	case 0x55:
  ------------------
  |  Branch (398:2): [True: 0, False: 1]
  ------------------
  399|      1|	case 0x66:
  ------------------
  |  Branch (399:2): [True: 0, False: 1]
  ------------------
  400|      1|	  result |= HWF_INTEL_FAST_SHLD;
  ------------------
  |  |  227|      1|#define HWF_INTEL_FAST_SHLD     (1 << 5)
  ------------------
  401|      1|	  break;
  402|      1|	}
  403|       |
  404|       |      /* These Intel Core processors that have AVX2 have slow VPGATHER and
  405|       |       * should be avoided for table-lookup use. */
  406|      1|      switch (model)
  ------------------
  |  Branch (406:15): [True: 1, False: 0]
  ------------------
  407|      1|	{
  408|      0|	case 0x3C:
  ------------------
  |  Branch (408:2): [True: 0, False: 1]
  ------------------
  409|      0|	case 0x3F:
  ------------------
  |  Branch (409:2): [True: 0, False: 1]
  ------------------
  410|      0|	case 0x45:
  ------------------
  |  Branch (410:2): [True: 0, False: 1]
  ------------------
  411|      0|	case 0x46:
  ------------------
  |  Branch (411:2): [True: 0, False: 1]
  ------------------
  412|       |	  /* Haswell */
  413|      0|	  avoid_vpgather |= 1;
  414|      0|	  break;
  415|      1|	}
  416|      1|    }
  417|      0|  else if (is_amd_cpu)
  ------------------
  |  Branch (417:12): [True: 0, False: 0]
  ------------------
  418|      0|    {
  419|       |      /* Non-AVX512 AMD CPUs (pre-Zen4) have slow VPGATHER and should be
  420|       |       * avoided for table-lookup use. */
  421|      0|      avoid_vpgather |= !(result & HWF_INTEL_AVX512);
  ------------------
  |  |  240|      0|#define HWF_INTEL_AVX512        (1 << 18)
  ------------------
  422|      0|    }
  423|      0|  else
  424|      0|    {
  425|       |      /* Avoid VPGATHER for non-Intel/non-AMD CPUs as testing is needed to
  426|       |       * make sure it is fast enough. */
  427|      0|      avoid_vpgather |= 1;
  428|      0|    }
  429|       |
  430|       |#ifdef ENABLE_FORCE_SOFT_HWFEATURES
  431|       |  /* Soft HW features mark functionality that is available on all systems
  432|       |   * but not feasible to use because of slow HW implementation. */
  433|       |
  434|       |  /* Some implementations are disabled for non-Intel CPUs. Mark
  435|       |   * current CPU as Intel one to enable those implementations. */
  436|       |  result |= HWF_INTEL_CPU;
  437|       |
  438|       |  /* SHLD is faster at rotating register than actual ROR/ROL instructions
  439|       |   * on older Intel systems (~sandy-bridge era). However, SHLD is very
  440|       |   * slow on almost anything else and later Intel processors have faster
  441|       |   * ROR/ROL. Therefore in regular build HWF_INTEL_FAST_SHLD is enabled
  442|       |   * only for those Intel processors that benefit from the SHLD
  443|       |   * instruction. Enabled here unconditionally as requested. */
  444|       |  result |= HWF_INTEL_FAST_SHLD;
  445|       |
  446|       |  /* VPGATHER instructions are used for look-up table based
  447|       |   * implementations which require VPGATHER to be fast enough to beat
  448|       |   * regular parallelized look-up table implementations (see Twofish).
  449|       |   * So far, only Intel processors beginning with Skylake and AMD
  450|       |   * processors starting with Zen4 have had VPGATHER fast enough to be
  451|       |   * enabled. Enable VPGATHER here unconditionally as requested. */
  452|       |  avoid_vpgather = 0;
  453|       |#endif
  454|       |
  455|      1|  if ((result & HWF_INTEL_AVX2) && !avoid_vpgather)
  ------------------
  |  |  235|      1|#define HWF_INTEL_AVX2          (1 << 13)
  ------------------
  |  Branch (455:7): [True: 1, False: 0]
  |  Branch (455:36): [True: 1, False: 0]
  ------------------
  456|      1|    result |= HWF_INTEL_FAST_VPGATHER;
  ------------------
  |  |  236|      1|#define HWF_INTEL_FAST_VPGATHER (1 << 14)
  ------------------
  457|       |
  458|      1|  return result;
  459|      1|}
hwf-x86.c:is_cpuid_available:
  128|      1|{
  129|      1|  return 1;
  130|      1|}
hwf-x86.c:get_cpuid:
  135|      3|{
  136|      3|  unsigned int regs[4];
  137|       |
  138|      3|  asm volatile
  139|      3|    ("cpuid\n\t"
  140|      3|     : "=a" (regs[0]), "=b" (regs[1]), "=c" (regs[2]), "=d" (regs[3])
  141|      3|     : "0" (in), "1" (0), "2" (0), "3" (0)
  142|      3|     : "cc"
  143|      3|     );
  144|       |
  145|      3|  if (eax)
  ------------------
  |  Branch (145:7): [True: 2, False: 1]
  ------------------
  146|      2|    *eax = regs[0];
  147|      3|  if (ebx)
  ------------------
  |  Branch (147:7): [True: 2, False: 1]
  ------------------
  148|      2|    *ebx = regs[1];
  149|      3|  if (ecx)
  ------------------
  |  Branch (149:7): [True: 3, False: 0]
  ------------------
  150|      3|    *ecx = regs[2];
  151|      3|  if (edx)
  ------------------
  |  Branch (151:7): [True: 2, False: 1]
  ------------------
  152|      2|    *edx = regs[3];
  153|      3|}
hwf-x86.c:get_xgetbv:
  158|      1|{
  159|      1|  unsigned int t_eax, t_edx;
  160|       |
  161|      1|  asm volatile
  162|      1|    ("xgetbv\n\t"
  163|      1|     : "=a" (t_eax), "=d" (t_edx)
  164|      1|     : "c" (0)
  165|      1|    );
  166|       |
  167|      1|  return t_eax;
  168|      1|}

_gcry_get_hw_features:
  148|  2.76k|{
  149|  2.76k|  return hw_features;
  150|  2.76k|}
_gcry_detect_hw_features:
  227|      1|{
  228|      1|  hw_features = 0;
  229|       |
  230|      1|  parse_hwf_deny_file ();
  231|       |
  232|      1|#if defined (HAVE_CPU_ARCH_X86)
  233|      1|  {
  234|      1|    hw_features = _gcry_hwf_detect_x86 ();
  235|      1|  }
  236|       |#elif defined (HAVE_CPU_ARCH_ARM)
  237|       |  {
  238|       |    hw_features = _gcry_hwf_detect_arm ();
  239|       |  }
  240|       |#elif defined (HAVE_CPU_ARCH_PPC)
  241|       |  {
  242|       |    hw_features = _gcry_hwf_detect_ppc ();
  243|       |  }
  244|       |#elif defined (HAVE_CPU_ARCH_S390X)
  245|       |  {
  246|       |    hw_features = _gcry_hwf_detect_s390x ();
  247|       |  }
  248|       |#endif
  249|      1|  hw_features &= ~disabled_hw_features;
  250|      1|}
hwfeatures.c:parse_hwf_deny_file:
  171|      1|{
  172|      1|  const char *fname = HWF_DENY_FILE;
  ------------------
  |  |   36|      1|#define HWF_DENY_FILE "/etc/gcrypt/hwf.deny"
  ------------------
  173|      1|  FILE *fp;
  174|      1|  char buffer[256];
  175|      1|  char *p, *pend;
  176|      1|  int lnr = 0;
  177|       |
  178|      1|  fp = fopen (fname, "r");
  179|      1|  if (!fp)
  ------------------
  |  Branch (179:7): [True: 1, False: 0]
  ------------------
  180|      1|    return;
  181|       |
  182|      0|  for (;;)
  183|      0|    {
  184|      0|      if (!fgets (buffer, sizeof buffer, fp))
  ------------------
  |  Branch (184:11): [True: 0, False: 0]
  ------------------
  185|      0|        {
  186|      0|          if (!feof (fp))
  ------------------
  |  Branch (186:15): [True: 0, False: 0]
  ------------------
  187|      0|            {
  188|      0|#ifdef HAVE_SYSLOG
  189|      0|              syslog (LOG_USER|LOG_WARNING,
  190|      0|                      "Libgcrypt warning: error reading '%s', line %d",
  191|      0|                      fname, lnr);
  192|      0|#endif /*HAVE_SYSLOG*/
  193|      0|            }
  194|      0|          fclose (fp);
  195|      0|          return;
  196|      0|        }
  197|      0|      lnr++;
  198|      0|      for (p=buffer; my_isascii (*p) && isspace (*p); p++)
  ------------------
  |  |  107|      0|#define my_isascii(c) (!((c) & 0x80))
  |  |  ------------------
  |  |  |  Branch (107:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  199|      0|        ;
  200|      0|      pend = strchr (p, '\n');
  201|      0|      if (pend)
  ------------------
  |  Branch (201:11): [True: 0, False: 0]
  ------------------
  202|      0|        *pend = 0;
  203|      0|      pend = p + (*p? (strlen (p)-1):0);
  ------------------
  |  Branch (203:19): [True: 0, False: 0]
  ------------------
  204|      0|      for ( ;pend > p; pend--)
  ------------------
  |  Branch (204:14): [True: 0, False: 0]
  ------------------
  205|      0|        if (my_isascii (*pend) && isspace (*pend))
  ------------------
  |  |  107|      0|#define my_isascii(c) (!((c) & 0x80))
  |  |  ------------------
  |  |  |  Branch (107:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  206|      0|          *pend = 0;
  207|      0|      if (!*p || *p == '#')
  ------------------
  |  Branch (207:11): [True: 0, False: 0]
  |  Branch (207:18): [True: 0, False: 0]
  ------------------
  208|      0|        continue;
  209|       |
  210|      0|      if (_gcry_disable_hw_feature (p) == GPG_ERR_INV_NAME)
  ------------------
  |  Branch (210:11): [True: 0, False: 0]
  ------------------
  211|      0|        {
  212|      0|#ifdef HAVE_SYSLOG
  213|      0|          syslog (LOG_USER|LOG_WARNING,
  214|      0|                  "Libgcrypt warning: unknown feature in '%s', line %d",
  215|      0|                  fname, lnr);
  216|      0|#endif /*HAVE_SYSLOG*/
  217|      0|        }
  218|      0|    }
  219|      0|}

_gcry_set_log_handler:
  102|      1|{
  103|      1|    log_handler = f;
  104|      1|    log_handler_value = opaque;
  105|      1|}
_gcry_fast_wipememory:
  508|   124k|{
  509|       |  /* Note: This function is called from wipememory/wipememory2 only if LEN
  510|       |     is large or unknown at compile time. New wipe function alternatives
  511|       |     need to be checked before adding to this function. New implementations
  512|       |     need to be faster than wipememory/wipememory2 macros in 'g10lib.h'.
  513|       |
  514|       |     Following implementations were found to have suboptimal performance:
  515|       |
  516|       |     - [_WIN32/mingw32] SecureZeroMemory; Inline function, equivalent to
  517|       |       volatile byte buffer set: while(buflen--) (volatile char *)(buf++)=set;
  518|       |   */
  519|   124k|#ifdef HAVE_EXPLICIT_BZERO
  520|   124k|  explicit_bzero (ptr, len);
  521|       |#elif defined(HAVE_EXPLICIT_MEMSET)
  522|       |  explicit_memset (ptr, 0, len);
  523|       |#else
  524|       |  memset_ptr (ptr, 0, len);
  525|       |#endif
  526|   124k|}
__gcry_burn_stack:
  550|  1.21k|{
  551|  1.21k|#ifdef HAVE_VLA
  552|       |  /* (bytes == 0 ? 1 : bytes) == (!bytes + bytes) */
  553|  1.21k|  unsigned int buflen = ((!bytes + bytes) + 63) & ~63;
  554|  1.21k|  char buf[buflen];
  555|       |
  556|  1.21k|  _gcry_fast_wipememory (buf, buflen);
  557|       |#else
  558|       |  volatile char buf[64];
  559|       |
  560|       |  _gcry_fast_wipememory (buf, sizeof buf);
  561|       |
  562|       |  if (bytes > sizeof buf)
  563|       |      _gcry_burn_stack (bytes - sizeof buf);
  564|       |#endif
  565|  1.21k|}

_gcry_secmem_module_init:
  568|      1|{
  569|       |  /* Not anymore needed.  */
  570|      1|  return 0;
  571|      1|}
_gcry_private_is_secure:
  801|   245k|{
  802|   245k|  pooldesc_t *pool;
  803|       |
  804|       |  /* We do no lock here because once a pool is allocated it will not
  805|       |   * be removed anymore (except for gcry_secmem_term).  Further, as
  806|       |   * assigment of POOL->NEXT in new pool structure is visible in
  807|       |   * this thread before assigment of MAINPOOL.NEXT, pool list can be
  808|       |   * iterated locklessly.  This visiblity is ensured by memory barrier
  809|       |   * between POOL->NEXT and MAINPOOL.NEXT assignments in
  810|       |   * _gcry_secmem_malloc_internal. */
  811|   491k|  for (pool = &mainpool; pool; pool = pool->next)
  ------------------
  |  Branch (811:26): [True: 245k, False: 245k]
  ------------------
  812|   245k|    if (pool->okay && ptr_into_pool_p (pool, p))
  ------------------
  |  Branch (812:9): [True: 0, False: 245k]
  |  Branch (812:23): [True: 0, False: 0]
  ------------------
  813|      0|      return 1;
  814|       |
  815|   245k|  return 0;
  816|   245k|}

_gcry_sexp_release:
  318|    573|{
  319|    573|  if (sexp)
  ------------------
  |  Branch (319:7): [True: 466, False: 107]
  ------------------
  320|    466|    {
  321|    466|      if (_gcry_is_secure (sexp))
  ------------------
  |  Branch (321:11): [True: 0, False: 466]
  ------------------
  322|      0|        {
  323|       |          /* Extra paranoid wiping. */
  324|      0|          const byte *p = sexp->d;
  325|      0|          int type;
  326|       |
  327|      0|          while ( (type = *p) != ST_STOP )
  ------------------
  |  |   91|      0|#define ST_STOP  0
  ------------------
  |  Branch (327:19): [True: 0, False: 0]
  ------------------
  328|      0|            {
  329|      0|              p++;
  330|      0|              switch ( type )
  331|      0|                {
  332|      0|                case ST_OPEN:
  ------------------
  |  |   94|      0|#define ST_OPEN  3
  ------------------
  |  Branch (332:17): [True: 0, False: 0]
  ------------------
  333|      0|                  break;
  334|      0|                case ST_CLOSE:
  ------------------
  |  |   95|      0|#define ST_CLOSE 4
  ------------------
  |  Branch (334:17): [True: 0, False: 0]
  ------------------
  335|      0|                  break;
  336|      0|                case ST_DATA:
  ------------------
  |  |   92|      0|#define ST_DATA  1  /* datalen follows */
  ------------------
  |  Branch (336:17): [True: 0, False: 0]
  ------------------
  337|      0|                  {
  338|      0|                    DATALEN n;
  339|      0|                    memcpy ( &n, p, sizeof n );
  340|      0|                    p += sizeof n;
  341|      0|                    p += n;
  342|      0|                  }
  343|      0|                  break;
  344|      0|                default:
  ------------------
  |  Branch (344:17): [True: 0, False: 0]
  ------------------
  345|      0|                  break;
  346|      0|                }
  347|      0|            }
  348|      0|          wipememory (sexp->d, p - sexp->d);
  ------------------
  |  |  398|      0|#define wipememory(_ptr,_len) wipememory2((_ptr),0,(_len))
  |  |  ------------------
  |  |  |  |  388|      0|#define wipememory2(_ptr,_set,_len) do { \
  |  |  |  |  389|      0|	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |               	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (389:12): [True: 0, False: 0]
  |  |  |  |  |  Branch (389:33): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  390|      0|		if (CONSTANT_P(_set) && (_set) == 0) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (87:27): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  391|      0|		  _gcry_fast_wipememory((void *)(_ptr), (_len)); \
  |  |  |  |  392|      0|		else \
  |  |  |  |  393|      0|		  _gcry_fast_wipememory2((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  394|      0|	      } else { \
  |  |  |  |  395|      0|		fast_wipememory2_inline((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  380|      0|#define fast_wipememory2_inline(_ptr,_set,_len) do { \
  |  |  |  |  |  |  381|      0|	      memset((_ptr), (_set), (_len)); \
  |  |  |  |  |  |  382|      0|	      asm volatile ("\n" :: "r" (_ptr) : "memory"); \
  |  |  |  |  |  |  383|      0|	    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (383:14): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  396|      0|	      } \
  |  |  |  |  397|      0|	    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (397:14): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  349|      0|        }
  350|    466|      xfree ( sexp );
  ------------------
  |  |  150|    466|#define xfree(a)         _gcry_free ((a))
  ------------------
  351|    466|    }
  352|    573|}
_gcry_sexp_find_token:
  436|    357|{
  437|    357|  const byte *p;
  438|    357|  DATALEN n;
  439|       |
  440|    357|  if ( !list )
  ------------------
  |  Branch (440:8): [True: 0, False: 357]
  ------------------
  441|      0|    return NULL;
  442|       |
  443|    357|  if ( !toklen )
  ------------------
  |  Branch (443:8): [True: 195, False: 162]
  ------------------
  444|    195|    toklen = strlen(tok);
  445|       |
  446|    357|  p = list->d;
  447|  1.41k|  while ( *p != ST_STOP )
  ------------------
  |  |   91|  1.41k|#define ST_STOP  0
  ------------------
  |  Branch (447:11): [True: 1.30k, False: 119]
  ------------------
  448|  1.30k|    {
  449|  1.30k|      if ( *p == ST_OPEN && p[1] == ST_DATA )
  ------------------
  |  |   94|  2.60k|#define ST_OPEN  3
  ------------------
                    if ( *p == ST_OPEN && p[1] == ST_DATA )
  ------------------
  |  |   92|    719|#define ST_DATA  1  /* datalen follows */
  ------------------
  |  Branch (449:12): [True: 719, False: 581]
  |  Branch (449:29): [True: 719, False: 0]
  ------------------
  450|    719|        {
  451|    719|          const byte *head = p;
  452|       |
  453|    719|          p += 2;
  454|    719|          memcpy ( &n, p, sizeof n );
  455|    719|          p += sizeof n;
  456|    719|          if ( n == toklen && !memcmp( p, tok, toklen ) )
  ------------------
  |  Branch (456:16): [True: 405, False: 314]
  |  Branch (456:31): [True: 238, False: 167]
  ------------------
  457|    238|            { /* found it */
  458|    238|              gcry_sexp_t newlist;
  459|    238|              byte *d;
  460|    238|              int level = 1;
  461|       |
  462|       |              /* Look for the end of the list.  */
  463|  1.41k|              for ( p += n; level; p++ )
  ------------------
  |  Branch (463:29): [True: 1.17k, False: 238]
  ------------------
  464|  1.17k|                {
  465|  1.17k|                  if ( *p == ST_DATA )
  ------------------
  |  |   92|  1.17k|#define ST_DATA  1  /* datalen follows */
  ------------------
  |  Branch (465:24): [True: 512, False: 664]
  ------------------
  466|    512|                    {
  467|    512|			memcpy ( &n, ++p, sizeof n );
  468|    512|			p += sizeof n + n;
  469|    512|			p--; /* Compensate for later increment. */
  470|    512|		    }
  471|    664|                  else if ( *p == ST_OPEN )
  ------------------
  |  |   94|    664|#define ST_OPEN  3
  ------------------
  |  Branch (471:29): [True: 213, False: 451]
  ------------------
  472|    213|                    {
  473|    213|                      level++;
  474|    213|		    }
  475|    451|                  else if ( *p == ST_CLOSE )
  ------------------
  |  |   95|    451|#define ST_CLOSE 4
  ------------------
  |  Branch (475:29): [True: 451, False: 0]
  ------------------
  476|    451|                    {
  477|    451|                      level--;
  478|    451|		    }
  479|      0|                  else if ( *p == ST_STOP )
  ------------------
  |  |   91|      0|#define ST_STOP  0
  ------------------
  |  Branch (479:29): [True: 0, False: 0]
  ------------------
  480|      0|                    {
  481|      0|                      BUG ();
  ------------------
  |  |  187|      0|#define BUG() _gcry_bug( __FILE__ , __LINE__, __FUNCTION__ )
  ------------------
  482|      0|		    }
  483|  1.17k|		}
  484|    238|              n = p - head;
  485|       |
  486|    238|              newlist = xtrymalloc ( sizeof *newlist + n );
  ------------------
  |  |  138|    238|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  487|    238|              if (!newlist)
  ------------------
  |  Branch (487:19): [True: 0, False: 238]
  ------------------
  488|      0|                {
  489|       |                  /* No way to return an error code, so we can only
  490|       |                     return Not Found. */
  491|      0|                  return NULL;
  492|      0|                }
  493|    238|              d = newlist->d;
  494|    238|              memcpy ( d, head, n ); d += n;
  495|    238|              *d++ = ST_STOP;
  ------------------
  |  |   91|    238|#define ST_STOP  0
  ------------------
  496|    238|              return normalize ( newlist );
  497|    238|	    }
  498|    481|          p += n;
  499|    481|	}
  500|    581|      else if ( *p == ST_DATA )
  ------------------
  |  |   92|    581|#define ST_DATA  1  /* datalen follows */
  ------------------
  |  Branch (500:17): [True: 262, False: 319]
  ------------------
  501|    262|        {
  502|    262|          memcpy ( &n, ++p, sizeof n ); p += sizeof n;
  503|    262|          p += n;
  504|    262|	}
  505|    319|      else
  506|    319|        p++;
  507|  1.30k|    }
  508|    119|  return NULL;
  509|    357|}
_gcry_sexp_nth:
  598|     76|{
  599|     76|  const byte *p;
  600|     76|  DATALEN n;
  601|     76|  gcry_sexp_t newlist;
  602|     76|  byte *d;
  603|     76|  int level = 0;
  604|       |
  605|     76|  if (!list || list->d[0] != ST_OPEN)
  ------------------
  |  |   94|     76|#define ST_OPEN  3
  ------------------
  |  Branch (605:7): [True: 0, False: 76]
  |  Branch (605:16): [True: 0, False: 76]
  ------------------
  606|      0|    return NULL;
  607|     76|  p = list->d;
  608|       |
  609|    107|  while (number > 0)
  ------------------
  |  Branch (609:10): [True: 31, False: 76]
  ------------------
  610|     31|    {
  611|     31|      p++;
  612|     31|      if (*p == ST_DATA)
  ------------------
  |  |   92|     31|#define ST_DATA  1  /* datalen follows */
  ------------------
  |  Branch (612:11): [True: 31, False: 0]
  ------------------
  613|     31|        {
  614|     31|          memcpy (&n, ++p, sizeof n);
  615|     31|          p += sizeof n + n;
  616|     31|          p--;
  617|     31|          if (!level)
  ------------------
  |  Branch (617:15): [True: 31, False: 0]
  ------------------
  618|     31|            number--;
  619|     31|	}
  620|      0|      else if (*p == ST_OPEN)
  ------------------
  |  |   94|      0|#define ST_OPEN  3
  ------------------
  |  Branch (620:16): [True: 0, False: 0]
  ------------------
  621|      0|        {
  622|      0|          level++;
  623|      0|	}
  624|      0|      else if (*p == ST_CLOSE)
  ------------------
  |  |   95|      0|#define ST_CLOSE 4
  ------------------
  |  Branch (624:16): [True: 0, False: 0]
  ------------------
  625|      0|        {
  626|      0|          level--;
  627|      0|          if ( !level )
  ------------------
  |  Branch (627:16): [True: 0, False: 0]
  ------------------
  628|      0|            number--;
  629|      0|	}
  630|      0|      else if (*p == ST_STOP)
  ------------------
  |  |   91|      0|#define ST_STOP  0
  ------------------
  |  Branch (630:16): [True: 0, False: 0]
  ------------------
  631|      0|        {
  632|      0|          return NULL;
  633|      0|	}
  634|     31|    }
  635|     76|  p++;
  636|       |
  637|     76|  if (*p == ST_DATA)
  ------------------
  |  |   92|     76|#define ST_DATA  1  /* datalen follows */
  ------------------
  |  Branch (637:7): [True: 0, False: 76]
  ------------------
  638|      0|    {
  639|      0|      memcpy (&n, p+1, sizeof n);
  640|      0|      newlist = xtrymalloc (sizeof *newlist + 1 + 1 + sizeof n + n + 1);
  ------------------
  |  |  138|      0|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  641|      0|      if (!newlist)
  ------------------
  |  Branch (641:11): [True: 0, False: 0]
  ------------------
  642|      0|        return NULL;
  643|      0|      d = newlist->d;
  644|      0|      *d++ = ST_OPEN;
  ------------------
  |  |   94|      0|#define ST_OPEN  3
  ------------------
  645|      0|      memcpy (d, p, 1 + sizeof n + n);
  646|      0|      d += 1 + sizeof n + n;
  647|      0|      *d++ = ST_CLOSE;
  ------------------
  |  |   95|      0|#define ST_CLOSE 4
  ------------------
  648|      0|      *d = ST_STOP;
  ------------------
  |  |   91|      0|#define ST_STOP  0
  ------------------
  649|      0|    }
  650|     76|  else if (*p == ST_OPEN)
  ------------------
  |  |   94|     76|#define ST_OPEN  3
  ------------------
  |  Branch (650:12): [True: 76, False: 0]
  ------------------
  651|     76|    {
  652|     76|      const byte *head = p;
  653|       |
  654|     76|      level = 1;
  655|    700|      do {
  656|    700|        p++;
  657|    700|        if (*p == ST_DATA)
  ------------------
  |  |   92|    700|#define ST_DATA  1  /* datalen follows */
  ------------------
  |  Branch (657:13): [True: 350, False: 350]
  ------------------
  658|    350|          {
  659|    350|            memcpy (&n, ++p, sizeof n);
  660|    350|            p += sizeof n + n;
  661|    350|            p--;
  662|    350|          }
  663|    350|        else if (*p == ST_OPEN)
  ------------------
  |  |   94|    350|#define ST_OPEN  3
  ------------------
  |  Branch (663:18): [True: 137, False: 213]
  ------------------
  664|    137|          {
  665|    137|            level++;
  666|    137|          }
  667|    213|        else if (*p == ST_CLOSE)
  ------------------
  |  |   95|    213|#define ST_CLOSE 4
  ------------------
  |  Branch (667:18): [True: 213, False: 0]
  ------------------
  668|    213|          {
  669|    213|            level--;
  670|    213|          }
  671|      0|        else if (*p == ST_STOP)
  ------------------
  |  |   91|      0|#define ST_STOP  0
  ------------------
  |  Branch (671:18): [True: 0, False: 0]
  ------------------
  672|      0|          {
  673|      0|            BUG ();
  ------------------
  |  |  187|      0|#define BUG() _gcry_bug( __FILE__ , __LINE__, __FUNCTION__ )
  ------------------
  674|      0|          }
  675|    700|      } while (level);
  ------------------
  |  Branch (675:16): [True: 624, False: 76]
  ------------------
  676|     76|      n = p + 1 - head;
  677|       |
  678|     76|      newlist = xtrymalloc (sizeof *newlist + n);
  ------------------
  |  |  138|     76|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  679|     76|      if (!newlist)
  ------------------
  |  Branch (679:11): [True: 0, False: 76]
  ------------------
  680|      0|        return NULL;
  681|     76|      d = newlist->d;
  682|     76|      memcpy (d, head, n);
  683|     76|      d += n;
  684|     76|      *d++ = ST_STOP;
  ------------------
  |  |   91|     76|#define ST_STOP  0
  ------------------
  685|     76|    }
  686|      0|  else
  687|      0|    newlist = NULL;
  688|       |
  689|     76|  return normalize (newlist);
  690|     76|}
_gcry_sexp_car:
  695|     45|{
  696|     45|  return _gcry_sexp_nth (list, 0);
  697|     45|}
_gcry_sexp_nth_data:
  763|      6|{
  764|      6|  return do_sexp_nth_data (list, number, datalen);
  765|      6|}
_gcry_sexp_nth_buffer:
  774|     24|{
  775|     24|  const char *s;
  776|     24|  size_t n;
  777|     24|  char *buf;
  778|       |
  779|     24|  *rlength = 0;
  780|     24|  s = do_sexp_nth_data (list, number, &n);
  781|     24|  if (!s || !n)
  ------------------
  |  Branch (781:7): [True: 0, False: 24]
  |  Branch (781:13): [True: 0, False: 24]
  ------------------
  782|      0|    return NULL;
  783|     24|  buf = xtrymalloc (n);
  ------------------
  |  |  138|     24|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  784|     24|  if (!buf)
  ------------------
  |  Branch (784:7): [True: 0, False: 24]
  ------------------
  785|      0|    return NULL;
  786|     24|  memcpy (buf, s, n);
  787|     24|  *rlength = n;
  788|     24|  return buf;
  789|     24|}
_gcry_sexp_nth_string:
  796|    116|{
  797|    116|  const char *s;
  798|    116|  size_t n;
  799|    116|  char *buf;
  800|       |
  801|    116|  s = do_sexp_nth_data (list, number, &n);
  802|    116|  if (!s || n < 1 || (n+1) < 1)
  ------------------
  |  Branch (802:7): [True: 0, False: 116]
  |  Branch (802:13): [True: 0, False: 116]
  |  Branch (802:22): [True: 0, False: 116]
  ------------------
  803|      0|    return NULL;
  804|    116|  buf = xtrymalloc (n+1);
  ------------------
  |  |  138|    116|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  805|    116|  if (!buf)
  ------------------
  |  Branch (805:7): [True: 0, False: 116]
  ------------------
  806|      0|    return NULL;
  807|    116|  memcpy (buf, s, n);
  808|    116|  buf[n] = 0;
  809|    116|  return buf;
  810|    116|}
_gcry_sexp_nth_mpi:
  818|    147|{
  819|    147|  size_t n;
  820|    147|  gcry_mpi_t a;
  821|       |
  822|    147|  if (mpifmt == GCRYMPI_FMT_OPAQUE)
  ------------------
  |  Branch (822:7): [True: 24, False: 123]
  ------------------
  823|     24|    {
  824|     24|      char *p;
  825|       |
  826|     24|      p = _gcry_sexp_nth_buffer (list, number, &n);
  827|     24|      if (!p)
  ------------------
  |  Branch (827:11): [True: 0, False: 24]
  ------------------
  828|      0|        return NULL;
  829|       |
  830|     24|      a = _gcry_is_secure (list)? _gcry_mpi_snew (0) : _gcry_mpi_new (0);
  ------------------
  |  Branch (830:11): [True: 0, False: 24]
  ------------------
  831|     24|      if (a)
  ------------------
  |  Branch (831:11): [True: 24, False: 0]
  ------------------
  832|     24|        mpi_set_opaque (a, p, n*8);
  ------------------
  |  |  561|     24|#define mpi_set_opaque(a,b,c)  _gcry_mpi_set_opaque ((a), (b), (c))
  ------------------
  833|      0|      else
  834|      0|        xfree (p);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
  835|     24|    }
  836|    123|  else
  837|    123|    {
  838|    123|      const char *s;
  839|       |
  840|    123|      if (!mpifmt)
  ------------------
  |  Branch (840:11): [True: 0, False: 123]
  ------------------
  841|      0|        mpifmt = GCRYMPI_FMT_STD;
  842|       |
  843|    123|      s = do_sexp_nth_data (list, number, &n);
  844|    123|      if (!s)
  ------------------
  |  Branch (844:11): [True: 0, False: 123]
  ------------------
  845|      0|        return NULL;
  846|       |
  847|    123|      if (_gcry_mpi_scan (&a, mpifmt, s, n, NULL))
  ------------------
  |  Branch (847:11): [True: 0, False: 123]
  ------------------
  848|      0|        return NULL;
  849|    123|    }
  850|       |
  851|    147|  return a;
  852|    147|}
_gcry_sexp_cdr:
  860|     45|{
  861|     45|  const byte *p;
  862|     45|  const byte *head;
  863|     45|  DATALEN n;
  864|     45|  gcry_sexp_t newlist;
  865|     45|  byte *d;
  866|     45|  int level = 0;
  867|     45|  int skip = 1;
  868|       |
  869|     45|  if (!list || list->d[0] != ST_OPEN)
  ------------------
  |  |   94|     45|#define ST_OPEN  3
  ------------------
  |  Branch (869:7): [True: 0, False: 45]
  |  Branch (869:16): [True: 0, False: 45]
  ------------------
  870|      0|    return NULL;
  871|     45|  p = list->d;
  872|       |
  873|     90|  while (skip > 0)
  ------------------
  |  Branch (873:10): [True: 45, False: 45]
  ------------------
  874|     45|    {
  875|     45|      p++;
  876|     45|      if (*p == ST_DATA)
  ------------------
  |  |   92|     45|#define ST_DATA  1  /* datalen follows */
  ------------------
  |  Branch (876:11): [True: 45, False: 0]
  ------------------
  877|     45|        {
  878|     45|          memcpy ( &n, ++p, sizeof n );
  879|     45|          p += sizeof n + n;
  880|     45|          p--;
  881|     45|          if ( !level )
  ------------------
  |  Branch (881:16): [True: 45, False: 0]
  ------------------
  882|     45|            skip--;
  883|     45|	}
  884|      0|      else if (*p == ST_OPEN)
  ------------------
  |  |   94|      0|#define ST_OPEN  3
  ------------------
  |  Branch (884:16): [True: 0, False: 0]
  ------------------
  885|      0|        {
  886|      0|          level++;
  887|      0|	}
  888|      0|      else if (*p == ST_CLOSE)
  ------------------
  |  |   95|      0|#define ST_CLOSE 4
  ------------------
  |  Branch (888:16): [True: 0, False: 0]
  ------------------
  889|      0|        {
  890|      0|          level--;
  891|      0|          if ( !level )
  ------------------
  |  Branch (891:16): [True: 0, False: 0]
  ------------------
  892|      0|            skip--;
  893|      0|	}
  894|      0|      else if (*p == ST_STOP)
  ------------------
  |  |   91|      0|#define ST_STOP  0
  ------------------
  |  Branch (894:16): [True: 0, False: 0]
  ------------------
  895|      0|        {
  896|      0|          return NULL;
  897|      0|	}
  898|     45|    }
  899|     45|  p++;
  900|       |
  901|     45|  head = p;
  902|     45|  level = 0;
  903|    495|  do {
  904|    495|    if (*p == ST_DATA)
  ------------------
  |  |   92|    495|#define ST_DATA  1  /* datalen follows */
  ------------------
  |  Branch (904:9): [True: 225, False: 270]
  ------------------
  905|    225|      {
  906|    225|        memcpy ( &n, ++p, sizeof n );
  907|    225|        p += sizeof n + n;
  908|    225|        p--;
  909|    225|      }
  910|    270|    else if (*p == ST_OPEN)
  ------------------
  |  |   94|    270|#define ST_OPEN  3
  ------------------
  |  Branch (910:14): [True: 135, False: 135]
  ------------------
  911|    135|      {
  912|    135|        level++;
  913|    135|      }
  914|    135|    else if (*p == ST_CLOSE)
  ------------------
  |  |   95|    135|#define ST_CLOSE 4
  ------------------
  |  Branch (914:14): [True: 135, False: 0]
  ------------------
  915|    135|      {
  916|    135|        level--;
  917|    135|      }
  918|      0|    else if (*p == ST_STOP)
  ------------------
  |  |   91|      0|#define ST_STOP  0
  ------------------
  |  Branch (918:14): [True: 0, False: 0]
  ------------------
  919|      0|      {
  920|      0|        return NULL;
  921|      0|      }
  922|    495|    p++;
  923|    495|  } while (level);
  ------------------
  |  Branch (923:12): [True: 450, False: 45]
  ------------------
  924|     45|  n = p - head;
  925|       |
  926|     45|  newlist = xtrymalloc (sizeof *newlist + n + 2);
  ------------------
  |  |  138|     45|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  927|     45|  if (!newlist)
  ------------------
  |  Branch (927:7): [True: 0, False: 45]
  ------------------
  928|      0|    return NULL;
  929|     45|  d = newlist->d;
  930|     45|  *d++ = ST_OPEN;
  ------------------
  |  |   94|     45|#define ST_OPEN  3
  ------------------
  931|     45|  memcpy (d, head, n);
  932|     45|  d += n;
  933|     45|  *d++ = ST_CLOSE;
  ------------------
  |  |   95|     45|#define ST_CLOSE 4
  ------------------
  934|     45|  *d++ = ST_STOP;
  ------------------
  |  |   91|     45|#define ST_STOP  0
  ------------------
  935|       |
  936|     45|  return normalize (newlist);
  937|     45|}
_gcry_sexp_cadr:
  942|     45|{
  943|     45|  gcry_sexp_t a, b;
  944|       |
  945|     45|  a = _gcry_sexp_cdr (list);
  946|     45|  b = _gcry_sexp_car (a);
  947|     45|  sexp_release (a);
  ------------------
  |  |  372|     45|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  948|     45|  return b;
  949|     45|}
_gcry_sexp_vbuild:
 1816|    107|{
 1817|    107|  return do_vsexp_sscan (retsexp, erroff, format, strlen(format), 1,
 1818|    107|                         NULL, arg_ptr);
 1819|    107|}
_gcry_sexp_vextract_param:
 2309|     54|{
 2310|     54|  gpg_err_code_t rc;
 2311|     54|  const char *s, *s2;
 2312|     54|  void **array[20];
 2313|     54|  char arrayisdesc[20];
 2314|     54|  int idx, i;
 2315|     54|  gcry_sexp_t l1 = NULL;
 2316|     54|  int mode = '+'; /* Default to GCRYMPI_FMT_USG.  */
 2317|     54|  int submode = 0;
 2318|     54|  gcry_sexp_t freethis = NULL;
 2319|     54|  char *tmpstr = NULL;
 2320|       |
 2321|       |  /* Values in ARRAYISDESC describing what the ARRAY holds.
 2322|       |   *  0  - MPI
 2323|       |   *  1  - gcry_buffer_t provided by caller.
 2324|       |   *  2  - gcry_buffer_t allocated by us.
 2325|       |   * 's' - String allocated by us.
 2326|       |   * 'x' - Ignore
 2327|       |   */
 2328|     54|  memset (arrayisdesc, 0, sizeof arrayisdesc);
 2329|       |
 2330|       |  /* First copy all the args into an array.  This is required so that
 2331|       |     we are able to release already allocated MPIs if later an error
 2332|       |     was found.  */
 2333|    147|  for (s=list, idx=0; *s && idx < DIM (array); s++)
  ------------------
  |  |  104|     93|#define DIM(v) (sizeof(v)/sizeof((v)[0]))
  ------------------
  |  Branch (2333:23): [True: 93, False: 54]
  |  Branch (2333:29): [True: 93, False: 0]
  ------------------
 2334|     93|    {
 2335|     93|      if (*s == '&' || *s == '+' || *s == '-' || *s == '/' || *s == '?')
  ------------------
  |  Branch (2335:11): [True: 0, False: 93]
  |  Branch (2335:24): [True: 0, False: 93]
  |  Branch (2335:37): [True: 0, False: 93]
  |  Branch (2335:50): [True: 8, False: 85]
  |  Branch (2335:63): [True: 0, False: 85]
  ------------------
 2336|      8|        ;
 2337|     85|      else if (*s == '%')
  ------------------
  |  Branch (2337:16): [True: 0, False: 85]
  ------------------
 2338|      0|        {
 2339|      0|          s++;
 2340|      0|          if (*s == 'l' && (s[1] == 'u' || s[1] == 'd'))
  ------------------
  |  Branch (2340:15): [True: 0, False: 0]
  |  Branch (2340:29): [True: 0, False: 0]
  |  Branch (2340:44): [True: 0, False: 0]
  ------------------
 2341|      0|            s++;
 2342|      0|          else if (*s == 'z' && s[1] == 'u')
  ------------------
  |  Branch (2342:20): [True: 0, False: 0]
  |  Branch (2342:33): [True: 0, False: 0]
  ------------------
 2343|      0|            s++;
 2344|      0|          else if (*s == '#' && s[1] == 's')
  ------------------
  |  Branch (2344:20): [True: 0, False: 0]
  |  Branch (2344:33): [True: 0, False: 0]
  ------------------
 2345|      0|            s++;
 2346|      0|          continue;
 2347|      0|        }
 2348|     85|      else if (whitespacep (s))
  ------------------
  |  Branch (2348:16): [True: 0, False: 85]
  ------------------
 2349|      0|        ;
 2350|     85|      else
 2351|     85|        {
 2352|     85|          if (*s == '\'')
  ------------------
  |  Branch (2352:15): [True: 0, False: 85]
  ------------------
 2353|      0|            {
 2354|      0|              s++;
 2355|      0|              s2 = strchr (s, '\'');
 2356|      0|              if (!s2 || s2 == s)
  ------------------
  |  Branch (2356:19): [True: 0, False: 0]
  |  Branch (2356:26): [True: 0, False: 0]
  ------------------
 2357|      0|                {
 2358|       |                  /* Closing quote not found or empty string.  */
 2359|      0|                  return GPG_ERR_SYNTAX;
 2360|      0|                }
 2361|      0|              s = s2;
 2362|      0|            }
 2363|     85|          array[idx] = va_arg (arg_ptr, void *);
 2364|     85|          if (!array[idx])
  ------------------
  |  Branch (2364:15): [True: 0, False: 85]
  ------------------
 2365|      0|            return GPG_ERR_MISSING_VALUE; /* NULL pointer given.  */
 2366|     85|          idx++;
 2367|     85|        }
 2368|     93|    }
 2369|     54|  if (*s)
  ------------------
  |  Branch (2369:7): [True: 0, False: 54]
  ------------------
 2370|      0|    return GPG_ERR_LIMIT_REACHED;  /* Too many list elements.  */
 2371|     54|  if (va_arg (arg_ptr, gcry_mpi_t *))
 2372|      0|    return GPG_ERR_INV_ARG;  /* Not enough list elemends.  */
 2373|       |
 2374|       |  /* Drill down.  */
 2375|     54|  while (path && *path)
  ------------------
  |  Branch (2375:10): [True: 0, False: 54]
  |  Branch (2375:18): [True: 0, False: 0]
  ------------------
 2376|      0|    {
 2377|      0|      size_t n;
 2378|       |
 2379|      0|      s = strchr (path, '!');
 2380|      0|      if (s == path)
  ------------------
  |  Branch (2380:11): [True: 0, False: 0]
  ------------------
 2381|      0|        {
 2382|      0|          rc = GPG_ERR_NOT_FOUND;
 2383|      0|          goto cleanup;
 2384|      0|        }
 2385|      0|      n = s? s - path : 0;
  ------------------
  |  Branch (2385:11): [True: 0, False: 0]
  ------------------
 2386|      0|      l1 = _gcry_sexp_find_token (sexp, path, n);
 2387|      0|      if (!l1)
  ------------------
  |  Branch (2387:11): [True: 0, False: 0]
  ------------------
 2388|      0|        {
 2389|      0|          rc = GPG_ERR_NOT_FOUND;
 2390|      0|          goto cleanup;
 2391|      0|        }
 2392|      0|      sexp = l1; l1 = NULL;
 2393|      0|      sexp_release (freethis);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 2394|      0|      freethis = sexp;
 2395|      0|      if (n)
  ------------------
  |  Branch (2395:11): [True: 0, False: 0]
  ------------------
 2396|      0|        path += n + 1;
 2397|      0|      else
 2398|      0|        path = NULL;
 2399|      0|    }
 2400|       |
 2401|       |
 2402|       |  /* Now extract all parameters.  */
 2403|    147|  for (s=list, idx=0; *s; s++)
  ------------------
  |  Branch (2403:23): [True: 93, False: 54]
  ------------------
 2404|     93|    {
 2405|     93|      if (*s == '&' || *s == '+' || *s == '-' || *s == '/')
  ------------------
  |  Branch (2405:11): [True: 0, False: 93]
  |  Branch (2405:24): [True: 0, False: 93]
  |  Branch (2405:37): [True: 0, False: 93]
  |  Branch (2405:50): [True: 8, False: 85]
  ------------------
 2406|      8|        mode = *s;
 2407|     85|      else if (*s == '%')
  ------------------
  |  Branch (2407:16): [True: 0, False: 85]
  ------------------
 2408|      0|        {
 2409|      0|          s++;
 2410|      0|          if (!*s)
  ------------------
  |  Branch (2410:15): [True: 0, False: 0]
  ------------------
 2411|      0|            continue;  /* Ignore at end of format.  */
 2412|      0|          if (*s == 's' || *s == 'd' || *s == 'u')
  ------------------
  |  Branch (2412:15): [True: 0, False: 0]
  |  Branch (2412:28): [True: 0, False: 0]
  |  Branch (2412:41): [True: 0, False: 0]
  ------------------
 2413|      0|            {
 2414|      0|              mode = *s;
 2415|      0|              submode = 0;
 2416|      0|            }
 2417|      0|          else if (*s == 'l' && (s[1] == 'u' || s[1] == 'd'))
  ------------------
  |  Branch (2417:20): [True: 0, False: 0]
  |  Branch (2417:34): [True: 0, False: 0]
  |  Branch (2417:49): [True: 0, False: 0]
  ------------------
 2418|      0|            {
 2419|      0|              mode = s[1];
 2420|      0|              submode = 'l';
 2421|      0|              s++;
 2422|      0|            }
 2423|      0|          else if (*s == 'z' && s[1] == 'u')
  ------------------
  |  Branch (2423:20): [True: 0, False: 0]
  |  Branch (2423:33): [True: 0, False: 0]
  ------------------
 2424|      0|            {
 2425|      0|              mode = s[1];
 2426|      0|              submode = 'z';
 2427|      0|              s++;
 2428|      0|            }
 2429|      0|          else if (*s == '#' && s[1] == 's')
  ------------------
  |  Branch (2429:20): [True: 0, False: 0]
  |  Branch (2429:33): [True: 0, False: 0]
  ------------------
 2430|      0|            {
 2431|      0|              mode = s[1];
 2432|      0|              submode = '#';
 2433|      0|              s++;
 2434|      0|            }
 2435|      0|          continue;
 2436|      0|        }
 2437|     85|      else if (whitespacep (s))
  ------------------
  |  Branch (2437:16): [True: 0, False: 85]
  ------------------
 2438|      0|        ;
 2439|     85|      else if (*s == '?')
  ------------------
  |  Branch (2439:16): [True: 0, False: 85]
  ------------------
 2440|      0|        ; /* Only used via lookahead.  */
 2441|     85|      else
 2442|     85|        {
 2443|     85|          if (*s == '\'')
  ------------------
  |  Branch (2443:15): [True: 0, False: 85]
  ------------------
 2444|      0|            {
 2445|       |              /* Find closing quote, find token, set S to closing quote.  */
 2446|      0|              s++;
 2447|      0|              s2 = strchr (s, '\'');
 2448|      0|              if (!s2 || s2 == s)
  ------------------
  |  Branch (2448:19): [True: 0, False: 0]
  |  Branch (2448:26): [True: 0, False: 0]
  ------------------
 2449|      0|                {
 2450|       |                  /* Closing quote not found or empty string.  */
 2451|      0|                  rc = GPG_ERR_SYNTAX;
 2452|      0|                  goto cleanup;
 2453|      0|                }
 2454|      0|              l1 = _gcry_sexp_find_token (sexp, s, s2 - s);
 2455|      0|              s = s2;
 2456|      0|            }
 2457|     85|          else
 2458|     85|            l1 = _gcry_sexp_find_token (sexp, s, 1);
 2459|       |
 2460|     85|          if (!l1 && s[1] == '?')
  ------------------
  |  Branch (2460:15): [True: 0, False: 85]
  |  Branch (2460:22): [True: 0, False: 0]
  ------------------
 2461|      0|            {
 2462|       |              /* Optional element not found.  */
 2463|      0|              if (mode == '&')
  ------------------
  |  Branch (2463:19): [True: 0, False: 0]
  ------------------
 2464|      0|                {
 2465|      0|                  gcry_buffer_t *spec = (gcry_buffer_t*)array[idx];
 2466|      0|                  if (!spec->data)
  ------------------
  |  Branch (2466:23): [True: 0, False: 0]
  ------------------
 2467|      0|                    {
 2468|      0|                      spec->size = 0;
 2469|      0|                      spec->off = 0;
 2470|      0|                    }
 2471|      0|                  spec->len = 0;
 2472|      0|                }
 2473|      0|              else if (mode == 's')
  ------------------
  |  Branch (2473:24): [True: 0, False: 0]
  ------------------
 2474|      0|                {
 2475|      0|                  *array[idx] = NULL;
 2476|      0|                  arrayisdesc[idx] = 's';
 2477|      0|                }
 2478|      0|              else if (mode == 'd')
  ------------------
  |  Branch (2478:24): [True: 0, False: 0]
  ------------------
 2479|      0|                {
 2480|      0|                  if (submode == 'l')
  ------------------
  |  Branch (2480:23): [True: 0, False: 0]
  ------------------
 2481|      0|                    *(long *)array[idx] = 0;
 2482|      0|                  else
 2483|      0|                    *(int *)array[idx] = 0;
 2484|      0|                  arrayisdesc[idx] = 'x';
 2485|      0|                }
 2486|      0|              else if (mode == 'u')
  ------------------
  |  Branch (2486:24): [True: 0, False: 0]
  ------------------
 2487|      0|                {
 2488|      0|                  if (submode == 'l')
  ------------------
  |  Branch (2488:23): [True: 0, False: 0]
  ------------------
 2489|      0|                    *(unsigned long *)array[idx] = 0;
 2490|      0|                  else if (submode == 'z')
  ------------------
  |  Branch (2490:28): [True: 0, False: 0]
  ------------------
 2491|      0|                    *(size_t *)array[idx] = 0;
 2492|      0|                  else
 2493|      0|                    *(unsigned int *)array[idx] = 0;
 2494|      0|                  arrayisdesc[idx] = 'x';
 2495|      0|                }
 2496|      0|              else
 2497|      0|                *array[idx] = NULL;
 2498|      0|            }
 2499|     85|          else if (!l1)
  ------------------
  |  Branch (2499:20): [True: 0, False: 85]
  ------------------
 2500|      0|            {
 2501|      0|              rc = GPG_ERR_NO_OBJ;  /* List element not found.  */
 2502|      0|              goto cleanup;
 2503|      0|            }
 2504|     85|           else
 2505|     85|            {
 2506|     85|              if (mode == '&')
  ------------------
  |  Branch (2506:19): [True: 0, False: 85]
  ------------------
 2507|      0|                {
 2508|      0|                  gcry_buffer_t *spec = (gcry_buffer_t*)array[idx];
 2509|       |
 2510|      0|                  if (spec->data)
  ------------------
  |  Branch (2510:23): [True: 0, False: 0]
  ------------------
 2511|      0|                    {
 2512|      0|                      const char *pbuf;
 2513|      0|                      size_t nbuf;
 2514|       |
 2515|      0|                      pbuf = _gcry_sexp_nth_data (l1, 1, &nbuf);
 2516|      0|                      if (!pbuf || !nbuf)
  ------------------
  |  Branch (2516:27): [True: 0, False: 0]
  |  Branch (2516:36): [True: 0, False: 0]
  ------------------
 2517|      0|                        {
 2518|      0|                          rc = GPG_ERR_INV_OBJ;
 2519|      0|                          goto cleanup;
 2520|      0|                        }
 2521|      0|                      if (spec->off + nbuf > spec->size)
  ------------------
  |  Branch (2521:27): [True: 0, False: 0]
  ------------------
 2522|      0|                        {
 2523|      0|                          rc = GPG_ERR_BUFFER_TOO_SHORT;
 2524|      0|                          goto cleanup;
 2525|      0|                        }
 2526|      0|                      memcpy ((char*)spec->data + spec->off, pbuf, nbuf);
 2527|      0|                      spec->len = nbuf;
 2528|      0|                      arrayisdesc[idx] = 1;
 2529|      0|                    }
 2530|      0|                  else
 2531|      0|                    {
 2532|      0|                      spec->data = _gcry_sexp_nth_buffer (l1, 1, &spec->size);
 2533|      0|                      if (!spec->data)
  ------------------
  |  Branch (2533:27): [True: 0, False: 0]
  ------------------
 2534|      0|                        {
 2535|      0|                          rc = GPG_ERR_INV_OBJ; /* Or out of core.  */
 2536|      0|                          goto cleanup;
 2537|      0|                        }
 2538|      0|                      spec->len = spec->size;
 2539|      0|                      spec->off = 0;
 2540|      0|                      arrayisdesc[idx] = 2;
 2541|      0|                    }
 2542|      0|                }
 2543|     85|              else if (mode == 's')
  ------------------
  |  Branch (2543:24): [True: 0, False: 85]
  ------------------
 2544|      0|                {
 2545|      0|                  if (submode == '#')
  ------------------
  |  Branch (2545:23): [True: 0, False: 0]
  ------------------
 2546|      0|                    {
 2547|      0|                      size_t needed = 0;
 2548|      0|                      size_t n;
 2549|      0|                      int l1len;
 2550|      0|                      char *p;
 2551|       |
 2552|      0|                      l1len = l1? sexp_length (l1) : 0;
  ------------------
  |  |  382|      0|#define sexp_length(a)               _gcry_sexp_length ((a))
  ------------------
  |  Branch (2552:31): [True: 0, False: 0]
  ------------------
 2553|      0|                      for (i = 1; i < l1len; i++)
  ------------------
  |  Branch (2553:35): [True: 0, False: 0]
  ------------------
 2554|      0|                        {
 2555|      0|                          s2 = sexp_nth_data (l1, i, &n);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
 2556|      0|                          if (!s2)
  ------------------
  |  Branch (2556:31): [True: 0, False: 0]
  ------------------
 2557|      0|                            n = 2; /* Not a data element; we use "()". */
 2558|      0|                          needed += n + 1;
 2559|      0|                        }
 2560|      0|                      if (!needed)
  ------------------
  |  Branch (2560:27): [True: 0, False: 0]
  ------------------
 2561|      0|                        {
 2562|      0|                          *array[idx] = p = xtrymalloc (1);
  ------------------
  |  |  138|      0|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
 2563|      0|                          if (p)
  ------------------
  |  Branch (2563:31): [True: 0, False: 0]
  ------------------
 2564|      0|                            *p = 0;
 2565|      0|                        }
 2566|      0|                      else if ((*array[idx] = p = xtrymalloc (needed)))
  ------------------
  |  |  138|      0|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
  |  Branch (2566:32): [True: 0, False: 0]
  ------------------
 2567|      0|                        {
 2568|      0|                          for (i = 1; i < l1len; i++)
  ------------------
  |  Branch (2568:39): [True: 0, False: 0]
  ------------------
 2569|      0|                            {
 2570|      0|                              s2 = sexp_nth_data (l1, i, &n);
  ------------------
  |  |  387|      0|#define sexp_nth_data(a, b, c)       _gcry_sexp_nth_data ((a), (b), (c))
  ------------------
 2571|      0|                              if (!s2)
  ------------------
  |  Branch (2571:35): [True: 0, False: 0]
  ------------------
 2572|      0|                                memcpy (p, "()", (n=2));
 2573|      0|                              else
 2574|      0|                                memcpy (p, s2, n);
 2575|      0|                              p[n] = ' ';
 2576|      0|                              p += n + 1;
 2577|      0|                            }
 2578|      0|                          if (p != *array[idx])
  ------------------
  |  Branch (2578:31): [True: 0, False: 0]
  ------------------
 2579|      0|                            p[-1] = 0;
 2580|      0|                        }
 2581|      0|                    }
 2582|      0|                  else
 2583|      0|                    *array[idx] = _gcry_sexp_nth_string (l1, 1);
 2584|      0|                  if (!*array[idx])
  ------------------
  |  Branch (2584:23): [True: 0, False: 0]
  ------------------
 2585|      0|                    {
 2586|      0|                      rc = gpg_err_code_from_syserror ();
 2587|      0|                      goto cleanup;
 2588|      0|                    }
 2589|      0|                  arrayisdesc[idx] = 's';
 2590|      0|                }
 2591|     85|              else if (mode == 'd')
  ------------------
  |  Branch (2591:24): [True: 0, False: 85]
  ------------------
 2592|      0|                {
 2593|      0|                  long along;
 2594|       |
 2595|      0|                  xfree (tmpstr);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 2596|      0|                  tmpstr = _gcry_sexp_nth_string (l1, 1);
 2597|      0|                  if (!tmpstr)
  ------------------
  |  Branch (2597:23): [True: 0, False: 0]
  ------------------
 2598|      0|                    {
 2599|      0|                      rc = gpg_err_code_from_syserror ();
 2600|      0|                      goto cleanup;
 2601|      0|                    }
 2602|      0|                  along = strtol (tmpstr, NULL, 10);
 2603|      0|                  if (submode == 'l')
  ------------------
  |  Branch (2603:23): [True: 0, False: 0]
  ------------------
 2604|      0|                    *(long *)array[idx] = along;
 2605|      0|                  else
 2606|      0|                    *(int *)array[idx] = along;
 2607|      0|                  arrayisdesc[idx] = 'x';
 2608|      0|                }
 2609|     85|              else if (mode == 'u')
  ------------------
  |  Branch (2609:24): [True: 0, False: 85]
  ------------------
 2610|      0|                {
 2611|      0|                  long aulong;
 2612|       |
 2613|      0|                  xfree (tmpstr);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 2614|      0|                  tmpstr = _gcry_sexp_nth_string (l1, 1);
 2615|      0|                  if (!tmpstr)
  ------------------
  |  Branch (2615:23): [True: 0, False: 0]
  ------------------
 2616|      0|                    {
 2617|      0|                      rc = gpg_err_code_from_syserror ();
 2618|      0|                      goto cleanup;
 2619|      0|                    }
 2620|      0|                  aulong = strtoul (tmpstr, NULL, 10);
 2621|      0|                  if (submode == 'l')
  ------------------
  |  Branch (2621:23): [True: 0, False: 0]
  ------------------
 2622|      0|                    *(unsigned long *)array[idx] = aulong;
 2623|      0|                  else if (submode == 'z')
  ------------------
  |  Branch (2623:28): [True: 0, False: 0]
  ------------------
 2624|      0|                    *(size_t *)array[idx] = aulong;
 2625|      0|                  else
 2626|      0|                    *(unsigned int *)array[idx] = aulong;
 2627|      0|                  arrayisdesc[idx] = 'x';
 2628|      0|                }
 2629|     85|              else
 2630|     85|                {
 2631|     85|                  if (mode == '/')
  ------------------
  |  Branch (2631:23): [True: 8, False: 77]
  ------------------
 2632|      8|                    *array[idx] = _gcry_sexp_nth_mpi (l1,1,GCRYMPI_FMT_OPAQUE);
 2633|     77|                  else if (mode == '-')
  ------------------
  |  Branch (2633:28): [True: 0, False: 77]
  ------------------
 2634|      0|                    *array[idx] = _gcry_sexp_nth_mpi (l1,1,GCRYMPI_FMT_STD);
 2635|     77|                  else
 2636|     77|                    *array[idx] = _gcry_sexp_nth_mpi (l1,1,GCRYMPI_FMT_USG);
 2637|     85|                  if (!*array[idx])
  ------------------
  |  Branch (2637:23): [True: 0, False: 85]
  ------------------
 2638|      0|                    {
 2639|      0|                      rc = GPG_ERR_INV_OBJ;  /* Conversion failed.  */
 2640|      0|                      goto cleanup;
 2641|      0|                    }
 2642|     85|                }
 2643|     85|              sexp_release (l1); l1 = NULL;
  ------------------
  |  |  372|     85|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 2644|     85|            }
 2645|     85|          idx++;
 2646|     85|        }
 2647|     93|    }
 2648|       |
 2649|     54|  xfree (tmpstr);
  ------------------
  |  |  150|     54|#define xfree(a)         _gcry_free ((a))
  ------------------
 2650|     54|  sexp_release (freethis);
  ------------------
  |  |  372|     54|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 2651|     54|  return 0;
 2652|       |
 2653|      0| cleanup:
 2654|      0|  xfree (tmpstr);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 2655|      0|  sexp_release (freethis);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 2656|      0|  sexp_release (l1);
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
 2657|      0|  while (idx--)
  ------------------
  |  Branch (2657:10): [True: 0, False: 0]
  ------------------
 2658|      0|    {
 2659|      0|      if (!arrayisdesc[idx])
  ------------------
  |  Branch (2659:11): [True: 0, False: 0]
  ------------------
 2660|      0|        {
 2661|      0|          _gcry_mpi_release (*array[idx]);
 2662|      0|          *array[idx] = NULL;
 2663|      0|        }
 2664|      0|      else if (arrayisdesc[idx] == 1)
  ------------------
  |  Branch (2664:16): [True: 0, False: 0]
  ------------------
 2665|      0|        {
 2666|       |          /* Caller provided buffer.  */
 2667|      0|          gcry_buffer_t *spec = (gcry_buffer_t*)array[idx];
 2668|      0|          spec->len = 0;
 2669|      0|        }
 2670|      0|      else if (arrayisdesc[idx] == 2)
  ------------------
  |  Branch (2670:16): [True: 0, False: 0]
  ------------------
 2671|      0|        {
 2672|       |          /* We might have allocated a buffer.  */
 2673|      0|          gcry_buffer_t *spec = (gcry_buffer_t*)array[idx];
 2674|      0|          xfree (spec->data);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 2675|      0|          spec->data = NULL;
 2676|      0|          spec->size = spec->off = spec->len = 0;
 2677|      0|        }
 2678|      0|      else if (arrayisdesc[idx] == 's')
  ------------------
  |  Branch (2678:16): [True: 0, False: 0]
  ------------------
 2679|      0|        {
 2680|       |          /* We might have allocated a buffer.  */
 2681|      0|          xfree (*array[idx]);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 2682|      0|          *array[idx] = NULL;
 2683|      0|        }
 2684|      0|     }
 2685|      0|  return rc;
 2686|     54|}
_gcry_sexp_extract_param:
 2691|     54|{
 2692|     54|  gcry_err_code_t rc;
 2693|     54|  va_list arg_ptr;
 2694|       |
 2695|     54|  va_start (arg_ptr, list);
 2696|     54|  rc = _gcry_sexp_vextract_param (sexp, path, list, arg_ptr);
 2697|     54|  va_end (arg_ptr);
 2698|     54|  return rc;
 2699|     54|}
sexp.c:normalize:
  225|    466|{
  226|    466|  unsigned char *p;
  227|       |
  228|    466|  if ( !list )
  ------------------
  |  Branch (228:8): [True: 0, False: 466]
  ------------------
  229|      0|    return NULL;
  230|    466|  p = list->d;
  231|    466|  if ( *p == ST_STOP )
  ------------------
  |  |   91|    466|#define ST_STOP  0
  ------------------
  |  Branch (231:8): [True: 0, False: 466]
  ------------------
  232|      0|    {
  233|       |      /* this is "" */
  234|      0|      sexp_release ( list );
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  235|      0|      return NULL;
  236|      0|    }
  237|    466|  if ( *p == ST_OPEN && p[1] == ST_CLOSE )
  ------------------
  |  |   94|    932|#define ST_OPEN  3
  ------------------
                if ( *p == ST_OPEN && p[1] == ST_CLOSE )
  ------------------
  |  |   95|    435|#define ST_CLOSE 4
  ------------------
  |  Branch (237:8): [True: 435, False: 31]
  |  Branch (237:25): [True: 0, False: 435]
  ------------------
  238|      0|    {
  239|       |      /* this is "()" */
  240|      0|      sexp_release ( list );
  ------------------
  |  |  372|      0|#define sexp_release(a)              _gcry_sexp_release ((a))
  ------------------
  241|      0|      return NULL;
  242|      0|    }
  243|       |
  244|    466|  return list;
  245|    466|}
sexp.c:do_sexp_nth_data:
  704|    269|{
  705|    269|  const byte *p;
  706|    269|  DATALEN n;
  707|    269|  int level = 0;
  708|       |
  709|    269|  *datalen = 0;
  710|    269|  if ( !list )
  ------------------
  |  Branch (710:8): [True: 0, False: 269]
  ------------------
  711|      0|    return NULL;
  712|       |
  713|    269|  p = list->d;
  714|    269|  if ( *p == ST_OPEN )
  ------------------
  |  |   94|    269|#define ST_OPEN  3
  ------------------
  |  Branch (714:8): [True: 238, False: 31]
  ------------------
  715|    238|    p++;	     /* Yep, a list. */
  716|     31|  else if (number)
  ------------------
  |  Branch (716:12): [True: 0, False: 31]
  ------------------
  717|      0|    return NULL;     /* Not a list but N > 0 requested. */
  718|       |
  719|       |  /* Skip over N elements. */
  720|    431|  while (number > 0)
  ------------------
  |  Branch (720:10): [True: 162, False: 269]
  ------------------
  721|    162|    {
  722|    162|      if (*p == ST_DATA)
  ------------------
  |  |   92|    162|#define ST_DATA  1  /* datalen follows */
  ------------------
  |  Branch (722:11): [True: 162, False: 0]
  ------------------
  723|    162|        {
  724|    162|          memcpy ( &n, ++p, sizeof n );
  725|    162|          p += sizeof n + n;
  726|    162|          p--;
  727|    162|          if ( !level )
  ------------------
  |  Branch (727:16): [True: 162, False: 0]
  ------------------
  728|    162|            number--;
  729|    162|	}
  730|      0|      else if (*p == ST_OPEN)
  ------------------
  |  |   94|      0|#define ST_OPEN  3
  ------------------
  |  Branch (730:16): [True: 0, False: 0]
  ------------------
  731|      0|        {
  732|      0|          level++;
  733|      0|	}
  734|      0|      else if (*p == ST_CLOSE)
  ------------------
  |  |   95|      0|#define ST_CLOSE 4
  ------------------
  |  Branch (734:16): [True: 0, False: 0]
  ------------------
  735|      0|        {
  736|      0|          level--;
  737|      0|          if ( !level )
  ------------------
  |  Branch (737:16): [True: 0, False: 0]
  ------------------
  738|      0|            number--;
  739|      0|	}
  740|      0|      else if (*p == ST_STOP)
  ------------------
  |  |   91|      0|#define ST_STOP  0
  ------------------
  |  Branch (740:16): [True: 0, False: 0]
  ------------------
  741|      0|        {
  742|      0|          return NULL;
  743|      0|	}
  744|    162|      p++;
  745|    162|    }
  746|       |
  747|       |  /* If this is data, return it.  */
  748|    269|  if (*p == ST_DATA)
  ------------------
  |  |   92|    269|#define ST_DATA  1  /* datalen follows */
  ------------------
  |  Branch (748:7): [True: 269, False: 0]
  ------------------
  749|    269|    {
  750|    269|      memcpy ( &n, ++p, sizeof n );
  751|    269|      *datalen = n;
  752|    269|      return (const char*)p + sizeof n;
  753|    269|    }
  754|       |
  755|      0|  return NULL;
  756|    269|}
sexp.c:do_vsexp_sscan:
 1099|    107|{
 1100|    107|  gcry_err_code_t err = 0;
 1101|    107|  static const char tokenchars[] =
 1102|    107|    "abcdefghijklmnopqrstuvwxyz"
 1103|    107|    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 1104|    107|    "0123456789-./_:*+=";
 1105|    107|  const char *p;
 1106|    107|  size_t n;
 1107|    107|  const char *digptr = NULL;
 1108|    107|  const char *quoted = NULL;
 1109|    107|  const char *tokenp = NULL;
 1110|    107|  const char *hexfmt = NULL;
 1111|    107|  const char *base64 = NULL;
 1112|    107|  const char *disphint = NULL;
 1113|    107|  const char *percent = NULL;
 1114|    107|  int hexcount = 0;
 1115|    107|  int b64count = 0;
 1116|    107|  int quoted_esc = 0;
 1117|    107|  size_t datalen = 0;
 1118|    107|  size_t dummy_erroff;
 1119|    107|  struct make_space_ctx c;
 1120|    107|  int arg_counter = 0;
 1121|    107|  int level = 0;
 1122|       |
 1123|    107|  if (!retsexp)
  ------------------
  |  Branch (1123:7): [True: 0, False: 107]
  ------------------
 1124|      0|    return GPG_ERR_INV_ARG;
 1125|    107|  *retsexp = NULL;
 1126|       |
 1127|    107|  if (!buffer)
  ------------------
  |  Branch (1127:7): [True: 0, False: 107]
  ------------------
 1128|      0|    return GPG_ERR_INV_ARG;
 1129|       |
 1130|    107|  if (!erroff)
  ------------------
  |  Branch (1130:7): [True: 107, False: 0]
  ------------------
 1131|    107|    erroff = &dummy_erroff;
 1132|       |
 1133|       |  /* Depending on whether ARG_LIST is non-zero or not, this macro gives
 1134|       |     us the next argument, either from the variable argument list as
 1135|       |     specified by ARG_PTR or from the argument array ARG_LIST.  */
 1136|    107|#define ARG_NEXT(storage, type)                          \
 1137|    107|  do                                                     \
 1138|    107|    {                                                    \
 1139|    107|      if (!arg_list)                                     \
 1140|    107|	storage = va_arg (arg_ptr, type);                \
 1141|    107|      else                                               \
 1142|    107|	storage = *((type *) (arg_list[arg_counter++])); \
 1143|    107|    }                                                    \
 1144|    107|  while (0)
 1145|       |
 1146|       |  /* The MAKE_SPACE macro is used before each store operation to
 1147|       |     ensure that the buffer is large enough.  It requires a global
 1148|       |     context named C and jumps out to the label LEAVE on error! It
 1149|       |     also sets ERROFF using the variables BUFFER and P.  */
 1150|    107|#define MAKE_SPACE(n)  do {                                                \
 1151|    107|                            gpg_err_code_t _ms_err = make_space (&c, (n)); \
 1152|    107|                            if (_ms_err)                                   \
 1153|    107|                              {                                            \
 1154|    107|                                err = _ms_err;                             \
 1155|    107|                                *erroff = p - buffer;                      \
 1156|    107|                                goto leave;                                \
 1157|    107|                              }                                            \
 1158|    107|                       } while (0)
 1159|       |
 1160|       |  /* The STORE_LEN macro is used to store the length N at buffer P. */
 1161|    107|#define STORE_LEN(p,n) do {						   \
 1162|    107|			    DATALEN ashort = (n);			   \
 1163|    107|			    memcpy ( (p), &ashort, sizeof(ashort) );	   \
 1164|    107|			    (p) += sizeof (ashort);			   \
 1165|    107|			} while (0)
 1166|       |
 1167|       |  /* We assume that the internal representation takes less memory than
 1168|       |     the provided one.  However, we add space for one extra datalen so
 1169|       |     that the code which does the ST_CLOSE can use MAKE_SPACE */
 1170|    107|  c.allocated = length + sizeof(DATALEN);
 1171|    107|  if (length && _gcry_is_secure (buffer))
  ------------------
  |  Branch (1171:7): [True: 107, False: 0]
  |  Branch (1171:17): [True: 0, False: 107]
  ------------------
 1172|      0|    c.sexp = xtrymalloc_secure (sizeof *c.sexp + c.allocated - 1);
  ------------------
  |  |  140|      0|#define xtrymalloc_secure(a)   _gcry_malloc_secure ((a))
  ------------------
 1173|    107|  else
 1174|    107|    c.sexp = xtrymalloc (sizeof *c.sexp + c.allocated - 1);
  ------------------
  |  |  138|    107|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
 1175|    107|  if (!c.sexp)
  ------------------
  |  Branch (1175:7): [True: 0, False: 107]
  ------------------
 1176|      0|    {
 1177|      0|      err = gpg_err_code_from_errno (errno);
 1178|      0|      *erroff = 0;
 1179|      0|      goto leave;
 1180|      0|    }
 1181|    107|  c.pos = c.sexp->d;
 1182|       |
 1183|  2.22k|  for (p = buffer, n = length; n; p++, n--)
  ------------------
  |  Branch (1183:32): [True: 2.12k, False: 107]
  ------------------
 1184|  2.12k|    {
 1185|  2.12k|      if (tokenp && !hexfmt)
  ------------------
  |  Branch (1185:11): [True: 1.19k, False: 930]
  |  Branch (1185:21): [True: 1.19k, False: 0]
  ------------------
 1186|  1.19k|	{
 1187|  1.19k|	  if (strchr (tokenchars, *p))
  ------------------
  |  Branch (1187:8): [True: 903, False: 289]
  ------------------
 1188|    903|	    continue;
 1189|    289|	  else
 1190|    289|	    {
 1191|    289|	      datalen = p - tokenp;
 1192|    289|	      MAKE_SPACE (datalen);
  ------------------
  |  | 1150|    289|#define MAKE_SPACE(n)  do {                                                \
  |  | 1151|    289|                            gpg_err_code_t _ms_err = make_space (&c, (n)); \
  |  | 1152|    289|                            if (_ms_err)                                   \
  |  |  ------------------
  |  |  |  Branch (1152:33): [True: 0, False: 289]
  |  |  ------------------
  |  | 1153|    289|                              {                                            \
  |  | 1154|      0|                                err = _ms_err;                             \
  |  | 1155|      0|                                *erroff = p - buffer;                      \
  |  | 1156|      0|                                goto leave;                                \
  |  | 1157|      0|                              }                                            \
  |  | 1158|    289|                       } while (0)
  |  |  ------------------
  |  |  |  Branch (1158:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1193|    289|	      *c.pos++ = ST_DATA;
  ------------------
  |  |   92|    289|#define ST_DATA  1  /* datalen follows */
  ------------------
 1194|    289|	      STORE_LEN (c.pos, datalen);
  ------------------
  |  | 1161|    289|#define STORE_LEN(p,n) do {						   \
  |  | 1162|    289|			    DATALEN ashort = (n);			   \
  |  | 1163|    289|			    memcpy ( (p), &ashort, sizeof(ashort) );	   \
  |  | 1164|    289|			    (p) += sizeof (ashort);			   \
  |  | 1165|    289|			} while (0)
  |  |  ------------------
  |  |  |  Branch (1165:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1195|    289|	      memcpy (c.pos, tokenp, datalen);
 1196|    289|	      c.pos += datalen;
 1197|    289|	      tokenp = NULL;
 1198|    289|	    }
 1199|  1.19k|	}
 1200|       |
 1201|  1.21k|      if (quoted)
  ------------------
  |  Branch (1201:11): [True: 0, False: 1.21k]
  ------------------
 1202|      0|	{
 1203|      0|	  if (quoted_esc)
  ------------------
  |  Branch (1203:8): [True: 0, False: 0]
  ------------------
 1204|      0|	    {
 1205|      0|	      switch (*p)
 1206|      0|		{
 1207|      0|		case 'b': case 't': case 'v': case 'n': case 'f':
  ------------------
  |  Branch (1207:3): [True: 0, False: 0]
  |  Branch (1207:13): [True: 0, False: 0]
  |  Branch (1207:23): [True: 0, False: 0]
  |  Branch (1207:33): [True: 0, False: 0]
  |  Branch (1207:43): [True: 0, False: 0]
  ------------------
 1208|      0|		case 'r': case '"': case '\'': case '\\':
  ------------------
  |  Branch (1208:3): [True: 0, False: 0]
  |  Branch (1208:13): [True: 0, False: 0]
  |  Branch (1208:23): [True: 0, False: 0]
  |  Branch (1208:34): [True: 0, False: 0]
  ------------------
 1209|      0|		  quoted_esc = 0;
 1210|      0|		  break;
 1211|       |
 1212|      0|		case '0': case '1': case '2': case '3': case '4':
  ------------------
  |  Branch (1212:3): [True: 0, False: 0]
  |  Branch (1212:13): [True: 0, False: 0]
  |  Branch (1212:23): [True: 0, False: 0]
  |  Branch (1212:33): [True: 0, False: 0]
  |  Branch (1212:43): [True: 0, False: 0]
  ------------------
 1213|      0|		case '5': case '6': case '7':
  ------------------
  |  Branch (1213:3): [True: 0, False: 0]
  |  Branch (1213:13): [True: 0, False: 0]
  |  Branch (1213:23): [True: 0, False: 0]
  ------------------
 1214|      0|		  if (!((n > 2)
  ------------------
  |  Branch (1214:11): [True: 0, False: 0]
  ------------------
 1215|      0|                        && (p[1] >= '0') && (p[1] <= '7')
  ------------------
  |  Branch (1215:28): [True: 0, False: 0]
  |  Branch (1215:45): [True: 0, False: 0]
  ------------------
 1216|      0|                        && (p[2] >= '0') && (p[2] <= '7')))
  ------------------
  |  Branch (1216:28): [True: 0, False: 0]
  |  Branch (1216:45): [True: 0, False: 0]
  ------------------
 1217|      0|		    {
 1218|      0|		      *erroff = p - buffer;
 1219|       |		      /* Invalid octal value.  */
 1220|      0|		      err = GPG_ERR_SEXP_BAD_QUOTATION;
 1221|      0|                      goto leave;
 1222|      0|		    }
 1223|      0|		  p += 2;
 1224|      0|		  n -= 2;
 1225|      0|		  quoted_esc = 0;
 1226|      0|		  break;
 1227|       |
 1228|      0|		case 'x':
  ------------------
  |  Branch (1228:3): [True: 0, False: 0]
  ------------------
 1229|      0|		  if (!((n > 2) && hexdigitp (p+1) && hexdigitp (p+2)))
  ------------------
  |  |  409|      0|#define hexdigitp(a) (digitp (a)                     \
  |  |  ------------------
  |  |  |  |  405|      0|#define digitp(p)   (*(p) >= '0' && *(p) <= '9')
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (405:22): [True: 0, False: 0]
  |  |  |  |  |  Branch (405:37): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  410|      0|                      || (*(a) >= 'A' && *(a) <= 'F')  \
  |  |  ------------------
  |  |  |  Branch (410:27): [True: 0, False: 0]
  |  |  |  Branch (410:42): [True: 0, False: 0]
  |  |  ------------------
  |  |  411|      0|                      || (*(a) >= 'a' && *(a) <= 'f'))
  |  |  ------------------
  |  |  |  Branch (411:27): [True: 0, False: 0]
  |  |  |  Branch (411:42): [True: 0, False: 0]
  |  |  ------------------
  ------------------
              		  if (!((n > 2) && hexdigitp (p+1) && hexdigitp (p+2)))
  ------------------
  |  |  409|      0|#define hexdigitp(a) (digitp (a)                     \
  |  |  ------------------
  |  |  |  |  405|      0|#define digitp(p)   (*(p) >= '0' && *(p) <= '9')
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (405:22): [True: 0, False: 0]
  |  |  |  |  |  Branch (405:37): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  410|      0|                      || (*(a) >= 'A' && *(a) <= 'F')  \
  |  |  ------------------
  |  |  |  Branch (410:27): [True: 0, False: 0]
  |  |  |  Branch (410:42): [True: 0, False: 0]
  |  |  ------------------
  |  |  411|      0|                      || (*(a) >= 'a' && *(a) <= 'f'))
  |  |  ------------------
  |  |  |  Branch (411:27): [True: 0, False: 0]
  |  |  |  Branch (411:42): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1229:11): [True: 0, False: 0]
  ------------------
 1230|      0|		    {
 1231|      0|		      *erroff = p - buffer;
 1232|       |		      /* Invalid hex value.  */
 1233|      0|		      err = GPG_ERR_SEXP_BAD_QUOTATION;
 1234|      0|                      goto leave;
 1235|      0|		    }
 1236|      0|		  p += 2;
 1237|      0|		  n -= 2;
 1238|      0|		  quoted_esc = 0;
 1239|      0|		  break;
 1240|       |
 1241|      0|		case '\r':
  ------------------
  |  Branch (1241:3): [True: 0, False: 0]
  ------------------
 1242|       |		  /* ignore CR[,LF] */
 1243|      0|		  if (n && (p[1] == '\n'))
  ------------------
  |  Branch (1243:9): [True: 0, False: 0]
  |  Branch (1243:14): [True: 0, False: 0]
  ------------------
 1244|      0|		    {
 1245|      0|		      p++;
 1246|      0|		      n--;
 1247|      0|		    }
 1248|      0|		  quoted_esc = 0;
 1249|      0|		  break;
 1250|       |
 1251|      0|		case '\n':
  ------------------
  |  Branch (1251:3): [True: 0, False: 0]
  ------------------
 1252|       |		  /* ignore LF[,CR] */
 1253|      0|		  if (n && (p[1] == '\r'))
  ------------------
  |  Branch (1253:9): [True: 0, False: 0]
  |  Branch (1253:14): [True: 0, False: 0]
  ------------------
 1254|      0|		    {
 1255|      0|		      p++;
 1256|      0|		      n--;
 1257|      0|		    }
 1258|      0|		  quoted_esc = 0;
 1259|      0|		  break;
 1260|       |
 1261|      0|		default:
  ------------------
  |  Branch (1261:3): [True: 0, False: 0]
  ------------------
 1262|      0|		  *erroff = p - buffer;
 1263|       |		  /* Invalid quoted string escape.  */
 1264|      0|		  err = GPG_ERR_SEXP_BAD_QUOTATION;
 1265|      0|                  goto leave;
 1266|      0|		}
 1267|      0|	    }
 1268|      0|	  else if (*p == '\\')
  ------------------
  |  Branch (1268:13): [True: 0, False: 0]
  ------------------
 1269|      0|	    quoted_esc = 1;
 1270|      0|	  else if (*p == '\"')
  ------------------
  |  Branch (1270:13): [True: 0, False: 0]
  ------------------
 1271|      0|	    {
 1272|       |	      /* Keep it easy - we know that the unquoted string will
 1273|       |		 never be larger. */
 1274|      0|	      unsigned char *save;
 1275|      0|	      size_t len;
 1276|       |
 1277|      0|	      quoted++; /* Skip leading quote.  */
 1278|      0|	      MAKE_SPACE (p - quoted);
  ------------------
  |  | 1150|      0|#define MAKE_SPACE(n)  do {                                                \
  |  | 1151|      0|                            gpg_err_code_t _ms_err = make_space (&c, (n)); \
  |  | 1152|      0|                            if (_ms_err)                                   \
  |  |  ------------------
  |  |  |  Branch (1152:33): [True: 0, False: 0]
  |  |  ------------------
  |  | 1153|      0|                              {                                            \
  |  | 1154|      0|                                err = _ms_err;                             \
  |  | 1155|      0|                                *erroff = p - buffer;                      \
  |  | 1156|      0|                                goto leave;                                \
  |  | 1157|      0|                              }                                            \
  |  | 1158|      0|                       } while (0)
  |  |  ------------------
  |  |  |  Branch (1158:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1279|      0|	      *c.pos++ = ST_DATA;
  ------------------
  |  |   92|      0|#define ST_DATA  1  /* datalen follows */
  ------------------
 1280|      0|	      save = c.pos;
 1281|      0|	      STORE_LEN (c.pos, 0); /* Will be fixed up later.  */
  ------------------
  |  | 1161|      0|#define STORE_LEN(p,n) do {						   \
  |  | 1162|      0|			    DATALEN ashort = (n);			   \
  |  | 1163|      0|			    memcpy ( (p), &ashort, sizeof(ashort) );	   \
  |  | 1164|      0|			    (p) += sizeof (ashort);			   \
  |  | 1165|      0|			} while (0)
  |  |  ------------------
  |  |  |  Branch (1165:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1282|      0|	      len = unquote_string (quoted, p - quoted, c.pos);
 1283|      0|	      c.pos += len;
 1284|      0|	      STORE_LEN (save, len);
  ------------------
  |  | 1161|      0|#define STORE_LEN(p,n) do {						   \
  |  | 1162|      0|			    DATALEN ashort = (n);			   \
  |  | 1163|      0|			    memcpy ( (p), &ashort, sizeof(ashort) );	   \
  |  | 1164|      0|			    (p) += sizeof (ashort);			   \
  |  | 1165|      0|			} while (0)
  |  |  ------------------
  |  |  |  Branch (1165:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1285|      0|	      quoted = NULL;
 1286|      0|	    }
 1287|      0|	}
 1288|  1.21k|      else if (hexfmt)
  ------------------
  |  Branch (1288:16): [True: 0, False: 1.21k]
  ------------------
 1289|      0|	{
 1290|      0|	  if (isxdigit (*p))
 1291|      0|	    hexcount++;
 1292|      0|	  else if (*p == '#')
  ------------------
  |  Branch (1292:13): [True: 0, False: 0]
  ------------------
 1293|      0|	    {
 1294|      0|	      if ((hexcount & 1))
  ------------------
  |  Branch (1294:12): [True: 0, False: 0]
  ------------------
 1295|      0|		{
 1296|      0|		  *erroff = p - buffer;
 1297|      0|		  err = GPG_ERR_SEXP_ODD_HEX_NUMBERS;
 1298|      0|                  goto leave;
 1299|      0|		}
 1300|       |
 1301|      0|	      datalen = hexcount / 2;
 1302|      0|	      MAKE_SPACE (datalen);
  ------------------
  |  | 1150|      0|#define MAKE_SPACE(n)  do {                                                \
  |  | 1151|      0|                            gpg_err_code_t _ms_err = make_space (&c, (n)); \
  |  | 1152|      0|                            if (_ms_err)                                   \
  |  |  ------------------
  |  |  |  Branch (1152:33): [True: 0, False: 0]
  |  |  ------------------
  |  | 1153|      0|                              {                                            \
  |  | 1154|      0|                                err = _ms_err;                             \
  |  | 1155|      0|                                *erroff = p - buffer;                      \
  |  | 1156|      0|                                goto leave;                                \
  |  | 1157|      0|                              }                                            \
  |  | 1158|      0|                       } while (0)
  |  |  ------------------
  |  |  |  Branch (1158:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1303|      0|	      *c.pos++ = ST_DATA;
  ------------------
  |  |   92|      0|#define ST_DATA  1  /* datalen follows */
  ------------------
 1304|      0|	      STORE_LEN (c.pos, datalen);
  ------------------
  |  | 1161|      0|#define STORE_LEN(p,n) do {						   \
  |  | 1162|      0|			    DATALEN ashort = (n);			   \
  |  | 1163|      0|			    memcpy ( (p), &ashort, sizeof(ashort) );	   \
  |  | 1164|      0|			    (p) += sizeof (ashort);			   \
  |  | 1165|      0|			} while (0)
  |  |  ------------------
  |  |  |  Branch (1165:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1305|      0|	      for (hexfmt++; hexfmt < p; hexfmt++)
  ------------------
  |  Branch (1305:23): [True: 0, False: 0]
  ------------------
 1306|      0|		{
 1307|      0|                  int tmpc;
 1308|       |
 1309|      0|		  if (whitespacep (hexfmt))
  ------------------
  |  Branch (1309:9): [True: 0, False: 0]
  ------------------
 1310|      0|		    continue;
 1311|      0|		  tmpc = hextonibble (*(const unsigned char*)hexfmt);
 1312|      0|                  for (hexfmt++; hexfmt < p && whitespacep (hexfmt); hexfmt++)
  ------------------
  |  Branch (1312:34): [True: 0, False: 0]
  |  Branch (1312:48): [True: 0, False: 0]
  ------------------
 1313|      0|		    ;
 1314|      0|                  if (hexfmt < p)
  ------------------
  |  Branch (1314:23): [True: 0, False: 0]
  ------------------
 1315|      0|                    {
 1316|      0|                      tmpc *= 16;
 1317|      0|                      tmpc += hextonibble (*(const unsigned char*)hexfmt);
 1318|      0|                    }
 1319|      0|                  *c.pos++ = tmpc;
 1320|      0|		}
 1321|      0|	      hexfmt = NULL;
 1322|      0|	    }
 1323|      0|	  else if (!whitespacep (p))
  ------------------
  |  Branch (1323:13): [True: 0, False: 0]
  ------------------
 1324|      0|	    {
 1325|      0|	      *erroff = p - buffer;
 1326|      0|	      err = GPG_ERR_SEXP_BAD_HEX_CHAR;
 1327|      0|              goto leave;
 1328|      0|	    }
 1329|      0|	}
 1330|  1.21k|      else if (base64)
  ------------------
  |  Branch (1330:16): [True: 0, False: 1.21k]
  ------------------
 1331|      0|        {
 1332|      0|          if (digitp (p) || alphap (p) || *p == '+' || *p == '/' || *p == '=')
  ------------------
  |  |  405|      0|#define digitp(p)   (*(p) >= '0' && *(p) <= '9')
  |  |  ------------------
  |  |  |  Branch (405:22): [True: 0, False: 0]
  |  |  |  Branch (405:37): [True: 0, False: 0]
  |  |  ------------------
  ------------------
                        if (digitp (p) || alphap (p) || *p == '+' || *p == '/' || *p == '=')
  ------------------
  |  |  407|      0|#define alphap(a)    (   (*(a) >= 'A' && *(a) <= 'Z')  \
  |  |  ------------------
  |  |  |  Branch (407:27): [True: 0, False: 0]
  |  |  |  Branch (407:42): [True: 0, False: 0]
  |  |  ------------------
  |  |  408|      0|                      || (*(a) >= 'a' && *(a) <= 'z'))
  |  |  ------------------
  |  |  |  Branch (408:27): [True: 0, False: 0]
  |  |  |  Branch (408:42): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1332:43): [True: 0, False: 0]
  |  Branch (1332:56): [True: 0, False: 0]
  |  Branch (1332:69): [True: 0, False: 0]
  ------------------
 1333|      0|            b64count++;
 1334|      0|          else if (*p == '|')
  ------------------
  |  Branch (1334:20): [True: 0, False: 0]
  ------------------
 1335|      0|            {
 1336|      0|              gpgrt_b64state_t b64state;
 1337|      0|              char *b64buf;
 1338|      0|              int i;
 1339|       |
 1340|      0|              base64++;         /* Skip beginning '|' */
 1341|      0|              b64buf = xtrymalloc (b64count);
  ------------------
  |  |  138|      0|#define xtrymalloc(a)    _gcry_malloc ((a))
  ------------------
 1342|      0|              if (!b64buf)
  ------------------
  |  Branch (1342:19): [True: 0, False: 0]
  ------------------
 1343|      0|                {
 1344|      0|                  err = gpg_err_code_from_syserror ();
 1345|      0|                  goto leave;
 1346|      0|                }
 1347|      0|              memcpy (b64buf, base64, b64count);
 1348|       |
 1349|      0|              b64state = gpgrt_b64dec_start (NULL);
 1350|      0|              if (!b64state)
  ------------------
  |  Branch (1350:19): [True: 0, False: 0]
  ------------------
 1351|      0|                {
 1352|      0|                  err = gpg_err_code_from_syserror ();
 1353|      0|                  xfree (b64buf);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1354|      0|                  goto leave;
 1355|      0|                }
 1356|      0|              err = gpgrt_b64dec_proc (b64state, b64buf, b64count,
 1357|      0|                                       &datalen);
 1358|      0|              if (err && gpg_err_code (err) != GPG_ERR_EOF)
  ------------------
  |  Branch (1358:19): [True: 0, False: 0]
  |  Branch (1358:26): [True: 0, False: 0]
  ------------------
 1359|      0|                {
 1360|      0|                  xfree (b64state);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1361|      0|                  xfree (b64buf);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1362|      0|                  goto leave;
 1363|      0|                }
 1364|      0|              err = gpgrt_b64dec_finish (b64state);
 1365|      0|              if (err)
  ------------------
  |  Branch (1365:19): [True: 0, False: 0]
  ------------------
 1366|      0|                {
 1367|      0|                  xfree (b64buf);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1368|      0|                  goto leave;
 1369|      0|                }
 1370|       |
 1371|      0|              MAKE_SPACE (datalen);
  ------------------
  |  | 1150|      0|#define MAKE_SPACE(n)  do {                                                \
  |  | 1151|      0|                            gpg_err_code_t _ms_err = make_space (&c, (n)); \
  |  | 1152|      0|                            if (_ms_err)                                   \
  |  |  ------------------
  |  |  |  Branch (1152:33): [True: 0, False: 0]
  |  |  ------------------
  |  | 1153|      0|                              {                                            \
  |  | 1154|      0|                                err = _ms_err;                             \
  |  | 1155|      0|                                *erroff = p - buffer;                      \
  |  | 1156|      0|                                goto leave;                                \
  |  | 1157|      0|                              }                                            \
  |  | 1158|      0|                       } while (0)
  |  |  ------------------
  |  |  |  Branch (1158:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1372|      0|              *c.pos++ = ST_DATA;
  ------------------
  |  |   92|      0|#define ST_DATA  1  /* datalen follows */
  ------------------
 1373|      0|              STORE_LEN (c.pos, datalen);
  ------------------
  |  | 1161|      0|#define STORE_LEN(p,n) do {						   \
  |  | 1162|      0|			    DATALEN ashort = (n);			   \
  |  | 1163|      0|			    memcpy ( (p), &ashort, sizeof(ashort) );	   \
  |  | 1164|      0|			    (p) += sizeof (ashort);			   \
  |  | 1165|      0|			} while (0)
  |  |  ------------------
  |  |  |  Branch (1165:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1374|      0|              for (i = 0; i < datalen; i++)
  ------------------
  |  Branch (1374:27): [True: 0, False: 0]
  ------------------
 1375|      0|                *c.pos++ = b64buf[i];
 1376|       |
 1377|      0|              xfree (b64buf);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1378|      0|              base64 = NULL;
 1379|      0|            }
 1380|      0|          else
 1381|      0|            {
 1382|      0|              *erroff = p - buffer;
 1383|      0|              err = GPG_ERR_SEXP_BAD_CHARACTER;
 1384|      0|              goto leave;
 1385|      0|            }
 1386|      0|	}
 1387|  1.21k|      else if (digptr)
  ------------------
  |  Branch (1387:16): [True: 0, False: 1.21k]
  ------------------
 1388|      0|	{
 1389|      0|	  if (digitp (p))
  ------------------
  |  |  405|      0|#define digitp(p)   (*(p) >= '0' && *(p) <= '9')
  |  |  ------------------
  |  |  |  Branch (405:22): [True: 0, False: 0]
  |  |  |  Branch (405:37): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1390|      0|	    ;
 1391|      0|	  else if (*p == ':')
  ------------------
  |  Branch (1391:13): [True: 0, False: 0]
  ------------------
 1392|      0|	    {
 1393|      0|	      datalen = atoi (digptr); /* FIXME: check for overflow.  */
 1394|      0|	      digptr = NULL;
 1395|      0|	      if (datalen > n - 1)
  ------------------
  |  Branch (1395:12): [True: 0, False: 0]
  ------------------
 1396|      0|		{
 1397|      0|		  *erroff = p - buffer;
 1398|       |		  /* Buffer too short.  */
 1399|      0|		  err = GPG_ERR_SEXP_STRING_TOO_LONG;
 1400|      0|                  goto leave;
 1401|      0|		}
 1402|       |	      /* Make a new list entry.  */
 1403|      0|	      MAKE_SPACE (datalen);
  ------------------
  |  | 1150|      0|#define MAKE_SPACE(n)  do {                                                \
  |  | 1151|      0|                            gpg_err_code_t _ms_err = make_space (&c, (n)); \
  |  | 1152|      0|                            if (_ms_err)                                   \
  |  |  ------------------
  |  |  |  Branch (1152:33): [True: 0, False: 0]
  |  |  ------------------
  |  | 1153|      0|                              {                                            \
  |  | 1154|      0|                                err = _ms_err;                             \
  |  | 1155|      0|                                *erroff = p - buffer;                      \
  |  | 1156|      0|                                goto leave;                                \
  |  | 1157|      0|                              }                                            \
  |  | 1158|      0|                       } while (0)
  |  |  ------------------
  |  |  |  Branch (1158:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1404|      0|	      *c.pos++ = ST_DATA;
  ------------------
  |  |   92|      0|#define ST_DATA  1  /* datalen follows */
  ------------------
 1405|      0|	      STORE_LEN (c.pos, datalen);
  ------------------
  |  | 1161|      0|#define STORE_LEN(p,n) do {						   \
  |  | 1162|      0|			    DATALEN ashort = (n);			   \
  |  | 1163|      0|			    memcpy ( (p), &ashort, sizeof(ashort) );	   \
  |  | 1164|      0|			    (p) += sizeof (ashort);			   \
  |  | 1165|      0|			} while (0)
  |  |  ------------------
  |  |  |  Branch (1165:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1406|      0|	      memcpy (c.pos, p + 1, datalen);
 1407|      0|	      c.pos += datalen;
 1408|      0|	      n -= datalen;
 1409|      0|	      p += datalen;
 1410|      0|	    }
 1411|      0|	  else if (*p == '\"')
  ------------------
  |  Branch (1411:13): [True: 0, False: 0]
  ------------------
 1412|      0|	    {
 1413|      0|	      digptr = NULL; /* We ignore the optional length.  */
 1414|      0|	      quoted = p;
 1415|      0|	      quoted_esc = 0;
 1416|      0|	    }
 1417|      0|	  else if (*p == '#')
  ------------------
  |  Branch (1417:13): [True: 0, False: 0]
  ------------------
 1418|      0|	    {
 1419|      0|	      digptr = NULL; /* We ignore the optional length.  */
 1420|      0|	      hexfmt = p;
 1421|      0|	      hexcount = 0;
 1422|      0|	    }
 1423|      0|          else if (*p == '|')
  ------------------
  |  Branch (1423:20): [True: 0, False: 0]
  ------------------
 1424|      0|            {
 1425|      0|              digptr = NULL; /* We ignore the optional length.  */
 1426|      0|              base64 = p;
 1427|      0|              b64count = 0;
 1428|      0|            }
 1429|      0|	  else
 1430|      0|	    {
 1431|      0|	      *erroff = p - buffer;
 1432|      0|	      err = GPG_ERR_SEXP_INV_LEN_SPEC;
 1433|      0|              goto leave;
 1434|      0|	    }
 1435|      0|	}
 1436|  1.21k|      else if (percent)
  ------------------
  |  Branch (1436:16): [True: 168, False: 1.05k]
  ------------------
 1437|    168|	{
 1438|    168|	  if (*p == 'm' || *p == 'M')
  ------------------
  |  Branch (1438:8): [True: 124, False: 44]
  |  Branch (1438:21): [True: 0, False: 44]
  ------------------
 1439|    124|	    {
 1440|       |	      /* Insert an MPI.  */
 1441|    124|	      gcry_mpi_t m;
 1442|    124|	      size_t nm = 0;
 1443|    124|              int mpifmt = *p == 'm'? GCRYMPI_FMT_STD: GCRYMPI_FMT_USG;
  ------------------
  |  Branch (1443:28): [True: 124, False: 0]
  ------------------
 1444|       |
 1445|    124|	      ARG_NEXT (m, gcry_mpi_t);
  ------------------
  |  | 1137|    124|  do                                                     \
  |  | 1138|    124|    {                                                    \
  |  | 1139|    124|      if (!arg_list)                                     \
  |  |  ------------------
  |  |  |  Branch (1139:11): [True: 124, False: 0]
  |  |  ------------------
  |  | 1140|    124|	storage = va_arg (arg_ptr, type);                \
  |  | 1141|    124|      else                                               \
  |  | 1142|    124|	storage = *((type *) (arg_list[arg_counter++])); \
  |  | 1143|    124|    }                                                    \
  |  | 1144|    124|  while (0)
  |  |  ------------------
  |  |  |  Branch (1144:10): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1446|       |
 1447|    124|              if (mpi_get_flag (m, GCRYMPI_FLAG_OPAQUE))
  ------------------
  |  |  566|    124|#define mpi_get_flag(a,f)      _gcry_mpi_get_flag ((a), (f))
  |  |  ------------------
  |  |  |  Branch (566:32): [True: 48, False: 76]
  |  |  ------------------
  ------------------
 1448|     48|                {
 1449|     48|                  void *mp;
 1450|     48|                  unsigned int nbits;
 1451|       |
 1452|     48|                  mp = mpi_get_opaque (m, &nbits);
  ------------------
  |  |  562|     48|#define mpi_get_opaque(a,b)    _gcry_mpi_get_opaque ((a), (b))
  ------------------
 1453|     48|                  nm = (nbits+7)/8;
 1454|     48|                  if (mp && nm)
  ------------------
  |  Branch (1454:23): [True: 48, False: 0]
  |  Branch (1454:29): [True: 48, False: 0]
  ------------------
 1455|     48|                    {
 1456|     48|                      MAKE_SPACE (nm);
  ------------------
  |  | 1150|     48|#define MAKE_SPACE(n)  do {                                                \
  |  | 1151|     48|                            gpg_err_code_t _ms_err = make_space (&c, (n)); \
  |  | 1152|     48|                            if (_ms_err)                                   \
  |  |  ------------------
  |  |  |  Branch (1152:33): [True: 0, False: 48]
  |  |  ------------------
  |  | 1153|     48|                              {                                            \
  |  | 1154|      0|                                err = _ms_err;                             \
  |  | 1155|      0|                                *erroff = p - buffer;                      \
  |  | 1156|      0|                                goto leave;                                \
  |  | 1157|      0|                              }                                            \
  |  | 1158|     48|                       } while (0)
  |  |  ------------------
  |  |  |  Branch (1158:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1457|     48|                      if (!_gcry_is_secure (c.sexp->d)
  ------------------
  |  Branch (1457:27): [True: 48, False: 0]
  ------------------
 1458|     48|                          && mpi_get_flag (m, GCRYMPI_FLAG_SECURE))
  ------------------
  |  |  566|     48|#define mpi_get_flag(a,f)      _gcry_mpi_get_flag ((a), (f))
  |  |  ------------------
  |  |  |  Branch (566:32): [True: 0, False: 48]
  |  |  ------------------
  ------------------
 1459|      0|                        {
 1460|       |                          /* We have to switch to secure allocation.  */
 1461|      0|                          gcry_sexp_t newsexp;
 1462|      0|                          byte *newhead;
 1463|       |
 1464|      0|                          newsexp = xtrymalloc_secure (sizeof *newsexp
  ------------------
  |  |  140|      0|#define xtrymalloc_secure(a)   _gcry_malloc_secure ((a))
  ------------------
 1465|      0|                                                       + c.allocated - 1);
 1466|      0|                          if (!newsexp)
  ------------------
  |  Branch (1466:31): [True: 0, False: 0]
  ------------------
 1467|      0|                            {
 1468|      0|                              err = gpg_err_code_from_errno (errno);
 1469|      0|                              goto leave;
 1470|      0|                            }
 1471|      0|                          newhead = newsexp->d;
 1472|      0|                          memcpy (newhead, c.sexp->d, (c.pos - c.sexp->d));
 1473|      0|                          c.pos = newhead + (c.pos - c.sexp->d);
 1474|      0|                          xfree (c.sexp);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1475|      0|                          c.sexp = newsexp;
 1476|      0|                        }
 1477|       |
 1478|     48|                      *c.pos++ = ST_DATA;
  ------------------
  |  |   92|     48|#define ST_DATA  1  /* datalen follows */
  ------------------
 1479|     48|                      STORE_LEN (c.pos, nm);
  ------------------
  |  | 1161|     48|#define STORE_LEN(p,n) do {						   \
  |  | 1162|     48|			    DATALEN ashort = (n);			   \
  |  | 1163|     48|			    memcpy ( (p), &ashort, sizeof(ashort) );	   \
  |  | 1164|     48|			    (p) += sizeof (ashort);			   \
  |  | 1165|     48|			} while (0)
  |  |  ------------------
  |  |  |  Branch (1165:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1480|     48|                      memcpy (c.pos, mp, nm);
 1481|     48|                      c.pos += nm;
 1482|     48|                    }
 1483|     48|                }
 1484|     76|              else
 1485|     76|                {
 1486|     76|                  if (mpifmt == GCRYMPI_FMT_USG && mpi_cmp_ui (m, 0) < 0)
  ------------------
  |  |  512|      0|#define mpi_cmp_ui( u, v )     _gcry_mpi_cmp_ui( (u), (v) )
  ------------------
  |  Branch (1486:23): [True: 0, False: 76]
  |  Branch (1486:52): [True: 0, False: 0]
  ------------------
 1487|      0|                    {
 1488|      0|                      err = GPG_ERR_INV_ARG;
 1489|      0|                      goto leave;
 1490|      0|                    }
 1491|       |
 1492|     76|                  err = _gcry_mpi_print (mpifmt, NULL, 0, &nm, m);
 1493|     76|                  if (err)
  ------------------
  |  Branch (1493:23): [True: 0, False: 76]
  ------------------
 1494|      0|                    goto leave;
 1495|       |
 1496|     76|                  MAKE_SPACE (nm);
  ------------------
  |  | 1150|     76|#define MAKE_SPACE(n)  do {                                                \
  |  | 1151|     76|                            gpg_err_code_t _ms_err = make_space (&c, (n)); \
  |  | 1152|     76|                            if (_ms_err)                                   \
  |  |  ------------------
  |  |  |  Branch (1152:33): [True: 0, False: 76]
  |  |  ------------------
  |  | 1153|     76|                              {                                            \
  |  | 1154|      0|                                err = _ms_err;                             \
  |  | 1155|      0|                                *erroff = p - buffer;                      \
  |  | 1156|      0|                                goto leave;                                \
  |  | 1157|      0|                              }                                            \
  |  | 1158|     76|                       } while (0)
  |  |  ------------------
  |  |  |  Branch (1158:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1497|     76|                  if (!_gcry_is_secure (c.sexp->d)
  ------------------
  |  Branch (1497:23): [True: 76, False: 0]
  ------------------
 1498|     76|                      && mpi_get_flag ( m, GCRYMPI_FLAG_SECURE))
  ------------------
  |  |  566|     76|#define mpi_get_flag(a,f)      _gcry_mpi_get_flag ((a), (f))
  |  |  ------------------
  |  |  |  Branch (566:32): [True: 0, False: 76]
  |  |  ------------------
  ------------------
 1499|      0|                    {
 1500|       |                      /* We have to switch to secure allocation.  */
 1501|      0|                      gcry_sexp_t newsexp;
 1502|      0|                      byte *newhead;
 1503|       |
 1504|      0|                      newsexp = xtrymalloc_secure (sizeof *newsexp
  ------------------
  |  |  140|      0|#define xtrymalloc_secure(a)   _gcry_malloc_secure ((a))
  ------------------
 1505|      0|                                                   + c.allocated - 1);
 1506|      0|                      if (!newsexp)
  ------------------
  |  Branch (1506:27): [True: 0, False: 0]
  ------------------
 1507|      0|                        {
 1508|      0|                          err = gpg_err_code_from_errno (errno);
 1509|      0|                          goto leave;
 1510|      0|                        }
 1511|      0|                      newhead = newsexp->d;
 1512|      0|                      memcpy (newhead, c.sexp->d, (c.pos - c.sexp->d));
 1513|      0|                      c.pos = newhead + (c.pos - c.sexp->d);
 1514|      0|                      xfree (c.sexp);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1515|      0|                      c.sexp = newsexp;
 1516|      0|                    }
 1517|       |
 1518|     76|                  *c.pos++ = ST_DATA;
  ------------------
  |  |   92|     76|#define ST_DATA  1  /* datalen follows */
  ------------------
 1519|     76|                  STORE_LEN (c.pos, nm);
  ------------------
  |  | 1161|     76|#define STORE_LEN(p,n) do {						   \
  |  | 1162|     76|			    DATALEN ashort = (n);			   \
  |  | 1163|     76|			    memcpy ( (p), &ashort, sizeof(ashort) );	   \
  |  | 1164|     76|			    (p) += sizeof (ashort);			   \
  |  | 1165|     76|			} while (0)
  |  |  ------------------
  |  |  |  Branch (1165:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1520|     76|                  err = _gcry_mpi_print (mpifmt, c.pos, nm, &nm, m);
 1521|     76|                  if (err)
  ------------------
  |  Branch (1521:23): [True: 0, False: 76]
  ------------------
 1522|      0|                    goto leave;
 1523|     76|                  c.pos += nm;
 1524|     76|                }
 1525|    124|	    }
 1526|     44|	  else if (*p == 's')
  ------------------
  |  Branch (1526:13): [True: 24, False: 20]
  ------------------
 1527|     24|	    {
 1528|       |	      /* Insert an string.  */
 1529|     24|	      const char *astr;
 1530|     24|	      size_t alen;
 1531|       |
 1532|     24|	      ARG_NEXT (astr, const char *);
  ------------------
  |  | 1137|     24|  do                                                     \
  |  | 1138|     24|    {                                                    \
  |  | 1139|     24|      if (!arg_list)                                     \
  |  |  ------------------
  |  |  |  Branch (1139:11): [True: 24, False: 0]
  |  |  ------------------
  |  | 1140|     24|	storage = va_arg (arg_ptr, type);                \
  |  | 1141|     24|      else                                               \
  |  | 1142|     24|	storage = *((type *) (arg_list[arg_counter++])); \
  |  | 1143|     24|    }                                                    \
  |  | 1144|     24|  while (0)
  |  |  ------------------
  |  |  |  Branch (1144:10): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1533|     24|	      alen = strlen (astr);
 1534|       |
 1535|     24|	      MAKE_SPACE (alen);
  ------------------
  |  | 1150|     24|#define MAKE_SPACE(n)  do {                                                \
  |  | 1151|     24|                            gpg_err_code_t _ms_err = make_space (&c, (n)); \
  |  | 1152|     24|                            if (_ms_err)                                   \
  |  |  ------------------
  |  |  |  Branch (1152:33): [True: 0, False: 24]
  |  |  ------------------
  |  | 1153|     24|                              {                                            \
  |  | 1154|      0|                                err = _ms_err;                             \
  |  | 1155|      0|                                *erroff = p - buffer;                      \
  |  | 1156|      0|                                goto leave;                                \
  |  | 1157|      0|                              }                                            \
  |  | 1158|     24|                       } while (0)
  |  |  ------------------
  |  |  |  Branch (1158:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1536|     24|	      *c.pos++ = ST_DATA;
  ------------------
  |  |   92|     24|#define ST_DATA  1  /* datalen follows */
  ------------------
 1537|     24|	      STORE_LEN (c.pos, alen);
  ------------------
  |  | 1161|     24|#define STORE_LEN(p,n) do {						   \
  |  | 1162|     24|			    DATALEN ashort = (n);			   \
  |  | 1163|     24|			    memcpy ( (p), &ashort, sizeof(ashort) );	   \
  |  | 1164|     24|			    (p) += sizeof (ashort);			   \
  |  | 1165|     24|			} while (0)
  |  |  ------------------
  |  |  |  Branch (1165:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1538|     24|	      memcpy (c.pos, astr, alen);
 1539|     24|	      c.pos += alen;
 1540|     24|	    }
 1541|     20|	  else if (*p == 'b')
  ------------------
  |  Branch (1541:13): [True: 20, False: 0]
  ------------------
 1542|     20|	    {
 1543|       |	      /* Insert a memory buffer.  */
 1544|     20|	      const char *astr;
 1545|     20|	      int alen;
 1546|       |
 1547|     20|	      ARG_NEXT (alen, int);
  ------------------
  |  | 1137|     20|  do                                                     \
  |  | 1138|     20|    {                                                    \
  |  | 1139|     20|      if (!arg_list)                                     \
  |  |  ------------------
  |  |  |  Branch (1139:11): [True: 20, False: 0]
  |  |  ------------------
  |  | 1140|     20|	storage = va_arg (arg_ptr, type);                \
  |  | 1141|     20|      else                                               \
  |  | 1142|     20|	storage = *((type *) (arg_list[arg_counter++])); \
  |  | 1143|     20|    }                                                    \
  |  | 1144|     20|  while (0)
  |  |  ------------------
  |  |  |  Branch (1144:10): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1548|     20|	      ARG_NEXT (astr, const char *);
  ------------------
  |  | 1137|     20|  do                                                     \
  |  | 1138|     20|    {                                                    \
  |  | 1139|     20|      if (!arg_list)                                     \
  |  |  ------------------
  |  |  |  Branch (1139:11): [True: 20, False: 0]
  |  |  ------------------
  |  | 1140|     20|	storage = va_arg (arg_ptr, type);                \
  |  | 1141|     20|      else                                               \
  |  | 1142|     20|	storage = *((type *) (arg_list[arg_counter++])); \
  |  | 1143|     20|    }                                                    \
  |  | 1144|     20|  while (0)
  |  |  ------------------
  |  |  |  Branch (1144:10): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1549|       |
 1550|     20|              if (alen < 0)
  ------------------
  |  Branch (1550:19): [True: 0, False: 20]
  ------------------
 1551|      0|                {
 1552|      0|                  *erroff = p - buffer;
 1553|      0|		  err = GPG_ERR_INV_ARG;
 1554|      0|                  goto leave;
 1555|      0|                }
 1556|       |
 1557|     20|	      MAKE_SPACE (alen);
  ------------------
  |  | 1150|     20|#define MAKE_SPACE(n)  do {                                                \
  |  | 1151|     20|                            gpg_err_code_t _ms_err = make_space (&c, (n)); \
  |  | 1152|     20|                            if (_ms_err)                                   \
  |  |  ------------------
  |  |  |  Branch (1152:33): [True: 0, False: 20]
  |  |  ------------------
  |  | 1153|     20|                              {                                            \
  |  | 1154|      0|                                err = _ms_err;                             \
  |  | 1155|      0|                                *erroff = p - buffer;                      \
  |  | 1156|      0|                                goto leave;                                \
  |  | 1157|      0|                              }                                            \
  |  | 1158|     20|                       } while (0)
  |  |  ------------------
  |  |  |  Branch (1158:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1558|     20|	      if (alen
  ------------------
  |  Branch (1558:12): [True: 20, False: 0]
  ------------------
 1559|     20|                  && !_gcry_is_secure (c.sexp->d)
  ------------------
  |  Branch (1559:22): [True: 20, False: 0]
  ------------------
 1560|     20|		  && _gcry_is_secure (astr))
  ------------------
  |  Branch (1560:8): [True: 0, False: 20]
  ------------------
 1561|      0|              {
 1562|       |		  /* We have to switch to secure allocation.  */
 1563|      0|		  gcry_sexp_t newsexp;
 1564|      0|		  byte *newhead;
 1565|       |
 1566|      0|		  newsexp = xtrymalloc_secure (sizeof *newsexp
  ------------------
  |  |  140|      0|#define xtrymalloc_secure(a)   _gcry_malloc_secure ((a))
  ------------------
 1567|      0|                                               + c.allocated - 1);
 1568|      0|                  if (!newsexp)
  ------------------
  |  Branch (1568:23): [True: 0, False: 0]
  ------------------
 1569|      0|                    {
 1570|      0|                      err = gpg_err_code_from_errno (errno);
 1571|      0|                      goto leave;
 1572|      0|                    }
 1573|      0|		  newhead = newsexp->d;
 1574|      0|		  memcpy (newhead, c.sexp->d, (c.pos - c.sexp->d));
 1575|      0|		  c.pos = newhead + (c.pos - c.sexp->d);
 1576|      0|		  xfree (c.sexp);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1577|      0|		  c.sexp = newsexp;
 1578|      0|		}
 1579|       |
 1580|     20|	      *c.pos++ = ST_DATA;
  ------------------
  |  |   92|     20|#define ST_DATA  1  /* datalen follows */
  ------------------
 1581|     20|	      STORE_LEN (c.pos, alen);
  ------------------
  |  | 1161|     20|#define STORE_LEN(p,n) do {						   \
  |  | 1162|     20|			    DATALEN ashort = (n);			   \
  |  | 1163|     20|			    memcpy ( (p), &ashort, sizeof(ashort) );	   \
  |  | 1164|     20|			    (p) += sizeof (ashort);			   \
  |  | 1165|     20|			} while (0)
  |  |  ------------------
  |  |  |  Branch (1165:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1582|     20|	      memcpy (c.pos, astr, alen);
 1583|     20|	      c.pos += alen;
 1584|     20|	    }
 1585|      0|	  else if (*p == 'd')
  ------------------
  |  Branch (1585:13): [True: 0, False: 0]
  ------------------
 1586|      0|	    {
 1587|       |	      /* Insert an integer as string.  */
 1588|      0|	      int aint;
 1589|      0|	      size_t alen;
 1590|      0|	      char buf[35];
 1591|       |
 1592|      0|	      ARG_NEXT (aint, int);
  ------------------
  |  | 1137|      0|  do                                                     \
  |  | 1138|      0|    {                                                    \
  |  | 1139|      0|      if (!arg_list)                                     \
  |  |  ------------------
  |  |  |  Branch (1139:11): [True: 0, False: 0]
  |  |  ------------------
  |  | 1140|      0|	storage = va_arg (arg_ptr, type);                \
  |  | 1141|      0|      else                                               \
  |  | 1142|      0|	storage = *((type *) (arg_list[arg_counter++])); \
  |  | 1143|      0|    }                                                    \
  |  | 1144|      0|  while (0)
  |  |  ------------------
  |  |  |  Branch (1144:10): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1593|      0|	      snprintf (buf, sizeof buf, "%d", aint);
 1594|      0|	      alen = strlen (buf);
 1595|      0|	      MAKE_SPACE (alen);
  ------------------
  |  | 1150|      0|#define MAKE_SPACE(n)  do {                                                \
  |  | 1151|      0|                            gpg_err_code_t _ms_err = make_space (&c, (n)); \
  |  | 1152|      0|                            if (_ms_err)                                   \
  |  |  ------------------
  |  |  |  Branch (1152:33): [True: 0, False: 0]
  |  |  ------------------
  |  | 1153|      0|                              {                                            \
  |  | 1154|      0|                                err = _ms_err;                             \
  |  | 1155|      0|                                *erroff = p - buffer;                      \
  |  | 1156|      0|                                goto leave;                                \
  |  | 1157|      0|                              }                                            \
  |  | 1158|      0|                       } while (0)
  |  |  ------------------
  |  |  |  Branch (1158:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1596|      0|	      *c.pos++ = ST_DATA;
  ------------------
  |  |   92|      0|#define ST_DATA  1  /* datalen follows */
  ------------------
 1597|      0|	      STORE_LEN (c.pos, alen);
  ------------------
  |  | 1161|      0|#define STORE_LEN(p,n) do {						   \
  |  | 1162|      0|			    DATALEN ashort = (n);			   \
  |  | 1163|      0|			    memcpy ( (p), &ashort, sizeof(ashort) );	   \
  |  | 1164|      0|			    (p) += sizeof (ashort);			   \
  |  | 1165|      0|			} while (0)
  |  |  ------------------
  |  |  |  Branch (1165:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1598|      0|	      memcpy (c.pos, buf, alen);
 1599|      0|	      c.pos += alen;
 1600|      0|	    }
 1601|      0|	  else if (*p == 'u')
  ------------------
  |  Branch (1601:13): [True: 0, False: 0]
  ------------------
 1602|      0|	    {
 1603|       |	      /* Insert an unsigned integer as string.  */
 1604|      0|	      unsigned int aint;
 1605|      0|	      size_t alen;
 1606|      0|	      char buf[35];
 1607|       |
 1608|      0|	      ARG_NEXT (aint, unsigned int);
  ------------------
  |  | 1137|      0|  do                                                     \
  |  | 1138|      0|    {                                                    \
  |  | 1139|      0|      if (!arg_list)                                     \
  |  |  ------------------
  |  |  |  Branch (1139:11): [True: 0, False: 0]
  |  |  ------------------
  |  | 1140|      0|	storage = va_arg (arg_ptr, type);                \
  |  | 1141|      0|      else                                               \
  |  | 1142|      0|	storage = *((type *) (arg_list[arg_counter++])); \
  |  | 1143|      0|    }                                                    \
  |  | 1144|      0|  while (0)
  |  |  ------------------
  |  |  |  Branch (1144:10): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1609|      0|	      snprintf (buf, sizeof buf, "%u", aint);
 1610|      0|	      alen = strlen (buf);
 1611|      0|	      MAKE_SPACE (alen);
  ------------------
  |  | 1150|      0|#define MAKE_SPACE(n)  do {                                                \
  |  | 1151|      0|                            gpg_err_code_t _ms_err = make_space (&c, (n)); \
  |  | 1152|      0|                            if (_ms_err)                                   \
  |  |  ------------------
  |  |  |  Branch (1152:33): [True: 0, False: 0]
  |  |  ------------------
  |  | 1153|      0|                              {                                            \
  |  | 1154|      0|                                err = _ms_err;                             \
  |  | 1155|      0|                                *erroff = p - buffer;                      \
  |  | 1156|      0|                                goto leave;                                \
  |  | 1157|      0|                              }                                            \
  |  | 1158|      0|                       } while (0)
  |  |  ------------------
  |  |  |  Branch (1158:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1612|      0|	      *c.pos++ = ST_DATA;
  ------------------
  |  |   92|      0|#define ST_DATA  1  /* datalen follows */
  ------------------
 1613|      0|	      STORE_LEN (c.pos, alen);
  ------------------
  |  | 1161|      0|#define STORE_LEN(p,n) do {						   \
  |  | 1162|      0|			    DATALEN ashort = (n);			   \
  |  | 1163|      0|			    memcpy ( (p), &ashort, sizeof(ashort) );	   \
  |  | 1164|      0|			    (p) += sizeof (ashort);			   \
  |  | 1165|      0|			} while (0)
  |  |  ------------------
  |  |  |  Branch (1165:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1614|      0|	      memcpy (c.pos, buf, alen);
 1615|      0|	      c.pos += alen;
 1616|      0|	    }
 1617|      0|	  else if (*p == 'S')
  ------------------
  |  Branch (1617:13): [True: 0, False: 0]
  ------------------
 1618|      0|	    {
 1619|       |	      /* Insert a gcry_sexp_t.  */
 1620|      0|	      gcry_sexp_t asexp;
 1621|      0|	      size_t alen, aoff;
 1622|       |
 1623|      0|	      ARG_NEXT (asexp, gcry_sexp_t);
  ------------------
  |  | 1137|      0|  do                                                     \
  |  | 1138|      0|    {                                                    \
  |  | 1139|      0|      if (!arg_list)                                     \
  |  |  ------------------
  |  |  |  Branch (1139:11): [True: 0, False: 0]
  |  |  ------------------
  |  | 1140|      0|	storage = va_arg (arg_ptr, type);                \
  |  | 1141|      0|      else                                               \
  |  | 1142|      0|	storage = *((type *) (arg_list[arg_counter++])); \
  |  | 1143|      0|    }                                                    \
  |  | 1144|      0|  while (0)
  |  |  ------------------
  |  |  |  Branch (1144:10): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1624|      0|              alen = get_internal_buffer (asexp, &aoff);
 1625|      0|              if (alen)
  ------------------
  |  Branch (1625:19): [True: 0, False: 0]
  ------------------
 1626|      0|                {
 1627|      0|                  MAKE_SPACE (alen);
  ------------------
  |  | 1150|      0|#define MAKE_SPACE(n)  do {                                                \
  |  | 1151|      0|                            gpg_err_code_t _ms_err = make_space (&c, (n)); \
  |  | 1152|      0|                            if (_ms_err)                                   \
  |  |  ------------------
  |  |  |  Branch (1152:33): [True: 0, False: 0]
  |  |  ------------------
  |  | 1153|      0|                              {                                            \
  |  | 1154|      0|                                err = _ms_err;                             \
  |  | 1155|      0|                                *erroff = p - buffer;                      \
  |  | 1156|      0|                                goto leave;                                \
  |  | 1157|      0|                              }                                            \
  |  | 1158|      0|                       } while (0)
  |  |  ------------------
  |  |  |  Branch (1158:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1628|      0|                  memcpy (c.pos, asexp->d + aoff, alen);
 1629|      0|                  c.pos += alen;
 1630|      0|                }
 1631|      0|	    }
 1632|      0|	  else
 1633|      0|	    {
 1634|      0|	      *erroff = p - buffer;
 1635|       |	      /* Invalid format specifier.  */
 1636|      0|	      err = GPG_ERR_SEXP_INV_LEN_SPEC;
 1637|      0|              goto leave;
 1638|      0|	    }
 1639|    168|	  percent = NULL;
 1640|    168|	}
 1641|  1.05k|      else if (*p == '(')
  ------------------
  |  Branch (1641:16): [True: 289, False: 762]
  ------------------
 1642|    289|	{
 1643|    289|	  if (disphint)
  ------------------
  |  Branch (1643:8): [True: 0, False: 289]
  ------------------
 1644|      0|	    {
 1645|      0|	      *erroff = p - buffer;
 1646|       |	      /* Open display hint.  */
 1647|      0|	      err = GPG_ERR_SEXP_UNMATCHED_DH;
 1648|      0|              goto leave;
 1649|      0|	    }
 1650|    289|	  MAKE_SPACE (0);
  ------------------
  |  | 1150|    289|#define MAKE_SPACE(n)  do {                                                \
  |  | 1151|    289|                            gpg_err_code_t _ms_err = make_space (&c, (n)); \
  |  | 1152|    289|                            if (_ms_err)                                   \
  |  |  ------------------
  |  |  |  Branch (1152:33): [True: 0, False: 289]
  |  |  ------------------
  |  | 1153|    289|                              {                                            \
  |  | 1154|      0|                                err = _ms_err;                             \
  |  | 1155|      0|                                *erroff = p - buffer;                      \
  |  | 1156|      0|                                goto leave;                                \
  |  | 1157|      0|                              }                                            \
  |  | 1158|    289|                       } while (0)
  |  |  ------------------
  |  |  |  Branch (1158:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1651|    289|	  *c.pos++ = ST_OPEN;
  ------------------
  |  |   94|    289|#define ST_OPEN  3
  ------------------
 1652|    289|	  level++;
 1653|    289|	}
 1654|    762|      else if (*p == ')')
  ------------------
  |  Branch (1654:16): [True: 289, False: 473]
  ------------------
 1655|    289|	{
 1656|       |	  /* Walk up.  */
 1657|    289|	  if (disphint)
  ------------------
  |  Branch (1657:8): [True: 0, False: 289]
  ------------------
 1658|      0|	    {
 1659|      0|	      *erroff = p - buffer;
 1660|       |	      /* Open display hint.  */
 1661|      0|	      err = GPG_ERR_SEXP_UNMATCHED_DH;
 1662|      0|              goto leave;
 1663|      0|	    }
 1664|       |
 1665|    289|	  if (level == 0)
  ------------------
  |  Branch (1665:8): [True: 0, False: 289]
  ------------------
 1666|      0|	    {
 1667|      0|	      *erroff = p - buffer;
 1668|      0|	      err = GPG_ERR_SEXP_UNMATCHED_PAREN;
 1669|      0|	      goto leave;
 1670|      0|	    }
 1671|    289|	  MAKE_SPACE (0);
  ------------------
  |  | 1150|    289|#define MAKE_SPACE(n)  do {                                                \
  |  | 1151|    289|                            gpg_err_code_t _ms_err = make_space (&c, (n)); \
  |  | 1152|    289|                            if (_ms_err)                                   \
  |  |  ------------------
  |  |  |  Branch (1152:33): [True: 0, False: 289]
  |  |  ------------------
  |  | 1153|    289|                              {                                            \
  |  | 1154|      0|                                err = _ms_err;                             \
  |  | 1155|      0|                                *erroff = p - buffer;                      \
  |  | 1156|      0|                                goto leave;                                \
  |  | 1157|      0|                              }                                            \
  |  | 1158|    289|                       } while (0)
  |  |  ------------------
  |  |  |  Branch (1158:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1672|    289|	  *c.pos++ = ST_CLOSE;
  ------------------
  |  |   95|    289|#define ST_CLOSE 4
  ------------------
 1673|    289|	  level--;
 1674|    289|	}
 1675|    473|      else if (*p == '\"')
  ------------------
  |  Branch (1675:16): [True: 0, False: 473]
  ------------------
 1676|      0|	{
 1677|      0|	  quoted = p;
 1678|      0|	  quoted_esc = 0;
 1679|      0|	}
 1680|    473|      else if (*p == '#')
  ------------------
  |  Branch (1680:16): [True: 0, False: 473]
  ------------------
 1681|      0|	{
 1682|      0|	  hexfmt = p;
 1683|      0|	  hexcount = 0;
 1684|      0|	}
 1685|    473|      else if (*p == '|')
  ------------------
  |  Branch (1685:16): [True: 0, False: 473]
  ------------------
 1686|      0|        {
 1687|      0|          base64 = p;
 1688|      0|          b64count = 0;
 1689|      0|        }
 1690|    473|      else if (*p == '[')
  ------------------
  |  Branch (1690:16): [True: 0, False: 473]
  ------------------
 1691|      0|	{
 1692|      0|	  if (disphint)
  ------------------
  |  Branch (1692:8): [True: 0, False: 0]
  ------------------
 1693|      0|	    {
 1694|      0|	      *erroff = p - buffer;
 1695|       |	      /* Open display hint.  */
 1696|      0|	      err = GPG_ERR_SEXP_NESTED_DH;
 1697|      0|              goto leave;
 1698|      0|	    }
 1699|      0|	  disphint = p;
 1700|      0|	}
 1701|    473|      else if (*p == ']')
  ------------------
  |  Branch (1701:16): [True: 0, False: 473]
  ------------------
 1702|      0|	{
 1703|      0|	  if (!disphint)
  ------------------
  |  Branch (1703:8): [True: 0, False: 0]
  ------------------
 1704|      0|	    {
 1705|      0|	      *erroff = p - buffer;
 1706|       |	      /* Open display hint.  */
 1707|      0|	      err = GPG_ERR_SEXP_UNMATCHED_DH;
 1708|      0|              goto leave;
 1709|      0|	    }
 1710|      0|	  disphint = NULL;
 1711|      0|	}
 1712|    473|      else if (digitp (p))
  ------------------
  |  |  405|    473|#define digitp(p)   (*(p) >= '0' && *(p) <= '9')
  |  |  ------------------
  |  |  |  Branch (405:22): [True: 289, False: 184]
  |  |  |  Branch (405:37): [True: 0, False: 289]
  |  |  ------------------
  ------------------
 1713|      0|	{
 1714|      0|	  if (*p == '0')
  ------------------
  |  Branch (1714:8): [True: 0, False: 0]
  ------------------
 1715|      0|	    {
 1716|       |	      /* A length may not begin with zero.  */
 1717|      0|	      *erroff = p - buffer;
 1718|      0|	      err = GPG_ERR_SEXP_ZERO_PREFIX;
 1719|      0|              goto leave;
 1720|      0|	    }
 1721|      0|	  digptr = p;
 1722|      0|	}
 1723|    473|      else if (strchr (tokenchars, *p))
  ------------------
  |  Branch (1723:16): [True: 289, False: 184]
  ------------------
 1724|    289|	tokenp = p;
 1725|    184|      else if (whitespacep (p))
  ------------------
  |  Branch (1725:16): [True: 16, False: 168]
  ------------------
 1726|     16|	;
 1727|    168|      else if (*p == '{')
  ------------------
  |  Branch (1727:16): [True: 0, False: 168]
  ------------------
 1728|      0|	{
 1729|       |	  /* fixme: handle rescanning: we can do this by saving our
 1730|       |	     current state and start over at p+1 -- Hmmm. At this
 1731|       |	     point here we are in a well defined state, so we don't
 1732|       |	     need to save it.  Great.  */
 1733|      0|	  *erroff = p - buffer;
 1734|      0|	  err = GPG_ERR_SEXP_UNEXPECTED_PUNC;
 1735|      0|          goto leave;
 1736|      0|	}
 1737|    168|      else if (strchr ("&\\", *p))
  ------------------
  |  Branch (1737:16): [True: 0, False: 168]
  ------------------
 1738|      0|	{
 1739|       |	  /* Reserved punctuation.  */
 1740|      0|	  *erroff = p - buffer;
 1741|      0|	  err = GPG_ERR_SEXP_UNEXPECTED_PUNC;
 1742|      0|          goto leave;
 1743|      0|	}
 1744|    168|      else if (argflag && (*p == '%'))
  ------------------
  |  Branch (1744:16): [True: 168, False: 0]
  |  Branch (1744:27): [True: 168, False: 0]
  ------------------
 1745|    168|	percent = p;
 1746|      0|      else
 1747|      0|	{
 1748|       |	  /* Bad or unavailable.  */
 1749|      0|	  *erroff = p - buffer;
 1750|      0|	  err = GPG_ERR_SEXP_BAD_CHARACTER;
 1751|      0|          goto leave;
 1752|      0|	}
 1753|  1.21k|    }
 1754|    107|  MAKE_SPACE (0);
  ------------------
  |  | 1150|    107|#define MAKE_SPACE(n)  do {                                                \
  |  | 1151|    107|                            gpg_err_code_t _ms_err = make_space (&c, (n)); \
  |  | 1152|    107|                            if (_ms_err)                                   \
  |  |  ------------------
  |  |  |  Branch (1152:33): [True: 0, False: 107]
  |  |  ------------------
  |  | 1153|    107|                              {                                            \
  |  | 1154|      0|                                err = _ms_err;                             \
  |  | 1155|      0|                                *erroff = p - buffer;                      \
  |  | 1156|      0|                                goto leave;                                \
  |  | 1157|      0|                              }                                            \
  |  | 1158|    107|                       } while (0)
  |  |  ------------------
  |  |  |  Branch (1158:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1755|    107|  *c.pos++ = ST_STOP;
  ------------------
  |  |   91|    107|#define ST_STOP  0
  ------------------
 1756|       |
 1757|    107|  if (level && !err)
  ------------------
  |  Branch (1757:7): [True: 0, False: 107]
  |  Branch (1757:16): [True: 0, False: 0]
  ------------------
 1758|      0|    err = GPG_ERR_SEXP_UNMATCHED_PAREN;
 1759|       |
 1760|    107| leave:
 1761|    107|  if (err)
  ------------------
  |  Branch (1761:7): [True: 0, False: 107]
  ------------------
 1762|      0|    {
 1763|       |      /* Error -> deallocate.  */
 1764|      0|      if (c.sexp)
  ------------------
  |  Branch (1764:11): [True: 0, False: 0]
  ------------------
 1765|      0|        {
 1766|       |          /* Extra paranoid wipe on error. */
 1767|      0|          if (_gcry_is_secure (c.sexp))
  ------------------
  |  Branch (1767:15): [True: 0, False: 0]
  ------------------
 1768|      0|            wipememory (c.sexp, sizeof (struct gcry_sexp) + c.allocated - 1);
  ------------------
  |  |  398|      0|#define wipememory(_ptr,_len) wipememory2((_ptr),0,(_len))
  |  |  ------------------
  |  |  |  |  388|      0|#define wipememory2(_ptr,_set,_len) do { \
  |  |  |  |  389|      0|	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |               	      if (!CONSTANT_P(_len) || !CONSTANT_P(_set)) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (389:12): [True: 0, False: 0]
  |  |  |  |  |  Branch (389:33): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  390|      0|		if (CONSTANT_P(_set) && (_set) == 0) \
  |  |  |  |  ------------------
  |  |  |  |  |  |   87|      0|#define CONSTANT_P(expr)  __builtin_constant_p( expr )
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (87:27): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:27): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  |  |  391|      0|		  _gcry_fast_wipememory((void *)(_ptr), (_len)); \
  |  |  |  |  392|      0|		else \
  |  |  |  |  393|      0|		  _gcry_fast_wipememory2((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  394|      0|	      } else { \
  |  |  |  |  395|      0|		fast_wipememory2_inline((void *)(_ptr), (_set), (_len)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  380|      0|#define fast_wipememory2_inline(_ptr,_set,_len) do { \
  |  |  |  |  |  |  381|      0|	      memset((_ptr), (_set), (_len)); \
  |  |  |  |  |  |  382|      0|	      asm volatile ("\n" :: "r" (_ptr) : "memory"); \
  |  |  |  |  |  |  383|      0|	    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (383:14): [Folded - Ignored]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  396|      0|	      } \
  |  |  |  |  397|      0|	    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (397:14): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1769|      0|          xfree (c.sexp);
  ------------------
  |  |  150|      0|#define xfree(a)         _gcry_free ((a))
  ------------------
 1770|      0|        }
 1771|      0|    }
 1772|    107|  else
 1773|    107|    *retsexp = normalize (c.sexp);
 1774|       |
 1775|    107|  return err;
 1776|    107|#undef MAKE_SPACE
 1777|    107|#undef STORE_LEN
 1778|    107|}
sexp.c:make_space:
  976|  1.14k|{
  977|  1.14k|  size_t used = c->pos - c->sexp->d;
  978|       |
  979|  1.14k|  if ( used + n + sizeof(DATALEN) + 1 >= c->allocated )
  ------------------
  |  Branch (979:8): [True: 162, False: 980]
  ------------------
  980|    162|    {
  981|    162|      gcry_sexp_t newsexp;
  982|    162|      byte *newhead;
  983|    162|      size_t newsize;
  984|       |
  985|    162|      newsize = c->allocated + 2*(n+sizeof(DATALEN)+1);
  986|    162|      if (newsize <= c->allocated)
  ------------------
  |  Branch (986:11): [True: 0, False: 162]
  ------------------
  987|      0|        return GPG_ERR_TOO_LARGE;
  988|    162|      newsexp = xtryrealloc ( c->sexp, sizeof *newsexp + newsize - 1);
  ------------------
  |  |  142|    162|#define xtryrealloc(a,b) _gcry_realloc ((a),(b))
  ------------------
  989|    162|      if (!newsexp)
  ------------------
  |  Branch (989:11): [True: 0, False: 162]
  ------------------
  990|      0|        return gpg_err_code_from_errno (errno);
  991|    162|      c->allocated = newsize;
  992|    162|      newhead = newsexp->d;
  993|    162|      c->pos = newhead + used;
  994|    162|      c->sexp = newsexp;
  995|    162|    }
  996|  1.14k|  return 0;
  997|  1.14k|}
sexp.c:whitespacep:
  120|    354|{
  121|    354|  switch (*p)
  122|    354|    {
  123|     16|    case ' ': case '\t': case '\v': case '\f': case '\r': case '\n': return 1;
  ------------------
  |  Branch (123:5): [True: 16, False: 338]
  |  Branch (123:15): [True: 0, False: 354]
  |  Branch (123:26): [True: 0, False: 354]
  |  Branch (123:37): [True: 0, False: 354]
  |  Branch (123:48): [True: 0, False: 354]
  |  Branch (123:59): [True: 0, False: 354]
  ------------------
  124|    338|    default: return 0;
  ------------------
  |  Branch (124:5): [True: 338, False: 16]
  ------------------
  125|    354|    }
  126|    354|}

_gcry_private_malloc:
   66|   236k|{
   67|   236k|  if (!n)
  ------------------
  |  Branch (67:7): [True: 198, False: 236k]
  ------------------
   68|    198|    {
   69|    198|      gpg_err_set_errno (EINVAL);
   70|    198|      return NULL; /* Allocating 0 bytes is undefined - we better return
   71|       |                      an error to detect such coding errors.  */
   72|    198|    }
   73|       |
   74|   236k|  return malloc( n );
   75|   236k|}
_gcry_private_realloc:
  104|    947|{
  105|    947|  if ( _gcry_private_is_secure(a) )
  ------------------
  |  Branch (105:8): [True: 0, False: 947]
  ------------------
  106|      0|    {
  107|      0|      return _gcry_secmem_realloc (a, n, xhint);
  108|      0|    }
  109|    947|  else
  110|    947|    {
  111|    947|      return realloc( a, n );
  112|    947|    }
  113|    947|}
_gcry_private_free:
  121|   237k|{
  122|   237k|  unsigned char *p = a;
  123|   237k|  unsigned char *freep;
  124|       |
  125|   237k|  if (!p)
  ------------------
  |  Branch (125:7): [True: 0, False: 237k]
  ------------------
  126|      0|    return;
  127|       |
  128|   237k|  freep = p;
  129|       |
  130|   237k|  if (!_gcry_private_is_secure (freep) ||
  ------------------
  |  Branch (130:7): [True: 237k, False: 0]
  ------------------
  131|   237k|      !_gcry_secmem_free (freep))
  ------------------
  |  Branch (131:7): [True: 0, False: 0]
  ------------------
  132|   237k|    {
  133|   237k|      free (freep);
  134|   237k|    }
  135|   237k|}

gcry_check_version:
   69|      1|{
   70|      1|  return _gcry_check_version (req_version);
   71|      1|}
gcry_sexp_build:
  112|    107|{
  113|    107|  gcry_err_code_t rc;
  114|    107|  va_list arg_ptr;
  115|       |
  116|    107|  va_start (arg_ptr, format);
  117|    107|  rc = _gcry_sexp_vbuild (retsexp, erroff, format, arg_ptr);
  118|    107|  va_end (arg_ptr);
  119|    107|  return gpg_error (rc);
  120|    107|}
gcry_sexp_release:
  131|    107|{
  132|    107|  _gcry_sexp_release (sexp);
  133|    107|}
gcry_mpi_release:
  283|  6.82k|{
  284|  6.82k|  _gcry_mpi_release (a);
  285|  6.82k|}
gcry_mpi_copy:
  289|    825|{
  290|    825|  return _gcry_mpi_copy (a);
  291|    825|}
gcry_mpi_cmp:
  343|     56|{
  344|     56|  return _gcry_mpi_cmp (u, v);
  345|     56|}
gcry_mpi_scan:
  357|    952|{
  358|    952|  return gpg_error (_gcry_mpi_scan (ret_mpi, format, buffer, buflen, nscanned));
  359|    952|}
gcry_mpi_print:
  366|    743|{
  367|    743|  return gpg_error (_gcry_mpi_print (format, buffer, buflen, nwritten, a));
  368|    743|}
gcry_mpi_get_nbits:
  634|    158|{
  635|    158|  return _gcry_mpi_get_nbits (a);
  636|    158|}
gcry_mpi_set_opaque:
  682|  3.42k|{
  683|  3.42k|  return _gcry_mpi_set_opaque (a, p, nbits);
  684|  3.42k|}
gcry_mpi_get_opaque:
  694|  1.72k|{
  695|  1.72k|  return _gcry_mpi_get_opaque (a, nbits);
  696|  1.72k|}
gcry_mpi_set_flag:
  700|    669|{
  701|    669|  _gcry_mpi_set_flag (a, flag);
  702|    669|}
gcry_mpi_get_flag:
  712|  3.47k|{
  713|  3.47k|  return _gcry_mpi_get_flag (a, flag);
  714|  3.47k|}
gcry_pk_verify:
 1058|     31|{
 1059|     31|  if (!fips_is_operational ())
  ------------------
  |  |  477|     31|        (!_gcry_global_any_init_done ? \
  |  |  ------------------
  |  |  |  Branch (477:10): [True: 0, False: 31]
  |  |  ------------------
  |  |  478|     31|                _gcry_global_is_operational() : \
  |  |  479|     31|                (!fips_mode () || _gcry_global_is_operational ()))
  |  |  ------------------
  |  |  |  |  449|     62|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (479:18): [True: 31, False: 0]
  |  |  |  Branch (479:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1059:7): [True: 0, False: 31]
  ------------------
 1060|      0|    return gpg_error (fips_not_operational ());
  ------------------
  |  |  481|      0|#define fips_not_operational()  (GPG_ERR_NOT_OPERATIONAL)
  ------------------
 1061|     31|  return gpg_error (_gcry_pk_verify (sigval, data, pkey));
 1062|     31|}
gcry_pk_algo_info:
 1104|   127k|{
 1105|   127k|  if (!fips_is_operational ())
  ------------------
  |  |  477|   127k|        (!_gcry_global_any_init_done ? \
  |  |  ------------------
  |  |  |  Branch (477:10): [True: 0, False: 127k]
  |  |  ------------------
  |  |  478|   127k|                _gcry_global_is_operational() : \
  |  |  479|   127k|                (!fips_mode () || _gcry_global_is_operational ()))
  |  |  ------------------
  |  |  |  |  449|   255k|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (479:18): [True: 127k, False: 0]
  |  |  |  Branch (479:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1105:7): [True: 0, False: 127k]
  ------------------
 1106|      0|    return gpg_error (fips_not_operational ());
  ------------------
  |  |  481|      0|#define fips_not_operational()  (GPG_ERR_NOT_OPERATIONAL)
  ------------------
 1107|       |
 1108|   127k|  return gpg_error (_gcry_pk_algo_info (algo, what, buffer, nbytes));
 1109|   127k|}
gcry_pk_get_keygrip:
 1137|     14|{
 1138|     14|  if (!fips_is_operational ())
  ------------------
  |  |  477|     14|        (!_gcry_global_any_init_done ? \
  |  |  ------------------
  |  |  |  Branch (477:10): [True: 0, False: 14]
  |  |  ------------------
  |  |  478|     14|                _gcry_global_is_operational() : \
  |  |  479|     14|                (!fips_mode () || _gcry_global_is_operational ()))
  |  |  ------------------
  |  |  |  |  449|     28|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (479:18): [True: 14, False: 0]
  |  |  |  Branch (479:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1138:7): [True: 0, False: 14]
  ------------------
 1139|      0|    {
 1140|      0|      (void)fips_not_operational ();
  ------------------
  |  |  481|      0|#define fips_not_operational()  (GPG_ERR_NOT_OPERATIONAL)
  ------------------
 1141|      0|      return NULL;
 1142|      0|    }
 1143|     14|  return _gcry_pk_get_keygrip (key, array);
 1144|     14|}
gcry_md_open:
 1194|  1.22k|{
 1195|  1.22k|  if (!fips_is_operational ())
  ------------------
  |  |  477|  1.22k|        (!_gcry_global_any_init_done ? \
  |  |  ------------------
  |  |  |  Branch (477:10): [True: 1, False: 1.22k]
  |  |  ------------------
  |  |  478|  1.22k|                _gcry_global_is_operational() : \
  |  |  479|  1.22k|                (!fips_mode () || _gcry_global_is_operational ()))
  |  |  ------------------
  |  |  |  |  449|  2.44k|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (479:18): [True: 1.22k, False: 0]
  |  |  |  Branch (479:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1195:7): [True: 0, False: 1.22k]
  ------------------
 1196|      0|    {
 1197|      0|      *h = NULL;
 1198|      0|      return gpg_error (fips_not_operational ());
  ------------------
  |  |  481|      0|#define fips_not_operational()  (GPG_ERR_NOT_OPERATIONAL)
  ------------------
 1199|      0|    }
 1200|       |
 1201|  1.22k|  return gpg_error (_gcry_md_open (h, algo, flags));
 1202|  1.22k|}
gcry_md_close:
 1206|  1.22k|{
 1207|  1.22k|  _gcry_md_close (hd);
 1208|  1.22k|}
gcry_md_enable:
 1212|    158|{
 1213|    158|  if (!fips_is_operational ())
  ------------------
  |  |  477|    158|        (!_gcry_global_any_init_done ? \
  |  |  ------------------
  |  |  |  Branch (477:10): [True: 0, False: 158]
  |  |  ------------------
  |  |  478|    158|                _gcry_global_is_operational() : \
  |  |  479|    158|                (!fips_mode () || _gcry_global_is_operational ()))
  |  |  ------------------
  |  |  |  |  449|    316|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (479:18): [True: 158, False: 0]
  |  |  |  Branch (479:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1213:7): [True: 0, False: 158]
  ------------------
 1214|      0|    return gpg_error (fips_not_operational ());
  ------------------
  |  |  481|      0|#define fips_not_operational()  (GPG_ERR_NOT_OPERATIONAL)
  ------------------
 1215|    158|  return gpg_error (_gcry_md_enable (hd, algo));
 1216|    158|}
gcry_md_reset:
 1231|  1.50k|{
 1232|  1.50k|  _gcry_md_reset (hd);
 1233|  1.50k|}
gcry_md_ctl:
 1237|  2.65k|{
 1238|  2.65k|  if (!fips_is_operational ())
  ------------------
  |  |  477|  2.65k|        (!_gcry_global_any_init_done ? \
  |  |  ------------------
  |  |  |  Branch (477:10): [True: 0, False: 2.65k]
  |  |  ------------------
  |  |  478|  2.65k|                _gcry_global_is_operational() : \
  |  |  479|  2.65k|                (!fips_mode () || _gcry_global_is_operational ()))
  |  |  ------------------
  |  |  |  |  449|  5.31k|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (479:18): [True: 2.65k, False: 0]
  |  |  |  Branch (479:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1238:7): [True: 0, False: 2.65k]
  ------------------
 1239|      0|    return gpg_error (fips_not_operational ());
  ------------------
  |  |  481|      0|#define fips_not_operational()  (GPG_ERR_NOT_OPERATIONAL)
  ------------------
 1240|  2.65k|  return gpg_error (_gcry_md_ctl (hd, cmd, buffer, buflen));
 1241|  2.65k|}
gcry_md_write:
 1245|  2.42k|{
 1246|  2.42k|  if (!fips_is_operational ())
  ------------------
  |  |  477|  2.42k|        (!_gcry_global_any_init_done ? \
  |  |  ------------------
  |  |  |  Branch (477:10): [True: 0, False: 2.42k]
  |  |  ------------------
  |  |  478|  2.42k|                _gcry_global_is_operational() : \
  |  |  479|  2.42k|                (!fips_mode () || _gcry_global_is_operational ()))
  |  |  ------------------
  |  |  |  |  449|  4.84k|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (479:18): [True: 2.42k, False: 0]
  |  |  |  Branch (479:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1246:7): [True: 0, False: 2.42k]
  ------------------
 1247|      0|    {
 1248|      0|      (void)fips_not_operational ();
  ------------------
  |  |  481|      0|#define fips_not_operational()  (GPG_ERR_NOT_OPERATIONAL)
  ------------------
 1249|      0|      return;
 1250|      0|    }
 1251|  2.42k|  _gcry_md_write (hd, buffer, length);
 1252|  2.42k|}
gcry_md_read:
 1256|  1.08k|{
 1257|  1.08k|  return _gcry_md_read (hd, algo);
 1258|  1.08k|}
gcry_md_hash_buffer:
 1271|     25|{
 1272|     25|  if (!fips_is_operational ())
  ------------------
  |  |  477|     25|        (!_gcry_global_any_init_done ? \
  |  |  ------------------
  |  |  |  Branch (477:10): [True: 0, False: 25]
  |  |  ------------------
  |  |  478|     25|                _gcry_global_is_operational() : \
  |  |  479|     25|                (!fips_mode () || _gcry_global_is_operational ()))
  |  |  ------------------
  |  |  |  |  449|     50|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (479:18): [True: 25, False: 0]
  |  |  |  Branch (479:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1272:7): [True: 0, False: 25]
  ------------------
 1273|      0|    {
 1274|      0|      (void)fips_not_operational ();
  ------------------
  |  |  481|      0|#define fips_not_operational()  (GPG_ERR_NOT_OPERATIONAL)
  ------------------
 1275|      0|      fips_signal_error ("called in non-operational state");
  ------------------
  |  |  459|      0|           _gcry_fips_signal_error (__FILE__, __LINE__, __FUNCTION__, 0, (a))
  ------------------
 1276|      0|    }
 1277|     25|  _gcry_md_hash_buffer (algo, digest, buffer, length);
 1278|     25|}
gcry_md_get_algo:
 1294|  1.01k|{
 1295|  1.01k|  if (!fips_is_operational ())
  ------------------
  |  |  477|  1.01k|        (!_gcry_global_any_init_done ? \
  |  |  ------------------
  |  |  |  Branch (477:10): [True: 0, False: 1.01k]
  |  |  ------------------
  |  |  478|  1.01k|                _gcry_global_is_operational() : \
  |  |  479|  1.01k|                (!fips_mode () || _gcry_global_is_operational ()))
  |  |  ------------------
  |  |  |  |  449|  2.02k|#define fips_mode() (!_gcry_no_fips_mode_required)
  |  |  ------------------
  |  |  |  Branch (479:18): [True: 1.01k, False: 0]
  |  |  |  Branch (479:35): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1295:7): [True: 0, False: 1.01k]
  ------------------
 1296|      0|    {
 1297|      0|      (void)fips_not_operational ();
  ------------------
  |  |  481|      0|#define fips_not_operational()  (GPG_ERR_NOT_OPERATIONAL)
  ------------------
 1298|      0|      fips_signal_error ("used in non-operational state");
  ------------------
  |  |  459|      0|           _gcry_fips_signal_error (__FILE__, __LINE__, __FUNCTION__, 0, (a))
  ------------------
 1299|      0|      return 0;
 1300|      0|    }
 1301|  1.01k|  return _gcry_md_get_algo (hd);
 1302|  1.01k|}
gcry_md_get_algo_dlen:
 1306|  1.17k|{
 1307|  1.17k|  return _gcry_md_get_algo_dlen (algo);
 1308|  1.17k|}
gcry_md_is_secure:
 1324|     15|{
 1325|     15|  return _gcry_md_is_secure (a);
 1326|     15|}
gcry_md_algo_info:
 1339|   126k|{
 1340|   126k|  return gpg_error (_gcry_md_algo_info (algo, what, buffer, nbytes));
 1341|   126k|}
gcry_set_log_handler:
 1614|      1|{
 1615|      1|  _gcry_set_log_handler (f, opaque);
 1616|      1|}
gcry_malloc:
 1626|  4.00k|{
 1627|  4.00k|  return _gcry_malloc (n);
 1628|  4.00k|}
gcry_calloc:
 1632|  3.81k|{
 1633|  3.81k|  return _gcry_calloc (n, m);
 1634|  3.81k|}
gcry_realloc:
 1650|      6|{
 1651|      6|  return _gcry_realloc (a, n);
 1652|      6|}
gcry_xmalloc:
 1662|  9.66k|{
 1663|  9.66k|  return _gcry_xmalloc (n);
 1664|  9.66k|}
gcry_xcalloc:
 1668|  6.77k|{
 1669|  6.77k|  return _gcry_xcalloc (n, m);
 1670|  6.77k|}
gcry_xrealloc:
 1686|    422|{
 1687|    422|  return _gcry_xrealloc (a, n);
 1688|    422|}
gcry_xstrdup:
 1692|    114|{
 1693|    114|  return _gcry_xstrdup (a);
 1694|    114|}
gcry_free:
 1698|  47.6k|{
 1699|  47.6k|  _gcry_free (a);
 1700|  47.6k|}

_gpg_err_code_from_errno:
   36|    198|{
   37|    198|  int idx;
   38|       |
   39|    198|  if (!err)
  ------------------
  |  Branch (39:7): [True: 0, False: 198]
  ------------------
   40|      0|    return GPG_ERR_NO_ERROR;
   41|       |
   42|    198|  idx = errno_to_idx (err);
  ------------------
  |  |  151|    198|#define errno_to_idx(code) (0 ? -1 \
  |  |  ------------------
  |  |  |  Branch (151:29): [Folded - Ignored]
  |  |  ------------------
  |  |  152|    198|  : ((code >= 1) && (code <= 11)) ? (code - 1) \
  |  |  ------------------
  |  |  |  Branch (152:6): [True: 198, False: 0]
  |  |  |  Branch (152:21): [True: 0, False: 198]
  |  |  ------------------
  |  |  153|    198|  : ((code >= 11) && (code <= 35)) ? (code - 0) \
  |  |  ------------------
  |  |  |  Branch (153:6): [True: 198, False: 0]
  |  |  |  Branch (153:22): [True: 198, False: 0]
  |  |  ------------------
  |  |  154|    198|  : ((code >= 35) && (code <= 40)) ? (code - -1) \
  |  |  ------------------
  |  |  |  Branch (154:6): [True: 0, False: 0]
  |  |  |  Branch (154:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  155|      0|  : ((code >= 42) && (code <= 57)) ? (code - 0) \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  Branch (155:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|  : ((code >= 59) && (code <= 95)) ? (code - 1) \
  |  |  ------------------
  |  |  |  Branch (156:6): [True: 0, False: 0]
  |  |  |  Branch (156:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|  : ((code >= 95) && (code <= 125)) ? (code - 0) \
  |  |  ------------------
  |  |  |  Branch (157:6): [True: 0, False: 0]
  |  |  |  Branch (157:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  158|      0|  : -1)
  ------------------
   43|       |
   44|    198|  if (idx < 0)
  ------------------
  |  Branch (44:7): [True: 0, False: 198]
  ------------------
   45|      0|    return GPG_ERR_UNKNOWN_ERRNO;
   46|       |
   47|    198|  return GPG_ERR_SYSTEM_ERROR | err_code_from_index[idx];
  ------------------
  |  |  584|    198|#define GPG_ERR_SYSTEM_ERROR	(1 << 15)
  ------------------
   48|    198|}
_gpg_err_code_from_syserror:
   56|    204|{
   57|    204|  int err = errno;
   58|    204|  int idx;
   59|       |
   60|    204|  if (!err)
  ------------------
  |  Branch (60:7): [True: 0, False: 204]
  ------------------
   61|      0|    return GPG_ERR_MISSING_ERRNO;
   62|       |
   63|    204|  idx = errno_to_idx (err);
  ------------------
  |  |  151|    204|#define errno_to_idx(code) (0 ? -1 \
  |  |  ------------------
  |  |  |  Branch (151:29): [Folded - Ignored]
  |  |  ------------------
  |  |  152|    204|  : ((code >= 1) && (code <= 11)) ? (code - 1) \
  |  |  ------------------
  |  |  |  Branch (152:6): [True: 204, False: 0]
  |  |  |  Branch (152:21): [True: 6, False: 198]
  |  |  ------------------
  |  |  153|    204|  : ((code >= 11) && (code <= 35)) ? (code - 0) \
  |  |  ------------------
  |  |  |  Branch (153:6): [True: 198, False: 0]
  |  |  |  Branch (153:22): [True: 198, False: 0]
  |  |  ------------------
  |  |  154|    198|  : ((code >= 35) && (code <= 40)) ? (code - -1) \
  |  |  ------------------
  |  |  |  Branch (154:6): [True: 0, False: 0]
  |  |  |  Branch (154:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  155|      0|  : ((code >= 42) && (code <= 57)) ? (code - 0) \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  Branch (155:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|  : ((code >= 59) && (code <= 95)) ? (code - 1) \
  |  |  ------------------
  |  |  |  Branch (156:6): [True: 0, False: 0]
  |  |  |  Branch (156:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|  : ((code >= 95) && (code <= 125)) ? (code - 0) \
  |  |  ------------------
  |  |  |  Branch (157:6): [True: 0, False: 0]
  |  |  |  Branch (157:22): [True: 0, False: 0]
  |  |  ------------------
  |  |  158|      0|  : -1)
  ------------------
   64|       |
   65|    204|  if (idx < 0)
  ------------------
  |  Branch (65:7): [True: 0, False: 204]
  ------------------
   66|      0|    return GPG_ERR_UNKNOWN_ERRNO;
   67|       |
   68|    204|  return GPG_ERR_SYSTEM_ERROR | err_code_from_index[idx];
  ------------------
  |  |  584|    204|#define GPG_ERR_SYSTEM_ERROR	(1 << 15)
  ------------------
   69|    204|}

_gpg_err_code_to_errno:
   33|    198|{
   34|    198|  if (!(code & GPG_ERR_SYSTEM_ERROR))
  ------------------
  |  |  584|    198|#define GPG_ERR_SYSTEM_ERROR	(1 << 15)
  ------------------
  |  Branch (34:7): [True: 0, False: 198]
  ------------------
   35|      0|    return 0;
   36|    198|  code &= ~GPG_ERR_SYSTEM_ERROR;
  ------------------
  |  |  584|    198|#define GPG_ERR_SYSTEM_ERROR	(1 << 15)
  ------------------
   37|       |
   38|    198|  if (code < sizeof (err_code_to_errno) / sizeof (err_code_to_errno[0]))
  ------------------
  |  Branch (38:7): [True: 198, False: 0]
  ------------------
   39|    198|    return err_code_to_errno[code];
   40|      0|  else
   41|      0|    return 0;
   42|    198|}

strerror.c:msgidxof:
  913|    171|{
  914|    171|  return (0 ? 0
  ------------------
  |  Branch (914:11): [Folded - Ignored]
  ------------------
  915|    171|  : ((code >= 0) && (code <= 213)) ? (code - 0)
  ------------------
  |  Branch (915:6): [True: 171, False: 0]
  |  Branch (915:21): [True: 171, False: 0]
  ------------------
  916|    171|  : ((code >= 217) && (code <= 271)) ? (code - 3)
  ------------------
  |  Branch (916:6): [True: 0, False: 0]
  |  Branch (916:23): [True: 0, False: 0]
  ------------------
  917|      0|  : ((code >= 273) && (code <= 281)) ? (code - 4)
  ------------------
  |  Branch (917:6): [True: 0, False: 0]
  |  Branch (917:23): [True: 0, False: 0]
  ------------------
  918|      0|  : ((code >= 300) && (code <= 319)) ? (code - 22)
  ------------------
  |  Branch (918:6): [True: 0, False: 0]
  |  Branch (918:23): [True: 0, False: 0]
  ------------------
  919|      0|  : ((code >= 666) && (code <= 666)) ? (code - 368)
  ------------------
  |  Branch (919:6): [True: 0, False: 0]
  |  Branch (919:23): [True: 0, False: 0]
  ------------------
  920|      0|  : ((code >= 711) && (code <= 718)) ? (code - 412)
  ------------------
  |  Branch (920:6): [True: 0, False: 0]
  |  Branch (920:23): [True: 0, False: 0]
  ------------------
  921|      0|  : ((code >= 721) && (code <= 729)) ? (code - 414)
  ------------------
  |  Branch (921:6): [True: 0, False: 0]
  |  Branch (921:23): [True: 0, False: 0]
  ------------------
  922|      0|  : ((code >= 750) && (code <= 752)) ? (code - 434)
  ------------------
  |  Branch (922:6): [True: 0, False: 0]
  |  Branch (922:23): [True: 0, False: 0]
  ------------------
  923|      0|  : ((code >= 754) && (code <= 782)) ? (code - 435)
  ------------------
  |  Branch (923:6): [True: 0, False: 0]
  |  Branch (923:23): [True: 0, False: 0]
  ------------------
  924|      0|  : ((code >= 784) && (code <= 789)) ? (code - 436)
  ------------------
  |  Branch (924:6): [True: 0, False: 0]
  |  Branch (924:23): [True: 0, False: 0]
  ------------------
  925|      0|  : ((code >= 800) && (code <= 804)) ? (code - 446)
  ------------------
  |  Branch (925:6): [True: 0, False: 0]
  |  Branch (925:23): [True: 0, False: 0]
  ------------------
  926|      0|  : ((code >= 815) && (code <= 822)) ? (code - 456)
  ------------------
  |  Branch (926:6): [True: 0, False: 0]
  |  Branch (926:23): [True: 0, False: 0]
  ------------------
  927|      0|  : ((code >= 832) && (code <= 839)) ? (code - 465)
  ------------------
  |  Branch (927:6): [True: 0, False: 0]
  |  Branch (927:23): [True: 0, False: 0]
  ------------------
  928|      0|  : ((code >= 844) && (code <= 844)) ? (code - 469)
  ------------------
  |  Branch (928:6): [True: 0, False: 0]
  |  Branch (928:23): [True: 0, False: 0]
  ------------------
  929|      0|  : ((code >= 848) && (code <= 848)) ? (code - 472)
  ------------------
  |  Branch (929:6): [True: 0, False: 0]
  |  Branch (929:23): [True: 0, False: 0]
  ------------------
  930|      0|  : ((code >= 881) && (code <= 891)) ? (code - 504)
  ------------------
  |  Branch (930:6): [True: 0, False: 0]
  |  Branch (930:23): [True: 0, False: 0]
  ------------------
  931|      0|  : ((code >= 1024) && (code <= 1039)) ? (code - 636)
  ------------------
  |  Branch (931:6): [True: 0, False: 0]
  |  Branch (931:24): [True: 0, False: 0]
  ------------------
  932|      0|  : ((code >= 1500) && (code <= 1528)) ? (code - 1096)
  ------------------
  |  Branch (932:6): [True: 0, False: 0]
  |  Branch (932:24): [True: 0, False: 0]
  ------------------
  933|      0|  : ((code >= 1600) && (code <= 1601)) ? (code - 1167)
  ------------------
  |  Branch (933:6): [True: 0, False: 0]
  |  Branch (933:24): [True: 0, False: 0]
  ------------------
  934|      0|  : ((code >= 16381) && (code <= 16383)) ? (code - 15946)
  ------------------
  |  Branch (934:6): [True: 0, False: 0]
  |  Branch (934:25): [True: 0, False: 0]
  ------------------
  935|      0|  : 16384 - 15946);
  936|    171|}

strsource.c:msgidxof:
   83|     11|{
   84|     11|  return (0 ? 0
  ------------------
  |  Branch (84:11): [Folded - Ignored]
  ------------------
   85|     11|  : ((code >= 0) && (code <= 17)) ? (code - 0)
  ------------------
  |  Branch (85:6): [True: 11, False: 0]
  |  Branch (85:21): [True: 11, False: 0]
  ------------------
   86|     11|  : ((code >= 31) && (code <= 35)) ? (code - 13)
  ------------------
  |  Branch (86:6): [True: 0, False: 0]
  |  Branch (86:22): [True: 0, False: 0]
  ------------------
   87|      0|  : 36 - 13);
   88|     11|}

_gpgrt_estream_format:
 1492|  43.0k|{
 1493|       |  /* Buffer to hold the argspecs and a pointer to it.*/
 1494|  43.0k|  struct argspec_s argspecs_buffer[DEFAULT_MAX_ARGSPECS];
 1495|  43.0k|  argspec_t argspecs = argspecs_buffer;
 1496|  43.0k|  size_t argspecs_len;  /* Number of specifications in ARGSPECS.  */
 1497|       |
 1498|       |  /* Buffer to hold the description for the values.  */
 1499|  43.0k|  struct valueitem_s valuetable_buffer[DEFAULT_MAX_VALUES];
 1500|  43.0k|  valueitem_t valuetable = valuetable_buffer;
 1501|       |
 1502|  43.0k|  int rc;        /* Return code. */
 1503|  43.0k|  size_t argidx; /* Used to index the argspecs array.  */
 1504|  43.0k|  size_t validx; /* Used to index the valuetable.  */
 1505|  43.0k|  int max_pos;   /* Highest argument position.  */
 1506|       |
 1507|  43.0k|  size_t nbytes = 0; /* Keep track of the number of bytes passed to
 1508|       |                        the output function.  */
 1509|       |
 1510|  43.0k|  int myerrno = errno; /* Save the errno for use with "%m". */
 1511|       |
 1512|       |
 1513|       |  /* Parse the arguments to come up with descriptive list.  We can't
 1514|       |     do this on the fly because we need to support positional
 1515|       |     arguments. */
 1516|  43.0k|  rc = parse_format (format, &argspecs, DIM(argspecs_buffer), &argspecs_len);
  ------------------
  |  |   93|  43.0k|# define DIM(array) (sizeof (array) / sizeof (*array))
  ------------------
 1517|  43.0k|  if (rc)
  ------------------
  |  Branch (1517:7): [True: 0, False: 43.0k]
  ------------------
 1518|      0|    goto leave;
 1519|       |
 1520|       |  /* Check that all ARG_POS fields are set.  */
 1521|   103k|  for (argidx=0,max_pos=0; argidx < argspecs_len; argidx++)
  ------------------
  |  Branch (1521:28): [True: 60.0k, False: 43.0k]
  ------------------
 1522|  60.0k|    {
 1523|  60.0k|      if (argspecs[argidx].arg_pos != -1
  ------------------
  |  Branch (1523:11): [True: 60.0k, False: 0]
  ------------------
 1524|  60.0k|          && argspecs[argidx].arg_pos > max_pos)
  ------------------
  |  Branch (1524:14): [True: 0, False: 60.0k]
  ------------------
 1525|      0|        max_pos = argspecs[argidx].arg_pos;
 1526|  60.0k|      if (argspecs[argidx].width_pos > max_pos)
  ------------------
  |  Branch (1526:11): [True: 0, False: 60.0k]
  ------------------
 1527|      0|        max_pos = argspecs[argidx].width_pos;
 1528|  60.0k|      if (argspecs[argidx].precision_pos > max_pos)
  ------------------
  |  Branch (1528:11): [True: 0, False: 60.0k]
  ------------------
 1529|      0|        max_pos = argspecs[argidx].precision_pos;
 1530|  60.0k|    }
 1531|  43.0k|  if (!max_pos)
  ------------------
  |  Branch (1531:7): [True: 43.0k, False: 0]
  ------------------
 1532|  43.0k|    {
 1533|       |      /* Fill in all the positions.  */
 1534|   103k|      for (argidx=0; argidx < argspecs_len; argidx++)
  ------------------
  |  Branch (1534:22): [True: 60.0k, False: 43.0k]
  ------------------
 1535|  60.0k|        {
 1536|  60.0k|          if (argspecs[argidx].width == STAR_FIELD_VALUE)
  ------------------
  |  |  133|  60.0k|#define STAR_FIELD_VALUE (-2)
  ------------------
  |  Branch (1536:15): [True: 0, False: 60.0k]
  ------------------
 1537|      0|            argspecs[argidx].width_pos = ++max_pos;
 1538|  60.0k|          if (argspecs[argidx].precision == STAR_FIELD_VALUE)
  ------------------
  |  |  133|  60.0k|#define STAR_FIELD_VALUE (-2)
  ------------------
  |  Branch (1538:15): [True: 3, False: 60.0k]
  ------------------
 1539|      3|            argspecs[argidx].precision_pos = ++max_pos;
 1540|  60.0k|          if (argspecs[argidx].arg_pos != -1 )
  ------------------
  |  Branch (1540:15): [True: 60.0k, False: 0]
  ------------------
 1541|  60.0k|            argspecs[argidx].arg_pos = ++max_pos;
 1542|  60.0k|        }
 1543|  43.0k|    }
 1544|      0|  else
 1545|      0|    {
 1546|       |      /* Check that they are all filled.   More test are done later.  */
 1547|      0|      for (argidx=0; argidx < argspecs_len; argidx++)
  ------------------
  |  Branch (1547:22): [True: 0, False: 0]
  ------------------
 1548|      0|        {
 1549|      0|          if (!argspecs[argidx].arg_pos
  ------------------
  |  Branch (1549:15): [True: 0, False: 0]
  ------------------
 1550|      0|              || (argspecs[argidx].width == STAR_FIELD_VALUE
  ------------------
  |  |  133|      0|#define STAR_FIELD_VALUE (-2)
  ------------------
  |  Branch (1550:19): [True: 0, False: 0]
  ------------------
 1551|      0|                  && !argspecs[argidx].width_pos)
  ------------------
  |  Branch (1551:22): [True: 0, False: 0]
  ------------------
 1552|      0|              || (argspecs[argidx].precision == STAR_FIELD_VALUE
  ------------------
  |  |  133|      0|#define STAR_FIELD_VALUE (-2)
  ------------------
  |  Branch (1552:19): [True: 0, False: 0]
  ------------------
 1553|      0|                  && !argspecs[argidx].precision_pos))
  ------------------
  |  Branch (1553:22): [True: 0, False: 0]
  ------------------
 1554|      0|            goto leave_einval;
 1555|      0|        }
 1556|      0|    }
 1557|       |  /* Check that there is no overflow in max_pos and that it has a
 1558|       |     reasonable length.  There may never be more elements than the
 1559|       |     number of characters in FORMAT.  */
 1560|  43.0k|  if (max_pos < 0 || max_pos >= strlen (format))
  ------------------
  |  Branch (1560:7): [True: 0, False: 43.0k]
  |  Branch (1560:22): [True: 0, False: 43.0k]
  ------------------
 1561|      0|    goto leave_einval;
 1562|       |
 1563|       |#ifdef DEBUG
 1564|       |    dump_argspecs (argspecs, argspecs_len);
 1565|       |#endif
 1566|       |
 1567|       |  /* Allocate a table to hold the values.  If it is small enough we
 1568|       |     use a stack allocated buffer.  */
 1569|  43.0k|  if (max_pos > DIM(valuetable_buffer))
  ------------------
  |  |   93|  43.0k|# define DIM(array) (sizeof (array) / sizeof (*array))
  ------------------
  |  Branch (1569:7): [True: 0, False: 43.0k]
  ------------------
 1570|      0|    {
 1571|      0|      valuetable = calloc (max_pos, sizeof *valuetable);
 1572|      0|      if (!valuetable)
  ------------------
  |  Branch (1572:11): [True: 0, False: 0]
  ------------------
 1573|      0|        goto leave_error;
 1574|      0|    }
 1575|  43.0k|  else
 1576|  43.0k|    {
 1577|   387k|      for (validx=0; validx < DIM(valuetable_buffer); validx++)
  ------------------
  |  |   93|   387k|# define DIM(array) (sizeof (array) / sizeof (*array))
  ------------------
  |  Branch (1577:22): [True: 344k, False: 43.0k]
  ------------------
 1578|   344k|        {
 1579|   344k|          valuetable[validx].vt = VALTYPE_UNSUPPORTED;
 1580|   344k|          memset (&valuetable[validx].value, 0,
 1581|   344k|                  sizeof valuetable[validx].value);
 1582|   344k|        }
 1583|  43.0k|    }
 1584|   103k|  for (argidx=0; argidx < argspecs_len; argidx++)
  ------------------
  |  Branch (1584:18): [True: 60.0k, False: 43.0k]
  ------------------
 1585|  60.0k|    {
 1586|  60.0k|      if (argspecs[argidx].arg_pos != - 1)
  ------------------
  |  Branch (1586:11): [True: 60.0k, False: 0]
  ------------------
 1587|  60.0k|        {
 1588|  60.0k|          validx = argspecs[argidx].arg_pos - 1;
 1589|  60.0k|          if (valuetable[validx].vt)
  ------------------
  |  Branch (1589:15): [True: 0, False: 60.0k]
  ------------------
 1590|      0|            goto leave_einval; /* Already defined. */
 1591|  60.0k|          valuetable[validx].vt = argspecs[argidx].vt;
 1592|  60.0k|        }
 1593|  60.0k|      if (argspecs[argidx].width == STAR_FIELD_VALUE)
  ------------------
  |  |  133|  60.0k|#define STAR_FIELD_VALUE (-2)
  ------------------
  |  Branch (1593:11): [True: 0, False: 60.0k]
  ------------------
 1594|      0|        {
 1595|      0|          validx = argspecs[argidx].width_pos - 1;
 1596|      0|          if (valuetable[validx].vt)
  ------------------
  |  Branch (1596:15): [True: 0, False: 0]
  ------------------
 1597|      0|            goto leave_einval; /* Already defined.  */
 1598|      0|          valuetable[validx].vt = VALTYPE_INT;
 1599|      0|        }
 1600|  60.0k|      if (argspecs[argidx].precision == STAR_FIELD_VALUE)
  ------------------
  |  |  133|  60.0k|#define STAR_FIELD_VALUE (-2)
  ------------------
  |  Branch (1600:11): [True: 3, False: 60.0k]
  ------------------
 1601|      3|        {
 1602|      3|          validx = argspecs[argidx].precision_pos - 1;
 1603|      3|          if (valuetable[validx].vt)
  ------------------
  |  Branch (1603:15): [True: 0, False: 3]
  ------------------
 1604|      0|            goto leave_einval; /* Already defined.  */
 1605|      3|          valuetable[validx].vt = VALTYPE_INT;
 1606|      3|        }
 1607|  60.0k|    }
 1608|       |
 1609|       |  /* Read all the arguments.  This will error out for unsupported
 1610|       |     types and for not given positional arguments. */
 1611|  43.0k|  rc = read_values (valuetable, max_pos, vaargs);
 1612|  43.0k|  if (rc)
  ------------------
  |  Branch (1612:7): [True: 0, False: 43.0k]
  ------------------
 1613|      0|    goto leave_einval;
 1614|       |
 1615|       |/*   for (validx=0; validx < max_pos; validx++) */
 1616|       |/*     fprintf (stderr, "%2d: vt=%d\n", validx, valuetable[validx].vt); */
 1617|       |
 1618|       |  /* Everything has been collected, go ahead with the formatting.  */
 1619|  43.0k|  rc = do_format (outfnc, outfncarg, sf, sfvalue, format,
 1620|  43.0k|                  argspecs, argspecs_len, valuetable, myerrno, &nbytes);
 1621|       |
 1622|  43.0k|  goto leave;
 1623|       |
 1624|      0| leave_einval:
 1625|      0|  _set_errno (EINVAL);
  ------------------
  |  |  113|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (113:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1626|      0| leave_error:
 1627|      0|  rc = -1;
 1628|  43.0k| leave:
 1629|  43.0k|  if (valuetable != valuetable_buffer)
  ------------------
  |  Branch (1629:7): [True: 0, False: 43.0k]
  ------------------
 1630|      0|    free (valuetable);
 1631|  43.0k|  if (argspecs != argspecs_buffer)
  ------------------
  |  Branch (1631:7): [True: 2.93k, False: 40.1k]
  ------------------
 1632|  2.93k|    free (argspecs);
 1633|  43.0k|  return rc;
 1634|      0|}
_gpgrt_estream_vsnprintf:
 1733|  5.97k|{
 1734|  5.97k|  struct fixed_buffer_parm_s parm;
 1735|  5.97k|  int rc;
 1736|       |
 1737|  5.97k|  parm.size = bufsize;
 1738|  5.97k|  parm.count = 0;
 1739|  5.97k|  parm.used = 0;
 1740|  5.97k|  parm.buffer = bufsize?buf:NULL;
  ------------------
  |  Branch (1740:17): [True: 5.97k, False: 0]
  ------------------
 1741|  5.97k|  rc = _gpgrt_estream_format (fixed_buffer_out, &parm, NULL, NULL,
 1742|  5.97k|                              format, arg_ptr);
 1743|  5.97k|  if (!rc)
  ------------------
  |  Branch (1743:7): [True: 5.97k, False: 0]
  ------------------
 1744|  5.97k|    rc = fixed_buffer_out (&parm, "", 1); /* Print terminating Nul.  */
 1745|  5.97k|  if (rc == -1)
  ------------------
  |  Branch (1745:7): [True: 0, False: 5.97k]
  ------------------
 1746|      0|    return -1;
 1747|  5.97k|  if (bufsize && buf && parm.size && parm.count >= parm.size)
  ------------------
  |  Branch (1747:7): [True: 5.97k, False: 0]
  |  Branch (1747:18): [True: 5.97k, False: 0]
  |  Branch (1747:25): [True: 5.97k, False: 0]
  |  Branch (1747:38): [True: 0, False: 5.97k]
  ------------------
 1748|      0|    buf[parm.size-1] = 0;
 1749|       |
 1750|  5.97k|  parm.count--; /* Do not count the trailing nul.  */
 1751|  5.97k|  return (int)parm.count; /* Return number of bytes which would have
 1752|       |                             been written.  */
 1753|  5.97k|}
_gpgrt_estream_vasprintf:
 1823|  2.08k|{
 1824|  2.08k|  struct dynamic_buffer_parm_s parm;
 1825|  2.08k|  int rc;
 1826|       |
 1827|  2.08k|  parm.error_flag = 0;
 1828|  2.08k|  parm.alloced = 512;
 1829|  2.08k|  parm.used = 0;
 1830|  2.08k|  parm.buffer = my_printf_realloc (NULL, parm.alloced);
  ------------------
  |  |  107|  2.08k|#define my_printf_realloc(a,b) _ESTREAM_PRINTF_REALLOC((a),(b))
  |  |  ------------------
  |  |  |  |  349|  2.08k|#define _ESTREAM_PRINTF_REALLOC _gpgrt_realloc
  |  |  ------------------
  ------------------
 1831|  2.08k|  if (!parm.buffer)
  ------------------
  |  Branch (1831:7): [True: 0, False: 2.08k]
  ------------------
 1832|      0|    {
 1833|      0|      *bufp = NULL;
 1834|      0|      return -1;
 1835|      0|    }
 1836|       |
 1837|  2.08k|  rc = _gpgrt_estream_format (dynamic_buffer_out, &parm, NULL, NULL,
 1838|  2.08k|                              format, arg_ptr);
 1839|  2.08k|  if (!rc)
  ------------------
  |  Branch (1839:7): [True: 2.08k, False: 0]
  ------------------
 1840|  2.08k|    rc = dynamic_buffer_out (&parm, "", 1); /* Print terminating Nul.  */
 1841|       |  /* Fixme: Should we shrink the resulting buffer?  */
 1842|  2.08k|  if (rc != -1 && parm.error_flag)
  ------------------
  |  Branch (1842:7): [True: 2.08k, False: 0]
  |  Branch (1842:19): [True: 0, False: 2.08k]
  ------------------
 1843|      0|    {
 1844|      0|      rc = -1;
 1845|      0|      _set_errno (parm.error_flag);
  ------------------
  |  |  113|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (113:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1846|      0|    }
 1847|  2.08k|  if (rc == -1)
  ------------------
  |  Branch (1847:7): [True: 0, False: 2.08k]
  ------------------
 1848|      0|    {
 1849|      0|      memset (parm.buffer, 0, parm.used);
 1850|      0|      if (parm.buffer)
  ------------------
  |  Branch (1850:11): [True: 0, False: 0]
  ------------------
 1851|      0|        my_printf_realloc (parm.buffer, 0);
  ------------------
  |  |  107|      0|#define my_printf_realloc(a,b) _ESTREAM_PRINTF_REALLOC((a),(b))
  |  |  ------------------
  |  |  |  |  349|      0|#define _ESTREAM_PRINTF_REALLOC _gpgrt_realloc
  |  |  ------------------
  ------------------
 1852|      0|      *bufp = NULL;
 1853|      0|      return -1;
 1854|      0|    }
 1855|  2.08k|  gpgrt_assert (parm.used);   /* We have at least the terminating Nul.  */
  ------------------
  |  |  577|  2.08k|  ((expr)                                                       \
  |  |  ------------------
  |  |  |  Branch (577:4): [True: 2.08k, False: 0]
  |  |  ------------------
  |  |  578|  2.08k|   ? (void) 0                                                   \
  |  |  579|  2.08k|   : _gpgrt__log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
  ------------------
 1856|      0|  *bufp = parm.buffer;
 1857|  2.08k|  return parm.used - 1; /* Do not include that Nul. */
 1858|  2.08k|}
estream-printf.c:parse_format:
  445|  43.0k|{
  446|  43.0k|  const char *s;
  447|  43.0k|  argspec_t argspecs = *argspecs_addr;
  448|  43.0k|  argspec_t arg;
  449|  43.0k|  size_t argcount = 0;
  450|       |
  451|  43.0k|  if (!format)
  ------------------
  |  Branch (451:7): [True: 0, False: 43.0k]
  ------------------
  452|      0|    goto leave_einval;
  453|       |
  454|   971k|  for (; *format; format++)
  ------------------
  |  Branch (454:10): [True: 928k, False: 43.0k]
  ------------------
  455|   928k|    {
  456|   928k|      unsigned int flags;
  457|   928k|      int width, precision;
  458|   928k|      lenmod_t lenmod;
  459|   928k|      conspec_t conspec;
  460|   928k|      int arg_pos, width_pos, precision_pos;
  461|       |
  462|   928k|      if (*format != '%')
  ------------------
  |  Branch (462:11): [True: 868k, False: 60.0k]
  ------------------
  463|   868k|        continue;
  464|  60.0k|      s = ++format;
  465|  60.0k|      if (!*s)
  ------------------
  |  Branch (465:11): [True: 0, False: 60.0k]
  ------------------
  466|      0|        goto leave_einval;
  467|  60.0k|      if (*s == '%')
  ------------------
  |  Branch (467:11): [True: 0, False: 60.0k]
  ------------------
  468|      0|        continue; /* Just a quoted percent.  */
  469|       |
  470|       |      /* First check whether there is a positional argument.  */
  471|  60.0k|      arg_pos = 0; /* No positional argument given.  */
  472|  60.0k|      if (*s >= '1' && *s <= '9')
  ------------------
  |  Branch (472:11): [True: 11.4k, False: 48.5k]
  |  Branch (472:24): [True: 3, False: 11.4k]
  ------------------
  473|      3|        {
  474|      3|          const char *save_s = s;
  475|       |
  476|      3|          arg_pos = (*s++ - '0');
  477|      6|          for (; *s >= '0' && *s <= '9'; s++)
  ------------------
  |  Branch (477:18): [True: 6, False: 0]
  |  Branch (477:31): [True: 3, False: 3]
  ------------------
  478|      3|            arg_pos = 10*arg_pos + (*s - '0');
  479|      3|          if (arg_pos < 0)
  ------------------
  |  Branch (479:15): [True: 0, False: 3]
  ------------------
  480|      0|            goto leave_einval; /* Overflow during conversion.  */
  481|      3|          if (*s == '$')
  ------------------
  |  Branch (481:15): [True: 0, False: 3]
  ------------------
  482|      0|            s++;
  483|      3|          else
  484|      3|            {
  485|      3|              arg_pos = 0;
  486|      3|              s = save_s;
  487|      3|            }
  488|      3|        }
  489|       |
  490|       |      /* Parse the flags.  */
  491|  60.0k|      flags = 0;
  492|   108k|      for ( ; *s; s++)
  ------------------
  |  Branch (492:15): [True: 108k, False: 0]
  ------------------
  493|   108k|        {
  494|   108k|          switch (*s)
  495|   108k|            {
  496|      0|            case '\'': flags |= FLAG_GROUPING; break;
  ------------------
  |  |  136|      0|#define FLAG_GROUPING   1
  ------------------
  |  Branch (496:13): [True: 0, False: 108k]
  ------------------
  497|      0|            case '-': flags |= FLAG_LEFT_JUST; break;
  ------------------
  |  |  137|      0|#define FLAG_LEFT_JUST  2
  ------------------
  |  Branch (497:13): [True: 0, False: 108k]
  ------------------
  498|      0|            case '+': flags |= FLAG_PLUS_SIGN; break;
  ------------------
  |  |  138|      0|#define FLAG_PLUS_SIGN  4
  ------------------
  |  Branch (498:13): [True: 0, False: 108k]
  ------------------
  499|      0|            case ' ': flags |= FLAG_SPACE_PLUS; break;
  ------------------
  |  |  139|      0|#define FLAG_SPACE_PLUS 8
  ------------------
  |  Branch (499:13): [True: 0, False: 108k]
  ------------------
  500|      0|            case '#': flags |= FLAG_ALT_CONV; break;
  ------------------
  |  |  140|      0|#define FLAG_ALT_CONV   16
  ------------------
  |  Branch (500:13): [True: 0, False: 108k]
  ------------------
  501|  48.5k|            case '0': flags |= FLAG_ZERO_PAD; break;
  ------------------
  |  |  141|  48.5k|#define FLAG_ZERO_PAD   32
  ------------------
  |  Branch (501:13): [True: 48.5k, False: 60.0k]
  ------------------
  502|  60.0k|            default:
  ------------------
  |  Branch (502:13): [True: 60.0k, False: 48.5k]
  ------------------
  503|  60.0k|              goto flags_parsed;
  504|   108k|            }
  505|   108k|        }
  506|  60.0k|    flags_parsed:
  507|       |
  508|       |      /* Parse the field width.  */
  509|  60.0k|      width_pos = 0;
  510|  60.0k|      if (*s == '*')
  ------------------
  |  Branch (510:11): [True: 0, False: 60.0k]
  ------------------
  511|      0|        {
  512|      0|          width = STAR_FIELD_VALUE;
  ------------------
  |  |  133|      0|#define STAR_FIELD_VALUE (-2)
  ------------------
  513|      0|          s++;
  514|       |          /* If we have a positional argument, another one might also
  515|       |             be used to give the position of the star's value. */
  516|      0|          if (arg_pos && *s >= '1' && *s <= '9')
  ------------------
  |  Branch (516:15): [True: 0, False: 0]
  |  Branch (516:26): [True: 0, False: 0]
  |  Branch (516:39): [True: 0, False: 0]
  ------------------
  517|      0|            {
  518|      0|              width_pos = (*s++ - '0');
  519|      0|              for (; *s >= '0' && *s <= '9'; s++)
  ------------------
  |  Branch (519:22): [True: 0, False: 0]
  |  Branch (519:35): [True: 0, False: 0]
  ------------------
  520|      0|                width_pos = 10*width_pos + (*s - '0');
  521|      0|              if (width_pos < 1)
  ------------------
  |  Branch (521:19): [True: 0, False: 0]
  ------------------
  522|      0|                goto leave_einval; /* Overflow during conversion.  */
  523|      0|              if (*s != '$')
  ------------------
  |  Branch (523:19): [True: 0, False: 0]
  ------------------
  524|      0|                goto leave_einval; /* Not followed by $.  */
  525|      0|              s++;
  526|      0|            }
  527|      0|        }
  528|  60.0k|      else if ( *s >= '0' && *s <= '9')
  ------------------
  |  Branch (528:17): [True: 60.0k, False: 3]
  |  Branch (528:30): [True: 48.5k, False: 11.4k]
  ------------------
  529|  48.5k|        {
  530|  48.5k|          width = (*s++ - '0');
  531|  48.5k|          for (; *s >= '0' && *s <= '9'; s++)
  ------------------
  |  Branch (531:18): [True: 48.5k, False: 0]
  |  Branch (531:31): [True: 3, False: 48.5k]
  ------------------
  532|      3|            {
  533|      3|              if (!width && *s == '0')
  ------------------
  |  Branch (533:19): [True: 0, False: 3]
  |  Branch (533:29): [True: 0, False: 0]
  ------------------
  534|      0|                goto leave_einval; /* Leading zeroes are not allowed.
  535|       |                                      Fixme: check what other
  536|       |                                      implementations do. */
  537|      3|              width = 10*width + (*s - '0');
  538|      3|            }
  539|  48.5k|          if (width < 0)
  ------------------
  |  Branch (539:15): [True: 0, False: 48.5k]
  ------------------
  540|      0|            goto leave_einval; /* Overflow during conversion.  */
  541|  48.5k|        }
  542|  11.4k|      else
  543|  11.4k|        width = NO_FIELD_VALUE;
  ------------------
  |  |  132|  11.4k|#define NO_FIELD_VALUE   (-1)
  ------------------
  544|       |
  545|       |      /* Parse the precision.  */
  546|  60.0k|      precision_pos = 0;
  547|  60.0k|      precision = NO_FIELD_VALUE;
  ------------------
  |  |  132|  60.0k|#define NO_FIELD_VALUE   (-1)
  ------------------
  548|  60.0k|      if (*s == '.')
  ------------------
  |  Branch (548:11): [True: 3, False: 60.0k]
  ------------------
  549|      3|        {
  550|      3|          int ignore_value = (s[1] == '-');
  551|       |
  552|      3|          s++;
  553|      3|          if (*s == '*')
  ------------------
  |  Branch (553:15): [True: 3, False: 0]
  ------------------
  554|      3|            {
  555|      3|              precision = STAR_FIELD_VALUE;
  ------------------
  |  |  133|      3|#define STAR_FIELD_VALUE (-2)
  ------------------
  556|      3|              s++;
  557|       |              /* If we have a positional argument, another one might also
  558|       |                 be used to give the position of the star's value. */
  559|      3|              if (arg_pos && *s >= '1' && *s <= '9')
  ------------------
  |  Branch (559:19): [True: 0, False: 3]
  |  Branch (559:30): [True: 0, False: 0]
  |  Branch (559:43): [True: 0, False: 0]
  ------------------
  560|      0|                {
  561|      0|                  precision_pos = (*s++ - '0');
  562|      0|                  for (; *s >= '0' && *s <= '9'; s++)
  ------------------
  |  Branch (562:26): [True: 0, False: 0]
  |  Branch (562:39): [True: 0, False: 0]
  ------------------
  563|      0|                    precision_pos = 10*precision_pos + (*s - '0');
  564|      0|                  if (precision_pos < 1)
  ------------------
  |  Branch (564:23): [True: 0, False: 0]
  ------------------
  565|      0|                    goto leave_einval; /* Overflow during conversion.  */
  566|      0|                  if (*s != '$')
  ------------------
  |  Branch (566:23): [True: 0, False: 0]
  ------------------
  567|      0|                    goto leave_einval; /* Not followed by $.  */
  568|      0|                  s++;
  569|      0|                }
  570|      3|            }
  571|      0|          else if ( *s >= '0' && *s <= '9')
  ------------------
  |  Branch (571:21): [True: 0, False: 0]
  |  Branch (571:34): [True: 0, False: 0]
  ------------------
  572|      0|            {
  573|      0|              precision = (*s++ - '0');
  574|      0|              for (; *s >= '0' && *s <= '9'; s++)
  ------------------
  |  Branch (574:22): [True: 0, False: 0]
  |  Branch (574:35): [True: 0, False: 0]
  ------------------
  575|      0|                {
  576|      0|                  if (!precision && *s == '0')
  ------------------
  |  Branch (576:23): [True: 0, False: 0]
  |  Branch (576:37): [True: 0, False: 0]
  ------------------
  577|      0|                    goto leave_einval; /* Leading zeroes are not allowed.
  578|       |                                          Fixme: check what other
  579|       |                                          implementations do. */
  580|      0|                  precision = 10*precision + (*s - '0');
  581|      0|                }
  582|      0|              if (precision < 0)
  ------------------
  |  Branch (582:19): [True: 0, False: 0]
  ------------------
  583|      0|                goto leave_einval; /* Overflow during conversion.  */
  584|      0|            }
  585|      0|          else
  586|      0|            precision = 0;
  587|      3|          if (ignore_value)
  ------------------
  |  Branch (587:15): [True: 0, False: 3]
  ------------------
  588|      0|            precision = NO_FIELD_VALUE;
  ------------------
  |  |  132|      0|#define NO_FIELD_VALUE   (-1)
  ------------------
  589|      3|        }
  590|       |
  591|       |      /* Parse the length modifiers.  */
  592|  60.0k|      switch (*s)
  593|  60.0k|        {
  594|      0|        case 'h':
  ------------------
  |  Branch (594:9): [True: 0, False: 60.0k]
  ------------------
  595|      0|          if (s[1] == 'h')
  ------------------
  |  Branch (595:15): [True: 0, False: 0]
  ------------------
  596|      0|            {
  597|      0|              lenmod = LENMOD_CHAR;
  598|      0|              s++;
  599|      0|            }
  600|      0|          else
  601|      0|            lenmod = LENMOD_SHORT;
  602|      0|          s++;
  603|      0|          break;
  604|  9.15k|        case 'l':
  ------------------
  |  Branch (604:9): [True: 9.15k, False: 50.8k]
  ------------------
  605|  9.15k|          if (s[1] == 'l')
  ------------------
  |  Branch (605:15): [True: 1.46k, False: 7.68k]
  ------------------
  606|  1.46k|            {
  607|  1.46k|              lenmod = LENMOD_LONGLONG;
  608|  1.46k|              s++;
  609|  1.46k|            }
  610|  7.68k|          else
  611|  7.68k|            lenmod = LENMOD_LONG;
  612|  9.15k|          s++;
  613|  9.15k|          break;
  614|      0|        case 'j': lenmod = LENMOD_INTMAX; s++; break;
  ------------------
  |  Branch (614:9): [True: 0, False: 60.0k]
  ------------------
  615|      0|        case 'z': lenmod = LENMOD_SIZET; s++; break;
  ------------------
  |  Branch (615:9): [True: 0, False: 60.0k]
  ------------------
  616|      0|        case 't': lenmod = LENMOD_PTRDIFF; s++; break;
  ------------------
  |  Branch (616:9): [True: 0, False: 60.0k]
  ------------------
  617|      0|        case 'L': lenmod = LENMOD_LONGDBL; s++; break;
  ------------------
  |  Branch (617:9): [True: 0, False: 60.0k]
  ------------------
  618|  50.8k|        default:  lenmod = LENMOD_NONE; break;
  ------------------
  |  Branch (618:9): [True: 50.8k, False: 9.15k]
  ------------------
  619|  60.0k|        }
  620|       |
  621|       |      /* Parse the conversion specifier.  */
  622|  60.0k|      switch (*s)
  623|  60.0k|        {
  624|  11.6k|        case 'd':
  ------------------
  |  Branch (624:9): [True: 11.6k, False: 48.3k]
  ------------------
  625|  11.6k|        case 'i': conspec = CONSPEC_DECIMAL; break;
  ------------------
  |  Branch (625:9): [True: 0, False: 60.0k]
  ------------------
  626|      0|        case 'o': conspec = CONSPEC_OCTAL; break;
  ------------------
  |  Branch (626:9): [True: 0, False: 60.0k]
  ------------------
  627|    215|        case 'u': conspec = CONSPEC_UNSIGNED; break;
  ------------------
  |  Branch (627:9): [True: 215, False: 59.8k]
  ------------------
  628|  16.8k|        case 'x': conspec = CONSPEC_HEX; break;
  ------------------
  |  Branch (628:9): [True: 16.8k, False: 43.2k]
  ------------------
  629|  24.4k|        case 'X': conspec = CONSPEC_HEX_UP; break;
  ------------------
  |  Branch (629:9): [True: 24.4k, False: 35.5k]
  ------------------
  630|      0|        case 'f': conspec = CONSPEC_FLOAT; break;
  ------------------
  |  Branch (630:9): [True: 0, False: 60.0k]
  ------------------
  631|      0|        case 'F': conspec = CONSPEC_FLOAT_UP; break;
  ------------------
  |  Branch (631:9): [True: 0, False: 60.0k]
  ------------------
  632|      0|        case 'e': conspec = CONSPEC_EXP; break;
  ------------------
  |  Branch (632:9): [True: 0, False: 60.0k]
  ------------------
  633|      0|        case 'E': conspec = CONSPEC_EXP_UP; break;
  ------------------
  |  Branch (633:9): [True: 0, False: 60.0k]
  ------------------
  634|      0|        case 'g': conspec = CONSPEC_F_OR_G; break;
  ------------------
  |  Branch (634:9): [True: 0, False: 60.0k]
  ------------------
  635|      0|        case 'G': conspec = CONSPEC_F_OR_G_UP; break;
  ------------------
  |  Branch (635:9): [True: 0, False: 60.0k]
  ------------------
  636|      0|        case 'a': conspec = CONSPEC_HEX_EXP; break;
  ------------------
  |  Branch (636:9): [True: 0, False: 60.0k]
  ------------------
  637|      0|        case 'A': conspec = CONSPEC_HEX_EXP_UP; break;
  ------------------
  |  Branch (637:9): [True: 0, False: 60.0k]
  ------------------
  638|      0|        case 'c': conspec = CONSPEC_CHAR; break;
  ------------------
  |  Branch (638:9): [True: 0, False: 60.0k]
  ------------------
  639|  6.88k|        case 's': conspec = CONSPEC_STRING; break;
  ------------------
  |  Branch (639:9): [True: 6.88k, False: 53.1k]
  ------------------
  640|      4|        case 'p': conspec = CONSPEC_POINTER; break;
  ------------------
  |  Branch (640:9): [True: 4, False: 60.0k]
  ------------------
  641|      0|        case 'n': conspec = CONSPEC_BYTES_SO_FAR; break;
  ------------------
  |  Branch (641:9): [True: 0, False: 60.0k]
  ------------------
  642|      0|        case 'C': conspec = CONSPEC_CHAR; lenmod = LENMOD_LONG; break;
  ------------------
  |  Branch (642:9): [True: 0, False: 60.0k]
  ------------------
  643|      0|        case 'S': conspec = CONSPEC_STRING; lenmod = LENMOD_LONG; break;
  ------------------
  |  Branch (643:9): [True: 0, False: 60.0k]
  ------------------
  644|      0|        case 'm': conspec = CONSPEC_STRERROR; arg_pos = -1; break;
  ------------------
  |  Branch (644:9): [True: 0, False: 60.0k]
  ------------------
  645|      0|        default: conspec = CONSPEC_UNKNOWN;
  ------------------
  |  Branch (645:9): [True: 0, False: 60.0k]
  ------------------
  646|  60.0k|        }
  647|       |
  648|       |      /* Save the args. */
  649|  60.0k|      if (argcount >= max_argspecs)
  ------------------
  |  Branch (649:11): [True: 2.93k, False: 57.1k]
  ------------------
  650|  2.93k|        {
  651|       |          /* We either need to allocate a new array instead of the
  652|       |             caller provided one or realloc the array.  Instead of
  653|       |             using realloc we allocate a new one and release the
  654|       |             original one then. */
  655|  2.93k|          size_t n, newmax;
  656|  2.93k|          argspec_t newarg;
  657|       |
  658|  2.93k|          newmax = max_argspecs + ARGSPECS_BUMP_VALUE;
  ------------------
  |  |  129|  2.93k|#define ARGSPECS_BUMP_VALUE   10
  ------------------
  659|  2.93k|          if (newmax <= max_argspecs)
  ------------------
  |  Branch (659:15): [True: 0, False: 2.93k]
  ------------------
  660|      0|            goto leave_einval;  /* Too many arguments. */
  661|  2.93k|          newarg = calloc (newmax, sizeof *newarg);
  662|  2.93k|          if (!newarg)
  ------------------
  |  Branch (662:15): [True: 0, False: 2.93k]
  ------------------
  663|      0|            goto leave;
  664|  17.5k|          for (n=0; n < argcount; n++)
  ------------------
  |  Branch (664:21): [True: 14.6k, False: 2.93k]
  ------------------
  665|  14.6k|            newarg[n] = argspecs[n];
  666|  2.93k|          if (argspecs != *argspecs_addr)
  ------------------
  |  Branch (666:15): [True: 0, False: 2.93k]
  ------------------
  667|      0|            free (argspecs);
  668|  2.93k|          argspecs = newarg;
  669|  2.93k|          max_argspecs = newmax;
  670|  2.93k|        }
  671|       |
  672|  60.0k|      arg = argspecs + argcount;
  673|  60.0k|      arg->length = s - format + 2;
  674|  60.0k|      arg->flags = flags;
  675|  60.0k|      arg->width = width;
  676|  60.0k|      arg->precision = precision;
  677|  60.0k|      arg->lenmod = lenmod;
  678|  60.0k|      arg->conspec = conspec;
  679|  60.0k|      arg->arg_pos = arg_pos;
  680|  60.0k|      arg->width_pos = width_pos;
  681|  60.0k|      arg->precision_pos = precision_pos;
  682|  60.0k|      compute_type (arg);
  683|  60.0k|      argcount++;
  684|  60.0k|      format = s;
  685|  60.0k|    }
  686|       |
  687|  43.0k|  *argspecs_addr = argspecs;
  688|  43.0k|  *r_argspecs_count = argcount;
  689|  43.0k|  return 0; /* Success.  */
  690|       |
  691|      0| leave_einval:
  692|      0|  _set_errno (EINVAL);
  ------------------
  |  |  113|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (113:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
  693|      0| leave:
  694|      0|  if (argspecs != *argspecs_addr)
  ------------------
  |  Branch (694:7): [True: 0, False: 0]
  ------------------
  695|      0|    free (argspecs);
  696|      0|  *argspecs_addr = NULL;
  697|      0|  return -1;
  698|      0|}
estream-printf.c:compute_type:
  345|  60.0k|{
  346|  60.0k|  switch (arg->conspec)
  ------------------
  |  Branch (346:11): [True: 0, False: 60.0k]
  ------------------
  347|  60.0k|    {
  348|      0|    case CONSPEC_UNKNOWN:
  ------------------
  |  Branch (348:5): [True: 0, False: 60.0k]
  ------------------
  349|      0|      arg->vt = VALTYPE_UNSUPPORTED;
  350|      0|      break;
  351|       |
  352|  11.6k|    case CONSPEC_DECIMAL:
  ------------------
  |  Branch (352:5): [True: 11.6k, False: 48.3k]
  ------------------
  353|  11.6k|      switch (arg->lenmod)
  354|  11.6k|        {
  355|      0|        case LENMOD_CHAR: arg->vt = VALTYPE_SCHAR; break;
  ------------------
  |  Branch (355:9): [True: 0, False: 11.6k]
  ------------------
  356|      0|        case LENMOD_SHORT: arg->vt = VALTYPE_SHORT; break;
  ------------------
  |  Branch (356:9): [True: 0, False: 11.6k]
  ------------------
  357|      0|        case LENMOD_LONG: arg->vt = VALTYPE_LONG; break;
  ------------------
  |  Branch (357:9): [True: 0, False: 11.6k]
  ------------------
  358|  1.46k|        case LENMOD_LONGLONG: arg->vt = VALTYPE_LONGLONG; break;
  ------------------
  |  Branch (358:9): [True: 1.46k, False: 10.2k]
  ------------------
  359|      0|        case LENMOD_INTMAX: arg->vt = VALTYPE_INTMAX; break;
  ------------------
  |  Branch (359:9): [True: 0, False: 11.6k]
  ------------------
  360|      0|        case LENMOD_SIZET: arg->vt = VALTYPE_SIZE; break;
  ------------------
  |  Branch (360:9): [True: 0, False: 11.6k]
  ------------------
  361|      0|        case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF; break;
  ------------------
  |  Branch (361:9): [True: 0, False: 11.6k]
  ------------------
  362|  10.2k|        default: arg->vt = VALTYPE_INT; break;
  ------------------
  |  Branch (362:9): [True: 10.2k, False: 1.46k]
  ------------------
  363|  11.6k|        }
  364|  11.6k|      break;
  365|       |
  366|  11.6k|    case CONSPEC_OCTAL:
  ------------------
  |  Branch (366:5): [True: 0, False: 60.0k]
  ------------------
  367|    215|    case CONSPEC_UNSIGNED:
  ------------------
  |  Branch (367:5): [True: 215, False: 59.8k]
  ------------------
  368|  17.0k|    case CONSPEC_HEX:
  ------------------
  |  Branch (368:5): [True: 16.8k, False: 43.2k]
  ------------------
  369|  41.4k|    case CONSPEC_HEX_UP:
  ------------------
  |  Branch (369:5): [True: 24.4k, False: 35.5k]
  ------------------
  370|  41.4k|      switch (arg->lenmod)
  371|  41.4k|        {
  372|      0|        case LENMOD_CHAR: arg->vt = VALTYPE_UCHAR; break;
  ------------------
  |  Branch (372:9): [True: 0, False: 41.4k]
  ------------------
  373|      0|        case LENMOD_SHORT: arg->vt = VALTYPE_USHORT; break;
  ------------------
  |  Branch (373:9): [True: 0, False: 41.4k]
  ------------------
  374|  7.68k|        case LENMOD_LONG: arg->vt = VALTYPE_ULONG; break;
  ------------------
  |  Branch (374:9): [True: 7.68k, False: 33.7k]
  ------------------
  375|      0|        case LENMOD_LONGLONG: arg->vt = VALTYPE_ULONGLONG; break;
  ------------------
  |  Branch (375:9): [True: 0, False: 41.4k]
  ------------------
  376|      0|        case LENMOD_INTMAX: arg->vt = VALTYPE_UINTMAX; break;
  ------------------
  |  Branch (376:9): [True: 0, False: 41.4k]
  ------------------
  377|      0|        case LENMOD_SIZET: arg->vt = VALTYPE_SIZE; break;
  ------------------
  |  Branch (377:9): [True: 0, False: 41.4k]
  ------------------
  378|      0|        case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF; break;
  ------------------
  |  Branch (378:9): [True: 0, False: 41.4k]
  ------------------
  379|  33.7k|        default: arg->vt = VALTYPE_UINT; break;
  ------------------
  |  Branch (379:9): [True: 33.7k, False: 7.68k]
  ------------------
  380|  41.4k|        }
  381|  41.4k|      break;
  382|       |
  383|  41.4k|    case CONSPEC_FLOAT:
  ------------------
  |  Branch (383:5): [True: 0, False: 60.0k]
  ------------------
  384|      0|    case CONSPEC_FLOAT_UP:
  ------------------
  |  Branch (384:5): [True: 0, False: 60.0k]
  ------------------
  385|      0|    case CONSPEC_EXP:
  ------------------
  |  Branch (385:5): [True: 0, False: 60.0k]
  ------------------
  386|      0|    case CONSPEC_EXP_UP:
  ------------------
  |  Branch (386:5): [True: 0, False: 60.0k]
  ------------------
  387|      0|    case CONSPEC_F_OR_G:
  ------------------
  |  Branch (387:5): [True: 0, False: 60.0k]
  ------------------
  388|      0|    case CONSPEC_F_OR_G_UP:
  ------------------
  |  Branch (388:5): [True: 0, False: 60.0k]
  ------------------
  389|      0|    case CONSPEC_HEX_EXP:
  ------------------
  |  Branch (389:5): [True: 0, False: 60.0k]
  ------------------
  390|      0|    case CONSPEC_HEX_EXP_UP:
  ------------------
  |  Branch (390:5): [True: 0, False: 60.0k]
  ------------------
  391|      0|      switch (arg->lenmod)
  392|      0|        {
  393|      0|        case LENMOD_LONGDBL: arg->vt = VALTYPE_LONGDOUBLE; break;
  ------------------
  |  Branch (393:9): [True: 0, False: 0]
  ------------------
  394|      0|        case LENMOD_LONG: arg->vt = VALTYPE_DOUBLE; break;
  ------------------
  |  Branch (394:9): [True: 0, False: 0]
  ------------------
  395|      0|        default: arg->vt = VALTYPE_DOUBLE; break;
  ------------------
  |  Branch (395:9): [True: 0, False: 0]
  ------------------
  396|      0|        }
  397|      0|      break;
  398|       |
  399|      0|    case CONSPEC_CHAR:
  ------------------
  |  Branch (399:5): [True: 0, False: 60.0k]
  ------------------
  400|      0|      arg->vt = VALTYPE_INT;
  401|      0|      break;
  402|       |
  403|  6.88k|    case CONSPEC_STRING:
  ------------------
  |  Branch (403:5): [True: 6.88k, False: 53.1k]
  ------------------
  404|  6.88k|      arg->vt = VALTYPE_STRING;
  405|  6.88k|      break;
  406|       |
  407|      4|    case CONSPEC_POINTER:
  ------------------
  |  Branch (407:5): [True: 4, False: 60.0k]
  ------------------
  408|      4|      arg->vt = VALTYPE_POINTER;
  409|      4|      break;
  410|       |
  411|      0|    case CONSPEC_STRERROR:
  ------------------
  |  Branch (411:5): [True: 0, False: 60.0k]
  ------------------
  412|      0|      arg->vt = VALTYPE_STRING;
  413|      0|      break;
  414|       |
  415|      0|    case CONSPEC_BYTES_SO_FAR:
  ------------------
  |  Branch (415:5): [True: 0, False: 60.0k]
  ------------------
  416|      0|      switch (arg->lenmod)
  417|      0|        {
  418|      0|        case LENMOD_CHAR: arg->vt = VALTYPE_SCHAR_PTR; break;
  ------------------
  |  Branch (418:9): [True: 0, False: 0]
  ------------------
  419|      0|        case LENMOD_SHORT: arg->vt = VALTYPE_SHORT_PTR; break;
  ------------------
  |  Branch (419:9): [True: 0, False: 0]
  ------------------
  420|      0|        case LENMOD_LONG: arg->vt = VALTYPE_LONG_PTR; break;
  ------------------
  |  Branch (420:9): [True: 0, False: 0]
  ------------------
  421|      0|        case LENMOD_LONGLONG: arg->vt = VALTYPE_LONGLONG_PTR; break;
  ------------------
  |  Branch (421:9): [True: 0, False: 0]
  ------------------
  422|      0|        case LENMOD_INTMAX: arg->vt = VALTYPE_INTMAX_PTR; break;
  ------------------
  |  Branch (422:9): [True: 0, False: 0]
  ------------------
  423|      0|        case LENMOD_SIZET: arg->vt = VALTYPE_SIZE_PTR; break;
  ------------------
  |  Branch (423:9): [True: 0, False: 0]
  ------------------
  424|      0|        case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF_PTR; break;
  ------------------
  |  Branch (424:9): [True: 0, False: 0]
  ------------------
  425|      0|        default: arg->vt = VALTYPE_INT_PTR; break;
  ------------------
  |  Branch (425:9): [True: 0, False: 0]
  ------------------
  426|      0|        }
  427|      0|      break;
  428|       |
  429|  60.0k|    }
  430|  60.0k|}
estream-printf.c:read_values:
  706|  43.0k|{
  707|  43.0k|  int validx;
  708|       |
  709|   103k|  for (validx=0; validx < valuetable_len; validx++)
  ------------------
  |  Branch (709:18): [True: 60.0k, False: 43.0k]
  ------------------
  710|  60.0k|    {
  711|  60.0k|      value_t *value = &valuetable[validx].value;
  712|  60.0k|      valtype_t vt = valuetable[validx].vt;
  713|       |
  714|  60.0k|      switch (vt)
  715|  60.0k|        {
  716|      0|        case VALTYPE_CHAR: value->a_char = va_arg (vaargs, int); break;
  ------------------
  |  Branch (716:9): [True: 0, False: 60.0k]
  ------------------
  717|      0|        case VALTYPE_CHAR_PTR:
  ------------------
  |  Branch (717:9): [True: 0, False: 60.0k]
  ------------------
  718|      0|          value->a_char_ptr = va_arg (vaargs, char *);
  719|      0|          break;
  720|      0|        case VALTYPE_SCHAR: value->a_schar = va_arg (vaargs, int); break;
  ------------------
  |  Branch (720:9): [True: 0, False: 60.0k]
  ------------------
  721|      0|        case VALTYPE_SCHAR_PTR:
  ------------------
  |  Branch (721:9): [True: 0, False: 60.0k]
  ------------------
  722|      0|          value->a_schar_ptr = va_arg (vaargs, signed char *);
  723|      0|          break;
  724|      0|        case VALTYPE_UCHAR: value->a_uchar = va_arg (vaargs, int); break;
  ------------------
  |  Branch (724:9): [True: 0, False: 60.0k]
  ------------------
  725|      0|        case VALTYPE_SHORT: value->a_short = va_arg (vaargs, int); break;
  ------------------
  |  Branch (725:9): [True: 0, False: 60.0k]
  ------------------
  726|      0|        case VALTYPE_USHORT: value->a_ushort = va_arg (vaargs, int); break;
  ------------------
  |  Branch (726:9): [True: 0, False: 60.0k]
  ------------------
  727|      0|        case VALTYPE_SHORT_PTR:
  ------------------
  |  Branch (727:9): [True: 0, False: 60.0k]
  ------------------
  728|      0|          value->a_short_ptr = va_arg (vaargs, short *);
  729|      0|          break;
  730|  10.2k|        case VALTYPE_INT:
  ------------------
  |  Branch (730:9): [True: 10.2k, False: 49.8k]
  ------------------
  731|  10.2k|          value->a_int = va_arg (vaargs, int);
  732|  10.2k|          break;
  733|      0|        case VALTYPE_INT_PTR:
  ------------------
  |  Branch (733:9): [True: 0, False: 60.0k]
  ------------------
  734|      0|          value->a_int_ptr = va_arg (vaargs, int *);
  735|      0|          break;
  736|  33.7k|        case VALTYPE_UINT:
  ------------------
  |  Branch (736:9): [True: 33.7k, False: 26.2k]
  ------------------
  737|  33.7k|          value->a_uint = va_arg (vaargs, unsigned int);
  738|  33.7k|          break;
  739|      0|        case VALTYPE_LONG:
  ------------------
  |  Branch (739:9): [True: 0, False: 60.0k]
  ------------------
  740|      0|          value->a_long = va_arg (vaargs, long);
  741|      0|          break;
  742|  7.68k|        case VALTYPE_ULONG:
  ------------------
  |  Branch (742:9): [True: 7.68k, False: 52.3k]
  ------------------
  743|  7.68k|          value->a_ulong = va_arg (vaargs, unsigned long);
  744|  7.68k|          break;
  745|      0|        case VALTYPE_LONG_PTR:
  ------------------
  |  Branch (745:9): [True: 0, False: 60.0k]
  ------------------
  746|      0|          value->a_long_ptr = va_arg (vaargs, long *);
  747|      0|          break;
  748|      0|#ifdef HAVE_LONG_LONG_INT
  749|  1.46k|        case VALTYPE_LONGLONG:
  ------------------
  |  Branch (749:9): [True: 1.46k, False: 58.5k]
  ------------------
  750|  1.46k|          value->a_longlong = va_arg (vaargs, long long int);
  751|  1.46k|          break;
  752|      0|        case VALTYPE_ULONGLONG:
  ------------------
  |  Branch (752:9): [True: 0, False: 60.0k]
  ------------------
  753|      0|          value->a_ulonglong = va_arg (vaargs, unsigned long long int);
  754|      0|          break;
  755|      0|        case VALTYPE_LONGLONG_PTR:
  ------------------
  |  Branch (755:9): [True: 0, False: 60.0k]
  ------------------
  756|      0|          value->a_longlong_ptr = va_arg (vaargs, long long *);
  757|      0|          break;
  758|      0|#endif
  759|      0|        case VALTYPE_DOUBLE:
  ------------------
  |  Branch (759:9): [True: 0, False: 60.0k]
  ------------------
  760|      0|          value->a_double = va_arg (vaargs, double);
  761|      0|          break;
  762|      0|#ifdef HAVE_LONG_DOUBLE
  763|      0|        case VALTYPE_LONGDOUBLE:
  ------------------
  |  Branch (763:9): [True: 0, False: 60.0k]
  ------------------
  764|      0|          value->a_longdouble = va_arg (vaargs, long double);
  765|      0|          break;
  766|      0|#endif
  767|  6.88k|        case VALTYPE_STRING:
  ------------------
  |  Branch (767:9): [True: 6.88k, False: 53.1k]
  ------------------
  768|  6.88k|          value->a_string = va_arg (vaargs, const char *);
  769|  6.88k|          break;
  770|      4|        case VALTYPE_POINTER:
  ------------------
  |  Branch (770:9): [True: 4, False: 60.0k]
  ------------------
  771|      4|          value->a_void_ptr = va_arg (vaargs, void *);
  772|      4|          break;
  773|      0|#ifdef HAVE_INTMAX_T
  774|      0|        case VALTYPE_INTMAX:
  ------------------
  |  Branch (774:9): [True: 0, False: 60.0k]
  ------------------
  775|      0|          value->a_intmax = va_arg (vaargs, intmax_t);
  776|      0|          break;
  777|      0|        case VALTYPE_INTMAX_PTR:
  ------------------
  |  Branch (777:9): [True: 0, False: 60.0k]
  ------------------
  778|      0|          value->a_intmax_ptr = va_arg (vaargs, intmax_t *);
  779|      0|          break;
  780|      0|#endif
  781|      0|#ifdef HAVE_UINTMAX_T
  782|      0|        case VALTYPE_UINTMAX:
  ------------------
  |  Branch (782:9): [True: 0, False: 60.0k]
  ------------------
  783|      0|          value->a_uintmax = va_arg (vaargs, uintmax_t);
  784|      0|          break;
  785|      0|#endif
  786|      0|        case VALTYPE_SIZE:
  ------------------
  |  Branch (786:9): [True: 0, False: 60.0k]
  ------------------
  787|      0|          value->a_size = va_arg (vaargs, size_t);
  788|      0|          break;
  789|      0|        case VALTYPE_SIZE_PTR:
  ------------------
  |  Branch (789:9): [True: 0, False: 60.0k]
  ------------------
  790|      0|          value->a_size_ptr = va_arg (vaargs, size_t *);
  791|      0|          break;
  792|      0|#ifdef HAVE_PTRDIFF_T
  793|      0|        case VALTYPE_PTRDIFF:
  ------------------
  |  Branch (793:9): [True: 0, False: 60.0k]
  ------------------
  794|      0|          value->a_ptrdiff = va_arg (vaargs, ptrdiff_t);
  795|      0|          break;
  796|      0|        case VALTYPE_PTRDIFF_PTR:
  ------------------
  |  Branch (796:9): [True: 0, False: 60.0k]
  ------------------
  797|      0|          value->a_ptrdiff_ptr = va_arg (vaargs, ptrdiff_t *);
  798|      0|          break;
  799|      0|#endif
  800|      0|        default: /* Unsupported type.  */
  ------------------
  |  Branch (800:9): [True: 0, False: 60.0k]
  ------------------
  801|      0|          return -1;
  802|  60.0k|        }
  803|  60.0k|    }
  804|  43.0k|  return 0;
  805|  43.0k|}
estream-printf.c:do_format:
 1354|  43.0k|{
 1355|  43.0k|  int rc = 0;
 1356|  43.0k|  const char *s;
 1357|  43.0k|  argspec_t arg = argspecs;
 1358|  43.0k|  int argidx = 0; /* Only used for assertion.  */
 1359|  43.0k|  size_t n;
 1360|  43.0k|  value_t value;
 1361|  43.0k|  int string_no = 0;  /* Number of processed "%s" args.  */
 1362|       |
 1363|  43.0k|  s = format;
 1364|   971k|  while ( *s )
  ------------------
  |  Branch (1364:11): [True: 928k, False: 43.0k]
  ------------------
 1365|   928k|    {
 1366|   928k|      if (*s != '%')
  ------------------
  |  Branch (1366:11): [True: 868k, False: 60.0k]
  ------------------
 1367|   868k|        {
 1368|   868k|          s++;
 1369|   868k|          continue;
 1370|   868k|        }
 1371|  60.0k|      if (s != format)
  ------------------
  |  Branch (1371:11): [True: 49.8k, False: 10.2k]
  ------------------
 1372|  49.8k|        {
 1373|  49.8k|          rc = outfnc (outfncarg, format, (n=s-format));
 1374|  49.8k|          if (rc)
  ------------------
  |  Branch (1374:15): [True: 0, False: 49.8k]
  ------------------
 1375|      0|            return rc;
 1376|  49.8k|          *nbytes += n;
 1377|  49.8k|        }
 1378|  60.0k|      if (s[1] == '%')
  ------------------
  |  Branch (1378:11): [True: 0, False: 60.0k]
  ------------------
 1379|      0|        {
 1380|       |          /* Note that this code ignores one trailing percent escape -
 1381|       |             this is however okay as the args parser must have
 1382|       |             detected this already.  */
 1383|      0|          rc = outfnc (outfncarg, s, 1);
 1384|      0|          if (rc)
  ------------------
  |  Branch (1384:15): [True: 0, False: 0]
  ------------------
 1385|      0|            return rc;
 1386|      0|          *nbytes += 1;
 1387|      0|          s += 2;
 1388|      0|          format = s;
 1389|      0|          continue;
 1390|      0|        }
 1391|       |
 1392|       |      /* Save the next start.  */
 1393|  60.0k|      s += arg->length;
 1394|  60.0k|      format = s;
 1395|       |
 1396|  60.0k|      gpgrt_assert (argidx < argspecs_len);
  ------------------
  |  |  577|  60.0k|  ((expr)                                                       \
  |  |  ------------------
  |  |  |  Branch (577:4): [True: 60.0k, False: 0]
  |  |  ------------------
  |  |  578|  60.0k|   ? (void) 0                                                   \
  |  |  579|  60.0k|   : _gpgrt__log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
  ------------------
 1397|      0|      argidx++;
 1398|       |
 1399|       |      /* Apply indirect field width and precision values.  */
 1400|  60.0k|      if (arg->width == STAR_FIELD_VALUE)
  ------------------
  |  |  133|  60.0k|#define STAR_FIELD_VALUE (-2)
  ------------------
  |  Branch (1400:11): [True: 0, False: 60.0k]
  ------------------
 1401|      0|        {
 1402|      0|          gpgrt_assert (valuetable[arg->width_pos-1].vt == VALTYPE_INT);
  ------------------
  |  |  577|      0|  ((expr)                                                       \
  |  |  ------------------
  |  |  |  Branch (577:4): [True: 0, False: 0]
  |  |  ------------------
  |  |  578|      0|   ? (void) 0                                                   \
  |  |  579|      0|   : _gpgrt__log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
  ------------------
 1403|      0|          arg->width = valuetable[arg->width_pos-1].value.a_int;
 1404|      0|          if (arg->width < 0)
  ------------------
  |  Branch (1404:15): [True: 0, False: 0]
  ------------------
 1405|      0|            {
 1406|      0|              arg->width = -arg->width;
 1407|      0|              arg->flags |= FLAG_LEFT_JUST;
  ------------------
  |  |  137|      0|#define FLAG_LEFT_JUST  2
  ------------------
 1408|      0|            }
 1409|      0|        }
 1410|  60.0k|      if (arg->precision == STAR_FIELD_VALUE)
  ------------------
  |  |  133|  60.0k|#define STAR_FIELD_VALUE (-2)
  ------------------
  |  Branch (1410:11): [True: 3, False: 60.0k]
  ------------------
 1411|      3|        {
 1412|      3|          gpgrt_assert (valuetable[arg->precision_pos-1].vt == VALTYPE_INT);
  ------------------
  |  |  577|      3|  ((expr)                                                       \
  |  |  ------------------
  |  |  |  Branch (577:4): [True: 3, False: 0]
  |  |  ------------------
  |  |  578|      3|   ? (void) 0                                                   \
  |  |  579|      3|   : _gpgrt__log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
  ------------------
 1413|      0|          arg->precision = valuetable[arg->precision_pos-1].value.a_int;
 1414|      3|          if (arg->precision < 0)
  ------------------
  |  Branch (1414:15): [True: 0, False: 3]
  ------------------
 1415|      0|            arg->precision = NO_FIELD_VALUE;
  ------------------
  |  |  132|      0|#define NO_FIELD_VALUE   (-1)
  ------------------
 1416|      3|        }
 1417|       |
 1418|  60.0k|      if (arg->arg_pos == -1 && arg->conspec == CONSPEC_STRERROR)
  ------------------
  |  Branch (1418:11): [True: 0, False: 60.0k]
  |  Branch (1418:33): [True: 0, False: 0]
  ------------------
 1419|      0|        value.a_string = strerror (myerrno);
 1420|  60.0k|      else
 1421|  60.0k|        {
 1422|  60.0k|          gpgrt_assert (arg->vt == valuetable[arg->arg_pos-1].vt);
  ------------------
  |  |  577|  60.0k|  ((expr)                                                       \
  |  |  ------------------
  |  |  |  Branch (577:4): [True: 60.0k, False: 0]
  |  |  ------------------
  |  |  578|  60.0k|   ? (void) 0                                                   \
  |  |  579|  60.0k|   : _gpgrt__log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
  ------------------
 1423|      0|          value = valuetable[arg->arg_pos-1].value;
 1424|  60.0k|        }
 1425|       |
 1426|      0|      switch (arg->conspec)
  ------------------
  |  Branch (1426:15): [True: 0, False: 60.0k]
  ------------------
 1427|  60.0k|        {
 1428|      0|        case CONSPEC_UNKNOWN: gpgrt_assert (!"bug"); break;
  ------------------
  |  |  577|      0|  ((expr)                                                       \
  |  |  ------------------
  |  |  |  Branch (577:4): [Folded - Ignored]
  |  |  ------------------
  |  |  578|      0|   ? (void) 0                                                   \
  |  |  579|      0|   : _gpgrt__log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
  ------------------
  |  Branch (1428:9): [True: 0, False: 60.0k]
  ------------------
 1429|       |
 1430|  11.6k|        case CONSPEC_DECIMAL:
  ------------------
  |  Branch (1430:9): [True: 11.6k, False: 48.3k]
  ------------------
 1431|  11.9k|        case CONSPEC_UNSIGNED:
  ------------------
  |  Branch (1431:9): [True: 215, False: 59.8k]
  ------------------
 1432|  11.9k|        case CONSPEC_OCTAL:
  ------------------
  |  Branch (1432:9): [True: 0, False: 60.0k]
  ------------------
 1433|  28.7k|        case CONSPEC_HEX:
  ------------------
  |  Branch (1433:9): [True: 16.8k, False: 43.2k]
  ------------------
 1434|  53.1k|        case CONSPEC_HEX_UP:
  ------------------
  |  Branch (1434:9): [True: 24.4k, False: 35.5k]
  ------------------
 1435|  53.1k|          rc = pr_integer (outfnc, outfncarg, arg, value, nbytes);
 1436|  53.1k|          break;
 1437|      0|        case CONSPEC_FLOAT:
  ------------------
  |  Branch (1437:9): [True: 0, False: 60.0k]
  ------------------
 1438|      0|        case CONSPEC_FLOAT_UP:
  ------------------
  |  Branch (1438:9): [True: 0, False: 60.0k]
  ------------------
 1439|      0|        case CONSPEC_EXP:
  ------------------
  |  Branch (1439:9): [True: 0, False: 60.0k]
  ------------------
 1440|      0|        case CONSPEC_EXP_UP:
  ------------------
  |  Branch (1440:9): [True: 0, False: 60.0k]
  ------------------
 1441|      0|        case CONSPEC_F_OR_G:
  ------------------
  |  Branch (1441:9): [True: 0, False: 60.0k]
  ------------------
 1442|      0|        case CONSPEC_F_OR_G_UP:
  ------------------
  |  Branch (1442:9): [True: 0, False: 60.0k]
  ------------------
 1443|      0|        case CONSPEC_HEX_EXP:
  ------------------
  |  Branch (1443:9): [True: 0, False: 60.0k]
  ------------------
 1444|      0|        case CONSPEC_HEX_EXP_UP:
  ------------------
  |  Branch (1444:9): [True: 0, False: 60.0k]
  ------------------
 1445|      0|          rc = pr_float (outfnc, outfncarg, arg, value, nbytes);
 1446|      0|          break;
 1447|      0|        case CONSPEC_CHAR:
  ------------------
  |  Branch (1447:9): [True: 0, False: 60.0k]
  ------------------
 1448|      0|          rc = pr_char (outfnc, outfncarg, arg, value, nbytes);
 1449|      0|          break;
 1450|  6.88k|        case CONSPEC_STRING:
  ------------------
  |  Branch (1450:9): [True: 6.88k, False: 53.1k]
  ------------------
 1451|  6.88k|          rc = pr_string (outfnc, outfncarg, arg, value, nbytes,
 1452|  6.88k|                          sf, sfvalue, string_no++);
 1453|  6.88k|          break;
 1454|      0|        case CONSPEC_STRERROR:
  ------------------
  |  Branch (1454:9): [True: 0, False: 60.0k]
  ------------------
 1455|      0|          rc = pr_string (outfnc, outfncarg, arg, value, nbytes,
 1456|      0|                          NULL, NULL, 0);
 1457|      0|          break;
 1458|      4|        case CONSPEC_POINTER:
  ------------------
  |  Branch (1458:9): [True: 4, False: 60.0k]
  ------------------
 1459|      4|          rc = pr_pointer (outfnc, outfncarg, arg, value, nbytes);
 1460|      4|          break;
 1461|      0|        case CONSPEC_BYTES_SO_FAR:
  ------------------
  |  Branch (1461:9): [True: 0, False: 60.0k]
  ------------------
 1462|      0|          rc = pr_bytes_so_far (outfnc, outfncarg, arg, value, nbytes);
 1463|      0|          break;
 1464|  60.0k|        }
 1465|  60.0k|      if (rc)
  ------------------
  |  Branch (1465:11): [True: 0, False: 60.0k]
  ------------------
 1466|      0|        return rc;
 1467|  60.0k|      arg++;
 1468|  60.0k|    }
 1469|       |
 1470|       |  /* Print out any trailing stuff. */
 1471|  43.0k|  n = s - format;
 1472|  43.0k|  rc = n? outfnc (outfncarg, format, n) : 0;
  ------------------
  |  Branch (1472:8): [True: 23.9k, False: 19.0k]
  ------------------
 1473|  43.0k|  if (!rc)
  ------------------
  |  Branch (1473:7): [True: 43.0k, False: 0]
  ------------------
 1474|  43.0k|    *nbytes += n;
 1475|       |
 1476|  43.0k|  return rc;
 1477|  43.0k|}
estream-printf.c:pr_integer:
  840|  53.1k|{
  841|  53.1k|  int rc;
  842|  53.1k|#ifdef HAVE_LONG_LONG_INT
  843|  53.1k|  unsigned long long aulong;
  844|       |#else
  845|       |  unsigned long aulong;
  846|       |#endif
  847|  53.1k|  char numbuf[100];
  848|  53.1k|  char *p, *pend;
  849|  53.1k|  size_t n;
  850|  53.1k|  char signchar = 0;
  851|  53.1k|  int n_prec;  /* Number of extra precision digits required.  */
  852|  53.1k|  int n_extra; /* Extra number of prefix or sign characters.  */
  853|       |
  854|  53.1k|  if (arg->conspec == CONSPEC_DECIMAL)
  ------------------
  |  Branch (854:7): [True: 11.6k, False: 41.4k]
  ------------------
  855|  11.6k|    {
  856|  11.6k|#ifdef HAVE_LONG_LONG_INT
  857|  11.6k|      long long along;
  858|       |#else
  859|       |      long along;
  860|       |#endif
  861|       |
  862|  11.6k|      switch (arg->vt)
  863|  11.6k|        {
  864|      0|        case VALTYPE_SHORT: along = value.a_short; break;
  ------------------
  |  Branch (864:9): [True: 0, False: 11.6k]
  ------------------
  865|  10.2k|        case VALTYPE_INT: along = value.a_int; break;
  ------------------
  |  Branch (865:9): [True: 10.2k, False: 1.46k]
  ------------------
  866|      0|        case VALTYPE_LONG: along = value.a_long; break;
  ------------------
  |  Branch (866:9): [True: 0, False: 11.6k]
  ------------------
  867|      0|#ifdef HAVE_LONG_LONG_INT
  868|  1.46k|        case VALTYPE_LONGLONG: along = value.a_longlong; break;
  ------------------
  |  Branch (868:9): [True: 1.46k, False: 10.2k]
  ------------------
  869|      0|        case VALTYPE_SIZE: along = value.a_size; break;
  ------------------
  |  Branch (869:9): [True: 0, False: 11.6k]
  ------------------
  870|      0|# ifdef HAVE_INTMAX_T
  871|      0|        case VALTYPE_INTMAX: along = value.a_intmax; break;
  ------------------
  |  Branch (871:9): [True: 0, False: 11.6k]
  ------------------
  872|      0|# endif
  873|      0|# ifdef HAVE_PTRDIFF_T
  874|      0|        case VALTYPE_PTRDIFF: along = value.a_ptrdiff; break;
  ------------------
  |  Branch (874:9): [True: 0, False: 11.6k]
  ------------------
  875|      0|# endif
  876|      0|#endif /*HAVE_LONG_LONG_INT*/
  877|      0|        default:
  ------------------
  |  Branch (877:9): [True: 0, False: 11.6k]
  ------------------
  878|      0|          return -1;
  879|  11.6k|        }
  880|  11.6k|      if (along < 0)
  ------------------
  |  Branch (880:11): [True: 0, False: 11.6k]
  ------------------
  881|      0|        {
  882|      0|          aulong = -along;
  883|      0|          signchar = '-';
  884|      0|        }
  885|  11.6k|      else
  886|  11.6k|        aulong = along;
  887|  11.6k|    }
  888|  41.4k|  else
  889|  41.4k|    {
  890|  41.4k|      switch (arg->vt)
  891|  41.4k|        {
  892|      0|        case VALTYPE_USHORT: aulong = value.a_ushort; break;
  ------------------
  |  Branch (892:9): [True: 0, False: 41.4k]
  ------------------
  893|  33.7k|        case VALTYPE_UINT: aulong = value.a_uint; break;
  ------------------
  |  Branch (893:9): [True: 33.7k, False: 7.68k]
  ------------------
  894|  7.68k|        case VALTYPE_ULONG: aulong = value.a_ulong; break;
  ------------------
  |  Branch (894:9): [True: 7.68k, False: 33.7k]
  ------------------
  895|      0|#ifdef HAVE_LONG_LONG_INT
  896|      0|        case VALTYPE_ULONGLONG: aulong = value.a_ulonglong; break;
  ------------------
  |  Branch (896:9): [True: 0, False: 41.4k]
  ------------------
  897|      0|        case VALTYPE_SIZE: aulong = value.a_size; break;
  ------------------
  |  Branch (897:9): [True: 0, False: 41.4k]
  ------------------
  898|      0|# ifdef HAVE_UINTMAX_T
  899|      0|        case VALTYPE_UINTMAX: aulong = value.a_uintmax; break;
  ------------------
  |  Branch (899:9): [True: 0, False: 41.4k]
  ------------------
  900|      0|# endif
  901|      0|# ifdef HAVE_PTRDIFF_T
  902|      0|        case VALTYPE_PTRDIFF: aulong = value.a_ptrdiff; break;
  ------------------
  |  Branch (902:9): [True: 0, False: 41.4k]
  ------------------
  903|      0|# endif
  904|      0|#endif /*HAVE_LONG_LONG_INT*/
  905|      0|        default:
  ------------------
  |  Branch (905:9): [True: 0, False: 41.4k]
  ------------------
  906|      0|          return -1;
  907|  41.4k|        }
  908|  41.4k|    }
  909|       |
  910|  53.1k|  if (signchar == '-')
  ------------------
  |  Branch (910:7): [True: 0, False: 53.1k]
  ------------------
  911|      0|    ;
  912|  53.1k|  else if ((arg->flags & FLAG_PLUS_SIGN))
  ------------------
  |  |  138|  53.1k|#define FLAG_PLUS_SIGN  4
  ------------------
  |  Branch (912:12): [True: 0, False: 53.1k]
  ------------------
  913|      0|    signchar = '+';
  914|  53.1k|  else if ((arg->flags & FLAG_SPACE_PLUS))
  ------------------
  |  |  139|  53.1k|#define FLAG_SPACE_PLUS 8
  ------------------
  |  Branch (914:12): [True: 0, False: 53.1k]
  ------------------
  915|      0|    signchar = ' ';
  916|       |
  917|  53.1k|  n_extra = !!signchar;
  918|       |
  919|       |  /* We build the string up backwards.  */
  920|  53.1k|  p = pend = numbuf + DIM(numbuf);
  ------------------
  |  |   93|  53.1k|# define DIM(array) (sizeof (array) / sizeof (*array))
  ------------------
  921|  53.1k|  if ((!aulong && !arg->precision))
  ------------------
  |  Branch (921:8): [True: 3.96k, False: 49.1k]
  |  Branch (921:19): [True: 0, False: 3.96k]
  ------------------
  922|      0|    ;
  923|  53.1k|  else if (arg->conspec == CONSPEC_DECIMAL
  ------------------
  |  Branch (923:12): [True: 11.6k, False: 41.4k]
  ------------------
  924|  53.1k|           || arg->conspec == CONSPEC_UNSIGNED)
  ------------------
  |  Branch (924:15): [True: 215, False: 41.2k]
  ------------------
  925|  11.9k|    {
  926|  11.9k|      int grouping = -1;
  927|  11.9k|      const char * grouping_string =
  928|  11.9k|#ifdef HAVE_LANGINFO_THOUSEP
  929|  11.9k|        nl_langinfo(THOUSEP);
  930|       |#else
  931|       |        "'";
  932|       |#endif
  933|       |
  934|  11.9k|      do
  935|  31.5k|        {
  936|  31.5k|          if ((arg->flags & FLAG_GROUPING)
  ------------------
  |  |  136|  31.5k|#define FLAG_GROUPING   1
  ------------------
  |  Branch (936:15): [True: 0, False: 31.5k]
  ------------------
  937|  31.5k|              && (++grouping == 3) && *grouping_string)
  ------------------
  |  Branch (937:18): [True: 0, False: 0]
  |  Branch (937:39): [True: 0, False: 0]
  ------------------
  938|      0|            {
  939|      0|              *--p = *grouping_string;
  940|      0|              grouping = 0;
  941|      0|            }
  942|  31.5k|          *--p = '0' + (aulong % 10);
  943|  31.5k|          aulong /= 10;
  944|  31.5k|        }
  945|  31.5k|      while (aulong);
  ------------------
  |  Branch (945:14): [True: 19.6k, False: 11.9k]
  ------------------
  946|  11.9k|    }
  947|  41.2k|  else if (arg->conspec == CONSPEC_OCTAL)
  ------------------
  |  Branch (947:12): [True: 0, False: 41.2k]
  ------------------
  948|      0|    {
  949|      0|      do
  950|      0|        {
  951|      0|          *--p = '0' + (aulong % 8);
  952|      0|          aulong /= 8;
  953|      0|        }
  954|      0|      while (aulong);
  ------------------
  |  Branch (954:14): [True: 0, False: 0]
  ------------------
  955|      0|      if ((arg->flags & FLAG_ALT_CONV) && *p != '0')
  ------------------
  |  |  140|      0|#define FLAG_ALT_CONV   16
  ------------------
  |  Branch (955:11): [True: 0, False: 0]
  |  Branch (955:43): [True: 0, False: 0]
  ------------------
  956|      0|        *--p = '0';
  957|      0|    }
  958|  41.2k|  else /* HEX or HEXUP */
  959|  41.2k|    {
  960|  41.2k|      const char *digits = ((arg->conspec == CONSPEC_HEX)
  ------------------
  |  Branch (960:29): [True: 16.8k, False: 24.4k]
  ------------------
  961|  41.2k|                            ? "0123456789abcdef" : "0123456789ABCDEF");
  962|  41.2k|      do
  963|   118k|        {
  964|   118k|          *--p = digits[(aulong % 16)];
  965|   118k|          aulong /= 16;
  966|   118k|        }
  967|   118k|      while (aulong);
  ------------------
  |  Branch (967:14): [True: 76.8k, False: 41.2k]
  ------------------
  968|  41.2k|      if ((arg->flags & FLAG_ALT_CONV))
  ------------------
  |  |  140|  41.2k|#define FLAG_ALT_CONV   16
  ------------------
  |  Branch (968:11): [True: 0, False: 41.2k]
  ------------------
  969|      0|        n_extra += 2;
  970|  41.2k|    }
  971|       |
  972|  53.1k|  n = pend - p;
  973|       |
  974|  53.1k|  if ((arg->flags & FLAG_ZERO_PAD)
  ------------------
  |  |  141|  53.1k|#define FLAG_ZERO_PAD   32
  ------------------
  |  Branch (974:7): [True: 48.5k, False: 4.58k]
  ------------------
  975|  53.1k|      && arg->precision == NO_FIELD_VALUE && !(arg->flags & FLAG_LEFT_JUST)
  ------------------
  |  |  132|   101k|#define NO_FIELD_VALUE   (-1)
  ------------------
                    && arg->precision == NO_FIELD_VALUE && !(arg->flags & FLAG_LEFT_JUST)
  ------------------
  |  |  137|  48.5k|#define FLAG_LEFT_JUST  2
  ------------------
  |  Branch (975:10): [True: 48.5k, False: 0]
  |  Branch (975:46): [True: 48.5k, False: 0]
  ------------------
  976|  53.1k|      && n && arg->width - n_extra > n )
  ------------------
  |  Branch (976:10): [True: 48.5k, False: 0]
  |  Branch (976:15): [True: 10.3k, False: 38.2k]
  ------------------
  977|  10.3k|    n_prec = arg->width - n_extra - n;
  978|  42.8k|  else if (arg->precision > 0 && arg->precision > n)
  ------------------
  |  Branch (978:12): [True: 0, False: 42.8k]
  |  Branch (978:34): [True: 0, False: 0]
  ------------------
  979|      0|    n_prec = arg->precision - n;
  980|  42.8k|  else
  981|  42.8k|    n_prec = 0;
  982|       |
  983|  53.1k|  if (!(arg->flags & FLAG_LEFT_JUST)
  ------------------
  |  |  137|  53.1k|#define FLAG_LEFT_JUST  2
  ------------------
  |  Branch (983:7): [True: 53.1k, False: 0]
  ------------------
  984|  53.1k|      && arg->width >= 0 && arg->width - n_extra > n
  ------------------
  |  Branch (984:10): [True: 48.5k, False: 4.57k]
  |  Branch (984:29): [True: 10.3k, False: 38.2k]
  ------------------
  985|  53.1k|      && arg->width - n_extra - n >= n_prec )
  ------------------
  |  Branch (985:10): [True: 10.3k, False: 0]
  ------------------
  986|  10.3k|    {
  987|  10.3k|      rc = pad_out (outfnc, outfncarg, ' ',
  988|  10.3k|                    arg->width - n_extra - n - n_prec, nbytes);
  989|  10.3k|      if (rc)
  ------------------
  |  Branch (989:11): [True: 0, False: 10.3k]
  ------------------
  990|      0|        return rc;
  991|  10.3k|    }
  992|       |
  993|  53.1k|  if (signchar)
  ------------------
  |  Branch (993:7): [True: 0, False: 53.1k]
  ------------------
  994|      0|    {
  995|      0|      rc = outfnc (outfncarg, &signchar, 1);
  996|      0|      if (rc)
  ------------------
  |  Branch (996:11): [True: 0, False: 0]
  ------------------
  997|      0|        return rc;
  998|      0|      *nbytes += 1;
  999|      0|    }
 1000|       |
 1001|  53.1k|  if ((arg->flags & FLAG_ALT_CONV)
  ------------------
  |  |  140|  53.1k|#define FLAG_ALT_CONV   16
  ------------------
  |  Branch (1001:7): [True: 0, False: 53.1k]
  ------------------
 1002|  53.1k|      && (arg->conspec == CONSPEC_HEX || arg->conspec == CONSPEC_HEX_UP))
  ------------------
  |  Branch (1002:11): [True: 0, False: 0]
  |  Branch (1002:42): [True: 0, False: 0]
  ------------------
 1003|      0|    {
 1004|      0|      rc = outfnc (outfncarg, arg->conspec == CONSPEC_HEX? "0x": "0X", 2);
  ------------------
  |  Branch (1004:31): [True: 0, False: 0]
  ------------------
 1005|      0|      if (rc)
  ------------------
  |  Branch (1005:11): [True: 0, False: 0]
  ------------------
 1006|      0|        return rc;
 1007|      0|      *nbytes += 2;
 1008|      0|    }
 1009|       |
 1010|  53.1k|  if (n_prec)
  ------------------
  |  Branch (1010:7): [True: 10.3k, False: 42.8k]
  ------------------
 1011|  10.3k|    {
 1012|  10.3k|      rc = pad_out (outfnc, outfncarg, '0', n_prec, nbytes);
 1013|  10.3k|      if (rc)
  ------------------
  |  Branch (1013:11): [True: 0, False: 10.3k]
  ------------------
 1014|      0|        return rc;
 1015|  10.3k|    }
 1016|       |
 1017|  53.1k|  rc = outfnc (outfncarg, p, pend - p);
 1018|  53.1k|  if (rc)
  ------------------
  |  Branch (1018:7): [True: 0, False: 53.1k]
  ------------------
 1019|      0|    return rc;
 1020|  53.1k|  *nbytes += pend - p;
 1021|       |
 1022|  53.1k|  if ((arg->flags & FLAG_LEFT_JUST)
  ------------------
  |  |  137|  53.1k|#define FLAG_LEFT_JUST  2
  ------------------
  |  Branch (1022:7): [True: 0, False: 53.1k]
  ------------------
 1023|  53.1k|      && arg->width >= 0 && arg->width - n_extra - n_prec > n)
  ------------------
  |  Branch (1023:10): [True: 0, False: 0]
  |  Branch (1023:29): [True: 0, False: 0]
  ------------------
 1024|      0|    {
 1025|      0|      rc = pad_out (outfnc, outfncarg, ' ',
 1026|      0|                    arg->width - n_extra - n_prec - n, nbytes);
 1027|      0|      if (rc)
  ------------------
  |  Branch (1027:11): [True: 0, False: 0]
  ------------------
 1028|      0|        return rc;
 1029|      0|    }
 1030|       |
 1031|  53.1k|  return 0;
 1032|  53.1k|}
estream-printf.c:pad_out:
  814|  20.6k|{
  815|  20.6k|  char buf[32];
  816|  20.6k|  size_t n;
  817|  20.6k|  int rc;
  818|       |
  819|  30.9k|  while (count > 0)
  ------------------
  |  Branch (819:10): [True: 10.3k, False: 20.6k]
  ------------------
  820|  10.3k|    {
  821|  10.3k|      n = (count <= sizeof buf)? count : sizeof buf;
  ------------------
  |  Branch (821:11): [True: 10.3k, False: 0]
  ------------------
  822|  10.3k|      memset (buf, padchar, n);
  823|  10.3k|      rc = outfnc (outfncarg, buf, n);
  824|  10.3k|      if (rc)
  ------------------
  |  Branch (824:11): [True: 0, False: 10.3k]
  ------------------
  825|      0|        return rc;
  826|  10.3k|      *nbytes += n;
  827|  10.3k|      count -= n;
  828|  10.3k|    }
  829|       |
  830|  20.6k|  return 0;
  831|  20.6k|}
estream-printf.c:pr_string:
 1190|  6.88k|{
 1191|  6.88k|  int rc;
 1192|  6.88k|  size_t n;
 1193|  6.88k|  const char *string, *s;
 1194|       |
 1195|  6.88k|  if (arg->vt != VALTYPE_STRING)
  ------------------
  |  Branch (1195:7): [True: 0, False: 6.88k]
  ------------------
 1196|      0|    return -1;
 1197|  6.88k|  if (sf)
  ------------------
  |  Branch (1197:7): [True: 3.18k, False: 3.69k]
  ------------------
 1198|  3.18k|    string = sf (value.a_string, string_no, sfvalue);
 1199|  3.69k|  else
 1200|  3.69k|    string = value.a_string;
 1201|       |
 1202|  6.88k|  if (!string)
  ------------------
  |  Branch (1202:7): [True: 0, False: 6.88k]
  ------------------
 1203|      0|    string = "(null)";
 1204|  6.88k|  if (arg->precision >= 0)
  ------------------
  |  Branch (1204:7): [True: 3, False: 6.87k]
  ------------------
 1205|      3|    {
 1206|       |      /* Test for nul after N so that we can pass a non-nul terminated
 1207|       |         string.  */
 1208|     57|      for (n=0,s=string; n < arg->precision && *s; s++)
  ------------------
  |  Branch (1208:26): [True: 54, False: 3]
  |  Branch (1208:48): [True: 54, False: 0]
  ------------------
 1209|     54|        n++;
 1210|      3|    }
 1211|  6.87k|  else
 1212|  6.87k|    n = strlen (string);
 1213|       |
 1214|  6.88k|  if (!(arg->flags & FLAG_LEFT_JUST)
  ------------------
  |  |  137|  6.88k|#define FLAG_LEFT_JUST  2
  ------------------
  |  Branch (1214:7): [True: 6.88k, False: 0]
  ------------------
 1215|  6.88k|      && arg->width >= 0 && arg->width > n )
  ------------------
  |  Branch (1215:10): [True: 0, False: 6.88k]
  |  Branch (1215:29): [True: 0, False: 0]
  ------------------
 1216|      0|    {
 1217|      0|      rc = pad_out (outfnc, outfncarg, ' ', arg->width - n, nbytes);
 1218|      0|      if (rc)
  ------------------
  |  Branch (1218:11): [True: 0, False: 0]
  ------------------
 1219|      0|        goto leave;
 1220|      0|    }
 1221|       |
 1222|  6.88k|  rc = outfnc (outfncarg, string, n);
 1223|  6.88k|  if (rc)
  ------------------
  |  Branch (1223:7): [True: 0, False: 6.88k]
  ------------------
 1224|      0|    goto leave;
 1225|  6.88k|  *nbytes += n;
 1226|       |
 1227|  6.88k|  if ((arg->flags & FLAG_LEFT_JUST)
  ------------------
  |  |  137|  6.88k|#define FLAG_LEFT_JUST  2
  ------------------
  |  Branch (1227:7): [True: 0, False: 6.88k]
  ------------------
 1228|  6.88k|      && arg->width >= 0 && arg->width > n)
  ------------------
  |  Branch (1228:10): [True: 0, False: 0]
  |  Branch (1228:29): [True: 0, False: 0]
  ------------------
 1229|      0|    {
 1230|      0|      rc = pad_out (outfnc, outfncarg, ' ', arg->width - n, nbytes);
 1231|      0|      if (rc)
  ------------------
  |  Branch (1231:11): [True: 0, False: 0]
  ------------------
 1232|      0|        goto leave;
 1233|      0|    }
 1234|       |
 1235|  6.88k|  rc = 0;
 1236|       |
 1237|  6.88k| leave:
 1238|  6.88k|  if (sf) /* Tell the filter to release resources.  */
  ------------------
  |  Branch (1238:7): [True: 3.18k, False: 3.69k]
  ------------------
 1239|  3.18k|    sf (value.a_string, -1, sfvalue);
 1240|       |
 1241|  6.88k|  return rc;
 1242|  6.88k|}
estream-printf.c:pr_pointer:
 1249|      4|{
 1250|      4|  int rc;
 1251|       |#if defined(HAVE_LONG_LONG_INT) && (SIZEOF_UNSIGNED_LONG < SIZEOF_VOID_P)
 1252|       |  unsigned long long aulong;
 1253|       |#else
 1254|      4|  unsigned long aulong;
 1255|      4|#endif
 1256|      4|  char numbuf[100];
 1257|      4|  char *p, *pend;
 1258|       |
 1259|      4|  if (arg->vt != VALTYPE_POINTER)
  ------------------
  |  Branch (1259:7): [True: 0, False: 4]
  ------------------
 1260|      0|    return -1;
 1261|       |  /* We assume that a pointer can be converted to an unsigned long.
 1262|       |     That is not correct for a 64 bit Windows, but then we assume that
 1263|       |     long long is supported and usable for storing a pointer.  */
 1264|       |#if defined(HAVE_LONG_LONG_INT) && (SIZEOF_UNSIGNED_LONG < SIZEOF_VOID_P)
 1265|       |  aulong = (unsigned long long)value.a_void_ptr;
 1266|       |#else
 1267|      4|  aulong = (unsigned long)value.a_void_ptr;
 1268|      4|#endif
 1269|       |
 1270|      4|  p = pend = numbuf + DIM(numbuf);
  ------------------
  |  |   93|      4|# define DIM(array) (sizeof (array) / sizeof (*array))
  ------------------
 1271|      4|  do
 1272|     28|    {
 1273|     28|      *--p = "0123456789abcdefx"[(aulong % 16)];
 1274|     28|      aulong /= 16;
 1275|     28|    }
 1276|     28|  while (aulong);
  ------------------
  |  Branch (1276:10): [True: 24, False: 4]
  ------------------
 1277|     40|  while ((pend-p) < 2*sizeof (aulong))
  ------------------
  |  Branch (1277:10): [True: 36, False: 4]
  ------------------
 1278|     36|    *--p = '0';
 1279|      4|  *--p = 'x';
 1280|      4|  *--p = '0';
 1281|       |
 1282|      4|  rc = outfnc (outfncarg, p, pend - p);
 1283|      4|  if (rc)
  ------------------
  |  Branch (1283:7): [True: 0, False: 4]
  ------------------
 1284|      0|    return rc;
 1285|      4|  *nbytes += pend - p;
 1286|       |
 1287|      4|  return 0;
 1288|      4|}
estream-printf.c:fixed_buffer_out:
 1704|  35.4k|{
 1705|  35.4k|  struct fixed_buffer_parm_s *parm = outfncarg;
 1706|       |
 1707|  35.4k|  parm->count += buflen;
 1708|       |
 1709|  35.4k|  if (!parm->buffer)
  ------------------
  |  Branch (1709:7): [True: 0, False: 35.4k]
  ------------------
 1710|      0|    ;
 1711|  35.4k|  else if (parm->used + buflen < parm->size)
  ------------------
  |  Branch (1711:12): [True: 35.4k, False: 0]
  ------------------
 1712|  35.4k|    {
 1713|       |      /* Handle the common case that everything fits into the buffer
 1714|       |         separately.  */
 1715|  35.4k|      memcpy (parm->buffer + parm->used, buf, buflen);
 1716|  35.4k|      parm->used += buflen;
 1717|  35.4k|    }
 1718|      0|  else
 1719|      0|    {
 1720|       |      /* The slow version of above.  */
 1721|      0|      for ( ;buflen && parm->used < parm->size; buflen--)
  ------------------
  |  Branch (1721:14): [True: 0, False: 0]
  |  Branch (1721:24): [True: 0, False: 0]
  ------------------
 1722|      0|        parm->buffer[parm->used++] = *buf++;
 1723|      0|    }
 1724|       |
 1725|  35.4k|  return 0;
 1726|  35.4k|}
estream-printf.c:dynamic_buffer_out:
 1784|  22.3k|{
 1785|  22.3k|  struct dynamic_buffer_parm_s *parm = outfncarg;
 1786|       |
 1787|  22.3k|  if (parm->error_flag)
  ------------------
  |  Branch (1787:7): [True: 0, False: 22.3k]
  ------------------
 1788|      0|    {
 1789|       |      /* Just in case some formatting routine did not checked for an
 1790|       |         error. */
 1791|      0|      _set_errno (parm->error_flag);
  ------------------
  |  |  113|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (113:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1792|      0|      return -1;
 1793|      0|    }
 1794|       |
 1795|  22.3k|  if (parm->used + buflen >= parm->alloced)
  ------------------
  |  Branch (1795:7): [True: 0, False: 22.3k]
  ------------------
 1796|      0|    {
 1797|      0|      char *p;
 1798|       |
 1799|      0|      parm->alloced += buflen + 512;
 1800|      0|      p = my_printf_realloc (parm->buffer, parm->alloced);
  ------------------
  |  |  107|      0|#define my_printf_realloc(a,b) _ESTREAM_PRINTF_REALLOC((a),(b))
  |  |  ------------------
  |  |  |  |  349|      0|#define _ESTREAM_PRINTF_REALLOC _gpgrt_realloc
  |  |  ------------------
  ------------------
 1801|      0|      if (!p)
  ------------------
  |  Branch (1801:11): [True: 0, False: 0]
  ------------------
 1802|      0|        {
 1803|      0|          parm->error_flag = errno ? errno : ENOMEM;
 1804|       |          /* Wipe out what we already accumulated.  This is useful in
 1805|       |             case sensitive data is formatted.  */
 1806|      0|          memset (parm->buffer, 0, parm->used);
 1807|      0|          return -1;
 1808|      0|        }
 1809|      0|      parm->buffer = p;
 1810|      0|    }
 1811|  22.3k|  memcpy (parm->buffer + parm->used, buf, buflen);
 1812|  22.3k|  parm->used += buflen;
 1813|       |
 1814|  22.3k|  return 0;
 1815|  22.3k|}

_gpgrt_estream_init:
  595|      2|{
  596|      2|  static int initialized;
  597|       |
  598|      2|  if (!initialized)
  ------------------
  |  Branch (598:7): [True: 2, False: 0]
  ------------------
  599|      2|    {
  600|      2|      initialized = 1;
  601|      2|      atexit (do_deinit);
  602|      2|    }
  603|      2|  return 0;
  604|      2|}
_gpgrt_fopen:
 3509|    248|{
 3510|    248|  unsigned int modeflags, cmode, xmode;
 3511|    248|  int create_called = 0;
 3512|    248|  estream_t stream = NULL;
 3513|    248|  void *cookie = NULL;
 3514|    248|  int err;
 3515|    248|  struct cookie_io_functions_s *functions;
 3516|    248|  es_syshd_t syshd;
 3517|    248|  int kind;
 3518|       |
 3519|    248|  err = parse_mode (mode, &modeflags, &xmode, &cmode);
 3520|    248|  if (err)
  ------------------
  |  Branch (3520:7): [True: 0, False: 248]
  ------------------
 3521|      0|    goto leave;
 3522|       |
 3523|       |  /* Convenience hack so that we can use /dev/null on Windows.  */
 3524|       |#ifdef HAVE_W32_SYSTEM
 3525|       |  if (path && !strcmp (path, "/dev/null"))
 3526|       |    path = "nul";
 3527|       |#endif
 3528|       |
 3529|       |#ifdef HAVE_W32_SYSTEM
 3530|       |  if ((xmode & X_SYSOPEN))
 3531|       |    {
 3532|       |      kind = BACKEND_W32;
 3533|       |      functions = &estream_functions_w32;
 3534|       |      syshd.type = ES_SYSHD_HANDLE;
 3535|       |      err = func_file_create_w32 (&cookie, &syshd.u.handle,
 3536|       |                                  path, modeflags, cmode);
 3537|       |    }
 3538|       |  else
 3539|       |#endif /* W32 */
 3540|    248|    {
 3541|    248|      kind = BACKEND_FD;
 3542|    248|      functions = &estream_functions_fd;
 3543|    248|      syshd.type = ES_SYSHD_FD;
  ------------------
  |  | 1255|    248|#define ES_SYSHD_FD     GPGRT_SYSHD_FD
  ------------------
 3544|    248|      err = func_file_create (&cookie, &syshd.u.fd,
 3545|    248|                              path, modeflags, cmode);
 3546|    248|    }
 3547|    248|  if (err)
  ------------------
  |  Branch (3547:7): [True: 2, False: 246]
  ------------------
 3548|      2|    goto leave;
 3549|       |
 3550|    246|  create_called = 1;
 3551|    246|  err = create_stream (&stream, cookie, &syshd, kind,
 3552|    246|                       *functions, modeflags, xmode, 0);
 3553|    246|  if (err)
  ------------------
  |  Branch (3553:7): [True: 0, False: 246]
  ------------------
 3554|      0|    goto leave;
 3555|       |
 3556|    246|  if (stream && path)
  ------------------
  |  Branch (3556:7): [True: 246, False: 0]
  |  Branch (3556:17): [True: 246, False: 0]
  ------------------
 3557|    246|    fname_set_internal (stream, path, 1);
 3558|       |
 3559|    248| leave:
 3560|    248|  if (err && create_called)
  ------------------
  |  Branch (3560:7): [True: 2, False: 246]
  |  Branch (3560:14): [True: 0, False: 2]
  ------------------
 3561|      0|    functions->public.func_close (cookie);
 3562|       |
 3563|    248|  return stream;
 3564|    246|}
_gpgrt__get_std_stream:
 4001|      3|{
 4002|      3|  estream_list_t list_obj;
 4003|      3|  estream_t stream = NULL;
 4004|       |
 4005|      3|  fd %= 3; /* We only allow 0, 1 or 2 but we don't want to return an error. */
 4006|       |
 4007|      3|  lock_list ();
 4008|       |
 4009|      5|  for (list_obj = estream_list; list_obj; list_obj = list_obj->next)
  ------------------
  |  Branch (4009:33): [True: 4, False: 1]
  ------------------
 4010|      4|    if (list_obj->stream && list_obj->stream->intern->is_stdstream
  ------------------
  |  Branch (4010:9): [True: 4, False: 0]
  |  Branch (4010:29): [True: 2, False: 2]
  ------------------
 4011|      4|        && list_obj->stream->intern->stdstream_fd == fd)
  ------------------
  |  Branch (4011:12): [True: 2, False: 0]
  ------------------
 4012|      2|      {
 4013|      2|	stream = list_obj->stream;
 4014|      2|	break;
 4015|      2|      }
 4016|      3|  if (!stream)
  ------------------
  |  Branch (4016:7): [True: 1, False: 2]
  ------------------
 4017|      1|    {
 4018|       |      /* Standard stream not yet created.  We first try to create them
 4019|       |         from registered file descriptors.  */
 4020|      1|      if (!fd && custom_std_fds_valid[0])
  ------------------
  |  Branch (4020:11): [True: 0, False: 1]
  |  Branch (4020:18): [True: 0, False: 0]
  ------------------
 4021|      0|        stream = do_fdopen (custom_std_fds[0], "r", 1, 1);
 4022|      1|      else if (fd == 1 && custom_std_fds_valid[1])
  ------------------
  |  Branch (4022:16): [True: 0, False: 1]
  |  Branch (4022:27): [True: 0, False: 0]
  ------------------
 4023|      0|        stream = do_fdopen (custom_std_fds[1], "a", 1, 1);
 4024|      1|      else if (custom_std_fds_valid[2])
  ------------------
  |  Branch (4024:16): [True: 0, False: 1]
  ------------------
 4025|      0|        stream = do_fdopen (custom_std_fds[2], "a", 1, 1);
 4026|       |
 4027|      1|      if (!stream)
  ------------------
  |  Branch (4027:11): [True: 1, False: 0]
  ------------------
 4028|      1|        {
 4029|       |          /* Second try is to use the standard C streams.  */
 4030|      1|          if (!fd)
  ------------------
  |  Branch (4030:15): [True: 0, False: 1]
  ------------------
 4031|      0|            stream = do_fpopen (stdin, "r", 1, 1);
 4032|      1|          else if (fd == 1)
  ------------------
  |  Branch (4032:20): [True: 0, False: 1]
  ------------------
 4033|      0|            stream = do_fpopen (stdout, "a", 1, 1);
 4034|      1|          else
 4035|      1|            stream = do_fpopen (stderr, "a", 1, 1);
 4036|      1|        }
 4037|       |
 4038|      1|      if (!stream)
  ------------------
  |  Branch (4038:11): [True: 0, False: 1]
  ------------------
 4039|      0|        {
 4040|       |          /* Last try: Create a bit bucket.  */
 4041|      0|          stream = do_fpopen (NULL, fd? "a":"r", 0, 1);
  ------------------
  |  Branch (4041:37): [True: 0, False: 0]
  ------------------
 4042|      0|          if (!stream)
  ------------------
  |  Branch (4042:15): [True: 0, False: 0]
  ------------------
 4043|      0|            {
 4044|      0|              fprintf (stderr, "fatal: error creating a dummy estream"
 4045|      0|                       " for %d: %s\n", fd, strerror (errno));
 4046|      0|              _gpgrt_abort();
 4047|      0|            }
 4048|      0|        }
 4049|       |
 4050|      1|      stream->intern->is_stdstream = 1;
 4051|      1|      stream->intern->stdstream_fd = fd;
 4052|      1|      if (fd == 2)
  ------------------
  |  Branch (4052:11): [True: 1, False: 0]
  ------------------
 4053|      1|        es_set_buffering (stream, NULL, _IOLBF, 0);
 4054|      1|      fname_set_internal (stream,
 4055|      1|                          fd == 0? "[stdin]" :
  ------------------
  |  Branch (4055:27): [True: 0, False: 1]
  ------------------
 4056|      1|                          fd == 1? "[stdout]" : "[stderr]", 0);
  ------------------
  |  Branch (4056:27): [True: 0, False: 1]
  ------------------
 4057|      1|    }
 4058|       |
 4059|      3|  unlock_list ();
 4060|      3|  return stream;
 4061|      3|}
_gpgrt_fclose:
 4144|    245|{
 4145|    245|  int err;
 4146|       |
 4147|    245|  err = do_close (stream, 0, 0);
 4148|       |
 4149|    245|  return err;
 4150|    245|}
_gpgrt_flockfile:
 4302|  22.6k|{
 4303|  22.6k|  lock_stream (stream);
 4304|  22.6k|}
_gpgrt_funlockfile:
 4316|  22.6k|{
 4317|  22.6k|  unlock_stream (stream);
 4318|  22.6k|}
_gpgrt_ferror_unlocked:
 4401|  1.11k|{
 4402|  1.11k|  return stream->intern->indicators.err;
 4403|  1.11k|}
_gpgrt_ferror:
 4408|    283|{
 4409|    283|  int ret;
 4410|       |
 4411|    283|  lock_stream (stream);
 4412|    283|  ret = _gpgrt_ferror_unlocked (stream);
 4413|    283|  unlock_stream (stream);
 4414|       |
 4415|    283|  return ret;
 4416|    283|}
_gpgrt_fseek:
 4487|      9|{
 4488|      9|  int err;
 4489|       |
 4490|      9|  lock_stream (stream);
 4491|      9|  err = es_seek (stream, offset, whence, NULL);
 4492|      9|  unlock_stream (stream);
 4493|       |
 4494|      9|  return err;
 4495|      9|}
_gpgrt_fseeko:
 4500|  1.28k|{
 4501|  1.28k|  int err;
 4502|       |
 4503|  1.28k|  lock_stream (stream);
 4504|  1.28k|  err = es_seek (stream, offset, whence, NULL);
 4505|  1.28k|  unlock_stream (stream);
 4506|       |
 4507|  1.28k|  return err;
 4508|  1.28k|}
_gpgrt_ftello:
 4526|    664|{
 4527|    664|  gpgrt_off_t ret = -1;
 4528|       |
 4529|    664|  lock_stream (stream);
 4530|    664|  ret = es_offset_calculate (stream);
 4531|    664|  unlock_stream (stream);
 4532|       |
 4533|    664|  return ret;
 4534|    664|}
_gpgrt__getc_underflow:
 4573|    560|{
 4574|    560|  int err;
 4575|    560|  unsigned char c;
 4576|    560|  size_t bytes_read;
 4577|       |
 4578|    560|  err = es_readn (stream, &c, 1, &bytes_read);
 4579|       |
 4580|    560|  return (err || (! bytes_read)) ? EOF : c;
  ------------------
  |  Branch (4580:11): [True: 0, False: 560]
  |  Branch (4580:18): [True: 263, False: 297]
  ------------------
 4581|    560|}
_gpgrt__putc_overflow:
 4586|      8|{
 4587|      8|  unsigned char d = c;
 4588|      8|  int err;
 4589|       |
 4590|      8|  err = es_writen (stream, &d, 1, NULL);
 4591|       |
 4592|      8|  return err ? EOF : c;
  ------------------
  |  Branch (4592:10): [True: 0, False: 8]
  ------------------
 4593|      8|}
_gpgrt_fgetc:
 4598|  2.24k|{
 4599|  2.24k|  int ret;
 4600|       |
 4601|  2.24k|  lock_stream (stream);
 4602|  2.24k|  ret = _gpgrt_getc_unlocked (stream);
  ------------------
  |  |  395|  2.24k|  (((!(stream)->flags.writing)					\
  |  |  ------------------
  |  |  |  Branch (395:5): [True: 2.24k, False: 0]
  |  |  ------------------
  |  |  396|  2.24k|    && ((stream)->data_offset < (stream)->data_len)		\
  |  |  ------------------
  |  |  |  Branch (396:8): [True: 1.68k, False: 560]
  |  |  ------------------
  |  |  397|  2.24k|    && (! (stream)->unread_data_len))				\
  |  |  ------------------
  |  |  |  Branch (397:8): [True: 1.68k, False: 0]
  |  |  ------------------
  |  |  398|  2.24k|  ? ((int) (stream)->buffer[((stream)->data_offset)++])		\
  |  |  399|  2.24k|  : _gpgrt__getc_underflow ((stream)))
  ------------------
 4603|  2.24k|  unlock_stream (stream);
 4604|       |
 4605|  2.24k|  return ret;
 4606|  2.24k|}
_gpgrt_fread:
 4679|    410|{
 4680|    410|  size_t ret, bytes;
 4681|       |
 4682|    410|  if (size && nitems)
  ------------------
  |  Branch (4682:7): [True: 410, False: 0]
  |  Branch (4682:15): [True: 410, False: 0]
  ------------------
 4683|    410|    {
 4684|    410|      lock_stream (stream);
 4685|    410|      es_readn (stream, ptr, size * nitems, &bytes);
 4686|    410|      unlock_stream (stream);
 4687|       |
 4688|    410|      ret = bytes / size;
 4689|    410|    }
 4690|      0|  else
 4691|      0|    ret = 0;
 4692|       |
 4693|    410|  return ret;
 4694|    410|}
_gpgrt_fwrite:
 4700|     23|{
 4701|     23|  size_t ret, bytes;
 4702|       |
 4703|     23|  if (size && nitems)
  ------------------
  |  Branch (4703:7): [True: 23, False: 0]
  |  Branch (4703:15): [True: 23, False: 0]
  ------------------
 4704|     23|    {
 4705|     23|      lock_stream (stream);
 4706|     23|      es_writen (stream, ptr, size * nitems, &bytes);
 4707|     23|      unlock_stream (stream);
 4708|       |
 4709|     23|      ret = bytes / size;
 4710|     23|    }
 4711|      0|  else
 4712|      0|    ret = 0;
 4713|       |
 4714|     23|  return ret;
 4715|     23|}
_gpgrt_vfprintf_unlocked:
 4961|  22.6k|{
 4962|  22.6k|  return do_print_stream (stream, sf, sfvalue, format, ap);
 4963|  22.6k|}
_gpgrt_fprintf_unlocked:
 4985|  12.3k|{
 4986|  12.3k|  int ret;
 4987|       |
 4988|  12.3k|  va_list ap;
 4989|  12.3k|  va_start (ap, format);
 4990|  12.3k|  ret = do_print_stream (stream, NULL, NULL, format, ap);
 4991|  12.3k|  va_end (ap);
 4992|       |
 4993|  12.3k|  return ret;
 4994|  12.3k|}
_gpgrt_setvbuf:
 5145|      2|{
 5146|      2|  int err;
 5147|       |
 5148|      2|  if ((type == _IOFBF || type == _IOLBF || type == _IONBF)
  ------------------
  |  Branch (5148:8): [True: 0, False: 2]
  |  Branch (5148:26): [True: 2, False: 0]
  |  Branch (5148:44): [True: 0, False: 0]
  ------------------
 5149|      2|      && (!buf || size || type == _IONBF))
  ------------------
  |  Branch (5149:11): [True: 2, False: 0]
  |  Branch (5149:19): [True: 0, False: 0]
  |  Branch (5149:27): [True: 0, False: 0]
  ------------------
 5150|      2|    {
 5151|      2|      lock_stream (stream);
 5152|      2|      err = es_set_buffering (stream, buf, type, size);
 5153|      2|      unlock_stream (stream);
 5154|      2|    }
 5155|      0|  else
 5156|      0|    {
 5157|      0|      _set_errno (EINVAL);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 5158|      0|      err = -1;
 5159|      0|    }
 5160|       |
 5161|      2|  return err;
 5162|      2|}
_gpgrt_write_sanitized:
 5665|    827|{
 5666|    827|  const unsigned char *p = buffer;
 5667|    827|  size_t count = 0;
 5668|    827|  int ret;
 5669|       |
 5670|    827|  lock_stream (stream);
 5671|  46.9k|  for (; length; length--, p++, count++)
  ------------------
  |  Branch (5671:10): [True: 46.0k, False: 827]
  ------------------
 5672|  46.0k|    {
 5673|  46.0k|      if (*p < 0x20
  ------------------
  |  Branch (5673:11): [True: 9.67k, False: 36.4k]
  ------------------
 5674|  46.0k|          || *p == 0x7f
  ------------------
  |  Branch (5674:14): [True: 10.2k, False: 26.1k]
  ------------------
 5675|  46.0k|          || (delimiters
  ------------------
  |  Branch (5675:15): [True: 0, False: 26.1k]
  ------------------
 5676|  26.1k|              && (strchr (delimiters, *p) || *p == '\\')))
  ------------------
  |  Branch (5676:19): [True: 0, False: 0]
  |  Branch (5676:46): [True: 0, False: 0]
  ------------------
 5677|  19.9k|        {
 5678|  19.9k|          _gpgrt_putc_unlocked ('\\', stream);
  ------------------
  |  |  402|  19.9k|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 19.9k, False: 0]
  |  |  ------------------
  |  |  403|  19.9k|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 19.9k, False: 0]
  |  |  ------------------
  |  |  404|  19.9k|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|  19.9k|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|  19.9k|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
 5679|  19.9k|          count++;
 5680|  19.9k|          if (*p == '\n')
  ------------------
  |  Branch (5680:15): [True: 821, False: 19.0k]
  ------------------
 5681|    821|            {
 5682|    821|              _gpgrt_putc_unlocked ('n', stream);
  ------------------
  |  |  402|    821|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 821, False: 0]
  |  |  ------------------
  |  |  403|    821|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 821, False: 0]
  |  |  ------------------
  |  |  404|    821|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|    821|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|    821|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
 5683|    821|              count++;
 5684|    821|            }
 5685|  19.0k|          else if (*p == '\r')
  ------------------
  |  Branch (5685:20): [True: 1.22k, False: 17.8k]
  ------------------
 5686|  1.22k|            {
 5687|  1.22k|              _gpgrt_putc_unlocked ('r', stream);
  ------------------
  |  |  402|  1.22k|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 1.22k, False: 0]
  |  |  ------------------
  |  |  403|  1.22k|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 1.22k, False: 3]
  |  |  ------------------
  |  |  404|  1.22k|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|  1.22k|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|  1.22k|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
 5688|  1.22k|              count++;
 5689|  1.22k|            }
 5690|  17.8k|          else if (*p == '\f')
  ------------------
  |  Branch (5690:20): [True: 295, False: 17.5k]
  ------------------
 5691|    295|            {
 5692|    295|              _gpgrt_putc_unlocked ('f', stream);
  ------------------
  |  |  402|    295|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 295, False: 0]
  |  |  ------------------
  |  |  403|    295|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 295, False: 0]
  |  |  ------------------
  |  |  404|    295|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|    295|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|    295|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
 5693|    295|              count++;
 5694|    295|            }
 5695|  17.5k|          else if (*p == '\v')
  ------------------
  |  Branch (5695:20): [True: 2.06k, False: 15.4k]
  ------------------
 5696|  2.06k|            {
 5697|  2.06k|              _gpgrt_putc_unlocked ('v', stream);
  ------------------
  |  |  402|  2.06k|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 2.06k, False: 0]
  |  |  ------------------
  |  |  403|  2.06k|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 2.06k, False: 0]
  |  |  ------------------
  |  |  404|  2.06k|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|  2.06k|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|  2.06k|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
 5698|  2.06k|              count++;
 5699|  2.06k|            }
 5700|  15.4k|          else if (*p == '\b')
  ------------------
  |  Branch (5700:20): [True: 1, False: 15.4k]
  ------------------
 5701|      1|            {
 5702|      1|              _gpgrt_putc_unlocked ('b', stream);
  ------------------
  |  |  402|      1|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 1, False: 0]
  |  |  ------------------
  |  |  403|      1|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 1, False: 0]
  |  |  ------------------
  |  |  404|      1|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|      1|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|      1|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
 5703|      1|              count++;
 5704|      1|            }
 5705|  15.4k|          else if (!*p)
  ------------------
  |  Branch (5705:20): [True: 3.11k, False: 12.3k]
  ------------------
 5706|  3.11k|            {
 5707|  3.11k|              _gpgrt_putc_unlocked('0', stream);
  ------------------
  |  |  402|  3.11k|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 3.11k, False: 0]
  |  |  ------------------
  |  |  403|  3.11k|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 3.11k, False: 1]
  |  |  ------------------
  |  |  404|  3.11k|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|  3.11k|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|  3.11k|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
 5708|  3.11k|              count++;
 5709|  3.11k|            }
 5710|  12.3k|          else
 5711|  12.3k|            {
 5712|  12.3k|              _gpgrt_fprintf_unlocked (stream, "x%02x", *p);
 5713|  12.3k|              count += 3;
 5714|  12.3k|            }
 5715|  19.9k|	}
 5716|  26.1k|      else
 5717|  26.1k|        {
 5718|  26.1k|          _gpgrt_putc_unlocked (*p, stream);
  ------------------
  |  |  402|  26.1k|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 26.1k, False: 0]
  |  |  ------------------
  |  |  403|  26.1k|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 26.1k, False: 4]
  |  |  ------------------
  |  |  404|  26.1k|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [True: 26.1k, False: 0]
  |  |  ------------------
  |  |  405|  26.1k|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|  26.1k|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
 5719|  26.1k|          count++;
 5720|  26.1k|        }
 5721|  46.0k|    }
 5722|       |
 5723|    827|  if (bytes_written)
  ------------------
  |  Branch (5723:7): [True: 0, False: 827]
  ------------------
 5724|      0|    *bytes_written = count;
 5725|    827|  ret =  _gpgrt_ferror_unlocked (stream)? -1 : 0;
  ------------------
  |  Branch (5725:10): [True: 0, False: 827]
  ------------------
 5726|    827|  unlock_stream (stream);
 5727|       |
 5728|    827|  return ret;
 5729|    827|}
estream.c:parse_mode:
 2101|    249|{
 2102|    249|  unsigned int omode, oflags, cmode;
 2103|    249|  int got_cmode = 0;
 2104|       |
 2105|    249|  *r_xmode = 0;
 2106|       |
 2107|    249|  switch (*modestr)
 2108|    249|    {
 2109|    234|    case 'r':
  ------------------
  |  Branch (2109:5): [True: 234, False: 15]
  ------------------
 2110|    234|      omode = O_RDONLY;
 2111|    234|      oflags = 0;
 2112|    234|      break;
 2113|     13|    case 'w':
  ------------------
  |  Branch (2113:5): [True: 13, False: 236]
  ------------------
 2114|     13|      omode = O_WRONLY;
 2115|     13|      oflags = O_TRUNC | O_CREAT;
 2116|     13|      break;
 2117|      2|    case 'a':
  ------------------
  |  Branch (2117:5): [True: 2, False: 247]
  ------------------
 2118|      2|      omode = O_WRONLY;
 2119|      2|      oflags = O_APPEND | O_CREAT;
 2120|      2|      break;
 2121|      0|    default:
  ------------------
  |  Branch (2121:5): [True: 0, False: 249]
  ------------------
 2122|      0|      _set_errno (EINVAL);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2123|      0|      return -1;
 2124|    249|    }
 2125|    496|  for (modestr++; *modestr; modestr++)
  ------------------
  |  Branch (2125:19): [True: 247, False: 249]
  ------------------
 2126|    247|    {
 2127|    247|      switch (*modestr)
 2128|    247|        {
 2129|      0|        case '+':
  ------------------
  |  Branch (2129:9): [True: 0, False: 247]
  ------------------
 2130|      0|          omode = O_RDWR;
 2131|      0|          break;
 2132|    247|        case 'b':
  ------------------
  |  Branch (2132:9): [True: 247, False: 0]
  ------------------
 2133|    247|          oflags |= O_BINARY;
  ------------------
  |  |  106|    247|# define O_BINARY 0
  ------------------
 2134|    247|          break;
 2135|      0|        case 'x':
  ------------------
  |  Branch (2135:9): [True: 0, False: 247]
  ------------------
 2136|      0|          oflags |= O_EXCL;
 2137|      0|          break;
 2138|      0|        case ',':
  ------------------
  |  Branch (2138:9): [True: 0, False: 247]
  ------------------
 2139|      0|          goto keyvalue;
 2140|      0|        default: /* Ignore unknown flags.  */
  ------------------
  |  Branch (2140:9): [True: 0, False: 247]
  ------------------
 2141|      0|          break;
 2142|    247|        }
 2143|    247|    }
 2144|       |
 2145|    249| keyvalue:
 2146|       |  /* Parse key/value pairs (similar to fopen on mainframes).  */
 2147|    249|  for (cmode=0; *modestr == ','; modestr += strcspn (modestr, ","))
  ------------------
  |  Branch (2147:17): [True: 0, False: 249]
  ------------------
 2148|      0|    {
 2149|      0|      modestr++;
 2150|      0|      modestr += strspn (modestr, " \t");
 2151|      0|      if (!strncmp (modestr, "mode=", 5))
  ------------------
  |  Branch (2151:11): [True: 0, False: 0]
  ------------------
 2152|      0|        {
 2153|      0|          static struct {
 2154|      0|            char letter;
 2155|      0|            unsigned int value;
 2156|      0|          } table[] = { { '-', 0 },
 2157|      0|                        { 'r', S_IRUSR }, { 'w', S_IWUSR }, { 'x', S_IXUSR },
 2158|      0|                        { 'r', S_IRGRP }, { 'w', S_IWGRP }, { 'x', S_IXGRP },
 2159|      0|                        { 'r', S_IROTH }, { 'w', S_IWOTH }, { 'x', S_IXOTH }};
 2160|      0|          int idx;
 2161|       |
 2162|      0|          got_cmode = 1;
 2163|      0|          modestr += 5;
 2164|       |          /* For now we only support a string as used by ls(1) and no
 2165|       |             octal numbers.  The first character must be a dash.  */
 2166|      0|          for (idx=0; idx < 10 && *modestr; idx++, modestr++)
  ------------------
  |  Branch (2166:23): [True: 0, False: 0]
  |  Branch (2166:35): [True: 0, False: 0]
  ------------------
 2167|      0|            {
 2168|      0|              if (*modestr == table[idx].letter)
  ------------------
  |  Branch (2168:19): [True: 0, False: 0]
  ------------------
 2169|      0|                cmode |= table[idx].value;
 2170|      0|              else if (*modestr != '-')
  ------------------
  |  Branch (2170:24): [True: 0, False: 0]
  ------------------
 2171|      0|                break;
 2172|      0|            }
 2173|      0|          if (*modestr && !strchr (" \t,", *modestr))
  ------------------
  |  Branch (2173:15): [True: 0, False: 0]
  |  Branch (2173:27): [True: 0, False: 0]
  ------------------
 2174|      0|            {
 2175|      0|              _set_errno (EINVAL);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2176|      0|              return -1;
 2177|      0|            }
 2178|      0|        }
 2179|      0|      else if (!strncmp (modestr, "samethread", 10))
  ------------------
  |  Branch (2179:16): [True: 0, False: 0]
  ------------------
 2180|      0|        {
 2181|      0|          modestr += 10;
 2182|      0|          if (*modestr && !strchr (" \t,", *modestr))
  ------------------
  |  Branch (2182:15): [True: 0, False: 0]
  |  Branch (2182:27): [True: 0, False: 0]
  ------------------
 2183|      0|            {
 2184|      0|              _set_errno (EINVAL);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2185|      0|              return -1;
 2186|      0|            }
 2187|      0|          *r_xmode |= X_SAMETHREAD;
  ------------------
  |  | 2044|      0|#define X_SAMETHREAD	(1 << 0)
  ------------------
 2188|      0|        }
 2189|      0|      else if (!strncmp (modestr, "nonblock", 8))
  ------------------
  |  Branch (2189:16): [True: 0, False: 0]
  ------------------
 2190|      0|        {
 2191|      0|          modestr += 8;
 2192|      0|          if (*modestr && !strchr (" \t,", *modestr))
  ------------------
  |  Branch (2192:15): [True: 0, False: 0]
  |  Branch (2192:27): [True: 0, False: 0]
  ------------------
 2193|      0|            {
 2194|      0|              _set_errno (EINVAL);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2195|      0|              return -1;
 2196|      0|            }
 2197|      0|          oflags |= O_NONBLOCK;
 2198|       |#if HAVE_W32_SYSTEM
 2199|       |          /* Currently, nonblock implies pollable on Windows.  */
 2200|       |          *r_xmode |= X_POLLABLE;
 2201|       |#endif
 2202|      0|        }
 2203|      0|      else if (!strncmp (modestr, "sysopen", 7))
  ------------------
  |  Branch (2203:16): [True: 0, False: 0]
  ------------------
 2204|      0|        {
 2205|      0|          modestr += 7;
 2206|      0|          if (*modestr && !strchr (" \t,", *modestr))
  ------------------
  |  Branch (2206:15): [True: 0, False: 0]
  |  Branch (2206:27): [True: 0, False: 0]
  ------------------
 2207|      0|            {
 2208|      0|              _set_errno (EINVAL);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2209|      0|              return -1;
 2210|      0|            }
 2211|      0|          *r_xmode |= X_SYSOPEN;
  ------------------
  |  | 2045|      0|#define X_SYSOPEN	(1 << 1)
  ------------------
 2212|      0|        }
 2213|      0|      else if (!strncmp (modestr, "pollable", 8))
  ------------------
  |  Branch (2213:16): [True: 0, False: 0]
  ------------------
 2214|      0|        {
 2215|      0|          modestr += 8;
 2216|      0|          if (*modestr && !strchr (" \t,", *modestr))
  ------------------
  |  Branch (2216:15): [True: 0, False: 0]
  |  Branch (2216:27): [True: 0, False: 0]
  ------------------
 2217|      0|            {
 2218|      0|              _set_errno (EINVAL);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2219|      0|              return -1;
 2220|      0|            }
 2221|      0|          *r_xmode |= X_POLLABLE;
  ------------------
  |  | 2046|      0|#define X_POLLABLE	(1 << 2)
  ------------------
 2222|      0|        }
 2223|      0|    }
 2224|    249|  if (!got_cmode)
  ------------------
  |  Branch (2224:7): [True: 249, False: 0]
  ------------------
 2225|    249|    cmode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
 2226|       |
 2227|    249|  *modeflags = (omode | oflags);
 2228|    249|  if (r_cmode)
  ------------------
  |  Branch (2228:7): [True: 249, False: 0]
  ------------------
 2229|    249|    *r_cmode = cmode;
 2230|    249|  return 0;
 2231|    249|}
estream.c:func_fd_read:
 1008|    584|{
 1009|    584|  estream_cookie_fd_t file_cookie = cookie;
 1010|    584|  gpgrt_ssize_t bytes_read;
 1011|       |
 1012|    584|  trace (("enter: cookie=%p buffer=%p size=%d", cookie, buffer, (int)size));
  ------------------
  |  |  189|    584|# define trace(X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (189:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1013|       |
 1014|    584|  if (!size)
  ------------------
  |  Branch (1014:7): [True: 0, False: 584]
  ------------------
 1015|      0|    bytes_read = -1; /* We don't know whether anything is pending.  */
 1016|    584|  else if (IS_INVALID_FD (file_cookie->fd))
  ------------------
  |  |  148|    584|#define IS_INVALID_FD(a)    ((a) == -1)
  |  |  ------------------
  |  |  |  Branch (148:29): [True: 0, False: 584]
  |  |  ------------------
  ------------------
 1017|      0|    {
 1018|      0|      _gpgrt_yield ();
 1019|      0|      bytes_read = 0;
 1020|      0|    }
 1021|    584|  else
 1022|    584|    {
 1023|    584|      _gpgrt_pre_syscall ();
 1024|    584|      do
 1025|    584|        {
 1026|    584|          bytes_read = read (file_cookie->fd, buffer, size);
 1027|    584|        }
 1028|    584|      while (bytes_read == -1 && errno == EINTR);
  ------------------
  |  Branch (1028:14): [True: 0, False: 584]
  |  Branch (1028:34): [True: 0, False: 0]
  ------------------
 1029|    584|      _gpgrt_post_syscall ();
 1030|    584|    }
 1031|       |
 1032|    584|  trace_errno (bytes_read == -1, ("leave: bytes_read=%d", (int)bytes_read));
  ------------------
  |  |  190|    584|# define trace_errno(C,X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (190:41): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1033|    584|  return bytes_read;
 1034|    584|}
estream.c:func_fd_write:
 1042|  64.4k|{
 1043|  64.4k|  estream_cookie_fd_t file_cookie = cookie;
 1044|  64.4k|  gpgrt_ssize_t bytes_written;
 1045|       |
 1046|  64.4k|  trace (("enter: cookie=%p buffer=%p size=%d", cookie, buffer, (int)size));
  ------------------
  |  |  189|  64.4k|# define trace(X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (189:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1047|       |
 1048|  64.4k|  if (IS_INVALID_FD (file_cookie->fd))
  ------------------
  |  |  148|  64.4k|#define IS_INVALID_FD(a)    ((a) == -1)
  |  |  ------------------
  |  |  |  Branch (148:29): [True: 0, False: 64.4k]
  |  |  ------------------
  ------------------
 1049|      0|    {
 1050|      0|      _gpgrt_yield ();
 1051|      0|      bytes_written = size; /* Yeah:  Success writing to the bit bucket.  */
 1052|      0|    }
 1053|  64.4k|  else if (buffer)
  ------------------
  |  Branch (1053:12): [True: 42.6k, False: 21.8k]
  ------------------
 1054|  42.6k|    {
 1055|  42.6k|      _gpgrt_pre_syscall ();
 1056|  42.6k|      do
 1057|  42.6k|        {
 1058|  42.6k|          bytes_written = write (file_cookie->fd, buffer, size);
 1059|  42.6k|        }
 1060|  42.6k|      while (bytes_written == -1 && errno == EINTR);
  ------------------
  |  Branch (1060:14): [True: 0, False: 42.6k]
  |  Branch (1060:37): [True: 0, False: 0]
  ------------------
 1061|  42.6k|      _gpgrt_post_syscall ();
 1062|  42.6k|    }
 1063|  21.8k|  else
 1064|  21.8k|    bytes_written = size; /* Note that for a flush SIZE should be 0.  */
 1065|       |
 1066|  64.4k|  trace_errno (bytes_written == -1,
  ------------------
  |  |  190|  64.4k|# define trace_errno(C,X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (190:41): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1067|  64.4k|               ("leave: bytes_written=%d", (int)bytes_written));
 1068|  64.4k|  return bytes_written;
 1069|  64.4k|}
estream.c:func_fd_seek:
 1077|  1.29k|{
 1078|  1.29k|  estream_cookie_fd_t file_cookie = cookie;
 1079|  1.29k|  gpgrt_off_t offset_new;
 1080|  1.29k|  int err;
 1081|       |
 1082|  1.29k|  if (IS_INVALID_FD (file_cookie->fd))
  ------------------
  |  |  148|  1.29k|#define IS_INVALID_FD(a)    ((a) == -1)
  |  |  ------------------
  |  |  |  Branch (148:29): [True: 0, False: 1.29k]
  |  |  ------------------
  ------------------
 1083|      0|    {
 1084|      0|      _set_errno (ESPIPE);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1085|      0|      err = -1;
 1086|      0|    }
 1087|  1.29k|  else
 1088|  1.29k|    {
 1089|  1.29k|      _gpgrt_pre_syscall ();
 1090|  1.29k|      offset_new = lseek (file_cookie->fd, *offset, whence);
 1091|  1.29k|      _gpgrt_post_syscall ();
 1092|  1.29k|      if (offset_new == -1)
  ------------------
  |  Branch (1092:11): [True: 0, False: 1.29k]
  ------------------
 1093|      0|        err = -1;
 1094|  1.29k|      else
 1095|  1.29k|        {
 1096|  1.29k|          *offset = offset_new;
 1097|  1.29k|          err = 0;
 1098|  1.29k|        }
 1099|  1.29k|    }
 1100|       |
 1101|  1.29k|  return err;
 1102|  1.29k|}
estream.c:func_file_create:
 1890|    248|{
 1891|    248|  estream_cookie_fd_t file_cookie;
 1892|    248|  int err;
 1893|    248|  int fd;
 1894|       |
 1895|    248|  err = 0;
 1896|       |
 1897|    248|  file_cookie = mem_alloc (sizeof (*file_cookie));
 1898|    248|  if (! file_cookie)
  ------------------
  |  Branch (1898:7): [True: 0, False: 248]
  ------------------
 1899|      0|    {
 1900|      0|      err = -1;
 1901|      0|      goto out;
 1902|      0|    }
 1903|       |
 1904|       |#ifdef HAVE_W32_SYSTEM
 1905|       |  if (any8bitchar (path))
 1906|       |    {
 1907|       |      wchar_t *wpath;
 1908|       |
 1909|       |      wpath = _gpgrt_utf8_to_wchar (path);
 1910|       |      if (!wpath)
 1911|       |        fd = -1;
 1912|       |      else
 1913|       |        {
 1914|       |          fd = _wopen (wpath, modeflags, cmode);
 1915|       |          _gpgrt_free_wchar (wpath);
 1916|       |        }
 1917|       |    }
 1918|       |  else  /* Avoid unnecessary conversion.  */
 1919|       |    fd = open (path, modeflags, cmode);
 1920|       |#else
 1921|    248|  fd = open (path, modeflags, cmode);
 1922|    248|#endif
 1923|    248|  if (fd == -1)
  ------------------
  |  Branch (1923:7): [True: 2, False: 246]
  ------------------
 1924|      2|    {
 1925|      2|      err = -1;
 1926|      2|      goto out;
 1927|      2|    }
 1928|       |#ifdef HAVE_DOSISH_SYSTEM
 1929|       |  /* Make sure it is in binary mode if requested.  */
 1930|       |  if ( (modeflags & O_BINARY) )
 1931|       |    setmode (fd, O_BINARY);
 1932|       |#endif
 1933|       |
 1934|    246|  file_cookie->fd = fd;
 1935|    246|  file_cookie->no_close = 0;
 1936|    246|  *cookie = file_cookie;
 1937|    246|  *filedes = fd;
 1938|       |
 1939|    248| out:
 1940|       |
 1941|    248|  if (err)
  ------------------
  |  Branch (1941:7): [True: 2, False: 246]
  ------------------
 1942|      2|    mem_free (file_cookie);
 1943|       |
 1944|    248|  return err;
 1945|    246|}
estream.c:create_stream:
 2490|    247|{
 2491|    247|  estream_internal_t stream_internal_new;
 2492|    247|  estream_t stream_new;
 2493|    247|  int err;
 2494|       |#if HAVE_W32_SYSTEM
 2495|       |  void *old_cookie = NULL;
 2496|       |#endif
 2497|       |
 2498|    247|  stream_new = NULL;
 2499|    247|  stream_internal_new = NULL;
 2500|       |
 2501|       |#if HAVE_W32_SYSTEM
 2502|       |  if ((xmode & X_POLLABLE) && kind != BACKEND_W32)
 2503|       |    {
 2504|       |      /* We require the W32 backend, because only that allows us to
 2505|       |       * write directly using the native W32 API and to disable the
 2506|       |       * system clamp.  Note that func_w32_create has already been
 2507|       |       * called with the flag to disable the system call clamp.  */
 2508|       |      _set_errno (EINVAL);
 2509|       |      err = -1;
 2510|       |      goto out;
 2511|       |    }
 2512|       |#endif /*HAVE_W32_SYSTEM*/
 2513|       |
 2514|    247|  stream_new = mem_alloc (sizeof (*stream_new));
 2515|    247|  if (! stream_new)
  ------------------
  |  Branch (2515:7): [True: 0, False: 247]
  ------------------
 2516|      0|    {
 2517|      0|      err = -1;
 2518|      0|      goto out;
 2519|      0|    }
 2520|       |
 2521|    247|  stream_internal_new = mem_alloc (sizeof (*stream_internal_new));
 2522|    247|  if (! stream_internal_new)
  ------------------
  |  Branch (2522:7): [True: 0, False: 247]
  ------------------
 2523|      0|    {
 2524|      0|      err = -1;
 2525|      0|      goto out;
 2526|      0|    }
 2527|       |
 2528|    247|  stream_new->buffer = stream_internal_new->buffer;
 2529|    247|  stream_new->buffer_size = sizeof (stream_internal_new->buffer);
 2530|    247|  stream_new->unread_buffer = stream_internal_new->unread_buffer;
 2531|    247|  stream_new->unread_buffer_size = sizeof (stream_internal_new->unread_buffer);
 2532|    247|  stream_new->intern = stream_internal_new;
 2533|       |
 2534|       |#if HAVE_W32_SYSTEM
 2535|       |  if ((xmode & X_POLLABLE))
 2536|       |    {
 2537|       |      void *new_cookie;
 2538|       |
 2539|       |      err = _gpgrt_w32_pollable_create (&new_cookie, modeflags,
 2540|       |                                        functions, cookie);
 2541|       |      if (err)
 2542|       |        goto out;
 2543|       |
 2544|       |      modeflags &= ~O_NONBLOCK;
 2545|       |      old_cookie = cookie;
 2546|       |      cookie = new_cookie;
 2547|       |      kind = BACKEND_W32_POLLABLE;
 2548|       |      functions = _gpgrt_functions_w32_pollable;
 2549|       |    }
 2550|       |#endif /*HAVE_W32_SYSTEM*/
 2551|       |
 2552|    247|  init_stream_obj (stream_new, cookie, syshd, kind, functions, modeflags,
 2553|    247|                   xmode);
 2554|    247|  init_stream_lock (stream_new);
 2555|       |
 2556|    247|  err = do_list_add (stream_new, with_locked_list);
 2557|    247|  if (err)
  ------------------
  |  Branch (2557:7): [True: 0, False: 247]
  ------------------
 2558|      0|    goto out;
 2559|       |
 2560|    247|  *r_stream = stream_new;
 2561|       |
 2562|    247| out:
 2563|       |
 2564|    247|  if (err)
  ------------------
  |  Branch (2564:7): [True: 0, False: 247]
  ------------------
 2565|      0|    {
 2566|      0|      trace_errno (err, ("leave: err=%d", err));
  ------------------
  |  |  190|      0|# define trace_errno(C,X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (190:41): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2567|      0|      if (stream_new)
  ------------------
  |  Branch (2567:11): [True: 0, False: 0]
  ------------------
 2568|      0|	{
 2569|      0|	  deinit_stream_obj (stream_new);
 2570|      0|          destroy_stream_lock (stream_new);
 2571|      0|	  mem_free (stream_new->intern);
 2572|      0|	  mem_free (stream_new);
 2573|      0|	}
 2574|      0|    }
 2575|       |#if HAVE_W32_SYSTEM
 2576|       |  else if (old_cookie)
 2577|       |    trace (("leave: success stream=%p cookie=%p,%p",
 2578|       |            *r_stream, old_cookie, cookie));
 2579|       |#endif
 2580|    247|  else
 2581|    247|    trace (("leave: success stream=%p cookie=%p", *r_stream, cookie));
  ------------------
  |  |  189|    247|# define trace(X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (189:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2582|       |
 2583|    247|  return err;
 2584|    247|}
estream.c:init_stream_lock:
  399|    247|{
  400|    247|  int rc;
  401|       |
  402|    247|  if (!stream->intern->samethread)
  ------------------
  |  Branch (402:7): [True: 247, False: 0]
  ------------------
  403|    247|    {
  404|    247|      dbg_lock_1 ("enter init_stream_lock for %p\n", stream);
  405|    247|      memset (&stream->intern->lock, 0 , sizeof stream->intern->lock);
  406|    247|      rc = _gpgrt_lock_init (&stream->intern->lock);
  407|    247|      dbg_lock_2 ("leave init_stream_lock for %p: rc=%d\n", stream, rc);
  408|    247|    }
  409|      0|  else
  410|      0|    rc = 0;
  411|    247|  return rc;
  412|    247|}
estream.c:do_list_add:
  510|    247|{
  511|    247|  estream_list_t item;
  512|       |
  513|    247|  if (!with_locked_list)
  ------------------
  |  Branch (513:7): [True: 246, False: 1]
  ------------------
  514|    246|    lock_list ();
  515|       |
  516|    918|  for (item = estream_list; item && item->stream; item = item->next)
  ------------------
  |  Branch (516:29): [True: 671, False: 247]
  |  Branch (516:37): [True: 671, False: 0]
  ------------------
  517|    671|    ;
  518|    247|  if (!item)
  ------------------
  |  Branch (518:7): [True: 247, False: 0]
  ------------------
  519|    247|    {
  520|    247|      item = mem_alloc (sizeof *item);
  521|    247|      if (item)
  ------------------
  |  Branch (521:11): [True: 247, False: 0]
  ------------------
  522|    247|        {
  523|    247|          item->next = estream_list;
  524|    247|          estream_list = item;
  525|    247|        }
  526|    247|    }
  527|    247|  if (item)
  ------------------
  |  Branch (527:7): [True: 247, False: 0]
  ------------------
  528|    247|    item->stream = stream;
  529|       |
  530|    247|  if (!with_locked_list)
  ------------------
  |  Branch (530:7): [True: 246, False: 1]
  ------------------
  531|    246|    unlock_list ();
  532|       |
  533|    247|  return item? 0 : -1;
  ------------------
  |  Branch (533:10): [True: 247, False: 0]
  ------------------
  534|    247|}
estream.c:destroy_stream_lock:
  417|    245|{
  418|    245|  if (!stream->intern->samethread)
  ------------------
  |  Branch (418:7): [True: 245, False: 0]
  ------------------
  419|    245|    {
  420|    245|      dbg_lock_1 ("enter destroy_stream_lock for %p\n", stream);
  421|    245|      _gpgrt_lock_destroy (&stream->intern->lock);
  422|    245|      dbg_lock_1 ("leave destroy_stream_lock for %p\n", stream);
  423|    245|    }
  424|    245|}
estream.c:mem_free:
  224|  1.22k|{
  225|  1.22k|  if (p)
  ------------------
  |  Branch (225:7): [True: 1.22k, False: 0]
  ------------------
  226|  1.22k|    _gpgrt_free (p);
  227|  1.22k|}
estream.c:es_writen:
 3145|  94.4k|{
 3146|  94.4k|  size_t data_written;
 3147|  94.4k|  int err;
 3148|       |
 3149|  94.4k|  data_written = 0;
 3150|  94.4k|  err = 0;
 3151|       |
 3152|  94.4k|  if (!stream->flags.writing)
  ------------------
  |  Branch (3152:7): [True: 0, False: 94.4k]
  ------------------
 3153|      0|    {
 3154|       |      /* Switching to writing mode -> discard input data and seek to
 3155|       |	 position at which reading has stopped.  We can do this only
 3156|       |	 if a seek function has been registered. */
 3157|      0|      if (stream->intern->func_seek)
  ------------------
  |  Branch (3157:11): [True: 0, False: 0]
  ------------------
 3158|      0|        {
 3159|      0|          err = es_seek (stream, 0, SEEK_CUR, NULL);
 3160|      0|          if (err)
  ------------------
  |  Branch (3160:15): [True: 0, False: 0]
  ------------------
 3161|      0|            {
 3162|      0|              if (errno == ESPIPE)
  ------------------
  |  Branch (3162:19): [True: 0, False: 0]
  ------------------
 3163|      0|                err = 0;
 3164|      0|              else
 3165|      0|                goto out;
 3166|      0|            }
 3167|      0|          stream->flags.writing = 1;
 3168|      0|        }
 3169|      0|    }
 3170|       |
 3171|  94.4k|  switch (stream->intern->strategy)
  ------------------
  |  Branch (3171:11): [True: 0, False: 94.4k]
  ------------------
 3172|  94.4k|    {
 3173|      0|    case _IONBF:
  ------------------
  |  Branch (3173:5): [True: 0, False: 94.4k]
  ------------------
 3174|      0|      err = es_write_nbf (stream, buffer, bytes_to_write, &data_written);
 3175|      0|      break;
 3176|       |
 3177|  94.4k|    case _IOLBF:
  ------------------
  |  Branch (3177:5): [True: 94.4k, False: 23]
  ------------------
 3178|  94.4k|      err = es_write_lbf (stream, buffer, bytes_to_write, &data_written);
 3179|  94.4k|      break;
 3180|       |
 3181|     23|    case _IOFBF:
  ------------------
  |  Branch (3181:5): [True: 23, False: 94.4k]
  ------------------
 3182|     23|      err = es_write_fbf (stream, buffer, bytes_to_write, &data_written);
 3183|     23|      break;
 3184|  94.4k|    }
 3185|       |
 3186|  94.4k| out:
 3187|       |
 3188|  94.4k|  if (bytes_written)
  ------------------
  |  Branch (3188:7): [True: 94.4k, False: 8]
  ------------------
 3189|  94.4k|    *bytes_written = data_written;
 3190|       |
 3191|  94.4k|  return err;
 3192|  94.4k|}
estream.c:es_write_nbf:
 3015|  21.7k|{
 3016|  21.7k|  gpgrt_cookie_write_function_t func_write = stream->intern->func_write;
 3017|  21.7k|  size_t data_written;
 3018|  21.7k|  gpgrt_ssize_t ret;
 3019|  21.7k|  int err;
 3020|       |
 3021|  21.7k|  if (bytes_to_write && (! func_write))
  ------------------
  |  Branch (3021:7): [True: 21.7k, False: 0]
  |  Branch (3021:25): [True: 0, False: 21.7k]
  ------------------
 3022|      0|    {
 3023|      0|      _set_errno (EOPNOTSUPP);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3024|      0|      err = -1;
 3025|      0|      goto out;
 3026|      0|    }
 3027|       |
 3028|  21.7k|  data_written = 0;
 3029|  21.7k|  err = 0;
 3030|       |
 3031|  43.5k|  while (bytes_to_write - data_written)
  ------------------
  |  Branch (3031:10): [True: 21.7k, False: 21.7k]
  ------------------
 3032|  21.7k|    {
 3033|  21.7k|      ret = (*func_write) (stream->intern->cookie,
 3034|  21.7k|			   buffer + data_written,
 3035|  21.7k|			   bytes_to_write - data_written);
 3036|  21.7k|      if (ret == -1)
  ------------------
  |  Branch (3036:11): [True: 0, False: 21.7k]
  ------------------
 3037|      0|	{
 3038|      0|	  err = -1;
 3039|       |#if EWOULDBLOCK != EAGAIN
 3040|       |          if (errno == EWOULDBLOCK)
 3041|       |            _set_errno (EAGAIN);
 3042|       |#endif
 3043|      0|	  break;
 3044|      0|	}
 3045|  21.7k|      else
 3046|  21.7k|	data_written += ret;
 3047|  21.7k|    }
 3048|       |
 3049|  21.7k|  stream->intern->offset += data_written;
 3050|  21.7k|  *bytes_written = data_written;
 3051|       |
 3052|  21.7k| out:
 3053|       |
 3054|  21.7k|  return err;
 3055|  21.7k|}
estream.c:es_write_lbf:
 3111|  94.4k|{
 3112|  94.4k|  size_t data_flushed = 0;
 3113|  94.4k|  size_t data_buffered = 0;
 3114|  94.4k|  unsigned char *nlp;
 3115|  94.4k|  int err = 0;
 3116|       |
 3117|  94.4k|  nlp = memrchr (buffer, '\n', bytes_to_write);
 3118|  94.4k|  if (nlp)
  ------------------
  |  Branch (3118:7): [True: 21.7k, False: 72.6k]
  ------------------
 3119|  21.7k|    {
 3120|       |      /* Found a newline, directly write up to (including) this
 3121|       |	 character.  */
 3122|  21.7k|      err = flush_stream (stream);
 3123|  21.7k|      if (!err)
  ------------------
  |  Branch (3123:11): [True: 21.7k, False: 0]
  ------------------
 3124|  21.7k|	err = es_write_nbf (stream, buffer, nlp - buffer + 1, &data_flushed);
 3125|  21.7k|    }
 3126|       |
 3127|  94.4k|  if (!err)
  ------------------
  |  Branch (3127:7): [True: 94.4k, False: 0]
  ------------------
 3128|  94.4k|    {
 3129|       |      /* Write remaining data fully buffered.  */
 3130|  94.4k|      err = es_write_fbf (stream, buffer + data_flushed,
 3131|  94.4k|			  bytes_to_write - data_flushed, &data_buffered);
 3132|  94.4k|    }
 3133|       |
 3134|  94.4k|  *bytes_written = data_flushed + data_buffered;
 3135|  94.4k|  return err;
 3136|  94.4k|}
estream.c:es_write_fbf:
 3067|  94.4k|{
 3068|  94.4k|  size_t space_available;
 3069|  94.4k|  size_t data_to_write;
 3070|  94.4k|  size_t data_written;
 3071|  94.4k|  int err;
 3072|       |
 3073|  94.4k|  data_written = 0;
 3074|  94.4k|  err = 0;
 3075|       |
 3076|   167k|  while ((bytes_to_write - data_written) && (! err))
  ------------------
  |  Branch (3076:10): [True: 72.6k, False: 94.4k]
  |  Branch (3076:45): [True: 72.6k, False: 0]
  ------------------
 3077|  72.6k|    {
 3078|  72.6k|      if (stream->data_offset == stream->buffer_size)
  ------------------
  |  Branch (3078:11): [True: 8, False: 72.6k]
  ------------------
 3079|       |	/* Container full, flush buffer.  */
 3080|      8|	err = flush_stream (stream);
 3081|       |
 3082|  72.6k|      if (! err)
  ------------------
  |  Branch (3082:11): [True: 72.6k, False: 0]
  ------------------
 3083|  72.6k|	{
 3084|       |	  /* Flushing resulted in empty container.  */
 3085|       |
 3086|  72.6k|	  data_to_write = bytes_to_write - data_written;
 3087|  72.6k|	  space_available = stream->buffer_size - stream->data_offset;
 3088|  72.6k|	  if (data_to_write > space_available)
  ------------------
  |  Branch (3088:8): [True: 0, False: 72.6k]
  ------------------
 3089|      0|	    data_to_write = space_available;
 3090|       |
 3091|  72.6k|	  memcpy (stream->buffer + stream->data_offset,
 3092|  72.6k|		  buffer + data_written, data_to_write);
 3093|  72.6k|	  stream->data_offset += data_to_write;
 3094|  72.6k|	  data_written += data_to_write;
 3095|  72.6k|	}
 3096|  72.6k|    }
 3097|       |
 3098|  94.4k|  *bytes_written = data_written;
 3099|       |
 3100|  94.4k|  return err;
 3101|  94.4k|}
estream.c:es_seek:
 2944|  1.29k|{
 2945|  1.29k|  gpgrt_cookie_seek_function_t func_seek = stream->intern->func_seek;
 2946|  1.29k|  int err, ret;
 2947|  1.29k|  gpgrt_off_t off;
 2948|       |
 2949|  1.29k|  if (! func_seek)
  ------------------
  |  Branch (2949:7): [True: 0, False: 1.29k]
  ------------------
 2950|      0|    {
 2951|      0|      _set_errno (EOPNOTSUPP);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2952|      0|      err = -1;
 2953|      0|      goto out;
 2954|      0|    }
 2955|       |
 2956|  1.29k|  if (stream->flags.writing)
  ------------------
  |  Branch (2956:7): [True: 0, False: 1.29k]
  ------------------
 2957|      0|    {
 2958|       |      /* Flush data first in order to prevent flushing it to the wrong
 2959|       |	 offset.  */
 2960|      0|      err = flush_stream (stream);
 2961|      0|      if (err)
  ------------------
  |  Branch (2961:11): [True: 0, False: 0]
  ------------------
 2962|      0|	goto out;
 2963|      0|      stream->flags.writing = 0;
 2964|      0|    }
 2965|       |
 2966|  1.29k|  off = offset;
 2967|  1.29k|  if (whence == SEEK_CUR)
  ------------------
  |  Branch (2967:7): [True: 9, False: 1.28k]
  ------------------
 2968|      9|    {
 2969|      9|      off = off - stream->data_len + stream->data_offset;
 2970|      9|      off -= stream->unread_data_len;
 2971|      9|    }
 2972|       |
 2973|  1.29k|  ret = (*func_seek) (stream->intern->cookie, &off, whence);
 2974|  1.29k|  if (ret == -1)
  ------------------
  |  Branch (2974:7): [True: 0, False: 1.29k]
  ------------------
 2975|      0|    {
 2976|      0|      err = -1;
 2977|       |#if EWOULDBLOCK != EAGAIN
 2978|       |      if (errno == EWOULDBLOCK)
 2979|       |        _set_errno (EAGAIN);
 2980|       |#endif
 2981|      0|      goto out;
 2982|      0|    }
 2983|       |
 2984|  1.29k|  err = 0;
 2985|  1.29k|  es_empty (stream);
 2986|       |
 2987|  1.29k|  if (offset_new)
  ------------------
  |  Branch (2987:7): [True: 0, False: 1.29k]
  ------------------
 2988|      0|    *offset_new = off;
 2989|       |
 2990|  1.29k|  stream->intern->indicators.eof = 0;
 2991|  1.29k|  stream->intern->offset = off;
 2992|       |
 2993|  1.29k| out:
 2994|       |
 2995|  1.29k|  if (err)
  ------------------
  |  Branch (2995:7): [True: 0, False: 1.29k]
  ------------------
 2996|      0|    {
 2997|      0|      if (errno == EPIPE)
  ------------------
  |  Branch (2997:11): [True: 0, False: 0]
  ------------------
 2998|      0|        stream->intern->indicators.hup = 1;
 2999|      0|      stream->intern->indicators.err = 1;
 3000|      0|    }
 3001|       |
 3002|  1.29k|  return err;
 3003|  1.29k|}
estream.c:es_empty:
 2380|  1.29k|{
 2381|  1.29k|  gpgrt_assert (!stream->flags.writing);
  ------------------
  |  |  577|  1.29k|  ((expr)                                                       \
  |  |  ------------------
  |  |  |  Branch (577:4): [True: 1.29k, False: 0]
  |  |  ------------------
  |  |  578|  1.29k|   ? (void) 0                                                   \
  |  |  579|  1.29k|   : _gpgrt__log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
  ------------------
 2382|      0|  stream->data_len = 0;
 2383|  1.29k|  stream->data_offset = 0;
 2384|  1.29k|  stream->unread_data_len = 0;
 2385|  1.29k|}
estream.c:do_fpopen:
 3777|      1|{
 3778|      1|  unsigned int modeflags, cmode, xmode;
 3779|      1|  int create_called = 0;
 3780|      1|  estream_t stream = NULL;
 3781|      1|  void *cookie = NULL;
 3782|      1|  int err;
 3783|      1|  es_syshd_t syshd;
 3784|       |
 3785|      1|  err = parse_mode (mode, &modeflags, &xmode, &cmode);
 3786|      1|  if (err)
  ------------------
  |  Branch (3786:7): [True: 0, False: 1]
  ------------------
 3787|      0|    goto out;
 3788|      1|  if ((xmode & X_SYSOPEN))
  ------------------
  |  | 2045|      1|#define X_SYSOPEN	(1 << 1)
  ------------------
  |  Branch (3788:7): [True: 0, False: 1]
  ------------------
 3789|      0|    {
 3790|       |      /* Not allowed for fpopen.  */
 3791|      0|      _set_errno (EINVAL);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 3792|      0|      err = -1;
 3793|      0|      goto out;
 3794|      0|    }
 3795|       |
 3796|      1|  if (fp)
  ------------------
  |  Branch (3796:7): [True: 1, False: 0]
  ------------------
 3797|      1|    fflush (fp);
 3798|      1|  err = func_fp_create (&cookie, fp, modeflags, no_close);
 3799|      1|  if (err)
  ------------------
  |  Branch (3799:7): [True: 0, False: 1]
  ------------------
 3800|      0|    goto out;
 3801|       |
 3802|      1|  syshd.type = ES_SYSHD_FD;
  ------------------
  |  | 1255|      1|#define ES_SYSHD_FD     GPGRT_SYSHD_FD
  ------------------
 3803|      1|  syshd.u.fd = fp? fileno (fp): -1;
  ------------------
  |  Branch (3803:16): [True: 1, False: 0]
  ------------------
 3804|      1|  create_called = 1;
 3805|      1|  err = create_stream (&stream, cookie, &syshd,
 3806|      1|                       BACKEND_FP, estream_functions_fp,
 3807|      1|                       modeflags, xmode, with_locked_list);
 3808|       |
 3809|      1| out:
 3810|      1|  if (err && create_called)
  ------------------
  |  Branch (3810:7): [True: 0, False: 1]
  |  Branch (3810:14): [True: 0, False: 0]
  ------------------
 3811|      0|    (*estream_functions_fp.public.func_close) (cookie);
 3812|       |
 3813|      1|  return stream;
 3814|      1|}
estream.c:func_fp_create:
 1681|      1|{
 1682|      1|  estream_cookie_fp_t fp_cookie;
 1683|      1|  int err;
 1684|       |
 1685|      1|  fp_cookie = mem_alloc (sizeof *fp_cookie);
 1686|      1|  if (!fp_cookie)
  ------------------
  |  Branch (1686:7): [True: 0, False: 1]
  ------------------
 1687|      0|    err = -1;
 1688|      1|  else
 1689|      1|    {
 1690|       |#ifdef HAVE_DOSISH_SYSTEM
 1691|       |      /* Make sure it is in binary mode if requested.  */
 1692|       |      if ( (modeflags & O_BINARY) )
 1693|       |        setmode (fileno (fp), O_BINARY);
 1694|       |#else
 1695|      1|      (void)modeflags;
 1696|      1|#endif
 1697|      1|      fp_cookie->fp = fp;
 1698|      1|      fp_cookie->no_close = no_close;
 1699|      1|      *cookie = fp_cookie;
 1700|      1|      err = 0;
 1701|      1|    }
 1702|       |
 1703|      1|  return err;
 1704|      1|}
estream.c:func_fp_write:
 1739|      8|{
 1740|      8|  estream_cookie_fp_t file_cookie = cookie;
 1741|      8|  size_t bytes_written;
 1742|       |
 1743|      8|  if (file_cookie->fp)
  ------------------
  |  Branch (1743:7): [True: 8, False: 0]
  ------------------
 1744|      8|    {
 1745|      8|      _gpgrt_pre_syscall ();
 1746|      8|      if (buffer)
  ------------------
  |  Branch (1746:11): [True: 4, False: 4]
  ------------------
 1747|      4|        {
 1748|       |#ifdef HAVE_W32_SYSTEM
 1749|       |          /* Using an fwrite to stdout connected to the console fails
 1750|       |             with the error "Not enough space" for an fwrite size of
 1751|       |             >= 52KB (tested on Windows XP SP2).  To solve this we
 1752|       |             always chunk the writes up into smaller blocks.  */
 1753|       |          bytes_written = 0;
 1754|       |          while (bytes_written < size)
 1755|       |            {
 1756|       |              size_t cnt = size - bytes_written;
 1757|       |
 1758|       |              if (cnt > 32*1024)
 1759|       |                cnt = 32*1024;
 1760|       |              if (fwrite ((const char*)buffer + bytes_written,
 1761|       |                          cnt, 1, file_cookie->fp) != 1)
 1762|       |                break; /* Write error.  */
 1763|       |              bytes_written += cnt;
 1764|       |            }
 1765|       |#else
 1766|      4|          bytes_written = fwrite (buffer, 1, size, file_cookie->fp);
 1767|      4|#endif
 1768|      4|        }
 1769|      4|      else /* Only flush requested.  */
 1770|      4|        bytes_written = size;
 1771|       |
 1772|      8|      fflush (file_cookie->fp);
 1773|      8|      _gpgrt_post_syscall ();
 1774|      8|    }
 1775|      0|  else
 1776|      0|    bytes_written = size; /* Successfully written to the bit bucket.  */
 1777|       |
 1778|      8|  if (bytes_written != size)
  ------------------
  |  Branch (1778:7): [True: 0, False: 8]
  ------------------
 1779|      0|    return -1;
 1780|      8|  return bytes_written;
 1781|      8|}
estream.c:lock_list:
  470|    494|{
  471|    494|  dbg_lock_0 ("enter lock_list\n");
  472|    494|  _gpgrt_lock_lock (&estream_list_lock);
  473|    494|  dbg_lock_0 ("leave lock_list\n");
  474|    494|}
estream.c:unlock_list:
  479|    494|{
  480|    494|  dbg_lock_0 ("enter unlock_list\n");
  481|    494|  _gpgrt_lock_unlock (&estream_list_lock);
  482|    494|  dbg_lock_0 ("leave unlock_list\n");
  483|    494|}
estream.c:es_set_buffering:
 3419|      3|{
 3420|      3|  int err;
 3421|       |
 3422|       |  /* Flush or empty buffer depending on mode.  */
 3423|      3|  if (stream->flags.writing)
  ------------------
  |  Branch (3423:7): [True: 3, False: 0]
  ------------------
 3424|      3|    {
 3425|      3|      err = flush_stream (stream);
 3426|      3|      if (err)
  ------------------
  |  Branch (3426:11): [True: 0, False: 3]
  ------------------
 3427|      0|	goto out;
 3428|      3|    }
 3429|      0|  else
 3430|      0|    es_empty (stream);
 3431|       |
 3432|      3|  stream->intern->indicators.eof = 0;
 3433|       |
 3434|       |  /* Free old buffer in case that was allocated by this function.  */
 3435|      3|  if (stream->intern->deallocate_buffer)
  ------------------
  |  Branch (3435:7): [True: 1, False: 2]
  ------------------
 3436|      1|    {
 3437|      1|      stream->intern->deallocate_buffer = 0;
 3438|      1|      mem_free (stream->buffer);
 3439|      1|      stream->buffer = NULL;
 3440|      1|    }
 3441|       |
 3442|      3|  if (mode == _IONBF)
  ------------------
  |  Branch (3442:7): [True: 0, False: 3]
  ------------------
 3443|      0|    stream->buffer_size = 0;
 3444|      3|  else
 3445|      3|    {
 3446|      3|      void *buffer_new;
 3447|       |
 3448|      3|      if (buffer)
  ------------------
  |  Branch (3448:11): [True: 0, False: 3]
  ------------------
 3449|      0|	buffer_new = buffer;
 3450|      3|      else
 3451|      3|	{
 3452|      3|          if (!size)
  ------------------
  |  Branch (3452:15): [True: 3, False: 0]
  ------------------
 3453|      3|            size = BUFSIZ;
 3454|      3|	  buffer_new = mem_alloc (size);
 3455|      3|	  if (! buffer_new)
  ------------------
  |  Branch (3455:8): [True: 0, False: 3]
  ------------------
 3456|      0|	    {
 3457|      0|	      err = -1;
 3458|      0|	      goto out;
 3459|      0|	    }
 3460|      3|	}
 3461|       |
 3462|      3|      stream->buffer = buffer_new;
 3463|      3|      stream->buffer_size = size;
 3464|      3|      if (! buffer)
  ------------------
  |  Branch (3464:11): [True: 3, False: 0]
  ------------------
 3465|      3|	stream->intern->deallocate_buffer = 1;
 3466|      3|    }
 3467|      3|  stream->intern->strategy = mode;
 3468|      3|  err = 0;
 3469|       |
 3470|      3| out:
 3471|       |
 3472|      3|  return err;
 3473|      3|}
estream.c:lock_stream:
  429|  28.3k|{
  430|  28.3k|  if (!stream->intern->samethread)
  ------------------
  |  Branch (430:7): [True: 28.3k, False: 0]
  ------------------
  431|  28.3k|    {
  432|  28.3k|      dbg_lock_1 ("enter lock_stream for %p\n", stream);
  433|  28.3k|      _gpgrt_lock_lock (&stream->intern->lock);
  434|  28.3k|      dbg_lock_1 ("leave lock_stream for %p\n", stream);
  435|  28.3k|    }
  436|  28.3k|}
estream.c:deinit_stream_obj:
 2443|    245|{
 2444|    245|  gpgrt_cookie_close_function_t func_close;
 2445|    245|  int err, tmp_err;
 2446|       |
 2447|    245|  trace (("enter: stream %p", stream));
  ------------------
  |  |  189|    245|# define trace(X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (189:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2448|    245|  func_close = stream->intern->func_close;
 2449|       |
 2450|    245|  err = 0;
 2451|    245|  if (stream->flags.writing)
  ------------------
  |  Branch (2451:7): [True: 13, False: 232]
  ------------------
 2452|     13|    {
 2453|     13|      tmp_err = flush_stream (stream);
 2454|     13|      if (!err)
  ------------------
  |  Branch (2454:11): [True: 13, False: 0]
  ------------------
 2455|     13|        err = tmp_err;
 2456|     13|    }
 2457|    245|  if (func_close)
  ------------------
  |  Branch (2457:7): [True: 245, False: 0]
  ------------------
 2458|    245|    {
 2459|    245|      trace (("stream %p calling func_close", stream));
  ------------------
  |  |  189|    245|# define trace(X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (189:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2460|    245|      tmp_err = func_close (stream->intern->cookie);
 2461|    245|      if (!err)
  ------------------
  |  Branch (2461:11): [True: 245, False: 0]
  ------------------
 2462|    245|        err = tmp_err;
 2463|    245|    }
 2464|       |
 2465|    245|  mem_free (stream->intern->printable_fname);
 2466|    245|  stream->intern->printable_fname = NULL;
 2467|    245|  stream->intern->printable_fname_inuse = 0;
 2468|    245|  while (stream->intern->onclose)
  ------------------
  |  Branch (2468:10): [True: 0, False: 245]
  ------------------
 2469|      0|    {
 2470|      0|      notify_list_t tmp = stream->intern->onclose->next;
 2471|      0|      mem_free (stream->intern->onclose);
 2472|      0|      stream->intern->onclose = tmp;
 2473|      0|    }
 2474|       |
 2475|    245|  trace_errno (err, ("leave: stream %p err=%d", stream, err));
  ------------------
  |  |  190|    245|# define trace_errno(C,X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (190:41): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2476|    245|  return err;
 2477|    245|}
estream.c:init_stream_obj:
 2397|    247|{
 2398|    247|  stream->intern->kind = kind;
 2399|    247|  stream->intern->cookie = cookie;
 2400|    247|  stream->intern->opaque = NULL;
 2401|    247|  stream->intern->offset = 0;
 2402|    247|  stream->intern->func_read = functions.public.func_read;
 2403|    247|  stream->intern->func_write = functions.public.func_write;
 2404|    247|  stream->intern->func_seek = functions.public.func_seek;
 2405|    247|  stream->intern->func_ioctl = functions.func_ioctl;
 2406|    247|  stream->intern->func_close = functions.public.func_close;
 2407|    247|  stream->intern->strategy = _IOFBF;
 2408|    247|  stream->intern->syshd = *syshd;
 2409|    247|  stream->intern->print_ntotal = 0;
 2410|    247|  stream->intern->indicators.err = 0;
 2411|    247|  stream->intern->indicators.eof = 0;
 2412|    247|  stream->intern->indicators.hup = 0;
 2413|    247|  stream->intern->is_stdstream = 0;
 2414|    247|  stream->intern->stdstream_fd = 0;
 2415|    247|  stream->intern->deallocate_buffer = 0;
 2416|    247|  stream->intern->printable_fname = NULL;
 2417|    247|  stream->intern->printable_fname_inuse = 0;
 2418|    247|  stream->intern->samethread = !! (xmode & X_SAMETHREAD);
  ------------------
  |  | 2044|    247|#define X_SAMETHREAD	(1 << 0)
  ------------------
 2419|    247|  stream->intern->onclose = NULL;
 2420|       |
 2421|    247|  stream->data_len = 0;
 2422|    247|  stream->data_offset = 0;
 2423|    247|  stream->data_flushed = 0;
 2424|    247|  stream->unread_data_len = 0;
 2425|       |  /* Depending on the modeflags we set whether we start in writing or
 2426|       |     reading mode.  This is required in case we are working on a
 2427|       |     stream which is not seeekable (like stdout).  Without this
 2428|       |     pre-initialization we would do a seek at the first write call and
 2429|       |     as this will fail no output will be delivered. */
 2430|    247|  if ((modeflags & O_WRONLY) || (modeflags & O_RDWR) )
  ------------------
  |  Branch (2430:7): [True: 15, False: 232]
  |  Branch (2430:33): [True: 0, False: 232]
  ------------------
 2431|     15|    stream->flags.writing = 1;
 2432|    232|  else
 2433|    232|    stream->flags.writing = 0;
 2434|    247|}
estream.c:func_fd_destroy:
 1153|    245|{
 1154|    245|  estream_cookie_fd_t fd_cookie = cookie;
 1155|    245|  int err;
 1156|       |
 1157|    245|  trace (("enter: cookie=%p", cookie));
  ------------------
  |  |  189|    245|# define trace(X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (189:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1158|       |
 1159|    245|  if (fd_cookie)
  ------------------
  |  Branch (1159:7): [True: 245, False: 0]
  ------------------
 1160|    245|    {
 1161|    245|      if (IS_INVALID_FD (fd_cookie->fd))
  ------------------
  |  |  148|    245|#define IS_INVALID_FD(a)    ((a) == -1)
  |  |  ------------------
  |  |  |  Branch (148:29): [True: 0, False: 245]
  |  |  ------------------
  ------------------
 1162|      0|        err = 0;
 1163|    245|      else
 1164|    245|        err = fd_cookie->no_close? 0 : close (fd_cookie->fd);
  ------------------
  |  Branch (1164:15): [True: 0, False: 245]
  ------------------
 1165|    245|      mem_free (fd_cookie);
 1166|    245|    }
 1167|      0|  else
 1168|      0|    err = 0;
 1169|       |
 1170|    245|  trace_errno (err,("leave: err=%d", err));
  ------------------
  |  |  190|    245|# define trace_errno(C,X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (190:41): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1171|    245|  return err;
 1172|    245|}
estream.c:do_close:
 2593|    245|{
 2594|    245|  int err;
 2595|       |
 2596|    245|  trace (("stream %p %s", stream, with_locked_list? "(with locked list)":""));
  ------------------
  |  |  189|    245|# define trace(X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (189:33): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2597|       |
 2598|    245|  if (stream)
  ------------------
  |  Branch (2598:7): [True: 245, False: 0]
  ------------------
 2599|    245|    {
 2600|    245|      do_list_remove (stream, with_locked_list);
 2601|    245|      if (cancel_mode)
  ------------------
  |  Branch (2601:11): [True: 0, False: 245]
  ------------------
 2602|      0|        {
 2603|      0|          stream->flags.writing = 0;
 2604|      0|          es_empty (stream);
 2605|      0|        }
 2606|    245|      while (stream->intern->onclose)
  ------------------
  |  Branch (2606:14): [True: 0, False: 245]
  ------------------
 2607|      0|        {
 2608|      0|          notify_list_t tmp = stream->intern->onclose->next;
 2609|       |
 2610|      0|          if (stream->intern->onclose->fnc)
  ------------------
  |  Branch (2610:15): [True: 0, False: 0]
  ------------------
 2611|      0|            stream->intern->onclose->fnc (stream,
 2612|      0|                                          stream->intern->onclose->fnc_value);
 2613|      0|          mem_free (stream->intern->onclose);
 2614|      0|          stream->intern->onclose = tmp;
 2615|      0|        }
 2616|    245|      err = deinit_stream_obj (stream);
 2617|    245|      destroy_stream_lock (stream);
 2618|    245|      if (stream->intern->deallocate_buffer)
  ------------------
  |  Branch (2618:11): [True: 0, False: 245]
  ------------------
 2619|      0|        mem_free (stream->buffer);
 2620|    245|      mem_free (stream->intern);
 2621|    245|      mem_free (stream);
 2622|    245|    }
 2623|      0|  else
 2624|      0|    err = 0;
 2625|       |
 2626|    245|  trace_errno (err, ("stream %p err=%d", stream, err));
  ------------------
  |  |  190|    245|# define trace_errno(C,X) do { } while (0)
  |  |  ------------------
  |  |  |  Branch (190:41): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2627|    245|  return err;
 2628|    245|}
estream.c:do_list_remove:
  541|    245|{
  542|    245|  estream_list_t item, item_prev = NULL;
  543|       |
  544|    245|  if (!with_locked_list)
  ------------------
  |  Branch (544:7): [True: 245, False: 0]
  ------------------
  545|    245|    lock_list ();
  546|       |
  547|    260|  for (item = estream_list; item; item = item->next)
  ------------------
  |  Branch (547:29): [True: 260, False: 0]
  ------------------
  548|    260|    if (item->stream == stream)
  ------------------
  |  Branch (548:9): [True: 245, False: 15]
  ------------------
  549|    245|      break;
  550|     15|    else
  551|     15|      item_prev = item;
  552|       |
  553|    245|  if (item)
  ------------------
  |  Branch (553:7): [True: 245, False: 0]
  ------------------
  554|    245|    {
  555|    245|      if (item_prev)
  ------------------
  |  Branch (555:11): [True: 15, False: 230]
  ------------------
  556|     15|        item_prev->next = item->next;
  557|    230|      else
  558|    230|        estream_list = item->next;
  559|    245|      mem_free (item);
  560|    245|    }
  561|       |
  562|    245|  if (!with_locked_list)
  ------------------
  |  Branch (562:7): [True: 245, False: 0]
  ------------------
  563|    245|    unlock_list ();
  564|    245|}
estream.c:unlock_stream:
  458|  28.3k|{
  459|  28.3k|  if (!stream->intern->samethread)
  ------------------
  |  Branch (459:7): [True: 28.3k, False: 0]
  ------------------
  460|  28.3k|    {
  461|  28.3k|      dbg_lock_1 ("enter unlock_stream for %p\n", stream);
  462|  28.3k|      _gpgrt_lock_unlock (&stream->intern->lock);
  463|  28.3k|      dbg_lock_1 ("leave unlock_stream for %p\n", stream);
  464|  28.3k|    }
  465|  28.3k|}
estream.c:flush_stream:
 2296|  21.8k|{
 2297|  21.8k|  gpgrt_cookie_write_function_t func_write = stream->intern->func_write;
 2298|  21.8k|  int err;
 2299|       |
 2300|  21.8k|  gpgrt_assert (stream->flags.writing);
  ------------------
  |  |  577|  21.8k|  ((expr)                                                       \
  |  |  ------------------
  |  |  |  Branch (577:4): [True: 21.8k, False: 0]
  |  |  ------------------
  |  |  578|  21.8k|   ? (void) 0                                                   \
  |  |  579|  21.8k|   : _gpgrt__log_assert (#expr, __FILE__, __LINE__, __FUNCTION__))
  ------------------
 2301|       |
 2302|  21.8k|  if (stream->data_offset)
  ------------------
  |  Branch (2302:7): [True: 20.8k, False: 962]
  ------------------
 2303|  20.8k|    {
 2304|  20.8k|      size_t bytes_written;
 2305|  20.8k|      size_t data_flushed;
 2306|  20.8k|      gpgrt_ssize_t ret;
 2307|       |
 2308|  20.8k|      if (! func_write)
  ------------------
  |  Branch (2308:11): [True: 0, False: 20.8k]
  ------------------
 2309|      0|	{
 2310|      0|          _set_errno (EOPNOTSUPP);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2311|      0|          err = -1;
 2312|      0|	  goto out;
 2313|      0|	}
 2314|       |
 2315|       |      /* Note: to prevent an endless loop caused by user-provided
 2316|       |	 write-functions that pretend to have written more bytes than
 2317|       |	 they were asked to write, we have to check for
 2318|       |	 "(stream->data_offset - data_flushed) > 0" instead of
 2319|       |	 "stream->data_offset - data_flushed".  */
 2320|       |
 2321|  20.8k|      data_flushed = 0;
 2322|  20.8k|      err = 0;
 2323|       |
 2324|  41.6k|      while ((((gpgrt_ssize_t) (stream->data_offset - data_flushed)) > 0)
  ------------------
  |  Branch (2324:14): [True: 20.8k, False: 20.8k]
  ------------------
 2325|  41.6k|             && !err)
  ------------------
  |  Branch (2325:17): [True: 20.8k, False: 0]
  ------------------
 2326|  20.8k|	{
 2327|  20.8k|	  ret = (*func_write) (stream->intern->cookie,
 2328|  20.8k|			       stream->buffer + data_flushed,
 2329|  20.8k|			       stream->data_offset - data_flushed);
 2330|  20.8k|	  if (ret == -1)
  ------------------
  |  Branch (2330:8): [True: 0, False: 20.8k]
  ------------------
 2331|      0|	    {
 2332|      0|	      bytes_written = 0;
 2333|      0|	      err = -1;
 2334|       |#if EWOULDBLOCK != EAGAIN
 2335|       |              if (errno == EWOULDBLOCK)
 2336|       |                _set_errno (EAGAIN);
 2337|       |#endif
 2338|      0|	    }
 2339|  20.8k|	  else
 2340|  20.8k|	    bytes_written = ret;
 2341|       |
 2342|  20.8k|	  data_flushed += bytes_written;
 2343|  20.8k|	  if (err)
  ------------------
  |  Branch (2343:8): [True: 0, False: 20.8k]
  ------------------
 2344|      0|	    break;
 2345|  20.8k|	}
 2346|       |
 2347|  20.8k|      stream->data_flushed += data_flushed;
 2348|  20.8k|      if (stream->data_offset == data_flushed)
  ------------------
  |  Branch (2348:11): [True: 20.8k, False: 0]
  ------------------
 2349|  20.8k|	{
 2350|  20.8k|	  stream->intern->offset += stream->data_offset;
 2351|  20.8k|	  stream->data_offset = 0;
 2352|  20.8k|	  stream->data_flushed = 0;
 2353|  20.8k|	}
 2354|  20.8k|    }
 2355|    962|  else
 2356|    962|    err = 0;
 2357|       |
 2358|       |  /* Always propagate flush event in case gpgrt_fflush was called
 2359|       |   * explictly to do flush buffers in caller's cookie functions.  */
 2360|  21.8k|  (*func_write) (stream->intern->cookie, NULL, 0);
 2361|       |
 2362|  21.8k| out:
 2363|       |
 2364|  21.8k|  if (err && errno != EAGAIN)
  ------------------
  |  Branch (2364:7): [True: 0, False: 21.8k]
  |  Branch (2364:14): [True: 0, False: 0]
  ------------------
 2365|      0|    {
 2366|      0|      if (errno == EPIPE)
  ------------------
  |  Branch (2366:11): [True: 0, False: 0]
  ------------------
 2367|      0|        stream->intern->indicators.hup = 1;
 2368|      0|      stream->intern->indicators.err = 1;
 2369|      0|    }
 2370|       |
 2371|  21.8k|  return err;
 2372|  21.8k|}
estream.c:es_offset_calculate:
 3478|    664|{
 3479|    664|  gpgrt_off_t offset;
 3480|       |
 3481|    664|  offset = stream->intern->offset + stream->data_offset;
 3482|    664|  if (offset < stream->unread_data_len)
  ------------------
  |  Branch (3482:7): [True: 0, False: 664]
  ------------------
 3483|       |    /* Offset undefined.  */
 3484|      0|    offset = 0;
 3485|    664|  else
 3486|    664|    offset -= stream->unread_data_len;
 3487|       |
 3488|    664|  return offset;
 3489|    664|}
estream.c:es_readn:
 2819|    970|{
 2820|    970|  unsigned char *buffer = (unsigned char *)buffer_arg;
 2821|    970|  size_t data_read_unread, data_read;
 2822|    970|  int err;
 2823|       |
 2824|    970|  data_read_unread = 0;
 2825|    970|  data_read = 0;
 2826|    970|  err = 0;
 2827|       |
 2828|    970|  if (stream->flags.writing)
  ------------------
  |  Branch (2828:7): [True: 0, False: 970]
  ------------------
 2829|      0|    {
 2830|       |      /* Switching to reading mode -> flush output.  */
 2831|      0|      err = flush_stream (stream);
 2832|      0|      if (err)
  ------------------
  |  Branch (2832:11): [True: 0, False: 0]
  ------------------
 2833|      0|	goto out;
 2834|      0|      stream->flags.writing = 0;
 2835|      0|    }
 2836|       |
 2837|       |  /* Read unread data first.  */
 2838|    970|  while ((bytes_to_read - data_read_unread) && stream->unread_data_len)
  ------------------
  |  Branch (2838:10): [True: 970, False: 0]
  |  Branch (2838:48): [True: 0, False: 970]
  ------------------
 2839|      0|    {
 2840|      0|      buffer[data_read_unread]
 2841|      0|	= stream->unread_buffer[stream->unread_data_len - 1];
 2842|      0|      stream->unread_data_len--;
 2843|      0|      data_read_unread++;
 2844|      0|    }
 2845|       |
 2846|    970|  switch (stream->intern->strategy)
  ------------------
  |  Branch (2846:11): [True: 0, False: 970]
  ------------------
 2847|    970|    {
 2848|      0|    case _IONBF:
  ------------------
  |  Branch (2848:5): [True: 0, False: 970]
  ------------------
 2849|      0|      err = do_read_nbf (stream,
 2850|      0|			 buffer + data_read_unread,
 2851|      0|			 bytes_to_read - data_read_unread, &data_read);
 2852|      0|      break;
 2853|      0|    case _IOLBF:
  ------------------
  |  Branch (2853:5): [True: 0, False: 970]
  ------------------
 2854|      0|      err = do_read_lbf (stream,
 2855|      0|			 buffer + data_read_unread,
 2856|      0|			 bytes_to_read - data_read_unread, &data_read);
 2857|      0|      break;
 2858|    970|    case _IOFBF:
  ------------------
  |  Branch (2858:5): [True: 970, False: 0]
  ------------------
 2859|    970|      err = do_read_fbf (stream,
 2860|    970|			 buffer + data_read_unread,
 2861|    970|			 bytes_to_read - data_read_unread, &data_read);
 2862|    970|      break;
 2863|    970|    }
 2864|       |
 2865|    970| out:
 2866|       |
 2867|    970|  if (bytes_read)
  ------------------
  |  Branch (2867:7): [True: 970, False: 0]
  ------------------
 2868|    970|    *bytes_read = data_read_unread + data_read;
 2869|       |
 2870|    970|  return err;
 2871|    970|}
estream.c:do_read_fbf:
 2728|    970|{
 2729|    970|  size_t data_available;
 2730|    970|  size_t data_to_read;
 2731|    970|  size_t data_read;
 2732|    970|  int err;
 2733|       |
 2734|    970|  data_read = 0;
 2735|    970|  err = 0;
 2736|       |
 2737|  1.66k|  while ((bytes_to_read - data_read) && (! err))
  ------------------
  |  Branch (2737:10): [True: 972, False: 694]
  |  Branch (2737:41): [True: 972, False: 0]
  ------------------
 2738|    972|    {
 2739|    972|      if (stream->data_offset == stream->data_len)
  ------------------
  |  Branch (2739:11): [True: 584, False: 388]
  ------------------
 2740|    584|	{
 2741|       |	  /* Nothing more to read in current container, try to
 2742|       |	     fill container with new data.  */
 2743|    584|	  err = fill_stream (stream);
 2744|    584|	  if (! err)
  ------------------
  |  Branch (2744:8): [True: 584, False: 0]
  ------------------
 2745|    584|	    if (! stream->data_len)
  ------------------
  |  Branch (2745:10): [True: 276, False: 308]
  ------------------
 2746|       |	      /* Filling did not result in any data read.  */
 2747|    276|	      break;
 2748|    584|	}
 2749|       |
 2750|    696|      if (! err)
  ------------------
  |  Branch (2750:11): [True: 696, False: 0]
  ------------------
 2751|    696|	{
 2752|       |	  /* Filling resulted in some new data.  */
 2753|       |
 2754|    696|	  data_to_read = bytes_to_read - data_read;
 2755|    696|	  data_available = stream->data_len - stream->data_offset;
 2756|    696|	  if (data_to_read > data_available)
  ------------------
  |  Branch (2756:8): [True: 2, False: 694]
  ------------------
 2757|      2|	    data_to_read = data_available;
 2758|       |
 2759|    696|	  memcpy (buffer + data_read,
 2760|    696|		  stream->buffer + stream->data_offset, data_to_read);
 2761|    696|	  stream->data_offset += data_to_read;
 2762|    696|	  data_read += data_to_read;
 2763|    696|	}
 2764|    696|    }
 2765|       |
 2766|    970|  *bytes_read = data_read;
 2767|       |
 2768|    970|  return err;
 2769|    970|}
estream.c:fill_stream:
 2241|    584|{
 2242|    584|  size_t bytes_read = 0;
 2243|    584|  int err;
 2244|       |
 2245|    584|  if (!stream->intern->func_read)
  ------------------
  |  Branch (2245:7): [True: 0, False: 584]
  ------------------
 2246|      0|    {
 2247|      0|      _set_errno (EOPNOTSUPP);
  ------------------
  |  |  146|      0|#define _set_errno(a)  do { errno = (a); } while (0)
  |  |  ------------------
  |  |  |  Branch (146:51): [Folded - Ignored]
  |  |  ------------------
  ------------------
 2248|      0|      err = -1;
 2249|      0|    }
 2250|    584|  else if (!stream->buffer_size)
  ------------------
  |  Branch (2250:12): [True: 0, False: 584]
  ------------------
 2251|      0|    err = 0;
 2252|    584|  else
 2253|    584|    {
 2254|    584|      gpgrt_cookie_read_function_t func_read = stream->intern->func_read;
 2255|    584|      gpgrt_ssize_t ret;
 2256|       |
 2257|    584|      ret = (*func_read) (stream->intern->cookie,
 2258|    584|			  stream->buffer, stream->buffer_size);
 2259|    584|      if (ret == -1)
  ------------------
  |  Branch (2259:11): [True: 0, False: 584]
  ------------------
 2260|      0|	{
 2261|      0|	  bytes_read = 0;
 2262|      0|	  err = -1;
 2263|       |#if EWOULDBLOCK != EAGAIN
 2264|       |          if (errno == EWOULDBLOCK)
 2265|       |            _set_errno (EAGAIN);
 2266|       |#endif
 2267|      0|	}
 2268|    584|      else
 2269|    584|	{
 2270|    584|	  bytes_read = ret;
 2271|    584|	  err = 0;
 2272|    584|	}
 2273|    584|    }
 2274|       |
 2275|    584|  if (err)
  ------------------
  |  Branch (2275:7): [True: 0, False: 584]
  ------------------
 2276|      0|    {
 2277|      0|      if (errno != EAGAIN)
  ------------------
  |  Branch (2277:11): [True: 0, False: 0]
  ------------------
 2278|      0|        {
 2279|      0|          if (errno == EPIPE)
  ------------------
  |  Branch (2279:15): [True: 0, False: 0]
  ------------------
 2280|      0|            stream->intern->indicators.hup = 1;
 2281|      0|          stream->intern->indicators.err = 1;
 2282|      0|        }
 2283|      0|    }
 2284|    584|  else if (!bytes_read)
  ------------------
  |  Branch (2284:12): [True: 276, False: 308]
  ------------------
 2285|    276|    stream->intern->indicators.eof = 1;
 2286|       |
 2287|    584|  stream->intern->offset += stream->data_len;
 2288|    584|  stream->data_len = bytes_read;
 2289|    584|  stream->data_offset = 0;
 2290|       |
 2291|    584|  return err;
 2292|    584|}
estream.c:mem_alloc:
  212|  1.24k|{
  213|  1.24k|  return _gpgrt_malloc (n);
  214|  1.24k|}
estream.c:do_print_stream:
 3405|  34.9k|{
 3406|  34.9k|  int rc;
 3407|       |
 3408|  34.9k|  stream->intern->print_ntotal = 0;
 3409|  34.9k|  rc = _gpgrt_estream_format (print_writer, stream, sf, sfvalue, format, ap);
 3410|  34.9k|  if (rc)
  ------------------
  |  Branch (3410:7): [True: 0, False: 34.9k]
  ------------------
 3411|      0|    return -1;
 3412|  34.9k|  return (int)stream->intern->print_ntotal;
 3413|  34.9k|}
estream.c:print_writer:
 3388|  94.3k|{
 3389|  94.3k|  estream_t stream = outfncarg;
 3390|  94.3k|  size_t nwritten;
 3391|  94.3k|  int rc;
 3392|       |
 3393|  94.3k|  nwritten = 0;
 3394|  94.3k|  rc = es_writen (stream, buf, buflen, &nwritten);
 3395|  94.3k|  stream->intern->print_ntotal += nwritten;
 3396|  94.3k|  return rc;
 3397|  94.3k|}
estream.c:fname_set_internal:
 5598|    247|{
 5599|    247|  if (stream->intern->printable_fname
  ------------------
  |  Branch (5599:7): [True: 0, False: 247]
  ------------------
 5600|    247|      && !stream->intern->printable_fname_inuse)
  ------------------
  |  Branch (5600:10): [True: 0, False: 0]
  ------------------
 5601|      0|    {
 5602|      0|      mem_free (stream->intern->printable_fname);
 5603|      0|      stream->intern->printable_fname = NULL;
 5604|      0|    }
 5605|    247|  if (stream->intern->printable_fname)
  ------------------
  |  Branch (5605:7): [True: 0, False: 247]
  ------------------
 5606|      0|    return; /* Can't change because it is in use.  */
 5607|       |
 5608|    247|  if (*fname != '[')
  ------------------
  |  Branch (5608:7): [True: 246, False: 1]
  ------------------
 5609|    246|    quote = 0;
 5610|      1|  else
 5611|      1|    quote = !!quote;
 5612|       |
 5613|    247|  stream->intern->printable_fname = mem_alloc (strlen (fname) + quote + 1);
 5614|    247|  if (quote)
  ------------------
  |  Branch (5614:7): [True: 0, False: 247]
  ------------------
 5615|      0|    stream->intern->printable_fname[0] = '\\';
 5616|    247|  strcpy (stream->intern->printable_fname+quote, fname);
 5617|    247|}

strsource.c:gpg_err_source:
  977|     11|{
  978|     11|  return (gpg_err_source_t) ((err >> GPG_ERR_SOURCE_SHIFT)
  ------------------
  |  |  748|     11|#define GPG_ERR_SOURCE_SHIFT	24
  ------------------
  979|     11|			     & GPG_ERR_SOURCE_MASK);
  ------------------
  |  |  747|     11|#define GPG_ERR_SOURCE_MASK	(GPG_ERR_SOURCE_DIM - 1)
  ------------------
  980|     11|}
strerror.c:gpg_err_code:
  969|    369|{
  970|    369|  return (gpg_err_code_t) (err & GPG_ERR_CODE_MASK);
  ------------------
  |  |  742|    369|#define GPG_ERR_CODE_MASK	(GPG_ERR_CODE_DIM - 1)
  ------------------
  971|    369|}

_gpg_err_init:
   92|      2|{
   93|       |#ifdef HAVE_W32_SYSTEM
   94|       |# ifdef DLL_EXPORT
   95|       |  /* We always have a constructor and thus this function is called
   96|       |     automatically.  Due to the way the C init code of mingw works,
   97|       |     the constructors are called before our DllMain function is
   98|       |     called.  The problem with that is that the TLS has not been setup
   99|       |     and w32-gettext.c requires TLS.  To solve this we do nothing here
  100|       |     but call the actual init code from our DllMain.  */
  101|       |# else /*!DLL_EXPORT*/
  102|       |  /* Note that if the TLS is actually used, we can't release the TLS
  103|       |     as there is no way to know when a thread terminates (i.e. no
  104|       |     thread-specific-atexit).  You are really better off to use the
  105|       |     DLL! */
  106|       |  if (tls_index == TLS_OUT_OF_INDEXES)
  107|       |    {
  108|       |      tls_index = TlsAlloc ();
  109|       |      if (tls_index == TLS_OUT_OF_INDEXES)
  110|       |        {
  111|       |          /* No way to continue - commit suicide.  */
  112|       |          _gpgrt_abort ();
  113|       |        }
  114|       |      _gpg_w32__init_gettext_module ();
  115|       |      real_init ();
  116|       |    }
  117|       |# endif /*!DLL_EXPORT*/
  118|       |#else
  119|      2|  real_init ();
  120|      2|#endif
  121|      2|  return 0;
  122|      2|}
_gpgrt_realloc:
  234|  4.55k|{
  235|  4.55k|  if (custom_realloc)
  ------------------
  |  Branch (235:7): [True: 0, False: 4.55k]
  ------------------
  236|      0|    return custom_realloc (a, n);
  237|       |
  238|  4.55k|  if (!n)
  ------------------
  |  Branch (238:7): [True: 1.22k, False: 3.32k]
  ------------------
  239|  1.22k|    {
  240|  1.22k|      free (a);
  241|  1.22k|      return NULL;
  242|  1.22k|    }
  243|       |
  244|  3.32k|  if (!a)
  ------------------
  |  Branch (244:7): [True: 3.32k, False: 0]
  ------------------
  245|  3.32k|    return malloc (n);
  246|       |
  247|      0|  return realloc (a, n);
  248|  3.32k|}
_gpgrt_malloc:
  303|  1.24k|{
  304|  1.24k|  if (!n)
  ------------------
  |  Branch (304:7): [True: 0, False: 1.24k]
  ------------------
  305|      0|    n++;
  306|  1.24k|  return _gpgrt_realloc (NULL, n);
  307|  1.24k|}
_gpgrt_free:
  398|  1.22k|{
  399|  1.22k|  int save_errno;
  400|       |
  401|  1.22k|  if (!a)
  ------------------
  |  Branch (401:7): [True: 0, False: 1.22k]
  ------------------
  402|      0|    return;  /* Shortcut */
  403|       |
  404|       |  /* In case ERRNO is set we better save it so that the free machinery
  405|       |   * may not accidentally change ERRNO.  We restore it only if it was
  406|       |   * already set to comply with the usual C semantic for ERRNO.
  407|       |   * See also https://dev.gnupg.org/T5393#146261  */
  408|  1.22k|  save_errno = errno;
  409|  1.22k|  _gpgrt_realloc (a, 0);
  410|  1.22k|  if (save_errno && save_errno != errno)
  ------------------
  |  Branch (410:7): [True: 1.22k, False: 5]
  |  Branch (410:21): [True: 0, False: 1.22k]
  ------------------
  411|      0|    _gpg_err_set_errno (save_errno);
  412|  1.22k|}
_gpg_err_set_errno:
  417|    201|{
  418|    201|  errno = err;
  419|    201|}
init.c:real_init:
   74|      2|{
   75|      2|#ifdef ENABLE_NLS
   76|      2|  char *locale_dir;
   77|       |
   78|       |  /* We only have to bind our locale directory to our text domain.  */
   79|      2|  locale_dir = get_locale_dir ();
  ------------------
  |  |   47|      2|#define get_locale_dir() LOCALEDIR
  ------------------
   80|      2|  if (locale_dir)
  ------------------
  |  Branch (80:7): [True: 2, False: 0]
  ------------------
   81|      2|    {
   82|      2|      bindtextdomain (PACKAGE, locale_dir);
  ------------------
  |  |  210|      2|#define PACKAGE "libgpg-error"
  ------------------
   83|      2|      drop_locale_dir (locale_dir);
   84|      2|    }
   85|      2|#endif
   86|      2|  _gpgrt_estream_init ();
   87|      2|}

_gpgrt_inc_errorcount:
  128|  20.0k|{
  129|       |  /* Protect against counter overflow.  */
  130|  20.0k|  if (errorcount < 30000)
  ------------------
  |  Branch (130:7): [True: 20.0k, False: 0]
  ------------------
  131|  20.0k|    errorcount++;
  132|  20.0k|}
_gpgrt_log_set_sink:
  538|      2|{
  539|      2|  if (name && !stream && fd == -1)
  ------------------
  |  Branch (539:7): [True: 1, False: 1]
  |  Branch (539:15): [True: 1, False: 0]
  |  Branch (539:26): [True: 1, False: 0]
  ------------------
  540|      1|    set_file_fd (name, -1, NULL);
  541|      1|  else if (!name && !stream && fd != -1)
  ------------------
  |  Branch (541:12): [True: 1, False: 0]
  |  Branch (541:21): [True: 1, False: 0]
  |  Branch (541:32): [True: 0, False: 1]
  ------------------
  542|      0|    {
  543|      0|      if (!_gpgrt_fd_valid_p (fd))
  ------------------
  |  Branch (543:11): [True: 0, False: 0]
  ------------------
  544|      0|        _gpgrt_log_fatal ("gpgrt_log_set_sink: fd is invalid: %s\n",
  545|      0|                     strerror (errno));
  546|      0|      set_file_fd (NULL, fd, NULL);
  547|      0|    }
  548|      1|  else if (!name && stream && fd == -1)
  ------------------
  |  Branch (548:12): [True: 1, False: 0]
  |  Branch (548:21): [True: 0, False: 1]
  |  Branch (548:31): [True: 0, False: 0]
  ------------------
  549|      0|    {
  550|      0|      set_file_fd (NULL, -1, stream);
  551|      0|    }
  552|      1|  else /* default */
  553|      1|    set_file_fd ("-", -1, NULL);
  554|      2|}
_gpgrt_log_get_stream:
  643|    827|{
  644|    827|  if (!logstream)
  ------------------
  |  Branch (644:7): [True: 0, False: 827]
  ------------------
  645|      0|    {
  646|       |      /* Make sure a log stream has been set.  */
  647|      0|      _gpgrt_log_set_sink (NULL, NULL, -1);
  648|      0|      if (!logstream)
  ------------------
  |  Branch (648:11): [True: 0, False: 0]
  ------------------
  649|      0|        {
  650|      0|          fputs ("gpgrt fatal: failed to init log stream\n", stderr);
  651|      0|          _gpgrt_abort ();
  652|      0|        }
  653|      0|    }
  654|    827|  return logstream;
  655|    827|}
_gpgrt_logv_internal:
  844|  22.6k|{
  845|  22.6k|  int leading_backspace = (fmt && *fmt == '\b');
  ------------------
  |  Branch (845:28): [True: 22.6k, False: 0]
  |  Branch (845:35): [True: 0, False: 22.6k]
  ------------------
  846|  22.6k|  int length;
  847|  22.6k|  int rc;
  848|       |
  849|  22.6k|  if (!logstream)
  ------------------
  |  Branch (849:7): [True: 1, False: 22.6k]
  ------------------
  850|      1|    {
  851|       |#ifdef HAVE_W32_SYSTEM
  852|       |      char *tmp;
  853|       |
  854|       |      tmp = (no_registry
  855|       |             ? NULL
  856|       |             : _gpgrt_w32_reg_query_string (NULL, "Software\\\\GNU\\\\GnuPG",
  857|       |                                            "DefaultLogFile"));
  858|       |      _gpgrt_log_set_sink (tmp && *tmp? tmp : NULL, NULL, -1);
  859|       |      _gpgrt_free (tmp);
  860|       |#else
  861|       |      /* Make sure a log stream has been set.  */
  862|      1|      _gpgrt_log_set_sink (NULL, NULL, -1);
  863|      1|#endif
  864|      1|      if (!logstream)
  ------------------
  |  Branch (864:11): [True: 0, False: 1]
  ------------------
  865|      0|        {
  866|      0|          fputs ("gpgrt fatal: failed to init log stream\n", stderr);
  867|      0|          _gpgrt_abort ();
  868|      0|        }
  869|      1|    }
  870|       |
  871|  22.6k|  _gpgrt_flockfile (logstream);
  872|  22.6k|  if (missing_lf && level != GPGRT_LOGLVL_CONT)
  ------------------
  |  Branch (872:7): [True: 829, False: 21.7k]
  |  Branch (872:21): [True: 0, False: 829]
  ------------------
  873|      0|    _gpgrt_putc_unlocked ('\n', logstream );
  ------------------
  |  |  402|      0|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  403|      0|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  404|      0|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|      0|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|      0|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
  874|  22.6k|  missing_lf = 0;
  875|       |
  876|  22.6k|  length = print_prefix (level, leading_backspace);
  877|  22.6k|  if (leading_backspace)
  ------------------
  |  Branch (877:7): [True: 0, False: 22.6k]
  ------------------
  878|      0|    fmt++;
  879|       |
  880|  22.6k|  if (fmt)
  ------------------
  |  Branch (880:7): [True: 22.6k, False: 0]
  ------------------
  881|  22.6k|    {
  882|  22.6k|      if (prefmt)
  ------------------
  |  Branch (882:11): [True: 0, False: 22.6k]
  ------------------
  883|      0|        {
  884|      0|          _gpgrt_fputs_unlocked (prefmt, logstream);
  885|      0|          length += strlen (prefmt);
  886|      0|        }
  887|       |
  888|  22.6k|      if (ignore_arg_ptr)
  ------------------
  |  Branch (888:11): [True: 0, False: 22.6k]
  ------------------
  889|      0|        { /* This is used by log_string and comes with the extra
  890|       |           * feature that after a LF the next line is indent at the
  891|       |           * length of the prefix.  Note that we do not yet include
  892|       |           * the length of the timestamp and pid in the indent
  893|       |           * computation.  */
  894|      0|          const char *p, *pend;
  895|       |
  896|      0|          for (p = fmt; (pend = strchr (p, '\n')); p = pend+1)
  ------------------
  |  Branch (896:25): [True: 0, False: 0]
  ------------------
  897|      0|            {
  898|      0|              rc = _gpgrt_fprintf_unlocked (logstream, "%*s%.*s",
  899|      0|                                 (int)((p != fmt
  ------------------
  |  Branch (899:41): [True: 0, False: 0]
  ------------------
  900|      0|                                        && (with_prefix || force_prefixes))
  ------------------
  |  Branch (900:45): [True: 0, False: 0]
  |  Branch (900:60): [True: 0, False: 0]
  ------------------
  901|      0|                                       ?strlen (prefix_buffer)+2:0), "",
  902|      0|                                 (int)(pend - p)+1, p);
  903|      0|              if (rc > 0)
  ------------------
  |  Branch (903:19): [True: 0, False: 0]
  ------------------
  904|      0|                length += rc;
  905|      0|            }
  906|      0|          _gpgrt_fputs_unlocked (p, logstream);
  907|      0|          length += strlen (p);
  908|      0|        }
  909|  22.6k|      else
  910|  22.6k|        {
  911|  22.6k|          struct fmt_string_filter_s sf = {NULL};
  912|       |
  913|  22.6k|          rc = _gpgrt_vfprintf_unlocked (logstream, fmt_string_filter, &sf,
  914|  22.6k|                                         fmt, arg_ptr);
  915|  22.6k|          if (rc > 0)
  ------------------
  |  Branch (915:15): [True: 22.6k, False: 0]
  ------------------
  916|  22.6k|            length += rc;
  917|  22.6k|        }
  918|       |
  919|  22.6k|      if (*fmt && fmt[strlen(fmt)-1] != '\n')
  ------------------
  |  Branch (919:11): [True: 22.6k, False: 0]
  |  Branch (919:19): [True: 829, False: 21.7k]
  ------------------
  920|    829|        missing_lf = 1;
  921|  22.6k|    }
  922|       |
  923|       |  /* If we have an EXTRASTRING print it now while we still hold the
  924|       |   * lock on the logstream.  */
  925|  22.6k|  if (extrastring)
  ------------------
  |  Branch (925:7): [True: 0, False: 22.6k]
  ------------------
  926|      0|    {
  927|      0|      int c;
  928|       |
  929|      0|      if (missing_lf)
  ------------------
  |  Branch (929:11): [True: 0, False: 0]
  ------------------
  930|      0|        {
  931|      0|          _gpgrt_putc_unlocked ('\n', logstream);
  ------------------
  |  |  402|      0|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  403|      0|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  404|      0|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|      0|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|      0|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
  932|      0|          missing_lf = 0;
  933|      0|          length = 0;
  934|      0|        }
  935|      0|      length += print_prefix (level, leading_backspace);
  936|      0|      _gpgrt_fputs_unlocked (">> ", logstream);
  937|      0|      length += 3;
  938|      0|      missing_lf = 1;
  939|      0|      while ((c = *extrastring++))
  ------------------
  |  Branch (939:14): [True: 0, False: 0]
  ------------------
  940|      0|        {
  941|      0|          missing_lf = 1;
  942|      0|          if (c == '\\')
  ------------------
  |  Branch (942:15): [True: 0, False: 0]
  ------------------
  943|      0|            {
  944|      0|              _gpgrt_fputs_unlocked ("\\\\", logstream);
  945|      0|              length += 2;
  946|      0|            }
  947|      0|          else if (c == '\r')
  ------------------
  |  Branch (947:20): [True: 0, False: 0]
  ------------------
  948|      0|            {
  949|      0|              _gpgrt_fputs_unlocked ("\\r", logstream);
  950|      0|              length += 2;
  951|      0|            }
  952|      0|          else if (c == '\n')
  ------------------
  |  Branch (952:20): [True: 0, False: 0]
  ------------------
  953|      0|            {
  954|      0|              _gpgrt_fputs_unlocked ("\\n\n", logstream);
  955|      0|              length = 0;
  956|      0|              if (*extrastring)
  ------------------
  |  Branch (956:19): [True: 0, False: 0]
  ------------------
  957|      0|                {
  958|      0|                  length += print_prefix (level, leading_backspace);
  959|      0|                  _gpgrt_fputs_unlocked (">> ", logstream);
  960|      0|                  length += 3;
  961|      0|                }
  962|      0|              else
  963|      0|                missing_lf = 0;
  964|      0|            }
  965|      0|          else
  966|      0|            {
  967|      0|              _gpgrt_putc_unlocked (c, logstream);
  ------------------
  |  |  402|      0|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  403|      0|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  404|      0|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  405|      0|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|      0|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
  968|      0|              length++;
  969|      0|            }
  970|      0|        }
  971|      0|      if (missing_lf)
  ------------------
  |  Branch (971:11): [True: 0, False: 0]
  ------------------
  972|      0|        {
  973|      0|          _gpgrt_putc_unlocked ('\n', logstream);
  ------------------
  |  |  402|      0|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  403|      0|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  404|      0|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|      0|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|      0|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
  974|      0|          length = 0;
  975|      0|          missing_lf = 0;
  976|      0|        }
  977|      0|    }
  978|       |
  979|  22.6k|  if (level == GPGRT_LOGLVL_FATAL)
  ------------------
  |  Branch (979:7): [True: 0, False: 22.6k]
  ------------------
  980|      0|    {
  981|      0|      if (missing_lf)
  ------------------
  |  Branch (981:11): [True: 0, False: 0]
  ------------------
  982|      0|        _gpgrt_putc_unlocked ('\n', logstream);
  ------------------
  |  |  402|      0|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  403|      0|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  404|      0|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|      0|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|      0|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
  983|      0|      _gpgrt_funlockfile (logstream);
  984|      0|      exit (2);
  985|      0|    }
  986|  22.6k|  else if (level == GPGRT_LOGLVL_BUG)
  ------------------
  |  Branch (986:12): [True: 0, False: 22.6k]
  ------------------
  987|      0|    {
  988|      0|      if (missing_lf)
  ------------------
  |  Branch (988:11): [True: 0, False: 0]
  ------------------
  989|      0|        _gpgrt_putc_unlocked ('\n', logstream );
  ------------------
  |  |  402|      0|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  403|      0|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  404|      0|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|      0|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|      0|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
  990|      0|      _gpgrt_funlockfile (logstream);
  991|       |      /* Using backtrace requires a configure test and to pass
  992|       |       * -rdynamic to gcc.  Thus we do not enable it now.  */
  993|       |      /* { */
  994|       |      /*   void *btbuf[20]; */
  995|       |      /*   int btidx, btlen; */
  996|       |      /*   char **btstr; */
  997|       |
  998|       |      /*   btlen = backtrace (btbuf, DIM (btbuf)); */
  999|       |      /*   btstr = backtrace_symbols (btbuf, btlen); */
 1000|       |      /*   if (btstr) */
 1001|       |      /*     for (btidx=0; btidx < btlen; btidx++) */
 1002|       |      /*       log_debug ("[%d] %s\n", btidx, btstr[btidx]); */
 1003|       |      /* } */
 1004|      0|      _gpgrt_abort ();
 1005|      0|    }
 1006|  22.6k|  else
 1007|  22.6k|    _gpgrt_funlockfile (logstream);
 1008|       |
 1009|       |  /* Bumb the error counter for log_error.  */
 1010|  22.6k|  if (level == GPGRT_LOGLVL_ERROR)
  ------------------
  |  Branch (1010:7): [True: 20.0k, False: 2.56k]
  ------------------
 1011|  20.0k|    _gpgrt_inc_errorcount ();
 1012|       |
 1013|  22.6k|  return length;
 1014|  22.6k|}
_gpgrt_logv:
 1030|  22.6k|{
 1031|  22.6k|  _gpgrt_logv_internal (level, 0, NULL, NULL, fmt, arg_ptr);
 1032|  22.6k|}
logging.c:set_file_fd:
  450|      2|{
  451|      2|  estream_t fp;
  452|      2|  int want_socket = 0;
  453|      2|  struct fun_cookie_s *cookie;
  454|       |
  455|       |  /* Close an open log stream.  */
  456|      2|  if (logstream)
  ------------------
  |  Branch (456:7): [True: 1, False: 1]
  ------------------
  457|      1|    {
  458|      1|      if (logstream != es_stderr)
  ------------------
  |  |  363|      1|#define es_stderr _gpgrt__get_std_stream (2)
  ------------------
  |  Branch (458:11): [True: 0, False: 1]
  ------------------
  459|      0|        _gpgrt_fclose (logstream);
  460|      1|      logstream = NULL;
  461|      1|    }
  462|       |
  463|      2|  if (stream)
  ------------------
  |  Branch (463:7): [True: 0, False: 2]
  ------------------
  464|      0|    {
  465|       |      /* We don't use a cookie to log directly to a stream.  */
  466|      0|      fp = stream;
  467|      0|      goto leave;
  468|      0|    }
  469|       |
  470|       |  /* Figure out what kind of logging we want.  */
  471|      2|  if (name && !strcmp (name, "-"))
  ------------------
  |  Branch (471:7): [True: 2, False: 0]
  |  Branch (471:15): [True: 1, False: 1]
  ------------------
  472|      1|    {
  473|      1|      fp = es_stderr;
  ------------------
  |  |  363|      1|#define es_stderr _gpgrt__get_std_stream (2)
  ------------------
  474|      1|      goto leave;
  475|      1|    }
  476|      1|  else if (name && !strncmp (name, "tcp://", 6) && name[6])
  ------------------
  |  Branch (476:12): [True: 1, False: 0]
  |  Branch (476:20): [True: 0, False: 1]
  |  Branch (476:52): [True: 0, False: 0]
  ------------------
  477|      0|    want_socket = 1;
  478|      1|#ifndef HAVE_W32_SYSTEM
  479|      1|  else if (name && !strncmp (name, "socket://", 9))
  ------------------
  |  Branch (479:12): [True: 1, False: 0]
  |  Branch (479:20): [True: 0, False: 1]
  ------------------
  480|      0|    want_socket = 2;
  481|      1|#endif /*HAVE_W32_SYSTEM*/
  482|       |
  483|       |  /* Setup a new stream.  */
  484|       |
  485|      1|  if (!name)
  ------------------
  |  Branch (485:7): [True: 0, False: 1]
  ------------------
  486|      0|    fp = _gpgrt_fdopen (fd, "w");
  487|      1|  else if (!want_socket)
  ------------------
  |  Branch (487:12): [True: 1, False: 0]
  ------------------
  488|      1|    fp = _gpgrt_fopen (name, "a");
  489|      0|  else
  490|      0|    {
  491|      0|      es_cookie_io_functions_t io = { NULL };
  492|       |
  493|      0|      cookie = _gpgrt_malloc (sizeof *cookie + (name? strlen (name):0));
  ------------------
  |  Branch (493:49): [True: 0, False: 0]
  ------------------
  494|      0|      if (!cookie)
  ------------------
  |  Branch (494:11): [True: 0, False: 0]
  ------------------
  495|      0|        return; /* oops */
  496|      0|      strcpy (cookie->name, name? name:"");
  ------------------
  |  Branch (496:29): [True: 0, False: 0]
  ------------------
  497|      0|      cookie->quiet = 0;
  498|      0|      cookie->is_socket = 0;
  499|      0|      cookie->want_socket = want_socket;
  500|      0|      cookie->fd = -1;
  501|      0|      log_socket = cookie->fd;
  502|       |
  503|      0|      io.func_write = fun_writer;
  504|      0|      io.func_close = fun_closer;
  505|       |
  506|      0|      fp = _gpgrt_fopencookie (cookie, "w", io);
  507|      0|    }
  508|       |
  509|       |  /* On error default to a stderr based estream.  */
  510|      1|  if (!fp)
  ------------------
  |  Branch (510:7): [True: 0, False: 1]
  ------------------
  511|      0|    fp = es_stderr;
  ------------------
  |  |  363|      0|#define es_stderr _gpgrt__get_std_stream (2)
  ------------------
  512|       |
  513|      2| leave:
  514|      2|  _gpgrt_setvbuf (fp, NULL, _IOLBF, 0);
  515|       |
  516|      2|  logstream = fp;
  517|       |
  518|       |  /* We always need to print the prefix and the pid for socket mode,
  519|       |     so that the server reading the socket can do something
  520|       |     meaningful. */
  521|      2|  force_prefixes = want_socket;
  522|       |
  523|      2|  missing_lf = 0;
  524|      2|}
logging.c:print_prefix:
  752|  22.6k|{
  753|  22.6k|  int rc;
  754|  22.6k|  int length = 0;
  755|       |
  756|  22.6k|  if (level != GPGRT_LOGLVL_CONT)
  ------------------
  |  Branch (756:7): [True: 21.7k, False: 829]
  ------------------
  757|  21.7k|    { /* Note this does not work for multiple line logging as we would
  758|       |       * need to print to a buffer first */
  759|  21.7k|      if (with_time && !force_prefixes)
  ------------------
  |  Branch (759:11): [True: 0, False: 21.7k]
  |  Branch (759:24): [True: 0, False: 0]
  ------------------
  760|      0|        {
  761|      0|          struct tm *tp;
  762|      0|          time_t atime = time (NULL);
  763|       |
  764|      0|          tp = localtime (&atime);
  765|      0|          rc = _gpgrt_fprintf_unlocked (logstream,
  766|      0|                                        "%04d-%02d-%02d %02d:%02d:%02d ",
  767|      0|                               1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday,
  768|      0|                               tp->tm_hour, tp->tm_min, tp->tm_sec );
  769|      0|          if (rc > 0)
  ------------------
  |  Branch (769:15): [True: 0, False: 0]
  ------------------
  770|      0|            length += rc;
  771|      0|        }
  772|  21.7k|      if (with_prefix || force_prefixes)
  ------------------
  |  Branch (772:11): [True: 0, False: 21.7k]
  |  Branch (772:26): [True: 0, False: 21.7k]
  ------------------
  773|      0|        {
  774|      0|          _gpgrt_fputs_unlocked (prefix_buffer, logstream);
  775|      0|          length += strlen (prefix_buffer);
  776|      0|        }
  777|  21.7k|      if (with_pid || force_prefixes)
  ------------------
  |  Branch (777:11): [True: 0, False: 21.7k]
  |  Branch (777:23): [True: 0, False: 21.7k]
  ------------------
  778|      0|        {
  779|      0|          unsigned long pidsuf;
  780|      0|          int pidfmt;
  781|       |
  782|      0|          if (get_pid_suffix_cb && (pidfmt=get_pid_suffix_cb (&pidsuf)))
  ------------------
  |  Branch (782:15): [True: 0, False: 0]
  |  Branch (782:36): [True: 0, False: 0]
  ------------------
  783|      0|            rc = _gpgrt_fprintf_unlocked (logstream,
  784|      0|                                          pidfmt == 1? "[%u.%lu]":"[%u.%lx]",
  ------------------
  |  Branch (784:43): [True: 0, False: 0]
  ------------------
  785|      0|                                          (unsigned int)getpid (), pidsuf);
  786|      0|          else
  787|      0|            rc = _gpgrt_fprintf_unlocked (logstream, "[%u]",
  788|      0|                                          (unsigned int)getpid ());
  789|      0|          if (rc > 0)
  ------------------
  |  Branch (789:15): [True: 0, False: 0]
  ------------------
  790|      0|            length += rc;
  791|      0|        }
  792|  21.7k|      if ((!with_time && (with_prefix || with_pid)) || force_prefixes)
  ------------------
  |  Branch (792:12): [True: 21.7k, False: 0]
  |  Branch (792:27): [True: 0, False: 21.7k]
  |  Branch (792:42): [True: 0, False: 21.7k]
  |  Branch (792:56): [True: 0, False: 21.7k]
  ------------------
  793|      0|        {
  794|      0|          _gpgrt_putc_unlocked (':', logstream);
  ------------------
  |  |  402|      0|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  403|      0|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  404|      0|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|      0|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|      0|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
  795|      0|          length++;
  796|      0|        }
  797|       |      /* A leading backspace suppresses the extra space so that we can
  798|       |         correctly output, programname, filename and linenumber. */
  799|  21.7k|      if (!leading_backspace
  ------------------
  |  Branch (799:11): [True: 21.7k, False: 0]
  ------------------
  800|  21.7k|          && (with_time || with_prefix || with_pid || force_prefixes))
  ------------------
  |  Branch (800:15): [True: 0, False: 21.7k]
  |  Branch (800:28): [True: 0, False: 21.7k]
  |  Branch (800:43): [True: 0, False: 21.7k]
  |  Branch (800:55): [True: 0, False: 21.7k]
  ------------------
  801|      0|        {
  802|      0|          _gpgrt_putc_unlocked (' ', logstream);
  ------------------
  |  |  402|      0|  (((stream)->flags.writing					\
  |  |  ------------------
  |  |  |  Branch (402:5): [True: 0, False: 0]
  |  |  ------------------
  |  |  403|      0|    && ((stream)->data_offset < (stream)->buffer_size)		\
  |  |  ------------------
  |  |  |  Branch (403:8): [True: 0, False: 0]
  |  |  ------------------
  |  |  404|      0|    && (c != '\n'))						\
  |  |  ------------------
  |  |  |  Branch (404:8): [Folded - Ignored]
  |  |  ------------------
  |  |  405|      0|  ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c)))	\
  |  |  406|      0|  : _gpgrt__putc_overflow ((c), (stream)))
  ------------------
  803|      0|          length++;
  804|      0|        }
  805|  21.7k|    }
  806|       |
  807|  22.6k|  switch (level)
  808|  22.6k|    {
  809|      0|    case GPGRT_LOGLVL_BEGIN: break;
  ------------------
  |  Branch (809:5): [True: 0, False: 22.6k]
  ------------------
  810|    829|    case GPGRT_LOGLVL_CONT: break;
  ------------------
  |  Branch (810:5): [True: 829, False: 21.7k]
  ------------------
  811|  1.73k|    case GPGRT_LOGLVL_INFO: break;
  ------------------
  |  Branch (811:5): [True: 1.73k, False: 20.8k]
  ------------------
  812|      0|    case GPGRT_LOGLVL_WARN: break;
  ------------------
  |  Branch (812:5): [True: 0, False: 22.6k]
  ------------------
  813|  20.0k|    case GPGRT_LOGLVL_ERROR: break;
  ------------------
  |  Branch (813:5): [True: 20.0k, False: 2.56k]
  ------------------
  814|      0|    case GPGRT_LOGLVL_FATAL:
  ------------------
  |  Branch (814:5): [True: 0, False: 22.6k]
  ------------------
  815|      0|      _gpgrt_fputs_unlocked ("Fatal: ", logstream);
  816|      0|      length += 7;
  817|      0|      break;
  818|      0|    case GPGRT_LOGLVL_BUG:
  ------------------
  |  Branch (818:5): [True: 0, False: 22.6k]
  ------------------
  819|      0|      _gpgrt_fputs_unlocked ("Ohhhh jeeee: ", logstream);
  820|      0|      length += 13;
  821|      0|      break;
  822|      0|    case GPGRT_LOGLVL_DEBUG:
  ------------------
  |  Branch (822:5): [True: 0, False: 22.6k]
  ------------------
  823|      0|      _gpgrt_fputs_unlocked ("DBG: ", logstream);
  824|      0|      length += 5;
  825|      0|      break;
  826|      0|    default:
  ------------------
  |  Branch (826:5): [True: 0, False: 22.6k]
  ------------------
  827|      0|      rc = _gpgrt_fprintf_unlocked (logstream,
  828|      0|                                    "[Unknown log level %d]: ", level);
  829|      0|      if (rc > 0)
  ------------------
  |  Branch (829:11): [True: 0, False: 0]
  ------------------
  830|      0|        length += rc;
  831|      0|      break;
  832|  22.6k|    }
  833|       |
  834|  22.6k|  return length;
  835|  22.6k|}
logging.c:fmt_string_filter:
  662|  6.37k|{
  663|  6.37k|  struct fmt_string_filter_s *state = opaque;
  664|  6.37k|  const unsigned char *p;
  665|  6.37k|  size_t buflen;
  666|  6.37k|  char *d;
  667|  6.37k|  int any;
  668|       |
  669|  6.37k|  if (no == -1)
  ------------------
  |  Branch (669:7): [True: 3.18k, False: 3.18k]
  ------------------
  670|  3.18k|    {
  671|       |      /* The printf engine asked us to release resources.  */
  672|  3.18k|      if (state->last_result)
  ------------------
  |  Branch (672:11): [True: 0, False: 3.18k]
  ------------------
  673|      0|        {
  674|      0|          _gpgrt_free (state->last_result);
  675|      0|          state->last_result = NULL;
  676|      0|        }
  677|  3.18k|      return NULL;
  678|  3.18k|    }
  679|       |
  680|  3.18k|  if (!string)
  ------------------
  |  Branch (680:7): [True: 0, False: 3.18k]
  ------------------
  681|      0|    return NULL; /* Nothing to filter - printf handles NULL nicely.  */
  682|       |
  683|       |  /* Check whether escaping is needed and count needed length. */
  684|  3.18k|  any = 0;
  685|  3.18k|  buflen = 1;
  686|  75.7k|  for (p = (const unsigned char *)string; *p; p++)
  ------------------
  |  Branch (686:43): [True: 72.5k, False: 3.18k]
  ------------------
  687|  72.5k|    {
  688|  72.5k|      switch (*p)
  689|  72.5k|        {
  690|      0|        case '\n':
  ------------------
  |  Branch (690:9): [True: 0, False: 72.5k]
  ------------------
  691|      0|        case '\r':
  ------------------
  |  Branch (691:9): [True: 0, False: 72.5k]
  ------------------
  692|      0|        case '\f':
  ------------------
  |  Branch (692:9): [True: 0, False: 72.5k]
  ------------------
  693|      0|        case '\v':
  ------------------
  |  Branch (693:9): [True: 0, False: 72.5k]
  ------------------
  694|      0|        case '\b':
  ------------------
  |  Branch (694:9): [True: 0, False: 72.5k]
  ------------------
  695|      0|        case '\t':
  ------------------
  |  Branch (695:9): [True: 0, False: 72.5k]
  ------------------
  696|      0|        case '\a':
  ------------------
  |  Branch (696:9): [True: 0, False: 72.5k]
  ------------------
  697|      0|        case '\\':
  ------------------
  |  Branch (697:9): [True: 0, False: 72.5k]
  ------------------
  698|      0|          buflen += 2;
  699|      0|          any = 1;
  700|      0|          break;
  701|  72.5k|        default:
  ------------------
  |  Branch (701:9): [True: 72.5k, False: 0]
  ------------------
  702|  72.5k|          if (*p < 0x20 || *p == 0x7f)
  ------------------
  |  Branch (702:15): [True: 0, False: 72.5k]
  |  Branch (702:28): [True: 0, False: 72.5k]
  ------------------
  703|      0|            {
  704|      0|              buflen += 5;
  705|      0|              any = 1;
  706|      0|            }
  707|  72.5k|          else
  708|  72.5k|            buflen++;
  709|  72.5k|        }
  710|  72.5k|    }
  711|  3.18k|  if (!any)
  ------------------
  |  Branch (711:7): [True: 3.18k, False: 0]
  ------------------
  712|  3.18k|    return (char*)string;  /* Nothing to escape.  */
  713|       |
  714|       |  /* Create a buffer and escape the input.  */
  715|      0|  _gpgrt_free (state->last_result);
  716|      0|  state->last_result = _gpgrt_malloc (buflen);
  717|      0|  if (!state->last_result)
  ------------------
  |  Branch (717:7): [True: 0, False: 0]
  ------------------
  718|      0|    return "[out_of_core_in_format_string_filter]";
  719|       |
  720|      0|  d = state->last_result;
  721|      0|  for (p = (const unsigned char *)string; *p; p++)
  ------------------
  |  Branch (721:43): [True: 0, False: 0]
  ------------------
  722|      0|    {
  723|      0|      switch (*p)
  724|      0|        {
  725|      0|        case '\n': *d++ = '\\'; *d++ = 'n'; break;
  ------------------
  |  Branch (725:9): [True: 0, False: 0]
  ------------------
  726|      0|        case '\r': *d++ = '\\'; *d++ = 'r'; break;
  ------------------
  |  Branch (726:9): [True: 0, False: 0]
  ------------------
  727|      0|        case '\f': *d++ = '\\'; *d++ = 'f'; break;
  ------------------
  |  Branch (727:9): [True: 0, False: 0]
  ------------------
  728|      0|        case '\v': *d++ = '\\'; *d++ = 'v'; break;
  ------------------
  |  Branch (728:9): [True: 0, False: 0]
  ------------------
  729|      0|        case '\b': *d++ = '\\'; *d++ = 'b'; break;
  ------------------
  |  Branch (729:9): [True: 0, False: 0]
  ------------------
  730|      0|        case '\t': *d++ = '\\'; *d++ = 't'; break;
  ------------------
  |  Branch (730:9): [True: 0, False: 0]
  ------------------
  731|      0|        case '\a': *d++ = '\\'; *d++ = 'a'; break;
  ------------------
  |  Branch (731:9): [True: 0, False: 0]
  ------------------
  732|      0|        case '\\': *d++ = '\\'; *d++ = '\\'; break;
  ------------------
  |  Branch (732:9): [True: 0, False: 0]
  ------------------
  733|       |
  734|      0|        default:
  ------------------
  |  Branch (734:9): [True: 0, False: 0]
  ------------------
  735|      0|          if (*p < 0x20 || *p == 0x7f)
  ------------------
  |  Branch (735:15): [True: 0, False: 0]
  |  Branch (735:28): [True: 0, False: 0]
  ------------------
  736|      0|            {
  737|      0|              snprintf (d, 5, "\\x%02x", *p);
  ------------------
  |  |  483|      0|#define snprintf _gpgrt_estream_snprintf
  ------------------
  738|      0|              d += 4;
  739|      0|            }
  740|      0|          else
  741|      0|            *d++ = *p;
  742|      0|        }
  743|      0|    }
  744|      0|  *d = 0;
  745|      0|  return state->last_result;
  746|      0|}

_gpgrt_lock_init:
  165|    247|{
  166|    247|  _gpgrt_lock_t *lock = (_gpgrt_lock_t*)lockhd;
  167|    247|  int rc;
  168|       |
  169|       |  /* If VERS is zero we assume that no static initialization has been
  170|       |     done, so we setup our ABI version right here.  The caller might
  171|       |     have called us to test whether lock support is at all available. */
  172|    247|  if (!lock->vers)
  ------------------
  |  Branch (172:7): [True: 247, False: 0]
  ------------------
  173|    247|    {
  174|    247|      if (sizeof (gpgrt_lock_t) < sizeof (_gpgrt_lock_t))
  ------------------
  |  Branch (174:11): [Folded - Ignored]
  ------------------
  175|      0|        {
  176|      0|          fputs ("gpgrt fatal: sizeof lock obj\n", stderr);
  177|      0|          _gpgrt_abort ();
  178|      0|        }
  179|    247|      lock->vers = LOCK_ABI_VERSION;
  ------------------
  |  |   25|    247|# define LOCK_ABI_VERSION 1
  ------------------
  180|    247|    }
  181|      0|  else /* Run the usual check.  */
  182|      0|    lock = get_lock_object (lockhd);
  183|       |
  184|    247|#if USE_POSIX_THREADS
  185|    247|  if (use_pthread_p())
  ------------------
  |  |   62|    247|#   define use_pthread_p() (!!pthread_cancel)
  |  |  ------------------
  |  |  |  Branch (62:28): [True: 247, False: 0]
  |  |  ------------------
  ------------------
  186|    247|    {
  187|    247|      rc = pthread_mutex_init (&lock->u.mtx, NULL);
  188|    247|      if (rc)
  ------------------
  |  Branch (188:11): [True: 0, False: 247]
  ------------------
  189|      0|        rc = _gpg_err_code_from_errno (rc);
  190|    247|    }
  191|      0|  else
  192|      0|    rc = 0; /* Threads are not used.  */
  193|       |#else /* Unknown thread system.  */
  194|       |  rc = lock->vers == LOCK_ABI_NOT_AVAILABLE? 0 : GPG_ERR_NOT_IMPLEMENTED;
  195|       |#endif /* Unknown thread system.  */
  196|       |
  197|    247|  return rc;
  198|    247|}
_gpgrt_lock_lock:
  203|  30.0k|{
  204|  30.0k|  _gpgrt_lock_t *lock = get_lock_object (lockhd);
  205|  30.0k|  int rc;
  206|       |
  207|  30.0k|#if USE_POSIX_THREADS
  208|  30.0k|  if (use_pthread_p())
  ------------------
  |  |   62|  30.0k|#   define use_pthread_p() (!!pthread_cancel)
  |  |  ------------------
  |  |  |  Branch (62:28): [True: 30.0k, False: 0]
  |  |  ------------------
  ------------------
  209|  30.0k|    {
  210|  30.0k|      _gpgrt_pre_syscall ();
  211|  30.0k|      rc = pthread_mutex_lock (&lock->u.mtx);
  212|  30.0k|      if (rc)
  ------------------
  |  Branch (212:11): [True: 0, False: 30.0k]
  ------------------
  213|      0|        rc = _gpg_err_code_from_errno (rc);
  214|  30.0k|      _gpgrt_post_syscall ();
  215|  30.0k|    }
  216|      0|  else
  217|      0|    rc = 0; /* Threads are not used.  */
  218|       |#else /* Unknown thread system.  */
  219|       |  rc = lock->vers == LOCK_ABI_NOT_AVAILABLE? 0 : GPG_ERR_NOT_IMPLEMENTED;
  220|       |#endif /* Unknown thread system.  */
  221|       |
  222|  30.0k|  return rc;
  223|  30.0k|}
_gpgrt_lock_unlock:
  251|  30.0k|{
  252|  30.0k|  _gpgrt_lock_t *lock = get_lock_object (lockhd);
  253|  30.0k|  int rc;
  254|       |
  255|  30.0k|#if USE_POSIX_THREADS
  256|  30.0k|  if (use_pthread_p())
  ------------------
  |  |   62|  30.0k|#   define use_pthread_p() (!!pthread_cancel)
  |  |  ------------------
  |  |  |  Branch (62:28): [True: 30.0k, False: 0]
  |  |  ------------------
  ------------------
  257|  30.0k|    {
  258|  30.0k|      rc = pthread_mutex_unlock (&lock->u.mtx);
  259|  30.0k|      if (rc)
  ------------------
  |  Branch (259:11): [True: 0, False: 30.0k]
  ------------------
  260|      0|        rc = _gpg_err_code_from_errno (rc);
  261|  30.0k|    }
  262|      0|  else
  263|      0|    rc = 0; /* Threads are not used.  */
  264|       |#else /* Unknown thread system.  */
  265|       |  rc = lock->vers == LOCK_ABI_NOT_AVAILABLE? 0 : GPG_ERR_NOT_IMPLEMENTED;
  266|       |#endif /* Unknown thread system.  */
  267|       |
  268|  30.0k|  return rc;
  269|  30.0k|}
_gpgrt_lock_destroy:
  276|    245|{
  277|    245|  _gpgrt_lock_t *lock = get_lock_object (lockhd);
  278|    245|  int rc;
  279|       |
  280|    245|#if USE_POSIX_THREADS
  281|    245|  if (use_pthread_p())
  ------------------
  |  |   62|    245|#   define use_pthread_p() (!!pthread_cancel)
  |  |  ------------------
  |  |  |  Branch (62:28): [True: 245, False: 0]
  |  |  ------------------
  ------------------
  282|    245|    {
  283|    245|      rc = pthread_mutex_destroy (&lock->u.mtx);
  284|    245|      if (rc)
  ------------------
  |  Branch (284:11): [True: 0, False: 245]
  ------------------
  285|      0|        rc = _gpg_err_code_from_errno (rc);
  286|    245|      else
  287|    245|        {
  288|       |          /* Re-init the mutex so that it can be re-used.  */
  289|    245|          gpgrt_lock_t tmp = GPGRT_LOCK_INITIALIZER;
  ------------------
  |  | 1126|    245|#define GPGRT_LOCK_INITIALIZER {1,{{0,0,0,0,0,0,0,0, \
  |  | 1127|    245|                                    0,0,0,0,0,0,0,0, \
  |  | 1128|    245|                                    0,0,0,0,0,0,0,0, \
  |  | 1129|    245|                                    0,0,0,0,0,0,0,0, \
  |  | 1130|    245|                                    0,0,0,0,0,0,0,0}}}
  ------------------
  290|    245|          memcpy (lockhd, &tmp, sizeof tmp);
  291|    245|        }
  292|    245|    }
  293|      0|  else
  294|      0|    rc = 0; /* Threads are not used.  */
  295|       |#else /* Unknown thread system.  */
  296|       |  rc = lock->vers == LOCK_ABI_NOT_AVAILABLE? 0 : GPG_ERR_NOT_IMPLEMENTED;
  297|       |#endif /* Unknown thread system.  */
  298|       |
  299|    245|  return rc;
  300|    245|}
posix-lock.c:get_lock_object:
  145|  60.4k|{
  146|  60.4k|  _gpgrt_lock_t *lock = (_gpgrt_lock_t*)lockhd;
  147|       |
  148|  60.4k|  if (lock->vers != LOCK_ABI_VERSION)
  ------------------
  |  |   25|  60.4k|# define LOCK_ABI_VERSION 1
  ------------------
  |  Branch (148:7): [True: 0, False: 60.4k]
  ------------------
  149|      0|    {
  150|      0|      fputs ("gpgrt fatal: lock ABI version mismatch\n", stderr);
  151|      0|      _gpgrt_abort ();
  152|      0|    }
  153|  60.4k|  if (sizeof (gpgrt_lock_t) < sizeof (_gpgrt_lock_t))
  ------------------
  |  Branch (153:7): [Folded - Ignored]
  ------------------
  154|      0|    {
  155|      0|      fputs ("gpgrt fatal: sizeof lock obj\n", stderr);
  156|      0|      _gpgrt_abort ();
  157|      0|    }
  158|       |
  159|  60.4k|  return lock;
  160|  60.4k|}

_gpg_strerror:
   43|    369|{
   44|    369|  gpg_err_code_t code = gpg_err_code (err);
   45|       |
   46|    369|  if (code & GPG_ERR_SYSTEM_ERROR)
  ------------------
  |  |  584|    369|#define GPG_ERR_SYSTEM_ERROR	(1 << 15)
  ------------------
  |  Branch (46:7): [True: 198, False: 171]
  ------------------
   47|    198|    {
   48|    198|      int no = gpg_err_code_to_errno (code);
   49|    198|      if (no)
  ------------------
  |  Branch (49:11): [True: 198, False: 0]
  ------------------
   50|    198|	return strerror (no);
   51|      0|      else
   52|      0|	code = GPG_ERR_UNKNOWN_ERRNO;
   53|    198|    }
   54|    171|  return dgettext (PACKAGE, msgstr + msgidx[msgidxof (code)]);
   55|    369|}

_gpg_strsource:
   34|     11|{
   35|     11|  gpg_err_source_t source = gpg_err_source (err);
   36|     11|  return dgettext (PACKAGE, msgstr + msgidx[msgidxof (source)]);
   37|     11|}

_gpgrt_get_syscall_clamp:
   59|      2|{
   60|      2|  *r_pre  = pre_syscall_func;
   61|      2|  *r_post = post_syscall_func;
   62|      2|}
_gpgrt_pre_syscall:
   68|  74.6k|{
   69|  74.6k|  if (pre_syscall_func)
  ------------------
  |  Branch (69:7): [True: 0, False: 74.6k]
  ------------------
   70|      0|    pre_syscall_func ();
   71|  74.6k|}
_gpgrt_post_syscall:
   77|  74.6k|{
   78|  74.6k|  if (post_syscall_func)
  ------------------
  |  Branch (78:7): [True: 0, False: 74.6k]
  ------------------
   79|      0|    post_syscall_func ();
   80|  74.6k|}

_gpgrt_access:
  492|     57|{
  493|     57|  gpg_err_code_t ec;
  494|       |
  495|       |#ifdef HAVE_W32_SYSTEM
  496|       |  wchar_t *wfname;
  497|       |  DWORD attribs;
  498|       |
  499|       |  wfname = _gpgrt_fname_to_wchar (fname);
  500|       |  if (!wfname)
  501|       |    return _gpg_err_code_from_syserror ();
  502|       |
  503|       |  attribs = GetFileAttributesW (wfname);
  504|       |  if (attribs == (DWORD)(-1))
  505|       |    ec = _gpgrt_w32_get_last_err_code ();
  506|       |  else
  507|       |    {
  508|       |      if ((mode & W_OK) && (attribs & FILE_ATTRIBUTE_READONLY))
  509|       |        {
  510|       |          _gpg_err_set_errno (EACCES);
  511|       |          ec = _gpg_err_code_from_syserror ();
  512|       |        }
  513|       |      else
  514|       |        ec = 0;
  515|       |    }
  516|       |  _gpgrt_free_wchar (wfname);
  517|       |#else /* Unix */
  518|     57|  ec = access (fname, mode)? _gpg_err_code_from_syserror () : 0;
  ------------------
  |  Branch (518:8): [True: 6, False: 51]
  ------------------
  519|     57|#endif /* Unix */
  520|       |
  521|     57|  return ec;
  522|     57|}

gpg_strerror:
   30|    369|{
   31|    369|  return _gpg_strerror (err);
   32|    369|}
gpg_strsource:
   42|     11|{
   43|     11|  return _gpg_strsource (err);
   44|     11|}
gpg_err_code_from_errno:
   48|    198|{
   49|    198|  return _gpg_err_code_from_errno (err);
   50|    198|}
gpg_err_code_to_errno:
   54|    198|{
   55|    198|  return _gpg_err_code_to_errno (code);
   56|    198|}
gpg_err_code_from_syserror:
   60|    198|{
   61|    198|  return _gpg_err_code_from_syserror ();
   62|    198|}
gpg_err_set_errno:
   66|    201|{
   67|    201|  _gpg_err_set_errno (err);
   68|    201|}
gpg_err_init:
   73|      2|{
   74|      2|  return _gpg_err_init ();
   75|      2|}
gpgrt_get_syscall_clamp:
  115|      2|{
  116|      2|  _gpgrt_get_syscall_clamp (r_pre, r_post);
  117|      2|}
gpgrt_lock_lock:
  134|  1.23k|{
  135|  1.23k|  return _gpgrt_lock_lock (lockhd);
  136|  1.23k|}
gpgrt_lock_unlock:
  146|  1.23k|{
  147|  1.23k|  return _gpgrt_lock_unlock (lockhd);
  148|  1.23k|}
gpgrt_fopen:
  167|    247|{
  168|    247|  return _gpgrt_fopen (path, mode);
  169|    247|}
gpgrt_fclose:
  249|    245|{
  250|    245|  return _gpgrt_fclose (stream);
  251|    245|}
_gpgrt_get_std_stream:
  304|      1|{
  305|      1|  return _gpgrt__get_std_stream (fd);  /* (double dash in name) */
  306|      1|}
gpgrt_ferror:
  352|    283|{
  353|    283|  return _gpgrt_ferror (stream);
  354|    283|}
gpgrt_fseek:
  382|      9|{
  383|      9|  return _gpgrt_fseek (stream, offset, whence);
  384|      9|}
gpgrt_fseeko:
  388|  1.28k|{
  389|  1.28k|  return _gpgrt_fseeko (stream, offset, whence);
  390|  1.28k|}
gpgrt_ftello:
  400|    664|{
  401|    664|  return _gpgrt_ftello (stream);
  402|    664|}
gpgrt_fgetc:
  418|  2.24k|{
  419|  2.24k|  return _gpgrt_fgetc (stream);
  420|  2.24k|}
gpgrt_write_sanitized:
  467|    827|{
  468|    827|  return _gpgrt_write_sanitized (stream, buffer, length, delimiters,
  469|    827|                                 bytes_written);
  470|    827|}
gpgrt_fread:
  484|    410|{
  485|    410|  return _gpgrt_fread (ptr, size, nitems, stream);
  486|    410|}
gpgrt_fwrite:
  491|     23|{
  492|     23|  return _gpgrt_fwrite (ptr, size, nitems, stream);
  493|     23|}
gpgrt_vasprintf:
  713|  2.08k|{
  714|  2.08k|  return _gpgrt_estream_vasprintf (r_buf, format, ap);
  715|  2.08k|}
gpgrt_snprintf:
  746|  5.97k|{
  747|  5.97k|  int rc;
  748|  5.97k|  va_list arg_ptr;
  749|       |
  750|  5.97k|  va_start (arg_ptr, format);
  751|  5.97k|  rc = _gpgrt_estream_vsnprintf (buf, bufsize, format, arg_ptr);
  752|  5.97k|  va_end (arg_ptr);
  753|       |
  754|  5.97k|  return rc;
  755|  5.97k|}
gpgrt_access:
  852|     57|{
  853|     57|  return _gpgrt_access (fname, mode);
  854|     57|}
gpgrt_inc_errorcount:
  905|      1|{
  906|      1|  _gpgrt_inc_errorcount ();
  907|      1|}
gpgrt_log_set_sink:
  911|      1|{
  912|      1|  _gpgrt_log_set_sink (name, stream, fd);
  913|      1|}
gpgrt_log_get_stream:
  953|    827|{
  954|    827|  return _gpgrt_log_get_stream ();
  955|    827|}
gpgrt_log_info:
  988|  1.73k|{
  989|  1.73k|  va_list arg_ptr;
  990|       |
  991|  1.73k|  va_start (arg_ptr, fmt);
  992|  1.73k|  _gpgrt_logv (GPGRT_LOGLVL_INFO, fmt, arg_ptr);
  993|  1.73k|  va_end (arg_ptr);
  994|  1.73k|}
gpgrt_log_error:
  998|  20.0k|{
  999|  20.0k|  va_list arg_ptr;
 1000|       |
 1001|  20.0k|  va_start (arg_ptr, fmt);
 1002|  20.0k|  _gpgrt_logv (GPGRT_LOGLVL_ERROR, fmt, arg_ptr);
 1003|  20.0k|  va_end (arg_ptr);
 1004|  20.0k|}
gpgrt_log_printf:
 1050|    829|{
 1051|    829|  va_list arg_ptr;
 1052|       |
 1053|    829|  va_start (arg_ptr, fmt);
 1054|    829|  _gpgrt_logv (fmt ? GPGRT_LOGLVL_CONT : GPGRT_LOGLVL_BEGIN, fmt, arg_ptr);
  ------------------
  |  Branch (1054:16): [True: 829, False: 0]
  ------------------
 1055|    829|  va_end (arg_ptr);
 1056|    829|}

