Add CRC-1 (parity bit)

This commit is contained in:
Matt Nadareski
2024-11-07 22:25:48 -05:00
parent 4a408ded7e
commit 7559ba2edc
4 changed files with 52 additions and 0 deletions

View File

@@ -21,6 +21,9 @@ namespace SabreTools.Hashing.Test
{HashType.BLAKE3, "d4bd7ca6f1ebea9580d9381106b248eb5b6069170d0bfd00b17d659fcd10dcdc"},
#endif
{HashType.CRC1_ZERO, "0"},
{HashType.CRC1_ONE, "1"},
{HashType.CRC3_GSM, "4"},
{HashType.CRC3_ROHC, "3"},

View File

@@ -3,6 +3,38 @@ namespace SabreTools.Hashing.Crc
/// <see href="https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.legend"/>
public static class StandardDefinitions
{
#region CRC-1
/// <summary>
/// CRC-1/ZERO [Parity bit with 0 start]
/// </summary>
public static readonly CrcDefinition CRC1_ZERO = new()
{
Name = "CRC-1/ZERO",
Width = 1,
Poly = 0x1,
Init = 0x0,
ReflectIn = false,
ReflectOut = false,
XorOut = 0x0,
};
/// <summary>
/// CRC-1/ONE [Parity bit with 1 start]
/// </summary>
public static readonly CrcDefinition CRC1_ONE = new()
{
Name = "CRC-1/ONE",
Width = 1,
Poly = 0x1,
Init = 0x1,
ReflectIn = false,
ReflectOut = false,
XorOut = 0x0,
};
#endregion
#region CRC-3
/// <summary>

View File

@@ -17,6 +17,20 @@ namespace SabreTools.Hashing
BLAKE3,
#endif
#region CRC-1
/// <summary>
/// CRC 1-bit checksum (CRC-1/ZERO [Parity bit with 0 start])
/// </summary>
CRC1_ZERO,
/// <summary>
/// CRC 1-bit checksum (CRC-1/ONE [Parity bit with 1 start])
/// </summary>
CRC1_ONE,
#endregion
#region CRC-3
/// <summary>

View File

@@ -119,6 +119,9 @@ namespace SabreTools.Hashing
HashType.BLAKE3 => new Blake3HashAlgorithm(),
#endif
HashType.CRC1_ZERO => new CrcRunner(StandardDefinitions.CRC1_ZERO),
HashType.CRC1_ONE => new CrcRunner(StandardDefinitions.CRC1_ONE),
HashType.CRC3_GSM => new CrcRunner(StandardDefinitions.CRC3_GSM),
HashType.CRC3_ROHC => new CrcRunner(StandardDefinitions.CRC3_ROHC),