Skip to content

Commit 9599239

Browse files
committed
test: test that ASM "encrypted" with plaintext algorithm is not accepted
1 parent 0efbe67 commit 9599239

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/imex.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0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