From 10f99d6b159ee2b5bf65d56bb1fc1464753ce9bb Mon Sep 17 00:00:00 2001 From: Atvaark Date: Fri, 27 Oct 2017 15:14:47 +0200 Subject: [PATCH] Fix unpacking DSIII files with padded AES encrypted regions - Version v0.5.1 --- BinderTool.Core/CryptographyUtility.cs | 16 ++++++++-------- BinderTool.Core/Properties/AssemblyInfo.cs | 4 ++-- BinderTool/Properties/AssemblyInfo.cs | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/BinderTool.Core/CryptographyUtility.cs b/BinderTool.Core/CryptographyUtility.cs index 70b696a..98e2fed 100644 --- a/BinderTool.Core/CryptographyUtility.cs +++ b/BinderTool.Core/CryptographyUtility.cs @@ -51,22 +51,22 @@ private static BufferedBlockCipher CreateAesEcbCipher(byte[] key) private static MemoryStream DecryptAes(Stream inputStream, BufferedBlockCipher cipher, long length) { int blockSize = cipher.GetBlockSize(); - long inputLength = inputStream.Length; - if (inputLength % blockSize > 0) + int inputLength = (int)length; + int paddedLength = inputLength; + if (paddedLength % blockSize > 0) { - inputLength += blockSize - inputLength % blockSize; + paddedLength += blockSize - paddedLength % blockSize; } - byte[] input = new byte[inputLength]; - byte[] output = new byte[cipher.GetOutputSize((int)inputLength)]; - - inputStream.Read(input, 0, (int)length); + byte[] input = new byte[paddedLength]; + byte[] output = new byte[cipher.GetOutputSize(paddedLength)]; + inputStream.Read(input, 0, inputLength); int len = cipher.ProcessBytes(input, 0, input.Length, output, 0); cipher.DoFinal(output, len); MemoryStream outputStream = new MemoryStream(); - outputStream.Write(output, 0, input.Length); + outputStream.Write(output, 0, inputLength); outputStream.Seek(0, SeekOrigin.Begin); return outputStream; } diff --git a/BinderTool.Core/Properties/AssemblyInfo.cs b/BinderTool.Core/Properties/AssemblyInfo.cs index e173b2b..37308c8 100644 --- a/BinderTool.Core/Properties/AssemblyInfo.cs +++ b/BinderTool.Core/Properties/AssemblyInfo.cs @@ -11,5 +11,5 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("615e60b8-3eb0-4f54-ad9b-4fa1a9fe0df0")] -[assembly: AssemblyVersion("0.5.0.0")] -[assembly: AssemblyFileVersion("0.5.0.0")] +[assembly: AssemblyVersion("0.5.1.0")] +[assembly: AssemblyFileVersion("0.5.1.0")] diff --git a/BinderTool/Properties/AssemblyInfo.cs b/BinderTool/Properties/AssemblyInfo.cs index 08ab421..0e09cc0 100644 --- a/BinderTool/Properties/AssemblyInfo.cs +++ b/BinderTool/Properties/AssemblyInfo.cs @@ -11,5 +11,5 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("5d388695-6078-4404-8f5a-0bb1a94df97b")] -[assembly: AssemblyVersion("0.5.0.0")] -[assembly: AssemblyFileVersion("0.5.0.0")] +[assembly: AssemblyVersion("0.5.1.0")] +[assembly: AssemblyFileVersion("0.5.1.0")]