diff --git a/CDChecksums.cs b/CDChecksums.cs index 0b9a8d5..3469ceb 100644 --- a/CDChecksums.cs +++ b/CDChecksums.cs @@ -45,8 +45,21 @@ namespace Aaru.Checksums static byte[] _eccBTable; static uint[] _edcTable; + /// + /// Checks the EDC and ECC of a CD sector + /// + /// CD sector + /// true if all checks were correct, false if any of them weren't, and null if none of them are present. public static bool? CheckCdSector(byte[] buffer) => CheckCdSector(buffer, out _, out _, out _); + /// + /// Checks the EDC and ECC of a CD sector + /// + /// CD sector + /// true if ECC P is correct, false if it isn't, and null if there is no ECC P in sector. + /// true if ECC Q is correct, false if it isn't, and null if there is no ECC Q in sector. + /// true if EDC is correct, false if it isn't, and null if there is no EDC in sector. + /// true if all checks were correct, false if any of them weren't, and null if none of them are present. public static bool? CheckCdSector(byte[] buffer, out bool? correctEccP, out bool? correctEccQ, out bool? correctEdc) { diff --git a/CRC16CCITTContext.cs b/CRC16CCITTContext.cs index 6a9695f..1e913b5 100644 --- a/CRC16CCITTContext.cs +++ b/CRC16CCITTContext.cs @@ -32,9 +32,14 @@ namespace Aaru.Checksums { + /// + /// Implements the CRC16 algorithm with CCITT polynomial and seed + /// public sealed class CRC16CCITTContext : Crc16Context { + /// CCITT CRC16 polynomial public const ushort CRC16_CCITT_POLY = 0x8408; + /// CCITT CRC16 seed public const ushort CRC16_CCITT_SEED = 0x0000; static readonly ushort[] _ccittCrc16Table = { @@ -60,6 +65,10 @@ namespace Aaru.Checksums 0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 }; + /// + /// Initializes an instance of the CRC16 with CCITT polynomial and seed. + /// + /// public CRC16CCITTContext() : base(CRC16_CCITT_POLY, CRC16_CCITT_SEED, _ccittCrc16Table, true) {} /// Gets the hash of a file @@ -89,6 +98,10 @@ namespace Aaru.Checksums /// Byte array of the hash value. public static string Data(byte[] data, out byte[] hash) => Data(data, (uint)data.Length, out hash); + /// + /// Calculates the CCITT CRC16 of the specified buffer with the specified parameters + /// + /// Buffer public static ushort Calculate(byte[] buffer) => Calculate(buffer, CRC16_CCITT_POLY, CRC16_CCITT_SEED, _ccittCrc16Table, true); } diff --git a/CRC16Context.cs b/CRC16Context.cs index 623f113..79a10d8 100644 --- a/CRC16Context.cs +++ b/CRC16Context.cs @@ -214,6 +214,15 @@ namespace Aaru.Checksums return crc16Output.ToString(); } + /// + /// Calculates the CRC16 of the specified buffer with the specified parameters + /// + /// Buffer + /// Polynomial + /// Seed + /// Pre-generated lookup table + /// Inverse CRC + /// CRC16 public static ushort Calculate(byte[] buffer, ushort polynomial, ushort seed, ushort[] table, bool inverse) { ushort[] localTable = table ?? GenerateTable(polynomial, inverse); diff --git a/CRC16IBMContext.cs b/CRC16IBMContext.cs index 0c484dc..0cc5a1a 100644 --- a/CRC16IBMContext.cs +++ b/CRC16IBMContext.cs @@ -32,6 +32,9 @@ namespace Aaru.Checksums { + /// + /// Implements the CRC16 algorithm with IBM polynomial and seed + /// public sealed class CRC16IBMContext : Crc16Context { const ushort CRC16_IBM_POLY = 0xA001; @@ -61,6 +64,10 @@ namespace Aaru.Checksums 0x8641, 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040 }; + /// + /// Initializes an instance of the CRC16 with IBM polynomial and seed. + /// + /// public CRC16IBMContext() : base(CRC16_IBM_POLY, CRC16_IBM_SEED, _ibmCrc16Table, false) {} /// Gets the hash of a file @@ -90,6 +97,10 @@ namespace Aaru.Checksums /// Byte array of the hash value. public static string Data(byte[] data, out byte[] hash) => Data(data, (uint)data.Length, out hash); + /// + /// Calculates the IBM CRC16 of the specified buffer with the specified parameters + /// + /// Buffer public static ushort Calculate(byte[] buffer) => Calculate(buffer, CRC16_IBM_POLY, CRC16_IBM_SEED, _ibmCrc16Table, false); } diff --git a/CRC64Context.cs b/CRC64Context.cs index 906649a..5b6e29b 100644 --- a/CRC64Context.cs +++ b/CRC64Context.cs @@ -40,7 +40,13 @@ namespace Aaru.Checksums /// Implements a CRC64 algorithm public sealed class Crc64Context : IChecksum { + /// + /// ECMA CRC64 polynomial + /// public const ulong CRC64_ECMA_POLY = 0xC96C5795D7870F42; + /// + /// ECMA CRC64 seed + /// public const ulong CRC64_ECMA_SEED = 0xFFFFFFFFFFFFFFFF; readonly ulong _finalSeed; diff --git a/Register.cs b/Register.cs index 88abfc6..4f7f41b 100644 --- a/Register.cs +++ b/Register.cs @@ -44,29 +44,40 @@ using Aaru.CommonTypes.Interfaces; namespace Aaru.Checksums { + /// public sealed class Register : IPluginRegister { + /// public List GetAllChecksumPlugins() => Assembly. GetExecutingAssembly().GetTypes(). Where(t => t.GetInterfaces().Contains(typeof(IChecksum))). Where(t => t.IsClass).ToList(); + /// public List GetAllFilesystemPlugins() => null; + /// public List GetAllFilterPlugins() => null; + /// public List GetAllFloppyImagePlugins() => null; + /// public List GetAllMediaImagePlugins() => null; + /// public List GetAllPartitionPlugins() => null; + /// public List GetAllReadOnlyFilesystemPlugins() => null; + /// public List GetAllWritableFloppyImagePlugins() => null; + /// public List GetAllWritableImagePlugins() => null; + /// public List GetAllArchivePlugins() => null; } }