diff --git a/Dalamud.Bootstrap/SqexArg/EncodedArgument.cs b/Dalamud.Bootstrap/SqexArg/EncodedArgument.cs index ddf307b1c..0d9df0633 100644 --- a/Dalamud.Bootstrap/SqexArg/EncodedArgument.cs +++ b/Dalamud.Bootstrap/SqexArg/EncodedArgument.cs @@ -66,11 +66,30 @@ namespace Dalamud.Bootstrap.SqexArg { var (keyFragment, step) = RecoverKeyFragmentFromChecksum(checksum); + Span keyBytes = stackalloc byte[8]; + var keyCandicate = keyFragment; while (true) { - // try with keyCandicate + if (!CreateKey(keyBytes, keyCandicate)) + { + var message = $"BUG"; + throw new InvalidOperationException(message); + } + var blowfish = new Blowfish(keyBytes); + blowfish.DecryptInPlace(); + + if (/* if data looks valid, return blowfish */) + { + // ... + // TODO: test if it's looks like valid utf8 string? + // ??? + + return blowfish; + } + + // .. next key plz try { keyCandicate = checked(keyCandicate + step); @@ -82,12 +101,8 @@ namespace Dalamud.Bootstrap.SqexArg } } - /// - /// - /// - /// - /// - /// + private static bool CreateKey(Span destination, uint key) => Utf8Formatter.TryFormat(key, destination, out var _, new StandardFormat('X', 8)); + private static (uint keyFragment, uint step) RecoverKeyFragmentFromChecksum(char checksum) { if (checksum == NoChecksumMarker) @@ -103,7 +118,7 @@ namespace Dalamud.Bootstrap.SqexArg } /// - /// Converts url safe variant of base64 string to bytes. + /// Converts the url-safe variant of base64 string to bytes. /// /// A url-safe variant of base64 string. private static byte[] DecodeUrlSafeBase64(string payload) diff --git a/build/DalamudBuild.cs b/build/DalamudBuild.cs index ad9ad8e4d..bc39f17d2 100644 --- a/build/DalamudBuild.cs +++ b/build/DalamudBuild.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Linq; using Nuke.Common; using Nuke.Common.Execution; @@ -13,6 +14,7 @@ using static Nuke.Common.EnvironmentInfo; using static Nuke.Common.IO.FileSystemTasks; using static Nuke.Common.IO.PathConstruction; using static Nuke.Common.Tools.DotNet.DotNetTasks; +using static Nuke.Common.Logger; [CheckBuildProjectConfigurations] [UnsetVisualStudioEnvironmentVariables] @@ -35,7 +37,7 @@ class DalamudBuild : NukeBuild AbsolutePath OutputDirectory => RootDirectory / "output"; - //AbsolutePath DefaultDalamudRoot => + AbsolutePath DefaultInstallDirectory => (AbsolutePath)Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) / "Dalamud" / "bin" / GitVersion.SemVer; Target Clean => _ => _ .Before(Restore) @@ -68,7 +70,7 @@ class DalamudBuild : NukeBuild .DependsOn(Compile) .Executes(() => { + Info($"Installing Dalamud to {DefaultInstallDirectory}"); // TODO - }); }