diff options
Diffstat (limited to 'g10/keyedit.c')
-rw-r--r-- | g10/keyedit.c | 76 |
1 files changed, 37 insertions, 39 deletions
diff --git a/g10/keyedit.c b/g10/keyedit.c index 56e1e82b9..c47fd0f85 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -115,7 +115,7 @@ find_pk_from_sknode (KBNODE pub_keyblock, KBNODE sec_node) KBNODE node = pub_keyblock; PKT_secret_key *sk; PKT_public_key *pk; - + if (sec_node->pkt->pkttype == PKT_SECRET_KEY && node->pkt->pkttype == PKT_PUBLIC_KEY) return node->pkt->pkt.public_key; @@ -129,7 +129,7 @@ find_pk_from_sknode (KBNODE pub_keyblock, KBNODE sec_node) if (pk->keyid[0] == sk->keyid[0] && pk->keyid[1] == sk->keyid[1]) return pk; } - + return NULL; } #endif /* ENABLE_CARD_SUPPORT */ @@ -528,7 +528,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified, } /* build a list of all signators. - * + * * We use the CERT flag to request the primary which must always * be one which is capable of signing keys. I can't see a reason * why to sign keys using a subkey. Implementation of USAGE_CERT @@ -705,7 +705,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified, { tty_printf(_("The self-signature on \"%s\"\n" "is a PGP 2.x-style signature.\n"),user); - + /* Note that the regular PGP2 warning below still applies if there are no v4 sigs on this key at all. */ @@ -1109,11 +1109,11 @@ change_passphrase( KBNODE keyblock ) sk = node->pkt->pkt.secret_key; for (any = 0, node=keyblock; node; node = node->next) { - if (node->pkt->pkttype == PKT_SECRET_KEY + if (node->pkt->pkttype == PKT_SECRET_KEY || node->pkt->pkttype == PKT_SECRET_SUBKEY) { PKT_secret_key *tmpsk = node->pkt->pkt.secret_key; if (!(tmpsk->is_protected - && (tmpsk->protect.s2k.mode == 1001 + && (tmpsk->protect.s2k.mode == 1001 || tmpsk->protect.s2k.mode == 1002))) { any = 1; break; @@ -1125,7 +1125,7 @@ change_passphrase( KBNODE keyblock ) "no passphrase to change.\n")); goto leave; } - + /* See how to handle this key. */ switch( is_secret_key_protected( sk ) ) { case -1: @@ -1157,7 +1157,7 @@ change_passphrase( KBNODE keyblock ) if( node->pkt->pkttype == PKT_SECRET_SUBKEY ) { PKT_secret_key *subsk = node->pkt->pkt.secret_key; if ( !(subsk->is_protected - && (subsk->protect.s2k.mode == 1001 + && (subsk->protect.s2k.mode == 1001 || subsk->protect.s2k.mode == 1002))) { set_next_passphrase( passphrase ); rc = check_secret_key( subsk, 0 ); @@ -1208,7 +1208,7 @@ change_passphrase( KBNODE keyblock ) if( node->pkt->pkttype == PKT_SECRET_SUBKEY ) { PKT_secret_key *subsk = node->pkt->pkt.secret_key; if ( !(subsk->is_protected - && (subsk->protect.s2k.mode == 1001 + && (subsk->protect.s2k.mode == 1001 || subsk->protect.s2k.mode == 1002))) { subsk->protect.algo = dek->algo; subsk->protect.s2k = *s2k; @@ -1345,7 +1345,7 @@ static struct int flags; const char *desc; } cmds[] = - { + { { "quit" , cmdQUIT , 0, N_("quit this menu") }, { "q" , cmdQUIT , 0, NULL }, { "save" , cmdSAVE , 0, N_("save and quit") }, @@ -1388,9 +1388,9 @@ static struct #ifdef ENABLE_CARD_SUPPORT { "addcardkey", cmdADDCARDKEY , KEYEDIT_NOT_SK|KEYEDIT_NEED_SK, N_("add a key to a smartcard") }, - { "keytocard", cmdKEYTOCARD , KEYEDIT_NEED_SK|KEYEDIT_ONLY_SK, + { "keytocard", cmdKEYTOCARD , KEYEDIT_NEED_SK|KEYEDIT_ONLY_SK, N_("move a key to a smartcard")}, - { "bkuptocard", cmdBKUPTOCARD , KEYEDIT_NEED_SK|KEYEDIT_ONLY_SK, + { "bkuptocard", cmdBKUPTOCARD , KEYEDIT_NEED_SK|KEYEDIT_ONLY_SK, N_("move a backup key to a smartcard")}, #endif /*ENABLE_CARD_SUPPORT*/ @@ -1554,7 +1554,7 @@ keyedit_menu( const char *username, STRLIST locusr, size_t an; fingerprint_from_pk (pk, afp, &an); - while (an < MAX_FINGERPRINT_LEN) + while (an < MAX_FINGERPRINT_LEN) afp[an++] = 0; rc = keydb_search_fpr (sec_kdbhd, afp); } @@ -1870,7 +1870,7 @@ keyedit_menu( const char *username, STRLIST locusr, case 1: for (node = sec_keyblock; node; node = node->next ) { - if (node->pkt->pkttype == PKT_SECRET_SUBKEY + if (node->pkt->pkttype == PKT_SECRET_SUBKEY && node->flag & NODFLG_SELKEY) break; } @@ -1922,15 +1922,15 @@ keyedit_menu( const char *username, STRLIST locusr, fname, strerror(errno)); break; } - + /* Parse and check that file. */ pkt = xmalloc (sizeof *pkt); init_packet (pkt); rc = parse_packet (a, pkt); iobuf_close (a); iobuf_ioctl (NULL, 2, 0, (char*)fname); /* (invalidate cache). */ - if (!rc - && pkt->pkttype != PKT_SECRET_KEY + if (!rc + && pkt->pkttype != PKT_SECRET_KEY && pkt->pkttype != PKT_SECRET_SUBKEY) rc = G10ERR_NO_SECKEY; if (rc) @@ -2309,7 +2309,7 @@ show_prefs (PKT_user_id *uid, PKT_signature *selfsig, int verbose) for(i=any=0; prefs[i].type; i++ ) { if( prefs[i].type == PREFTYPE_SYM ) { const char *s = cipher_algo_to_string (prefs[i].value); - + if (any) tty_printf (", "); any = 1; @@ -2320,7 +2320,7 @@ show_prefs (PKT_user_id *uid, PKT_signature *selfsig, int verbose) tty_printf ("[%d]", prefs[i].value); if (prefs[i].value == CIPHER_ALGO_3DES ) des_seen = 1; - } + } } if (!des_seen) { if (any) @@ -2332,7 +2332,7 @@ show_prefs (PKT_user_id *uid, PKT_signature *selfsig, int verbose) for(i=any=0; prefs[i].type; i++ ) { if( prefs[i].type == PREFTYPE_HASH ) { const char *s = digest_algo_to_string (prefs[i].value); - + if (any) tty_printf (", "); any = 1; @@ -2355,7 +2355,7 @@ show_prefs (PKT_user_id *uid, PKT_signature *selfsig, int verbose) for(i=any=0; prefs[i].type; i++ ) { if( prefs[i].type == PREFTYPE_ZIP ) { const char *s=compress_algo_to_string(prefs[i].value); - + if (any) tty_printf (", "); any = 1; @@ -2489,15 +2489,15 @@ show_key_with_all_names_colon (KBNODE keyblock) putchar(get_ownertrust_info (pk)); putchar(':'); putchar('\n'); - + print_fingerprint (pk, NULL, 0); print_revokers(pk); } } - + /* the user ids */ i = 0; - for (node = keyblock; node; node = node->next) + for (node = keyblock; node; node = node->next) { if ( node->pkt->pkttype == PKT_USER_ID ) { @@ -2541,7 +2541,7 @@ show_key_with_all_names_colon (KBNODE keyblock) if (pk_version>3 || uid->selfsigversion>3) { const prefitem_t *prefs = uid->prefs; - + for (j=0; prefs && prefs[j].type; j++) { if (j) @@ -2550,12 +2550,12 @@ show_key_with_all_names_colon (KBNODE keyblock) prefs[j].type == PREFTYPE_HASH ? 'H' : prefs[j].type == PREFTYPE_ZIP ? 'Z':'?', prefs[j].value); - } + } if (uid->flags.mdc) printf (",mdc"); if (!uid->flags.ks_modify) printf (",no-ks-modify"); - } + } putchar (':'); /* flags */ printf ("%d,", i); @@ -2644,7 +2644,6 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker, KBNODE node; int i; int do_warn = 0; - byte pk_version=0; PKT_public_key *primary=NULL; if (opt.with_colons) @@ -2676,7 +2675,6 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker, do_warn = 1; } - pk_version=pk->version; primary=pk; } @@ -2754,7 +2752,7 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker, tty_printf(_("trust: %s"), otrust); tty_printf("%*s",width,""); } - + tty_printf(_("validity: %s"), trust ); tty_printf("\n"); } @@ -2790,7 +2788,7 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker, if (sk->is_protected && sk->protect.s2k.mode == 1002) { tty_printf(" "); - tty_printf(_("card-no: ")); + tty_printf(_("card-no: ")); if (sk->protect.ivlen == 16 && !memcmp (sk->protect.iv, "\xD2\x76\x00\x01\x24\x01", 6)) { /* This is an OpenPGP card. */ @@ -2816,7 +2814,7 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker, if (do_warn) tty_printf (_("Please note that the shown key validity" " is not necessarily correct\n" - "unless you restart the program.\n")); + "unless you restart the program.\n")); } @@ -2836,7 +2834,7 @@ show_basic_key_info ( KBNODE keyblock ) if (node->pkt->pkttype == PKT_PUBLIC_KEY) { PKT_public_key *pk = node->pkt->pkt.public_key; - + /* Note, we use the same format string as in other show functions to make the translation job easier. */ tty_printf ("%s %4u%c/%s ", @@ -2875,7 +2873,7 @@ show_basic_key_info ( KBNODE keyblock ) { PKT_user_id *uid = node->pkt->pkt.user_id; ++i; - + tty_printf (" "); if (uid->is_revoked) tty_printf("[%s] ",_("revoked")); @@ -3823,7 +3821,7 @@ change_primary_uid_cb ( PKT_signature *sig, void *opaque ) delete_sig_subpkt (sig->unhashed, SIGSUBPKT_PRIMARY_UID); /* if opaque is set,we want to set the primary id */ - if (opaque) { + if (opaque) { buf[0] = 1; build_sig_subpkt (sig, SIGSUBPKT_PRIMARY_UID, buf, 1 ); } @@ -3956,7 +3954,7 @@ menu_set_primary_uid ( KBNODE pub_keyblock, KBNODE sec_keyblock ) } -/* +/* * Set preferences to new values for the selected user IDs */ static int @@ -4007,7 +4005,7 @@ menu_set_preferences (KBNODE pub_keyblock, KBNODE sec_keyblock ) xfree(user); } else { - /* This is a selfsignature which is to be replaced + /* This is a selfsignature which is to be replaced * We have to ignore v3 signatures because they are * not able to carry the preferences */ PKT_signature *newsig; @@ -4037,7 +4035,7 @@ menu_set_preferences (KBNODE pub_keyblock, KBNODE sec_keyblock ) } } } - + free_secret_key( sk ); return modified; } @@ -4684,7 +4682,7 @@ menu_revsig( KBNODE keyblock ) /* First check whether we have any signatures at all. */ any = 0; - for (node = keyblock; node; node = node->next ) + for (node = keyblock; node; node = node->next ) { node->flag &= ~(NODFLG_SELSIG | NODFLG_MARK_A); if (node->pkt->pkttype == PKT_USER_ID) { |