Compare commits

...

2 Commits

Author SHA1 Message Date
Dmitry Isaenko 1f25e917c3 Small optimizations, renaming
continuous-integration/drone/push Build is passing Details
2023-01-21 14:45:44 +03:00
Dmitry Isaenko 394bc8f226 XTS AES - remove deprecated BouncyCastle methods usage 2023-01-21 14:17:50 +03:00
73 changed files with 167 additions and 179 deletions

View File

@ -1,4 +1,4 @@
package libKonogonka;
package libKonogonka.aesctr;
import java.io.BufferedInputStream;
import java.io.File;

View File

@ -18,8 +18,6 @@
*/
package libKonogonka.aesctr;
import libKonogonka.IProducer;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.InputStream;

View File

@ -18,8 +18,6 @@
*/
package libKonogonka.aesctr;
import libKonogonka.IProducer;
import java.io.BufferedInputStream;
import java.io.File;
import java.nio.file.Files;

View File

@ -1,4 +1,4 @@
package libKonogonka.Tools;
package libKonogonka.fs;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;

View File

@ -16,18 +16,19 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools;
package libKonogonka.fs;
import libKonogonka.aesctr.InFileStreamProducer;
import java.io.File;
import java.io.FileNotFoundException;
/**
* Any class of this type must provide streams
* */
public interface ISuperProvider {
InFileStreamProducer getStreamProducer(String subFileName) throws Exception;
InFileStreamProducer getStreamProducer(int subFileNumber) throws Exception;
InFileStreamProducer getStreamProducer(int subFileNumber) throws FileNotFoundException;
boolean exportContent(String saveToLocation, String subFileName) throws Exception;
boolean exportContent(String saveToLocation, int subFileNumber) throws Exception;
File getFile();

View File

@ -16,11 +16,11 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NCA;
package libKonogonka.fs.NCA;
import libKonogonka.Tools.NCA.NCASectionTableBlock.NcaFsHeader;
import libKonogonka.Tools.PFS0.PFS0Provider;
import libKonogonka.Tools.RomFs.RomFsProvider;
import libKonogonka.fs.NCA.NCASectionTableBlock.NcaFsHeader;
import libKonogonka.fs.PFS0.PFS0Provider;
import libKonogonka.fs.RomFs.RomFsProvider;
import libKonogonka.aesctr.AesCtrBufferedInputStream;
import libKonogonka.aesctr.AesCtrDecryptForMediaBlocks;
import libKonogonka.aesctr.InFileStreamProducer;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NCA;
package libKonogonka.fs.NCA;
import libKonogonka.Converter;

View File

@ -16,10 +16,10 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NCA;
package libKonogonka.fs.NCA;
import libKonogonka.Converter;
import libKonogonka.Tools.NCA.NCASectionTableBlock.NcaFsHeader;
import libKonogonka.fs.NCA.NCASectionTableBlock.NcaFsHeader;
import libKonogonka.exceptions.EmptySectionException;
import libKonogonka.xtsaes.XTSAESCipher;
import org.apache.logging.log4j.LogManager;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NCA.NCASectionTableBlock;
package libKonogonka.fs.NCA.NCASectionTableBlock;
import libKonogonka.Converter;
import org.apache.logging.log4j.LogManager;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NCA.NCASectionTableBlock;
package libKonogonka.fs.NCA.NCASectionTableBlock;
import libKonogonka.Converter;
import org.apache.logging.log4j.LogManager;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NCA.NCASectionTableBlock;
package libKonogonka.fs.NCA.NCASectionTableBlock;
import libKonogonka.Converter;
import org.apache.logging.log4j.LogManager;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NCA.NCASectionTableBlock;
package libKonogonka.fs.NCA.NCASectionTableBlock;
import libKonogonka.Converter;
import libKonogonka.RainbowDump;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NCA.NCASectionTableBlock;
package libKonogonka.fs.NCA.NCASectionTableBlock;
import libKonogonka.Converter;
import org.apache.logging.log4j.LogManager;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NCA.NCASectionTableBlock;
package libKonogonka.fs.NCA.NCASectionTableBlock;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NCA.NCASectionTableBlock;
package libKonogonka.fs.NCA.NCASectionTableBlock;
import java.util.Arrays;

View File

@ -16,10 +16,10 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NPDM.ACI0;
package libKonogonka.fs.NPDM.ACI0;
import libKonogonka.Tools.NPDM.KernelAccessControlProvider;
import libKonogonka.Tools.NPDM.ServiceAccessControlProvider;
import libKonogonka.fs.NPDM.KernelAccessControlProvider;
import libKonogonka.fs.NPDM.ServiceAccessControlProvider;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NPDM.ACI0;
package libKonogonka.fs.NPDM.ACI0;
import libKonogonka.Converter;

View File

@ -16,10 +16,10 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NPDM.ACID;
package libKonogonka.fs.NPDM.ACID;
import libKonogonka.Tools.NPDM.KernelAccessControlProvider;
import libKonogonka.Tools.NPDM.ServiceAccessControlProvider;
import libKonogonka.fs.NPDM.KernelAccessControlProvider;
import libKonogonka.fs.NPDM.ServiceAccessControlProvider;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NPDM.ACID;
package libKonogonka.fs.NPDM.ACID;
import libKonogonka.Converter;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NPDM;
package libKonogonka.fs.NPDM;
import libKonogonka.Converter;
import org.apache.logging.log4j.LogManager;
@ -88,7 +88,7 @@ public class KernelAccessControlProvider {
DEBUGFLAGS = 16;
// RAW data
private final LinkedList<Integer> rawData;
private byte[] raw;
private final byte[] raw;
// Kernel flags
private boolean kernelFlagsAvailable;
private int kernelFlagCpuIdHi;

View File

@ -16,10 +16,10 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NPDM;
package libKonogonka.fs.NPDM;
import libKonogonka.Tools.NPDM.ACI0.ACI0Provider;
import libKonogonka.Tools.NPDM.ACID.ACIDProvider;
import libKonogonka.fs.NPDM.ACI0.ACI0Provider;
import libKonogonka.fs.NPDM.ACID.ACIDProvider;
import libKonogonka.aesctr.InFileStreamProducer;
import java.io.BufferedInputStream;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NPDM;
package libKonogonka.fs.NPDM;
import java.nio.charset.StandardCharsets;
import java.util.LinkedHashMap;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NSO;
package libKonogonka.fs.NSO;
import libKonogonka.Converter;
import libKonogonka.RainbowDump;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NSO;
package libKonogonka.fs.NSO;
import libKonogonka.aesctr.InFileStreamProducer;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NSO;
package libKonogonka.fs.NSO;
public class NSO0Raw {
private NSO0Header headerObject;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NSO;
package libKonogonka.fs.NSO;
import libKonogonka.aesctr.InFileStreamProducer;
import net.jpountz.lz4.LZ4Factory;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NSO;
package libKonogonka.fs.NSO;
import libKonogonka.Converter;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.NSO;
package libKonogonka.fs.NSO;
import libKonogonka.Converter;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.PFS0;
package libKonogonka.fs.PFS0;
import libKonogonka.Converter;
import libKonogonka.RainbowDump;

View File

@ -16,12 +16,12 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.PFS0;
package libKonogonka.fs.PFS0;
import libKonogonka.RainbowDump;
import libKonogonka.Tools.ExportAble;
import libKonogonka.Tools.ISuperProvider;
import libKonogonka.Tools.NCA.NCASectionTableBlock.SuperBlockPFS0;
import libKonogonka.fs.ExportAble;
import libKonogonka.fs.ISuperProvider;
import libKonogonka.fs.NCA.NCASectionTableBlock.SuperBlockPFS0;
import libKonogonka.aesctr.InFileStreamProducer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.PFS0;
package libKonogonka.fs.PFS0;
public class PFS0subFile {
private final String name;

View File

@ -17,10 +17,10 @@
* along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.RomFs;
package libKonogonka.fs.RomFs;
import libKonogonka.Converter;
import libKonogonka.Tools.RomFs.view.FileSystemTreeViewMaker;
import libKonogonka.fs.RomFs.view.FileSystemTreeViewMaker;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

View File

@ -17,7 +17,7 @@
* along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.RomFs;
package libKonogonka.fs.RomFs;
import libKonogonka.Converter;
import libKonogonka.RainbowDump;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.RomFs;
package libKonogonka.fs.RomFs;
import libKonogonka.Converter;
import libKonogonka.aesctr.InFileStreamProducer;

View File

@ -16,11 +16,11 @@
* You should have received a copy of the GNU General Public License
* along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.RomFs;
package libKonogonka.fs.RomFs;
import libKonogonka.Tools.ExportAble;
import libKonogonka.Tools.RomFs.view.DirectoryMetaTablePlainView;
import libKonogonka.Tools.RomFs.view.FileMetaTablePlainView;
import libKonogonka.fs.ExportAble;
import libKonogonka.fs.RomFs.view.DirectoryMetaTablePlainView;
import libKonogonka.fs.RomFs.view.FileMetaTablePlainView;
import libKonogonka.aesctr.InFileStreamProducer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.RomFs.view;
package libKonogonka.fs.RomFs.view;
import libKonogonka.Converter;
import org.apache.logging.log4j.LogManager;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.RomFs.view;
package libKonogonka.fs.RomFs.view;
import libKonogonka.Converter;
import org.apache.logging.log4j.LogManager;

View File

@ -16,9 +16,9 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.RomFs.view;
package libKonogonka.fs.RomFs.view;
import libKonogonka.Tools.RomFs.FileSystemEntry;
import libKonogonka.fs.RomFs.FileSystemEntry;
import java.util.List;
/**

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.TIK;
package libKonogonka.fs.TIK;
import java.io.BufferedInputStream;
import java.io.File;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.XCI;
package libKonogonka.fs.XCI;
public class HFS0File {
private final String name;

View File

@ -16,10 +16,10 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.XCI;
package libKonogonka.fs.XCI;
import libKonogonka.Tools.ExportAble;
import libKonogonka.Tools.ISuperProvider;
import libKonogonka.fs.ExportAble;
import libKonogonka.fs.ISuperProvider;
import libKonogonka.aesctr.InFileStreamProducer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.XCI;
package libKonogonka.fs.XCI;
import libKonogonka.Converter;
import org.apache.logging.log4j.LogManager;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.XCI;
package libKonogonka.fs.XCI;
import libKonogonka.Converter;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.XCI;
package libKonogonka.fs.XCI;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.XCI;
package libKonogonka.fs.XCI;
import java.io.File;
import java.io.FileNotFoundException;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.other.System2;
package libKonogonka.fs.other.System2;
import libKonogonka.Converter;
import libKonogonka.RainbowDump;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.other.System2;
package libKonogonka.fs.other.System2;
import libKonogonka.Converter;
import libKonogonka.RainbowDump;

View File

@ -16,11 +16,11 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.other.System2;
package libKonogonka.fs.other.System2;
import libKonogonka.KeyChainHolder;
import libKonogonka.Tools.ExportAble;
import libKonogonka.Tools.other.System2.ini1.Ini1Provider;
import libKonogonka.fs.ExportAble;
import libKonogonka.fs.other.System2.ini1.Ini1Provider;
import libKonogonka.aesctr.InFileStreamProducer;
import libKonogonka.aesctr.InFileStreamClassicProducer;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.other.System2.ini1;
package libKonogonka.fs.other.System2.ini1;
import libKonogonka.Converter;
import libKonogonka.RainbowDump;

View File

@ -16,10 +16,10 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.other.System2.ini1;
package libKonogonka.fs.other.System2.ini1;
import libKonogonka.Tools.ExportAble;
import libKonogonka.Tools.other.System2.System2Header;
import libKonogonka.fs.ExportAble;
import libKonogonka.fs.other.System2.System2Header;
import libKonogonka.aesctr.InFileStreamClassicProducer;
import java.io.IOException;

View File

@ -16,12 +16,12 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.other.System2.ini1;
package libKonogonka.fs.other.System2.ini1;
import libKonogonka.Converter;
import libKonogonka.RainbowDump;
import libKonogonka.Tools.NPDM.KernelAccessControlProvider;
import libKonogonka.Tools.NSO.SegmentHeader;
import libKonogonka.fs.NPDM.KernelAccessControlProvider;
import libKonogonka.fs.NSO.SegmentHeader;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

View File

@ -16,9 +16,9 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.other.System2.ini1;
package libKonogonka.fs.other.System2.ini1;
import libKonogonka.Tools.ExportAble;
import libKonogonka.fs.ExportAble;
import libKonogonka.aesctr.InFileStreamClassicProducer;
import java.nio.file.Paths;

View File

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.other.System2.ini1;
package libKonogonka.fs.other.System2.ini1;
import java.nio.ByteBuffer;

View File

@ -16,9 +16,9 @@
You should have received a copy of the GNU General Public License
along with libKonogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package libKonogonka.Tools.other.System2.ini1;
package libKonogonka.fs.other.System2.ini1;
import libKonogonka.Tools.NSO.SegmentHeader;
import libKonogonka.fs.NSO.SegmentHeader;
import libKonogonka.blz.BlzDecompress;
import libKonogonka.aesctr.InFileStreamClassicProducer;
@ -29,7 +29,7 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import static libKonogonka.Tools.other.System2.ini1.KIP1Provider.HEADER_SIZE;
import static libKonogonka.fs.other.System2.ini1.KIP1Provider.HEADER_SIZE;
public class Kip1Unpacker {
private static final String DECOMPRESSED_FILE_POSTFIX = "_decompressed";
@ -42,7 +42,6 @@ public class Kip1Unpacker {
private byte[] _rwDataDecompressedSection;
private int textFileOffsetNew;
private int roDataFileOffsetNew;
private int rwDataFileOffsetNew;
private Kip1Unpacker(KIP1Header kip1Header, InFileStreamClassicProducer producer) throws Exception{
this.kip1Header = kip1Header;
@ -150,7 +149,7 @@ public class Kip1Unpacker {
private void makeHeader(){
textFileOffsetNew = kip1Header.getTextSegmentHeader().getMemoryOffset();
roDataFileOffsetNew = kip1Header.getRoDataSegmentHeader().getMemoryOffset();
rwDataFileOffsetNew = kip1Header.getRwDataSegmentHeader().getMemoryOffset();
int rwDataFileOffsetNew = kip1Header.getRwDataSegmentHeader().getMemoryOffset();
byte flags = kip1Header.getFlags();
flags &= ~0b111; //mark .text .ro .rw as 'not compress'

View File

@ -34,10 +34,8 @@ import java.util.function.LongFunction;
* XTS-AES cipher with arbitrary (non 128-bit aligned) data unit lengths.
*
* @author Ahseya
*/
/**
* Updated for special usage by Dmitry Isaenko.
*
* Class updated for NCAs usage.
* */
@NotThreadSafe
public class XTSAESCipher {

View File

@ -26,7 +26,7 @@ package libKonogonka.xtsaes;
import net.jcip.annotations.NotThreadSafe;
import org.bouncycastle.crypto.BlockCipher;
import org.bouncycastle.crypto.DataLengthException;
import org.bouncycastle.crypto.engines.AESFastEngine;
import org.bouncycastle.crypto.engines.AESEngine;
import org.bouncycastle.crypto.params.KeyParameter;
import java.util.Arrays;
@ -36,10 +36,8 @@ import java.util.Objects;
* XTS core functions.
*
* @author Ahseya
*/
/**
* Updated for special usage by Dmitry Isaenko.
*
* Class updated for NCAs usage.
* */
@NotThreadSafe
class XTSCore {
@ -56,7 +54,7 @@ class XTSCore {
}
XTSCore(XTSTweak tweak) {
this(new AESFastEngine(), tweak);
this(new AESEngine(), tweak);
}
XTSCore(boolean isDefault) {
@ -64,7 +62,7 @@ class XTSCore {
}
XTSCore init(boolean forEncryption, KeyParameter key) throws IllegalArgumentException {
byte[] k = ((KeyParameter) key).getKey();
byte[] k = key.getKey();
if (k.length != 32 && k.length != 64) {
throw new IllegalArgumentException("bad key length: " + k.length);
}

View File

@ -26,7 +26,7 @@ package libKonogonka.xtsaes;
import net.jcip.annotations.NotThreadSafe;
import org.bouncycastle.crypto.BlockCipher;
import org.bouncycastle.crypto.DataLengthException;
import org.bouncycastle.crypto.engines.AESFastEngine;
import org.bouncycastle.crypto.engines.AESEngine;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.util.Pack;
@ -38,29 +38,11 @@ import java.util.function.LongFunction;
* XTS tweak with pluggable tweak function.
*
* @author Ahseya
*/
/**
* Updated for special usage by Dmitry Isaenko.
*
* Class updated for NCAs usage.
* */
@NotThreadSafe
class XTSTweak {
static byte[] nintTweakFunction(long tweakValue) {
byte[] bs = new byte[BLOCK_SIZE];
byte[] twk = Pack.longToBigEndian(tweakValue);
int j = BLOCK_SIZE - twk.length;
for (byte b: twk){
bs[j++] = b;
}
return bs;
}
static byte[] defaultTweakFunction(long tweakValue) {
byte[] bs = Pack.longToLittleEndian(tweakValue);
bs = Arrays.copyOfRange(bs, 0, BLOCK_SIZE);
return bs;
}
private static final long FDBK = 0x87;
private static final long MSB = 0x8000000000000000L;
private static final int BLOCK_SIZE = 16;
@ -84,7 +66,7 @@ class XTSTweak {
}
XTSTweak(LongFunction<byte[]> tweakFunction) {
this(new AESFastEngine(), tweakFunction);
this(new AESEngine(), tweakFunction);
}
XTSTweak(boolean isDefault) {
@ -92,6 +74,20 @@ class XTSTweak {
? XTSTweak::defaultTweakFunction
: XTSTweak::nintTweakFunction);
}
static byte[] defaultTweakFunction(long tweakValue) {
byte[] bs = Pack.longToLittleEndian(tweakValue);
bs = Arrays.copyOfRange(bs, 0, BLOCK_SIZE);
return bs;
}
static byte[] nintTweakFunction(long tweakValue) {
byte[] bs = new byte[BLOCK_SIZE];
byte[] twk = Pack.longToBigEndian(tweakValue);
int j = BLOCK_SIZE - twk.length;
for (byte b: twk){
bs[j++] = b;
}
return bs;
}
XTSTweak init(KeyParameter key) throws IllegalArgumentException {
cipher.init(true, key);

View File

@ -2,9 +2,9 @@ package libKonogonka.package2;
import libKonogonka.Converter;
import libKonogonka.KeyChainHolder;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.RomFs.FileSystemEntry;
import libKonogonka.Tools.RomFs.RomFsProvider;
import libKonogonka.fs.NCA.NCAProvider;
import libKonogonka.fs.RomFs.FileSystemEntry;
import libKonogonka.fs.RomFs.RomFsProvider;
import org.junit.jupiter.api.*;
import java.io.File;

View File

@ -2,11 +2,11 @@ package libKonogonka.package2;
import libKonogonka.Converter;
import libKonogonka.KeyChainHolder;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.RomFs.FileSystemEntry;
import libKonogonka.Tools.RomFs.RomFsProvider;
import libKonogonka.Tools.other.System2.System2Provider;
import libKonogonka.Tools.other.System2.ini1.Ini1Provider;
import libKonogonka.fs.NCA.NCAProvider;
import libKonogonka.fs.RomFs.FileSystemEntry;
import libKonogonka.fs.RomFs.RomFsProvider;
import libKonogonka.fs.other.System2.System2Provider;
import libKonogonka.fs.other.System2.ini1.Ini1Provider;
import libKonogonka.aesctr.InFileStreamProducer;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;

View File

@ -2,10 +2,10 @@ package libKonogonka.package2;
import libKonogonka.Converter;
import libKonogonka.KeyChainHolder;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.RomFs.FileSystemEntry;
import libKonogonka.Tools.RomFs.RomFsProvider;
import libKonogonka.Tools.other.System2.System2Provider;
import libKonogonka.fs.NCA.NCAProvider;
import libKonogonka.fs.RomFs.FileSystemEntry;
import libKonogonka.fs.RomFs.RomFsProvider;
import libKonogonka.fs.other.System2.System2Provider;
import libKonogonka.aesctr.InFileStreamProducer;
import org.junit.jupiter.api.*;

View File

@ -2,12 +2,12 @@ package libKonogonka.package2;
import libKonogonka.Converter;
import libKonogonka.KeyChainHolder;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.RomFs.FileSystemEntry;
import libKonogonka.Tools.RomFs.RomFsProvider;
import libKonogonka.Tools.other.System2.System2Provider;
import libKonogonka.Tools.other.System2.ini1.Ini1Provider;
import libKonogonka.Tools.other.System2.ini1.KIP1Provider;
import libKonogonka.fs.NCA.NCAProvider;
import libKonogonka.fs.RomFs.FileSystemEntry;
import libKonogonka.fs.RomFs.RomFsProvider;
import libKonogonka.fs.other.System2.System2Provider;
import libKonogonka.fs.other.System2.ini1.Ini1Provider;
import libKonogonka.fs.other.System2.ini1.KIP1Provider;
import libKonogonka.aesctr.InFileStreamProducer;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;

View File

@ -2,12 +2,12 @@ package libKonogonka.package2;
import libKonogonka.Converter;
import libKonogonka.KeyChainHolder;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.RomFs.FileSystemEntry;
import libKonogonka.Tools.RomFs.RomFsProvider;
import libKonogonka.Tools.other.System2.System2Provider;
import libKonogonka.Tools.other.System2.ini1.Ini1Provider;
import libKonogonka.Tools.other.System2.ini1.KIP1Provider;
import libKonogonka.fs.NCA.NCAProvider;
import libKonogonka.fs.RomFs.FileSystemEntry;
import libKonogonka.fs.RomFs.RomFsProvider;
import libKonogonka.fs.other.System2.System2Provider;
import libKonogonka.fs.other.System2.ini1.Ini1Provider;
import libKonogonka.fs.other.System2.ini1.KIP1Provider;
import libKonogonka.aesctr.InFileStreamProducer;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;

View File

@ -19,9 +19,9 @@
package libKonogonka.unsorted;
import libKonogonka.KeyChainHolder;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.NSO.NSO0Provider;
import libKonogonka.Tools.PFS0.PFS0Provider;
import libKonogonka.fs.NCA.NCAProvider;
import libKonogonka.fs.NSO.NSO0Provider;
import libKonogonka.fs.PFS0.PFS0Provider;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

View File

@ -54,31 +54,31 @@ public class KeyChainHolderTest {
void printKAKApplication(){
System.out.println("-=== key_area_key_application test ===-");
for (Map.Entry entry : keyChainHolder.getKey_area_key_application().entrySet()){
for (Map.Entry<String, String> entry : keyChainHolder.getKey_area_key_application().entrySet()){
System.out.println(entry.getKey() + " - " + entry.getValue());
}
}
void printKAKOcean(){
System.out.println("-=== key_area_key_ocean test ===-");
for (Map.Entry entry : keyChainHolder.getKey_area_key_ocean().entrySet()){
for (Map.Entry<String, String> entry : keyChainHolder.getKey_area_key_ocean().entrySet()){
System.out.println(entry.getKey() + " - " + entry.getValue());
}
}
void printKAKSystem(){
System.out.println("-=== key_area_key_system test ===-");
for (Map.Entry entry : keyChainHolder.getKey_area_key_system().entrySet()){
for (Map.Entry<String, String> entry : keyChainHolder.getKey_area_key_system().entrySet()){
System.out.println(entry.getKey() + " - " + entry.getValue());
}
}
void printKAKTitleKek(){
System.out.println("-=== titlekek test ===-");
for (Map.Entry entry : keyChainHolder.getTitlekek().entrySet()){
for (Map.Entry<String, String> entry : keyChainHolder.getTitlekek().entrySet()){
System.out.println(entry.getKey() + " - " + entry.getValue());
}
}
void printRawKeySet(){
System.out.println("-=== Raw Key Set (everything) test ===-");
for (Map.Entry entry : keyChainHolder.getRawKeySet().entrySet()){
for (Map.Entry<String, String> entry : keyChainHolder.getRawKeySet().entrySet()){
System.out.println(entry.getKey() + " - " + entry.getValue());
}
}

View File

@ -19,7 +19,7 @@
package libKonogonka.unsorted;
import libKonogonka.KeyChainHolder;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.fs.NCA.NCAProvider;
import org.junit.jupiter.api.*;
import java.io.BufferedReader;

View File

@ -18,7 +18,7 @@
*/
package libKonogonka.unsorted;
import libKonogonka.Tools.NSO.NSO0Provider;
import libKonogonka.fs.NSO.NSO0Provider;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

View File

@ -20,10 +20,10 @@ package libKonogonka.unsorted;
import libKonogonka.KeyChainHolder;
import libKonogonka.RainbowDump;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.NSO.NSO0Provider;
import libKonogonka.Tools.PFS0.PFS0Provider;
import libKonogonka.Tools.PFS0.PFS0subFile;
import libKonogonka.fs.NCA.NCAProvider;
import libKonogonka.fs.NSO.NSO0Provider;
import libKonogonka.fs.PFS0.PFS0Provider;
import libKonogonka.fs.PFS0.PFS0subFile;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

View File

@ -21,9 +21,9 @@ package libKonogonka.unsorted;
import libKonogonka.KeyChainHolder;
import libKonogonka.RainbowDump;
import libKonogonka.TitleKeyChainHolder;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.PFS0.PFS0Provider;
import libKonogonka.Tools.PFS0.PFS0subFile;
import libKonogonka.fs.NCA.NCAProvider;
import libKonogonka.fs.PFS0.PFS0Provider;
import libKonogonka.fs.PFS0.PFS0subFile;
import libKonogonka.aesctr.AesCtrBufferedInputStream;
import libKonogonka.aesctr.AesCtrDecryptForMediaBlocks;
import org.junit.jupiter.api.Disabled;
@ -209,7 +209,7 @@ public class NSPpfs0EncryptedTest {
private void exportContentLegacy(PFS0subFile entry, String saveToLocation) throws Exception {
File contentFile = new File(saveToLocation + entry.getName());
BufferedOutputStream extractedFileBOS = new BufferedOutputStream(new FileOutputStream(contentFile));
BufferedOutputStream extractedFileBOS = new BufferedOutputStream(Files.newOutputStream(contentFile.toPath()));
BufferedInputStream pis = ncaProvider.getNCAContentProvider(0)
.getPfs0()
.getStreamProducer(entry.getName())

View File

@ -20,8 +20,8 @@ package libKonogonka.unsorted;
import libKonogonka.KeyChainHolder;
import libKonogonka.TitleKeyChainHolder;
import libKonogonka.Tools.PFS0.PFS0Provider;
import libKonogonka.Tools.PFS0.PFS0subFile;
import libKonogonka.fs.PFS0.PFS0Provider;
import libKonogonka.fs.PFS0.PFS0subFile;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

View File

@ -20,9 +20,9 @@ package libKonogonka.unsorted;
import libKonogonka.KeyChainHolder;
import libKonogonka.RainbowDump;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.PFS0.PFS0Provider;
import libKonogonka.Tools.PFS0.PFS0subFile;
import libKonogonka.fs.NCA.NCAProvider;
import libKonogonka.fs.PFS0.PFS0Provider;
import libKonogonka.fs.PFS0.PFS0subFile;
import libKonogonka.aesctr.AesCtrBufferedInputStream;
import libKonogonka.aesctr.AesCtrDecryptForMediaBlocks;
import org.junit.jupiter.api.*;
@ -183,7 +183,7 @@ public class Pfs0EncryptedTest {
private void exportContentLegacy(PFS0subFile entry, String saveToLocation) throws Exception {
File contentFile = new File(saveToLocation + entry.getName());
BufferedOutputStream extractedFileBOS = new BufferedOutputStream(new FileOutputStream(contentFile));
BufferedOutputStream extractedFileBOS = new BufferedOutputStream(Files.newOutputStream(contentFile.toPath()));
BufferedInputStream pis = ncaProvider.getNCAContentProvider(0)
.getPfs0()
.getStreamProducer(entry.getName())

View File

@ -22,8 +22,8 @@ import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import libKonogonka.Tools.RomFs.FileSystemEntry;
import libKonogonka.Tools.RomFs.RomFsProvider;
import libKonogonka.fs.RomFs.FileSystemEntry;
import libKonogonka.fs.RomFs.RomFsProvider;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

View File

@ -21,9 +21,9 @@ package libKonogonka.unsorted;
import libKonogonka.aesctr.AesCtrBufferedInputStream;
import libKonogonka.KeyChainHolder;
import libKonogonka.RainbowDump;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.NCA.NCASectionTableBlock.NcaFsHeader;
import libKonogonka.Tools.RomFs.FileSystemEntry;
import libKonogonka.fs.NCA.NCAProvider;
import libKonogonka.fs.NCA.NCASectionTableBlock.NcaFsHeader;
import libKonogonka.fs.RomFs.FileSystemEntry;
import libKonogonka.aesctr.AesCtrDecryptForMediaBlocks;
import org.junit.jupiter.api.*;

View File

@ -19,10 +19,10 @@
package libKonogonka.unsorted;
import libKonogonka.KeyChainHolder;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.XCI.HFS0File;
import libKonogonka.Tools.XCI.HFS0Provider;
import libKonogonka.Tools.XCI.XCIProvider;
import libKonogonka.fs.NCA.NCAProvider;
import libKonogonka.fs.XCI.HFS0File;
import libKonogonka.fs.XCI.HFS0Provider;
import libKonogonka.fs.XCI.XCIProvider;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;