~ubuntu-branches/ubuntu/natty/gnupg2/natty-security

« back to all changes in this revision

Viewing changes to agent/protect-tool.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Urlichs
  • Date: 2005-12-08 22:13:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051208221321-4rvs2vu835iam5wv
Tags: 1.9.19-2
* Convert debian/changelog to UTF-8.
* Put gnupg-agent and gpgsm lintian overrides in the respectively
  right package.  Closes: #335066
* Added debhelper tokens to maintainer scripts.
* xsession fixes:
  o Added host name to gpg-agent PID file name.  Closes: #312717
  o Fixed xsession script to be able to run under zsh.  Closes: #308516
  o Don't run gpg-agent if one is already running.  Closes: #336480
* debian/control:
  o Fixed package description of gpgsm package.  Closes: #299842
  o Added mention of gpg-agent to description of gnupg-agent package.
    Closes: #304355
* Thanks to Peter Eisentraut <petere@debian.org> for all of the above.

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
  oShadow,
61
61
  oShowShadowInfo,
62
62
  oShowKeygrip,
 
63
  oCanonical,
63
64
 
64
65
  oP12Import,
65
66
  oP12Export,
86
87
 
87
88
static const char *opt_homedir;
88
89
static int opt_armor;
 
90
static int opt_canonical;
89
91
static int opt_store;
90
92
static int opt_force;
91
93
static int opt_no_fail_on_exist;
107
109
 
108
110
  { oVerbose, "verbose",   0, "verbose" },
109
111
  { oArmor,   "armor",     0, "write output in advanced format" },
 
112
  { oCanonical, "canonical", 0, "write output in canonical format" },
110
113
  { oPassphrase, "passphrase", 2, "|STRING|use passphrase STRING" },
111
114
  { oProtect, "protect",     256, "protect a private key"},
112
115
  { oUnprotect, "unprotect", 256, "unprotect a private key"},
113
 
  { oShadow,  "shadow", 256, "create a shadow entry for a priblic key"},
 
116
  { oShadow,  "shadow", 256, "create a shadow entry for a public key"},
114
117
  { oShowShadowInfo,  "show-shadow-info", 256, "return the shadow info"},
115
118
  { oShowKeygrip, "show-keygrip", 256, "show the \"keygrip\""},
116
119
 
236
239
  int rc;
237
240
  size_t erroff, len;
238
241
  gcry_sexp_t sexp;
239
 
  unsigned char *result;
 
242
  char *result;
240
243
 
241
 
  rc = gcry_sexp_sscan (&sexp, &erroff, buf, buflen);
 
244
  rc = gcry_sexp_sscan (&sexp, &erroff, (const char*)buf, buflen);
242
245
  if (rc)
243
246
    {
244
247
      log_error ("invalid canonical S-Expression (off=%u): %s\n",
375
378
      xfree (result);
376
379
      if (!p)
377
380
        return;
378
 
      result = p;
 
381
      result = (unsigned char*)p;
379
382
      resultlen = strlen (p);
380
383
    }
381
384
 
414
417
      xfree (result);
415
418
      if (!p)
416
419
        return;
417
 
      result = p;
 
420
      result = (unsigned char*)p;
418
421
      resultlen = strlen (p);
419
422
    }
420
423
 
431
434
  unsigned char *key;
432
435
  unsigned char *result;
433
436
  size_t resultlen;
 
437
  unsigned char dummy_info[] = "(8:313233342:43)";
434
438
  
435
439
  key = read_key (fname);
436
440
  if (!key)
437
441
    return;
438
442
 
439
 
  rc = agent_shadow_key (key, "(8:313233342:43)", &result);
 
443
  rc = agent_shadow_key (key, dummy_info, &result);
440
444
  xfree (key);
441
445
  if (rc)
442
446
    {
452
456
      xfree (result);
453
457
      if (!p)
454
458
        return;
455
 
      result = p;
 
459
      result = (unsigned char*)p;
456
460
      resultlen = strlen (p);
457
461
    }
458
462
 
508
512
 
509
513
  keylen = gcry_sexp_canon_len (key, 0, NULL,NULL);
510
514
  assert (keylen);
511
 
 
512
 
  p = make_advanced (key, keylen);
 
515
  
 
516
  if (opt_canonical)
 
517
    {
 
518
      fwrite (key, keylen, 1, stdout);
 
519
    }
 
520
  else
 
521
    {
 
522
      p = make_advanced (key, keylen);
 
523
      if (p)
 
524
        {
 
525
          fwrite (p, strlen (p), 1, stdout);
 
526
          xfree (p);
 
527
        }
 
528
    }
513
529
  xfree (key);
514
 
  if (p)
515
 
    {
516
 
      fwrite (p, strlen (p), 1, stdout);
517
 
      xfree (p);
518
 
    }
519
530
}
520
531
 
521
532
static void
672
683
  if (!buf)
673
684
    return;
674
685
 
675
 
  kparms = p12_parse (buf, buflen, (pw=get_passphrase (2)),
 
686
  kparms = p12_parse ((unsigned char*)buf, buflen, (pw=get_passphrase (2)),
676
687
                      import_p12_cert_cb, NULL);
677
688
  release_passphrase (pw);
678
689
  xfree (buf);
763
774
      xfree (result);
764
775
      if (!p)
765
776
        return;
766
 
      result = p;
 
777
      result = (unsigned char*)p;
767
778
      resultlen = strlen (p);
768
779
    }
769
780
 
922
933
 
923
934
  if (opt_have_cert)
924
935
    {
925
 
      cert = read_file ("-", &certlen);
 
936
      cert = (unsigned char*)read_file ("-", &certlen);
926
937
      if (!cert)
927
938
        {
928
939
          wipememory (key, keylen_for_wipe);
1030
1041
static char *
1031
1042
percent_plus_unescape_string (char *string) 
1032
1043
{
1033
 
  unsigned char *p = string;
 
1044
  unsigned char *p = (unsigned char*)string;
1034
1045
  size_t n;
1035
1046
 
1036
1047
  n = percent_plus_unescape (p);
1079
1090
        {
1080
1091
        case oVerbose: opt.verbose++; break;
1081
1092
        case oArmor:   opt_armor=1; break;
 
1093
        case oCanonical: opt_canonical=1; break;
1082
1094
        case oHomedir: opt_homedir = pargs.r.ret_str; break;
1083
1095
 
1084
1096
        case oProtect: cmd = oProtect; break;