Skip to content

Commit

Permalink
Add decryption test for Envelope::decrypt.
Browse files Browse the repository at this point in the history
  • Loading branch information
rubdos committed Jul 13, 2020
1 parent 03d91e4 commit 2658326
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions libsignal-service/src/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,38 @@ pub(crate) const VERSION_LENGTH: usize = 1;
pub(crate) const IV_OFFSET: usize = VERSION_OFFSET + VERSION_LENGTH;
pub(crate) const IV_LENGTH: usize = 16;
pub(crate) const CIPHERTEXT_OFFSET: usize = IV_OFFSET + IV_LENGTH;

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn decrypt_envelope() {
// This is a real message, reencrypted with the zero-key.
let body = [
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, 32, 12, 100,
26, 157, 130, 210, 254, 174, 87, 45, 238, 126, 68, 39, 188, 171,
156, 16, 10, 138, 233, 73, 202, 52, 125, 102, 121, 182, 71, 148, 8,
3, 134, 149, 154, 67, 116, 40, 146, 253, 242, 196, 139, 203, 14,
174, 254, 78, 27, 47, 108, 60, 202, 60, 42, 210, 242, 58, 13, 185,
67, 147, 166, 191, 71, 164, 128, 81, 177, 199, 147, 252, 162, 229,
143, 98, 141, 222, 46, 83, 109, 82, 196, 109, 161, 40, 108, 207,
82, 53, 162, 205, 171, 33, 140, 5, 74, 76, 150, 22, 122, 176, 189,
228, 176, 234, 176, 13, 118, 181, 134, 35, 133, 164, 160, 205, 176,
32, 188, 185, 166, 73, 24, 164, 20, 187, 2, 226, 186, 238, 98, 57,
51, 76, 156, 83, 113, 72, 184, 50, 220, 49, 138, 46, 36, 4, 49,
215, 66, 173, 58, 139, 187, 6, 252, 97, 191, 69, 246, 82, 48, 177,
11, 149, 168, 93, 15, 170, 125, 131, 101, 103, 253, 177, 165, 71,
85, 219, 207, 106, 12, 58, 47, 159, 33, 243, 107, 6, 117, 141, 209,
115, 207, 19, 236, 137, 195, 230, 167, 225, 172, 99, 204, 113, 125,
69, 125, 97, 252, 90, 248, 198, 175, 240, 187, 246, 164, 220, 102,
7, 224, 124, 28, 170, 6, 4, 137, 155, 233, 85, 125, 93, 119, 97,
183, 114, 193, 10, 184, 191, 202, 109, 97, 116, 194, 152, 40, 46,
202, 49, 195, 138, 14, 2, 255, 44, 107, 160, 45, 150, 6, 78, 145,
99,
];

let signaling_key = [0u8; 52];
let _ = Envelope::decrypt(&body, &signaling_key, true).unwrap();
}
}

0 comments on commit 2658326

Please sign in to comment.