Skip to content

Commit 098084b

Browse files
committed
feat: temporarily disable OpenPGP recipient anonymization
1 parent 9bc2aee commit 098084b

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

src/e2ee.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,22 @@ impl EncryptHelper {
4646
keyring: Vec<SignedPublicKey>,
4747
mail_to_encrypt: MimePart<'static>,
4848
compress: bool,
49+
anonymous_recipients: bool,
4950
) -> Result<String> {
5051
let sign_key = load_self_secret_key(context).await?;
5152

5253
let mut raw_message = Vec::new();
5354
let cursor = Cursor::new(&mut raw_message);
5455
mail_to_encrypt.clone().write_part(cursor).ok();
5556

56-
let ctext = pgp::pk_encrypt(raw_message, keyring, Some(sign_key), compress).await?;
57+
let ctext = pgp::pk_encrypt(
58+
raw_message,
59+
keyring,
60+
Some(sign_key),
61+
compress,
62+
anonymous_recipients,
63+
)
64+
.await?;
5765

5866
Ok(ctext)
5967
}

src/mimefactory.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,11 +1178,28 @@ impl MimeFactory {
11781178
let mut encryption_keyring = vec![encrypt_helper.public_key.clone()];
11791179
encryption_keyring.extend(encryption_keys.iter().map(|(_addr, key)| (*key).clone()));
11801180

1181+
// Do not anonymize OpenPGP recipients.
1182+
//
1183+
// This is disabled to avoid interoperability problems
1184+
// with old core versions <1.160.0 that do not support
1185+
// receiving messages with wildcard Key IDs:
1186+
// <https://github.com/chatmail/core/issues/7378>
1187+
//
1188+
// The option should be changed to true
1189+
// once new core versions are sufficiently deployed.
1190+
let anonymous_recipients = false;
1191+
11811192
// XXX: additional newline is needed
11821193
// to pass filtermail at
11831194
// <https://github.com/deltachat/chatmail/blob/4d915f9800435bf13057d41af8d708abd34dbfa8/chatmaild/src/chatmaild/filtermail.py#L84-L86>
11841195
let encrypted = encrypt_helper
1185-
.encrypt(context, encryption_keyring, message, compress)
1196+
.encrypt(
1197+
context,
1198+
encryption_keyring,
1199+
message,
1200+
compress,
1201+
anonymous_recipients,
1202+
)
11861203
.await?
11871204
+ "\n";
11881205

src/pgp.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ pub async fn pk_encrypt(
166166
public_keys_for_encryption: Vec<SignedPublicKey>,
167167
private_key_for_signing: Option<SignedSecretKey>,
168168
compress: bool,
169+
anonymous_recipients: bool,
169170
) -> Result<String> {
170171
Handle::current()
171172
.spawn_blocking(move || {
@@ -178,7 +179,11 @@ pub async fn pk_encrypt(
178179
let msg = MessageBuilder::from_bytes("", plain);
179180
let mut msg = msg.seipd_v1(&mut rng, SYMMETRIC_KEY_ALGORITHM);
180181
for pkey in pkeys {
181-
msg.encrypt_to_key_anonymous(&mut rng, &pkey)?;
182+
if anonymous_recipients {
183+
msg.encrypt_to_key_anonymous(&mut rng, &pkey)?;
184+
} else {
185+
msg.encrypt_to_key(&mut rng, &pkey)?;
186+
}
182187
}
183188

184189
if let Some(ref skey) = private_key_for_signing {
@@ -434,6 +439,7 @@ mod tests {
434439

435440
/// A ciphertext encrypted to Alice & Bob, signed by Alice.
436441
async fn ctext_signed() -> &'static String {
442+
let anonymous_recipients = true;
437443
CTEXT_SIGNED
438444
.get_or_init(|| async {
439445
let keyring = vec![KEYS.alice_public.clone(), KEYS.bob_public.clone()];
@@ -444,6 +450,7 @@ mod tests {
444450
keyring,
445451
Some(KEYS.alice_secret.clone()),
446452
compress,
453+
anonymous_recipients,
447454
)
448455
.await
449456
.unwrap()
@@ -453,14 +460,21 @@ mod tests {
453460

454461
/// A ciphertext encrypted to Alice & Bob, not signed.
455462
async fn ctext_unsigned() -> &'static String {
463+
let anonymous_recipients = true;
456464
CTEXT_UNSIGNED
457465
.get_or_init(|| async {
458466
let keyring = vec![KEYS.alice_public.clone(), KEYS.bob_public.clone()];
459467
let compress = true;
460468

461-
pk_encrypt(CLEARTEXT.to_vec(), keyring, None, compress)
462-
.await
463-
.unwrap()
469+
pk_encrypt(
470+
CLEARTEXT.to_vec(),
471+
keyring,
472+
None,
473+
compress,
474+
anonymous_recipients,
475+
)
476+
.await
477+
.unwrap()
464478
})
465479
.await
466480
}

0 commit comments

Comments
 (0)