Parse Header and Footer in new base class
This commit is contained in:
+7
-51
@@ -192,7 +192,7 @@ namespace LibIRD
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
/// <exception cref="FileNotFoundException"></exception>
|
||||
/// <exception cref="InvalidDataException"></exception>
|
||||
public ReIRD(string isoPath, string getKeyLog)
|
||||
public ReIRD(string isoPath, string getKeyLog) : base(isoPath, getKeyLog)
|
||||
{
|
||||
// Validate ISO path
|
||||
if (isoPath == null || isoPath.Length <= 0)
|
||||
@@ -206,63 +206,22 @@ namespace LibIRD
|
||||
// Calculate size of ISO
|
||||
long size = iso.Length;
|
||||
|
||||
// Parse .getkey.log for the Disc Key (Data1Key)
|
||||
ParseGetKeyLog(getKeyLog);
|
||||
// Generate Unique Identifier using ISO CRC32
|
||||
GenerateUID(isoPath);
|
||||
|
||||
// Generate Data 2 using Disc ID
|
||||
GenerateD2(GenerateID(size));
|
||||
byte[] d2 = Data2Key;
|
||||
GenerateD2(GenerateID(size));
|
||||
// Check that GetKey log matches expected Disc ID
|
||||
if (!((ReadOnlySpan<byte>)Data2Key).SequenceEqual(d2))
|
||||
throw new InvalidDataException("Unexpected Disc ID in .getkey.log");
|
||||
|
||||
// Generate Disc PIC
|
||||
byte[] pic = PIC;
|
||||
GeneratePIC(size);
|
||||
// Check that GetKey log matches expected PIC
|
||||
if (!((ReadOnlySpan<byte>) PIC).SequenceEqual(pic))
|
||||
throw new InvalidDataException("Unexpected PIC in .getkey.log");
|
||||
|
||||
// Generate Unique Identifier using ISO CRC32
|
||||
GenerateUID(isoPath);
|
||||
|
||||
// Generate the IRD hashes
|
||||
Generate(isoPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with required redump-style IRD fields
|
||||
/// </summary>
|
||||
/// <param name="isoPath">Path to the ISO</param>
|
||||
/// <param name="key">Disc Key, redump-style (AES encrypted Data 1)</param>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
/// <exception cref="FileNotFoundException"></exception>
|
||||
public ReIRD(string isoPath, byte[] key)
|
||||
{
|
||||
// Validate ISO path
|
||||
if (isoPath == null || isoPath.Length <= 0)
|
||||
throw new ArgumentNullException(nameof(isoPath));
|
||||
|
||||
// Check file exists
|
||||
var iso = new FileInfo(isoPath);
|
||||
if (!iso.Exists)
|
||||
throw new FileNotFoundException(isoPath);
|
||||
|
||||
// Calculate size of ISO
|
||||
long size = iso.Length;
|
||||
|
||||
// Generate Data 1 using Disc Key
|
||||
GenerateD1(key);
|
||||
|
||||
// Generate Data 2 using Disc ID
|
||||
GenerateD2(GenerateID(size));
|
||||
|
||||
// Generate Disc PIC
|
||||
GeneratePIC(size);
|
||||
|
||||
// Generate Unique Identifier using ISO CRC32
|
||||
GenerateUID(isoPath);
|
||||
|
||||
// Generate the IRD hashes
|
||||
Generate(isoPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -273,7 +232,7 @@ namespace LibIRD
|
||||
/// <param name="region">Disc Region</param>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
/// <exception cref="FileNotFoundException"></exception>
|
||||
public ReIRD(string isoPath, byte[] key, Region region)
|
||||
public ReIRD(string isoPath, byte[] key, Region region = Region.NONE) : base(isoPath)
|
||||
{
|
||||
// Validate ISO path
|
||||
if (isoPath == null || isoPath.Length <= 0)
|
||||
@@ -298,9 +257,6 @@ namespace LibIRD
|
||||
|
||||
// Generate Disc PIC
|
||||
GeneratePIC(size);
|
||||
|
||||
// Generate the IRD hashes
|
||||
Generate(isoPath);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user