diff --git a/src/main/java/libKonogonka/ctraesclassic/AesCtrDecryptClassic.java b/src/main/java/libKonogonka/ctraesclassic/AesCtrDecryptClassic.java index 0c9b751..d0d9372 100644 --- a/src/main/java/libKonogonka/ctraesclassic/AesCtrDecryptClassic.java +++ b/src/main/java/libKonogonka/ctraesclassic/AesCtrDecryptClassic.java @@ -24,6 +24,7 @@ import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import java.math.BigInteger; +import java.nio.ByteBuffer; import java.security.Security; public class AesCtrDecryptClassic { @@ -64,7 +65,14 @@ public class AesCtrDecryptClassic { private byte[] calculateCtr(long offset){ BigInteger ctr = new BigInteger(ivArray); BigInteger updateTo = BigInteger.valueOf(offset / 0x10L); - return ctr.add(updateTo).toByteArray(); + byte[] ctrCalculated = ctr.add(updateTo).toByteArray(); + if (ctrCalculated.length != 0x10) { + ByteBuffer ctrByteBuffer = ByteBuffer.allocate(0x10); + ctrByteBuffer.position(0x10 - ctrCalculated.length); + ctrByteBuffer.put(ctrCalculated); + return ctrByteBuffer.array(); + } + return ctrCalculated; } /** diff --git a/src/main/java/libKonogonka/ctraesclassic/InFileStreamClassicProducer.java b/src/main/java/libKonogonka/ctraesclassic/InFileStreamClassicProducer.java index 0839ff6..dbe1700 100644 --- a/src/main/java/libKonogonka/ctraesclassic/InFileStreamClassicProducer.java +++ b/src/main/java/libKonogonka/ctraesclassic/InFileStreamClassicProducer.java @@ -96,6 +96,7 @@ public class InFileStreamClassicProducer implements IProducer { * @param encryptedEndOffset Offset since parent stream start at stream where encrypted section ends * @param key AES-CTR Key * @param iv CTR / IV (counter) + * @param fileSize File Size */ public InFileStreamClassicProducer(InFileStreamProducer parentProducer, long offset,