diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..7e1ef7361c0c425300666c33c07b395359100e58 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.bz2 filter=lfs diff=lfs merge=lfs -text diff --git a/.lfsconfig b/.lfsconfig new file mode 100644 index 0000000000000000000000000000000000000000..2ea38d3ded8b07ea1eee4c224be2c082e4a710b8 --- /dev/null +++ b/.lfsconfig @@ -0,0 +1,2 @@ +[lfs] + url = https://artlfs.openeuler.openatom.cn/src-openEuler/gnupg2 diff --git a/backport-0001-CVE-2025-30258.patch b/backport-0001-CVE-2025-30258.patch deleted file mode 100644 index 1ac16d4b6a8760b267d630258b658923d3abf943..0000000000000000000000000000000000000000 --- a/backport-0001-CVE-2025-30258.patch +++ /dev/null @@ -1,147 +0,0 @@ -From 25d748c3dfc0102f9e54afea59ff26b3969bd8c1 Mon Sep 17 00:00:00 2001 -From: Werner Koch -Date: Tue, 11 Feb 2025 14:44:23 +0100 -Subject: [PATCH] gpg: Lookup key for merging/inserting only by primary key. - -* g10/getkey.c (get_keyblock_byfpr_fast): Add arg primary_only and -implement. -* g10/import.c (import_one_real): Simplify filling the fpr buffer with -zeroes. -(import_one_real): Find key only by primary fingerprint. --- - -This should have been done early: When looking up the original -keyblock we want to update, we need to lookup it up only using the -primary key. This avoids to find a key which has the primary key also -has a subkey. - -GnuPG-bug-id: 7527 ---- - g10/getkey.c | 27 ++++++++++++++++++++++----- - g10/import.c | 8 ++++---- - g10/keydb.h | 9 +++++---- - 3 files changed, 31 insertions(+), 13 deletions(-) - -diff --git a/g10/getkey.c b/g10/getkey.c -index 618ad13e9..20ae84332 100644 ---- a/g10/getkey.c -+++ b/g10/getkey.c -@@ -1946,7 +1946,7 @@ get_pubkey_byfprint_fast (ctrl_t ctrl, PKT_public_key * pk, - KBNODE keyblock; - - err = get_keyblock_byfprint_fast (ctrl, -- &keyblock, NULL, fprint, fprint_len, 0); -+ &keyblock, NULL, 0, fprint, fprint_len, 0); - if (!err) - { - if (pk) -@@ -1963,18 +1963,23 @@ get_pubkey_byfprint_fast (ctrl_t ctrl, PKT_public_key * pk, - * R_HD may be NULL. If LOCK is set the handle has been opend in - * locked mode and keydb_disable_caching () has been called. On error - * R_KEYBLOCK is set to NULL but R_HD must be released by the caller; -- * it may have a value of NULL, though. This allows one to do an insert -- * operation on a locked keydb handle. */ -+ * it may have a value of NULL, though. This allows one to do an -+ * insert operation on a locked keydb handle. If PRIMARY_ONLY is set -+ * the function returns a keyblock which has the requested fingerprint -+ * has primary key. */ - gpg_error_t - get_keyblock_byfprint_fast (ctrl_t ctrl, -- kbnode_t *r_keyblock, KEYDB_HANDLE *r_hd, -- const byte *fprint, size_t fprint_len, int lock) -+ kbnode_t *r_keyblock, KEYDB_HANDLE *r_hd, -+ int primary_only, -+ const byte *fprint, size_t fprint_len, int lock) - { - gpg_error_t err; - KEYDB_HANDLE hd; - kbnode_t keyblock; - byte fprbuf[MAX_FINGERPRINT_LEN]; - int i; -+ byte tmpfpr[MAX_FINGERPRINT_LEN]; -+ size_t tmpfprlen; - - if (r_keyblock) - *r_keyblock = NULL; -@@ -2006,6 +2011,7 @@ get_keyblock_byfprint_fast (ctrl_t ctrl, - if (r_hd) - *r_hd = hd; - -+ again: - err = keydb_search_fpr (hd, fprbuf, fprint_len); - if (gpg_err_code (err) == GPG_ERR_NOT_FOUND) - { -@@ -2025,6 +2031,17 @@ get_keyblock_byfprint_fast (ctrl_t ctrl, - log_assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY - || keyblock->pkt->pkttype == PKT_PUBLIC_SUBKEY); - -+ if (primary_only) -+ { -+ fingerprint_from_pk (keyblock->pkt->pkt.public_key, tmpfpr, &tmpfprlen); -+ if (fprint_len != tmpfprlen || memcmp (fprint, tmpfpr, fprint_len)) -+ { -+ release_kbnode (keyblock); -+ keyblock = NULL; -+ goto again; -+ } -+ } -+ - /* Not caching key here since it won't have all of the fields - properly set. */ - -diff --git a/g10/import.c b/g10/import.c -index 7e48284c1..9adda3e8c 100644 ---- a/g10/import.c -+++ b/g10/import.c -@@ -1993,7 +1993,6 @@ import_one_real (ctrl_t ctrl, - int mod_key = 0; - int same_key = 0; - int non_self_or_utk = 0; -- size_t an; - char pkstrbuf[PUBKEY_STRING_SIZE]; - int merge_keys_done = 0; - KEYDB_HANDLE hd = NULL; -@@ -2014,8 +2013,8 @@ import_one_real (ctrl_t ctrl, - pk = node->pkt->pkt.public_key; - - fingerprint_from_pk (pk, fpr2, &fpr2len); -- for (an = fpr2len; an < MAX_FINGERPRINT_LEN; an++) -- fpr2[an] = 0; -+ if (MAX_FINGERPRINT_LEN > fpr2len) -+ memset (fpr2+fpr2len, 0, MAX_FINGERPRINT_LEN - fpr2len); - keyid_from_pk( pk, keyid ); - uidnode = find_next_kbnode( keyblock, PKT_USER_ID ); - -@@ -2212,7 +2211,8 @@ import_one_real (ctrl_t ctrl, - - /* Do we have this key already in one of our pubrings ? */ - err = get_keyblock_byfprint_fast (ctrl, &keyblock_orig, &hd, -- fpr2, fpr2len, 1/*locked*/); -+ 1 /*primary only */, -+ fpr2, fpr2len, 1/*locked*/); - if ((err - && gpg_err_code (err) != GPG_ERR_NO_PUBKEY - && gpg_err_code (err) != GPG_ERR_UNUSABLE_PUBKEY) -diff --git a/g10/keydb.h b/g10/keydb.h -index ac0953659..658c85a29 100644 ---- a/g10/keydb.h -+++ b/g10/keydb.h -@@ -420,10 +420,11 @@ gpg_error_t get_pubkey_byfprint_fast (ctrl_t ctrl, PKT_public_key *pk, - merge the self-signed data into the public key and subkeys or into - the user ids. */ - gpg_error_t get_keyblock_byfprint_fast (ctrl_t ctrl, -- kbnode_t *r_keyblock, -- KEYDB_HANDLE *r_hd, -- const byte *fprint, size_t fprint_len, -- int lock); -+ kbnode_t *r_keyblock, -+ KEYDB_HANDLE *r_hd, -+ int primary_only, -+ const byte *fpr, size_t fprlen, -+ int lock); - - - /* Returns true if a secret key is available for the public key with --- -2.33.0 - diff --git a/backport-0002-CVE-2025-30258.patch b/backport-0002-CVE-2025-30258.patch deleted file mode 100644 index 72487178313512dbe5259420d329e251f098d202..0000000000000000000000000000000000000000 --- a/backport-0002-CVE-2025-30258.patch +++ /dev/null @@ -1,127 +0,0 @@ -From 9cd371b12d80cfc5bc85cb6e5f5eebb4decbe94f Mon Sep 17 00:00:00 2001 -From: Werner Koch -Date: Thu, 20 Feb 2025 14:50:20 +0100 -Subject: [PATCH] gpg: Remove a signature check function wrapper. - -* g10/sig-check.c (check_signature2): Rename to -(check_signature): this and remove the old wrapper. Adjust all -callers. ---- - g10/mainproc.c | 13 +++++-------- - g10/packet.h | 6 +----- - g10/sig-check.c | 26 ++++++++------------------ - 3 files changed, 14 insertions(+), 31 deletions(-) - -diff --git a/g10/mainproc.c b/g10/mainproc.c -index 739ad0a35..86f5a2db9 100644 ---- a/g10/mainproc.c -+++ b/g10/mainproc.c -@@ -1240,19 +1240,17 @@ do_check_sig (CTX c, kbnode_t node, const void *extrahash, size_t extrahashlen, - - /* We only get here if we are checking the signature of a binary - (0x00) or text document (0x01). */ -- rc = check_signature2 (c->ctrl, sig, md, extrahash, extrahashlen, -- forced_pk, -- NULL, is_expkey, is_revkey, r_pk); -+ rc = check_signature (c->ctrl, sig, md, extrahash, extrahashlen, -+ forced_pk, NULL, is_expkey, is_revkey, r_pk); - if (! rc) - md_good = md; - else if (gpg_err_code (rc) == GPG_ERR_BAD_SIGNATURE && md2) - { - PKT_public_key *pk2; - -- rc = check_signature2 (c->ctrl, sig, md2, extrahash, extrahashlen, -- forced_pk, -- NULL, is_expkey, is_revkey, -- r_pk? &pk2 : NULL); -+ rc = check_signature (c->ctrl, sig, md2, extrahash, extrahashlen, -+ forced_pk, NULL, is_expkey, is_revkey, -+ r_pk? &pk2 : NULL); - if (!rc) - { - md_good = md2; -@@ -1834,7 +1832,6 @@ issuer_fpr_string (PKT_signature *sig) - return p? bin2hex (p, n, NULL) : NULL; - } - -- - static void - print_good_bad_signature (int statno, const char *keyid_str, kbnode_t un, - PKT_signature *sig, int rc) -diff --git a/g10/packet.h b/g10/packet.h -index 7bc0a6461..b61c65417 100644 ---- a/g10/packet.h -+++ b/g10/packet.h -@@ -907,16 +907,12 @@ int cmp_user_ids( PKT_user_id *a, PKT_user_id *b ); - - - /*-- sig-check.c --*/ --/* Check a signature. This is shorthand for check_signature2 with -- the unnamed arguments passed as NULL. */ --int check_signature (ctrl_t ctrl, PKT_signature *sig, gcry_md_hd_t digest); -- - /* Check a signature. Looks up the public key from the key db. (If - * R_PK is not NULL, it is stored at RET_PK.) DIGEST contains a - * valid hash context that already includes the signed data. This - * function adds the relevant meta-data to the hash before finalizing - * it and verifying the signature. FOCRED_PK is usually NULL. */ --gpg_error_t check_signature2 (ctrl_t ctrl, -+gpg_error_t check_signature (ctrl_t ctrl, - PKT_signature *sig, gcry_md_hd_t digest, - const void *extrahash, size_t extrahashlen, - PKT_public_key *forced_pk, -diff --git a/g10/sig-check.c b/g10/sig-check.c -index 06329f659..54db2089a 100644 ---- a/g10/sig-check.c -+++ b/g10/sig-check.c -@@ -88,17 +88,6 @@ check_key_verify_compliance (PKT_public_key *pk) - } - - -- --/* Check a signature. This is shorthand for check_signature2 with -- the unnamed arguments passed as NULL. */ --int --check_signature (ctrl_t ctrl, PKT_signature *sig, gcry_md_hd_t digest) --{ -- return check_signature2 (ctrl, sig, digest, NULL, 0, NULL, -- NULL, NULL, NULL, NULL); --} -- -- - /* Check a signature. - * - * Looks up the public key that created the signature (SIG->KEYID) -@@ -144,12 +133,12 @@ check_signature (ctrl_t ctrl, PKT_signature *sig, gcry_md_hd_t digest) - * - * Returns 0 on success. An error code otherwise. */ - gpg_error_t --check_signature2 (ctrl_t ctrl, -- PKT_signature *sig, gcry_md_hd_t digest, -- const void *extrahash, size_t extrahashlen, -- PKT_public_key *forced_pk, -- u32 *r_expiredate, -- int *r_expired, int *r_revoked, PKT_public_key **r_pk) -+check_signature (ctrl_t ctrl, -+ PKT_signature *sig, gcry_md_hd_t digest, -+ const void *extrahash, size_t extrahashlen, -+ PKT_public_key *forced_pk, -+ u32 *r_expiredate, int *r_expired, int *r_revoked, -+ PKT_public_key **r_pk) - { - int rc=0; - PKT_public_key *pk; -@@ -802,7 +791,8 @@ check_revocation_keys (ctrl_t ctrl, PKT_public_key *pk, PKT_signature *sig) - hash_public_key(md,pk); - /* Note: check_signature only checks that the signature - is good. It does not fail if the key is revoked. */ -- rc = check_signature (ctrl, sig, md); -+ rc = check_signature (ctrl, sig, md, NULL, 0, NULL, -+ NULL, NULL, NULL, NULL); - cache_sig_result(sig,rc); - gcry_md_close (md); - break; --- -2.33.0 - diff --git a/backport-0003-CVE-2025-30258.patch b/backport-0003-CVE-2025-30258.patch deleted file mode 100644 index efcea80afd2642dee656f86e01483e2e7aa1d0e5..0000000000000000000000000000000000000000 --- a/backport-0003-CVE-2025-30258.patch +++ /dev/null @@ -1,625 +0,0 @@ -From da0164efc7f32013bc24d97b9afa9f8d67c318bb Mon Sep 17 00:00:00 2001 -From: Werner Koch -Date: Fri, 21 Feb 2025 12:16:17 +0100 -Subject: [PATCH] gpg: Fix a verification DoS due to a malicious subkey in the - keyring. - -* g10/getkey.c (get_pubkey): Factor code out to ... -(get_pubkey_bykid): new. Add feature to return the keyblock. -(get_pubkey_for_sig): Add arg r_keyblock to return the used keyblock. -Request a signing usage. -(get_pubkeyblock_for_sig): Remove. -(finish_lookup): Improve debug output. -* g10/sig-check.c (check_signature): Add arg r_keyblock and pass it -down. -* g10/mainproc.c (do_check_sig): Ditto. -(check_sig_and_print): Use the keyblock returned by do_check_sig to -show further information instead of looking it up again with -get_pubkeyblock_for_sig. Also re-check the signature after the import -of an included keyblock. --- - -The problem here is that it is possible to import a key from someone -who added a signature subkey from another public key and thus inhibits -that a good signature good be verified. - -Such a malicious key signature subkey must have been created w/o the -mandatory backsig which bind a signature subkey to its primary key. -For encryption subkeys this is not an issue because the existence of a -decryption private key is all you need to decrypt something and then -it does not matter if the public subkey or its binding signature has -been put below another primary key; in fact we do the latter for -ADSKs. - -GnuPG-bug-id: 7527 -Backported-from-master: 48978ccb4e20866472ef18436a32744350a65158 ---- - g10/getkey.c | 108 ++++++++++++++++++++++++++++++------------------ - g10/gpg.h | 3 +- - g10/keydb.h | 10 ++++- - g10/mainproc.c | 92 ++++++++++++++++++++++++++--------------- - g10/packet.h | 2 +- - g10/sig-check.c | 23 +++++++---- - 6 files changed, 152 insertions(+), 86 deletions(-) - -diff --git a/g10/getkey.c b/g10/getkey.c -index 20ae84332..c4d02fbb1 100644 ---- a/g10/getkey.c -+++ b/g10/getkey.c -@@ -316,27 +316,50 @@ pk_from_block (PKT_public_key *pk, kbnode_t keyblock, kbnode_t found_key) - - /* Specialized version of get_pubkey which retrieves the key based on - * information in SIG. In contrast to get_pubkey PK is required. IF -- * FORCED_PK is not NULL, this public key is used and copied to PK. */ -+ * FORCED_PK is not NULL, this public key is used and copied to PK. -+ * If R_KEYBLOCK is not NULL the entire keyblock is stored there if -+ * found and FORCED_PK is not used; if not used or on error NULL is -+ * stored there. */ - gpg_error_t - get_pubkey_for_sig (ctrl_t ctrl, PKT_public_key *pk, PKT_signature *sig, -- PKT_public_key *forced_pk) -+ PKT_public_key *forced_pk, kbnode_t *r_keyblock) - { -+ gpg_error_t err; - const byte *fpr; - size_t fprlen; - -+ if (r_keyblock) -+ *r_keyblock = NULL; -+ - if (forced_pk) - { - copy_public_key (pk, forced_pk); - return 0; - } - -+ /* Make sure to request only keys cabable of signing. This makes -+ * sure that a subkey w/o a valid backsig or with bad usage flags -+ * will be skipped. */ -+ pk->req_usage = PUBKEY_USAGE_SIG; -+ - /* First try the ISSUER_FPR info. */ - fpr = issuer_fpr_raw (sig, &fprlen); -- if (fpr && !get_pubkey_byfprint (ctrl, pk, NULL, fpr, fprlen)) -+ if (fpr && !get_pubkey_byfprint (ctrl, pk, r_keyblock, fpr, fprlen)) - return 0; -+ if (r_keyblock) -+ { -+ release_kbnode (*r_keyblock); -+ *r_keyblock = NULL; -+ } - - /* Fallback to use the ISSUER_KEYID. */ -- return get_pubkey (ctrl, pk, sig->keyid); -+ err = get_pubkey_bykid (ctrl, pk, r_keyblock, sig->keyid); -+ if (err && r_keyblock) -+ { -+ release_kbnode (*r_keyblock); -+ *r_keyblock = NULL; -+ } -+ return err; - } - - -@@ -354,6 +377,10 @@ get_pubkey_for_sig (ctrl_t ctrl, PKT_public_key *pk, PKT_signature *sig, - * usage will be returned. As such, it is essential that - * PK->REQ_USAGE be correctly initialized! - * -+ * If R_KEYBLOCK is not NULL, then the first result's keyblock is -+ * returned in *R_KEYBLOCK. This should be freed using -+ * release_kbnode(). -+ * - * Returns 0 on success, GPG_ERR_NO_PUBKEY if there is no public key - * with the specified key id, or another error code if an error - * occurs. -@@ -361,24 +388,30 @@ get_pubkey_for_sig (ctrl_t ctrl, PKT_public_key *pk, PKT_signature *sig, - * If the data was not read from the cache, then the self-signed data - * has definitely been merged into the public key using - * merge_selfsigs. */ --int --get_pubkey (ctrl_t ctrl, PKT_public_key * pk, u32 * keyid) -+gpg_error_t -+get_pubkey_bykid (ctrl_t ctrl, PKT_public_key *pk, kbnode_t *r_keyblock, -+ u32 *keyid) - { - int internal = 0; -- int rc = 0; -+ gpg_error_t rc = 0; -+ -+ if (r_keyblock) -+ *r_keyblock = NULL; - - #if MAX_PK_CACHE_ENTRIES -- if (pk) -+ if (pk && !r_keyblock) - { - /* Try to get it from the cache. We don't do this when pk is -- NULL as it does not guarantee that the user IDs are -- cached. */ -+ * NULL as it does not guarantee that the user IDs are cached. -+ * The old get_pubkey_function did not check PK->REQ_USAGE when -+ * reading form the caceh. This is probably a bug. Note that -+ * the cache is not used when the caller asked to return the -+ * entire keyblock. This is because the cache does not -+ * associate the public key wit its primary key. */ - pk_cache_entry_t ce; - for (ce = pk_cache; ce; ce = ce->next) - { - if (ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1]) -- /* XXX: We don't check PK->REQ_USAGE here, but if we don't -- read from the cache, we do check it! */ - { - copy_public_key (pk, ce->pk); - return 0; -@@ -386,6 +419,7 @@ get_pubkey (ctrl_t ctrl, PKT_public_key * pk, u32 * keyid) - } - } - #endif -+ - /* More init stuff. */ - if (!pk) - { -@@ -431,16 +465,18 @@ get_pubkey (ctrl_t ctrl, PKT_public_key * pk, u32 * keyid) - ctx.req_usage = pk->req_usage; - rc = lookup (ctrl, &ctx, 0, &kb, &found_key); - if (!rc) -+ pk_from_block (pk, kb, found_key); -+ getkey_end (ctrl, &ctx); -+ if (!rc && r_keyblock) - { -- pk_from_block (pk, kb, found_key); -+ *r_keyblock = kb; -+ kb = NULL; - } -- getkey_end (ctrl, &ctx); - release_kbnode (kb); - } -- if (!rc) -- goto leave; - -- rc = GPG_ERR_NO_PUBKEY; -+ if (rc) /* Return a more useful error code. */ -+ rc = gpg_error (GPG_ERR_NO_PUBKEY); - - leave: - if (!rc) -@@ -451,6 +487,14 @@ leave: - } - - -+/* Wrapper for get_pubkey_bykid w/o keyblock return feature. */ -+int -+get_pubkey (ctrl_t ctrl, PKT_public_key *pk, u32 *keyid) -+{ -+ return get_pubkey_bykid (ctrl, pk, NULL, keyid); -+} -+ -+ - /* Same as get_pubkey but if the key was not found the function tries - * to import it from LDAP. FIXME: We should not need this but swicth - * to a fingerprint lookup. */ -@@ -563,28 +607,6 @@ get_pubkey_fast (ctrl_t ctrl, PKT_public_key * pk, u32 * keyid) - } - - --/* Return the entire keyblock used to create SIG. This is a -- * specialized version of get_pubkeyblock. -- * -- * FIXME: This is a hack because get_pubkey_for_sig was already called -- * and it could have used a cache to hold the key. */ --kbnode_t --get_pubkeyblock_for_sig (ctrl_t ctrl, PKT_signature *sig) --{ -- const byte *fpr; -- size_t fprlen; -- kbnode_t keyblock; -- -- /* First try the ISSUER_FPR info. */ -- fpr = issuer_fpr_raw (sig, &fprlen); -- if (fpr && !get_pubkey_byfprint (ctrl, NULL, &keyblock, fpr, fprlen)) -- return keyblock; -- -- /* Fallback to use the ISSUER_KEYID. */ -- return get_pubkeyblock (ctrl, sig->keyid); --} -- -- - /* Return the key block for the key with key id KEYID or NULL, if an - * error occurs. Use release_kbnode() to release the key block. - * -@@ -3701,6 +3723,7 @@ finish_lookup (kbnode_t keyblock, unsigned int req_usage, int want_exact, - kbnode_t latest_key; - PKT_public_key *pk; - int req_prim; -+ int diag_exactfound = 0; - u32 curtime = make_timestamp (); - - if (r_flags) -@@ -3731,11 +3754,10 @@ finish_lookup (kbnode_t keyblock, unsigned int req_usage, int want_exact, - { - if (want_exact) - { -- if (DBG_LOOKUP) -- log_debug ("finish_lookup: exact search requested and found\n"); - foundk = k; - pk = k->pkt->pkt.public_key; - pk->flags.exact = 1; -+ diag_exactfound = 1; - break; - } - else if (!allow_adsk && (k->pkt->pkt.public_key->pubkey_usage -@@ -3765,10 +3787,14 @@ finish_lookup (kbnode_t keyblock, unsigned int req_usage, int want_exact, - log_debug ("finish_lookup: checking key %08lX (%s)(req_usage=%x)\n", - (ulong) keyid_from_pk (keyblock->pkt->pkt.public_key, NULL), - foundk ? "one" : "all", req_usage); -+ if (diag_exactfound && DBG_LOOKUP) -+ log_debug ("\texact search requested and found\n"); - - if (!req_usage) - { - latest_key = foundk ? foundk : keyblock; -+ if (DBG_LOOKUP) -+ log_debug ("\tno usage requested - accepting key\n"); - goto found; - } - -diff --git a/g10/gpg.h b/g10/gpg.h -index c51bbbb46..0cdcb8b12 100644 ---- a/g10/gpg.h -+++ b/g10/gpg.h -@@ -69,7 +69,8 @@ struct dirmngr_local_s; - typedef struct dirmngr_local_s *dirmngr_local_t; - - /* Object used to describe a keyblock node. */ --typedef struct kbnode_struct *KBNODE; /* Deprecated use kbnode_t. */typedef struct kbnode_struct *kbnode_t; -+typedef struct kbnode_struct *KBNODE; /* Deprecated use kbnode_t. */ -+typedef struct kbnode_struct *kbnode_t; - - /* The handle for keydb operations. */ - typedef struct keydb_handle_s *KEYDB_HANDLE; -diff --git a/g10/keydb.h b/g10/keydb.h -index 658c85a29..7d25b3550 100644 ---- a/g10/keydb.h -+++ b/g10/keydb.h -@@ -332,9 +332,15 @@ void getkey_disable_caches(void); - /* Return the public key used for signature SIG and store it at PK. */ - gpg_error_t get_pubkey_for_sig (ctrl_t ctrl, - PKT_public_key *pk, PKT_signature *sig, -- PKT_public_key *forced_pk); -+ PKT_public_key *forced_pk, -+ kbnode_t *r_keyblock); - --/* Return the public key with the key id KEYID and store it at PK. */ -+/* Return the public key with the key id KEYID and store it at PK. -+ * Optionally return the entire keyblock. */ -+gpg_error_t get_pubkey_bykid (ctrl_t ctrl, PKT_public_key *pk, -+ kbnode_t *r_keyblock, u32 *keyid); -+ -+/* Same as get_pubkey_bykid but w/o r_keyblock. */ - int get_pubkey (ctrl_t ctrl, PKT_public_key *pk, u32 *keyid); - - /* Same as get_pubkey but with auto LDAP fetch. */ -diff --git a/g10/mainproc.c b/g10/mainproc.c -index 86f5a2db9..308738839 100644 ---- a/g10/mainproc.c -+++ b/g10/mainproc.c -@@ -1150,12 +1150,15 @@ proc_compressed (CTX c, PACKET *pkt) - * used to verify the signature will be stored there, or NULL if not - * found. If FORCED_PK is not NULL, this public key is used to verify - * _data signatures_ and no key lookup is done. Returns: 0 = valid -- * signature or an error code -+ * signature or an error code. If R_KEYBLOCK is not NULL the keyblock -+ * carries the used PK is stored there. The caller should always free -+ * the return value using release_kbnode. - */ - static int - do_check_sig (CTX c, kbnode_t node, const void *extrahash, size_t extrahashlen, - PKT_public_key *forced_pk, int *is_selfsig, -- int *is_expkey, int *is_revkey, PKT_public_key **r_pk) -+ int *is_expkey, int *is_revkey, -+ PKT_public_key **r_pk, kbnode_t *r_keyblock) - { - PKT_signature *sig; - gcry_md_hd_t md = NULL; -@@ -1165,6 +1168,8 @@ do_check_sig (CTX c, kbnode_t node, const void *extrahash, size_t extrahashlen, - - if (r_pk) - *r_pk = NULL; -+ if (r_keyblock) -+ *r_keyblock = NULL; - - log_assert (node->pkt->pkttype == PKT_SIGNATURE); - if (is_selfsig) -@@ -1241,16 +1246,19 @@ do_check_sig (CTX c, kbnode_t node, const void *extrahash, size_t extrahashlen, - /* We only get here if we are checking the signature of a binary - (0x00) or text document (0x01). */ - rc = check_signature (c->ctrl, sig, md, extrahash, extrahashlen, -- forced_pk, NULL, is_expkey, is_revkey, r_pk); -+ forced_pk, NULL, is_expkey, is_revkey, -+ r_pk, r_keyblock); - if (! rc) - md_good = md; - else if (gpg_err_code (rc) == GPG_ERR_BAD_SIGNATURE && md2) - { - PKT_public_key *pk2; - -+ if (r_keyblock) -+ release_kbnode (*r_keyblock); - rc = check_signature (c->ctrl, sig, md2, extrahash, extrahashlen, - forced_pk, NULL, is_expkey, is_revkey, -- r_pk? &pk2 : NULL); -+ r_pk? &pk2 : NULL, r_keyblock); - if (!rc) - { - md_good = md2; -@@ -1413,7 +1421,7 @@ list_node (CTX c, kbnode_t node) - { - fflush (stdout); - rc2 = do_check_sig (c, node, NULL, 0, NULL, -- &is_selfsig, NULL, NULL, NULL); -+ &is_selfsig, NULL, NULL, NULL, NULL); - switch (gpg_err_code (rc2)) - { - case 0: sigrc = '!'; break; -@@ -1872,7 +1880,7 @@ check_sig_and_print (CTX c, kbnode_t node) - PKT_public_key *pk = NULL; /* The public key for the signature or NULL. */ - const void *extrahash = NULL; - size_t extrahashlen = 0; -- kbnode_t included_keyblock = NULL; -+ kbnode_t keyblock = NULL; - char pkstrbuf[PUBKEY_STRING_SIZE] = { 0 }; - - -@@ -1993,7 +2001,8 @@ check_sig_and_print (CTX c, kbnode_t node) - { - ambiguous: - log_error(_("can't handle this ambiguous signature data\n")); -- return 0; -+ rc = 0; -+ goto leave; - } - } /* End checking signature packet composition. */ - -@@ -2029,7 +2038,7 @@ check_sig_and_print (CTX c, kbnode_t node) - log_info (_(" issuer \"%s\"\n"), sig->signers_uid); - - rc = do_check_sig (c, node, extrahash, extrahashlen, NULL, -- NULL, &is_expkey, &is_revkey, &pk); -+ NULL, &is_expkey, &is_revkey, &pk, &keyblock); - - /* If the key is not found but the signature includes a key block we - * use that key block for verification and on success import it. */ -@@ -2037,6 +2046,7 @@ check_sig_and_print (CTX c, kbnode_t node) - && sig->flags.key_block - && opt.flags.auto_key_import) - { -+ kbnode_t included_keyblock = NULL; - PKT_public_key *included_pk; - const byte *kblock; - size_t kblock_len; -@@ -2048,10 +2058,12 @@ check_sig_and_print (CTX c, kbnode_t node) - kblock+1, kblock_len-1, - sig->keyid, &included_keyblock)) - { -+ /* Note: This is the only place where we use the forced_pk -+ * arg (ie. included_pk) with do_check_sig. */ - rc = do_check_sig (c, node, extrahash, extrahashlen, included_pk, -- NULL, &is_expkey, &is_revkey, &pk); -+ NULL, &is_expkey, &is_revkey, &pk, NULL); - if (opt.verbose) -- log_debug ("checked signature using included key block: %s\n", -+ log_info ("checked signature using included key block: %s\n", - gpg_strerror (rc)); - if (!rc) - { -@@ -2061,6 +2073,18 @@ check_sig_and_print (CTX c, kbnode_t node) - - } - free_public_key (included_pk); -+ release_kbnode (included_keyblock); -+ -+ /* To make sure that nothing strange happened we check the -+ * signature again now using our own key store. This also -+ * returns the keyblock which we use later on. */ -+ if (!rc) -+ { -+ release_kbnode (keyblock); -+ keyblock = NULL; -+ rc = do_check_sig (c, node, extrahash, extrahashlen, NULL, -+ NULL, &is_expkey, &is_revkey, &pk, &keyblock); -+ } - } - - /* If the key isn't found, check for a preferred keyserver. Note -@@ -2107,8 +2131,13 @@ check_sig_and_print (CTX c, kbnode_t node) - KEYSERVER_IMPORT_FLAG_QUICK); - glo_ctrl.in_auto_key_retrieve--; - if (!res) -- rc = do_check_sig (c, node, extrahash, extrahashlen, NULL, -- NULL, &is_expkey, &is_revkey, &pk); -+ { -+ release_kbnode (keyblock); -+ keyblock = NULL; -+ rc = do_check_sig (c, node, extrahash, extrahashlen, NULL, -+ NULL, &is_expkey, &is_revkey, &pk, -+ &keyblock); -+ } - else if (DBG_LOOKUP) - log_debug ("lookup via %s failed: %s\n", "Pref-KS", - gpg_strerror (res)); -@@ -2149,8 +2178,12 @@ check_sig_and_print (CTX c, kbnode_t node) - /* Fixme: If the fingerprint is embedded in the signature, - * compare it to the fingerprint of the returned key. */ - if (!res) -- rc = do_check_sig (c, node, extrahash, extrahashlen, NULL, -- NULL, &is_expkey, &is_revkey, &pk); -+ { -+ release_kbnode (keyblock); -+ keyblock = NULL; -+ rc = do_check_sig (c, node, extrahash, extrahashlen, NULL, -+ NULL, &is_expkey, &is_revkey, &pk, &keyblock); -+ } - else if (DBG_LOOKUP) - log_debug ("lookup via %s failed: %s\n", "WKD", gpg_strerror (res)); - } -@@ -2180,8 +2213,13 @@ check_sig_and_print (CTX c, kbnode_t node) - KEYSERVER_IMPORT_FLAG_QUICK); - glo_ctrl.in_auto_key_retrieve--; - if (!res) -- rc = do_check_sig (c, node, extrahash, extrahashlen, NULL, -- NULL, &is_expkey, &is_revkey, &pk); -+ { -+ release_kbnode (keyblock); -+ keyblock = NULL; -+ rc = do_check_sig (c, node, extrahash, extrahashlen, NULL, -+ NULL, &is_expkey, &is_revkey, &pk, -+ &keyblock); -+ } - else if (DBG_LOOKUP) - log_debug ("lookup via %s failed: %s\n", "KS", gpg_strerror (res)); - } -@@ -2192,7 +2230,7 @@ check_sig_and_print (CTX c, kbnode_t node) - { - /* We have checked the signature and the result is either a good - * signature or a bad signature. Further examination follows. */ -- kbnode_t un, keyblock; -+ kbnode_t un; - int count = 0; - int keyblock_has_pk = 0; /* For failsafe check. */ - int statno; -@@ -2210,18 +2248,6 @@ check_sig_and_print (CTX c, kbnode_t node) - else - statno = STATUS_GOODSIG; - -- /* FIXME: We should have the public key in PK and thus the -- * keyblock has already been fetched. Thus we could use the -- * fingerprint or PK itself to lookup the entire keyblock. That -- * would best be done with a cache. */ -- if (included_keyblock) -- { -- keyblock = included_keyblock; -- included_keyblock = NULL; -- } -- else -- keyblock = get_pubkeyblock_for_sig (c->ctrl, sig); -- - snprintf (keyid_str, sizeof keyid_str, "%08lX%08lX [uncertain] ", - (ulong)sig->keyid[0], (ulong)sig->keyid[1]); - -@@ -2287,10 +2313,10 @@ check_sig_and_print (CTX c, kbnode_t node) - * contained in the keyring.*/ - } - -- log_assert (mainpk); -- if (!keyblock_has_pk) -+ if (!mainpk || !keyblock_has_pk) - { -- log_error ("signature key lost from keyblock\n"); -+ log_error ("signature key lost from keyblock (%p,%p,%d)\n", -+ keyblock, mainpk, keyblock_has_pk); - rc = gpg_error (GPG_ERR_INTERNAL); - } - -@@ -2562,8 +2588,8 @@ check_sig_and_print (CTX c, kbnode_t node) - log_error (_("Can't check signature: %s\n"), gpg_strerror (rc)); - } - -+ leave: - free_public_key (pk); -- release_kbnode (included_keyblock); - xfree (issuer_fpr); - return rc; - } -diff --git a/g10/packet.h b/g10/packet.h -index b61c65417..d6cbef4bc 100644 ---- a/g10/packet.h -+++ b/g10/packet.h -@@ -917,7 +917,7 @@ gpg_error_t check_signature (ctrl_t ctrl, - const void *extrahash, size_t extrahashlen, - PKT_public_key *forced_pk, - u32 *r_expiredate, int *r_expired, int *r_revoked, -- PKT_public_key **r_pk); -+ PKT_public_key **r_pk, kbnode_t *r_keyblock); - - - /*-- pubkey-enc.c --*/ -diff --git a/g10/sig-check.c b/g10/sig-check.c -index 54db2089a..456c29320 100644 ---- a/g10/sig-check.c -+++ b/g10/sig-check.c -@@ -131,6 +131,11 @@ check_key_verify_compliance (PKT_public_key *pk) - * If R_PK is not NULL, the public key is stored at that address if it - * was found; other wise NULL is stored. - * -+ * If R_KEYBLOCK is not NULL, the entire keyblock used to verify the -+ * signature is stored at that address. If no key was found or on -+ * some other errors NULL is stored there. The callers needs to -+ * release the keyblock using release_kbnode (kb). -+ * - * Returns 0 on success. An error code otherwise. */ - gpg_error_t - check_signature (ctrl_t ctrl, -@@ -138,7 +143,7 @@ check_signature (ctrl_t ctrl, - const void *extrahash, size_t extrahashlen, - PKT_public_key *forced_pk, - u32 *r_expiredate, int *r_expired, int *r_revoked, -- PKT_public_key **r_pk) -+ PKT_public_key **r_pk, kbnode_t *r_keyblock) - { - int rc=0; - PKT_public_key *pk; -@@ -151,6 +156,8 @@ check_signature (ctrl_t ctrl, - *r_revoked = 0; - if (r_pk) - *r_pk = NULL; -+ if (r_keyblock) -+ *r_keyblock = NULL; - - pk = xtrycalloc (1, sizeof *pk); - if (!pk) -@@ -181,7 +188,7 @@ check_signature (ctrl_t ctrl, - log_info(_("WARNING: signature digest conflict in message\n")); - rc = gpg_error (GPG_ERR_GENERAL); - } -- else if (get_pubkey_for_sig (ctrl, pk, sig, forced_pk)) -+ else if (get_pubkey_for_sig (ctrl, pk, sig, forced_pk, r_keyblock)) - rc = gpg_error (GPG_ERR_NO_PUBKEY); - else if ((rc = check_key_verify_compliance (pk))) - ;/* Compliance failure. */ -@@ -780,9 +787,9 @@ check_revocation_keys (ctrl_t ctrl, PKT_public_key *pk, PKT_signature *sig) - keyid_from_fingerprint (ctrl, pk->revkey[i].fpr, pk->revkey[i].fprlen, - keyid); - -- if(keyid[0]==sig->keyid[0] && keyid[1]==sig->keyid[1]) -- /* The signature was generated by a designated revoker. -- Verify the signature. */ -+ /* If the signature was generated by a designated revoker -+ * verify the signature. */ -+ if (keyid[0] == sig->keyid[0] && keyid[1] == sig->keyid[1]) - { - gcry_md_hd_t md; - -@@ -790,9 +797,9 @@ check_revocation_keys (ctrl_t ctrl, PKT_public_key *pk, PKT_signature *sig) - BUG (); - hash_public_key(md,pk); - /* Note: check_signature only checks that the signature -- is good. It does not fail if the key is revoked. */ -+ * is good. It does not fail if the key is revoked. */ - rc = check_signature (ctrl, sig, md, NULL, 0, NULL, -- NULL, NULL, NULL, NULL); -+ NULL, NULL, NULL, NULL, NULL); - cache_sig_result(sig,rc); - gcry_md_close (md); - break; -@@ -997,7 +1004,7 @@ check_signature_over_key_or_uid (ctrl_t ctrl, PKT_public_key *signer, - if (IS_CERT (sig)) - signer->req_usage = PUBKEY_USAGE_CERT; - -- rc = get_pubkey_for_sig (ctrl, signer, sig, NULL); -+ rc = get_pubkey_for_sig (ctrl, signer, sig, NULL, NULL); - if (rc) - { - xfree (signer); --- -2.33.0 - diff --git a/backport-0004-CVE-2025-30258.patch b/backport-0004-CVE-2025-30258.patch deleted file mode 100644 index 872b572730f18dd68669909eb81cc190e5a30a21..0000000000000000000000000000000000000000 --- a/backport-0004-CVE-2025-30258.patch +++ /dev/null @@ -1,177 +0,0 @@ -From 1e581619bf5315957f2be06b3b1a7f513304c126 Mon Sep 17 00:00:00 2001 -From: Werner Koch -Date: Thu, 6 Mar 2025 17:17:17 +0100 -Subject: [PATCH] gpg: Fix regression for the recent malicious subkey DoS fix. - -* g10/packet.h (PUBKEY_USAGE_VERIFY): New. -* g10/getkey.c (get_pubkey_for_sig): Pass new flag also to requested -usage. -(finish_lookup): Introduce a verify_mode. --- - -Fixes-commit: da0164efc7f32013bc24d97b9afa9f8d67c318bb -GnuPG-bug-id: 7547 ---- - g10/getkey.c | 44 ++++++++++++++++++++++++++++---------------- - g10/packet.h | 1 + - 2 files changed, 29 insertions(+), 16 deletions(-) - -diff --git a/g10/getkey.c b/g10/getkey.c -index c4d02fbb1..e3264062f 100644 ---- a/g10/getkey.c -+++ b/g10/getkey.c -@@ -315,11 +315,12 @@ pk_from_block (PKT_public_key *pk, kbnode_t keyblock, kbnode_t found_key) - - - /* Specialized version of get_pubkey which retrieves the key based on -- * information in SIG. In contrast to get_pubkey PK is required. IF -+ * information in SIG. In contrast to get_pubkey PK is required. If - * FORCED_PK is not NULL, this public key is used and copied to PK. - * If R_KEYBLOCK is not NULL the entire keyblock is stored there if - * found and FORCED_PK is not used; if not used or on error NULL is -- * stored there. */ -+ * stored there. Use this function only to find the key for -+ * verification; it can't be used to select a key for signing. */ - gpg_error_t - get_pubkey_for_sig (ctrl_t ctrl, PKT_public_key *pk, PKT_signature *sig, - PKT_public_key *forced_pk, kbnode_t *r_keyblock) -@@ -339,8 +340,9 @@ get_pubkey_for_sig (ctrl_t ctrl, PKT_public_key *pk, PKT_signature *sig, - - /* Make sure to request only keys cabable of signing. This makes - * sure that a subkey w/o a valid backsig or with bad usage flags -- * will be skipped. */ -- pk->req_usage = PUBKEY_USAGE_SIG; -+ * will be skipped. We also request the verification mode so that -+ * expired and reoked keys are returned. */ -+ pk->req_usage = (PUBKEY_USAGE_SIG | PUBKEY_USAGE_VERIFY); - - /* First try the ISSUER_FPR info. */ - fpr = issuer_fpr_raw (sig, &fprlen); -@@ -404,10 +406,10 @@ get_pubkey_bykid (ctrl_t ctrl, PKT_public_key *pk, kbnode_t *r_keyblock, - /* Try to get it from the cache. We don't do this when pk is - * NULL as it does not guarantee that the user IDs are cached. - * The old get_pubkey_function did not check PK->REQ_USAGE when -- * reading form the caceh. This is probably a bug. Note that -+ * reading from the cache. This is probably a bug. Note that - * the cache is not used when the caller asked to return the - * entire keyblock. This is because the cache does not -- * associate the public key wit its primary key. */ -+ * associate the public key with its primary key. */ - pk_cache_entry_t ce; - for (ce = pk_cache; ce; ce = ce->next) - { -@@ -3724,11 +3726,18 @@ finish_lookup (kbnode_t keyblock, unsigned int req_usage, int want_exact, - PKT_public_key *pk; - int req_prim; - int diag_exactfound = 0; -+ int verify_mode = 0; - u32 curtime = make_timestamp (); - - if (r_flags) - *r_flags = 0; - -+ -+ /* The verify mode is used to change the behaviour so that we can -+ * return an expired or revoked key for signature verification. */ -+ verify_mode = ((req_usage & PUBKEY_USAGE_VERIFY) -+ && (req_usage & PUBKEY_USAGE_SIG)); -+ - #define USAGE_MASK (PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC|PUBKEY_USAGE_CERT) - req_usage &= USAGE_MASK; - /* In allow ADSK mode make sure both encryption bits are set. */ -@@ -3784,9 +3793,9 @@ finish_lookup (kbnode_t keyblock, unsigned int req_usage, int want_exact, - } - - if (DBG_LOOKUP) -- log_debug ("finish_lookup: checking key %08lX (%s)(req_usage=%x)\n", -+ log_debug ("finish_lookup: checking key %08lX (%s)(req_usage=%x%s)\n", - (ulong) keyid_from_pk (keyblock->pkt->pkt.public_key, NULL), -- foundk ? "one" : "all", req_usage); -+ foundk ? "one" : "all", req_usage, verify_mode? ",verify":""); - if (diag_exactfound && DBG_LOOKUP) - log_debug ("\texact search requested and found\n"); - -@@ -3850,28 +3859,29 @@ finish_lookup (kbnode_t keyblock, unsigned int req_usage, int want_exact, - } - - n_subkeys++; -- if (pk->flags.revoked) -+ if (!verify_mode && pk->flags.revoked) - { - if (DBG_LOOKUP) - log_debug ("\tsubkey has been revoked\n"); - n_revoked_or_expired++; - continue; - } -- if (pk->has_expired && !opt.ignore_expiration) -+ if (!verify_mode && pk->has_expired && !opt.ignore_expiration) - { - if (DBG_LOOKUP) - log_debug ("\tsubkey has expired\n"); - n_revoked_or_expired++; - continue; - } -- if (pk->timestamp > curtime && !opt.ignore_valid_from) -+ if (!verify_mode && pk->timestamp > curtime && !opt.ignore_valid_from) - { - if (DBG_LOOKUP) - log_debug ("\tsubkey not yet valid\n"); - continue; - } - -- if (want_secret) -+ -+ if (!verify_mode && want_secret) - { - int secret_key_avail = agent_probe_secret_key (NULL, pk); - -@@ -3898,7 +3908,8 @@ finish_lookup (kbnode_t keyblock, unsigned int req_usage, int want_exact, - } - - if (DBG_LOOKUP) -- log_debug ("\tsubkey might be fine\n"); -+ log_debug ("\tsubkey might be fine%s\n", -+ verify_mode? " for verification":""); - /* In case a key has a timestamp of 0 set, we make sure - that it is used. A better change would be to compare - ">=" but that might also change the selected keys and -@@ -3939,12 +3950,12 @@ finish_lookup (kbnode_t keyblock, unsigned int req_usage, int want_exact, - log_debug ("\tprimary key usage does not match: " - "want=%x have=%x\n", req_usage, pk->pubkey_usage); - } -- else if (pk->flags.revoked) -+ else if (!verify_mode && pk->flags.revoked) - { - if (DBG_LOOKUP) - log_debug ("\tprimary key has been revoked\n"); - } -- else if (pk->has_expired) -+ else if (!verify_mode && pk->has_expired) - { - if (DBG_LOOKUP) - log_debug ("\tprimary key has expired\n"); -@@ -3952,7 +3963,8 @@ finish_lookup (kbnode_t keyblock, unsigned int req_usage, int want_exact, - else /* Okay. */ - { - if (DBG_LOOKUP) -- log_debug ("\tprimary key may be used\n"); -+ log_debug ("\tprimary key may be used%s\n", -+ verify_mode? " for verification":""); - latest_key = keyblock; - } - } -diff --git a/g10/packet.h b/g10/packet.h -index d6cbef4bc..9a1198d4a 100644 ---- a/g10/packet.h -+++ b/g10/packet.h -@@ -60,6 +60,7 @@ - #define PUBKEY_USAGE_RENC 1024 /* Restricted encryption. */ - #define PUBKEY_USAGE_TIME 2048 /* Timestamp use. */ - -+#define PUBKEY_USAGE_VERIFY 16384 /* Verify only modifier. */ - - /* The usage bits which can be derived from the algo. */ - #define PUBKEY_USAGE_BASIC_MASK (PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC\ --- -2.33.0 - diff --git a/backport-0005-CVE-2025-30258.patch b/backport-0005-CVE-2025-30258.patch deleted file mode 100644 index 71ca241df65a8bf502c0e09d8e7ddf3040b03024..0000000000000000000000000000000000000000 --- a/backport-0005-CVE-2025-30258.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 9b7c067717d815e16f9ea3cec88bca09a6cce7cb Mon Sep 17 00:00:00 2001 -From: Werner Koch -Date: Fri, 2 May 2025 11:11:05 +0200 -Subject: [PATCH] gpg: Fix another regression due to the T7547 fix. - -* g10/getkey.c (get_pubkey_for_sig): Keep a requested -PUBKEY_USAGE_CERT. -(finish_lookup): For correctness in future use cases allow -PUBKEY_USAGE_CERT to also trigger verify mode. --- - -The case here was that a cert-only primary key was removed with -export-clean. - -GnuPG-bug-id: 7583 ---- - g10/getkey.c | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -diff --git a/g10/getkey.c b/g10/getkey.c -index e3264062f..ae0e00220 100644 ---- a/g10/getkey.c -+++ b/g10/getkey.c -@@ -341,8 +341,10 @@ get_pubkey_for_sig (ctrl_t ctrl, PKT_public_key *pk, PKT_signature *sig, - /* Make sure to request only keys cabable of signing. This makes - * sure that a subkey w/o a valid backsig or with bad usage flags - * will be skipped. We also request the verification mode so that -- * expired and reoked keys are returned. */ -- pk->req_usage = (PUBKEY_USAGE_SIG | PUBKEY_USAGE_VERIFY); -+ * expired and revoked keys are returned. We keep only a requested -+ * CERT usage in PK for the sake of key signatures. */ -+ pk->req_usage = (PUBKEY_USAGE_SIG | PUBKEY_USAGE_VERIFY -+ | (pk->req_usage & PUBKEY_USAGE_CERT)); - - /* First try the ISSUER_FPR info. */ - fpr = issuer_fpr_raw (sig, &fprlen); -@@ -3736,7 +3738,7 @@ finish_lookup (kbnode_t keyblock, unsigned int req_usage, int want_exact, - /* The verify mode is used to change the behaviour so that we can - * return an expired or revoked key for signature verification. */ - verify_mode = ((req_usage & PUBKEY_USAGE_VERIFY) -- && (req_usage & PUBKEY_USAGE_SIG)); -+ && (req_usage & (PUBKEY_USAGE_CERT|PUBKEY_USAGE_SIG))); - - #define USAGE_MASK (PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC|PUBKEY_USAGE_CERT) - req_usage &= USAGE_MASK; --- -2.43.0 - diff --git a/backport-gpg-Fix-double-free-of-internal-data.patch b/backport-gpg-Fix-double-free-of-internal-data.patch deleted file mode 100644 index 4b2f9669aeb231cf3511ca6415191e464c8a9150..0000000000000000000000000000000000000000 --- a/backport-gpg-Fix-double-free-of-internal-data.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 4be25979a6b3e2a79d7c9667b07db8b09fb046e9 Mon Sep 17 00:00:00 2001 -From: Werner Koch -Date: Thu, 13 Mar 2025 11:35:34 +0100 -Subject: [PATCH] gpg: Fix double free of internal data. - -* g10/sig-check.c (check_signature_over_key_or_uid): Do not free in -no-sig-cache mode if allocated by caller. --- - -GnuPG-bug-id: 7547 -Fixes-commit: 44cdb9d73f1a0b7d2c8483a119b9c4d6caabc1ec ---- - g10/sig-check.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/g10/sig-check.c b/g10/sig-check.c -index 456c29320..ed83c23f9 100644 ---- a/g10/sig-check.c -+++ b/g10/sig-check.c -@@ -1007,7 +1007,8 @@ check_signature_over_key_or_uid (ctrl_t ctrl, PKT_public_key *signer, - rc = get_pubkey_for_sig (ctrl, signer, sig, NULL, NULL); - if (rc) - { -- xfree (signer); -+ if (signer_alloced != 1) -+ xfree (signer); - signer = NULL; - signer_alloced = 0; - goto leave; --- -2.33.0 - diff --git a/gnupg-2.4.7.tar.bz2 b/gnupg-2.4.7.tar.bz2 deleted file mode 100644 index 231de454dfab065c5d619733e6c663159accabfe..0000000000000000000000000000000000000000 Binary files a/gnupg-2.4.7.tar.bz2 and /dev/null differ diff --git a/gnupg-2.4.7.tar.bz2.sig b/gnupg-2.4.7.tar.bz2.sig deleted file mode 100644 index 28237895b76f3ad48a526bd48f3a8fe68d8d1185..0000000000000000000000000000000000000000 Binary files a/gnupg-2.4.7.tar.bz2.sig and /dev/null differ diff --git a/gnupg-2.2.18-gpg-allow-import-of-previously-known-keys-even-without-UI.patch b/gnupg-2.4.8-gpg-allow-import-of-previously-known-keys-even-without-UI.patch similarity index 90% rename from gnupg-2.2.18-gpg-allow-import-of-previously-known-keys-even-without-UI.patch rename to gnupg-2.4.8-gpg-allow-import-of-previously-known-keys-even-without-UI.patch index 3af14ba4fe914fc2232f012958a5f4a5c4fe38ec..c3af71e80d7bd13a46bea5548d4b0efb765815a6 100644 --- a/gnupg-2.2.18-gpg-allow-import-of-previously-known-keys-even-without-UI.patch +++ b/gnupg-2.4.8-gpg-allow-import-of-previously-known-keys-even-without-UI.patch @@ -18,18 +18,18 @@ Signed-off-by: Daniel Kahn Gillmor 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/g10/import.c b/g10/import.c -index 9fab46ca6..c70a6221c 100644 +index 9adda3e..6bb9769 100644 --- a/g10/import.c +++ b/g10/import.c -@@ -1954,7 +1954,6 @@ import_one_real (ctrl_t ctrl, - size_t an; +@@ -1995,7 +1995,6 @@ import_one_real (ctrl_t ctrl, + int non_self_or_utk = 0; char pkstrbuf[PUBKEY_STRING_SIZE]; int merge_keys_done = 0; - int any_filter = 0; KEYDB_HANDLE hd = NULL; if (r_valid) -@@ -1991,14 +1990,6 @@ import_one_real (ctrl_t ctrl, +@@ -2032,14 +2031,6 @@ import_one_real (ctrl_t ctrl, log_printf ("\n"); } @@ -44,7 +44,7 @@ index 9fab46ca6..c70a6221c 100644 if (screener && screener (keyblock, screener_arg)) { log_error (_("key %s: %s\n"), keystr_from_pk (pk), -@@ -2078,18 +2069,10 @@ import_one_real (ctrl_t ctrl, +@@ -2133,18 +2124,10 @@ import_one_real (ctrl_t ctrl, } } @@ -67,7 +67,7 @@ index 9fab46ca6..c70a6221c 100644 /* Get rid of deleted nodes. */ commit_kbnode (&keyblock); -@@ -2099,24 +2082,11 @@ import_one_real (ctrl_t ctrl, +@@ -2154,24 +2137,11 @@ import_one_real (ctrl_t ctrl, { apply_keep_uid_filter (ctrl, keyblock, import_filter.keep_uid); commit_kbnode (&keyblock); @@ -92,7 +92,7 @@ index 9fab46ca6..c70a6221c 100644 } /* The keyblock is valid and ready for real import. */ -@@ -2174,6 +2144,13 @@ import_one_real (ctrl_t ctrl, +@@ -2231,6 +2201,13 @@ import_one_real (ctrl_t ctrl, err = 0; stats->skipped_new_keys++; } diff --git a/gnupg-2.4.8.tar.bz2 b/gnupg-2.4.8.tar.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..19f4b9f07ae326e35d0c2d5f9b586f416f764607 --- /dev/null +++ b/gnupg-2.4.8.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b58c80d79b04d3243ff49c1c3fc6b5f83138eb3784689563bcdd060595318616 +size 8017685 diff --git a/gnupg-2.4.8.tar.bz2.sig b/gnupg-2.4.8.tar.bz2.sig new file mode 100644 index 0000000000000000000000000000000000000000..a37eda23567a6b536b78d65e454abcfabbce4db2 Binary files /dev/null and b/gnupg-2.4.8.tar.bz2.sig differ diff --git a/gnupg2.spec b/gnupg2.spec index bf7bc2a0c6ae8a84c7874b0dbb6cdf64944ccaaa..8f096fb9f31fd4cdfcc685cb9ace12b3551ec2d5 100644 --- a/gnupg2.spec +++ b/gnupg2.spec @@ -1,6 +1,6 @@ Name: gnupg2 -Version: 2.4.7 -Release: 6 +Version: 2.4.8 +Release: 1 Summary: Utility for secure communication and data storage License: CC0-1.0 AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-2.1-or-later AND LGPL-3.0-or-later AND (BSD-3-Clause OR LGPL-3.0-or-later OR GPL-2.0-or-later) AND CC-BY-4.0 AND MIT @@ -12,7 +12,7 @@ Patch0: gnupg-2.1.10-secmem.patch Patch1: gnupg-2.1.1-fips-algo.patch Patch2: gnupg-2.2.23-large-rsa.patch Patch4: gnupg-2.2.18-gpg-accept-subkeys-with-a-good-revocation-but-no-self-sig.patch -Patch5: gnupg-2.2.18-gpg-allow-import-of-previously-known-keys-even-without-UI.patch +Patch5: gnupg-2.4.8-gpg-allow-import-of-previously-known-keys-even-without-UI.patch Patch6: gnupg-2.2.18-tests-add-test-cases-for-import-without-uid.patch Patch7: gnupg-2.4.4-file-is-digest.patch Patch8: gnupg-2.2.21-coverity.patch @@ -20,27 +20,23 @@ Patch9: gnupg2-revert-rfc4880bis.patch # https://lists.gnupg.org/pipermail/gnupg-devel/2024-July/035627.html Patch10: gnupg-2.4.5-do-install-expired-ca.patch Patch13: supports-sm2-algorithm-signature-and-uses-sm3-hash-algorithm.patch -Patch14: backport-0001-CVE-2025-30258.patch -Patch15: backport-0002-CVE-2025-30258.patch -Patch16: backport-0003-CVE-2025-30258.patch -Patch17: backport-0004-CVE-2025-30258.patch -Patch18: backport-0005-CVE-2025-30258.patch -Patch19: backport-gpg-Fix-double-free-of-internal-data.patch BuildRequires: gcc BuildRequires: autoconf automake -BuildRequires: zlib-devel, npth-devel, texinfo +BuildRequires: zlib-devel, bzip2-devel, npth-devel, texinfo BuildRequires: libgpg-error-devel >= 1.46 BuildRequires: libgcrypt-devel >= 1.10.2-3 BuildRequires: libksba-devel >= 1.6.3 BuildRequires: libassuan-devel >= 2.5.0 BuildRequires: sqlite-devel >= 3.27 +BuildRequires: readline-devel # compile dirmngr module, need gnutls BuildRequires: gnutls-devel >= 3.2 BuildRequires: gettext-devel >= 0.17 Requires: libgcrypt >= 1.10.2-3 Requires: libgpg-error >= 1.46 +Requires: npth >= %(rpm -q --queryformat="%%{VERSION}" npth) Recommends: pinentry Recommends: gnupg2-smime @@ -129,6 +125,10 @@ rm -f %{buildroot}%{_infodir}/dir %changelog +* Thu May 15 2025 Funda Wang - 2.4.8-1 +- update to 2.4.8 +- bump ntph version requirement due to conditioned version comparation code used + * Tue May 6 2025 yixiangzhike - 2.4.7-6 - backport follow-up patch for CVE-2025-30258