401
450
tty_fprintf (fp, "Signature counter : %lu\n", info.sig_counter);
402
451
tty_fprintf (fp, "Signature key ....:");
403
452
print_sha1_fpr (fp, info.fpr1valid? info.fpr1:NULL);
453
if (info.fpr1valid && info.fpr1time)
454
tty_fprintf (fp, " created ....: %s\n",
455
isotimestamp (info.fpr1time));
404
456
tty_fprintf (fp, "Encryption key....:");
405
457
print_sha1_fpr (fp, info.fpr2valid? info.fpr2:NULL);
458
if (info.fpr2valid && info.fpr2time)
459
tty_fprintf (fp, " created ....: %s\n",
460
isotimestamp (info.fpr2time));
406
461
tty_fprintf (fp, "Authentication key:");
407
462
print_sha1_fpr (fp, info.fpr3valid? info.fpr3:NULL);
463
if (info.fpr3valid && info.fpr3time)
464
tty_fprintf (fp, " created ....: %s\n",
465
isotimestamp (info.fpr3time));
408
466
tty_fprintf (fp, "General key info..: ");
409
if (info.fpr1valid && !get_pubkey_byfprint (pk, info.fpr1, 20))
410
print_pubkey_info (fp, pk);
468
thefpr = (info.fpr1valid? info.fpr1 : info.fpr2valid? info.fpr2 :
469
info.fpr3valid? info.fpr3 : NULL);
470
if ( thefpr && !get_pubkey_byfprint (pk, thefpr, 20))
472
KBNODE keyblock = NULL;
474
print_pubkey_info (fp, pk);
476
if ( !get_seckeyblock_byfprint (&keyblock, thefpr, 20) )
477
print_card_key_info (fp, keyblock);
478
else if ( !get_keyblock_byfprint (&keyblock, thefpr, 20) )
480
release_kbnode (keyblock);
483
if (!auto_create_card_key_stub (info.serialno,
484
info.fpr1valid? info.fpr1:NULL,
485
info.fpr2valid? info.fpr2:NULL,
486
info.fpr3valid? info.fpr3:NULL))
488
if ( !get_seckeyblock_byfprint (&keyblock, thefpr, 20) )
489
print_card_key_info (fp, keyblock);
493
release_kbnode (keyblock);
412
496
tty_fprintf (fp, "[none]\n");
1134
1283
free_secret_key (copied_sk);
1135
1284
agent_release_card_info (&info);
1143
/* Menu to edit all user changeable values on an OpenPGP card. Only
1144
Key creation is not handled here. */
1146
card_edit (STRLIST commands)
1290
/* Data used by the command parser. This needs to be outside of the
1291
function scope to allow readline based command completion. */
1150
cmdQUIT, cmdADMIN, cmdHELP, cmdLIST, cmdDEBUG,
1295
cmdQUIT, cmdADMIN, cmdHELP, cmdLIST, cmdDEBUG, cmdVERIFY,
1151
1296
cmdNAME, cmdURL, cmdFETCH, cmdLOGIN, cmdLANG, cmdSEX, cmdCAFPR,
1152
cmdFORCESIG, cmdGENERATE, cmdPASSWD,
1297
cmdFORCESIG, cmdGENERATE, cmdPASSWD, cmdPRIVATEDO,
1162
{ N_("quit") , cmdQUIT , 0, N_("quit this menu") },
1163
{ N_("q") , cmdQUIT , 0, NULL },
1164
{ N_("admin") , cmdADMIN , 0, N_("show admin commands") },
1165
{ N_("help") , cmdHELP , 0, N_("show this help") },
1166
{ "?" , cmdHELP , 0, NULL },
1167
{ N_("list") , cmdLIST , 0, N_("list all available data") },
1168
{ N_("l") , cmdLIST , 0, NULL },
1169
{ N_("debug") , cmdDEBUG , 0, NULL },
1170
{ N_("name") , cmdNAME , 1, N_("change card holder's name") },
1171
{ N_("url") , cmdURL , 1, N_("change URL to retrieve key") },
1172
{ N_("fetch") , cmdFETCH , 0,
1173
N_("fetch the key specified in the card URL") },
1174
{ N_("login") , cmdLOGIN , 1, N_("change the login name") },
1175
{ N_("lang") , cmdLANG , 1, N_("change the language preferences") },
1176
{ N_("sex") , cmdSEX , 1, N_("change card holder's sex") },
1177
{ N_("cafpr"), cmdCAFPR, 1, N_("change a CA fingerprint") },
1179
cmdFORCESIG, 1, N_("toggle the signature force PIN flag") },
1181
cmdGENERATE, 1, N_("generate new keys") },
1182
{ N_("passwd"), cmdPASSWD, 0, N_("menu to change or unblock the PIN") },
1309
{ "quit" , cmdQUIT , 0, N_("quit this menu")},
1310
{ "q" , cmdQUIT , 0, NULL },
1311
{ "admin" , cmdADMIN , 0, N_("show admin commands")},
1312
{ "help" , cmdHELP , 0, N_("show this help")},
1313
{ "?" , cmdHELP , 0, NULL },
1314
{ "list" , cmdLIST , 0, N_("list all available data")},
1315
{ "l" , cmdLIST , 0, NULL },
1316
{ "debug" , cmdDEBUG , 0, NULL },
1317
{ "name" , cmdNAME , 1, N_("change card holder's name")},
1318
{ "url" , cmdURL , 1, N_("change URL to retrieve key")},
1319
{ "fetch" , cmdFETCH , 0, N_("fetch the key specified in the card URL")},
1320
{ "login" , cmdLOGIN , 1, N_("change the login name")},
1321
{ "lang" , cmdLANG , 1, N_("change the language preferences")},
1322
{ "sex" , cmdSEX , 1, N_("change card holder's sex")},
1323
{ "cafpr" , cmdCAFPR , 1, N_("change a CA fingerprint")},
1324
{ "forcesig", cmdFORCESIG, 1, N_("toggle the signature force PIN flag")},
1325
{ "generate", cmdGENERATE, 1, N_("generate new keys")},
1326
{ "passwd" , cmdPASSWD, 0, N_("menu to change or unblock the PIN")},
1327
{ "verify" , cmdVERIFY, 0, N_("verify the PIN and list all data")},
1328
/* Note, that we do not announce this command yet. */
1329
{ "privatedo", cmdPRIVATEDO, 0, NULL },
1183
1330
{ NULL, cmdINVCMD, 0, NULL }
1334
#if GNUPG_MAJOR_VERSION == 1 && defined (HAVE_LIBREADLINE)
1336
/* These two functions are used by readline for command completion. */
1339
command_generator(const char *text,int state)
1341
static int list_index,len;
1344
/* If this is a new word to complete, initialize now. This includes
1345
saving the length of TEXT for efficiency, and initializing the
1346
index variable to 0. */
1353
/* Return the next partial match */
1354
while((name=cmds[list_index].name))
1356
/* Only complete commands that have help text */
1357
if(cmds[list_index++].desc && strncmp(name,text,len)==0)
1358
return strdup(name);
1365
card_edit_completion(const char *text, int start, int end)
1367
/* If we are at the start of a line, we try and command-complete.
1368
If not, just do nothing for now. */
1371
return rl_completion_matches(text,command_generator);
1373
rl_attempted_completion_over=1;
1377
#endif /* GNUPG_MAJOR_VERSION == 1 && HAVE_LIBREADLINE */
1379
/* Menu to edit all user changeable values on an OpenPGP card. Only
1380
Key creation is not handled here. */
1382
card_edit (strlist_t commands)
1186
1384
enum cmdids cmd = cmdNOP;
1187
1385
int have_commands = !!commands;
1188
1386
int redisplay = 1;