mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-02 12:01:32 +01:00
gpg: Add dedicated error code for PGP-2 keys.
* g10/parse-packet.c (parse_key): Return GPG_ERR_LEGACY_KEY for PGP2 keys. * g10/import.c (read_block): Simplify by checking GPG_ERR_LEGACY_KEY. * g10/getkey.c (lookup): Silence error message for PGP-2 keys. * common/util.h (GPG_ERR_LEGACY_KEY): Add replacement for older libgpg-error. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
11142e0ad7
commit
6f3d11d883
@ -38,6 +38,7 @@
|
||||
/* These error codes are used but not defined in the required
|
||||
libgpg-error version. Define them here. */
|
||||
#if GPG_ERROR_VERSION_NUMBER < 0x011200 /* 1.18 */
|
||||
# define GPG_ERR_LEGACY_KEY 222
|
||||
# define GPG_ERR_OBJ_TERM_STATE 225
|
||||
# define GPG_ERR_FORBIDDEN 251
|
||||
#endif
|
||||
|
@ -403,8 +403,6 @@ get_pubkey (PKT_public_key * pk, u32 * keyid)
|
||||
if (!rc)
|
||||
goto leave;
|
||||
|
||||
log_debug ("looking up key %08X%08X failed: %s\n", keyid[0], keyid[1],
|
||||
gpg_strerror (rc));
|
||||
rc = GPG_ERR_NO_PUBKEY;
|
||||
|
||||
leave:
|
||||
@ -2573,7 +2571,8 @@ lookup (getkey_ctx_t ctx, kbnode_t *ret_keyblock, int want_secret)
|
||||
}
|
||||
|
||||
found:
|
||||
if (rc && gpg_err_code (rc) != GPG_ERR_NOT_FOUND)
|
||||
if (rc && gpg_err_code (rc) != GPG_ERR_NOT_FOUND
|
||||
&& gpg_err_code (rc) != GPG_ERR_LEGACY_KEY)
|
||||
log_error ("keydb_search failed: %s\n", gpg_strerror (rc));
|
||||
|
||||
if (!rc)
|
||||
|
@ -544,11 +544,9 @@ read_block( IOBUF a, PACKET **pending_pkt, kbnode_t *ret_root, int *r_v3keys)
|
||||
in_v3key = 0;
|
||||
while ((rc=parse_packet(a, pkt)) != -1)
|
||||
{
|
||||
if (rc && (gpg_err_code (rc) == GPG_ERR_INV_PACKET
|
||||
if (rc && (gpg_err_code (rc) == GPG_ERR_LEGACY_KEY
|
||||
&& (pkt->pkttype == PKT_PUBLIC_KEY
|
||||
|| pkt->pkttype == PKT_SECRET_KEY)
|
||||
&& (pkt->pkt.public_key->version == 2
|
||||
|| pkt->pkt.public_key->version == 3)))
|
||||
|| pkt->pkttype == PKT_SECRET_KEY)))
|
||||
{
|
||||
in_v3key = 1;
|
||||
++*r_v3keys;
|
||||
|
@ -350,7 +350,7 @@ keyring_lock (KEYRING_HANDLE hd, int yes)
|
||||
|
||||
|
||||
/*
|
||||
* Return the last found keyring. Caller must free it.
|
||||
* Return the last found keyblock. Caller must free it.
|
||||
* The returned keyblock has the kbode flag bit 0 set for the node with
|
||||
* the public key used to locate the keyblock or flag bit 1 set for
|
||||
* the user ID node.
|
||||
@ -1409,8 +1409,6 @@ keyring_rebuild_cache (void *token,int noisy)
|
||||
goto leave;
|
||||
}
|
||||
|
||||
log_debug ("keblock with version %d\n",
|
||||
keyblock->pkt->pkt.public_key->version);
|
||||
if (keyblock->pkt->pkt.public_key->version < 4)
|
||||
{
|
||||
/* We do not copy/cache v3 keys or any other unknown
|
||||
|
@ -1963,7 +1963,7 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen,
|
||||
if (list_mode)
|
||||
es_fprintf (listfp, ":key packet: [obsolete version %d]\n", version);
|
||||
pk->version = version;
|
||||
err = gpg_error (GPG_ERR_INV_PACKET);
|
||||
err = gpg_error (GPG_ERR_LEGACY_KEY);
|
||||
goto leave;
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user