Minor corrections
continuous-integration/drone/push Build is passing Details

master
Dmitry Isaenko 2023-05-17 16:37:27 +03:00
parent de15275297
commit c6e56956e1
3 changed files with 12 additions and 17 deletions

View File

@ -46,14 +46,14 @@ public class KeyChainHolder {
private void collectEverything() throws Exception{
rawKeySet = new HashMap<>();
BufferedReader br = new BufferedReader(new FileReader(keysFile));
String fileLine;
String[] keyValue;
while ((fileLine = br.readLine()) != null){
keyValue = fileLine.trim().split("\\s+?=\\s+?", 2);
if (keyValue.length == 2)
rawKeySet.put(keyValue[0], keyValue[1]);
try (BufferedReader br = new BufferedReader(new FileReader(keysFile))) {
String fileLine;
String[] keyValue;
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");

View File

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

View File

@ -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){