aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--g10/ChangeLog18
-rw-r--r--g10/g10.c29
-rw-r--r--g10/getkey.c2
-rw-r--r--g10/gpgv.c2
-rw-r--r--g10/keylist.c2
-rw-r--r--g10/packet.h5
-rw-r--r--g10/trustdb.c19
-rw-r--r--g10/trustdb.h2
8 files changed, 55 insertions, 24 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index b368e5a5c..d9dc0703a 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,21 @@
+2003-05-09 David Shaw <[email protected]>
+
+ * g10.c (main): New --gnupg option to disable the various
+ --openpgp, --pgpX, etc. options. This is the same as --no-XXXX
+ for those options.
+
+ * packet.h, getkey.c (skip_disabled), keylist.c
+ (print_capabilities): New "pk_is_disabled" macro to retrieve the
+ cached disabled value if available, and fill it in via
+ cache_disabled_value if not available.
+
+ * trustdb.h, gpgv.c (is_disabled), trustdb.c (is_disabled): Rename
+ to cache_disabled_value. Cache the result of the check so we
+ don't need to hit the trustdb more than once.
+
+ * trustdb.c (get_validity): Cache the disabled value since we have
+ it handy and it might be useful later.
+
2003-05-07 David Shaw <[email protected]>
* revoke.c (ask_revocation_reason): Clear old reason if user
diff --git a/g10/g10.c b/g10/g10.c
index bafa03539..51c7a6b4f 100644
--- a/g10/g10.c
+++ b/g10/g10.c
@@ -162,16 +162,13 @@ enum cmd_and_opt_values { aNull = 0,
oMarginalsNeeded,
oMaxCertDepth,
oLoadExtension,
+ oGnuPG,
oRFC1991,
oOpenPGP,
oPGP2,
- oNoPGP2,
oPGP6,
- oNoPGP6,
oPGP7,
- oNoPGP7,
oPGP8,
- oNoPGP8,
oCipherAlgo,
oDigestAlgo,
oCertDigestAlgo,
@@ -439,16 +436,17 @@ static ARGPARSE_OPTS opts[] = {
{ oMaxCertDepth, "max-cert-depth", 1, "@" },
{ oTrustedKey, "trusted-key", 2, N_("|KEYID|ultimately trust this key")},
{ oLoadExtension, "load-extension" ,2, N_("|FILE|load extension module FILE")},
+ { oGnuPG, "gnupg", 0, "@"},
+ { oGnuPG, "no-pgp2", 0, "@"},
+ { oGnuPG, "no-pgp6", 0, "@"},
+ { oGnuPG, "no-pgp7", 0, "@"},
+ { oGnuPG, "no-pgp8", 0, "@"},
{ oRFC1991, "rfc1991", 0, N_("emulate the mode described in RFC1991")},
{ oOpenPGP, "openpgp", 0, N_("set all packet, cipher and digest options to OpenPGP behavior")},
{ oPGP2, "pgp2", 0, N_("set all packet, cipher and digest options to PGP 2.x behavior")},
- { oNoPGP2, "no-pgp2", 0, "@"},
{ oPGP6, "pgp6", 0, "@"},
- { oNoPGP6, "no-pgp6", 0, "@"},
{ oPGP7, "pgp7", 0, "@"},
- { oNoPGP7, "no-pgp7", 0, "@"},
{ oPGP8, "pgp8", 0, "@"},
- { oNoPGP8, "no-pgp8", 0, "@"},
{ oS2KMode, "s2k-mode", 1, N_("|N|use passphrase mode N")},
{ oS2KDigest, "s2k-digest-algo",2,
N_("|NAME|use message digest algorithm NAME for passphrases")},
@@ -1463,16 +1461,11 @@ main( int argc, char **argv )
opt.s2k_digest_algo = DIGEST_ALGO_SHA1;
opt.s2k_cipher_algo = CIPHER_ALGO_3DES;
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 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 oGnuPG: opt.compliance = CO_GNUPG; break;
case oEmuMDEncodeBug: opt.emulate_bugs |= EMUBUG_MDENCODE; break;
case oCompressSigs: opt.compress_sigs = 1; break;
case oRunAsShmCP:
diff --git a/g10/getkey.c b/g10/getkey.c
index 13bbda366..fe98d49a0 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -747,7 +747,7 @@ skip_disabled(void *dummy,u32 *keyid)
goto leave;
}
- disabled=is_disabled(pk);
+ disabled=pk_is_disabled(pk);
leave:
free_public_key(pk);
diff --git a/g10/gpgv.c b/g10/gpgv.c
index f0509ba3f..660f81f64 100644
--- a/g10/gpgv.c
+++ b/g10/gpgv.c
@@ -243,7 +243,7 @@ check_signatures_trust( PKT_signature *sig )
*/
int
-is_disabled(PKT_public_key *pk)
+cache_disabled_value(PKT_public_key *pk)
{
return 0;
}
diff --git a/g10/keylist.c b/g10/keylist.c
index 54296e7b8..fb0959024 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -325,7 +325,7 @@ print_capabilities (PKT_public_key *pk, PKT_secret_key *sk, KBNODE keyblock)
pk = k->pkt->pkt.public_key;
if(pk->is_primary)
- disabled=is_disabled(pk);
+ disabled=pk_is_disabled(pk);
if ( pk->is_valid && !pk->is_revoked && !pk->has_expired ) {
if ( pk->pubkey_usage & PUBKEY_USAGE_ENC )
diff --git a/g10/packet.h b/g10/packet.h
index a10ee811a..c75b301c5 100644
--- a/g10/packet.h
+++ b/g10/packet.h
@@ -205,6 +205,7 @@ typedef struct {
u32 main_keyid[2]; /* keyid of the primary key */
u32 keyid[2]; /* calculated by keyid_from_pk() */
byte is_primary;
+ byte is_disabled; /* 0 for unset, 1 for enabled, 2 for disabled. */
prefitem_t *prefs; /* list of preferences (may be NULL) */
int mdc_feature; /* mdc feature set */
PKT_user_id *user_id; /* if != NULL: found by that uid */
@@ -213,6 +214,10 @@ typedef struct {
MPI pkey[PUBKEY_MAX_NPKEY];
} PKT_public_key;
+/* Evaluates as true if the pk is disabled, and false if it isn't. If
+ there is no disable value cached, fill one in. */
+#define pk_is_disabled(a) (((a)->is_disabled)?((a)->is_disabled==2):(cache_disabled_value((a))))
+
typedef struct {
u32 timestamp; /* key made */
u32 expiredate; /* expires at this date or 0 if not at all */
diff --git a/g10/trustdb.c b/g10/trustdb.c
index 5edc10d5b..3b972e339 100644
--- a/g10/trustdb.c
+++ b/g10/trustdb.c
@@ -745,12 +745,15 @@ clear_validity (PKT_public_key *pk)
/* Return true if key is disabled */
int
-is_disabled(PKT_public_key *pk)
+cache_disabled_value(PKT_public_key *pk)
{
int rc;
TRUSTREC trec;
int disabled=0;
+ if(pk->is_disabled)
+ return (pk->is_disabled==2);
+
init_trustdb();
rc = read_trust_record (pk, &trec);
@@ -765,6 +768,13 @@ is_disabled(PKT_public_key *pk)
if(trec.r.trust.ownertrust & TRUST_FLAG_DISABLED)
disabled=1;
+ /* Cache it for later so we don't need to look at the trustdb every
+ time */
+ if(disabled)
+ pk->is_disabled=2;
+ else
+ pk->is_disabled=1;
+
leave:
return disabled;
}
@@ -875,7 +885,12 @@ get_validity (PKT_public_key *pk, PKT_user_id *uid)
}
if ( (trec.r.trust.ownertrust & TRUST_FLAG_DISABLED) )
- validity |= TRUST_FLAG_DISABLED;
+ {
+ validity |= TRUST_FLAG_DISABLED;
+ pk->is_disabled=2;
+ }
+ else
+ pk->is_disabled=1;
leave:
/* set some flags direct from the key */
diff --git a/g10/trustdb.h b/g10/trustdb.h
index 9f8dd9dea..0210e2aae 100644
--- a/g10/trustdb.h
+++ b/g10/trustdb.h
@@ -48,7 +48,7 @@ void sync_trustdb( void );
void revalidation_mark (void);
-int is_disabled(PKT_public_key *pk);
+int cache_disabled_value(PKT_public_key *pk);
unsigned int get_validity (PKT_public_key *pk, PKT_user_id *uid);
int get_validity_info (PKT_public_key *pk, PKT_user_id *uid);