Fixed encryption changes not being written

This commit is contained in:
Carson McManus 2016-08-23 13:49:52 -04:00
parent c0c14e1fc3
commit 1b6a702593
2 changed files with 9 additions and 6 deletions

View file

@ -304,8 +304,8 @@ public class Manifest
public bool SaveAccount(SteamGuardAccount account, bool encrypt, string passKey = null, string salt = null, string iV = null) public bool SaveAccount(SteamGuardAccount account, bool encrypt, string passKey = null, string salt = null, string iV = null)
{ {
if (encrypt && String.IsNullOrEmpty(passKey)) return false; if (encrypt && (String.IsNullOrEmpty(passKey) || String.IsNullOrEmpty(salt) || String.IsNullOrEmpty(iV))) return false;
if (!encrypt && this.Encrypted) return false; //if (!encrypt && this.Encrypted) return false;
string jsonAccount = JsonConvert.SerializeObject(account); string jsonAccount = JsonConvert.SerializeObject(account);
@ -337,7 +337,7 @@ public class Manifest
} }
bool wasEncrypted = this.Encrypted; bool wasEncrypted = this.Encrypted;
this.Encrypted = encrypt || this.Encrypted; this.Encrypted = encrypt;// || this.Encrypted;
if (!this.Save()) if (!this.Save())
{ {
@ -351,7 +351,7 @@ public class Manifest
MemoryStream ms = null; MemoryStream ms = null;
RijndaelManaged aes256; RijndaelManaged aes256;
if (Encrypted) if (encrypt)
{ {
ms = new MemoryStream(); ms = new MemoryStream();
byte[] key = GetEncryptionKey(passKey, newEntry.Salt); byte[] key = GetEncryptionKey(passKey, newEntry.Salt);
@ -377,7 +377,7 @@ public class Manifest
writer.Write(jsonAccount); writer.Write(jsonAccount);
} }
if (Encrypted) if (encrypt)
{ {
File.WriteAllText(Path.Combine(Program.SteamGuardPath, newEntry.Filename), Convert.ToBase64String(ms.ToArray())); File.WriteAllText(Path.Combine(Program.SteamGuardPath, newEntry.Filename), Convert.ToBase64String(ms.ToArray()));
} }

View file

@ -185,7 +185,10 @@ public static class Program
for (int i = 0; i < SteamGuardAccounts.Length; i++) for (int i = 0; i < SteamGuardAccounts.Length; i++)
{ {
var account = SteamGuardAccounts[i]; var account = SteamGuardAccounts[i];
bool success = Manifest.SaveAccount(account, true, newPassKey, Manifest.GetRandomSalt(), Manifest.GetInitializationVector()); var salt = Manifest.GetRandomSalt();
var iv = Manifest.GetInitializationVector();
if (Program.Verbose) Console.WriteLine($"New encryption info: pass: {newPassKey}, salt: {salt}, iv: {iv}");
bool success = Manifest.SaveAccount(account, true, newPassKey, salt, iv);
if (Verbose) Console.WriteLine("Encrypted {0}: {1}", account.AccountName, success); if (Verbose) Console.WriteLine("Encrypted {0}: {1}", account.AccountName, success);
} }
} }