diff --git a/NDecrypt.Core/DecryptArgs.cs b/NDecrypt.Core/DecryptArgs.cs
index 950cd32..29d61e1 100644
--- a/NDecrypt.Core/DecryptArgs.cs
+++ b/NDecrypt.Core/DecryptArgs.cs
@@ -21,29 +21,29 @@ namespace NDecrypt.Core
///
/// AES Hardware Constant
///
- public byte[]? AESHardwareConstant { get; private set; }
+ public byte[] AESHardwareConstant { get; private set; } = [];
#region Retail Keys
///
/// KeyX 0x18 (New 3DS 9.3)
///
- public byte[]? KeyX0x18 { get; private set; }
+ public byte[] KeyX0x18 { get; private set; } = [];
///
/// KeyX 0x1B (New 3DS 9.6)
///
- public byte[]? KeyX0x1B { get; private set; }
+ public byte[] KeyX0x1B { get; private set; } = [];
///
/// KeyX 0x25 (> 7.x)
///
- public byte[]? KeyX0x25 { get; private set; }
+ public byte[] KeyX0x25 { get; private set; } = [];
///
/// KeyX 0x2C (< 6.x)
///
- public byte[]? KeyX0x2C { get; private set; }
+ public byte[] KeyX0x2C { get; private set; } = [];
#endregion
@@ -52,22 +52,22 @@ namespace NDecrypt.Core
///
/// Dev KeyX 0x18 (New 3DS 9.3)
///
- public byte[]? DevKeyX0x18 { get; private set; }
+ public byte[] DevKeyX0x18 { get; private set; } = [];
///
/// Dev KeyX 0x1B New 3DS 9.6)
///
- public byte[]? DevKeyX0x1B { get; private set; }
+ public byte[] DevKeyX0x1B { get; private set; } = [];
///
/// Dev KeyX 0x25 (> 7.x)
///
- public byte[]? DevKeyX0x25 { get; private set; }
+ public byte[] DevKeyX0x25 { get; private set; } = [];
///
/// Dev KeyX 0x2C (< 6.x)
///
- public byte[]? DevKeyX0x2C { get; private set; }
+ public byte[] DevKeyX0x2C { get; private set; } = [];
#endregion
diff --git a/NDecrypt.Core/PartitionKeys.cs b/NDecrypt.Core/PartitionKeys.cs
index 842bda0..4418556 100644
--- a/NDecrypt.Core/PartitionKeys.cs
+++ b/NDecrypt.Core/PartitionKeys.cs
@@ -10,15 +10,15 @@ namespace NDecrypt.Core
///
public class PartitionKeys
{
- public byte[]? KeyX { get; private set; }
+ public byte[] KeyX { get; private set; }
- public byte[]? KeyX2C { get; private set; }
+ public byte[] KeyX2C { get; }
- public byte[]? KeyY { get; private set; }
+ public byte[] KeyY { get; }
- public byte[]? NormalKey { get; private set; }
+ public byte[] NormalKey { get; private set; }
- public byte[]? NormalKey2C { get; private set; }
+ public byte[] NormalKey2C { get; }
///
/// Decryption args to use while processing
@@ -61,7 +61,11 @@ namespace NDecrypt.Core
// Set the standard normal key values
NormalKey = new byte[16];
- NormalKey2C = RotateLeft(Add(Xor(RotateLeft(KeyX2C!, 2), KeyY), args.AESHardwareConstant!), 87);
+
+ NormalKey2C = RotateLeft(KeyX2C!, 2);
+ NormalKey2C = Xor(NormalKey2C, KeyY);
+ NormalKey2C = Add(NormalKey2C, args.AESHardwareConstant);
+ NormalKey2C = RotateLeft(NormalKey2C, 87);
// Special case for zero-key
if (masks.HasFlag(BitMasks.FixedCryptoKey))
@@ -97,7 +101,10 @@ namespace NDecrypt.Core
}
// Set the normal key based on the new KeyX value
- NormalKey = RotateLeft(Add(Xor(RotateLeft(KeyX!, 2), KeyY), args.AESHardwareConstant!), 87);
+ NormalKey = RotateLeft(KeyX!, 2);
+ NormalKey = Xor(NormalKey, KeyY);
+ NormalKey = Add(NormalKey, args.AESHardwareConstant);
+ NormalKey = RotateLeft(NormalKey, 87);
}
///
@@ -114,7 +121,11 @@ namespace NDecrypt.Core
// Encrypting RomFS for partitions 1 and up always use Key0x2C
KeyX = _development ? _decryptArgs.DevKeyX0x2C : _decryptArgs.KeyX0x2C;
- NormalKey = RotateLeft(Add(Xor(RotateLeft(KeyX!, 2), KeyY!), _decryptArgs.AESHardwareConstant!), 87);
+
+ NormalKey = RotateLeft(KeyX!, 2);
+ NormalKey = Xor(NormalKey, KeyY);
+ NormalKey = Add(NormalKey, _decryptArgs.AESHardwareConstant);
+ NormalKey = RotateLeft(NormalKey, 87);
}
}
}
\ No newline at end of file