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;
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\""},
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, "@"},
175
/* Used by gcry for logging */
177
my_gcry_logger (void *dummy, int level, const char *fmt, va_list arg_ptr)
179
/* translate the log levels */
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);
194
180
/* static void */
195
181
/* print_mpi (const char *text, gcry_mpi_t a) */
987
973
kparms[8] = NULL;
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);
993
979
for (i=0; i < 8; i++)
1071
1057
if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
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) );
1077
gcry_set_log_handler (my_gcry_logger, NULL);
1063
setup_libgcrypt_logging ();
1079
1064
gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
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;
1105
1091
case oPassphrase: opt_passphrase = pargs.r.ret_str; break;
1106
1092
case oStore: opt_store = 1; break;