[svn] GnuPG - r5313 - trunk/g10
svn author wk
cvs at cvs.gnupg.org
Tue Apr 20 20:19:20 CEST 2010
Author: wk
Date: 2010-04-20 20:19:19 +0200 (Tue, 20 Apr 2010)
New Revision: 5313
Modified:
trunk/g10/keyedit.c
Log:
Reindented
[The diff below has been truncated]
Modified: trunk/g10/keyedit.c
===================================================================
--- trunk/g10/keyedit.c 2010-04-20 17:57:50 UTC (rev 5312)
+++ trunk/g10/keyedit.c 2010-04-20 18:19:19 UTC (rev 5313)
@@ -26,8 +26,8 @@
#include <assert.h>
#include <ctype.h>
#ifdef HAVE_LIBREADLINE
-#define GNUPG_LIBREADLINE_H_INCLUDED
-#include <readline/readline.h>
+# define GNUPG_LIBREADLINE_H_INCLUDED
+# include <readline/readline.h>
#endif
#include "gpg.h"
@@ -46,64 +46,67 @@
#include "i18n.h"
#include "keyserver-internal.h"
-static void show_prefs( PKT_user_id *uid, PKT_signature *selfsig, int verbose);
-static void show_names(KBNODE keyblock,PKT_public_key *pk,
- unsigned int flag,int with_prefs);
-static void show_key_with_all_names( KBNODE keyblock, int only_marked,
- int with_revoker, int with_fpr, int with_subkeys, int with_prefs );
-static void show_key_and_fingerprint( KBNODE keyblock );
-static int menu_adduid( KBNODE keyblock, KBNODE sec_keyblock,
- int photo, const char *photo_name );
-static void menu_deluid( KBNODE pub_keyblock, KBNODE sec_keyblock );
-static int menu_delsig( KBNODE pub_keyblock );
-static int menu_clean(KBNODE keyblock,int self_only);
-static void menu_delkey( KBNODE pub_keyblock, KBNODE sec_keyblock );
-static int menu_addrevoker( KBNODE pub_keyblock,
- KBNODE sec_keyblock, int sensitive );
-static int menu_expire( KBNODE pub_keyblock, KBNODE sec_keyblock );
-static int menu_backsign(KBNODE pub_keyblock,KBNODE sec_keyblock);
-static int menu_set_primary_uid( KBNODE pub_keyblock, KBNODE sec_keyblock );
-static int menu_set_preferences( KBNODE pub_keyblock, KBNODE sec_keyblock );
+static void show_prefs (PKT_user_id * uid, PKT_signature * selfsig,
+ int verbose);
+static void show_names (KBNODE keyblock, PKT_public_key * pk,
+ unsigned int flag, int with_prefs);
+static void show_key_with_all_names (KBNODE keyblock, int only_marked,
+ int with_revoker, int with_fpr,
+ int with_subkeys, int with_prefs);
+static void show_key_and_fingerprint (KBNODE keyblock);
+static int menu_adduid (KBNODE keyblock, KBNODE sec_keyblock,
+ int photo, const char *photo_name);
+static void menu_deluid (KBNODE pub_keyblock, KBNODE sec_keyblock);
+static int menu_delsig (KBNODE pub_keyblock);
+static int menu_clean (KBNODE keyblock, int self_only);
+static void menu_delkey (KBNODE pub_keyblock, KBNODE sec_keyblock);
+static int menu_addrevoker (KBNODE pub_keyblock,
+ KBNODE sec_keyblock, int sensitive);
+static int menu_expire (KBNODE pub_keyblock, KBNODE sec_keyblock);
+static int menu_backsign (KBNODE pub_keyblock, KBNODE sec_keyblock);
+static int menu_set_primary_uid (KBNODE pub_keyblock, KBNODE sec_keyblock);
+static int menu_set_preferences (KBNODE pub_keyblock, KBNODE sec_keyblock);
static int menu_set_keyserver_url (const char *url,
- KBNODE pub_keyblock, KBNODE sec_keyblock );
-static int menu_set_notation(const char *string,
- KBNODE pub_keyblock,KBNODE sec_keyblock);
-static int menu_select_uid( KBNODE keyblock, int idx );
-static int menu_select_uid_namehash( KBNODE keyblock, const char *namehash );
-static int menu_select_key( KBNODE keyblock, int idx );
-static int count_uids( KBNODE keyblock );
-static int count_uids_with_flag( KBNODE keyblock, unsigned flag );
-static int count_keys_with_flag( KBNODE keyblock, unsigned flag );
-static int count_selected_uids( KBNODE keyblock );
-static int real_uids_left( KBNODE keyblock );
-static int count_selected_keys( KBNODE keyblock );
-static int menu_revsig( KBNODE keyblock );
-static int menu_revuid( KBNODE keyblock, KBNODE sec_keyblock );
-static int menu_revkey( KBNODE pub_keyblock, KBNODE sec_keyblock );
-static int menu_revsubkey( KBNODE pub_keyblock, KBNODE sec_keyblock );
-static int enable_disable_key( KBNODE keyblock, int disable );
-static void menu_showphoto( KBNODE keyblock );
+ KBNODE pub_keyblock, KBNODE sec_keyblock);
+static int menu_set_notation (const char *string,
+ KBNODE pub_keyblock, KBNODE sec_keyblock);
+static int menu_select_uid (KBNODE keyblock, int idx);
+static int menu_select_uid_namehash (KBNODE keyblock, const char *namehash);
+static int menu_select_key (KBNODE keyblock, int idx);
+static int count_uids (KBNODE keyblock);
+static int count_uids_with_flag (KBNODE keyblock, unsigned flag);
+static int count_keys_with_flag (KBNODE keyblock, unsigned flag);
+static int count_selected_uids (KBNODE keyblock);
+static int real_uids_left (KBNODE keyblock);
+static int count_selected_keys (KBNODE keyblock);
+static int menu_revsig (KBNODE keyblock);
+static int menu_revuid (KBNODE keyblock, KBNODE sec_keyblock);
+static int menu_revkey (KBNODE pub_keyblock, KBNODE sec_keyblock);
+static int menu_revsubkey (KBNODE pub_keyblock, KBNODE sec_keyblock);
+static int enable_disable_key (KBNODE keyblock, int disable);
+static void menu_showphoto (KBNODE keyblock);
-static int update_trust=0;
+static int update_trust = 0;
#define CONTROL_D ('D' - 'A' + 1)
-#define NODFLG_BADSIG (1<<0) /* bad signature */
-#define NODFLG_NOKEY (1<<1) /* no public key */
-#define NODFLG_SIGERR (1<<2) /* other sig error */
+#define NODFLG_BADSIG (1<<0) /* Bad signature. */
+#define NODFLG_NOKEY (1<<1) /* No public key. */
+#define NODFLG_SIGERR (1<<2) /* Other sig error. */
-#define NODFLG_MARK_A (1<<4) /* temporary mark */
-#define NODFLG_DELSIG (1<<5) /* to be deleted */
+#define NODFLG_MARK_A (1<<4) /* Temporary mark. */
+#define NODFLG_DELSIG (1<<5) /* To be deleted. */
-#define NODFLG_SELUID (1<<8) /* indicate the selected userid */
-#define NODFLG_SELKEY (1<<9) /* indicate the selected key */
-#define NODFLG_SELSIG (1<<10) /* indicate a selected signature */
+#define NODFLG_SELUID (1<<8) /* Indicate the selected userid. */
+#define NODFLG_SELKEY (1<<9) /* Indicate the selected key. */
+#define NODFLG_SELSIG (1<<10) /* Indicate a selected signature. */
-struct sign_attrib {
- int non_exportable,non_revocable;
- struct revocation_reason_info *reason;
- byte trust_depth,trust_value;
- char *trust_regexp;
+struct sign_attrib
+{
+ int non_exportable, non_revocable;
+ struct revocation_reason_info *reason;
+ byte trust_depth, trust_value;
+ char *trust_regexp;
};
@@ -116,7 +119,7 @@
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;
@@ -126,11 +129,11 @@
for (; node; node = node->next)
if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY)
{
- pk = node->pkt->pkt.public_key;
- if (pk->keyid[0] == sk->keyid[0] && pk->keyid[1] == sk->keyid[1])
- return pk;
+ pk = node->pkt->pkt.public_key;
+ if (pk->keyid[0] == sk->keyid[0] && pk->keyid[1] == sk->keyid[1])
+ return pk;
}
-
+
return NULL;
}
#endif /* ENABLE_CARD_SUPPORT */
@@ -139,9 +142,9 @@
/* TODO: Fix duplicated code between here and the check-sigs/list-sigs
code in keylist.c. */
static int
-print_and_check_one_sig_colon( KBNODE keyblock, KBNODE node,
+print_and_check_one_sig_colon (KBNODE keyblock, KBNODE node,
int *inv_sigs, int *no_key, int *oth_err,
- int *is_selfsig, int print_without_key )
+ int *is_selfsig, int print_without_key)
{
PKT_signature *sig = node->pkt->pkt.signature;
int rc, sigrc;
@@ -149,1134 +152,1188 @@
/* TODO: Make sure a cached sig record here still has the pk that
issued it. See also keylist.c:list_keyblock_print */
- switch((rc=check_key_signature(keyblock,node,is_selfsig)))
+ switch ((rc = check_key_signature (keyblock, node, is_selfsig)))
{
case 0:
- node->flag &= ~(NODFLG_BADSIG|NODFLG_NOKEY|NODFLG_SIGERR);
+ node->flag &= ~(NODFLG_BADSIG | NODFLG_NOKEY | NODFLG_SIGERR);
sigrc = '!';
break;
case G10ERR_BAD_SIGN:
node->flag = NODFLG_BADSIG;
sigrc = '-';
- if( inv_sigs )
- ++*inv_sigs;
+ if (inv_sigs)
+ ++ * inv_sigs;
break;
case G10ERR_NO_PUBKEY:
case G10ERR_UNU_PUBKEY:
node->flag = NODFLG_NOKEY;
sigrc = '?';
- if( no_key )
- ++*no_key;
+ if (no_key)
+ ++ * no_key;
break;
default:
node->flag = NODFLG_SIGERR;
sigrc = '%';
- if( oth_err )
- ++*oth_err;
+ if (oth_err)
+ ++ * oth_err;
break;
}
- if( sigrc != '?' || print_without_key )
+ if (sigrc != '?' || print_without_key)
{
- printf("sig:%c::%d:%08lX%08lX:%lu:%lu:",
- sigrc,sig->pubkey_algo,(ulong)sig->keyid[0],(ulong)sig->keyid[1],
- (ulong)sig->timestamp,(ulong)sig->expiredate);
+ printf ("sig:%c::%d:%08lX%08lX:%lu:%lu:",
+ sigrc, sig->pubkey_algo, (ulong) sig->keyid[0],
+ (ulong) sig->keyid[1], (ulong) sig->timestamp,
+ (ulong) sig->expiredate);
- if(sig->trust_depth || sig->trust_value)
- printf("%d %d",sig->trust_depth,sig->trust_value);
+ if (sig->trust_depth || sig->trust_value)
+ printf ("%d %d", sig->trust_depth, sig->trust_value);
- printf(":");
+ printf (":");
- if(sig->trust_regexp)
- es_write_sanitized (es_stdout,
- sig->trust_regexp, strlen (sig->trust_regexp),
- ":", NULL);
+ if (sig->trust_regexp)
+ es_write_sanitized (es_stdout,
+ sig->trust_regexp, strlen (sig->trust_regexp),
+ ":", NULL);
- printf("::%02x%c\n",sig->sig_class,sig->flags.exportable?'x':'l');
+ printf ("::%02x%c\n", sig->sig_class,
+ sig->flags.exportable ? 'x' : 'l');
- if(opt.show_subpackets)
- print_subpackets_colon(sig);
+ if (opt.show_subpackets)
+ print_subpackets_colon (sig);
}
return (sigrc == '!');
}
-/****************
+/*
* Print information about a signature, check it and return true
* if the signature is okay. NODE must be a signature packet.
*/
static int
-print_and_check_one_sig( KBNODE keyblock, KBNODE node,
+print_and_check_one_sig (KBNODE keyblock, KBNODE node,
int *inv_sigs, int *no_key, int *oth_err,
- int *is_selfsig, int print_without_key )
+ int *is_selfsig, int print_without_key)
{
- PKT_signature *sig = node->pkt->pkt.signature;
- int rc, sigrc;
- int is_rev = sig->sig_class == 0x30;
+ PKT_signature *sig = node->pkt->pkt.signature;
+ int rc, sigrc;
+ int is_rev = sig->sig_class == 0x30;
- /* TODO: Make sure a cached sig record here still has the pk that
- issued it. See also keylist.c:list_keyblock_print */
+ /* TODO: Make sure a cached sig record here still has the pk that
+ issued it. See also keylist.c:list_keyblock_print */
- switch( (rc = check_key_signature( keyblock, node, is_selfsig)) ) {
- case 0:
- node->flag &= ~(NODFLG_BADSIG|NODFLG_NOKEY|NODFLG_SIGERR);
- sigrc = '!';
- break;
- case G10ERR_BAD_SIGN:
- node->flag = NODFLG_BADSIG;
- sigrc = '-';
- if( inv_sigs )
- ++*inv_sigs;
- break;
- case G10ERR_NO_PUBKEY:
- case G10ERR_UNU_PUBKEY:
- node->flag = NODFLG_NOKEY;
- sigrc = '?';
- if( no_key )
- ++*no_key;
- break;
- default:
- node->flag = NODFLG_SIGERR;
- sigrc = '%';
- if( oth_err )
- ++*oth_err;
- break;
+ switch ((rc = check_key_signature (keyblock, node, is_selfsig)))
+ {
+ case 0:
+ node->flag &= ~(NODFLG_BADSIG | NODFLG_NOKEY | NODFLG_SIGERR);
+ sigrc = '!';
+ break;
+ case G10ERR_BAD_SIGN:
+ node->flag = NODFLG_BADSIG;
+ sigrc = '-';
+ if (inv_sigs)
+ ++ * inv_sigs;
+ break;
+ case G10ERR_NO_PUBKEY:
+ case G10ERR_UNU_PUBKEY:
+ node->flag = NODFLG_NOKEY;
+ sigrc = '?';
+ if (no_key)
+ ++ * no_key;
+ break;
+ default:
+ node->flag = NODFLG_SIGERR;
+ sigrc = '%';
+ if (oth_err)
+ ++ * oth_err;
+ break;
}
- if( sigrc != '?' || print_without_key ) {
- tty_printf("%s%c%c %c%c%c%c%c%c %s %s",
- is_rev? "rev":"sig",sigrc,
- (sig->sig_class-0x10>0 &&
- sig->sig_class-0x10<4)?'0'+sig->sig_class-0x10:' ',
- sig->flags.exportable?' ':'L',
- sig->flags.revocable?' ':'R',
- sig->flags.policy_url?'P':' ',
- sig->flags.notation?'N':' ',
- sig->flags.expired?'X':' ',
- (sig->trust_depth>9)?'T':
- (sig->trust_depth>0)?'0'+sig->trust_depth:' ',
- keystr(sig->keyid),datestr_from_sig(sig));
- if(opt.list_options&LIST_SHOW_SIG_EXPIRE)
- tty_printf(" %s",expirestr_from_sig(sig));
- tty_printf(" ");
- if( sigrc == '%' )
- tty_printf("[%s] ", g10_errstr(rc) );
- else if( sigrc == '?' )
- ;
- else if( *is_selfsig ) {
- tty_printf( is_rev? _("[revocation]")
- : _("[self-signature]") );
+ if (sigrc != '?' || print_without_key)
+ {
+ tty_printf ("%s%c%c %c%c%c%c%c%c %s %s",
+ is_rev ? "rev" : "sig", sigrc,
+ (sig->sig_class - 0x10 > 0 &&
+ sig->sig_class - 0x10 <
+ 4) ? '0' + sig->sig_class - 0x10 : ' ',
+ sig->flags.exportable ? ' ' : 'L',
+ sig->flags.revocable ? ' ' : 'R',
+ sig->flags.policy_url ? 'P' : ' ',
+ sig->flags.notation ? 'N' : ' ',
+ sig->flags.expired ? 'X' : ' ',
+ (sig->trust_depth > 9) ? 'T' : (sig->trust_depth >
+ 0) ? '0' +
+ sig->trust_depth : ' ', keystr (sig->keyid),
+ datestr_from_sig (sig));
+ if (opt.list_options & LIST_SHOW_SIG_EXPIRE)
+ tty_printf (" %s", expirestr_from_sig (sig));
+ tty_printf (" ");
+ if (sigrc == '%')
+ tty_printf ("[%s] ", g10_errstr (rc));
+ else if (sigrc == '?')
+ ;
+ else if (*is_selfsig)
+ {
+ tty_printf (is_rev ? _("[revocation]") : _("[self-signature]"));
}
- else
- {
- size_t n;
- char *p = get_user_id( sig->keyid, &n );
- tty_print_utf8_string2(p, n, opt.screen_columns-keystrlen()-26-
- ((opt.list_options&LIST_SHOW_SIG_EXPIRE)?11:0));
- xfree(p);
- }
- tty_printf("\n");
+ else
+ {
+ size_t n;
+ char *p = get_user_id (sig->keyid, &n);
+ tty_print_utf8_string2 (p, n,
+ opt.screen_columns - keystrlen () - 26 -
+ ((opt.
+ list_options & LIST_SHOW_SIG_EXPIRE) ? 11
+ : 0));
+ xfree (p);
+ }
+ tty_printf ("\n");
- if(sig->flags.policy_url && (opt.list_options&LIST_SHOW_POLICY_URLS))
- show_policy_url(sig,3,0);
+ if (sig->flags.policy_url && (opt.list_options & LIST_SHOW_POLICY_URLS))
+ show_policy_url (sig, 3, 0);
- if(sig->flags.notation && (opt.list_options&LIST_SHOW_NOTATIONS))
- show_notation(sig,3,0,
- ((opt.list_options&LIST_SHOW_STD_NOTATIONS)?1:0)+
- ((opt.list_options&LIST_SHOW_USER_NOTATIONS)?2:0));
+ if (sig->flags.notation && (opt.list_options & LIST_SHOW_NOTATIONS))
+ show_notation (sig, 3, 0,
+ ((opt.
+ list_options & LIST_SHOW_STD_NOTATIONS) ? 1 : 0) +
+ ((opt.
+ list_options & LIST_SHOW_USER_NOTATIONS) ? 2 : 0));
- if(sig->flags.pref_ks && (opt.list_options&LIST_SHOW_KEYSERVER_URLS))
- show_keyserver_url(sig,3,0);
+ if (sig->flags.pref_ks && (opt.list_options & LIST_SHOW_KEYSERVER_URLS))
+ show_keyserver_url (sig, 3, 0);
}
- return (sigrc == '!');
+ return (sigrc == '!');
}
-/****************
+/*
* Check the keysigs and set the flags to indicate errors.
* Returns true if error found.
*/
static int
-check_all_keysigs( KBNODE keyblock, int only_selected )
+check_all_keysigs (KBNODE keyblock, int only_selected)
{
- KBNODE kbctx;
- KBNODE node;
- int inv_sigs = 0;
- int no_key = 0;
- int oth_err = 0;
- int has_selfsig = 0;
- int mis_selfsig = 0;
- int selected = !only_selected;
- int anyuid = 0;
+ KBNODE kbctx;
+ KBNODE node;
+ int inv_sigs = 0;
+ int no_key = 0;
+ int oth_err = 0;
+ int has_selfsig = 0;
+ int mis_selfsig = 0;
+ int selected = !only_selected;
+ int anyuid = 0;
- for( kbctx=NULL; (node=walk_kbnode( keyblock, &kbctx, 0)) ; ) {
- if( node->pkt->pkttype == PKT_USER_ID ) {
- PKT_user_id *uid = node->pkt->pkt.user_id;
+ for (kbctx = NULL; (node = walk_kbnode (keyblock, &kbctx, 0));)
+ {
+ if (node->pkt->pkttype == PKT_USER_ID)
+ {
+ PKT_user_id *uid = node->pkt->pkt.user_id;
- if( only_selected )
- selected = (node->flag & NODFLG_SELUID);
- if( selected ) {
- tty_printf("uid ");
- tty_print_utf8_string( uid->name, uid->len );
- tty_printf("\n");
- if( anyuid && !has_selfsig )
- mis_selfsig++;
- has_selfsig = 0;
- anyuid = 1;
+ if (only_selected)
+ selected = (node->flag & NODFLG_SELUID);
+ if (selected)
+ {
+ tty_printf ("uid ");
+ tty_print_utf8_string (uid->name, uid->len);
+ tty_printf ("\n");
+ if (anyuid && !has_selfsig)
+ mis_selfsig++;
+ has_selfsig = 0;
+ anyuid = 1;
}
}
- else if( selected && node->pkt->pkttype == PKT_SIGNATURE
- && ( (node->pkt->pkt.signature->sig_class&~3) == 0x10
- || node->pkt->pkt.signature->sig_class == 0x30 ) ) {
- int selfsig;
+ else if (selected && node->pkt->pkttype == PKT_SIGNATURE
+ && ((node->pkt->pkt.signature->sig_class & ~3) == 0x10
+ || node->pkt->pkt.signature->sig_class == 0x30))
+ {
+ int selfsig;
- if( print_and_check_one_sig( keyblock, node, &inv_sigs,
- &no_key, &oth_err, &selfsig, 0 ) ) {
- if( selfsig )
- has_selfsig = 1;
+ if (print_and_check_one_sig (keyblock, node, &inv_sigs,
+ &no_key, &oth_err, &selfsig, 0))
+ {
+ if (selfsig)
+ has_selfsig = 1;
}
- /* Hmmm: should we update the trustdb here? */
+ /* Hmmm: should we update the trustdb here? */
}
}
- if( !has_selfsig )
- mis_selfsig++;
- if( inv_sigs == 1 )
- tty_printf(_("1 bad signature\n") );
- else if( inv_sigs )
- tty_printf(_("%d bad signatures\n"), inv_sigs );
- if( no_key == 1 )
- tty_printf(_("1 signature not checked due to a missing key\n") );
- else if( no_key )
- tty_printf(_("%d signatures not checked due to missing keys\n"), no_key );
- if( oth_err == 1 )
- tty_printf(_("1 signature not checked due to an error\n") );
- else if( oth_err )
- tty_printf(_("%d signatures not checked due to errors\n"), oth_err );
- if( mis_selfsig == 1 )
- tty_printf(_("1 user ID without valid self-signature detected\n"));
- else if( mis_selfsig )
- tty_printf(_("%d user IDs without valid self-signatures detected\n"),
- mis_selfsig);
+ if (!has_selfsig)
+ mis_selfsig++;
+ if (inv_sigs == 1)
+ tty_printf (_("1 bad signature\n"));
+ else if (inv_sigs)
+ tty_printf (_("%d bad signatures\n"), inv_sigs);
+ if (no_key == 1)
+ tty_printf (_("1 signature not checked due to a missing key\n"));
+ else if (no_key)
+ tty_printf (_("%d signatures not checked due to missing keys\n"), no_key);
+ if (oth_err == 1)
+ tty_printf (_("1 signature not checked due to an error\n"));
+ else if (oth_err)
+ tty_printf (_("%d signatures not checked due to errors\n"), oth_err);
+ if (mis_selfsig == 1)
+ tty_printf (_("1 user ID without valid self-signature detected\n"));
+ else if (mis_selfsig)
+ tty_printf (_("%d user IDs without valid self-signatures detected\n"),
+ mis_selfsig);
- return inv_sigs || no_key || oth_err || mis_selfsig;
+ return inv_sigs || no_key || oth_err || mis_selfsig;
}
static int
-sign_mk_attrib( PKT_signature *sig, void *opaque )
+sign_mk_attrib (PKT_signature * sig, void *opaque)
{
- struct sign_attrib *attrib = opaque;
- byte buf[8];
+ struct sign_attrib *attrib = opaque;
+ byte buf[8];
- if( attrib->non_exportable ) {
- buf[0] = 0; /* not exportable */
- build_sig_subpkt( sig, SIGSUBPKT_EXPORTABLE, buf, 1 );
+ if (attrib->non_exportable)
+ {
+ buf[0] = 0; /* not exportable */
+ build_sig_subpkt (sig, SIGSUBPKT_EXPORTABLE, buf, 1);
}
- if( attrib->non_revocable ) {
- buf[0] = 0; /* not revocable */
- build_sig_subpkt( sig, SIGSUBPKT_REVOCABLE, buf, 1 );
+ if (attrib->non_revocable)
+ {
+ buf[0] = 0; /* not revocable */
+ build_sig_subpkt (sig, SIGSUBPKT_REVOCABLE, buf, 1);
}
- if( attrib->reason )
- revocation_reason_build_cb( sig, attrib->reason );
+ if (attrib->reason)
+ revocation_reason_build_cb (sig, attrib->reason);
- if(attrib->trust_depth)
- {
- /* Not critical. If someone doesn't understand trust sigs,
- this can still be a valid regular signature. */
- buf[0] = attrib->trust_depth;
- buf[1] = attrib->trust_value;
- build_sig_subpkt(sig,SIGSUBPKT_TRUST,buf,2);
+ if (attrib->trust_depth)
+ {
+ /* Not critical. If someone doesn't understand trust sigs,
+ this can still be a valid regular signature. */
+ buf[0] = attrib->trust_depth;
+ buf[1] = attrib->trust_value;
+ build_sig_subpkt (sig, SIGSUBPKT_TRUST, buf, 2);
- /* Critical. If someone doesn't understands regexps, this
- whole sig should be invalid. Note the +1 for the length -
- regexps are null terminated. */
- if(attrib->trust_regexp)
- build_sig_subpkt(sig,SIGSUBPKT_FLAG_CRITICAL|SIGSUBPKT_REGEXP,
- attrib->trust_regexp,
- strlen(attrib->trust_regexp)+1);
- }
+ /* Critical. If someone doesn't understands regexps, this
+ whole sig should be invalid. Note the +1 for the length -
+ regexps are null terminated. */
+ if (attrib->trust_regexp)
+ build_sig_subpkt (sig, SIGSUBPKT_FLAG_CRITICAL | SIGSUBPKT_REGEXP,
+ attrib->trust_regexp,
+ strlen (attrib->trust_regexp) + 1);
+ }
- return 0;
+ return 0;
}
+
static void
-trustsig_prompt(byte *trust_value,byte *trust_depth,char **regexp)
+trustsig_prompt (byte * trust_value, byte * trust_depth, char **regexp)
{
char *p;
- *trust_value=0;
- *trust_depth=0;
- *regexp=NULL;
+ *trust_value = 0;
+ *trust_depth = 0;
+ *regexp = NULL;
/* Same string as pkclist.c:do_edit_ownertrust */
- tty_printf(_("Please decide how far you trust this user to correctly verify"
+ tty_printf (_
+ ("Please decide how far you trust this user to correctly verify"
" other users' keys\n(by looking at passports, checking"
" fingerprints from different sources, etc.)\n"));
- tty_printf("\n");
+ tty_printf ("\n");
tty_printf (_(" %d = I trust marginally\n"), 1);
tty_printf (_(" %d = I trust fully\n"), 2);
- tty_printf("\n");
+ tty_printf ("\n");
- while(*trust_value==0)
+ while (*trust_value == 0)
{
- p = cpr_get("trustsig_prompt.trust_value",_("Your selection? "));
- trim_spaces(p);
- cpr_kill_prompt();
+ p = cpr_get ("trustsig_prompt.trust_value", _("Your selection? "));
+ trim_spaces (p);
+ cpr_kill_prompt ();
/* 60 and 120 are as per RFC2440 */
- if(p[0]=='1' && !p[1])
- *trust_value=60;
- else if(p[0]=='2' && !p[1])
- *trust_value=120;
- xfree(p);
+ if (p[0] == '1' && !p[1])
+ *trust_value = 60;
+ else if (p[0] == '2' && !p[1])
+ *trust_value = 120;
+ xfree (p);
}
- tty_printf("\n");
+ tty_printf ("\n");
- tty_printf(_(
- "Please enter the depth of this trust signature.\n"
- "A depth greater than 1 allows the key you are signing to make\n"
- "trust signatures on your behalf.\n"));
- tty_printf("\n");
+ tty_printf (_("Please enter the depth of this trust signature.\n"
+ "A depth greater than 1 allows the key you are signing to make\n"
+ "trust signatures on your behalf.\n"));
+ tty_printf ("\n");
- while(*trust_depth==0)
+ while (*trust_depth == 0)
{
- p = cpr_get("trustsig_prompt.trust_depth",_("Your selection? "));
- trim_spaces(p);
- cpr_kill_prompt();
- *trust_depth=atoi(p);
- xfree(p);
+ p = cpr_get ("trustsig_prompt.trust_depth", _("Your selection? "));
+ trim_spaces (p);
+ cpr_kill_prompt ();
+ *trust_depth = atoi (p);
+ xfree (p);
}
- tty_printf("\n");
+ tty_printf ("\n");
- tty_printf(_("Please enter a domain to restrict this signature, "
- "or enter for none.\n"));
+ tty_printf (_("Please enter a domain to restrict this signature, "
+ "or enter for none.\n"));
- tty_printf("\n");
+ tty_printf ("\n");
- p=cpr_get("trustsig_prompt.trust_regexp",_("Your selection? "));
- trim_spaces(p);
- cpr_kill_prompt();
+ p = cpr_get ("trustsig_prompt.trust_regexp", _("Your selection? "));
+ trim_spaces (p);
+ cpr_kill_prompt ();
- if(strlen(p)>0)
+ if (strlen (p) > 0)
{
- char *q=p;
- int regexplen=100,ind;
+ char *q = p;
+ int regexplen = 100, ind;
- *regexp=xmalloc(regexplen);
+ *regexp = xmalloc (regexplen);
/* Now mangle the domain the user entered into a regexp. To do
- this, \-escape everything that isn't alphanumeric, and attach
- "<[^>]+[@.]" to the front, and ">$" to the end. */
+ this, \-escape everything that isn't alphanumeric, and attach
+ "<[^>]+[@.]" to the front, and ">$" to the end. */
- strcpy(*regexp,"<[^>]+[@.]");
- ind=strlen(*regexp);
+ strcpy (*regexp, "<[^>]+[@.]");
+ ind = strlen (*regexp);
- while(*q)
+ while (*q)
{
- if(!((*q>='A' && *q<='Z')
- || (*q>='a' && *q<='z') || (*q>='0' && *q<='9')))
- (*regexp)[ind++]='\\';
+ if (!((*q >= 'A' && *q <= 'Z')
+ || (*q >= 'a' && *q <= 'z') || (*q >= '0' && *q <= '9')))
+ (*regexp)[ind++] = '\\';
- (*regexp)[ind++]=*q;
+ (*regexp)[ind++] = *q;
- if((regexplen-ind)<3)
+ if ((regexplen - ind) < 3)
{
- regexplen+=100;
- *regexp=xrealloc(*regexp,regexplen);
+ regexplen += 100;
+ *regexp = xrealloc (*regexp, regexplen);
}
q++;
}
- (*regexp)[ind]='\0';
- strcat(*regexp,">$");
+ (*regexp)[ind] = '\0';
+ strcat (*regexp, ">$");
}
- xfree(p);
- tty_printf("\n");
+ xfree (p);
+ tty_printf ("\n");
}
-/****************
+
+/*
* Loop over all locusr and and sign the uids after asking.
* If no user id is marked, all user ids will be signed;
* if some user_ids are marked those will be signed.
*/
static int
-sign_uids( KBNODE keyblock, strlist_t locusr, int *ret_modified,
- int local, int nonrevocable, int trust, int interactive )
+sign_uids (KBNODE keyblock, strlist_t locusr, int *ret_modified,
+ int local, int nonrevocable, int trust, int interactive)
{
- int rc = 0;
- SK_LIST sk_list = NULL;
- SK_LIST sk_rover = NULL;
- PKT_public_key *pk = NULL;
- KBNODE node, uidnode;
- PKT_public_key *primary_pk=NULL;
- int select_all = !count_selected_uids(keyblock) || interactive;
- int all_v3=1;
+ int rc = 0;
+ SK_LIST sk_list = NULL;
+ SK_LIST sk_rover = NULL;
+ PKT_public_key *pk = NULL;
+ KBNODE node, uidnode;
+ PKT_public_key *primary_pk = NULL;
+ int select_all = !count_selected_uids (keyblock) || interactive;
+ int all_v3 = 1;
- /* Are there any non-v3 sigs on this key already? */
- if(PGP2)
- for(node=keyblock;node;node=node->next)
- if(node->pkt->pkttype==PKT_SIGNATURE &&
- node->pkt->pkt.signature->version>3)
- {
- all_v3=0;
- break;
- }
+ /* Are there any non-v3 sigs on this key already? */
+ if (PGP2)
+ for (node = keyblock; node; node = node->next)
+ if (node->pkt->pkttype == PKT_SIGNATURE &&
+ node->pkt->pkt.signature->version > 3)
+ {
+ all_v3 = 0;
+ break;
+ }
- /* 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
- * is just a hack in getkey.c and does not mean that a subkey
- * marked as certification capable will be used. */
- rc=build_sk_list( locusr, &sk_list, 0, PUBKEY_USAGE_CERT);
- if( rc )
- goto leave;
+ /* 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
+ * is just a hack in getkey.c and does not mean that a subkey
+ * marked as certification capable will be used. */
+ rc = build_sk_list (locusr, &sk_list, 0, PUBKEY_USAGE_CERT);
+ if (rc)
+ goto leave;
- /* loop over all signators */
- for( sk_rover = sk_list; sk_rover; sk_rover = sk_rover->next ) {
- u32 sk_keyid[2],pk_keyid[2];
- char *p,*trust_regexp=NULL;
- int force_v4=0,class=0,selfsig=0;
- u32 duration=0,timestamp=0;
- byte trust_depth=0,trust_value=0;
+ /* Loop over all signators. */
+ for (sk_rover = sk_list; sk_rover; sk_rover = sk_rover->next)
+ {
+ u32 sk_keyid[2], pk_keyid[2];
+ char *p, *trust_regexp = NULL;
+ int force_v4 = 0, class = 0, selfsig = 0;
+ u32 duration = 0, timestamp = 0;
+ byte trust_depth = 0, trust_value = 0;
- if(local || nonrevocable || trust ||
- opt.cert_policy_url || opt.cert_notations)
- force_v4=1;
+ if (local || nonrevocable || trust ||
+ opt.cert_policy_url || opt.cert_notations)
+ force_v4 = 1;
- /* We have to use a copy of the pk, because make_keysig_packet
- * may remove the protection from sk and if we did other
- * changes to the secret key, we would save the unprotected
- * version. FIXME: This can be removed because all protection
- * is now done by gpg-agent. */
- if (pk)
- free_public_key (pk);
- pk = copy_public_key (NULL, sk_rover->pk);
- keyid_from_pk (pk, sk_keyid);
+ /* We have to use a copy of the pk, because make_keysig_packet
+ * may remove the protection from sk and if we did other
+ * changes to the secret key, we would save the unprotected
+ * version. FIXME: This can be removed because all protection
+ * is now done by gpg-agent. */
+ if (pk)
+ free_public_key (pk);
+ pk = copy_public_key (NULL, sk_rover->pk);
+ keyid_from_pk (pk, sk_keyid);
- /* set mark A for all selected user ids */
- for( node=keyblock; node; node = node->next ) {
- if( select_all || (node->flag & NODFLG_SELUID) )
- node->flag |= NODFLG_MARK_A;
- else
- node->flag &= ~NODFLG_MARK_A;
+ /* Set mark A for all selected user ids. */
+ for (node = keyblock; node; node = node->next)
+ {
+ if (select_all || (node->flag & NODFLG_SELUID))
+ node->flag |= NODFLG_MARK_A;
+ else
+ node->flag &= ~NODFLG_MARK_A;
}
- /* reset mark for uids which are already signed */
- uidnode = NULL;
- for( node=keyblock; node; node = node->next ) {
- if( node->pkt->pkttype == PKT_PUBLIC_KEY ) {
- primary_pk=node->pkt->pkt.public_key;
- keyid_from_pk( primary_pk, pk_keyid );
+ /* Reset mark for uids which are already signed. */
+ uidnode = NULL;
+ for (node = keyblock; node; node = node->next)
+ {
+ if (node->pkt->pkttype == PKT_PUBLIC_KEY)
+ {
+ primary_pk = node->pkt->pkt.public_key;
+ keyid_from_pk (primary_pk, pk_keyid);
- /* Is this a self-sig? */
- if(pk_keyid[0]==sk_keyid[0] && pk_keyid[1]==sk_keyid[1])
- {
- selfsig=1;
- /* Do not force a v4 sig here, otherwise it would
- be difficult to remake a v3 selfsig. If this
- is a v3->v4 promotion case, then we set
- force_v4 later anyway. */
- force_v4=0;
- }
+ /* Is this a self-sig? */
+ if (pk_keyid[0] == sk_keyid[0] && pk_keyid[1] == sk_keyid[1])
+ {
+ selfsig = 1;
+ /* Do not force a v4 sig here, otherwise it would
+ be difficult to remake a v3 selfsig. If this
+ is a v3->v4 promotion case, then we set
+ force_v4 later anyway. */
+ force_v4 = 0;
+ }
}
- else if( node->pkt->pkttype == PKT_USER_ID )
- {
- uidnode = (node->flag & NODFLG_MARK_A)? node : NULL;
- if(uidnode)
- {
- int yesreally=0;
- char *user=utf8_to_native(uidnode->pkt->pkt.user_id->name,
- uidnode->pkt->pkt.user_id->len,
- 0);
+ else if (node->pkt->pkttype == PKT_USER_ID)
+ {
+ uidnode = (node->flag & NODFLG_MARK_A) ? node : NULL;
+ if (uidnode)
+ {
+ int yesreally = 0;
+ char *user =
+ utf8_to_native (uidnode->pkt->pkt.user_id->name,
+ uidnode->pkt->pkt.user_id->len,
+ 0);
- if(uidnode->pkt->pkt.user_id->is_revoked)
- {
- tty_printf(_("User ID \"%s\" is revoked."),user);
+ if (uidnode->pkt->pkt.user_id->is_revoked)
+ {
+ tty_printf (_("User ID \"%s\" is revoked."), user);
- if(selfsig)
- tty_printf("\n");
- else if(opt.expert)
- {
- tty_printf("\n");
- /* No, so remove the mark and continue */
- if(!cpr_get_answer_is_yes("sign_uid.revoke_okay",
+ if (selfsig)
+ tty_printf ("\n");
+ else if (opt.expert)
+ {
+ tty_printf ("\n");
+ /* No, so remove the mark and continue */
+ if (!cpr_get_answer_is_yes ("sign_uid.revoke_okay",
_("Are you sure you "
"still want to sign "
"it? (y/N) ")))
- {
- uidnode->flag &= ~NODFLG_MARK_A;
- uidnode=NULL;
- }
- else if(interactive)
- yesreally=1;
- }
- else
- {
- uidnode->flag &= ~NODFLG_MARK_A;
- uidnode=NULL;
- tty_printf(_(" Unable to sign.\n"));
- }
- }
- else if(uidnode->pkt->pkt.user_id->is_expired)
- {
- tty_printf(_("User ID \"%s\" is expired."),user);
+ {
+ uidnode->flag &= ~NODFLG_MARK_A;
+ uidnode = NULL;
+ }
+ else if (interactive)
+ yesreally = 1;
+ }
+ else
+ {
+ uidnode->flag &= ~NODFLG_MARK_A;
+ uidnode = NULL;
+ tty_printf (_(" Unable to sign.\n"));
+ }
+ }
+ else if (uidnode->pkt->pkt.user_id->is_expired)
+ {
+ tty_printf (_("User ID \"%s\" is expired."), user);
- if(selfsig)
- tty_printf("\n");
- else if(opt.expert)
- {
- tty_printf("\n");
- /* No, so remove the mark and continue */
- if(!cpr_get_answer_is_yes("sign_uid.expire_okay",
+ if (selfsig)
+ tty_printf ("\n");
+ else if (opt.expert)
+ {
+ tty_printf ("\n");
+ /* No, so remove the mark and continue */
+ if (!cpr_get_answer_is_yes ("sign_uid.expire_okay",
_("Are you sure you "
"still want to sign "
"it? (y/N) ")))
- {
- uidnode->flag &= ~NODFLG_MARK_A;
- uidnode=NULL;
- }
- else if(interactive)
- yesreally=1;
- }
- else
- {
- uidnode->flag &= ~NODFLG_MARK_A;
- uidnode=NULL;
- tty_printf(_(" Unable to sign.\n"));
- }
- }
- else if(!uidnode->pkt->pkt.user_id->created && !selfsig)
- {
- tty_printf(_("User ID \"%s\" is not self-signed."),
- user);
+ {
+ uidnode->flag &= ~NODFLG_MARK_A;
+ uidnode = NULL;
+ }
+ else if (interactive)
+ yesreally = 1;
+ }
+ else
+ {
+ uidnode->flag &= ~NODFLG_MARK_A;
+ uidnode = NULL;
+ tty_printf (_(" Unable to sign.\n"));
+ }
+ }
+ else if (!uidnode->pkt->pkt.user_id->created && !selfsig)
+ {
+ tty_printf (_("User ID \"%s\" is not self-signed."),
+ user);
- if(opt.expert)
- {
- tty_printf("\n");
- /* No, so remove the mark and continue */
- if(!cpr_get_answer_is_yes("sign_uid.nosig_okay",
+ if (opt.expert)
+ {
+ tty_printf ("\n");
+ /* No, so remove the mark and continue */
+ if (!cpr_get_answer_is_yes ("sign_uid.nosig_okay",
_("Are you sure you "
"still want to sign "
"it? (y/N) ")))
- {
- uidnode->flag &= ~NODFLG_MARK_A;
- uidnode=NULL;
- }
- else if(interactive)
- yesreally=1;
- }
- else
- {
- uidnode->flag &= ~NODFLG_MARK_A;
- uidnode=NULL;
- tty_printf(_(" Unable to sign.\n"));
- }
- }
+ {
+ uidnode->flag &= ~NODFLG_MARK_A;
+ uidnode = NULL;
+ }
+ else if (interactive)
+ yesreally = 1;
+ }
+ else
+ {
+ uidnode->flag &= ~NODFLG_MARK_A;
+ uidnode = NULL;
+ tty_printf (_(" Unable to sign.\n"));
+ }
+ }
- if(uidnode && interactive && !yesreally)
- {
- tty_printf(_("User ID \"%s\" is signable. "),user);
- if(!cpr_get_answer_is_yes("sign_uid.sign_okay",
+ if (uidnode && interactive && !yesreally)
+ {
+ tty_printf (_("User ID \"%s\" is signable. "), user);
+ if (!cpr_get_answer_is_yes ("sign_uid.sign_okay",
_("Sign it? (y/N) ")))
- {
- uidnode->flag &= ~NODFLG_MARK_A;
- uidnode=NULL;
- }
- }
+ {
+ uidnode->flag &= ~NODFLG_MARK_A;
+ uidnode = NULL;
+ }
+ }
- xfree(user);
- }
- }
- else if( uidnode && node->pkt->pkttype == PKT_SIGNATURE
- && (node->pkt->pkt.signature->sig_class&~3) == 0x10 ) {
- if( sk_keyid[0] == node->pkt->pkt.signature->keyid[0]
- && sk_keyid[1] == node->pkt->pkt.signature->keyid[1] ) {
- char buf[50];
- char *user=utf8_to_native(uidnode->pkt->pkt.user_id->name,
- uidnode->pkt->pkt.user_id->len,
- 0);
+ xfree (user);
+ }
+ }
+ else if (uidnode && node->pkt->pkttype == PKT_SIGNATURE
+ && (node->pkt->pkt.signature->sig_class & ~3) == 0x10)
+ {
+ if (sk_keyid[0] == node->pkt->pkt.signature->keyid[0]
+ && sk_keyid[1] == node->pkt->pkt.signature->keyid[1])
+ {
+ char buf[50];
+ char *user =
+ utf8_to_native (uidnode->pkt->pkt.user_id->name,
+ uidnode->pkt->pkt.user_id->len,
+ 0);
- /* It's a v3 self-sig. Make it into a v4 self-sig? */
- if(node->pkt->pkt.signature->version<4 && selfsig)
- {
- 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. */
+ /* It's a v3 self-sig. Make it into a v4 self-sig? */
+ if (node->pkt->pkt.signature->version < 4 && selfsig)
+ {
+ tty_printf (_("The self-signature on \"%s\"\n"
+ "is a PGP 2.x-style signature.\n"), user);
- if(opt.expert)
- if(cpr_get_answer_is_yes("sign_uid.v4_promote_okay",
+ /* Note that the regular PGP2 warning below
+ still applies if there are no v4 sigs on
+ this key at all. */
+
+ if (opt.expert)
+ if (cpr_get_answer_is_yes ("sign_uid.v4_promote_okay",
_("Do you want to promote "
"it to an OpenPGP self-"
"signature? (y/N) ")))
- {
- force_v4=1;
- node->flag|=NODFLG_DELSIG;
- xfree(user);
- continue;
- }
- }
-
- /* Is the current signature expired? */
- if(node->pkt->pkt.signature->flags.expired)
- {
- tty_printf(_("Your current signature on \"%s\"\n"
- "has expired.\n"),user);
-
- if(cpr_get_answer_is_yes("sign_uid.replace_expired_okay",
- _("Do you want to issue a "
- "new signature to replace "
- "the expired one? (y/N) ")))
{
- /* Mark these for later deletion. We
- don't want to delete them here, just in
- case the replacement signature doesn't
- happen for some reason. We only delete
- these after the replacement is already
- in place. */
-
- node->flag|=NODFLG_DELSIG;
- xfree(user);
+ force_v4 = 1;
+ node->flag |= NODFLG_DELSIG;
+ xfree (user);
continue;
}
- }
+ }
- if(!node->pkt->pkt.signature->flags.exportable && !local)
- {
- /* It's a local sig, and we want to make a
- exportable sig. */
- tty_printf(_("Your current signature on \"%s\"\n"
- "is a local signature.\n"),user);
+ /* Is the current signature expired? */
+ if (node->pkt->pkt.signature->flags.expired)
+ {
+ tty_printf (_("Your current signature on \"%s\"\n"
+ "has expired.\n"), user);
- if(cpr_get_answer_is_yes("sign_uid.local_promote_okay",
- _("Do you want to promote "
- "it to a full exportable "
- "signature? (y/N) ")))
- {
- /* Mark these for later deletion. We
- don't want to delete them here, just in
- case the replacement signature doesn't
- happen for some reason. We only delete
- these after the replacement is already
- in place. */
+ if (cpr_get_answer_is_yes
+ ("sign_uid.replace_expired_okay",
+ _("Do you want to issue a "
+ "new signature to replace "
+ "the expired one? (y/N) ")))
+ {
+ /* Mark these for later deletion. We
+ don't want to delete them here, just in
+ case the replacement signature doesn't
+ happen for some reason. We only delete
+ these after the replacement is already
+ in place. */
- node->flag|=NODFLG_DELSIG;
- xfree(user);
- continue;
- }
- }
+ node->flag |= NODFLG_DELSIG;
+ xfree (user);
+ continue;
+ }
+ }
- /* Fixme: see whether there is a revocation in which
- * case we should allow to sign it again. */
- if (!node->pkt->pkt.signature->flags.exportable && local)
- tty_printf(_(
- "\"%s\" was already locally signed by key %s\n"),
- user,keystr_from_pk (pk));
- else
- tty_printf(_("\"%s\" was already signed by key %s\n"),
- user,keystr_from_pk (pk));
+ if (!node->pkt->pkt.signature->flags.exportable && !local)
+ {
+ /* It's a local sig, and we want to make a
+ exportable sig. */
+ tty_printf (_("Your current signature on \"%s\"\n"
+ "is a local signature.\n"), user);
- if(opt.expert
- && cpr_get_answer_is_yes("sign_uid.dupe_okay",
+ if (cpr_get_answer_is_yes
+ ("sign_uid.local_promote_okay",
+ _("Do you want to promote "
+ "it to a full exportable " "signature? (y/N) ")))
+ {
+ /* Mark these for later deletion. We
+ don't want to delete them here, just in
+ case the replacement signature doesn't
+ happen for some reason. We only delete
+ these after the replacement is already
+ in place. */
+
+ node->flag |= NODFLG_DELSIG;
+ xfree (user);
+ continue;
+ }
+ }
+
+ /* Fixme: see whether there is a revocation in which
+ * case we should allow to sign it again. */
+ if (!node->pkt->pkt.signature->flags.exportable && local)
+ tty_printf (_
+ ("\"%s\" was already locally signed by key %s\n"),
+ user, keystr_from_pk (pk));
+ else
+ tty_printf (_("\"%s\" was already signed by key %s\n"),
+ user, keystr_from_pk (pk));
+
+ if (opt.expert
+ && cpr_get_answer_is_yes ("sign_uid.dupe_okay",
_("Do you want to sign it "
"again anyway? (y/N) ")))
- {
- /* Don't delete the old sig here since this is
- an --expert thing. */
- xfree(user);
- continue;
- }
+ {
+ /* Don't delete the old sig here since this is
+ an --expert thing. */
+ xfree (user);
+ continue;
+ }
- snprintf (buf, sizeof buf, "%08lX%08lX",
- (ulong)pk->keyid[0], (ulong)pk->keyid[1]);
- write_status_text (STATUS_ALREADY_SIGNED, buf);
- uidnode->flag &= ~NODFLG_MARK_A; /* remove mark */
+ snprintf (buf, sizeof buf, "%08lX%08lX",
+ (ulong) pk->keyid[0], (ulong) pk->keyid[1]);
+ write_status_text (STATUS_ALREADY_SIGNED, buf);
+ uidnode->flag &= ~NODFLG_MARK_A; /* remove mark */
- xfree(user);
+ xfree (user);
}
}
}
- /* check whether any uids are left for signing */
- if( !count_uids_with_flag(keyblock, NODFLG_MARK_A) )
- {
- tty_printf (_("Nothing to sign with key %s\n"), keystr_from_pk (pk));
- continue;
- }
+ /* Check whether any uids are left for signing. */
+ if (!count_uids_with_flag (keyblock, NODFLG_MARK_A))
+ {
+ tty_printf (_("Nothing to sign with key %s\n"),
+ keystr_from_pk (pk));
+ continue;
+ }
- /* Ask whether we really should sign these user id(s) */
- tty_printf("\n");
- show_key_with_all_names( keyblock, 1, 0, 1, 0, 0 );
- tty_printf("\n");
+ /* Ask whether we really should sign these user id(s). */
+ tty_printf ("\n");
+ show_key_with_all_names (keyblock, 1, 0, 1, 0, 0);
+ tty_printf ("\n");
- if(primary_pk->expiredate && !selfsig)
- {
- u32 now=make_timestamp();
+ if (primary_pk->expiredate && !selfsig)
+ {
+ u32 now = make_timestamp ();
- if(primary_pk->expiredate<=now)
- {
- tty_printf(_("This key has expired!"));
+ if (primary_pk->expiredate <= now)
+ {
+ tty_printf (_("This key has expired!"));
- if(opt.expert)
- {
- tty_printf(" ");
- if(!cpr_get_answer_is_yes("sign_uid.expired_okay",
+ if (opt.expert)
+ {
+ tty_printf (" ");
+ if (!cpr_get_answer_is_yes ("sign_uid.expired_okay",
_("Are you sure you still "
"want to sign it? (y/N) ")))
- continue;
- }
- else
- {
- tty_printf(_(" Unable to sign.\n"));
continue;
- }
- }
- else
- {
- tty_printf(_("This key is due to expire on %s.\n"),
- expirestr_from_pk(primary_pk));
+ }
+ else
+ {
+ tty_printf (_(" Unable to sign.\n"));
+ continue;
+ }
+ }
+ else
+ {
+ tty_printf (_("This key is due to expire on %s.\n"),
+ expirestr_from_pk (primary_pk));
- if(opt.ask_cert_expire)
- {
- char *answer=cpr_get("sign_uid.expire",
- _("Do you want your signature to "
- "expire at the same time? (Y/n) "));
- if(answer_is_yes_no_default(answer,1))
- {
- /* This fixes the signature timestamp we're
- going to make as now. This is so the
- expiration date is exactly correct, and not
- a few seconds off (due to the time it takes
- to answer the questions, enter the
- passphrase, etc). */
- timestamp=now;
- duration=primary_pk->expiredate-now;
- force_v4=1;
- }
+ if (opt.ask_cert_expire)
+ {
+ char *answer = cpr_get ("sign_uid.expire",
+ _("Do you want your signature to "
+ "expire at the same time? (Y/n) "));
+ if (answer_is_yes_no_default (answer, 1))
+ {
+ /* This fixes the signature timestamp we're
+ going to make as now. This is so the
+ expiration date is exactly correct, and not
+ a few seconds off (due to the time it takes
+ to answer the questions, enter the
+ passphrase, etc). */
+ timestamp = now;
+ duration = primary_pk->expiredate - now;
+ force_v4 = 1;
+ }
- cpr_kill_prompt();
- xfree(answer);
- }
- }
- }
+ cpr_kill_prompt ();
+ xfree (answer);
+ }
+ }
+ }
- /* Only ask for duration if we haven't already set it to match
- the expiration of the pk */
- if(!duration && !selfsig)
- {
- if(opt.ask_cert_expire)
- duration=ask_expire_interval(1,opt.def_cert_expire);
- else
- duration=parse_expire_string(opt.def_cert_expire);
- }
+ /* Only ask for duration if we haven't already set it to match
+ the expiration of the pk */
+ if (!duration && !selfsig)
+ {
+ if (opt.ask_cert_expire)
+ duration = ask_expire_interval (1, opt.def_cert_expire);
+ else
+ duration = parse_expire_string (opt.def_cert_expire);
+ }
- if(duration)
- force_v4=1;
+ if (duration)
+ force_v4 = 1;
- /* Is --pgp2 on, it's a v3 key, all the sigs on the key are
- currently v3 and we're about to sign it with a v4 sig? If
- so, danger! */
- if(PGP2 && all_v3 &&
- (pk->version > 3 || force_v4) && primary_pk->version <= 3)
- {
- tty_printf(_("You may not make an OpenPGP signature on a "
- "PGP 2.x key while in --pgp2 mode.\n"));
- tty_printf(_("This would make the key unusable in PGP 2.x.\n"));
+ /* Is --pgp2 on, it's a v3 key, all the sigs on the key are
+ currently v3 and we're about to sign it with a v4 sig? If
+ so, danger! */
+ if (PGP2 && all_v3 &&
+ (pk->version > 3 || force_v4) && primary_pk->version <= 3)
More information about the Gnupg-commits
mailing list