Start working on titlekeys support
This commit is contained in:
parent
f925b9c8e1
commit
a5004a9a31
8 changed files with 259 additions and 200 deletions
|
@ -98,4 +98,11 @@ public class AppPreferences {
|
||||||
public String getSystemKey(int number){ return preferences.get("key_area_key_system_0"+number, "");}
|
public String getSystemKey(int number){ return preferences.get("key_area_key_system_0"+number, "");}
|
||||||
public void setSystemKey(int number, String key){ preferences.put("key_area_key_system_0"+number, key); }
|
public void setSystemKey(int number, String key){ preferences.put("key_area_key_system_0"+number, key); }
|
||||||
|
|
||||||
|
public int getTitleKeysCount(){ return preferences.getInt("title_keys_count", 0);}
|
||||||
|
public void setTitleKeysCount(int number){ preferences.putInt("title_keys_count", number);}
|
||||||
|
|
||||||
|
public String[] getTitleKey(int number){
|
||||||
|
return preferences.get(Integer.toString(number), "0 = 0").split(" = ", 2);
|
||||||
|
}
|
||||||
|
public void setTitleKey(int number, String name, String value){ preferences.put(Integer.toString(number), name+" = "+value); }
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,7 @@ public class NCAController implements TabController {
|
||||||
keysMap.put("key_area_key_application_0"+i, AppPreferences.getInstance().getApplicationKey(i));
|
keysMap.put("key_area_key_application_0"+i, AppPreferences.getInstance().getApplicationKey(i));
|
||||||
keysMap.put("key_area_key_ocean_0"+i, AppPreferences.getInstance().getOceanKey(i));
|
keysMap.put("key_area_key_ocean_0"+i, AppPreferences.getInstance().getOceanKey(i));
|
||||||
keysMap.put("key_area_key_system_0"+i, AppPreferences.getInstance().getSystemKey(i));
|
keysMap.put("key_area_key_system_0"+i, AppPreferences.getInstance().getSystemKey(i));
|
||||||
|
// TODO: Add titlekeys
|
||||||
}
|
}
|
||||||
|
|
||||||
AnalyzerNCA analyzerNCA = new AnalyzerNCA(file, keysMap);
|
AnalyzerNCA analyzerNCA = new AnalyzerNCA(file, keysMap);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import javafx.fxml.Initializable;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.control.TextFormatter;
|
import javafx.scene.control.TextFormatter;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.stage.FileChooser;
|
import javafx.stage.FileChooser;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import konogonka.AppPreferences;
|
import konogonka.AppPreferences;
|
||||||
|
@ -17,7 +18,9 @@ import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class SettingsController implements Initializable {
|
public class SettingsController implements Initializable {
|
||||||
@FXML
|
@FXML
|
||||||
private Button okBtn, cancelBtn, importBtn;
|
private Button okBtn, cancelBtn, importKeysBtn, importTitleKeysBtn;
|
||||||
|
@FXML
|
||||||
|
private VBox titleKeysVbox;
|
||||||
@FXML
|
@FXML
|
||||||
private TextField
|
private TextField
|
||||||
xciHdrKeyTF,
|
xciHdrKeyTF,
|
||||||
|
@ -103,13 +106,13 @@ public class SettingsController implements Initializable {
|
||||||
setTextValidation(keySys6TF);
|
setTextValidation(keySys6TF);
|
||||||
setTextValidation(keySys7TF);
|
setTextValidation(keySys7TF);
|
||||||
|
|
||||||
importBtn.setOnAction(e->{
|
importKeysBtn.setOnAction(e->{
|
||||||
FileChooser fileChooser = new FileChooser();
|
FileChooser fileChooser = new FileChooser();
|
||||||
fileChooser.setTitle("prod.keys");
|
fileChooser.setTitle("prod.keys");
|
||||||
fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));
|
fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));
|
||||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("prod.keys", "prod.keys"));
|
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("prod.keys", "prod.keys"));
|
||||||
|
|
||||||
File prodKeysFile = fileChooser.showOpenDialog(importBtn.getScene().getWindow());
|
File prodKeysFile = fileChooser.showOpenDialog(importKeysBtn.getScene().getWindow());
|
||||||
|
|
||||||
if (prodKeysFile != null && prodKeysFile.exists()) {
|
if (prodKeysFile != null && prodKeysFile.exists()) {
|
||||||
HashMap<String, String > fileMap = new HashMap<>();
|
HashMap<String, String > fileMap = new HashMap<>();
|
||||||
|
|
|
@ -38,7 +38,9 @@ public class SettingsWindow {
|
||||||
new Image(MainFx.class.getResourceAsStream("/res/settings_icon128x128.png"))
|
new Image(MainFx.class.getResourceAsStream("/res/settings_icon128x128.png"))
|
||||||
);
|
);
|
||||||
|
|
||||||
stageSettings.setScene(new Scene(parentAbout, 570, 500));
|
Scene settingsScene = new Scene(parentAbout, 800, 800);
|
||||||
|
settingsScene.getStylesheets().add("/res/app_light.css");
|
||||||
|
stageSettings.setScene(settingsScene);
|
||||||
stageSettings.setMinWidth(550.0);
|
stageSettings.setMinWidth(550.0);
|
||||||
stageSettings.setMinHeight(550.0);
|
stageSettings.setMinHeight(550.0);
|
||||||
stageSettings.show();
|
stageSettings.show();
|
||||||
|
|
|
@ -207,9 +207,10 @@ public class NCAContentPFS0 {
|
||||||
}
|
}
|
||||||
// Skip padding and go to PFS0 location
|
// Skip padding and go to PFS0 location
|
||||||
if (counter < pfs0offset){
|
if (counter < pfs0offset){
|
||||||
if ((pfs0offset-counter) != pipedInputStream.skip(pfs0offset-counter))
|
long toSkip = pfs0offset-counter;
|
||||||
|
if (toSkip != pipedInputStream.skip(toSkip))
|
||||||
return; // TODO: fix?
|
return; // TODO: fix?
|
||||||
counter += pfs0offset-counter;
|
counter += toSkip;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
byte[] magic = new byte[0x4];
|
byte[] magic = new byte[0x4];
|
||||||
|
|
|
@ -253,6 +253,8 @@ public class NCAProvider {
|
||||||
* @param sectionNumber should be 1-4
|
* @param sectionNumber should be 1-4
|
||||||
* */
|
* */
|
||||||
public NCAContentPFS0 getNCAContentPFS0(int sectionNumber){
|
public NCAContentPFS0 getNCAContentPFS0(int sectionNumber){
|
||||||
|
// TODO: provide titleKey if needed
|
||||||
|
|
||||||
switch (sectionNumber){
|
switch (sectionNumber){
|
||||||
case 0:
|
case 0:
|
||||||
return new NCAContentPFS0(file, offset, sectionBlock0, tableEntry0, decryptedKey2); // TODO: remove decryptedKey2
|
return new NCAContentPFS0(file, offset, sectionBlock0, tableEntry0, decryptedKey2); // TODO: remove decryptedKey2
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<GridPane xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="konogonka.Controllers.NCA.NCASectionHeaderBlockController">
|
<GridPane xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="konogonka.Controllers.NCA.NCASectionHeaderBlockController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="60.0" minWidth="55.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="60.0" minWidth="55.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="75.0" minWidth="60.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="75.0" minWidth="60.0" />
|
||||||
|
@ -228,7 +228,7 @@
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
<AnchorPane styleClass="customGrid" GridPane.columnIndex="2" GridPane.rowIndex="4">
|
<AnchorPane styleClass="customGrid" GridPane.columnIndex="2" GridPane.rowIndex="4">
|
||||||
<children>
|
<children>
|
||||||
<Label text="Crypto type. 0 and >4 are invalid. 1 = none(plaintext from raw NCA). 2 = other crypto. 3 = regular crypto. 4 = unknown." AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<Label text="Crypto type. 0 and >4 are invalid, 1 = None, 2 = AesCtrOld, 3 = AesCtr, 4 = AesCtrEx" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<padding>
|
<padding>
|
||||||
<Insets left="5.0" right="5.0" />
|
<Insets left="5.0" right="5.0" />
|
||||||
</padding>
|
</padding>
|
||||||
|
|
|
@ -6,18 +6,21 @@
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.control.ScrollPane?>
|
<?import javafx.scene.control.ScrollPane?>
|
||||||
<?import javafx.scene.control.Separator?>
|
<?import javafx.scene.control.Separator?>
|
||||||
|
<?import javafx.scene.control.Tab?>
|
||||||
|
<?import javafx.scene.control.TabPane?>
|
||||||
<?import javafx.scene.control.TextField?>
|
<?import javafx.scene.control.TextField?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
|
||||||
<?import javafx.scene.layout.HBox?>
|
<?import javafx.scene.layout.HBox?>
|
||||||
<?import javafx.scene.layout.Pane?>
|
<?import javafx.scene.layout.Pane?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
<?import javafx.scene.shape.SVGPath?>
|
<?import javafx.scene.shape.SVGPath?>
|
||||||
|
|
||||||
<AnchorPane prefHeight="600.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="konogonka.Settings.SettingsController">
|
<VBox minHeight="600.0" minWidth="600.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="konogonka.Settings.SettingsController">
|
||||||
<children>
|
<children>
|
||||||
<VBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<TabPane side="LEFT" tabClosingPolicy="UNAVAILABLE" tabMaxHeight="100.0" tabMaxWidth="80.0" tabMinHeight="80.0" tabMinWidth="50.0" VBox.vgrow="ALWAYS">
|
||||||
<children>
|
<tabs>
|
||||||
<ScrollPane fitToWidth="true" VBox.vgrow="ALWAYS">
|
<Tab closable="false">
|
||||||
|
<content>
|
||||||
|
<ScrollPane fitToWidth="true">
|
||||||
<content>
|
<content>
|
||||||
<VBox prefHeight="200.0" prefWidth="100.0" spacing="5.0">
|
<VBox prefHeight="200.0" prefWidth="100.0" spacing="5.0">
|
||||||
<children>
|
<children>
|
||||||
|
@ -31,7 +34,7 @@
|
||||||
<Label disable="true" text="Length should be 32 symbols" wrapText="true" />
|
<Label disable="true" text="Length should be 32 symbols" wrapText="true" />
|
||||||
<Separator prefWidth="200.0" />
|
<Separator prefWidth="200.0" />
|
||||||
<Label text="Used for NCA" />
|
<Label text="Used for NCA" />
|
||||||
<Button fx:id="importBtn" contentDisplay="TOP" mnemonicParsing="false" text="Import from prod.keys">
|
<Button fx:id="importKeysBtn" contentDisplay="TOP" mnemonicParsing="false" text="Import from prod.keys">
|
||||||
<graphic>
|
<graphic>
|
||||||
<SVGPath content="M1,12H10.76L8.26,9.5L9.67,8.08L14.59,13L9.67,17.92L8.26,16.5L10.76,14H1V12M19,3C20.11,3 21,3.9 21,5V19A2,2 0 0,1 19,21H5C3.89,21 3,20.1 3,19V16H5V19H19V7H5V10H3V5A2,2 0 0,1 5,3H19Z" />
|
<SVGPath content="M1,12H10.76L8.26,9.5L9.67,8.08L14.59,13L9.67,17.92L8.26,16.5L10.76,14H1V12M19,3C20.11,3 21,3.9 21,5V19A2,2 0 0,1 19,21H5C3.89,21 3,20.1 3,19V16H5V19H19V7H5V10H3V5A2,2 0 0,1 5,3H19Z" />
|
||||||
</graphic>
|
</graphic>
|
||||||
|
@ -196,6 +199,48 @@
|
||||||
</VBox>
|
</VBox>
|
||||||
</content>
|
</content>
|
||||||
</ScrollPane>
|
</ScrollPane>
|
||||||
|
</content>
|
||||||
|
<graphic>
|
||||||
|
<VBox alignment="TOP_CENTER" spacing="5.0">
|
||||||
|
<children>
|
||||||
|
<SVGPath content="M6.5,2C8.46,2 10.13,3.25 10.74,5H22V8H18V11H15V8H10.74C10.13,9.75 8.46,11 6.5,11C4,11 2,9 2,6.5C2,4 4,2 6.5,2M6.5,5A1.5,1.5 0 0,0 5,6.5A1.5,1.5 0 0,0 6.5,8A1.5,1.5 0 0,0 8,6.5A1.5,1.5 0 0,0 6.5,5M6.5,13C8.46,13 10.13,14.25 10.74,16H22V19H20V22H18V19H16V22H13V19H10.74C10.13,20.75 8.46,22 6.5,22C4,22 2,20 2,17.5C2,15 4,13 6.5,13M6.5,16A1.5,1.5 0 0,0 5,17.5A1.5,1.5 0 0,0 6.5,19A1.5,1.5 0 0,0 8,17.5A1.5,1.5 0 0,0 6.5,16Z" />
|
||||||
|
<Label text="prod.keys" />
|
||||||
|
</children>
|
||||||
|
</VBox>
|
||||||
|
</graphic>
|
||||||
|
</Tab>
|
||||||
|
<Tab closable="false">
|
||||||
|
<content>
|
||||||
|
<ScrollPane fitToWidth="true">
|
||||||
|
<content>
|
||||||
|
<VBox spacing="5.0">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||||
|
</padding>
|
||||||
|
<children>
|
||||||
|
<Label text="Title Keys" />
|
||||||
|
<Button fx:id="importTitleKeysBtn" contentDisplay="TOP" mnemonicParsing="false" text="Import from title.keys">
|
||||||
|
<graphic>
|
||||||
|
<SVGPath content="M1,12H10.76L8.26,9.5L9.67,8.08L14.59,13L9.67,17.92L8.26,16.5L10.76,14H1V12M19,3C20.11,3 21,3.9 21,5V19A2,2 0 0,1 19,21H5C3.89,21 3,20.1 3,19V16H5V19H19V7H5V10H3V5A2,2 0 0,1 5,3H19Z" />
|
||||||
|
</graphic>
|
||||||
|
</Button>
|
||||||
|
<VBox fx:id="titleKeysVbox" spacing="5.0" />
|
||||||
|
</children>
|
||||||
|
</VBox>
|
||||||
|
</content>
|
||||||
|
</ScrollPane>
|
||||||
|
</content>
|
||||||
|
<graphic>
|
||||||
|
<VBox alignment="TOP_CENTER" spacing="5.0">
|
||||||
|
<children>
|
||||||
|
<SVGPath content="M22,18V22H18V19H15V16H12L9.74,13.74C9.19,13.91 8.61,14 8,14A6,6 0 0,1 2,8A6,6 0 0,1 8,2A6,6 0 0,1 14,8C14,8.61 13.91,9.19 13.74,9.74L22,18M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" />
|
||||||
|
<Label text="title.keys" />
|
||||||
|
</children>
|
||||||
|
</VBox>
|
||||||
|
</graphic>
|
||||||
|
</Tab>
|
||||||
|
</tabs>
|
||||||
|
</TabPane>
|
||||||
<ButtonBar>
|
<ButtonBar>
|
||||||
<buttons>
|
<buttons>
|
||||||
|
|
||||||
|
@ -208,5 +253,3 @@
|
||||||
</ButtonBar>
|
</ButtonBar>
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
</VBox>
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
||||||
|
|
Loading…
Reference in a new issue