Blame tests/run-genkey.c

Packit Service 672cf4
/* run-genkey.c  - Test tool to perform key generation
Packit Service 672cf4
 * Copyright (C) 2016 g10 Code GmbH
Packit Service 672cf4
 *
Packit Service 672cf4
 * This file is part of GPGME.
Packit Service 672cf4
 *
Packit Service 672cf4
 * GPGME is free software; you can redistribute it and/or modify it
Packit Service 672cf4
 * under the terms of the GNU Lesser General Public License as
Packit Service 672cf4
 * published by the Free Software Foundation; either version 2.1 of
Packit Service 672cf4
 * the License, or (at your option) any later version.
Packit Service 672cf4
 *
Packit Service 672cf4
 * GPGME is distributed in the hope that it will be useful, but
Packit Service 672cf4
 * WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 672cf4
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 672cf4
 * Lesser General Public License for more details.
Packit Service 672cf4
 *
Packit Service 672cf4
 * You should have received a copy of the GNU Lesser General Public
Packit Service 0ef63b
 * License along with this program; if not, see <https://gnu.org/licenses/>.
Packit Service 0ef63b
 * SPDX-License-Identifier: LGPL-2.1-or-later
Packit Service 672cf4
 */
Packit Service 672cf4
Packit Service 672cf4
/* We need to include config.h so that we know whether we are building
Packit Service 672cf4
   with large file system (LFS) support. */
Packit Service 672cf4
#ifdef HAVE_CONFIG_H
Packit Service 672cf4
#include <config.h>
Packit Service 672cf4
#endif
Packit Service 672cf4
Packit Service 672cf4
#include <stdlib.h>
Packit Service 672cf4
#include <stdio.h>
Packit Service 672cf4
#include <string.h>
Packit Service 672cf4
#include <assert.h>
Packit Service 672cf4
Packit Service 672cf4
#include <gpgme.h>
Packit Service 672cf4
Packit Service 672cf4
#define PGM "run-genkey"
Packit Service 672cf4
Packit Service 672cf4
#include "run-support.h"
Packit Service 672cf4
Packit Service 672cf4
Packit Service 672cf4
static int verbose;
Packit Service 672cf4
Packit Service 672cf4
Packit Service 672cf4
/* Tokenize STRING using the set of delimiters in DELIM.  Leading
Packit Service 672cf4
 * spaces and tabs are removed from all tokens.  The caller must free
Packit Service 672cf4
 * the result.
Packit Service 672cf4
 *
Packit Service 672cf4
 * Returns: A malloced and NULL delimited array with the tokens.  On
Packit Service 672cf4
 *          memory error NULL is returned and ERRNO is set.
Packit Service 672cf4
 */
Packit Service 672cf4
static char **
Packit Service 672cf4
strtokenize (const char *string, const char *delim)
Packit Service 672cf4
{
Packit Service 672cf4
  const char *s;
Packit Service 672cf4
  size_t fields;
Packit Service 672cf4
  size_t bytes, n;
Packit Service 672cf4
  char *buffer;
Packit Service 672cf4
  char *p, *px, *pend;
Packit Service 672cf4
  char **result;
Packit Service 672cf4
Packit Service 672cf4
  /* Count the number of fields.  */
Packit Service 672cf4
  for (fields = 1, s = strpbrk (string, delim); s; s = strpbrk (s + 1, delim))
Packit Service 672cf4
    fields++;
Packit Service 672cf4
  fields++; /* Add one for the terminating NULL.  */
Packit Service 672cf4
Packit Service 672cf4
  /* Allocate an array for all fields, a terminating NULL, and space
Packit Service 672cf4
     for a copy of the string.  */
Packit Service 672cf4
  bytes = fields * sizeof *result;
Packit Service 672cf4
  if (bytes / sizeof *result != fields)
Packit Service 672cf4
    {
Packit Service 672cf4
      gpg_err_set_errno (ENOMEM);
Packit Service 672cf4
      return NULL;
Packit Service 672cf4
    }
Packit Service 672cf4
  n = strlen (string) + 1;
Packit Service 672cf4
  bytes += n;
Packit Service 672cf4
  if (bytes < n)
Packit Service 672cf4
    {
Packit Service 672cf4
      gpg_err_set_errno (ENOMEM);
Packit Service 672cf4
      return NULL;
Packit Service 672cf4
    }
Packit Service 672cf4
  result = malloc (bytes);
Packit Service 672cf4
  if (!result)
Packit Service 672cf4
    return NULL;
Packit Service 672cf4
  buffer = (char*)(result + fields);
Packit Service 672cf4
Packit Service 672cf4
  /* Copy and parse the string.  */
Packit Service 672cf4
  strcpy (buffer, string);
Packit Service 672cf4
  for (n = 0, p = buffer; (pend = strpbrk (p, delim)); p = pend + 1)
Packit Service 672cf4
    {
Packit Service 672cf4
      *pend = 0;
Packit Service 672cf4
      while (*p == ' ' || *p == '\t')
Packit Service 672cf4
        p++;
Packit Service 672cf4
      for (px = pend - 1; px >= p && (*px == ' ' || *px == '\t'); px--)
Packit Service 672cf4
        *px = 0;
Packit Service 672cf4
      result[n++] = p;
Packit Service 672cf4
    }
Packit Service 672cf4
  while (*p == ' ' || *p == '\t')
Packit Service 672cf4
    p++;
Packit Service 672cf4
  for (px = p + strlen (p) - 1; px >= p && (*px == ' ' || *px == '\t'); px--)
Packit Service 672cf4
    *px = 0;
Packit Service 672cf4
  result[n++] = p;
Packit Service 672cf4
  result[n] = NULL;
Packit Service 672cf4
Packit Service 672cf4
  assert ((char*)(result + n + 1) == buffer);
Packit Service 672cf4
Packit Service 672cf4
  return result;
Packit Service 672cf4
}
Packit Service 672cf4
Packit Service 672cf4
Packit Service 672cf4
static gpg_error_t
Packit Service 672cf4
status_cb (void *opaque, const char *keyword, const char *value)
Packit Service 672cf4
{
Packit Service 672cf4
  (void)opaque;
Packit Service 672cf4
  fprintf (stderr, "status_cb: %s %s\n", nonnull(keyword), nonnull(value));
Packit Service 672cf4
  return 0;
Packit Service 672cf4
}
Packit Service 672cf4
Packit Service 672cf4
Packit Service 672cf4
static void
Packit Service 672cf4
progress_cb (void *opaque, const char *what, int type, int current, int total)
Packit Service 672cf4
{
Packit Service 672cf4
  (void)opaque;
Packit Service 672cf4
  (void)type;
Packit Service 672cf4
Packit Service 672cf4
  if (total)
Packit Service 672cf4
    fprintf (stderr, "progress for '%s' %u%% (%d of %d)\n",
Packit Service 672cf4
             nonnull (what),
Packit Service 672cf4
             (unsigned)(((double)current / total) * 100), current, total);
Packit Service 672cf4
  else
Packit Service 672cf4
    fprintf (stderr, "progress for '%s' %d\n", nonnull(what), current);
Packit Service 672cf4
  fflush (stderr);
Packit Service 672cf4
}
Packit Service 672cf4
Packit Service 672cf4
Packit Service 672cf4
static unsigned long
Packit Service 672cf4
parse_expire_string (const char *string)
Packit Service 672cf4
{
Packit Service 672cf4
  unsigned long seconds;
Packit Service 672cf4
Packit Service 672cf4
  if (!string || !*string || !strcmp (string, "none")
Packit Service 672cf4
      || !strcmp (string, "never") || !strcmp (string, "-"))
Packit Service 672cf4
    seconds = 0;
Packit Service 672cf4
  else if (strspn (string, "01234567890") == strlen (string))
Packit Service 672cf4
    seconds = strtoul (string, NULL, 10);
Packit Service 672cf4
  else
Packit Service 672cf4
    {
Packit Service 672cf4
      fprintf (stderr, PGM ": invalid value '%s'\n", string);
Packit Service 672cf4
      exit (1);
Packit Service 672cf4
    }
Packit Service 672cf4
Packit Service 672cf4
  return seconds;
Packit Service 672cf4
}
Packit Service 672cf4
Packit Service 672cf4
Packit Service 672cf4
/* Parse a usage string and return flags for gpgme_op_createkey.  */
Packit Service 672cf4
static unsigned int
Packit Service 672cf4
parse_usage_string (const char *string)
Packit Service 672cf4
{
Packit Service 672cf4
  gpg_error_t err;
Packit Service 672cf4
  char **tokens = NULL;
Packit Service 672cf4
  const char *s;
Packit Service 672cf4
  int i;
Packit Service 672cf4
  unsigned int flags = 0;
Packit Service 672cf4
Packit Service 672cf4
  tokens = strtokenize (string, " \t,");
Packit Service 672cf4
  if (!tokens)
Packit Service 672cf4
    {
Packit Service 672cf4
      err = gpg_error_from_syserror ();
Packit Service 672cf4
      fprintf (stderr, PGM": strtokenize failed: %s\n", gpg_strerror (err));
Packit Service 672cf4
      exit (1);
Packit Service 672cf4
    }
Packit Service 672cf4
Packit Service 672cf4
  for (i=0; (s = tokens[i]); i++)
Packit Service 672cf4
    {
Packit Service 672cf4
      if (!*s)
Packit Service 672cf4
        ;
Packit Service 672cf4
      else if (!strcmp (s, "default"))
Packit Service 672cf4
        ;
Packit Service 672cf4
      else if (!strcmp (s, "sign"))
Packit Service 672cf4
        flags |= GPGME_CREATE_SIGN;
Packit Service 672cf4
      else if (!strcmp (s, "encr"))
Packit Service 672cf4
        flags |= GPGME_CREATE_ENCR;
Packit Service 672cf4
      else if (!strcmp (s, "cert"))
Packit Service 672cf4
        flags |= GPGME_CREATE_CERT;
Packit Service 672cf4
      else if (!strcmp (s, "auth"))
Packit Service 672cf4
        flags |= GPGME_CREATE_AUTH;
Packit Service 672cf4
      else
Packit Service 672cf4
        {
Packit Service 672cf4
          free (tokens);
Packit Service 672cf4
          fprintf (stderr, PGM": invalid value '%s': %s\n",
Packit Service 672cf4
                   string, "bad usage");
Packit Service 672cf4
          exit (1);
Packit Service 672cf4
        }
Packit Service 672cf4
    }
Packit Service 672cf4
Packit Service 672cf4
  free (tokens);
Packit Service 672cf4
  return flags;
Packit Service 672cf4
}
Packit Service 672cf4
Packit Service 672cf4
Packit Service 672cf4
Packit Service 672cf4
static int
Packit Service 672cf4
show_usage (int ex)
Packit Service 672cf4
{
Packit Service 672cf4
  fputs ("usage: " PGM " [options] ARGS\n"
Packit Service 672cf4
         "         args: USERID [ALGO [USAGE [EXPIRESECONDS]]]\n"
Packit Service 672cf4
         "   for addkey: FPR    [ALGO [USAGE [EXPIRESECONDS]]]\n"
Packit Service 672cf4
         "   for adduid: FPR    USERID\n"
Packit Service 672cf4
         "   for revuid: FPR    USERID\n"
Packit Service 672cf4
         "   for set-primary: FPR    USERID\n"
Packit Service 672cf4
         "Options:\n"
Packit Service 672cf4
         "  --addkey         add a subkey to the key with FPR\n"
Packit Service 672cf4
         "  --adduid         add a user id to the key with FPR\n"
Packit Service 672cf4
         "  --revuid         revoke a user id from the key with FPR\n"
Packit Service 672cf4
         "  --set-primary    set the primary key flag on USERID\n"
Packit Service 672cf4
         "  --verbose        run in verbose mode\n"
Packit Service 672cf4
         "  --status         print status lines from the backend\n"
Packit Service 672cf4
         "  --progress       print progress info\n"
Packit Service 672cf4
         "  --openpgp        use the OpenPGP protocol (default)\n"
Packit Service 672cf4
         "  --cms            use the CMS protocol\n"
Packit Service 672cf4
         "  --loopback       use a loopback pinentry\n"
Packit Service 672cf4
         "  --unprotected    do not use a passphrase\n"
Packit Service 672cf4
         "  --force          do not check for a duplicated user id\n"
Packit Service 672cf4
         , stderr);
Packit Service 672cf4
  exit (ex);
Packit Service 672cf4
}
Packit Service 672cf4
Packit Service 672cf4
Packit Service 672cf4
int
Packit Service 672cf4
main (int argc, char **argv)
Packit Service 672cf4
{
Packit Service 672cf4
  int last_argc = -1;
Packit Service 672cf4
  gpgme_error_t err;
Packit Service 672cf4
  gpgme_ctx_t ctx;
Packit Service 672cf4
  gpgme_protocol_t protocol = GPGME_PROTOCOL_OpenPGP;
Packit Service 672cf4
  int print_status = 0;
Packit Service 672cf4
  int print_progress = 0;
Packit Service 672cf4
  int use_loopback = 0;
Packit Service 672cf4
  int addkey = 0;
Packit Service 672cf4
  int adduid = 0;
Packit Service 672cf4
  int revuid = 0;
Packit Service 672cf4
  int setpri = 0;
Packit Service 672cf4
  const char *userid;
Packit Service 672cf4
  const char *algo = NULL;
Packit Service 672cf4
  const char *newuserid = NULL;
Packit Service 672cf4
  unsigned int flags = 0;
Packit Service 672cf4
  unsigned long expire = 0;
Packit Service 672cf4
  gpgme_genkey_result_t result;
Packit Service 672cf4
Packit Service 672cf4
  if (argc)
Packit Service 672cf4
    { argc--; argv++; }
Packit Service 672cf4
Packit Service 672cf4
  while (argc && last_argc != argc )
Packit Service 672cf4
    {
Packit Service 672cf4
      last_argc = argc;
Packit Service 672cf4
      if (!strcmp (*argv, "--"))
Packit Service 672cf4
        {
Packit Service 672cf4
          argc--; argv++;
Packit Service 672cf4
          break;
Packit Service 672cf4
        }
Packit Service 672cf4
      else if (!strcmp (*argv, "--help"))
Packit Service 672cf4
        show_usage (0);
Packit Service 672cf4
      else if (!strcmp (*argv, "--addkey"))
Packit Service 672cf4
        {
Packit Service 672cf4
          addkey = 1;
Packit Service 672cf4
          adduid = 0;
Packit Service 672cf4
          revuid = 0;
Packit Service 672cf4
          setpri = 0;
Packit Service 672cf4
          argc--; argv++;
Packit Service 672cf4
        }
Packit Service 672cf4
      else if (!strcmp (*argv, "--adduid"))
Packit Service 672cf4
        {
Packit Service 672cf4
          addkey = 0;
Packit Service 672cf4
          adduid = 1;
Packit Service 672cf4
          revuid = 0;
Packit Service 672cf4
          setpri = 0;
Packit Service 672cf4
          argc--; argv++;
Packit Service 672cf4
        }
Packit Service 672cf4
      else if (!strcmp (*argv, "--revuid"))
Packit Service 672cf4
        {
Packit Service 672cf4
          addkey = 0;
Packit Service 672cf4
          adduid = 0;
Packit Service 672cf4
          revuid = 1;
Packit Service 672cf4
          setpri = 0;
Packit Service 672cf4
          argc--; argv++;
Packit Service 672cf4
        }
Packit Service 672cf4
      else if (!strcmp (*argv, "--set-primary"))
Packit Service 672cf4
        {
Packit Service 672cf4
          addkey = 0;
Packit Service 672cf4
          adduid = 0;
Packit Service 672cf4
          revuid = 0;
Packit Service 672cf4
          setpri = 1;
Packit Service 672cf4
          argc--; argv++;
Packit Service 672cf4
        }
Packit Service 672cf4
      else if (!strcmp (*argv, "--verbose"))
Packit Service 672cf4
        {
Packit Service 672cf4
          verbose = 1;
Packit Service 672cf4
          argc--; argv++;
Packit Service 672cf4
        }
Packit Service 672cf4
      else if (!strcmp (*argv, "--status"))
Packit Service 672cf4
        {
Packit Service 672cf4
          print_status = 1;
Packit Service 672cf4
          argc--; argv++;
Packit Service 672cf4
        }
Packit Service 672cf4
      else if (!strcmp (*argv, "--progress"))
Packit Service 672cf4
        {
Packit Service 672cf4
          print_progress = 1;
Packit Service 672cf4
          argc--; argv++;
Packit Service 672cf4
        }
Packit Service 672cf4
      else if (!strcmp (*argv, "--openpgp"))
Packit Service 672cf4
        {
Packit Service 672cf4
          protocol = GPGME_PROTOCOL_OpenPGP;
Packit Service 672cf4
          argc--; argv++;
Packit Service 672cf4
        }
Packit Service 672cf4
      else if (!strcmp (*argv, "--cms"))
Packit Service 672cf4
        {
Packit Service 672cf4
          protocol = GPGME_PROTOCOL_CMS;
Packit Service 672cf4
          argc--; argv++;
Packit Service 672cf4
        }
Packit Service 672cf4
      else if (!strcmp (*argv, "--loopback"))
Packit Service 672cf4
        {
Packit Service 672cf4
          use_loopback = 1;
Packit Service 672cf4
          argc--; argv++;
Packit Service 672cf4
        }
Packit Service 672cf4
      else if (!strcmp (*argv, "--unprotected"))
Packit Service 672cf4
        {
Packit Service 672cf4
          flags |= GPGME_CREATE_NOPASSWD;
Packit Service 672cf4
          argc--; argv++;
Packit Service 672cf4
        }
Packit Service 672cf4
      else if (!strcmp (*argv, "--force"))
Packit Service 672cf4
        {
Packit Service 672cf4
          flags |= GPGME_CREATE_FORCE;
Packit Service 672cf4
          argc--; argv++;
Packit Service 672cf4
        }
Packit Service 672cf4
      else if (!strncmp (*argv, "--", 2))
Packit Service 672cf4
        show_usage (1);
Packit Service 672cf4
    }
Packit Service 672cf4
Packit Service 672cf4
  if (adduid || revuid || setpri)
Packit Service 672cf4
    {
Packit Service 672cf4
      if (argc != 2)
Packit Service 672cf4
        show_usage (1);
Packit Service 672cf4
      userid = argv[0];
Packit Service 672cf4
      newuserid = argv[1];
Packit Service 672cf4
    }
Packit Service 672cf4
  else
Packit Service 672cf4
    {
Packit Service 672cf4
      if (!argc || argc > 4)
Packit Service 672cf4
        show_usage (1);
Packit Service 672cf4
      userid = argv[0];
Packit Service 672cf4
      if (argc > 1)
Packit Service 672cf4
        algo = argv[1];
Packit Service 672cf4
      if (argc > 2)
Packit Service 672cf4
        flags |= parse_usage_string (argv[2]);
Packit Service 672cf4
      if (argc > 3)
Packit Service 672cf4
        expire = parse_expire_string (argv[3]);
Packit Service 672cf4
    }
Packit Service 672cf4
Packit Service 672cf4
  init_gpgme (protocol);
Packit Service 672cf4
Packit Service 672cf4
  err = gpgme_new (&ctx;;
Packit Service 672cf4
  fail_if_err (err);
Packit Service 672cf4
  gpgme_set_protocol (ctx, protocol);
Packit Service 672cf4
  gpgme_set_armor (ctx, 1);
Packit Service 672cf4
  if (print_status)
Packit Service 672cf4
    {
Packit Service 672cf4
      gpgme_set_status_cb (ctx, status_cb, NULL);
Packit Service 672cf4
      gpgme_set_ctx_flag (ctx, "full-status", "1");
Packit Service 672cf4
    }
Packit Service 672cf4
  if (print_progress)
Packit Service 672cf4
    gpgme_set_progress_cb (ctx, progress_cb, NULL);
Packit Service 672cf4
  if (use_loopback)
Packit Service 672cf4
    {
Packit Service 672cf4
      gpgme_set_pinentry_mode (ctx, GPGME_PINENTRY_MODE_LOOPBACK);
Packit Service 672cf4
      gpgme_set_passphrase_cb (ctx, passphrase_cb, NULL);
Packit Service 672cf4
    }
Packit Service 672cf4
Packit Service 672cf4
  if (addkey || adduid || revuid || setpri)
Packit Service 672cf4
    {
Packit Service 672cf4
      gpgme_key_t akey;
Packit Service 672cf4
Packit Service 672cf4
      err = gpgme_get_key (ctx, userid, &akey, 1);
Packit Service 672cf4
      if (err)
Packit Service 672cf4
        {
Packit Service 672cf4
          fprintf (stderr, PGM ": error getting secret key for '%s': %s\n",
Packit Service 672cf4
                   userid, gpg_strerror (err));
Packit Service 672cf4
          exit (1);
Packit Service 672cf4
        }
Packit Service 672cf4
Packit Service 672cf4
      if (addkey)
Packit Service 672cf4
        {
Packit Service 672cf4
          err = gpgme_op_createsubkey (ctx, akey, algo, 0, expire, flags);
Packit Service 672cf4
          if (err)
Packit Service 672cf4
            {
Packit Service 672cf4
              fprintf (stderr, PGM ": gpgme_op_createsubkey failed: %s\n",
Packit Service 672cf4
                       gpg_strerror (err));
Packit Service 672cf4
              exit (1);
Packit Service 672cf4
            }
Packit Service 672cf4
        }
Packit Service 672cf4
      else if (adduid)
Packit Service 672cf4
        {
Packit Service 672cf4
          err = gpgme_op_adduid (ctx, akey, newuserid, flags);
Packit Service 672cf4
          if (err)
Packit Service 672cf4
            {
Packit Service 672cf4
              fprintf (stderr, PGM ": gpgme_op_adduid failed: %s\n",
Packit Service 672cf4
                       gpg_strerror (err));
Packit Service 672cf4
              exit (1);
Packit Service 672cf4
            }
Packit Service 672cf4
        }
Packit Service 672cf4
      else if (revuid)
Packit Service 672cf4
        {
Packit Service 672cf4
          err = gpgme_op_revuid (ctx, akey, newuserid, flags);
Packit Service 672cf4
          if (err)
Packit Service 672cf4
            {
Packit Service 672cf4
              fprintf (stderr, PGM ": gpgme_op_revuid failed: %s\n",
Packit Service 672cf4
                       gpg_strerror (err));
Packit Service 672cf4
              exit (1);
Packit Service 672cf4
            }
Packit Service 672cf4
        }
Packit Service 672cf4
      else if (setpri)
Packit Service 672cf4
        {
Packit Service 672cf4
          err = gpgme_op_set_uid_flag (ctx, akey, newuserid, "primary", NULL);
Packit Service 672cf4
          if (err)
Packit Service 672cf4
            {
Packit Service 672cf4
              fprintf (stderr, PGM ": gpgme_op_set_uid_flag failed: %s\n",
Packit Service 672cf4
                       gpg_strerror (err));
Packit Service 672cf4
              exit (1);
Packit Service 672cf4
            }
Packit Service 672cf4
        }
Packit Service 672cf4
      gpgme_key_unref (akey);
Packit Service 672cf4
    }
Packit Service 672cf4
  else
Packit Service 672cf4
    {
Packit Service 672cf4
      err = gpgme_op_createkey (ctx, userid, algo, 0, expire, NULL, flags);
Packit Service 672cf4
      if (err)
Packit Service 672cf4
        {
Packit Service 672cf4
          fprintf (stderr, PGM ": gpgme_op_createkey failed: %s\n",
Packit Service 672cf4
                   gpg_strerror (err));
Packit Service 672cf4
          exit (1);
Packit Service 672cf4
        }
Packit Service 672cf4
    }
Packit Service 672cf4
Packit Service 672cf4
  if (!setpri)
Packit Service 672cf4
    {
Packit Service 672cf4
      result = gpgme_op_genkey_result (ctx);
Packit Service 672cf4
      if (!result)
Packit Service 672cf4
        {
Packit Service 672cf4
          fprintf (stderr, PGM": gpgme_op_genkey_result returned NULL\n");
Packit Service 672cf4
          exit (1);
Packit Service 672cf4
        }
Packit Service 672cf4
Packit Service 672cf4
      printf ("Generated key: %s (%s)\n",
Packit Service 672cf4
              result->fpr ? result->fpr : "none",
Packit Service 672cf4
              result->primary ? (result->sub ? "primary, sub" : "primary")
Packit Service 672cf4
              /**/            : (result->sub ? "sub" : "none"));
Packit Service 672cf4
Packit Service 672cf4
      if (result->fpr && strlen (result->fpr) < 40)
Packit Service 672cf4
        fprintf (stderr, PGM": generated key has unexpected fingerprint\n");
Packit Service 672cf4
      if (!result->primary)
Packit Service 672cf4
        fprintf (stderr, PGM": primary key was not generated\n");
Packit Service 672cf4
      if (!result->sub)
Packit Service 672cf4
        fprintf (stderr, PGM": sub key was not generated\n");
Packit Service 672cf4
      if (!result->uid)
Packit Service 672cf4
        fprintf (stderr, PGM": uid was not generated\n");
Packit Service 672cf4
    }
Packit Service 672cf4
Packit Service 672cf4
  gpgme_release (ctx);
Packit Service 672cf4
  return 0;
Packit Service 672cf4
}