@@ -12,6 +12,7 @@ use crate::config::Config;
12
12
use crate :: constants:: { DC_GCL_FOR_FORWARDING , DC_GCL_NO_SPECIALS } ;
13
13
use crate :: download:: { DownloadState , MIN_DOWNLOAD_LIMIT } ;
14
14
use crate :: imap:: prefetch_should_download;
15
+ use crate :: imex:: { imex, ImexMode } ;
15
16
use crate :: message:: { self , Message } ;
16
17
use crate :: test_utils:: { get_chat_msg, TestContext , TestContextManager } ;
17
18
@@ -4016,6 +4017,37 @@ async fn test_download_later() -> Result<()> {
4016
4017
Ok ( ( ) )
4017
4018
}
4018
4019
4020
+ /// Malice can pretend they have the same address as Alice and sends a message encrypted to Alice's
4021
+ /// key but signed with another one. Alice must detect that this message is wrongly signed and not
4022
+ /// treat it as Autocrypt-encrypted.
4023
+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
4024
+ async fn test_outgoing_msg_forgery ( ) -> Result < ( ) > {
4025
+ let mut tcm = TestContextManager :: new ( ) ;
4026
+ let export_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
4027
+ let alice = & tcm. alice ( ) . await ;
4028
+ let alice_addr = & alice. get_config ( Config :: Addr ) . await ?. unwrap ( ) ;
4029
+ imex ( alice, ImexMode :: ExportSelfKeys , export_dir. path ( ) , None ) . await ?;
4030
+ // We need Bob only to encrypt the forged message to Alice's key, actually Bob doesn't
4031
+ // participate in the scenario.
4032
+ let bob = & TestContext :: new ( ) . await ;
4033
+ bob. configure_addr ( "bob@example.net" ) . await ;
4034
+ imex ( bob, ImexMode :: ImportSelfKeys , export_dir. path ( ) , None ) . await ?;
4035
+ let malice = & TestContext :: new ( ) . await ;
4036
+ malice. configure_addr ( alice_addr) . await ;
4037
+
4038
+ let malice_chat_id = tcm
4039
+ . send_recv_accept ( bob, malice, "hi from bob" )
4040
+ . await
4041
+ . chat_id ;
4042
+
4043
+ let sent_msg = malice. send_text ( malice_chat_id, "hi from malice" ) . await ;
4044
+ let msg = alice. recv_msg ( & sent_msg) . await ;
4045
+ assert_eq ! ( msg. state, MessageState :: OutDelivered ) ;
4046
+ assert ! ( !msg. get_showpadlock( ) ) ;
4047
+
4048
+ Ok ( ( ) )
4049
+ }
4050
+
4019
4051
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
4020
4052
async fn test_create_group_with_big_msg ( ) -> Result < ( ) > {
4021
4053
let mut tcm = TestContextManager :: new ( ) ;
0 commit comments