aboutsummaryrefslogtreecommitdiffstats
path: root/g10/packet.h
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2025-09-26 12:43:39 +0000
committerWerner Koch <[email protected]>2025-09-26 12:46:14 +0000
commit600df5259db0b7be25a2e2b06c0c2d13265eceea (patch)
treea019d82c85e29353a3988fb761ea1b8ce4bb2467 /g10/packet.h
parentw32: Fix gnupg_isatty. (diff)
downloadgnupg-600df5259db0b7be25a2e2b06c0c2d13265eceea.tar.gz
gnupg-600df5259db0b7be25a2e2b06c0c2d13265eceea.zip
gpg: Detect duplicate keys with --add-recipients.
* g10/packet.h (struct pubkey_enc_list): Change to use a union to also store symkey_enc data. Adjust all users accordingly. (struct pubkey_enc_info_item): New. * g10/free-packet.c (free_pubkey_enc_list): New. * g10/mainproc.c (release_list): Use it here. * g10/decrypt.c (decrypt_message): and here. * g10/encrypt.c (reencrypt_to_new_recipients): Record the used pubkey_enc packets and pass them to write_pubkey_enc_from_list. (write_pubkey_enc_from_list): Add arg restrict_pk_list and use it to skip recipients already used. -- GnuPG-bug-id: 1825 Note that we here already prepare to better handle symkey_enc packets.
Diffstat (limited to 'g10/packet.h')
-rw-r--r--g10/packet.h25
1 files changed, 22 insertions, 3 deletions
diff --git a/g10/packet.h b/g10/packet.h
index 6b1be6fc8..52f9aef8f 100644
--- a/g10/packet.h
+++ b/g10/packet.h
@@ -166,17 +166,34 @@ typedef struct {
/* Whether to hide the key id. This value is not directly
serialized. */
byte throw_keyid;
- /* The session key. */
+ /* The encrypted session key. */
gcry_mpi_t data[PUBKEY_MAX_NENC];
} PKT_pubkey_enc;
-/* An object to build a list of public-key encrypted session key. */
+/* An object to build a list of public-key and symkey encrypted
+ * session key. Note that we use a dedicated uinion here instead of
+ * the usual PACKET type; this the need for extra allocations. */
struct pubkey_enc_list
{
struct pubkey_enc_list *next;
int result;
- PKT_pubkey_enc d;
+ int u_sym; /* Use the sym member. */
+ union {
+ PKT_pubkey_enc pub;
+ PKT_symkey_enc sym;
+ } u;
+};
+
+
+/* An object to record some properties of a PKT_pubkey_enc packet. */
+struct pubkey_enc_info_item
+{
+ struct pubkey_enc_info_item *next;
+ /* 3 fields copied from a PKT_pubkey_enc: */
+ u32 keyid[2];
+ byte version;
+ byte pubkey_algo;
};
@@ -945,6 +962,8 @@ PKT_public_key *copy_public_key( PKT_public_key *d, PKT_public_key *s );
PKT_signature *copy_signature( PKT_signature *d, PKT_signature *s );
PKT_user_id *scopy_user_id (PKT_user_id *sd );
+void free_pubkey_enc_list (struct pubkey_enc_list *pkenc_list);
+
int cmp_public_keys( PKT_public_key *a, PKT_public_key *b );
int cmp_signatures( PKT_signature *a, PKT_signature *b );
int cmp_user_ids( PKT_user_id *a, PKT_user_id *b );