aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--g10/ChangeLog17
-rw-r--r--g10/cipher.c4
-rw-r--r--g10/g10.c1
-rw-r--r--g10/keygen.c59
-rw-r--r--g10/options.h1
5 files changed, 65 insertions, 17 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 8289b8694..fd7497835 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,5 +1,22 @@
2002-05-29 David Shaw <[email protected]>
+ * keygen.c (keygen_set_std_prefs, add_feature_mdc): Use "mdc" and
+ "no-mdc" in the prefs string to allow switching on and off the MDC
+ feature. This is needed to properly export a key from GnuPG for
+ use on PGP which does not support MDC - without this, MDC-capable
+ implementations will still try and generate MDCs which will break
+ PGP.
+
+ * keygen.c (keygen_get_std_prefs): Show "[mdc]" in prefs string if
+ it is enabled.
+
+ * options.h, g10.c (main), cipher.c (write_header), keygen.c
+ (keygen_set_std_prefs): For consistency, allow the user to specify
+ mdc/no-mdc in the --personal-preference-list. If disabled, it
+ acts just like --disable-mdc.
+
+2002-05-29 David Shaw <[email protected]>
+
* options.h, exec.c: Add some debugging info, using the 1024 debug
flag.
diff --git a/g10/cipher.c b/g10/cipher.c
index 6f89e6bc3..1f73e2923 100644
--- a/g10/cipher.c
+++ b/g10/cipher.c
@@ -64,7 +64,7 @@ write_header( cipher_filter_context_t *cfx, IOBUF a )
if (opt.force_mdc)
use_mdc = 1;
- if( opt.rfc2440 || opt.rfc1991 || opt.disable_mdc )
+ if( opt.rfc2440 || opt.rfc1991 || opt.disable_mdc || !opt.personal_mdc )
use_mdc = 0; /* override - rfc2440 does not know about MDC */
memset( &ed, 0, sizeof ed );
@@ -165,5 +165,3 @@ cipher_filter( void *opaque, int control,
}
return rc;
}
-
-
diff --git a/g10/g10.c b/g10/g10.c
index 4551b512f..2fce0633a 100644
--- a/g10/g10.c
+++ b/g10/g10.c
@@ -850,6 +850,7 @@ main( int argc, char **argv )
opt.def_digest_algo = 0;
opt.cert_digest_algo = 0;
opt.def_compress_algo = -1;
+ opt.personal_mdc = 1; /* default - we like to use mdc if we can */
opt.s2k_mode = 3; /* iterated+salted */
opt.s2k_digest_algo = DIGEST_ALGO_SHA1;
opt.s2k_cipher_algo = CIPHER_ALGO_CAST5;
diff --git a/g10/keygen.c b/g10/keygen.c
index 65805263c..d8619f798 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -106,7 +106,7 @@ static byte hash_prefs[MAX_PREFS];
static int nhash_prefs;
static byte zip_prefs[MAX_PREFS];
static int nzip_prefs;
-
+static int mdc_available;
static void do_generate_keypair( struct para_data_s *para,
struct output_control_s *outctrl );
@@ -215,7 +215,7 @@ int
keygen_set_std_prefs (const char *string,int personal)
{
byte sym[MAX_PREFS], hash[MAX_PREFS], zip[MAX_PREFS];
- int nsym=0, nhash=0, nzip=0;
+ int nsym=0, nhash=0, nzip=0, mdc=1; /* mdc defaults on */
ulong val;
const char *s, *s2;
int rc = 0;
@@ -255,6 +255,14 @@ keygen_set_std_prefs (const char *string,int personal)
if (set_one_pref (val, 'Z', check_zip_algo, zip, &nzip))
rc = -1;
}
+ else if (ascii_strcasecmp(s,"mdc")==0) {
+ mdc=1;
+ s2=s+3;
+ }
+ else if (ascii_strcasecmp(s,"no-mdc")==0) {
+ mdc=0;
+ s2=s+6;
+ }
else if (isspace (*s))
s2 = s+1;
else {
@@ -289,11 +297,14 @@ keygen_set_std_prefs (const char *string,int personal)
opt.personal_prefs[n].type = PREFTYPE_NONE; /* end of list marker */
opt.personal_prefs[n].value = 0;
}
+
+ opt.personal_mdc = mdc;
}
else {
memcpy (sym_prefs, sym, (nsym_prefs=nsym));
memcpy (hash_prefs, hash, (nhash_prefs=nhash));
memcpy (zip_prefs, zip, (nzip_prefs=nzip));
+ mdc_available = mdc;
prefs_initialized = 1;
}
}
@@ -313,7 +324,7 @@ keygen_get_std_prefs ()
if (!prefs_initialized)
keygen_set_std_prefs (NULL,0);
- buf = m_alloc ( MAX_PREFS*3*5 + 1);
+ buf = m_alloc ( MAX_PREFS*3*5 + 5 + 1);
*buf = 0;
for (i=0; i < nsym_prefs; i++ )
sprintf (buf+strlen(buf), "S%d ", sym_prefs[i]);
@@ -321,23 +332,30 @@ keygen_get_std_prefs ()
sprintf (buf+strlen(buf), "H%d ", hash_prefs[i]);
for (i=0; i < nzip_prefs; i++ )
sprintf (buf+strlen(buf), "Z%d ", zip_prefs[i]);
-
- if (*buf) /* trim the trailing space */
- buf[strlen(buf)-1] = 0;
+
+ if(mdc_available)
+ sprintf(buf+strlen(buf),"[mdc]");
+ else if (*buf) /* trim the trailing space */
+ buf[strlen(buf)-1] = 0;
+
return buf;
}
static void
-add_feature_mdc (PKT_signature *sig)
+add_feature_mdc (PKT_signature *sig,int enabled)
{
const byte *s;
size_t n;
+ int i;
char *buf;
s = parse_sig_subpkt (sig->hashed, SIGSUBPKT_FEATURES, &n );
- if (s && n && (s[0] & 0x01))
- return; /* already set */
+ /* Already set or cleared */
+ if (s && n &&
+ ((enabled && (s[0] & 0x01)) || (!enabled && !(s[0] & 0x01))))
+ return;
+
if (!s || !n) { /* create a new one */
n = 1;
buf = m_alloc_clear (n);
@@ -346,12 +364,25 @@ add_feature_mdc (PKT_signature *sig)
buf = m_alloc (n);
memcpy (buf, s, n);
}
- buf[0] |= 0x01; /* MDC feature */
- build_sig_subpkt (sig, SIGSUBPKT_FEATURES, buf, n);
+
+ if(enabled)
+ buf[0] |= 0x01; /* MDC feature */
+ else
+ buf[0] &= ~0x01;
+
+ /* Are there any bits set? */
+ for(i=0;i<n;i++)
+ if(buf[i]!=0)
+ break;
+
+ if(i==n)
+ delete_sig_subpkt (sig->hashed, SIGSUBPKT_FEATURES);
+ else
+ build_sig_subpkt (sig, SIGSUBPKT_FEATURES, buf, n);
+
m_free (buf);
}
-
int
keygen_upd_std_prefs( PKT_signature *sig, void *opaque )
{
@@ -382,8 +413,8 @@ keygen_upd_std_prefs( PKT_signature *sig, void *opaque )
delete_sig_subpkt (sig->unhashed, SIGSUBPKT_PREF_COMPR);
}
- /* Make sure that the MDC feature flag is set */
- add_feature_mdc (sig);
+ /* Make sure that the MDC feature flag is set if needed */
+ add_feature_mdc (sig,mdc_available);
return 0;
}
diff --git a/g10/options.h b/g10/options.h
index e7df37fe2..fd9cecc32 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -127,6 +127,7 @@ struct {
int exec_disable;
char *def_preference_list;
prefitem_t *personal_prefs;
+ int personal_mdc;
int no_perm_warn;
char *temp_dir;
int no_encrypt_to;