~ubuntu-branches/ubuntu/karmic/gnupg2/karmic-security

« back to all changes in this revision

Viewing changes to sm/export.c

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2009-08-04 12:27:49 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20090804122749-q0j52zp6xmzvyall
Tags: 2.0.12-0ubuntu1
* New upstream release.
* Add 01-scd-pw2.patch, 03-opgp-writekey.patch, and 06-opgp-sign3072.patch
  from https://bugs.g10code.com/gnupg/issue1094 to make OpenPGP 2.0
  smartcards work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* export.c - Export certificates and private keys.
2
 
 * Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
 
2
 * Copyright (C) 2002, 2003, 2004, 2007, 2009 Free Software Foundation, Inc.
3
3
 *
4
4
 * This file is part of GnuPG.
5
5
 *
37
37
 
38
38
 
39
39
/* A table to store a fingerprint as used in a duplicates table.  We
40
 
   don't need to hash here because a fingerprint is alrady a perfect
 
40
   don't need to hash here because a fingerprint is already a perfect
41
41
   hash value.  This we use the most significant bits to index the
42
42
   table and then use a linked list for the overflow.  Possible
43
 
   enhancement for very large number of certictates: Add a second
44
 
   level table and then resort to a linked list. */
 
43
   enhancement for very large number of certificates:  Add a second
 
44
   level table and then resort to a linked list.  */
45
45
struct duptable_s
46
46
{
47
47
  struct duptable_s *next;
192
192
        }
193
193
    }
194
194
 
195
 
  /* If all specifications are done by fingerprint, we switch to
196
 
     ephemeral mode so that _all_ currently available and matching
197
 
     certificates are exported. 
198
 
 
199
 
     fixme: we should in this case keep a list of certificates to
200
 
     avoid accidential export of duplicate certificates. */
 
195
  /* If all specifications are done by fingerprint or keygrip, we
 
196
     switch to ephemeral mode so that _all_ currently available and
 
197
     matching certificates are exported.  */
201
198
  if (names && ndesc)
202
199
    {
203
200
      for (i=0; (i < ndesc
204
201
                 && (desc[i].mode == KEYDB_SEARCH_MODE_FPR
205
202
                     || desc[i].mode == KEYDB_SEARCH_MODE_FPR20
206
 
                     || desc[i].mode == KEYDB_SEARCH_MODE_FPR16)); i++)
 
203
                     || desc[i].mode == KEYDB_SEARCH_MODE_FPR16
 
204
                     || desc[i].mode == KEYDB_SEARCH_MODE_KEYGRIP)); i++)
207
205
        ;
208
206
      if (i == ndesc)
209
207
        keydb_set_ephemeral (hd, 1);
228
226
      rc = insert_duptable (dtable, fpr, &exists);
229
227
      if (rc)
230
228
        {
231
 
          log_error ("inserting into duplicates table fauiled: %s\n",
 
229
          log_error ("inserting into duplicates table failed: %s\n",
232
230
                     gpg_strerror (rc));
233
231
          goto leave;
234
232
        }
576
574
                    const char *prompt, const char *keygrip,
577
575
                    pid_t *pid)
578
576
{
579
 
  const char *argv[20];
 
577
  const char *argv[22];
580
578
  int i=0;
581
579
 
582
580
  /* Make sure that the agent is running so that the protect tool is
583
581
     able to ask for a passphrase.  This has only an effect under W32
584
582
     where the agent is started on demand; sending a NOP does not harm
585
 
     on other platforms. */
 
583
     on other platforms.  This is not really necessary anymore because
 
584
     the protect tool does this now by itself; it does not harm either.*/
586
585
  gpgsm_agent_send_nop (ctrl);
587
586
 
588
587
  argv[i++] = "--homedir";
597
596
      argv[i++] = "--p12-charset";
598
597
      argv[i++] = opt.p12_charset;
599
598
    }
 
599
  if (opt.agent_program)
 
600
    {
 
601
      argv[i++] = "--agent-program";
 
602
      argv[i++] = opt.agent_program;
 
603
    }
600
604
  argv[i++] = "--",
601
605
  argv[i++] = keygrip,
602
606
  argv[i] = NULL;
603
607
  assert (i < sizeof argv);
604
608
 
605
609
  return gnupg_spawn_process (pgmname, argv, infile, outfile,
606
 
                              setup_pinentry_env, 128,
 
610
                              setup_pinentry_env, (128|64),
607
611
                              statusfile, pid);
608
612
}
609
613