@@ -1095,6 +1095,10 @@ mod tests {
1095
1095
const S_EM_SETUPCODE : & str = "1742-0185-6197-1303-7016-8412-3581-4441-0597" ;
1096
1096
const S_EM_SETUPFILE : & str = include_str ! ( "../test-data/message/stress.txt" ) ;
1097
1097
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
+
1098
1102
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
1099
1103
async fn test_split_and_decrypt ( ) {
1100
1104
let buf_1 = S_EM_SETUPFILE . as_bytes ( ) . to_vec ( ) ;
@@ -1118,6 +1122,23 @@ mod tests {
1118
1122
assert ! ( headers. get( HEADER_SETUPCODE ) . is_none( ) ) ;
1119
1123
}
1120
1124
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
+
1121
1142
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
1122
1143
async fn test_key_transfer ( ) -> Result < ( ) > {
1123
1144
let alice = TestContext :: new_alice ( ) . await ;
0 commit comments