@@ -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