101
101
static char *opt_prompt;
102
102
static int opt_status_msg;
103
103
static const char *opt_p12_charset;
104
static const char *opt_agent_program;
104
static const char *opt_agent_program;
105
static session_env_t opt_session_env;
106
107
static char *get_passphrase (int promptno);
107
108
static void release_passphrase (char *pw);
117
118
ARGPARSE_c (oShadow, "shadow", "create a shadow entry for a public key"),
118
119
ARGPARSE_c (oShowShadowInfo, "show-shadow-info", "return the shadow info"),
119
120
ARGPARSE_c (oShowKeygrip, "show-keygrip", "show the \"keygrip\""),
120
ARGPARSE_c (oP12Import, "p12-import",
121
ARGPARSE_c (oP12Import, "p12-import",
121
122
"import a pkcs#12 encoded private key"),
122
123
ARGPARSE_c (oP12Export, "p12-export",
123
124
"export a private key pkcs#12 encoded"),
125
126
ARGPARSE_c (oS2Kcalibration, "s2k-calibration", "@"),
127
128
ARGPARSE_group (301, N_("@\nOptions:\n ")),
129
130
ARGPARSE_s_n (oVerbose, "verbose", "verbose"),
135
136
"|NAME|set charset for a new PKCS#12 passphrase to NAME"),
136
137
ARGPARSE_s_n (oHaveCert, "have-cert",
137
138
"certificate to export provided on STDIN"),
138
ARGPARSE_s_n (oStore, "store",
139
ARGPARSE_s_n (oStore, "store",
139
140
"store the created key in the appropriate place"),
140
ARGPARSE_s_n (oForce, "force",
141
ARGPARSE_s_n (oForce, "force",
141
142
"force overwriting"),
142
143
ARGPARSE_s_n (oNoFailOnExist, "no-fail-on-exist", "@"),
143
ARGPARSE_s_s (oHomedir, "homedir", "@"),
144
ARGPARSE_s_s (oPrompt, "prompt",
145
"|ESCSTRING|use ESCSTRING as prompt in pinentry"),
144
ARGPARSE_s_s (oHomedir, "homedir", "@"),
145
ARGPARSE_s_s (oPrompt, "prompt",
146
"|ESCSTRING|use ESCSTRING as prompt in pinentry"),
146
147
ARGPARSE_s_n (oStatusMsg, "enable-status-msg", "@"),
148
149
ARGPARSE_s_s (oAgentProgram, "agent-program", "@"),
292
293
log_error ("can't open `%s': %s\n", fname, strerror (errno));
296
297
if (fstat (fileno(fp), &st))
298
299
log_error ("can't stat `%s': %s\n", fname, strerror (errno));
303
304
buflen = st.st_size;
304
305
buf = xmalloc (buflen+1);
305
306
if (fread (buf, buflen, 1, fp) != 1)
389
rc = agent_unprotect (key, (pw=get_passphrase (1)),
390
rc = agent_unprotect (key, (pw=get_passphrase (1)),
390
391
protected_at, &result, &resultlen);
391
392
release_passphrase (pw);
497
498
unsigned char *key;
501
502
key = read_key (fname);
505
506
keylen = gcry_sexp_canon_len (key, 0, NULL,NULL);
508
509
if (opt_canonical)
510
511
fwrite (key, keylen, 1, stdout);
824
825
/* Parameter names used with RSA. */
825
826
elems = "nedpqu";
826
827
array = xcalloc (strlen(elems) + 1, sizeof *array);
827
for (idx=0, s=elems; *s; s++, idx++ )
828
for (idx=0, s=elems; *s; s++, idx++ )
829
830
l2 = gcry_sexp_find_token (list, s, 1);
988
989
kparms[4] = sk.p;
989
990
kparms[5] = gcry_mpi_snew (0); /* compute d mod (p-1) */
990
991
gcry_mpi_sub_ui (kparms[5], kparms[3], 1);
991
gcry_mpi_mod (kparms[5], sk.d, kparms[5]);
992
gcry_mpi_mod (kparms[5], sk.d, kparms[5]);
992
993
kparms[6] = gcry_mpi_snew (0); /* compute d mod (q-1) */
993
994
gcry_mpi_sub_ui (kparms[6], kparms[4], 1);
994
gcry_mpi_mod (kparms[6], sk.d, kparms[6]);
995
gcry_mpi_mod (kparms[6], sk.d, kparms[6]);
995
996
kparms[7] = sk.u;
996
997
kparms[8] = NULL;
1023
1024
set_strusage (my_strusage);
1024
1025
gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN);
1025
log_set_prefix ("gpg-protect-tool", 1);
1026
log_set_prefix ("gpg-protect-tool", 1);
1027
1028
/* Make sure that our subsystems are ready. */
1237
1241
/* FWIW: Under Windows Vista the standard fopen in the msvcrt
1238
1242
fails if the "x" GNU extension is used. */
1239
fp = es_fopen (fname, "wbx");
1243
fp = es_fopen (fname, "wbx");
1244
1248
log_error ("can't create `%s': %s\n", fname, strerror (errno));