1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-02-22 19:58:29 +01:00

* sign.c (sign_file): Fix bug that causes spurious compression preference

warning.

* sign.c (clearsign_file): Fix bug that prevents proper warning message
from appearing when clearsigning in --pgp2 mode with a non-v3 RSA key.

* main.h, misc.c (compliance_option_string, compliance_string,
compliance_failure), sign.c (sign_file, clearsign_file), encode.c
(encode_crypt, write_pubkey_enc_from_list): New functions to put the "this
message may not be usable...." warning in one place.

* options.h, g10.c (main): Part two of the simplification.  Use a single
enum to indicate what we are compliant to (1991, 2440, PGPx, etc.)
This commit is contained in:
David Shaw 2003-05-02 21:41:43 +00:00
parent 37ec8572e8
commit 5d283fdd8b
7 changed files with 180 additions and 143 deletions

View File

@ -1,11 +1,27 @@
2003-05-02 David Shaw <dshaw@jabberwocky.com>
* sign.c (sign_file): Fix bug that causes spurious compression
preference warning.
* sign.c (clearsign_file): Fix bug that prevents proper warning
message from appearing when clearsigning in --pgp2 mode with a
non-v3 RSA key.
* main.h, misc.c (compliance_option_string, compliance_string,
compliance_failure), sign.c (sign_file, clearsign_file), encode.c
(encode_crypt, write_pubkey_enc_from_list): New functions to put
the "this message may not be usable...." warning in one place.
* options.h, armor.c, cipher.c, g10.c, keyedit.c, pkclist.c,
sign.c, encode.c, getkey.c, revoke.c: The current flags for
different levels of PGP-ness are massively complex. This is step
one in simplifying them. No functional change yet, just use a
macro to check for compliance level.
* options.h, g10.c (main): Part two of the simplification. Use a
single enum to indicate what we are compliant to (1991, 2440,
PGPx, etc.)
2003-05-01 David Shaw <dshaw@jabberwocky.com>
* packet.h, build-packet.c (build_sig_subpkt), export.c

View File

@ -415,8 +415,7 @@ encode_crypt( const char *filename, STRLIST remusr )
{
log_info(_("you can only encrypt to RSA keys of 2048 bits or "
"less in --pgp2 mode\n"));
log_info(_("this message may not be usable by %s\n"),"PGP 2.x");
opt.xpgp2=0;
compliance_failure();
break;
}
}
@ -467,8 +466,7 @@ encode_crypt( const char *filename, STRLIST remusr )
if( PGP2 ) {
log_info(_("unable to use the IDEA cipher for all of the keys "
"you are encrypting to.\n"));
log_info(_("this message may not be usable by %s\n"),"PGP 2.x");
opt.xpgp2=0;
compliance_failure();
}
}
}
@ -719,13 +717,8 @@ write_pubkey_enc_from_list( PK_LIST pk_list, DEK *dek, IOBUF out )
if(opt.throw_keyid && (PGP2 || PGP6 || PGP7 || PGP8))
{
log_info(_("you may not use %s while in %s mode\n"),
"--throw-keyid",
PGP2?"--pgp2":PGP6?"--pgp6":PGP7?"--pgp7":"--pgp8");
log_info(_("this message may not be usable by %s\n"),
PGP2?"PGP 2.x":PGP6?"PGP 6.x":PGP7?"PGP 7.x":"PGP 8.x");
opt.xpgp2=opt.xpgp6=opt.xpgp7=opt.xpgp8=0;
"--throw-keyid",compliance_option_string());
compliance_failure();
}
/* Okay, what's going on: We have the session key somewhere in

View File

@ -1437,8 +1437,7 @@ main( int argc, char **argv )
#endif /* __riscos__ */
break;
case oRFC1991:
opt.xrfc1991 = 1;
opt.xrfc2440 = 0;
opt.compliance = CO_RFC1991;
opt.force_v4_certs = 0;
opt.disable_mdc = 1;
opt.escape_from = 1;
@ -1446,8 +1445,7 @@ main( int argc, char **argv )
case oOpenPGP:
/* TODO: When 2440bis becomes a RFC, these may need
changing. */
opt.xrfc1991 = 0;
opt.xrfc2440 = 1;
opt.compliance = CO_RFC2440;
opt.disable_mdc = 1;
opt.allow_non_selfsigned_uid = 1;
opt.allow_freeform_uid = 1;
@ -1464,19 +1462,17 @@ main( int argc, char **argv )
opt.s2k_mode = 3; /* iterated+salted */
opt.s2k_digest_algo = DIGEST_ALGO_SHA1;
opt.s2k_cipher_algo = CIPHER_ALGO_3DES;
opt.xpgp2 = 0;
opt.xpgp6 = 0;
opt.xpgp7 = 0;
opt.xpgp8 = 0;
break;
case oPGP2: opt.xpgp2 = 1; break;
case oNoPGP2: opt.xpgp2 = 0; break;
case oPGP6: opt.xpgp6 = 1; break;
case oNoPGP6: opt.xpgp6 = 0; break;
case oPGP7: opt.xpgp7 = 1; break;
case oNoPGP7: opt.xpgp7 = 0; break;
case oPGP8: opt.xpgp8 = 1; break;
case oNoPGP8: opt.xpgp8 = 0; break;
case oPGP2: opt.compliance = CO_PGP2; break;
case oPGP6: opt.compliance = CO_PGP6; break;
case oPGP7: opt.compliance = CO_PGP7; break;
case oPGP8: opt.compliance = CO_PGP8; break;
case oNoPGP2:
case oNoPGP6:
case oNoPGP7:
case oNoPGP8:
opt.compliance = CO_GNUPG;
break;
case oEmuMDEncodeBug: opt.emulate_bugs |= EMUBUG_MDENCODE; break;
case oCompressSigs: opt.compress_sigs = 1; break;
case oRunAsShmCP:
@ -1770,11 +1766,6 @@ main( int argc, char **argv )
set_debug();
/* Do these after the switch(), so they can override settings. */
if(PGP2 && (PGP6 || PGP7 || PGP8))
log_error(_("%s not allowed with %s!\n"),
"--pgp2",PGP6?"--pgp6":PGP7?"--pgp7":"--pgp8");
else
{
if(PGP2)
{
int unusable=0;
@ -1830,15 +1821,9 @@ main( int argc, char **argv )
}
if(unusable)
{
log_info(_("this message may not be usable by %s\n"),
"PGP 2.x");
opt.xpgp2=0;
}
compliance_failure();
else
{
opt.xrfc1991 = 1;
opt.xrfc2440 = 0;
opt.force_mdc = 0;
opt.disable_mdc = 1;
opt.force_v4_certs = 0;
@ -1876,7 +1861,6 @@ main( int argc, char **argv )
opt.escape_from=1;
opt.def_compress_algo=1;
}
}
/* must do this after dropping setuid, because string_to...
* may try to load an module */

View File

@ -87,6 +87,8 @@ void deprecated_warning(const char *configname,unsigned int configlineno,
const char *option,const char *repl1,const char *repl2);
const char *compress_algo_to_string(int algo);
int check_compress_algo(int algo);
void compliance_failure(void);
const char *compliance_option_string(void);
/*-- helptext.c --*/
void display_online_help( const char *keyword );

View File

@ -546,3 +546,50 @@ check_compress_algo(int algo)
return G10ERR_COMPR_ALGO;
}
const char *
compliance_option_string(void)
{
switch(opt.compliance)
{
case CO_RFC2440:
return "--openpgp";
case CO_PGP2:
return "--pgp2";
case CO_PGP6:
return "--pgp6";
case CO_PGP7:
return "--pgp7";
case CO_PGP8:
return "--pgp8";
default:
return "???";
}
}
static const char *
compliance_string(void)
{
switch(opt.compliance)
{
case CO_RFC2440:
return "OpenPGP";
case CO_PGP2:
return "PGP 2.x";
case CO_PGP6:
return "PGP 6.x";
case CO_PGP7:
return "PGP 7.x";
case CO_PGP8:
return "PGP 8.x";
default:
return "???";
}
}
void
compliance_failure(void)
{
log_info(_("this message may not be usable by %s\n"),compliance_string());
opt.compliance=CO_GNUPG;
}

View File

@ -90,13 +90,10 @@ struct {
int compress_keys;
int compress_sigs;
int always_trust;
/* TODO: change these to an emulate_pgp variable */
int xpgp2;
int xpgp6;
int xpgp7;
int xpgp8;
int xrfc1991;
int xrfc2440;
enum
{
CO_GNUPG=0, CO_RFC2440, CO_RFC1991, CO_PGP2, CO_PGP6, CO_PGP7, CO_PGP8
} compliance;
int pgp2_workarounds;
unsigned int emulate_bugs; /* bug emulation flags EMUBUG_xxxx */
int shm_coprocess;
@ -207,11 +204,11 @@ struct {
#define DBG_HASHING (opt.debug & DBG_HASHING_VALUE)
#define DBG_EXTPROG (opt.debug & DBG_EXTPROG_VALUE)
#define RFC1991 (opt.xrfc1991)
#define RFC2440 (opt.xrfc2440)
#define PGP2 (opt.xpgp2)
#define PGP6 (opt.xpgp6)
#define PGP7 (opt.xpgp7)
#define PGP8 (opt.xpgp8)
#define RFC1991 (opt.compliance==CO_RFC1991 || opt.compliance==CO_PGP2)
#define RFC2440 (opt.compliance==CO_RFC2440)
#define PGP2 (opt.compliance==CO_PGP2)
#define PGP6 (opt.compliance==CO_PGP6)
#define PGP7 (opt.compliance==CO_PGP7)
#define PGP8 (opt.compliance==CO_PGP8)
#endif /*G10_OPTIONS_H*/

View File

@ -647,8 +647,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
{
log_info(_("you can only detach-sign with PGP 2.x style keys "
"while in --pgp2 mode\n"));
log_info(_("this message may not be usable by %s\n"),"PGP 2.x");
opt.xpgp2=0;
compliance_failure();
}
if(encryptflag && (rc=build_pk_list( remusr, &pk_list, PUBKEY_USAGE_ENC )))
@ -764,8 +763,8 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
select_algo_from_prefs(pk_list,PREFTYPE_ZIP,-1,NULL))==-1)
compr_algo=DEFAULT_COMPRESS_ALGO;
}
else if(!opt.expert &&
select_algo_from_prefs(pk_list,PREFTYPE_ZIP,
else if(!opt.expert && pk_list
&& select_algo_from_prefs(pk_list,PREFTYPE_ZIP,
compr_algo,NULL)!=compr_algo)
log_info(_("forcing compression algorithm %s (%d) "
"violates recipient preferences\n"),
@ -890,12 +889,11 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile )
if( !old_style && !duration )
old_style = only_old_style( sk_list );
if(!old_style && PGP2)
if(PGP2 && !only_old_style(sk_list))
{
log_info(_("you can only clearsign with PGP 2.x style keys "
"while in --pgp2 mode\n"));
log_info(_("this message may not be usable by %s\n"),"PGP 2.x");
opt.xpgp2=0;
compliance_failure();
}
/* prepare iobufs */