diff --git a/src/netmd/base.rs b/src/netmd/base.rs index 2335d81..c4a2e4b 100644 --- a/src/netmd/base.rs +++ b/src/netmd/base.rs @@ -69,6 +69,15 @@ pub static DEVICE_IDS: Lazy> = Lazy::new(|| { } }); +pub static DEVICE_IDS_CROSSUSB: Lazy> = Lazy::new(|| { + DEVICE_IDS.iter().map(|d|{ + cross_usb::device_filter! { + vendor_id: d.vendor_id, + product_id: d.product_id, + } + }).collect() +}); + /// The current status of the Minidisc device pub enum Status { Ready, diff --git a/src/netmd/encryption.rs b/src/netmd/encryption.rs index a0672b7..285dc6c 100644 --- a/src/netmd/encryption.rs +++ b/src/netmd/encryption.rs @@ -22,12 +22,11 @@ pub fn new_thread_encryptor( rand::thread_rng().fill_bytes(&mut random_key); // Encrypt it with the kek - let mut encrypted_random_key = random_key.clone(); - match DesEcbEnc::new(&input.kek.into()) + let mut encrypted_random_key = random_key; + if let Err(x) = DesEcbEnc::new(&input.kek.into()) .decrypt_padded_mut::(&mut encrypted_random_key) { - Err(x) => panic!("Cannot create main key {:?}", x), - Ok(_) => {} + panic!("Cannot create main key {:?}", x) }; let default_chunk_size = match input.chunk_size { diff --git a/src/netmd/interface.rs b/src/netmd/interface.rs index 53c81ad..252c8d8 100644 --- a/src/netmd/interface.rs +++ b/src/netmd/interface.rs @@ -1531,6 +1531,7 @@ impl NetMDInterface { Ok(()) } + #[allow(clippy::too_many_arguments)] pub async fn send_track( &mut self, wireformat: u8, @@ -1587,7 +1588,7 @@ impl NetMDInterface { _written_bytes += binpack.len(); packet_count += 1; (progress_callback)(total_bytes, _written_bytes); - if total_bytes == _written_bytes.try_into().unwrap() { + if total_bytes == _written_bytes { packets.close(); break; } @@ -1652,7 +1653,7 @@ pub fn retailmac(key: &[u8], value: &[u8], iv: &[u8; 8]) -> Vec { let iv2 = &beginning[beginning.len() - 8..]; let mut wonky_key = [0u8; 24]; - wonky_key[0..16].clone_from_slice(&key); + wonky_key[0..16].clone_from_slice(key); wonky_key[16..].clone_from_slice(&key[0..8]); TDesCbcEnc::new(&wonky_key.into(), iv2.into()) .encrypt_padded_mut::(&mut end, 8) @@ -1717,6 +1718,8 @@ pub struct MDTrack { pub data: Vec, pub chunk_size: usize, pub full_width_title: Option, + + #[allow(clippy::type_complexity)] pub encrypt_packets_iterator: Box UnboundedReceiver<(Vec, Vec, Vec)>>, } @@ -1775,7 +1778,7 @@ impl MDTrack { pub fn get_encrypting_iterator(&mut self) -> UnboundedReceiver<(Vec, Vec, Vec)> { (self.encrypt_packets_iterator)(DataEncryptorInput { - kek: self.get_kek().clone(), + kek: self.get_kek(), frame_size: self.frame_size(), chunk_size: self.chunk_size(), data: std::mem::take(&mut self.data), @@ -1814,7 +1817,7 @@ impl<'a> MDSession<'a> { } pub async fn close(&mut self) -> Result<(), Box> { - if let None = self.hex_session_key { + if self.hex_session_key.is_none() { self.md.session_key_forget().await?; } self.hex_session_key = None; @@ -1831,14 +1834,14 @@ impl<'a> MDSession<'a> { where F: Fn(usize, usize), { - if let None = self.hex_session_key { + if self.hex_session_key.is_none() { return Err("Cannot download a track using a non-init()'ed session!".into()); } self.md .setup_download( &track.content_id(), &track.get_kek(), - &self.hex_session_key.as_ref().unwrap(), + self.hex_session_key.as_ref().unwrap(), ) .await?; let data_format = track.data_format(); @@ -1866,7 +1869,7 @@ impl<'a> MDSession<'a> { .await?; } self.md - .commit_track(track_index, &self.hex_session_key.as_ref().unwrap()) + .commit_track(track_index, self.hex_session_key.as_ref().unwrap()) .await?; Ok((track_index, uuid, ccid)) diff --git a/src/netmd/utils.rs b/src/netmd/utils.rs index 3f79e18..90622f8 100644 --- a/src/netmd/utils.rs +++ b/src/netmd/utils.rs @@ -173,7 +173,7 @@ pub fn agressive_sanitize_title(title: &str) -> String { .into() } -pub fn time_to_duration(time: &Vec) -> std::time::Duration { +pub fn time_to_duration(time: &[u64]) -> std::time::Duration { assert_eq!(time.len(), 4); std::time::Duration::from_micros( (time[0] * 3600000000) + (time[1] * 60000000) + (time[2] * 1000000) + (time[3] * 11600),