Skip to content

Commit

Permalink
check that we fail to decrypt with the wrong key
Browse files Browse the repository at this point in the history
  • Loading branch information
uhoreg committed Dec 2, 2024
1 parent 7c50703 commit b917884
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/olm/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1479,4 +1479,29 @@ mod test {

Ok(())
}

#[test]
fn fails_to_rehydrate_with_wrong_key() -> Result<()> {
let mut alice = Account::new();

alice.generate_one_time_keys(alice.max_number_of_one_time_keys());
alice.generate_fallback_key();

let alice_dehydrated =
alice.to_dehydrated_device(&PICKLE_KEY).expect("Should be able to dehydrate device");

assert!(Account::from_dehydrated_device(
&alice_dehydrated,
&alice.curve25519_key().to_base64(),
&[1; 32],
).is_err());

assert!(Account::from_dehydrated_device(
&alice_dehydrated,
&"WrongDeviceID",
&PICKLE_KEY,
).is_err());

Ok(())
}
}

0 comments on commit b917884

Please sign in to comment.