From 92067c400c9152b269e47cb335d844fdbcde2874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Tue, 25 Feb 2020 17:49:43 +0100 Subject: [PATCH] crypto: Test signature verification with an invalid key. --- src/crypto/machine.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/crypto/machine.rs b/src/crypto/machine.rs index 59568d6f..259a6fb9 100644 --- a/src/crypto/machine.rs +++ b/src/crypto/machine.rs @@ -322,4 +322,19 @@ mod test { ); assert!(ret.is_ok()); } + + #[test] + fn test_invalid_signature() { + let machine = OlmMachine::new(USER_ID, DEVICE_ID); + + let mut device_keys = machine.device_keys(); + + let ret = machine.verify_json( + &machine.user_id, + &machine.device_id, + "fake_key", + &mut device_keys, + ); + assert!(ret.is_err()); + } }