From 7502b310d2697b7fe16957811f4c9bc096e9645d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Sun, 15 Sep 2024 16:18:18 +0100 Subject: [PATCH] refactor: ekey decrypt now return `Vec` instead. --- um_crypto/qmc/src/ekey.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/um_crypto/qmc/src/ekey.rs b/um_crypto/qmc/src/ekey.rs index 644acb8..26e3881 100644 --- a/um_crypto/qmc/src/ekey.rs +++ b/um_crypto/qmc/src/ekey.rs @@ -42,7 +42,7 @@ fn make_simple_key() -> [u8; N] { result } -pub fn decrypt_v1(ekey: &[u8]) -> Result> { +pub fn decrypt_v1(ekey: &[u8]) -> Result> { if ekey.len() < 12 { Err(EKeyDecryptError::EKeyTooShort)?; } @@ -58,10 +58,10 @@ pub fn decrypt_v1(ekey: &[u8]) -> Result> { .collect_vec(); let plaintext = tc_tea::decrypt(cipher, tea_key).map_err(EKeyDecryptError::FailDecryptV1)?; - Ok([header, &plaintext].concat().into()) + Ok([header, &plaintext].concat()) } -pub fn decrypt_v2(ekey: &[u8]) -> Result> { +pub fn decrypt_v2(ekey: &[u8]) -> Result> { let ekey = base64::decode(ekey)?; let ekey = tc_tea::decrypt(ekey, EKEY_V2_KEY1).map_err(EKeyDecryptError::FailDecryptV2)?; let ekey = tc_tea::decrypt(ekey, EKEY_V2_KEY2).map_err(EKeyDecryptError::FailDecryptV2)?; @@ -70,7 +70,7 @@ pub fn decrypt_v2(ekey: &[u8]) -> Result> { decrypt_v1(&ekey) } -pub fn decrypt>(ekey: T) -> Result> { +pub fn decrypt>(ekey: T) -> Result> { let ekey = ekey.as_ref(); match ekey.strip_prefix(EKEY_V2_PREFIX) { Some(v2_ekey) => decrypt_v2(v2_ekey),