1
0
Fork 0
mirror of https://github.com/librespot-org/librespot.git synced 2025-10-04 10:19:27 +02:00

Merge branch 'dev' into tokio_migration

This commit is contained in:
johannesd3 2021-02-23 14:45:01 +01:00 committed by Johannesd3
commit 678d1777fd
32 changed files with 674 additions and 360 deletions

View file

@ -1,5 +1,5 @@
use byteorder::{BigEndian, ByteOrder, WriteBytesExt};
use hmac::{Hmac, Mac};
use hmac::{Hmac, Mac, NewMac};
use protobuf::{self, Message};
use rand::thread_rng;
use sha1::Sha1;
@ -122,16 +122,16 @@ fn compute_keys(shared_secret: &[u8], packets: &[u8]) -> (Vec<u8>, Vec<u8>, Vec<
let mut data = Vec::with_capacity(0x64);
for i in 1..6 {
let mut mac = HmacSha1::new_varkey(&shared_secret).expect("HMAC can take key of any size");
mac.input(packets);
mac.input(&[i]);
data.extend_from_slice(&mac.result().code());
mac.update(packets);
mac.update(&[i]);
data.extend_from_slice(&mac.finalize().into_bytes());
}
let mut mac = HmacSha1::new_varkey(&data[..0x14]).expect("HMAC can take key of any size");
mac.input(packets);
mac.update(packets);
(
mac.result().code().to_vec(),
mac.finalize().into_bytes().to_vec(),
data[0x14..0x34].to_vec(),
data[0x34..0x54].to_vec(),
)