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.
This commit is contained in:
Paul Lietar 2016-01-02 13:30:01 +01:00
parent f8956166ea
commit 2c2ff16986

View file

@ -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()
};