From 14479963d5be1300624bf0c93d4ae03af4ed024f Mon Sep 17 00:00:00 2001 From: Dmitry Isaenko Date: Fri, 23 Dec 2022 06:23:40 +0300 Subject: [PATCH] cosmetic fixes --- src/main/java/libKonogonka/Converter.java | 2 +- .../libKonogonka/Tools/NCA/NCAProvider.java | 8 +-- .../NCA/NCASectionTableBlock/NcaFsHeader.java | 50 +++++++++---------- .../libKonogonka/Tools/NSO/NSO0Header.java | 12 ++--- .../libKonogonka/Tools/PFS0/PFS0Header.java | 4 +- .../Tools/XCI/XCIGamecardCert.java | 14 +++--- 6 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/main/java/libKonogonka/Converter.java b/src/main/java/libKonogonka/Converter.java index c600ab3..e3d71e6 100644 --- a/src/main/java/libKonogonka/Converter.java +++ b/src/main/java/libKonogonka/Converter.java @@ -47,7 +47,7 @@ public class Converter { return ByteBuffer.wrap(holder).order(ByteOrder.LITTLE_ENDIAN).getLong(); } - public static String byteArrToHexString(byte[] bArr){ + public static String byteArrToHexStringAsLE(byte[] bArr){ if (bArr == null) return ""; StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/libKonogonka/Tools/NCA/NCAProvider.java b/src/main/java/libKonogonka/Tools/NCA/NCAProvider.java index 0c23929..65789eb 100644 --- a/src/main/java/libKonogonka/Tools/NCA/NCAProvider.java +++ b/src/main/java/libKonogonka/Tools/NCA/NCAProvider.java @@ -33,7 +33,7 @@ import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.HashMap; -import static libKonogonka.Converter.byteArrToHexString; +import static libKonogonka.Converter.byteArrToHexStringAsLE; import static libKonogonka.Converter.getLElong; // TODO: check file size @@ -253,7 +253,7 @@ public class NCAProvider { if (Arrays.equals(rightsId, new byte[0x10])) // If empty Rights ID return decryptedKey2; // NOTE: Just remember this dumb hack - byte[] rightsIdKey = hexStrToByteArray(keys.get(byteArrToHexString(rightsId))); // throws NullPointerException + byte[] rightsIdKey = hexStrToByteArray(keys.get(byteArrToHexStringAsLE(rightsId))); // throws NullPointerException SecretKeySpec skSpec = new SecretKeySpec( hexStrToByteArray(keys.get(String.format("titlekek_%02x", cryptoTypeReal)) @@ -264,7 +264,7 @@ public class NCAProvider { } catch (Exception e){ throw new Exception("No title.keys loaded for '"+ - String.format("titlekek_%02x", cryptoTypeReal)+"' or '"+byteArrToHexString(rightsId)+"'? ("+e+")", e); + String.format("titlekek_%02x", cryptoTypeReal)+"' or '"+ byteArrToHexStringAsLE(rightsId)+"'? ("+e+")", e); } } private void setupNcaContentByNumber(int number, byte[] key){ @@ -371,7 +371,7 @@ public class NCAProvider { if (Arrays.equals(rightsId, new byte[0x10])) return false; else - return keys.containsKey(byteArrToHexString(rightsId)); + return keys.containsKey(byteArrToHexStringAsLE(rightsId)); } /** * Get content for the selected section diff --git a/src/main/java/libKonogonka/Tools/NCA/NCASectionTableBlock/NcaFsHeader.java b/src/main/java/libKonogonka/Tools/NCA/NCASectionTableBlock/NcaFsHeader.java index 977a76c..d0a8c2a 100644 --- a/src/main/java/libKonogonka/Tools/NCA/NCASectionTableBlock/NcaFsHeader.java +++ b/src/main/java/libKonogonka/Tools/NCA/NCASectionTableBlock/NcaFsHeader.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.Logger; import java.util.Arrays; -import static libKonogonka.Converter.byteArrToHexString; +import static libKonogonka.Converter.byteArrToHexStringAsLE; import static libKonogonka.Converter.getLElong; public class NcaFsHeader { @@ -178,12 +178,12 @@ public class NcaFsHeader { } log.debug("NCASectionBlock:\n" + - "Version : " + byteArrToHexString(version) + "\n" + + "Version : " + byteArrToHexStringAsLE(version) + "\n" + "FS Type : " + fsType +(fsType == 0?" (RomFS)":fsType == 1?" (PartitionFS)":" (Unknown)")+ "\n" + "Hash Type : " + hashType +" ("+ hashTypeDescription + ")\n" + "Crypto Type : " + cryptoType + " (" + cryptoTypeDescription + ")\n" + "Meta Data Hash Type : " + metaDataHashType + "\n" + - "Padding : " + byteArrToHexString(padding) + "\n" + + "Padding : " + byteArrToHexStringAsLE(padding) + "\n" + "Super Block IVFC : " + (superBlockIVFC == null ? "-\n": "YES\n") + "Super Block PFS0 : " + (superBlockPFS0 == null ? "-\n": "YES\n") + "================================================================================================\n" + @@ -197,47 +197,47 @@ public class NcaFsHeader { "| Level 1 Offset : " + RainbowDump.formatDecHexString(superBlockIVFC.getLvl1Offset()) + "\n" + "| Level 1 Size : " + RainbowDump.formatDecHexString(superBlockIVFC.getLvl1Size()) + "\n" + "| Level 1 Block Size (log2) : " + RainbowDump.formatDecHexString(superBlockIVFC.getLvl1SBlockSize()) + "\n" + - "| Level 1 reserved : " + byteArrToHexString(superBlockIVFC.getReserved1()) + "\n\n" + + "| Level 1 reserved : " + byteArrToHexStringAsLE(superBlockIVFC.getReserved1()) + "\n\n" + "| Level 2 Offset : " + RainbowDump.formatDecHexString(superBlockIVFC.getLvl2Offset()) + "\n" + "| Level 2 Size : " + RainbowDump.formatDecHexString(superBlockIVFC.getLvl2Size()) + "\n" + "| Level 2 Block Size (log2) : " + RainbowDump.formatDecHexString(superBlockIVFC.getLvl2SBlockSize()) + "\n" + - "| Level 2 reserved : " + byteArrToHexString(superBlockIVFC.getReserved2()) + "\n\n" + + "| Level 2 reserved : " + byteArrToHexStringAsLE(superBlockIVFC.getReserved2()) + "\n\n" + "| Level 3 Offset : " + RainbowDump.formatDecHexString(superBlockIVFC.getLvl3Offset()) + "\n" + "| Level 3 Size : " + RainbowDump.formatDecHexString(superBlockIVFC.getLvl3Size()) + "\n" + "| Level 3 Block Size (log2) : " + RainbowDump.formatDecHexString(superBlockIVFC.getLvl3SBlockSize()) + "\n" + - "| Level 3 reserved : " + byteArrToHexString(superBlockIVFC.getReserved3()) + "\n\n" + + "| Level 3 reserved : " + byteArrToHexStringAsLE(superBlockIVFC.getReserved3()) + "\n\n" + "| Level 4 Offset : " + RainbowDump.formatDecHexString(superBlockIVFC.getLvl4Offset()) + "\n" + "| Level 4 Size : " + RainbowDump.formatDecHexString(superBlockIVFC.getLvl4Size()) + "\n" + "| Level 4 Block Size (log2) : " + RainbowDump.formatDecHexString(superBlockIVFC.getLvl4SBlockSize()) + "\n" + - "| Level 4 reserved : " + byteArrToHexString(superBlockIVFC.getReserved4()) + "\n\n" + + "| Level 4 reserved : " + byteArrToHexStringAsLE(superBlockIVFC.getReserved4()) + "\n\n" + "| Level 5 Offset : " + RainbowDump.formatDecHexString(superBlockIVFC.getLvl5Offset()) + "\n" + "| Level 5 Size : " + RainbowDump.formatDecHexString(superBlockIVFC.getLvl5Size()) + "\n" + "| Level 5 Block Size (log2) : " + RainbowDump.formatDecHexString(superBlockIVFC.getLvl5SBlockSize()) + "\n" + - "| Level 5 reserved : " + byteArrToHexString(superBlockIVFC.getReserved5()) + "\n\n" + + "| Level 5 reserved : " + byteArrToHexStringAsLE(superBlockIVFC.getReserved5()) + "\n\n" + "| Level 6 Offset : " + RainbowDump.formatDecHexString(superBlockIVFC.getLvl6Offset()) + "\n" + "| Level 6 Size : " + RainbowDump.formatDecHexString(superBlockIVFC.getLvl6Size()) + "\n" + "| Level 6 Block Size (log2) : " + RainbowDump.formatDecHexString(superBlockIVFC.getLvl6SBlockSize()) + "\n" + - "| Level 6 reserved : " + byteArrToHexString(superBlockIVFC.getReserved6()) + "\n\n" + + "| Level 6 reserved : " + byteArrToHexStringAsLE(superBlockIVFC.getReserved6()) + "\n\n" + - "| SignatureSalt : " + byteArrToHexString(superBlockIVFC.getSignatureSalt()) + "\n" + - "| Master Hash : " + byteArrToHexString(superBlockIVFC.getMasterHash()) + "\n" + - "| Reserved (tail) : " + byteArrToHexString(superBlockIVFC.getReservedTail()) + "\n" + "| SignatureSalt : " + byteArrToHexStringAsLE(superBlockIVFC.getSignatureSalt()) + "\n" + + "| Master Hash : " + byteArrToHexStringAsLE(superBlockIVFC.getMasterHash()) + "\n" + + "| Reserved (tail) : " + byteArrToHexStringAsLE(superBlockIVFC.getReservedTail()) + "\n" ) :(((fsType == 0x1) && (hashType == 0x2))? ("| Hash Data - PFS0\n" + - "| SHA256 hash : " + byteArrToHexString(superBlockPFS0.getSHA256hash()) + "\n" + + "| SHA256 hash : " + byteArrToHexStringAsLE(superBlockPFS0.getSHA256hash()) + "\n" + "| Block Size (bytes) : " + superBlockPFS0.getBlockSize() + "\n" + "| Layer Count (2) : " + superBlockPFS0.getLayerCount() + "\n" + "| Hash table offset : " + RainbowDump.formatDecHexString(superBlockPFS0.getHashTableOffset()) + "\n" + "| Hash table size : " + RainbowDump.formatDecHexString(superBlockPFS0.getHashTableSize()) + "\n" + "| PFS0 header offset : " + RainbowDump.formatDecHexString(superBlockPFS0.getPfs0offset()) + "\n" + "| PFS0 header size : " + RainbowDump.formatDecHexString(superBlockPFS0.getPfs0size()) + "\n" + - "| Unknown (reserved) : " + byteArrToHexString(superBlockPFS0.getZeroes()) + "\n" + "| Unknown (reserved) : " + byteArrToHexStringAsLE(superBlockPFS0.getZeroes()) + "\n" ) : " // Hash Data - EMPTY \\\\ \n" @@ -250,17 +250,17 @@ public class NcaFsHeader { "Magic ('BKTR') : " + BktrSection1.getMagic() + "\n" + "Version : " + BktrSection1.getVersion() + "\n" + "EntryCount : " + BktrSection1.getEntryCount() + "\n" + - "Unknown (reserved) : " + byteArrToHexString(BktrSection1.getUnknown()) + "\n" + + "Unknown (reserved) : " + byteArrToHexStringAsLE(BktrSection1.getUnknown()) + "\n" + "------------------------------------------------------------------------------------------------\n" + "AesCtrEx Offset : " + PatchInfoOffsetSection2 + "\n" + "AesCtrEx Size : " + PatchInfoSizeSection2 + "\n" + "Magic ('BKTR') : " + BktrSection2.getMagic() + "\n" + "Version : " + BktrSection2.getVersion() + "\n" + "EntryCount : " + BktrSection2.getEntryCount() + "\n" + - "Unknown (reserved) : " + byteArrToHexString(BktrSection2.getUnknown()) + "\n" + + "Unknown (reserved) : " + byteArrToHexStringAsLE(BktrSection2.getUnknown()) + "\n" + "================================================================================================\n" + - "Generation : " + byteArrToHexString(generation) + "\n" + - "Section CTR : " + byteArrToHexString(sectionCTR) + "\n" + + "Generation : " + byteArrToHexStringAsLE(generation) + "\n" + + "Section CTR : " + byteArrToHexStringAsLE(sectionCTR) + "\n" + "================================================================================================\n" + " Sparse Info\n" + "Table Offset : " + sparseInfo.getOffset() + "\n" + @@ -268,10 +268,10 @@ public class NcaFsHeader { "Magic ('BKTR') : " + sparseInfo.getBktrMagic() + "\n" + "Version : " + sparseInfo.getBktrVersion() + "\n" + "EntryCount : " + sparseInfo.getBktrEntryCount() + "\n" + - "Unknown (BKTR) : " + byteArrToHexString(sparseInfo.getBktrUnknown()) + "\n" + + "Unknown (BKTR) : " + byteArrToHexStringAsLE(sparseInfo.getBktrUnknown()) + "\n" + "PhysicalOffset : " + sparseInfo.getPhysicalOffset() + "\n" + - "Generation : " + byteArrToHexString(sparseInfo.getGeneration()) + "\n" + - "Unknown (reserved) : " + byteArrToHexString(sparseInfo.getUnknown()) + "\n" + + "Generation : " + byteArrToHexStringAsLE(sparseInfo.getGeneration()) + "\n" + + "Unknown (reserved) : " + byteArrToHexStringAsLE(sparseInfo.getUnknown()) + "\n" + "================================================================================================\n" + " Compression Info\n" + "Table Offset : " + compressionInfo.getOffset() + "\n" + @@ -279,15 +279,15 @@ public class NcaFsHeader { "Magic ('BKTR') : " + compressionInfo.getBktrMagic() + "\n" + "Version : " + compressionInfo.getBktrVersion() + "\n" + "EntryCount : " + compressionInfo.getBktrEntryCount() + "\n" + - "Unknown (reserved) : " + byteArrToHexString(compressionInfo.getBktrUnknown()) + "\n" + - "Reserved : " + byteArrToHexString(compressionInfo.getUnknown()) + "\n" + + "Unknown (reserved) : " + byteArrToHexStringAsLE(compressionInfo.getBktrUnknown()) + "\n" + + "Reserved : " + byteArrToHexStringAsLE(compressionInfo.getUnknown()) + "\n" + "================================================================================================\n" + " Meta Data Hash Data Info\n" + "Table Offset : " + metaDataHashDataInfo.getOffset() + "\n" + "Table Size : " + metaDataHashDataInfo.getSize() + "\n" + - "Unknown (reserved) : " + byteArrToHexString(metaDataHashDataInfo.getTableHash()) + "\n" + + "Unknown (reserved) : " + byteArrToHexStringAsLE(metaDataHashDataInfo.getTableHash()) + "\n" + "================================================================================================\n" + - "Unknown End Padding : " + byteArrToHexString(unknownEndPadding) + "\n" + + "Unknown End Padding : " + byteArrToHexStringAsLE(unknownEndPadding) + "\n" + "################################################################################################\n" ); } diff --git a/src/main/java/libKonogonka/Tools/NSO/NSO0Header.java b/src/main/java/libKonogonka/Tools/NSO/NSO0Header.java index dd5af64..7c3d9f0 100644 --- a/src/main/java/libKonogonka/Tools/NSO/NSO0Header.java +++ b/src/main/java/libKonogonka/Tools/NSO/NSO0Header.java @@ -121,7 +121,7 @@ public class NSO0Header { " ============================================================= \n" + "Magic \"NSO0\" " + magic + "\n" + "Version (always 0) " + version + "\n" + - "Reserved " + Converter.byteArrToHexString(upperReserved) + "\n" + + "Reserved " + Converter.byteArrToHexStringAsLE(upperReserved) + "\n" + "Flags " + Converter.intToBinaryString(flags) + "\n" + " |- 0. .text Compress " + isTextCompressFlag() + "\n" + " |- 1. .rodata Compress " + isRoCompressFlag() + "\n" + @@ -147,11 +147,11 @@ public class NSO0Header { " |- Memory Offset - - - - - - - - - - - - - " + RainbowDump.formatDecHexString(dataSegmentHeader.getMemoryOffset()) + "\n" + " |- Size As Decompressed - - - - - - - - - " + RainbowDump.formatDecHexString(dataSegmentHeader.getSizeAsDecompressed()) + "\n" + " .bss Size " + RainbowDump.formatDecHexString(bssSize) + "\n" + // Block Started by Symbol - "Module ID (aka Build ID) " + Converter.byteArrToHexString(moduleId) + "\n" + + "Module ID (aka Build ID) " + Converter.byteArrToHexStringAsLE(moduleId) + "\n" + " .text Size (compressed) " + RainbowDump.formatDecHexString(textCompressedSize) + "\n" + " .rodata Size (compressed) " + RainbowDump.formatDecHexString(rodataCompressedSize) + "\n" + " .data Size (compressed) " + RainbowDump.formatDecHexString(dataCompressedSize) + "\n" + - "Reserved " + Converter.byteArrToHexString(bottomReserved) + "\n" + + "Reserved " + Converter.byteArrToHexStringAsLE(bottomReserved) + "\n" + " xxx\n"+ "SegmentHeaderRelative for .api_info\n" + " |- Offset - - - - - - - - - - - - - - - - " + RainbowDump.formatDecHexString(_api_infoRelative.getOffset()) + "\n" + @@ -165,9 +165,9 @@ public class NSO0Header { " |- Offset - - - - - - - - - - - - - - - - " + RainbowDump.formatDecHexString(_dynsymRelative.getOffset()) + "\n" + " |- Size - - - - - - - - - - - - - - - - - " + RainbowDump.formatDecHexString(_dynsymRelative.getSize()) + "\n" + " xxx\n"+ - ".text decompressed' SHA-256 hash " + Converter.byteArrToHexString(textHash) + "\n" + - ".rodata decompressed' SHA-256 hash " + Converter.byteArrToHexString(rodataHash) + "\n" + - ".data decompressed' SHA-256 hash " + Converter.byteArrToHexString(dataHash) + "\n" + + ".text decompressed' SHA-256 hash " + Converter.byteArrToHexStringAsLE(textHash) + "\n" + + ".rodata decompressed' SHA-256 hash " + Converter.byteArrToHexStringAsLE(rodataHash) + "\n" + + ".data decompressed' SHA-256 hash " + Converter.byteArrToHexStringAsLE(dataHash) + "\n" + " ============================================================= " ); } diff --git a/src/main/java/libKonogonka/Tools/PFS0/PFS0Header.java b/src/main/java/libKonogonka/Tools/PFS0/PFS0Header.java index 84b95bb..b66e963 100644 --- a/src/main/java/libKonogonka/Tools/PFS0/PFS0Header.java +++ b/src/main/java/libKonogonka/Tools/PFS0/PFS0Header.java @@ -111,13 +111,13 @@ public class PFS0Header { "Magic " + magic + "\n" + "Files count " + RainbowDump.formatDecHexString(filesCount) + "\n" + "String Table Size " + RainbowDump.formatDecHexString(stringTableSize) + "\n" + - "Padding " + Converter.byteArrToHexString(padding) + "\n\n" + "Padding " + Converter.byteArrToHexStringAsLE(padding) + "\n\n" ); for (PFS0subFile subFile : pfs0subFiles){ log.debug("\nName: " + subFile.getName() + "\n" + "Offset " + RainbowDump.formatDecHexString(subFile.getOffset()) + "\n" + "Size " + RainbowDump.formatDecHexString(subFile.getSize()) + "\n" + - "Zeroes " + Converter.byteArrToHexString(subFile.getZeroes()) + "\n" + + "Zeroes " + Converter.byteArrToHexStringAsLE(subFile.getZeroes()) + "\n" + "----------------------------------------------------------------" ); } diff --git a/src/main/java/libKonogonka/Tools/XCI/XCIGamecardCert.java b/src/main/java/libKonogonka/Tools/XCI/XCIGamecardCert.java index 4bcfa76..17e8b57 100644 --- a/src/main/java/libKonogonka/Tools/XCI/XCIGamecardCert.java +++ b/src/main/java/libKonogonka/Tools/XCI/XCIGamecardCert.java @@ -63,14 +63,14 @@ public class XCIGamecardCert { public void printDebug(){ log.debug("== XCIGamecardCert ==\n" + - "rsa2048PKCS1sig " + Converter.byteArrToHexString(rsa2048PKCS1sig) + "\n" + - "magicCert " + Converter.byteArrToHexString(magicCert) + "\n" + - "unknown1 " + Converter.byteArrToHexString(unknown1) + "\n" + + "rsa2048PKCS1sig " + Converter.byteArrToHexStringAsLE(rsa2048PKCS1sig) + "\n" + + "magicCert " + Converter.byteArrToHexStringAsLE(magicCert) + "\n" + + "unknown1 " + Converter.byteArrToHexStringAsLE(unknown1) + "\n" + "kekIndex " + kekIndex + "\n" + - "unknown2 " + Converter.byteArrToHexString(unknown2) + "\n" + - "deviceID " + Converter.byteArrToHexString(deviceID) + "\n" + - "unknown3 " + Converter.byteArrToHexString(unknown3) + "\n" + - "encryptedData " + Converter.byteArrToHexString(encryptedData) + "\n" + "unknown2 " + Converter.byteArrToHexStringAsLE(unknown2) + "\n" + + "deviceID " + Converter.byteArrToHexStringAsLE(deviceID) + "\n" + + "unknown3 " + Converter.byteArrToHexStringAsLE(unknown3) + "\n" + + "encryptedData " + Converter.byteArrToHexStringAsLE(encryptedData) + "\n" ); } }