1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-23 10:29:58 +01:00

* 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.
This commit is contained in:
David Shaw 2003-05-09 16:05:24 +00:00
parent 66f51ba19f
commit 6957239566
8 changed files with 55 additions and 24 deletions

View File

@ -1,3 +1,21 @@
2003-05-09 David Shaw <dshaw@jabberwocky.com>
* 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 <dshaw@jabberwocky.com>
* revoke.c (ask_revocation_reason): Clear old reason if user

View File

@ -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:

View File

@ -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);

View File

@ -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;
}

View File

@ -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 )

View File

@ -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 */

View File

@ -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 */

View File

@ -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);