mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-28 22:49:59 +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:
parent
66f51ba19f
commit
6957239566
@ -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>
|
2003-05-07 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* revoke.c (ask_revocation_reason): Clear old reason if user
|
* revoke.c (ask_revocation_reason): Clear old reason if user
|
||||||
|
29
g10/g10.c
29
g10/g10.c
@ -162,16 +162,13 @@ enum cmd_and_opt_values { aNull = 0,
|
|||||||
oMarginalsNeeded,
|
oMarginalsNeeded,
|
||||||
oMaxCertDepth,
|
oMaxCertDepth,
|
||||||
oLoadExtension,
|
oLoadExtension,
|
||||||
|
oGnuPG,
|
||||||
oRFC1991,
|
oRFC1991,
|
||||||
oOpenPGP,
|
oOpenPGP,
|
||||||
oPGP2,
|
oPGP2,
|
||||||
oNoPGP2,
|
|
||||||
oPGP6,
|
oPGP6,
|
||||||
oNoPGP6,
|
|
||||||
oPGP7,
|
oPGP7,
|
||||||
oNoPGP7,
|
|
||||||
oPGP8,
|
oPGP8,
|
||||||
oNoPGP8,
|
|
||||||
oCipherAlgo,
|
oCipherAlgo,
|
||||||
oDigestAlgo,
|
oDigestAlgo,
|
||||||
oCertDigestAlgo,
|
oCertDigestAlgo,
|
||||||
@ -439,16 +436,17 @@ static ARGPARSE_OPTS opts[] = {
|
|||||||
{ oMaxCertDepth, "max-cert-depth", 1, "@" },
|
{ oMaxCertDepth, "max-cert-depth", 1, "@" },
|
||||||
{ oTrustedKey, "trusted-key", 2, N_("|KEYID|ultimately trust this key")},
|
{ oTrustedKey, "trusted-key", 2, N_("|KEYID|ultimately trust this key")},
|
||||||
{ oLoadExtension, "load-extension" ,2, N_("|FILE|load extension module FILE")},
|
{ 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")},
|
{ oRFC1991, "rfc1991", 0, N_("emulate the mode described in RFC1991")},
|
||||||
{ oOpenPGP, "openpgp", 0, N_("set all packet, cipher and digest options to OpenPGP behavior")},
|
{ 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")},
|
{ oPGP2, "pgp2", 0, N_("set all packet, cipher and digest options to PGP 2.x behavior")},
|
||||||
{ oNoPGP2, "no-pgp2", 0, "@"},
|
|
||||||
{ oPGP6, "pgp6", 0, "@"},
|
{ oPGP6, "pgp6", 0, "@"},
|
||||||
{ oNoPGP6, "no-pgp6", 0, "@"},
|
|
||||||
{ oPGP7, "pgp7", 0, "@"},
|
{ oPGP7, "pgp7", 0, "@"},
|
||||||
{ oNoPGP7, "no-pgp7", 0, "@"},
|
|
||||||
{ oPGP8, "pgp8", 0, "@"},
|
{ oPGP8, "pgp8", 0, "@"},
|
||||||
{ oNoPGP8, "no-pgp8", 0, "@"},
|
|
||||||
{ oS2KMode, "s2k-mode", 1, N_("|N|use passphrase mode N")},
|
{ oS2KMode, "s2k-mode", 1, N_("|N|use passphrase mode N")},
|
||||||
{ oS2KDigest, "s2k-digest-algo",2,
|
{ oS2KDigest, "s2k-digest-algo",2,
|
||||||
N_("|NAME|use message digest algorithm NAME for passphrases")},
|
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_digest_algo = DIGEST_ALGO_SHA1;
|
||||||
opt.s2k_cipher_algo = CIPHER_ALGO_3DES;
|
opt.s2k_cipher_algo = CIPHER_ALGO_3DES;
|
||||||
break;
|
break;
|
||||||
case oPGP2: opt.compliance = CO_PGP2; break;
|
case oPGP2: opt.compliance = CO_PGP2; break;
|
||||||
case oPGP6: opt.compliance = CO_PGP6; break;
|
case oPGP6: opt.compliance = CO_PGP6; break;
|
||||||
case oPGP7: opt.compliance = CO_PGP7; break;
|
case oPGP7: opt.compliance = CO_PGP7; break;
|
||||||
case oPGP8: opt.compliance = CO_PGP8; break;
|
case oPGP8: opt.compliance = CO_PGP8; break;
|
||||||
case oNoPGP2:
|
case oGnuPG: opt.compliance = CO_GNUPG; break;
|
||||||
case oNoPGP6:
|
|
||||||
case oNoPGP7:
|
|
||||||
case oNoPGP8:
|
|
||||||
opt.compliance = CO_GNUPG;
|
|
||||||
break;
|
|
||||||
case oEmuMDEncodeBug: opt.emulate_bugs |= EMUBUG_MDENCODE; break;
|
case oEmuMDEncodeBug: opt.emulate_bugs |= EMUBUG_MDENCODE; break;
|
||||||
case oCompressSigs: opt.compress_sigs = 1; break;
|
case oCompressSigs: opt.compress_sigs = 1; break;
|
||||||
case oRunAsShmCP:
|
case oRunAsShmCP:
|
||||||
|
@ -747,7 +747,7 @@ skip_disabled(void *dummy,u32 *keyid)
|
|||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
disabled=is_disabled(pk);
|
disabled=pk_is_disabled(pk);
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
free_public_key(pk);
|
free_public_key(pk);
|
||||||
|
@ -243,7 +243,7 @@ check_signatures_trust( PKT_signature *sig )
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
is_disabled(PKT_public_key *pk)
|
cache_disabled_value(PKT_public_key *pk)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,7 @@ print_capabilities (PKT_public_key *pk, PKT_secret_key *sk, KBNODE keyblock)
|
|||||||
pk = k->pkt->pkt.public_key;
|
pk = k->pkt->pkt.public_key;
|
||||||
|
|
||||||
if(pk->is_primary)
|
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->is_valid && !pk->is_revoked && !pk->has_expired ) {
|
||||||
if ( pk->pubkey_usage & PUBKEY_USAGE_ENC )
|
if ( pk->pubkey_usage & PUBKEY_USAGE_ENC )
|
||||||
|
@ -205,6 +205,7 @@ typedef struct {
|
|||||||
u32 main_keyid[2]; /* keyid of the primary key */
|
u32 main_keyid[2]; /* keyid of the primary key */
|
||||||
u32 keyid[2]; /* calculated by keyid_from_pk() */
|
u32 keyid[2]; /* calculated by keyid_from_pk() */
|
||||||
byte is_primary;
|
byte is_primary;
|
||||||
|
byte is_disabled; /* 0 for unset, 1 for enabled, 2 for disabled. */
|
||||||
prefitem_t *prefs; /* list of preferences (may be NULL) */
|
prefitem_t *prefs; /* list of preferences (may be NULL) */
|
||||||
int mdc_feature; /* mdc feature set */
|
int mdc_feature; /* mdc feature set */
|
||||||
PKT_user_id *user_id; /* if != NULL: found by that uid */
|
PKT_user_id *user_id; /* if != NULL: found by that uid */
|
||||||
@ -213,6 +214,10 @@ typedef struct {
|
|||||||
MPI pkey[PUBKEY_MAX_NPKEY];
|
MPI pkey[PUBKEY_MAX_NPKEY];
|
||||||
} PKT_public_key;
|
} 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 {
|
typedef struct {
|
||||||
u32 timestamp; /* key made */
|
u32 timestamp; /* key made */
|
||||||
u32 expiredate; /* expires at this date or 0 if not at all */
|
u32 expiredate; /* expires at this date or 0 if not at all */
|
||||||
|
@ -745,12 +745,15 @@ clear_validity (PKT_public_key *pk)
|
|||||||
|
|
||||||
/* Return true if key is disabled */
|
/* Return true if key is disabled */
|
||||||
int
|
int
|
||||||
is_disabled(PKT_public_key *pk)
|
cache_disabled_value(PKT_public_key *pk)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
TRUSTREC trec;
|
TRUSTREC trec;
|
||||||
int disabled=0;
|
int disabled=0;
|
||||||
|
|
||||||
|
if(pk->is_disabled)
|
||||||
|
return (pk->is_disabled==2);
|
||||||
|
|
||||||
init_trustdb();
|
init_trustdb();
|
||||||
|
|
||||||
rc = read_trust_record (pk, &trec);
|
rc = read_trust_record (pk, &trec);
|
||||||
@ -765,6 +768,13 @@ is_disabled(PKT_public_key *pk)
|
|||||||
if(trec.r.trust.ownertrust & TRUST_FLAG_DISABLED)
|
if(trec.r.trust.ownertrust & TRUST_FLAG_DISABLED)
|
||||||
disabled=1;
|
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:
|
leave:
|
||||||
return disabled;
|
return disabled;
|
||||||
}
|
}
|
||||||
@ -875,7 +885,12 @@ get_validity (PKT_public_key *pk, PKT_user_id *uid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( (trec.r.trust.ownertrust & TRUST_FLAG_DISABLED) )
|
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:
|
leave:
|
||||||
/* set some flags direct from the key */
|
/* set some flags direct from the key */
|
||||||
|
@ -48,7 +48,7 @@ void sync_trustdb( void );
|
|||||||
|
|
||||||
void revalidation_mark (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);
|
unsigned int get_validity (PKT_public_key *pk, PKT_user_id *uid);
|
||||||
int get_validity_info (PKT_public_key *pk, PKT_user_id *uid);
|
int get_validity_info (PKT_public_key *pk, PKT_user_id *uid);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user