From 02d8cade2a7c650481fc51da7aeec7c837852019 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Sun, 15 Aug 2021 20:04:29 -0400 Subject: [PATCH] correctly implement SDA compatible decryption --- Cargo.lock | 8 ++++---- src/accountmanager.rs | 12 +++++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index accc720..c9c29b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -950,9 +950,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.33" +version = "0.10.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a61075b62a23fef5a29815de7536d940aa35ce96d18ce0cc5076272db678a577" +checksum = "549430950c79ae24e6d02e0b7404534ecf311d94cc9f861e9e4020187d13d885" dependencies = [ "bitflags", "cfg-if", @@ -970,9 +970,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" [[package]] name = "openssl-sys" -version = "0.9.61" +version = "0.9.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "313752393519e876837e09e1fa183ddef0be7735868dced3196f4472d536277f" +checksum = "7a7907e3bfa08bb85105209cdfcb6c63d109f8f6c1ed6ca318fff5c1853fbc1d" dependencies = [ "autocfg 1.0.1", "cc", diff --git a/src/accountmanager.rs b/src/accountmanager.rs index 9eb53ab..59f17dd 100644 --- a/src/accountmanager.rs +++ b/src/accountmanager.rs @@ -1,5 +1,5 @@ use aes::Aes256; -use block_modes::block_padding::Pkcs7; +use block_modes::block_padding::NoPadding; use block_modes::{BlockMode, Cbc}; use log::*; use ring::pbkdf2; @@ -10,7 +10,7 @@ use std::path::Path; use std::sync::{Arc, Mutex}; use steamguard::SteamGuardAccount; -type Aes256Cbc = Cbc; +type Aes256Cbc = Cbc; #[derive(Debug, Serialize, Deserialize)] pub struct Manifest { @@ -102,9 +102,15 @@ impl Manifest { let key = get_encryption_key(&passkey.into(), ¶ms.salt)?; let iv = base64::decode(¶ms.iv)?; let cipher = Aes256Cbc::new_from_slices(&key, &iv)?; + let mut ciphertext: Vec = vec![]; reader.read_to_end(&mut ciphertext)?; - let decrypted = cipher.decrypt(&mut ciphertext)?; + ciphertext = base64::decode(ciphertext)?; + let size: usize = ciphertext.len() / 16 + 1; + let mut buffer = vec![0xffu8; 16 * size]; + buffer[..ciphertext.len()].copy_from_slice(&ciphertext); + let decrypted = cipher.clone().decrypt(&mut buffer[..ciphertext.len()])?; + account = serde_json::from_slice(decrypted)?; } (None, Some(_)) => {