Fix AES CTR decryption issue
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
d63d2416ff
commit
5bb6a3c3f4
2 changed files with 10 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue