@@ -1095,6 +1095,10 @@ mod tests {
10951095 const S_EM_SETUPCODE : & str = "1742-0185-6197-1303-7016-8412-3581-4441-0597" ;
10961096 const S_EM_SETUPFILE : & str = include_str ! ( "../test-data/message/stress.txt" ) ;
10971097
1098+ // Autocrypt Setup Message payload "encrypted" with plaintext algorithm.
1099+ const S_PLAINTEXT_SETUPFILE : & str =
1100+ include_str ! ( "../test-data/message/plaintext-autocrypt-setup.txt" ) ;
1101+
10981102 #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
10991103 async fn test_split_and_decrypt ( ) {
11001104 let buf_1 = S_EM_SETUPFILE . as_bytes ( ) . to_vec ( ) ;
@@ -1118,6 +1122,23 @@ mod tests {
11181122 assert ! ( headers. get( HEADER_SETUPCODE ) . is_none( ) ) ;
11191123 }
11201124
1125+ /// Tests that Autocrypt Setup Message encrypted with "plaintext" algorithm cannot be
1126+ /// decrypted.
1127+ ///
1128+ /// According to <https://datatracker.ietf.org/doc/html/rfc4880#section-13.4>
1129+ /// "Implementations MUST NOT use plaintext in Symmetrically Encrypted Data packets".
1130+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
1131+ async fn test_decrypt_plaintext_autocrypt_setup_message ( ) {
1132+ let setup_file = S_PLAINTEXT_SETUPFILE . to_string ( ) ;
1133+ let incorrect_setupcode = "0000-0000-0000-0000-0000-0000-0000-0000-0000" ;
1134+ assert ! ( decrypt_setup_file(
1135+ incorrect_setupcode,
1136+ std:: io:: Cursor :: new( setup_file. as_bytes( ) ) ,
1137+ )
1138+ . await
1139+ . is_err( ) ) ;
1140+ }
1141+
11211142 #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
11221143 async fn test_key_transfer ( ) -> Result < ( ) > {
11231144 let alice = TestContext :: new_alice ( ) . await ;
0 commit comments