This commit is contained in:
parent
de15275297
commit
c6e56956e1
3 changed files with 12 additions and 17 deletions
|
@ -46,8 +46,7 @@ public class KeyChainHolder {
|
||||||
|
|
||||||
private void collectEverything() throws Exception{
|
private void collectEverything() throws Exception{
|
||||||
rawKeySet = new HashMap<>();
|
rawKeySet = new HashMap<>();
|
||||||
BufferedReader br = new BufferedReader(new FileReader(keysFile));
|
try (BufferedReader br = new BufferedReader(new FileReader(keysFile))) {
|
||||||
|
|
||||||
String fileLine;
|
String fileLine;
|
||||||
String[] keyValue;
|
String[] keyValue;
|
||||||
while ((fileLine = br.readLine()) != null) {
|
while ((fileLine = br.readLine()) != null) {
|
||||||
|
@ -55,6 +54,7 @@ public class KeyChainHolder {
|
||||||
if (keyValue.length == 2)
|
if (keyValue.length == 2)
|
||||||
rawKeySet.put(keyValue[0], keyValue[1]);
|
rawKeySet.put(keyValue[0], keyValue[1]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
key_area_key_application = collectKeysByType("key_area_key_application");
|
key_area_key_application = collectKeysByType("key_area_key_application");
|
||||||
key_area_key_ocean = collectKeysByType("key_area_key_ocean");
|
key_area_key_ocean = collectKeysByType("key_area_key_ocean");
|
||||||
|
|
|
@ -5,13 +5,9 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
|
|
||||||
public abstract class AesCtrDecrypt {
|
public abstract class AesCtrDecrypt {
|
||||||
private static boolean shouldBeInitialized = true;
|
|
||||||
|
|
||||||
protected AesCtrDecrypt(){
|
protected AesCtrDecrypt(){
|
||||||
if (shouldBeInitialized){
|
if (Security.getProvider("BC") == null)
|
||||||
Security.addProvider(new BouncyCastleProvider());
|
Security.addProvider(new BouncyCastleProvider());
|
||||||
shouldBeInitialized = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -255,15 +255,14 @@ public class NCAProvider {
|
||||||
byte[] rightsIdKey = hexStrToByteArray(keys.get(byteArrToHexStringAsLE(rightsId))); // throws NullPointerException
|
byte[] rightsIdKey = hexStrToByteArray(keys.get(byteArrToHexStringAsLE(rightsId))); // throws NullPointerException
|
||||||
|
|
||||||
SecretKeySpec skSpec = new SecretKeySpec(
|
SecretKeySpec skSpec = new SecretKeySpec(
|
||||||
hexStrToByteArray(keys.get(String.format("titlekek_%02x", cryptoTypeReal))
|
hexStrToByteArray(keys.get(String.format("titlekek_%02x", cryptoTypeReal))), "AES");
|
||||||
), "AES");
|
|
||||||
Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");
|
Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");
|
||||||
cipher.init(Cipher.DECRYPT_MODE, skSpec);
|
cipher.init(Cipher.DECRYPT_MODE, skSpec);
|
||||||
return cipher.doFinal(rightsIdKey);
|
return cipher.doFinal(rightsIdKey);
|
||||||
}
|
}
|
||||||
catch (Exception e){
|
catch (Exception e){
|
||||||
throw new Exception("No title.keys loaded for '"+
|
throw new Exception(String.format("No title.keys loaded for 'titlekek_%02x' or '%s' (%s)",
|
||||||
String.format("titlekek_%02x", cryptoTypeReal)+"' or '"+ byteArrToHexStringAsLE(rightsId)+"'? ("+e+")", e);
|
cryptoTypeReal, byteArrToHexStringAsLE(rightsId), e), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void setupNcaContentByNumber(int number, byte[] key){
|
private void setupNcaContentByNumber(int number, byte[] key){
|
||||||
|
|
Loading…
Reference in a new issue