diff --git a/g10/ChangeLog b/g10/ChangeLog index cb1ece74b..fd35c3a29 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,13 @@ +2003-07-24 David Shaw + + * options.h, g10.c (main, add_keyserver_url): Add + --sig-preferred-keyserver to implant a "where to get my key" + subpacket into a signature. + + * sign.c (mk_notation_and_policy): Rename to + mk_notation_policy_etc and add preferred keyserver support for + signatures. + 2003-07-21 David Shaw * keygen.c (do_add_key_flags): Don't set the certify flag for diff --git a/g10/g10.c b/g10/g10.c index c2dab50f1..8c4d36a22 100644 --- a/g10/g10.c +++ b/g10/g10.c @@ -220,6 +220,7 @@ enum cmd_and_opt_values { aNull = 0, oCertPolicyURL, oShowPolicyURL, oNoShowPolicyURL, + oSigKeyserverURL, oUseEmbeddedFilename, oComment, oDefaultComment, @@ -555,6 +556,7 @@ static ARGPARSE_OPTS opts[] = { { oCertPolicyURL, "cert-policy-url", 2, "@" }, { oShowPolicyURL, "show-policy-url", 0, "@" }, { oNoShowPolicyURL, "no-show-policy-url", 0, "@" }, + { oSigKeyserverURL, "sig-preferred-keyserver", 2, "@" }, { oShowNotation, "show-notation", 0, "@" }, { oNoShowNotation, "no-show-notation", 0, "@" }, { oComment, "comment", 2, "@" }, @@ -641,6 +643,7 @@ static void set_cmd( enum cmd_and_opt_values *ret_cmd, static void print_mds( const char *fname, int algo ); static void add_notation_data( const char *string, int which ); static void add_policy_url( const char *string, int which ); +static void add_keyserver_url( const char *string, int which ); #ifdef __riscos__ RISCOS_GLOBAL_STATICS("GnuPG Heap") @@ -1602,6 +1605,7 @@ main( int argc, char **argv ) opt.list_options&=~LIST_SHOW_POLICY; opt.verify_options&=~VERIFY_SHOW_POLICY; break; + case oSigKeyserverURL: add_keyserver_url(pargs.r.ret_str,0); break; case oUseEmbeddedFilename: opt.use_embedded_filename = 1; break; case oComment: opt.comment_string = pargs.r.ret_str; break; case oDefaultComment: opt.comment_string = NULL; break; @@ -1757,9 +1761,9 @@ main( int argc, char **argv ) {"show-photos",LIST_SHOW_PHOTOS}, {"show-policy-url",LIST_SHOW_POLICY}, {"show-notation",LIST_SHOW_NOTATION}, + {"show-keyring",LIST_SHOW_KEYRING}, {"show-validity",LIST_SHOW_VALIDITY}, {"show-long-keyid",LIST_SHOW_LONG_KEYID}, - {"show-keyring",LIST_SHOW_KEYRING}, {NULL,0} }; @@ -3111,7 +3115,6 @@ add_notation_data( const char *string, int which ) sl->flags |= 1; } - static void add_policy_url( const char *string, int which ) { @@ -3144,3 +3147,37 @@ add_policy_url( const char *string, int which ) if(critical) sl->flags |= 1; } + +static void +add_keyserver_url( const char *string, int which ) +{ + int i,critical=0; + STRLIST sl; + + if(*string=='!') + { + string++; + critical=1; + } + + for(i=0;iflags |= 1; +} diff --git a/g10/options.h b/g10/options.h index b45525c95..d9ea86571 100644 --- a/g10/options.h +++ b/g10/options.h @@ -153,6 +153,7 @@ struct { STRLIST cert_notation_data; STRLIST sig_policy_url; STRLIST cert_policy_url; + STRLIST sig_keyserver_url; int use_embedded_filename; int allow_non_selfsigned_uid; int allow_freeform_uid; diff --git a/g10/sign.c b/g10/sign.c index 73286fcb3..c55035798 100644 --- a/g10/sign.c +++ b/g10/sign.c @@ -58,7 +58,7 @@ static int recipient_digest_algo=0; * NAME=VALUE format. */ static void -mk_notation_and_policy( PKT_signature *sig, +mk_notation_policy_etc( PKT_signature *sig, PKT_public_key *pk, PKT_secret_key *sk ) { const char *string; @@ -163,6 +163,34 @@ mk_notation_and_policy( PKT_signature *sig, if(opt.list_options&LIST_SHOW_POLICY) show_policy_url(sig,0,0); + + /* preferred keyserver URL */ + if( IS_SIG(sig) && opt.sig_keyserver_url ) + { + if(sig->version<4) + log_info("can't put a preferred keyserver URL into v3 signatures\n"); + else + pu=opt.sig_keyserver_url; + } + + for(;pu;pu=pu->next) + { + string = pu->d; + + s=pct_expando(string,&args); + if(!s) + { + log_error(_("WARNING: unable to %%-expand preferred keyserver url " + "(too large). Using unexpanded.\n")); + s=m_strdup(string); + } + + build_sig_subpkt(sig,SIGSUBPKT_PREF_KS| + ((pu->flags & 1)?SIGSUBPKT_FLAG_CRITICAL:0), + s,strlen(s)); + + m_free(s); + } } @@ -564,7 +592,8 @@ write_signature_packets (SK_LIST sk_list, IOBUF out, MD_HANDLE hash, sig = m_alloc_clear (sizeof *sig); if(opt.force_v3_sigs || RFC1991) sig->version=3; - else if(duration || opt.sig_policy_url || opt.sig_notation_data) + else if(duration || opt.sig_policy_url + || opt.sig_notation_data || opt.sig_keyserver_url) sig->version=4; else sig->version=sk->version; @@ -583,7 +612,7 @@ write_signature_packets (SK_LIST sk_list, IOBUF out, MD_HANDLE hash, if (sig->version >= 4) build_sig_subpkt_from_sig (sig); - mk_notation_and_policy (sig, NULL, sk); + mk_notation_policy_etc (sig, NULL, sk); hash_sigversion_to_magic (md, sig); md_final (md); @@ -1251,7 +1280,7 @@ make_keysig_packet( PKT_signature **ret_sig, PKT_public_key *pk, sig->sig_class = sigclass; if( sig->version >= 4 ) build_sig_subpkt_from_sig( sig ); - mk_notation_and_policy( sig, pk, sk ); + mk_notation_policy_etc( sig, pk, sk ); /* Crucial that the call to mksubpkt comes LAST before the calls to finalize the sig as that makes it possible for the mksubpkt