Skip to content

Commit

Permalink
Fix unpacking DSIII files with padded AES encrypted regions
Browse files Browse the repository at this point in the history
- Version v0.5.1
  • Loading branch information
Atvaark committed Oct 27, 2017
1 parent 3bd646e commit 10f99d6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions BinderTool.Core/CryptographyUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions BinderTool.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
4 changes: 2 additions & 2 deletions BinderTool/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

0 comments on commit 10f99d6

Please sign in to comment.