Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ibigbug committed Dec 31, 2023
1 parent 7f4571c commit 3ba5b65
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions clash_lib/src/common/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ use aes_gcm::{AeadInPlace, KeyInit};
pub fn aes_cfb_encrypt(key: &[u8], iv: &[u8], data: &mut [u8]) -> anyhow::Result<()> {
match key.len() {
16 => {
cfb_mode::Encryptor::<aes::Aes256>::new(key.into(), iv.into()).encrypt(data);
cfb_mode::Encryptor::<aes::Aes128>::new(key.into(), iv.into()).encrypt(data);
Ok(())
}
24 => {
cfb_mode::Encryptor::<aes::Aes192>::new(key.into(), iv.into()).encrypt(data);
Ok(())
}
32 => {
cfb_mode::Encryptor::<aes::Aes128>::new(key.into(), iv.into()).encrypt(data);
cfb_mode::Encryptor::<aes::Aes256>::new(key.into(), iv.into()).encrypt(data);
Ok(())
}
_ => anyhow::bail!("invalid key length"),
Expand All @@ -27,15 +27,15 @@ pub fn aes_cfb_encrypt(key: &[u8], iv: &[u8], data: &mut [u8]) -> anyhow::Result
pub fn aes_cfb_decrypt(key: &[u8], iv: &[u8], data: &mut [u8]) -> anyhow::Result<()> {
match key.len() {
16 => {
cfb_mode::Decryptor::<aes::Aes256>::new(key.into(), iv.into()).decrypt(data);
cfb_mode::Decryptor::<aes::Aes128>::new(key.into(), iv.into()).decrypt(data);
Ok(())
}
24 => {
cfb_mode::Decryptor::<aes::Aes192>::new(key.into(), iv.into()).decrypt(data);
Ok(())
}
32 => {
cfb_mode::Decryptor::<aes::Aes128>::new(key.into(), iv.into()).decrypt(data);
cfb_mode::Decryptor::<aes::Aes256>::new(key.into(), iv.into()).decrypt(data);
Ok(())
}
_ => anyhow::bail!("invalid key length"),
Expand Down
3 changes: 1 addition & 2 deletions clash_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,12 +471,11 @@ mod tests {
use std::time::Duration;

#[test]
#[ignore]
fn start_and_stop() {
let conf = r#"
socks-port: 7891
bind-address: 127.0.0.1
mmdb: "clash_lib/tests/data/Country.mmdb"
mmdb: "tests/data/Country.mmdb"
"#;

let handle = thread::spawn(|| {
Expand Down

0 comments on commit 3ba5b65

Please sign in to comment.