Compare commits

..

No commits in common. "1f25e917c39a8ba3b297534d0d749349f27538b8" and "6e4e4dd3e7bea4a15bf136157d9d9a8a9f9e5db1" have entirely different histories.

73 changed files with 179 additions and 167 deletions

View file

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

View file

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

View file

@ -16,19 +16,18 @@
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.fs;
package libKonogonka.Tools;
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 FileNotFoundException;
InFileStreamProducer getStreamProducer(int subFileNumber) throws Exception;
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.fs.NCA;
package libKonogonka.Tools.NCA;
import libKonogonka.fs.NCA.NCASectionTableBlock.NcaFsHeader;
import libKonogonka.fs.PFS0.PFS0Provider;
import libKonogonka.fs.RomFs.RomFsProvider;
import libKonogonka.Tools.NCA.NCASectionTableBlock.NcaFsHeader;
import libKonogonka.Tools.PFS0.PFS0Provider;
import libKonogonka.Tools.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.fs.NCA;
package libKonogonka.Tools.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.fs.NCA;
package libKonogonka.Tools.NCA;
import libKonogonka.Converter;
import libKonogonka.fs.NCA.NCASectionTableBlock.NcaFsHeader;
import libKonogonka.Tools.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.fs.NCA.NCASectionTableBlock;
package libKonogonka.Tools.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.fs.NCA.NCASectionTableBlock;
package libKonogonka.Tools.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.fs.NCA.NCASectionTableBlock;
package libKonogonka.Tools.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.fs.NCA.NCASectionTableBlock;
package libKonogonka.Tools.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.fs.NCA.NCASectionTableBlock;
package libKonogonka.Tools.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.fs.NCA.NCASectionTableBlock;
package libKonogonka.Tools.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.fs.NCA.NCASectionTableBlock;
package libKonogonka.Tools.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.fs.NPDM.ACI0;
package libKonogonka.Tools.NPDM.ACI0;
import libKonogonka.fs.NPDM.KernelAccessControlProvider;
import libKonogonka.fs.NPDM.ServiceAccessControlProvider;
import libKonogonka.Tools.NPDM.KernelAccessControlProvider;
import libKonogonka.Tools.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.fs.NPDM.ACI0;
package libKonogonka.Tools.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.fs.NPDM.ACID;
package libKonogonka.Tools.NPDM.ACID;
import libKonogonka.fs.NPDM.KernelAccessControlProvider;
import libKonogonka.fs.NPDM.ServiceAccessControlProvider;
import libKonogonka.Tools.NPDM.KernelAccessControlProvider;
import libKonogonka.Tools.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.fs.NPDM.ACID;
package libKonogonka.Tools.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.fs.NPDM;
package libKonogonka.Tools.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 final byte[] raw;
private 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.fs.NPDM;
package libKonogonka.Tools.NPDM;
import libKonogonka.fs.NPDM.ACI0.ACI0Provider;
import libKonogonka.fs.NPDM.ACID.ACIDProvider;
import libKonogonka.Tools.NPDM.ACI0.ACI0Provider;
import libKonogonka.Tools.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.fs.NPDM;
package libKonogonka.Tools.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.fs.NSO;
package libKonogonka.Tools.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.fs.NSO;
package libKonogonka.Tools.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.fs.NSO;
package libKonogonka.Tools.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.fs.NSO;
package libKonogonka.Tools.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.fs.NSO;
package libKonogonka.Tools.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.fs.NSO;
package libKonogonka.Tools.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.fs.PFS0;
package libKonogonka.Tools.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.fs.PFS0;
package libKonogonka.Tools.PFS0;
import libKonogonka.RainbowDump;
import libKonogonka.fs.ExportAble;
import libKonogonka.fs.ISuperProvider;
import libKonogonka.fs.NCA.NCASectionTableBlock.SuperBlockPFS0;
import libKonogonka.Tools.ExportAble;
import libKonogonka.Tools.ISuperProvider;
import libKonogonka.Tools.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.fs.PFS0;
package libKonogonka.Tools.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.fs.RomFs;
package libKonogonka.Tools.RomFs;
import libKonogonka.Converter;
import libKonogonka.fs.RomFs.view.FileSystemTreeViewMaker;
import libKonogonka.Tools.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.fs.RomFs;
package libKonogonka.Tools.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.fs.RomFs;
package libKonogonka.Tools.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.fs.RomFs;
package libKonogonka.Tools.RomFs;
import libKonogonka.fs.ExportAble;
import libKonogonka.fs.RomFs.view.DirectoryMetaTablePlainView;
import libKonogonka.fs.RomFs.view.FileMetaTablePlainView;
import libKonogonka.Tools.ExportAble;
import libKonogonka.Tools.RomFs.view.DirectoryMetaTablePlainView;
import libKonogonka.Tools.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.fs.RomFs.view;
package libKonogonka.Tools.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.fs.RomFs.view;
package libKonogonka.Tools.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.fs.RomFs.view;
package libKonogonka.Tools.RomFs.view;
import libKonogonka.fs.RomFs.FileSystemEntry;
import libKonogonka.Tools.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.fs.TIK;
package libKonogonka.Tools.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.fs.XCI;
package libKonogonka.Tools.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.fs.XCI;
package libKonogonka.Tools.XCI;
import libKonogonka.fs.ExportAble;
import libKonogonka.fs.ISuperProvider;
import libKonogonka.Tools.ExportAble;
import libKonogonka.Tools.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.fs.XCI;
package libKonogonka.Tools.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.fs.XCI;
package libKonogonka.Tools.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.fs.XCI;
package libKonogonka.Tools.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.fs.XCI;
package libKonogonka.Tools.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.fs.other.System2;
package libKonogonka.Tools.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.fs.other.System2;
package libKonogonka.Tools.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.fs.other.System2;
package libKonogonka.Tools.other.System2;
import libKonogonka.KeyChainHolder;
import libKonogonka.fs.ExportAble;
import libKonogonka.fs.other.System2.ini1.Ini1Provider;
import libKonogonka.Tools.ExportAble;
import libKonogonka.Tools.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.fs.other.System2.ini1;
package libKonogonka.Tools.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.fs.other.System2.ini1;
package libKonogonka.Tools.other.System2.ini1;
import libKonogonka.fs.ExportAble;
import libKonogonka.fs.other.System2.System2Header;
import libKonogonka.Tools.ExportAble;
import libKonogonka.Tools.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.fs.other.System2.ini1;
package libKonogonka.Tools.other.System2.ini1;
import libKonogonka.Converter;
import libKonogonka.RainbowDump;
import libKonogonka.fs.NPDM.KernelAccessControlProvider;
import libKonogonka.fs.NSO.SegmentHeader;
import libKonogonka.Tools.NPDM.KernelAccessControlProvider;
import libKonogonka.Tools.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.fs.other.System2.ini1;
package libKonogonka.Tools.other.System2.ini1;
import libKonogonka.fs.ExportAble;
import libKonogonka.Tools.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.fs.other.System2.ini1;
package libKonogonka.Tools.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.fs.other.System2.ini1;
package libKonogonka.Tools.other.System2.ini1;
import libKonogonka.fs.NSO.SegmentHeader;
import libKonogonka.Tools.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.fs.other.System2.ini1.KIP1Provider.HEADER_SIZE;
import static libKonogonka.Tools.other.System2.ini1.KIP1Provider.HEADER_SIZE;
public class Kip1Unpacker {
private static final String DECOMPRESSED_FILE_POSTFIX = "_decompressed";
@ -42,6 +42,7 @@ 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;
@ -149,7 +150,7 @@ public class Kip1Unpacker {
private void makeHeader(){
textFileOffsetNew = kip1Header.getTextSegmentHeader().getMemoryOffset();
roDataFileOffsetNew = kip1Header.getRoDataSegmentHeader().getMemoryOffset();
int rwDataFileOffsetNew = kip1Header.getRwDataSegmentHeader().getMemoryOffset();
rwDataFileOffsetNew = kip1Header.getRwDataSegmentHeader().getMemoryOffset();
byte flags = kip1Header.getFlags();
flags &= ~0b111; //mark .text .ro .rw as 'not compress'

View file

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

View file

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

View file

@ -34,8 +34,10 @@ import java.util.function.LongFunction;
* XTS-AES cipher with arbitrary (non 128-bit aligned) data unit lengths.
*
* @author Ahseya
*
* Class updated for NCAs usage.
*/
/**
* Updated for special usage by Dmitry Isaenko.
* */
@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.AESEngine;
import org.bouncycastle.crypto.engines.AESFastEngine;
import org.bouncycastle.crypto.params.KeyParameter;
import java.util.Arrays;
@ -36,8 +36,10 @@ import java.util.Objects;
* XTS core functions.
*
* @author Ahseya
*
* Class updated for NCAs usage.
*/
/**
* Updated for special usage by Dmitry Isaenko.
* */
@NotThreadSafe
class XTSCore {
@ -54,7 +56,7 @@ class XTSCore {
}
XTSCore(XTSTweak tweak) {
this(new AESEngine(), tweak);
this(new AESFastEngine(), tweak);
}
XTSCore(boolean isDefault) {
@ -62,7 +64,7 @@ class XTSCore {
}
XTSCore init(boolean forEncryption, KeyParameter key) throws IllegalArgumentException {
byte[] k = key.getKey();
byte[] k = ((KeyParameter) 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.AESEngine;
import org.bouncycastle.crypto.engines.AESFastEngine;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.util.Pack;
@ -38,11 +38,29 @@ import java.util.function.LongFunction;
* XTS tweak with pluggable tweak function.
*
* @author Ahseya
*
* Class updated for NCAs usage.
*/
/**
* Updated for special usage by Dmitry Isaenko.
* */
@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;
@ -66,7 +84,7 @@ class XTSTweak {
}
XTSTweak(LongFunction<byte[]> tweakFunction) {
this(new AESEngine(), tweakFunction);
this(new AESFastEngine(), tweakFunction);
}
XTSTweak(boolean isDefault) {
@ -74,20 +92,6 @@ 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.fs.NCA.NCAProvider;
import libKonogonka.fs.RomFs.FileSystemEntry;
import libKonogonka.fs.RomFs.RomFsProvider;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.RomFs.FileSystemEntry;
import libKonogonka.Tools.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.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.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.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.fs.NCA.NCAProvider;
import libKonogonka.fs.RomFs.FileSystemEntry;
import libKonogonka.fs.RomFs.RomFsProvider;
import libKonogonka.fs.other.System2.System2Provider;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.RomFs.FileSystemEntry;
import libKonogonka.Tools.RomFs.RomFsProvider;
import libKonogonka.Tools.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.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.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.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.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.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.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.fs.NCA.NCAProvider;
import libKonogonka.fs.NSO.NSO0Provider;
import libKonogonka.fs.PFS0.PFS0Provider;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.NSO.NSO0Provider;
import libKonogonka.Tools.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<String, String> entry : keyChainHolder.getKey_area_key_application().entrySet()){
for (Map.Entry 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<String, String> entry : keyChainHolder.getKey_area_key_ocean().entrySet()){
for (Map.Entry 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<String, String> entry : keyChainHolder.getKey_area_key_system().entrySet()){
for (Map.Entry entry : keyChainHolder.getKey_area_key_system().entrySet()){
System.out.println(entry.getKey() + " - " + entry.getValue());
}
}
void printKAKTitleKek(){
System.out.println("-=== titlekek test ===-");
for (Map.Entry<String, String> entry : keyChainHolder.getTitlekek().entrySet()){
for (Map.Entry entry : keyChainHolder.getTitlekek().entrySet()){
System.out.println(entry.getKey() + " - " + entry.getValue());
}
}
void printRawKeySet(){
System.out.println("-=== Raw Key Set (everything) test ===-");
for (Map.Entry<String, String> entry : keyChainHolder.getRawKeySet().entrySet()){
for (Map.Entry 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.fs.NCA.NCAProvider;
import libKonogonka.Tools.NCA.NCAProvider;
import org.junit.jupiter.api.*;
import java.io.BufferedReader;

View file

@ -18,7 +18,7 @@
*/
package libKonogonka.unsorted;
import libKonogonka.fs.NSO.NSO0Provider;
import libKonogonka.Tools.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.fs.NCA.NCAProvider;
import libKonogonka.fs.NSO.NSO0Provider;
import libKonogonka.fs.PFS0.PFS0Provider;
import libKonogonka.fs.PFS0.PFS0subFile;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.NSO.NSO0Provider;
import libKonogonka.Tools.PFS0.PFS0Provider;
import libKonogonka.Tools.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.fs.NCA.NCAProvider;
import libKonogonka.fs.PFS0.PFS0Provider;
import libKonogonka.fs.PFS0.PFS0subFile;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.PFS0.PFS0Provider;
import libKonogonka.Tools.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(Files.newOutputStream(contentFile.toPath()));
BufferedOutputStream extractedFileBOS = new BufferedOutputStream(new FileOutputStream(contentFile));
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.fs.PFS0.PFS0Provider;
import libKonogonka.fs.PFS0.PFS0subFile;
import libKonogonka.Tools.PFS0.PFS0Provider;
import libKonogonka.Tools.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.fs.NCA.NCAProvider;
import libKonogonka.fs.PFS0.PFS0Provider;
import libKonogonka.fs.PFS0.PFS0subFile;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.PFS0.PFS0Provider;
import libKonogonka.Tools.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(Files.newOutputStream(contentFile.toPath()));
BufferedOutputStream extractedFileBOS = new BufferedOutputStream(new FileOutputStream(contentFile));
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.fs.RomFs.FileSystemEntry;
import libKonogonka.fs.RomFs.RomFsProvider;
import libKonogonka.Tools.RomFs.FileSystemEntry;
import libKonogonka.Tools.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.fs.NCA.NCAProvider;
import libKonogonka.fs.NCA.NCASectionTableBlock.NcaFsHeader;
import libKonogonka.fs.RomFs.FileSystemEntry;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.NCA.NCASectionTableBlock.NcaFsHeader;
import libKonogonka.Tools.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.fs.NCA.NCAProvider;
import libKonogonka.fs.XCI.HFS0File;
import libKonogonka.fs.XCI.HFS0Provider;
import libKonogonka.fs.XCI.XCIProvider;
import libKonogonka.Tools.NCA.NCAProvider;
import libKonogonka.Tools.XCI.HFS0File;
import libKonogonka.Tools.XCI.HFS0Provider;
import libKonogonka.Tools.XCI.XCIProvider;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;