diff --git a/um_crypto/qmc/src/v2_rc4/cipher.rs b/um_crypto/qmc/src/v2_rc4/cipher.rs index 40e9d01..ad63fba 100644 --- a/um_crypto/qmc/src/v2_rc4/cipher.rs +++ b/um_crypto/qmc/src/v2_rc4/cipher.rs @@ -17,13 +17,13 @@ pub struct QMC2RC4 { impl QMC2RC4 { pub fn new(key: &[u8]) -> Self { let mut rc4 = RC4::new(key); - let mut key_stream = [0u8; RC4_STREAM_CACHE_SIZE]; - rc4.derive(&mut key_stream); + let mut key_stream = Box::new([0u8; RC4_STREAM_CACHE_SIZE]); + rc4.derive(&mut key_stream[..]); Self { hash: hash(key), key: key.into(), - key_stream: key_stream.into(), + key_stream, } } diff --git a/um_crypto/qmc/src/v2_rc4/rc4.rs b/um_crypto/qmc/src/v2_rc4/rc4.rs index c7724e1..b273b52 100644 --- a/um_crypto/qmc/src/v2_rc4/rc4.rs +++ b/um_crypto/qmc/src/v2_rc4/rc4.rs @@ -42,8 +42,11 @@ impl RC4 { self.state[index] } - pub fn derive(&mut self, buffer: &mut [u8]) { - for item in buffer.iter_mut() { + pub fn derive(&mut self, buffer: &mut T) + where + T: AsMut<[u8]> + ?Sized, + { + for item in buffer.as_mut().iter_mut() { *item ^= self.generate(); } }