Add CRC-32/DVD-ROM-EDC (fixes #4)

This commit is contained in:
Matt Nadareski
2026-01-11 09:20:15 -05:00
parent 214b449e5e
commit 0075b9b1ad
7 changed files with 28 additions and 3 deletions

View File

@@ -42,4 +42,4 @@ namespace SabreTools.Hashing.Test
Assert.Equal(expected, result);
}
}
}
}

View File

@@ -6,7 +6,7 @@ namespace SabreTools.Hashing.Test
/// <summary>
/// Helper class for tests
/// </summary>
/// CRC values confirmed with <see href="https://emn178.github.io/online-tools/crc/"/>
/// CRC values confirmed with <see href="https://emn178.github.io/online-tools/crc/"/>
internal static class TestHelper
{
#region Known File Information
@@ -143,6 +143,7 @@ namespace SabreTools.Hashing.Test
{HashType.CRC32_BZIP2, "18aa4603"},
{HashType.CRC32_CDROMEDC, "b8ced467"},
{HashType.CRC32_CKSUM, "f27b3c27"},
{HashType.CRC32_DVDROMEDC, "b538afc0"},
{HashType.CRC32_ISCSI, "544d37db"},
{HashType.CRC32_ISOHDLC, "ba02a660"},
{HashType.CRC32_JAMCRC, "45fd599f"},
@@ -244,4 +245,4 @@ namespace SabreTools.Hashing.Test
public static void ValidateSize(long fileSize)
=> Assert.Equal(_hashFileSize, fileSize);
}
}
}

View File

@@ -1481,6 +1481,20 @@ namespace SabreTools.Hashing.Checksum
XorOut = 0xffffffff,
};
/// <summary>
/// CRC-32/DVD-ROM-EDC
/// </summary>
public static readonly CrcDefinition CRC32_DVDROMEDC = new()
{
Name = "CRC-32/DVD-ROM-EDC",
Width = 32,
Poly = 0x80000011,
Init = 0x00000000,
ReflectIn = false,
ReflectOut = false,
XorOut = 0x00000000,
};
/// <summary>
/// CRC-32/ISCSI
/// </summary>

View File

@@ -138,6 +138,7 @@ namespace SabreTools.Hashing
HashType.CRC32_BZIP2 => "BZIP2",
HashType.CRC32_CDROMEDC => "CRC-32/CD-ROM-EDC",
HashType.CRC32_CKSUM => "CRC-32/CKSUM",
HashType.CRC32_DVDROMEDC => "CRC-32/DVD-ROM-EDC",
HashType.CRC32_ISCSI => "CRC-32/ISCSI",
HashType.CRC32_ISOHDLC => "CRC-32/ISO-HDLC",
HashType.CRC32_JAMCRC => "CRC-32/JAMCRC",
@@ -364,6 +365,7 @@ namespace SabreTools.Hashing
"crc32_bzip2" => HashType.CRC32_BZIP2,
"crc32_cdromedc" => HashType.CRC32_CDROMEDC,
"crc32_cksum" => HashType.CRC32_CKSUM,
"crc32_dvdromedc" => HashType.CRC32_DVDROMEDC,
"crc32_iscsi" => HashType.CRC32_ISCSI,
"crc32_isohdlc" => HashType.CRC32_ISOHDLC,
"crc32_jamcrc" => HashType.CRC32_JAMCRC,

View File

@@ -615,6 +615,11 @@ namespace SabreTools.Hashing
/// </summary>
CRC32_CKSUM,
/// <summary>
/// CRC 32-bit checksum (CRC-32/DVD-ROM-EDC)
/// </summary>
CRC32_DVDROMEDC,
/// <summary>
/// CRC 32-bit checksum (CRC-32/ISCSI)
/// </summary>

View File

@@ -208,6 +208,7 @@ namespace SabreTools.Hashing
HashType.CRC32_BZIP2 => new Crc(StandardDefinitions.CRC32_BZIP2),
HashType.CRC32_CDROMEDC => new Crc(StandardDefinitions.CRC32_CDROMEDC),
HashType.CRC32_CKSUM => new Crc(StandardDefinitions.CRC32_CKSUM),
HashType.CRC32_DVDROMEDC => new Crc(StandardDefinitions.CRC32_DVDROMEDC),
HashType.CRC32_ISCSI => new Crc(StandardDefinitions.CRC32_ISCSI),
HashType.CRC32_ISOHDLC => new Crc(StandardDefinitions.CRC32_ISOHDLC),
HashType.CRC32_JAMCRC => new Crc(StandardDefinitions.CRC32_JAMCRC),

View File

@@ -221,6 +221,7 @@ namespace SabreTools.Hashing
{HashType.CRC32_BZIP2, [0x00, 0x00, 0x00, 0x00]},
{HashType.CRC32_CDROMEDC, [0x00, 0x00, 0x00, 0x00]},
{HashType.CRC32_CKSUM, [0xff, 0xff, 0xff, 0xff]},
{HashType.CRC32_DVDROMEDC, [0x00, 0x00, 0x00, 0x00]},
{HashType.CRC32_ISCSI, [0x00, 0x00, 0x00, 0x00]},
{HashType.CRC32_ISOHDLC, [0x00, 0x00, 0x00, 0x00]},
{HashType.CRC32_JAMCRC, [0xff, 0xff, 0xff, 0xff]},
@@ -523,6 +524,7 @@ namespace SabreTools.Hashing
{HashType.CRC32_BZIP2, "00000000"},
{HashType.CRC32_CDROMEDC, "00000000"},
{HashType.CRC32_CKSUM, "ffffffff"},
{HashType.CRC32_DVDROMEDC, "00000000"},
{HashType.CRC32_ISCSI, "00000000"},
{HashType.CRC32_ISOHDLC, "00000000"},
{HashType.CRC32_JAMCRC, "ffffffff"},