diff --git a/src/de/mas/wiiu/jnus/implementations/FSTDataProviderNUSTitle.java b/src/de/mas/wiiu/jnus/implementations/FSTDataProviderNUSTitle.java index 43cb5ab..bedc45a 100644 --- a/src/de/mas/wiiu/jnus/implementations/FSTDataProviderNUSTitle.java +++ b/src/de/mas/wiiu/jnus/implementations/FSTDataProviderNUSTitle.java @@ -146,7 +146,7 @@ public class FSTDataProviderNUSTitle implements FSTDataProvider, HasNUSTitle { if (c.isHashed()) { h3HashedOpt = dataProvider.getContentH3Hash(c); } - return nusdecryption.decryptStreams(in, outputStream, fileSize, fileOffset, c, h3HashedOpt); + return nusdecryption.decryptStreams(in, outputStream, fileOffset, fileSize, c, h3HashedOpt); } catch (CheckSumWrongException e) { if (c.isUNKNWNFlag1Set()) { log.info("Hash doesn't match. But file is optional. Don't worry."); diff --git a/src/de/mas/wiiu/jnus/utils/cryptography/NUSDecryption.java b/src/de/mas/wiiu/jnus/utils/cryptography/NUSDecryption.java index 9e17f33..73b2f4c 100644 --- a/src/de/mas/wiiu/jnus/utils/cryptography/NUSDecryption.java +++ b/src/de/mas/wiiu/jnus/utils/cryptography/NUSDecryption.java @@ -57,7 +57,7 @@ public class NUSDecryption extends AESDecryption { return decrypt(blockBuffer, offset, BLOCKSIZE); } - public void decryptFileStream(InputStream inputStream, OutputStream outputStream, long filesize, long fileOffset, short contentIndex, byte[] h3hash, + public void decryptFileStream(InputStream inputStream, OutputStream outputStream, long fileOffset, long filesize, short contentIndex, byte[] h3hash, long expectedSizeForHash) throws IOException, CheckSumWrongException { MessageDigest sha1 = null; MessageDigest sha1fallback = null; @@ -191,7 +191,7 @@ public class NUSDecryption extends AESDecryption { } } - public void decryptFileStreamHashed(InputStream inputStream, OutputStream outputStream, long filesize, long fileoffset, short contentIndex, byte[] h3Hash) + public void decryptFileStreamHashed(InputStream inputStream, OutputStream outputStream, long fileoffset, long filesize, short contentIndex, byte[] h3Hash) throws IOException, CheckSumWrongException, NoSuchAlgorithmException { int BLOCKSIZE = 0x10000; int HASHBLOCKSIZE = 0xFC00; @@ -276,7 +276,7 @@ public class NUSDecryption extends AESDecryption { return output; } - public boolean decryptStreams(InputStream inputStream, OutputStream outputStream, long size, long offset, Content content, Optional h3HashHashed) + public boolean decryptStreams(InputStream inputStream, OutputStream outputStream, long offset, long size, Content content, Optional h3HashHashed) throws IOException, CheckSumWrongException, NoSuchAlgorithmException { short contentIndex = (short) content.getIndex(); @@ -287,7 +287,7 @@ public class NUSDecryption extends AESDecryption { if (content.isEncrypted()) { if (content.isHashed()) { byte[] h3 = h3HashHashed.orElseThrow(() -> new FileNotFoundException("h3 hash not found.")); - decryptFileStreamHashed(inputStream, outputStream, size, offset, (short) contentIndex, h3); + decryptFileStreamHashed(inputStream, outputStream, offset, size, (short) contentIndex, h3); } else { byte[] h3Hash = content.getSHA2Hash(); // We want to check if we read the whole file or just a part of it. @@ -297,7 +297,7 @@ public class NUSDecryption extends AESDecryption { if (size > 0 && size < fstFileSize) { h3Hash = null; } - decryptFileStream(inputStream, outputStream, size, offset, (short) contentIndex, h3Hash, encryptedFileSize); + decryptFileStream(inputStream, outputStream, offset, size, (short) contentIndex, h3Hash, encryptedFileSize); } } else { StreamUtils.saveInputStreamToOutputStreamWithHash(inputStream, outputStream, size, content.getSHA2Hash(), encryptedFileSize);