From 3d5a4b6286921260aacb81ba2b83f9fa7a6e943f Mon Sep 17 00:00:00 2001 From: Dmitry Isaenko Date: Sun, 5 Apr 2020 22:03:46 +0300 Subject: [PATCH] Add Header1SignatureKeyGeneration and Key Generation Reserved fields support to NCA Header --- .../Controllers/NCA/NCAController.java | 10 +- .../java/konogonka/Tools/NCA/NCAProvider.java | 8 +- src/main/resources/FXML/NCA/NCATab.fxml | 104 +++++++++++++++--- 3 files changed, 104 insertions(+), 18 deletions(-) diff --git a/src/main/java/konogonka/Controllers/NCA/NCAController.java b/src/main/java/konogonka/Controllers/NCA/NCAController.java index 58fd610..83f9026 100644 --- a/src/main/java/konogonka/Controllers/NCA/NCAController.java +++ b/src/main/java/konogonka/Controllers/NCA/NCAController.java @@ -51,6 +51,8 @@ public class NCAController implements ITabController { contentIndexLbl, sdkVersionLbl, cryptoType2Lbl, + header1SignatureKeyGenerationLbl, + keyGenerationReservedLbl, ticketLbl; @FXML private TextField @@ -94,9 +96,9 @@ public class NCAController implements ITabController { keysMap.put(pair[0], pair[1]); } - Task analyzer = Analyzer.analyzeNCA(file, keysMap, offset); + Task analyzer = Analyzer.analyzeNCA(file, keysMap, offset); analyzer.setOnSucceeded(e->{ - populateFields((NCAProvider) analyzer.getValue()); + populateFields(analyzer.getValue()); }); Thread workThread = new Thread(analyzer); workThread.setDaemon(true); @@ -125,6 +127,8 @@ public class NCAController implements ITabController { titleIdLbl.setText("-"); sdkVersionLbl.setText("-"); cryptoType2Lbl.setText("-"); + header1SignatureKeyGenerationLbl.setText("-"); + keyGenerationReservedLbl.setText("-"); ticketLbl.setText("-"); contentIndexLbl.setText("-"); sha256section1TF.setText("-"); @@ -174,6 +178,8 @@ public class NCAController implements ITabController { +"."+ncaProvider.getSdkVersion()[1] +"."+ncaProvider.getSdkVersion()[0]); cryptoType2Lbl.setText(Byte.toString(ncaProvider.getCryptoType2())); + header1SignatureKeyGenerationLbl.setText(Byte.toString(ncaProvider.getHeader1SignatureKeyGeneration())); + keyGenerationReservedLbl.setText(byteArrToHexString(ncaProvider.getKeyGenerationReserved())); ticketLbl.setText(byteArrToHexString(ncaProvider.getRightsId())); sha256section1TF.setText(byteArrToHexString(ncaProvider.getSha256hash0())); sha256section2TF.setText(byteArrToHexString(ncaProvider.getSha256hash1())); diff --git a/src/main/java/konogonka/Tools/NCA/NCAProvider.java b/src/main/java/konogonka/Tools/NCA/NCAProvider.java index 57b61f4..fa64959 100644 --- a/src/main/java/konogonka/Tools/NCA/NCAProvider.java +++ b/src/main/java/konogonka/Tools/NCA/NCAProvider.java @@ -31,7 +31,9 @@ public class NCAProvider { private byte[] titleId; private byte[] contentIndx; private byte[] sdkVersion; // version ver_revision.ver_micro.vev_minor.ver_major - private byte cryptoType2; // keyblob index. Considering as number within application/ocean/system + private byte cryptoType2; // keyblob index. Considering as number within application/ocean/system | AKA KeyGeneration + private byte Header1SignatureKeyGeneration; + private byte[] keyGenerationReserved; private byte[] rightsId; private byte cryptoTypeReal; @@ -143,6 +145,8 @@ public class NCAProvider { contentIndx = Arrays.copyOfRange(decryptedData, 0x218, 0x21C); sdkVersion = Arrays.copyOfRange(decryptedData, 0x21c, 0x220); cryptoType2 = decryptedData[0x220]; + Header1SignatureKeyGeneration = decryptedData[0x221]; + keyGenerationReserved = Arrays.copyOfRange(decryptedData, 0x222, 0x230); rightsId = Arrays.copyOfRange(decryptedData, 0x230, 0x240); byte[] tableBytes = Arrays.copyOfRange(decryptedData, 0x240, 0x280); byte[] sha256tableBytes = Arrays.copyOfRange(decryptedData, 0x280, 0x300); @@ -239,6 +243,8 @@ public class NCAProvider { public byte[] getContentIndx() { return contentIndx; } public byte[] getSdkVersion() { return sdkVersion; } public byte getCryptoType2() { return cryptoType2; } + public byte getHeader1SignatureKeyGeneration() { return Header1SignatureKeyGeneration; } + public byte[] getKeyGenerationReserved() { return keyGenerationReserved; } public byte[] getRightsId() { return rightsId; } public byte[] getSha256hash0() { return sha256hash0; } diff --git a/src/main/resources/FXML/NCA/NCATab.fxml b/src/main/resources/FXML/NCA/NCATab.fxml index bd5fd27..c5f6a2e 100644 --- a/src/main/resources/FXML/NCA/NCATab.fxml +++ b/src/main/resources/FXML/NCA/NCATab.fxml @@ -40,6 +40,8 @@ + + @@ -73,7 +75,7 @@ - + - + - + - + - + - + - + - + - + - + @@ -438,7 +440,7 @@ - + - + - + - + @@ -580,7 +582,7 @@ - + @@ -685,6 +687,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +