From 2c2ff16986b4d8e0965a88a49e829dbaaa316369 Mon Sep 17 00:00:00 2001 From: Paul Lietar Date: Sat, 2 Jan 2016 13:30:01 +0100 Subject: [PATCH] discovery: Truncate the AES key to 128 The computed key is 20 bytes long (SHA1 checksum), but it used for AES128. The last 4 bytes should therefore be dropped. --- src/discovery.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/discovery.rs b/src/discovery.rs index bc1528b..a720dfe 100644 --- a/src/discovery.rs +++ b/src/discovery.rs @@ -100,7 +100,7 @@ impl DiscoveryManager { let decrypted = { let mut data = vec![0u8; encrypted.len()]; - let mut cipher = crypto::aes::ctr(crypto::aes::KeySize::KeySize128, &encryption_key, &iv); + let mut cipher = crypto::aes::ctr(crypto::aes::KeySize::KeySize128, &encryption_key[0..16], &iv); cipher.process(&encrypted, &mut data); String::from_utf8(data).unwrap() };