Add Header1SignatureKeyGeneration and Key Generation Reserved fields support to NCA Header

master
Dmitry Isaenko 2020-04-05 22:03:46 +03:00
parent d917d4c22f
commit 3d5a4b6286
3 changed files with 104 additions and 18 deletions

View File

@ -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<NCAProvider> 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()));

View File

@ -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; }

View File

@ -40,6 +40,8 @@
<RowConstraints maxHeight="30.0" minHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="30.0" vgrow="SOMETIMES" />
@ -73,7 +75,7 @@
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.rowIndex="14">
<AnchorPane styleClass="customGrid" GridPane.rowIndex="16">
<children>
<Label text="0x240" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
@ -145,7 +147,7 @@
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.rowIndex="13">
<AnchorPane styleClass="customGrid" GridPane.rowIndex="15">
<children>
<Label text="0x230" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
@ -163,7 +165,7 @@
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.rowIndex="15">
<AnchorPane styleClass="customGrid" GridPane.rowIndex="17">
<children>
<Label text="0x280" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
@ -172,7 +174,7 @@
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.rowIndex="16">
<AnchorPane styleClass="customGrid" GridPane.rowIndex="18">
<children>
<Label text="0x300" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
@ -244,7 +246,7 @@
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="1" GridPane.rowIndex="16">
<AnchorPane styleClass="customGrid" GridPane.columnIndex="1" GridPane.rowIndex="18">
<children>
<Label text="0x10*0x4(0x40)" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
@ -253,7 +255,7 @@
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="1" GridPane.rowIndex="15">
<AnchorPane styleClass="customGrid" GridPane.columnIndex="1" GridPane.rowIndex="17">
<children>
<Label text="0x20*0x4(0x80)" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
@ -262,7 +264,7 @@
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="1" GridPane.rowIndex="14">
<AnchorPane styleClass="customGrid" GridPane.columnIndex="1" GridPane.rowIndex="16">
<children>
<Label text="0x10*0x4(0x40)" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
@ -343,7 +345,7 @@
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="1" GridPane.rowIndex="13">
<AnchorPane styleClass="customGrid" GridPane.columnIndex="1" GridPane.rowIndex="15">
<children>
<Label text="0x10" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
@ -406,7 +408,7 @@
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="2" GridPane.rowIndex="13">
<AnchorPane styleClass="customGrid" GridPane.columnIndex="2" GridPane.rowIndex="15">
<children>
<Label text="Rights ID (title.keys key-name to decrypt)" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
@ -415,7 +417,7 @@
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="2" GridPane.columnSpan="2" GridPane.rowIndex="14">
<AnchorPane styleClass="customGrid" GridPane.columnIndex="2" GridPane.columnSpan="2" GridPane.rowIndex="16">
<children>
<VBox spacing="5.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
@ -438,7 +440,7 @@
</VBox>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="2" GridPane.rowIndex="15">
<AnchorPane styleClass="customGrid" GridPane.columnIndex="2" GridPane.rowIndex="17">
<children>
<Label text="Table of SHA256 hashes, over each 0x200-byte Section Header Block." AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
@ -447,7 +449,7 @@
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="2" GridPane.rowIndex="16">
<AnchorPane styleClass="customGrid" GridPane.columnIndex="2" GridPane.rowIndex="18">
<children>
<Label text="Key area" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
@ -537,7 +539,7 @@
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="3" GridPane.rowIndex="13">
<AnchorPane styleClass="customGrid" GridPane.columnIndex="3" GridPane.rowIndex="15">
<children>
<Label fx:id="ticketLbl" text="-" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
@ -565,7 +567,7 @@
<TextField fx:id="rsa2048twoTF" editable="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="3" GridPane.rowIndex="15">
<AnchorPane styleClass="customGrid" GridPane.columnIndex="3" GridPane.rowIndex="17">
<children>
<VBox spacing="3.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
@ -580,7 +582,7 @@
</VBox>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="3" GridPane.rowIndex="16">
<AnchorPane styleClass="customGrid" GridPane.columnIndex="3" GridPane.rowIndex="18">
<children>
<VBox spacing="3.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
@ -685,6 +687,78 @@
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.rowIndex="13">
<children>
<Label layoutX="5.0" layoutY="6.0" text="0x221" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.rowIndex="14">
<children>
<Label text="0x222" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="1" GridPane.rowIndex="13">
<children>
<Label text="0x1" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="1" GridPane.rowIndex="14">
<children>
<Label text="0xE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="2" GridPane.rowIndex="13">
<children>
<Label text="[9.0.0+] Header1SignatureKeyGeneration (0 or 1) " AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="2" GridPane.rowIndex="14">
<children>
<Label text="Reserved (?)" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="3" GridPane.rowIndex="13">
<children>
<Label fx:id="header1SignatureKeyGenerationLbl" text="-" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="3" GridPane.rowIndex="14">
<children>
<Label fx:id="keyGenerationReservedLbl" text="-" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
</children>
</GridPane>
</children>