~ubuntu-branches/ubuntu/hardy/gnupg2/hardy-proposed

« back to all changes in this revision

Viewing changes to agent/protect-tool.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Bienia
  • Date: 2007-05-15 13:54:55 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20070515135455-89qfyalmgjy6gcqw
Tags: 2.0.4-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Remove libpcsclite-dev, libopensc2-dev build dependencies (they are in
    universe).
  - Build-depend on libcurl3-gnutls-dev
  - g10/call-agent.c: set DBG_ASSUAN to 0 to suppress a debug message
  - Include /doc files as done with gnupg
  - debian/rules: add doc/com-certs.pem to the docs for gpgsm
  - debian/copyright: update download url
  - debian/README.Debian: remove note the gnupg2 isn't released yet.
  - debian/control: Change Maintainer/XSBC-Original-Maintainer field.

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
 
66
66
  oP12Import,
67
67
  oP12Export,
 
68
  oP12Charset,
68
69
  oStore,
69
70
  oForce,
70
71
  oHaveCert,
96
97
static const char *opt_passphrase;
97
98
static char *opt_prompt;
98
99
static int opt_status_msg;
 
100
static const char *opt_p12_charset;
99
101
 
100
102
static char *get_passphrase (int promptno, int opt_check);
101
103
static char *get_new_passphrase (int promptno);
118
120
  { oShowShadowInfo,  "show-shadow-info", 256, "return the shadow info"},
119
121
  { oShowKeygrip, "show-keygrip", 256, "show the \"keygrip\""},
120
122
 
121
 
  { oP12Import, "p12-import", 256, "import a PKCS-12 encoded private key"},
122
 
  { oP12Export, "p12-export", 256, "export a private key PKCS-12 encoded"},
 
123
  { oP12Import, "p12-import", 256, "import a pkcs#12 encoded private key"},
 
124
  { oP12Export, "p12-export", 256, "export a private key pkcs#12 encoded"},
 
125
  { oP12Charset,"p12-charset", 2,
 
126
    "|NAME|set charset for a new PKCS#12 passphrase to NAME" },
123
127
  { oHaveCert, "have-cert", 0,  "certificate to export provided on STDIN"},
124
128
  { oStore,     "store", 0, "store the created key in the appropriate place"},
125
129
  { oForce,     "force", 0, "force overwriting"},
127
131
  { oHomedir, "homedir", 2, "@" }, 
128
132
  { oPrompt,  "prompt", 2, "|ESCSTRING|use ESCSTRING as prompt in pinentry"}, 
129
133
  { oStatusMsg, "enable-status-msg", 0, "@"},
 
134
 
130
135
  {0}
131
136
};
132
137
 
172
177
 
173
178
 
174
179
 
175
 
/* Used by gcry for logging */
176
 
static void
177
 
my_gcry_logger (void *dummy, int level, const char *fmt, va_list arg_ptr)
178
 
{
179
 
  /* translate the log levels */
180
 
  switch (level)
181
 
    {
182
 
    case GCRY_LOG_CONT: level = JNLIB_LOG_CONT; break;
183
 
    case GCRY_LOG_INFO: level = JNLIB_LOG_INFO; break;
184
 
    case GCRY_LOG_WARN: level = JNLIB_LOG_WARN; break;
185
 
    case GCRY_LOG_ERROR:level = JNLIB_LOG_ERROR; break;
186
 
    case GCRY_LOG_FATAL:level = JNLIB_LOG_FATAL; break;
187
 
    case GCRY_LOG_BUG:  level = JNLIB_LOG_BUG; break;
188
 
    case GCRY_LOG_DEBUG:level = JNLIB_LOG_DEBUG; break;
189
 
    default:            level = JNLIB_LOG_ERROR; break;      }
190
 
  log_logv (level, fmt, arg_ptr);
191
 
}
192
 
 
193
 
 
194
180
/*  static void */
195
181
/*  print_mpi (const char *text, gcry_mpi_t a) */
196
182
/*  { */
987
973
  kparms[8] = NULL;
988
974
 
989
975
  key = p12_build (kparms, cert, certlen,
990
 
                   (pw=get_new_passphrase (3)), &keylen);
 
976
                   (pw=get_new_passphrase (3)), opt_p12_charset, &keylen);
991
977
  release_passphrase (pw);
992
978
  xfree (cert);
993
979
  for (i=0; i < 8; i++)
1070
1056
 
1071
1057
  if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
1072
1058
    {
1073
 
      log_fatal( _("libgcrypt is too old (need %s, have %s)\n"),
 
1059
      log_fatal( _("%s is too old (need %s, have %s)\n"), "libgcrypt",
1074
1060
                 NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) );
1075
1061
    }
1076
1062
 
1077
 
  gcry_set_log_handler (my_gcry_logger, NULL);
1078
 
  
 
1063
  setup_libgcrypt_logging ();
1079
1064
  gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
1080
1065
 
1081
1066
 
1101
1086
        case oShowKeygrip: cmd = oShowKeygrip; break;
1102
1087
        case oP12Import: cmd = oP12Import; break;
1103
1088
        case oP12Export: cmd = oP12Export; break;
 
1089
        case oP12Charset: opt_p12_charset = pargs.r.ret_str; break;
1104
1090
 
1105
1091
        case oPassphrase: opt_passphrase = pargs.r.ret_str; break;
1106
1092
        case oStore: opt_store = 1; break;