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