Better Null Exceptions
This commit is contained in:
+8
-2
@@ -168,11 +168,14 @@ namespace LibIRD
|
|||||||
/// Generates Data 1, via AES-128 CBC decryption of a Disc Key
|
/// Generates Data 1, via AES-128 CBC decryption of a Disc Key
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key">Byte array containing AES encrypted Disc Key</param>
|
/// <param name="key">Byte array containing AES encrypted Disc Key</param>
|
||||||
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
/// <exception cref="ArgumentException"></exception>
|
/// <exception cref="ArgumentException"></exception>
|
||||||
protected void GenerateD1(byte[] key)
|
protected void GenerateD1(byte[] key)
|
||||||
{
|
{
|
||||||
// Validate key
|
// Validate key
|
||||||
if (key == null || key.Length != 16)
|
if (key == null)
|
||||||
|
throw new ArgumentNullException(nameof(key));
|
||||||
|
if (key.Length != 16)
|
||||||
throw new ArgumentException("Disc Key must be a byte array of length 16", nameof(key));
|
throw new ArgumentException("Disc Key must be a byte array of length 16", nameof(key));
|
||||||
|
|
||||||
// TODO: AES decryption
|
// TODO: AES decryption
|
||||||
@@ -183,11 +186,14 @@ namespace LibIRD
|
|||||||
/// Generates Data 2, via AES-128 CBC encryption of a Disc ID
|
/// Generates Data 2, via AES-128 CBC encryption of a Disc ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Byte array containing AES decrypted Disc ID</param>
|
/// <param name="id">Byte array containing AES decrypted Disc ID</param>
|
||||||
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
/// <exception cref="ArgumentException"></exception>
|
/// <exception cref="ArgumentException"></exception>
|
||||||
protected void GenerateD2(byte[] id)
|
protected void GenerateD2(byte[] id)
|
||||||
{
|
{
|
||||||
// Validate id
|
// Validate id
|
||||||
if (id == null || id.Length != 16)
|
if (id == null)
|
||||||
|
throw new ArgumentNullException(nameof(id));
|
||||||
|
if (id.Length != 16)
|
||||||
throw new ArgumentException("Disc ID must be a byte array of length 16", nameof(id));
|
throw new ArgumentException("Disc ID must be a byte array of length 16", nameof(id));
|
||||||
|
|
||||||
// TODO: AES encryption
|
// TODO: AES encryption
|
||||||
|
|||||||
+6
-2
@@ -10,7 +10,7 @@ namespace LibIRD
|
|||||||
public enum Region
|
public enum Region
|
||||||
{
|
{
|
||||||
// Null region
|
// Null region
|
||||||
NONE = 0,
|
NONE = 0x00,
|
||||||
|
|
||||||
// Japan and Asia
|
// Japan and Asia
|
||||||
Asia = 0x01, // BLAS/BCAS serials
|
Asia = 0x01, // BLAS/BCAS serials
|
||||||
@@ -162,12 +162,16 @@ namespace LibIRD
|
|||||||
/// Generates the UID field
|
/// Generates the UID field
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="crc32">Redump ISO CRC32 hash</param>
|
/// <param name="crc32">Redump ISO CRC32 hash</param>
|
||||||
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
/// <exception cref="ArgumentException"></exception>
|
/// <exception cref="ArgumentException"></exception>
|
||||||
private void GenerateUID(byte[] crc32)
|
private void GenerateUID(byte[] crc32)
|
||||||
{
|
{
|
||||||
// Validate CRC32
|
// Validate CRC32
|
||||||
if (crc32 == null || crc32.Length != 8)
|
if (crc32 == null)
|
||||||
|
throw new ArgumentNullException(nameof(crc32));
|
||||||
|
if (crc32.Length != 8)
|
||||||
throw new ArgumentException("CRC32 hash must be an byte array of length 8", nameof(crc32));
|
throw new ArgumentException("CRC32 hash must be an byte array of length 8", nameof(crc32));
|
||||||
|
|
||||||
// Redump ISO CRC32 hash is used as the Unique ID in the IRD
|
// Redump ISO CRC32 hash is used as the Unique ID in the IRD
|
||||||
UID = BitConverter.ToUInt32(crc32, 0);
|
UID = BitConverter.ToUInt32(crc32, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user