diff --git a/ArchiSteamFarm/CryptoHelper.cs b/ArchiSteamFarm/ArchiCryptoHelper.cs similarity index 96% rename from ArchiSteamFarm/CryptoHelper.cs rename to ArchiSteamFarm/ArchiCryptoHelper.cs index be0cb244f..d729cd0b6 100644 --- a/ArchiSteamFarm/CryptoHelper.cs +++ b/ArchiSteamFarm/ArchiCryptoHelper.cs @@ -23,9 +23,10 @@ using System; using System.Security.Cryptography; using System.Text; using ArchiSteamFarm.Localization; +using SteamKit2; namespace ArchiSteamFarm { - internal static class CryptoHelper { + internal static class ArchiCryptoHelper { private static byte[] EncryptionKey = Encoding.UTF8.GetBytes(nameof(ArchiSteamFarm)); internal static string Decrypt(ECryptoMethod cryptoMethod, string encrypted) { @@ -88,7 +89,7 @@ namespace ArchiSteamFarm { } byte[] decryptedData = Convert.FromBase64String(encrypted); - decryptedData = SteamKit2.CryptoHelper.SymmetricDecrypt(decryptedData, key); + decryptedData = CryptoHelper.SymmetricDecrypt(decryptedData, key); return Encoding.UTF8.GetString(decryptedData); } catch (Exception e) { ASF.ArchiLogger.LogGenericException(e); @@ -132,7 +133,7 @@ namespace ArchiSteamFarm { } byte[] encryptedData = Encoding.UTF8.GetBytes(decrypted); - encryptedData = SteamKit2.CryptoHelper.SymmetricEncrypt(encryptedData, key); + encryptedData = CryptoHelper.SymmetricEncrypt(encryptedData, key); return Convert.ToBase64String(encryptedData); } catch (Exception e) { ASF.ArchiLogger.LogGenericException(e); @@ -169,4 +170,4 @@ namespace ArchiSteamFarm { ProtectedDataForCurrentUser } } -} \ No newline at end of file +} diff --git a/ArchiSteamFarm/ArchiWebHandler.cs b/ArchiSteamFarm/ArchiWebHandler.cs index bbf7a67f5..90a0984d9 100644 --- a/ArchiSteamFarm/ArchiWebHandler.cs +++ b/ArchiSteamFarm/ArchiWebHandler.cs @@ -984,7 +984,7 @@ namespace ArchiSteamFarm { string sessionID = Convert.ToBase64String(Encoding.UTF8.GetBytes(steamID.ToString())); // Generate an AES session key - byte[] sessionKey = SteamKit2.CryptoHelper.GenerateRandomBlock(32); + byte[] sessionKey = CryptoHelper.GenerateRandomBlock(32); // RSA encrypt it with the public key for the universe we're on byte[] cryptedSessionKey; @@ -997,7 +997,7 @@ namespace ArchiSteamFarm { Array.Copy(Encoding.ASCII.GetBytes(webAPIUserNonce), loginKey, webAPIUserNonce.Length); // AES encrypt the loginkey with our session key - byte[] cryptedLoginKey = SteamKit2.CryptoHelper.SymmetricEncrypt(loginKey, sessionKey); + byte[] cryptedLoginKey = CryptoHelper.SymmetricEncrypt(loginKey, sessionKey); // Do the magic Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.LoggingIn, ISteamUserAuth)); diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index 43bc78c3d..e7832bffb 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -1832,7 +1832,7 @@ namespace ArchiSteamFarm { if (File.Exists(SentryFilePath)) { try { byte[] sentryFileContent = await RuntimeCompatibility.File.ReadAllBytesAsync(SentryFilePath).ConfigureAwait(false); - sentryFileHash = SteamKit2.CryptoHelper.SHAHash(sentryFileContent); + sentryFileHash = CryptoHelper.SHAHash(sentryFileContent); } catch (Exception e) { ArchiLogger.LogGenericException(e); @@ -1850,8 +1850,8 @@ namespace ArchiSteamFarm { loginKey = BotDatabase.LoginKey; // Decrypt login key if needed - if (!string.IsNullOrEmpty(loginKey) && (loginKey.Length > 19) && (BotConfig.PasswordFormat != CryptoHelper.ECryptoMethod.PlainText)) { - loginKey = CryptoHelper.Decrypt(BotConfig.PasswordFormat, loginKey); + if (!string.IsNullOrEmpty(loginKey) && (loginKey.Length > 19) && (BotConfig.PasswordFormat != ArchiCryptoHelper.ECryptoMethod.PlainText)) { + loginKey = ArchiCryptoHelper.Decrypt(BotConfig.PasswordFormat, loginKey); } } else { // If we're not using login keys, ensure we don't have any saved @@ -2344,8 +2344,8 @@ namespace ArchiSteamFarm { } string loginKey = callback.LoginKey; - if (BotConfig.PasswordFormat != CryptoHelper.ECryptoMethod.PlainText) { - loginKey = CryptoHelper.Encrypt(BotConfig.PasswordFormat, loginKey); + if (BotConfig.PasswordFormat != ArchiCryptoHelper.ECryptoMethod.PlainText) { + loginKey = ArchiCryptoHelper.Encrypt(BotConfig.PasswordFormat, loginKey); } await BotDatabase.SetLoginKey(loginKey).ConfigureAwait(false); @@ -4127,7 +4127,7 @@ namespace ArchiSteamFarm { return FormatBotResponse(string.Format(Strings.ErrorIsEmpty, nameof(BotConfig.SteamPassword))); } - string response = FormatBotResponse(string.Format(Strings.BotEncryptedPassword, CryptoHelper.ECryptoMethod.AES, CryptoHelper.Encrypt(CryptoHelper.ECryptoMethod.AES, BotConfig.SteamPassword))) + FormatBotResponse(string.Format(Strings.BotEncryptedPassword, CryptoHelper.ECryptoMethod.ProtectedDataForCurrentUser, CryptoHelper.Encrypt(CryptoHelper.ECryptoMethod.ProtectedDataForCurrentUser, BotConfig.SteamPassword))); + string response = FormatBotResponse(string.Format(Strings.BotEncryptedPassword, ArchiCryptoHelper.ECryptoMethod.AES, ArchiCryptoHelper.Encrypt(ArchiCryptoHelper.ECryptoMethod.AES, BotConfig.SteamPassword))) + FormatBotResponse(string.Format(Strings.BotEncryptedPassword, ArchiCryptoHelper.ECryptoMethod.ProtectedDataForCurrentUser, ArchiCryptoHelper.Encrypt(ArchiCryptoHelper.ECryptoMethod.ProtectedDataForCurrentUser, BotConfig.SteamPassword))); return response; } diff --git a/ArchiSteamFarm/BotConfig.cs b/ArchiSteamFarm/BotConfig.cs index 4487776e4..f426f67eb 100644 --- a/ArchiSteamFarm/BotConfig.cs +++ b/ArchiSteamFarm/BotConfig.cs @@ -45,7 +45,7 @@ namespace ArchiSteamFarm { private const bool DefaultIdlePriorityQueueOnly = false; private const bool DefaultIdleRefundableGames = true; private const EPersonaState DefaultOnlineStatus = EPersonaState.Online; - private const CryptoHelper.ECryptoMethod DefaultPasswordFormat = CryptoHelper.ECryptoMethod.PlainText; + private const ArchiCryptoHelper.ECryptoMethod DefaultPasswordFormat = ArchiCryptoHelper.ECryptoMethod.PlainText; private const bool DefaultPaused = false; private const ERedeemingPreferences DefaultRedeemingPreferences = ERedeemingPreferences.None; private const bool DefaultSendOnFarmingFinished = false; @@ -109,7 +109,7 @@ namespace ArchiSteamFarm { internal readonly EPersonaState OnlineStatus = DefaultOnlineStatus; [JsonProperty(Required = Required.DisallowNull)] - internal readonly CryptoHelper.ECryptoMethod PasswordFormat = DefaultPasswordFormat; + internal readonly ArchiCryptoHelper.ECryptoMethod PasswordFormat = DefaultPasswordFormat; [JsonProperty(Required = Required.DisallowNull)] internal readonly bool Paused = DefaultPaused; @@ -155,7 +155,7 @@ namespace ArchiSteamFarm { return null; } - return PasswordFormat == CryptoHelper.ECryptoMethod.PlainText ? EncryptedSteamPassword : CryptoHelper.Decrypt(PasswordFormat, EncryptedSteamPassword); + return PasswordFormat == ArchiCryptoHelper.ECryptoMethod.PlainText ? EncryptedSteamPassword : ArchiCryptoHelper.Decrypt(PasswordFormat, EncryptedSteamPassword); } set { if (string.IsNullOrEmpty(value)) { @@ -163,7 +163,7 @@ namespace ArchiSteamFarm { return; } - EncryptedSteamPassword = PasswordFormat == CryptoHelper.ECryptoMethod.PlainText ? value : CryptoHelper.Encrypt(PasswordFormat, value); + EncryptedSteamPassword = PasswordFormat == ArchiCryptoHelper.ECryptoMethod.PlainText ? value : ArchiCryptoHelper.Encrypt(PasswordFormat, value); } } @@ -245,7 +245,7 @@ namespace ArchiSteamFarm { return null; } - if (!Enum.IsDefined(typeof(CryptoHelper.ECryptoMethod), botConfig.PasswordFormat)) { + if (!Enum.IsDefined(typeof(ArchiCryptoHelper.ECryptoMethod), botConfig.PasswordFormat)) { ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorConfigPropertyInvalid, nameof(botConfig.PasswordFormat), botConfig.PasswordFormat)); return null; } diff --git a/ArchiSteamFarm/CardsFarmer.cs b/ArchiSteamFarm/CardsFarmer.cs index 4bcd1818f..b5f8a8737 100755 --- a/ArchiSteamFarm/CardsFarmer.cs +++ b/ArchiSteamFarm/CardsFarmer.cs @@ -851,7 +851,7 @@ namespace ArchiSteamFarm { GamesToFarm.Clear(); - List tasks = new List(); + HashSet tasks = new HashSet(); Task mainTask = CheckPage(htmlDocument); switch (Program.GlobalConfig.OptimizationMode) { @@ -1072,4 +1072,4 @@ namespace ArchiSteamFarm { public override int GetHashCode() => (int) (AppID - 1 - int.MaxValue); } } -} \ No newline at end of file +} diff --git a/ArchiSteamFarm/Json/GitHub.cs b/ArchiSteamFarm/Json/GitHub.cs index 9de76461c..bfdbd6ac1 100644 --- a/ArchiSteamFarm/Json/GitHub.cs +++ b/ArchiSteamFarm/Json/GitHub.cs @@ -28,7 +28,7 @@ namespace ArchiSteamFarm.JSON { [SuppressMessage("ReSharper", "ClassCannotBeInstantiated")] internal sealed class ReleaseResponse { [JsonProperty(PropertyName = "assets", Required = Required.Always)] - internal readonly List Assets; + internal readonly HashSet Assets; [JsonProperty(PropertyName = "tag_name", Required = Required.Always)] internal readonly string Tag; diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index 534e27b97..6301684b7 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -158,7 +158,7 @@ namespace ArchiSteamFarm { return; } - CryptoHelper.SetEncryptionKey(cryptKey); + ArchiCryptoHelper.SetEncryptionKey(cryptKey); } private static void HandlePathArgument(string path) {