1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-05-28 21:50:02 +02: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:
Werner Koch 2015-01-22 12:14:48 +01:00
parent 11142e0ad7
commit 6f3d11d883
5 changed files with 7 additions and 11 deletions

View File

@ -38,6 +38,7 @@
/* These error codes are used but not defined in the required /* These error codes are used but not defined in the required
libgpg-error version. Define them here. */ libgpg-error version. Define them here. */
#if GPG_ERROR_VERSION_NUMBER < 0x011200 /* 1.18 */ #if GPG_ERROR_VERSION_NUMBER < 0x011200 /* 1.18 */
# define GPG_ERR_LEGACY_KEY 222
# define GPG_ERR_OBJ_TERM_STATE 225 # define GPG_ERR_OBJ_TERM_STATE 225
# define GPG_ERR_FORBIDDEN 251 # define GPG_ERR_FORBIDDEN 251
#endif #endif

View File

@ -403,8 +403,6 @@ get_pubkey (PKT_public_key * pk, u32 * keyid)
if (!rc) if (!rc)
goto leave; goto leave;
log_debug ("looking up key %08X%08X failed: %s\n", keyid[0], keyid[1],
gpg_strerror (rc));
rc = GPG_ERR_NO_PUBKEY; rc = GPG_ERR_NO_PUBKEY;
leave: leave:
@ -2573,7 +2571,8 @@ lookup (getkey_ctx_t ctx, kbnode_t *ret_keyblock, int want_secret)
} }
found: 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)); log_error ("keydb_search failed: %s\n", gpg_strerror (rc));
if (!rc) if (!rc)

View File

@ -544,11 +544,9 @@ read_block( IOBUF a, PACKET **pending_pkt, kbnode_t *ret_root, int *r_v3keys)
in_v3key = 0; in_v3key = 0;
while ((rc=parse_packet(a, pkt)) != -1) 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_PUBLIC_KEY
|| pkt->pkttype == PKT_SECRET_KEY) || pkt->pkttype == PKT_SECRET_KEY)))
&& (pkt->pkt.public_key->version == 2
|| pkt->pkt.public_key->version == 3)))
{ {
in_v3key = 1; in_v3key = 1;
++*r_v3keys; ++*r_v3keys;

View File

@ -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 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 public key used to locate the keyblock or flag bit 1 set for
* the user ID node. * the user ID node.
@ -1409,8 +1409,6 @@ keyring_rebuild_cache (void *token,int noisy)
goto leave; goto leave;
} }
log_debug ("keblock with version %d\n",
keyblock->pkt->pkt.public_key->version);
if (keyblock->pkt->pkt.public_key->version < 4) if (keyblock->pkt->pkt.public_key->version < 4)
{ {
/* We do not copy/cache v3 keys or any other unknown /* We do not copy/cache v3 keys or any other unknown

View File

@ -1963,7 +1963,7 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen,
if (list_mode) if (list_mode)
es_fprintf (listfp, ":key packet: [obsolete version %d]\n", version); es_fprintf (listfp, ":key packet: [obsolete version %d]\n", version);
pk->version = version; pk->version = version;
err = gpg_error (GPG_ERR_INV_PACKET); err = gpg_error (GPG_ERR_LEGACY_KEY);
goto leave; goto leave;
} }
else else