Bugfix for dumb issue with key_area_key_[all] to support Lockpick dump: hex representation instead of dec %)
This commit is contained in:
parent
0f49812e5f
commit
ce4c5d9870
6 changed files with 104 additions and 108 deletions
|
@ -77,7 +77,7 @@ public class AppPreferences {
|
|||
public void setKAKAppCount(int number){
|
||||
if (this.kakAppCount > number){
|
||||
for (int i = number; i < this.kakAppCount; i++) {
|
||||
preferences.remove(String.format("key_area_key_application_%02d", number));
|
||||
preferences.remove(String.format("key_area_key_application_%02x", number));
|
||||
}
|
||||
}
|
||||
preferences.putInt("key_area_key_application_count", number);
|
||||
|
@ -86,7 +86,7 @@ public class AppPreferences {
|
|||
public void setKAKOceanCount(int number){
|
||||
if (this.kakOceanCount > number){
|
||||
for (int i = number; i < this.kakOceanCount; i++) {
|
||||
preferences.remove(String.format("key_area_key_ocean_%02d", number));
|
||||
preferences.remove(String.format("key_area_key_ocean_%02x", number));
|
||||
}
|
||||
}
|
||||
preferences.putInt("key_area_key_ocean_count", number);
|
||||
|
@ -95,7 +95,7 @@ public class AppPreferences {
|
|||
public void setKAKSysCount(int number){
|
||||
if (this.kakSysCount > number){
|
||||
for (int i = number; i < this.kakSysCount; i++) {
|
||||
preferences.remove(String.format("key_area_key_system_%02d", number));
|
||||
preferences.remove(String.format("key_area_key_system_%02x", number));
|
||||
}
|
||||
}
|
||||
preferences.putInt("key_area_key_system_count", number);
|
||||
|
@ -105,7 +105,7 @@ public class AppPreferences {
|
|||
public void setTitleKeksCount(int number){
|
||||
if (this.titleKeksCount > number){
|
||||
for (int i = number; i < this.titleKeksCount; i++) {
|
||||
preferences.remove(String.format("titlekek_%02d", number));
|
||||
preferences.remove(String.format("titlekek_%02x", number));
|
||||
}
|
||||
}
|
||||
preferences.putInt("titlekek_count", number);
|
||||
|
@ -117,17 +117,17 @@ public class AppPreferences {
|
|||
public int getKAKSysCount(){ return preferences.getInt("key_area_key_system_count", 0); }
|
||||
public int getTitleKeksCount(){ return preferences.getInt("titlekek_count", 0); }
|
||||
|
||||
public String getApplicationKey(int number){ return preferences.get(String.format("key_area_key_application_%02d", number), "");}
|
||||
public void setApplicationKey(int number, String key){ preferences.put(String.format("key_area_key_application_%02d", number), key); }
|
||||
public String getApplicationKey(int number){ return preferences.get(String.format("key_area_key_application_%02x", number), "");}
|
||||
public void setApplicationKey(int number, String key){ preferences.put(String.format("key_area_key_application_%02x", number), key); }
|
||||
|
||||
public String getOceanKey(int number){ return preferences.get(String.format("key_area_key_ocean_%02d", number), "");}
|
||||
public void setOceanKey(int number, String key){ preferences.put(String.format("key_area_key_ocean_%02d", number), key); }
|
||||
public String getOceanKey(int number){ return preferences.get(String.format("key_area_key_ocean_%02x", number), "");}
|
||||
public void setOceanKey(int number, String key){ preferences.put(String.format("key_area_key_ocean_%02x", number), key); }
|
||||
|
||||
public String getSystemKey(int number){ return preferences.get(String.format("key_area_key_system_%02d", number), "");}
|
||||
public void setSystemKey(int number, String key){ preferences.put(String.format("key_area_key_system_%02d", number), key); }
|
||||
public String getSystemKey(int number){ return preferences.get(String.format("key_area_key_system_%02x", number), "");}
|
||||
public void setSystemKey(int number, String key){ preferences.put(String.format("key_area_key_system_%02x", number), key); }
|
||||
|
||||
public String getTitleKek(int number){ return preferences.get(String.format("titlekek_%02d", number), "");}
|
||||
public void setTitleKek(int number, String key){ preferences.put(String.format("titlekek_%02d", number), key); }
|
||||
public String getTitleKek(int number){ return preferences.get(String.format("titlekek_%02x", number), "");}
|
||||
public void setTitleKek(int number, String key){ preferences.put(String.format("titlekek_%02x", number), key); }
|
||||
|
||||
|
||||
// Title keys
|
||||
|
|
|
@ -101,13 +101,13 @@ public class NCAController implements ITabController {
|
|||
keysMap.put("header_key", AppPreferences.getInstance().getHeaderKey());
|
||||
|
||||
for (int i = 0; i < AppPreferences.getInstance().getKAKAppCount(); i++)
|
||||
keysMap.put(String.format("key_area_key_application_%02d", i), AppPreferences.getInstance().getApplicationKey(i));
|
||||
keysMap.put(String.format("key_area_key_application_%02x", i), AppPreferences.getInstance().getApplicationKey(i));
|
||||
for (int i = 0; i < AppPreferences.getInstance().getKAKOceanCount(); i++)
|
||||
keysMap.put(String.format("key_area_key_ocean_%02d", i), AppPreferences.getInstance().getOceanKey(i));
|
||||
keysMap.put(String.format("key_area_key_ocean_%02x", i), AppPreferences.getInstance().getOceanKey(i));
|
||||
for (int i = 0; i < AppPreferences.getInstance().getKAKSysCount(); i++)
|
||||
keysMap.put(String.format("key_area_key_system_%02d", i), AppPreferences.getInstance().getSystemKey(i));
|
||||
keysMap.put(String.format("key_area_key_system_%02x", i), AppPreferences.getInstance().getSystemKey(i));
|
||||
for (int i = 0; i < AppPreferences.getInstance().getTitleKeksCount(); i++)
|
||||
keysMap.put(String.format("titlekek_%02d", i), AppPreferences.getInstance().getTitleKek(i));
|
||||
keysMap.put(String.format("titlekek_%02x", i), AppPreferences.getInstance().getTitleKek(i));
|
||||
for (int i = 0; i < AppPreferences.getInstance().getTitleKeysCount(); i++){
|
||||
String[] pair = AppPreferences.getInstance().getTitleKeyPair(i);
|
||||
if ( ! pair[0].equals("0") && ! pair[1].equals("0"))
|
||||
|
@ -180,7 +180,8 @@ public class NCAController implements ITabController {
|
|||
}
|
||||
|
||||
private void populateFields(NCAProvider ncaProvider){
|
||||
if (ncaProvider != null){
|
||||
if (ncaProvider == null)
|
||||
return;
|
||||
rsa2048oneTF.setText(byteArrToHexString(ncaProvider.getRsa2048one()));
|
||||
rsa2048twoTF.setText(byteArrToHexString(ncaProvider.getRsa2048two()));
|
||||
magicnumLbl.setText(ncaProvider.getMagicnum());
|
||||
|
@ -235,4 +236,3 @@ public class NCAController implements ITabController {
|
|||
NCASectionContentFourthController.populateFields(ncaContentPFS0.getPfs0(), ncaContentPFS0.getSHA256hashes());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class ListSelectorController implements Initializable {
|
|||
|
||||
newRecordName.setText(predictionPattern);
|
||||
newRecordName.setTextFormatter(new TextFormatter<Object>(change -> {
|
||||
if (change.getControlNewText().matches("^"+predictionPattern+"[0-9]{0,2}$"))
|
||||
if (change.getControlNewText().matches("^"+predictionPattern+"[a-fA-F0-9]{0,2}$"))
|
||||
return change;
|
||||
return null;
|
||||
}));
|
||||
|
@ -110,7 +110,7 @@ public class ListSelectorController implements Initializable {
|
|||
newRecordValue.clear();
|
||||
}
|
||||
else {
|
||||
if (newRecordName.getText().matches("^"+predictionPattern+"[0-9]{2}$")){
|
||||
if (newRecordName.getText().matches("^"+predictionPattern+"[a-fA-F0-9]{2}$")){
|
||||
validateAndAdd(newRecordName.getText() + " = " + newRecordValue.getText());
|
||||
newRecordName.setText(predictionPattern);
|
||||
newRecordValue.clear();
|
||||
|
|
|
@ -78,25 +78,25 @@ public class SettingsController implements Initializable {
|
|||
LinkedHashMap<String, String> preparedPairsMapInit = new LinkedHashMap<>();
|
||||
|
||||
for (int i = 0; i < AppPreferences.getInstance().getKAKAppCount(); i++){
|
||||
preparedPairsMapInit.put(String.format("key_area_key_application_%02d", i), AppPreferences.getInstance().getApplicationKey(i));
|
||||
preparedPairsMapInit.put(String.format("key_area_key_application_%02x", i), AppPreferences.getInstance().getApplicationKey(i));
|
||||
}
|
||||
ListSelectorKAEKAppController.setList(preparedPairsMapInit);
|
||||
preparedPairsMapInit.clear();
|
||||
|
||||
for (int i = 0; i < AppPreferences.getInstance().getKAKOceanCount(); i++){
|
||||
preparedPairsMapInit.put(String.format("key_area_key_ocean_%02d", i), AppPreferences.getInstance().getOceanKey(i));
|
||||
preparedPairsMapInit.put(String.format("key_area_key_ocean_%02x", i), AppPreferences.getInstance().getOceanKey(i));
|
||||
}
|
||||
ListSelectorKAEKOceanController.setList(preparedPairsMapInit);
|
||||
preparedPairsMapInit.clear();
|
||||
|
||||
for (int i = 0; i < AppPreferences.getInstance().getKAKSysCount(); i++){
|
||||
preparedPairsMapInit.put(String.format("key_area_key_system_%02d", i), AppPreferences.getInstance().getSystemKey(i));
|
||||
preparedPairsMapInit.put(String.format("key_area_key_system_%02x", i), AppPreferences.getInstance().getSystemKey(i));
|
||||
}
|
||||
ListSelectorKAEKSysController.setList(preparedPairsMapInit);
|
||||
preparedPairsMapInit.clear();
|
||||
|
||||
for (int i = 0; i < AppPreferences.getInstance().getTitleKeksCount(); i++){
|
||||
preparedPairsMapInit.put(String.format("titlekek_%02d", i), AppPreferences.getInstance().getTitleKek(i));
|
||||
preparedPairsMapInit.put(String.format("titlekek_%02x", i), AppPreferences.getInstance().getTitleKek(i));
|
||||
}
|
||||
ListSelectorTitleKeksController.setList(preparedPairsMapInit);
|
||||
preparedPairsMapInit.clear();
|
||||
|
@ -143,32 +143,32 @@ public class SettingsController implements Initializable {
|
|||
|
||||
String keyParsed;
|
||||
int counter = 0;
|
||||
while ((keyParsed = fileMap.get(String.format("key_area_key_application_%02d", counter))) != null){
|
||||
kaekSingle.put(String.format("key_area_key_application_%02d", counter), keyParsed);
|
||||
while ((keyParsed = fileMap.get(String.format("key_area_key_application_%02x", counter))) != null){
|
||||
kaekSingle.put(String.format("key_area_key_application_%02x", counter), keyParsed);
|
||||
counter++;
|
||||
}
|
||||
ListSelectorKAEKAppController.setList(kaekSingle);
|
||||
|
||||
kaekSingle.clear();
|
||||
counter = 0;
|
||||
while ((keyParsed = fileMap.get(String.format("key_area_key_ocean_%02d", counter))) != null){
|
||||
kaekSingle.put(String.format("key_area_key_ocean_%02d", counter), keyParsed);
|
||||
while ((keyParsed = fileMap.get(String.format("key_area_key_ocean_%02x", counter))) != null){
|
||||
kaekSingle.put(String.format("key_area_key_ocean_%02x", counter), keyParsed);
|
||||
counter++;
|
||||
}
|
||||
ListSelectorKAEKOceanController.setList(kaekSingle);
|
||||
|
||||
kaekSingle.clear();
|
||||
counter = 0;
|
||||
while ((keyParsed = fileMap.get(String.format("key_area_key_system_%02d", counter))) != null){
|
||||
kaekSingle.put(String.format("key_area_key_system_%02d", counter), keyParsed);
|
||||
while ((keyParsed = fileMap.get(String.format("key_area_key_system_%02x", counter))) != null){
|
||||
kaekSingle.put(String.format("key_area_key_system_%02x", counter), keyParsed);
|
||||
counter++;
|
||||
}
|
||||
ListSelectorKAEKSysController.setList(kaekSingle);
|
||||
|
||||
kaekSingle.clear();
|
||||
counter = 0;
|
||||
while ((keyParsed = fileMap.get(String.format("titlekek_%02d", counter))) != null){
|
||||
kaekSingle.put(String.format("titlekek_%02d", counter), keyParsed);
|
||||
while ((keyParsed = fileMap.get(String.format("titlekek_%02x", counter))) != null){
|
||||
kaekSingle.put(String.format("titlekek_%02x", counter), keyParsed);
|
||||
counter++;
|
||||
}
|
||||
ListSelectorTitleKeksController.setList(kaekSingle);
|
||||
|
|
|
@ -194,13 +194,13 @@ public class NCAProvider {
|
|||
String keyAreaKey;
|
||||
switch (keyIndex){
|
||||
case 0:
|
||||
keyAreaKey = keys.get(String.format("key_area_key_application_%02d", cryptoTypeReal));
|
||||
keyAreaKey = keys.get(String.format("key_area_key_application_%02x", cryptoTypeReal));
|
||||
break;
|
||||
case 1:
|
||||
keyAreaKey = keys.get(String.format("key_area_key_ocean_%02d", cryptoTypeReal));
|
||||
keyAreaKey = keys.get(String.format("key_area_key_ocean_%02x", cryptoTypeReal));
|
||||
break;
|
||||
case 2:
|
||||
keyAreaKey = keys.get(String.format("key_area_key_system_%02d", cryptoTypeReal));
|
||||
keyAreaKey = keys.get(String.format("key_area_key_system_%02x", cryptoTypeReal));
|
||||
break;
|
||||
default:
|
||||
keyAreaKey = null;
|
||||
|
@ -231,7 +231,7 @@ public class NCAProvider {
|
|||
exceptionStringBuilder.append(keyIndex);
|
||||
exceptionStringBuilder.append("[UNKNOWN]_");
|
||||
}
|
||||
exceptionStringBuilder.append(String.format("%02d", cryptoTypeReal));
|
||||
exceptionStringBuilder.append(String.format("%02x", cryptoTypeReal));
|
||||
exceptionStringBuilder.append(" requested. Not supported or not found.");
|
||||
|
||||
throw new Exception(exceptionStringBuilder.toString());
|
||||
|
@ -312,7 +312,7 @@ public class NCAProvider {
|
|||
byte[] rightsIDkey = hexStrToByteArray(keys.get(byteArrToHexString(rightsId))); // throws NullPointerException
|
||||
|
||||
SecretKeySpec skSpec = new SecretKeySpec(
|
||||
hexStrToByteArray(keys.get(String.format("titlekek_%02d", cryptoTypeReal))
|
||||
hexStrToByteArray(keys.get(String.format("titlekek_%02x", cryptoTypeReal))
|
||||
), "AES");
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");
|
||||
cipher.init(Cipher.DECRYPT_MODE, skSpec);
|
||||
|
|
|
@ -107,8 +107,14 @@
|
|||
</graphic>
|
||||
</Tab>
|
||||
<Tab closable="false">
|
||||
<content>
|
||||
<ScrollPane fitToWidth="true">
|
||||
<graphic>
|
||||
<VBox alignment="TOP_CENTER" spacing="5.0">
|
||||
<children>
|
||||
<SVGPath content="M7,6H17A6,6 0 0,1 23,12A6,6 0 0,1 17,18C15.22,18 13.63,17.23 12.53,16H11.47C10.37,17.23 8.78,18 7,18A6,6 0 0,1 1,12A6,6 0 0,1 7,6M6,9V11H4V13H6V15H8V13H10V11H8V9H6M15.5,12A1.5,1.5 0 0,0 14,13.5A1.5,1.5 0 0,0 15.5,15A1.5,1.5 0 0,0 17,13.5A1.5,1.5 0 0,0 15.5,12M18.5,9A1.5,1.5 0 0,0 17,10.5A1.5,1.5 0 0,0 18.5,12A1.5,1.5 0 0,0 20,10.5A1.5,1.5 0 0,0 18.5,9Z" />
|
||||
<Label text="title.keys" />
|
||||
</children>
|
||||
</VBox>
|
||||
</graphic>
|
||||
<content>
|
||||
<VBox spacing="5.0">
|
||||
<padding>
|
||||
|
@ -125,16 +131,6 @@
|
|||
</children>
|
||||
</VBox>
|
||||
</content>
|
||||
</ScrollPane>
|
||||
</content>
|
||||
<graphic>
|
||||
<VBox alignment="TOP_CENTER" spacing="5.0">
|
||||
<children>
|
||||
<SVGPath content="M7,6H17A6,6 0 0,1 23,12A6,6 0 0,1 17,18C15.22,18 13.63,17.23 12.53,16H11.47C10.37,17.23 8.78,18 7,18A6,6 0 0,1 1,12A6,6 0 0,1 7,6M6,9V11H4V13H6V15H8V13H10V11H8V9H6M15.5,12A1.5,1.5 0 0,0 14,13.5A1.5,1.5 0 0,0 15.5,15A1.5,1.5 0 0,0 17,13.5A1.5,1.5 0 0,0 15.5,12M18.5,9A1.5,1.5 0 0,0 17,10.5A1.5,1.5 0 0,0 18.5,12A1.5,1.5 0 0,0 20,10.5A1.5,1.5 0 0,0 18.5,9Z" />
|
||||
<Label text="title.keys" />
|
||||
</children>
|
||||
</VBox>
|
||||
</graphic>
|
||||
</Tab>
|
||||
</tabs>
|
||||
</TabPane>
|
||||
|
|
Loading…
Reference in a new issue