chore(deps): update cargo dependencies (#7377)

* chore(deps): update cargo dependencies

* fix aes feature

* fix: update aes-gcm nonce conversion

* refactor: use aes-gcm key init api

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Tunglies <77394545+Tunglies@users.noreply.github.com>
This commit is contained in:
renovate[bot]
2026-07-06 06:14:15 +00:00
committed by GitHub
co-authored by renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Tunglies
parent d4118295a3
commit 8bf5fc1aca
4 changed files with 38 additions and 71 deletions
+3 -3
View File
@@ -56,7 +56,7 @@ serde_yaml_ng = { workspace = true }
smartstring = { workspace = true, features = ["serde"] }
bitflags = { workspace = true }
warp = { version = "0.4.3", features = ["server"] }
open = "5.3.5"
open = "5.3.6"
dunce = "1.0.5"
nanoid = "0.5"
chrono = "0.4.45"
@@ -83,7 +83,7 @@ tauri-plugin-deep-link = "2.4.9"
tauri-plugin-window-state = "2.4.1"
zip = "8.6.0"
reqwest_dav = "0.3.3"
aes-gcm = { version = "0.10.3", features = ["std"] }
aes-gcm = { version = "0.11.0" }
base64 = "0.22.1"
getrandom = "0.4.3"
futures = "0.3.32"
@@ -101,7 +101,7 @@ async-trait = "0.1.89"
clash_verge_service_ipc = { version = "2.3.2", features = [
"client",
], git = "https://github.com/clash-verge-rev/clash-verge-service-ipc" }
arc-swap = "1.9.1"
arc-swap = "1.9.2"
tokio-rustls = "0.26.4"
rustls = { version = "0.23.41", features = ["ring"] }
webpki-roots = "1.0.8"
+7 -10
View File
@@ -1,6 +1,6 @@
use crate::utils::dirs::get_encryption_key;
use aes_gcm::{
Aes256Gcm, Key,
Aes256Gcm,
aead::{Aead as _, KeyInit as _},
};
use base64::{Engine as _, engine::general_purpose::STANDARD};
@@ -16,33 +16,29 @@ tokio::task_local! {
}
/// Encrypt data
#[allow(deprecated)]
pub fn encrypt_data(data: &str) -> Result<String, Box<dyn std::error::Error>> {
let encryption_key = get_encryption_key()?;
let key = Key::<Aes256Gcm>::from_slice(&encryption_key);
let cipher = Aes256Gcm::new(key);
let cipher = Aes256Gcm::new_from_slice(&encryption_key)?;
// Generate random nonce
let mut nonce = vec![0u8; NONCE_LENGTH];
let mut nonce = [0u8; NONCE_LENGTH];
getrandom::fill(&mut nonce)?;
// Encrypt data
let ciphertext = cipher
.encrypt(nonce.as_slice().into(), data.as_bytes())
.encrypt((&nonce).into(), data.as_bytes())
.map_err(|e| format!("Encryption failed: {e}"))?;
// Concatenate nonce and ciphertext and encode them in base64
let mut combined = nonce;
let mut combined = nonce.to_vec();
combined.extend(ciphertext);
Ok(STANDARD.encode(combined))
}
/// Decrypt data
#[allow(deprecated)]
pub fn decrypt_data(encrypted: &str) -> Result<String, Box<dyn std::error::Error>> {
let encryption_key = get_encryption_key()?;
let key = Key::<Aes256Gcm>::from_slice(&encryption_key);
let cipher = Aes256Gcm::new(key);
let cipher = Aes256Gcm::new_from_slice(&encryption_key)?;
// Decode from base64
let data = STANDARD.decode(encrypted)?;
if data.len() < NONCE_LENGTH {
@@ -51,6 +47,7 @@ pub fn decrypt_data(encrypted: &str) -> Result<String, Box<dyn std::error::Error
// Separate nonce and ciphertext
let (nonce, ciphertext) = data.split_at(NONCE_LENGTH);
let nonce: &[u8; NONCE_LENGTH] = nonce.try_into()?;
// Decrypt data
let plaintext = cipher