mirror of
https://github.com/aaru-dps/Aaru.Checksums.git
synced 2025-12-16 19:24:29 +00:00
REFACTOR: Use preferred braces style.
This commit is contained in:
@@ -92,10 +92,7 @@ namespace DiscImageChef.Checksums
|
|||||||
StringBuilder adlerOutput = new StringBuilder();
|
StringBuilder adlerOutput = new StringBuilder();
|
||||||
|
|
||||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||||
for(int i = 0; i < BigEndianBitConverter.GetBytes(finalSum).Length; i++)
|
for(int i = 0; i < BigEndianBitConverter.GetBytes(finalSum).Length; i++) adlerOutput.Append(BigEndianBitConverter.GetBytes(finalSum)[i].ToString("x2"));
|
||||||
{
|
|
||||||
adlerOutput.Append(BigEndianBitConverter.GetBytes(finalSum)[i].ToString("x2"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return adlerOutput.ToString();
|
return adlerOutput.ToString();
|
||||||
}
|
}
|
||||||
@@ -138,7 +135,7 @@ namespace DiscImageChef.Checksums
|
|||||||
|
|
||||||
StringBuilder adlerOutput = new StringBuilder();
|
StringBuilder adlerOutput = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { adlerOutput.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) adlerOutput.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
|
|
||||||
@@ -172,7 +169,7 @@ namespace DiscImageChef.Checksums
|
|||||||
|
|
||||||
StringBuilder adlerOutput = new StringBuilder();
|
StringBuilder adlerOutput = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { adlerOutput.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) adlerOutput.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
return adlerOutput.ToString();
|
return adlerOutput.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,17 +99,17 @@ namespace DiscImageChef.Checksums
|
|||||||
for(minor = 0; minor < minorCount; minor++)
|
for(minor = 0; minor < minorCount; minor++)
|
||||||
{
|
{
|
||||||
byte temp;
|
byte temp;
|
||||||
if(index < 4) { temp = address[index]; }
|
if(index < 4) temp = address[index];
|
||||||
else { temp = data[index - 4]; }
|
else temp = data[index - 4];
|
||||||
index += minorInc;
|
index += minorInc;
|
||||||
if(index >= size) { index -= size; }
|
if(index >= size) index -= size;
|
||||||
eccA ^= temp;
|
eccA ^= temp;
|
||||||
eccB ^= temp;
|
eccB ^= temp;
|
||||||
eccA = eccFTable[eccA];
|
eccA = eccFTable[eccA];
|
||||||
}
|
}
|
||||||
|
|
||||||
eccA = eccBTable[eccFTable[eccA] ^ eccB];
|
eccA = eccBTable[eccFTable[eccA] ^ eccB];
|
||||||
if(ecc[major] != eccA || ecc[major + majorCount] != (eccA ^ eccB)) { return false; }
|
if(ecc[major] != eccA || ecc[major + majorCount] != (eccA ^ eccB)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -132,7 +132,6 @@ namespace DiscImageChef.Checksums
|
|||||||
DicConsole.DebugWriteLine("CD checksums", "Mode 0 sector at address {0:X2}:{1:X2}:{2:X2}",
|
DicConsole.DebugWriteLine("CD checksums", "Mode 0 sector at address {0:X2}:{1:X2}:{2:X2}",
|
||||||
channel[0x00C], channel[0x00D], channel[0x00E]);
|
channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||||
for(int i = 0x010; i < 0x930; i++)
|
for(int i = 0x010; i < 0x930; i++)
|
||||||
{
|
|
||||||
if(channel[i] != 0x00)
|
if(channel[i] != 0x00)
|
||||||
{
|
{
|
||||||
DicConsole.DebugWriteLine("CD checksums",
|
DicConsole.DebugWriteLine("CD checksums",
|
||||||
@@ -140,7 +139,6 @@ namespace DiscImageChef.Checksums
|
|||||||
channel[0x00C], channel[0x00D], channel[0x00E]);
|
channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -211,11 +209,9 @@ namespace DiscImageChef.Checksums
|
|||||||
{
|
{
|
||||||
if(channel[0x010] != channel[0x014] || channel[0x011] != channel[0x015] ||
|
if(channel[0x010] != channel[0x014] || channel[0x011] != channel[0x015] ||
|
||||||
channel[0x012] != channel[0x016] || channel[0x013] != channel[0x017])
|
channel[0x012] != channel[0x016] || channel[0x013] != channel[0x017])
|
||||||
{
|
|
||||||
DicConsole.DebugWriteLine("CD checksums",
|
DicConsole.DebugWriteLine("CD checksums",
|
||||||
"Subheader copies differ in mode 2 form 2 sector at address: {0:X2}:{1:X2}:{2:X2}",
|
"Subheader copies differ in mode 2 form 2 sector at address: {0:X2}:{1:X2}:{2:X2}",
|
||||||
channel[0x00C], channel[0x00D], channel[0x00E]);
|
channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO: This is not working
|
/* TODO: This is not working
|
||||||
byte[] SectorForCheck = new byte[0x91C];
|
byte[] SectorForCheck = new byte[0x91C];
|
||||||
@@ -235,11 +231,9 @@ namespace DiscImageChef.Checksums
|
|||||||
{
|
{
|
||||||
if(channel[0x010] != channel[0x014] || channel[0x011] != channel[0x015] ||
|
if(channel[0x010] != channel[0x014] || channel[0x011] != channel[0x015] ||
|
||||||
channel[0x012] != channel[0x016] || channel[0x013] != channel[0x017])
|
channel[0x012] != channel[0x016] || channel[0x013] != channel[0x017])
|
||||||
{
|
|
||||||
DicConsole.DebugWriteLine("CD checksums",
|
DicConsole.DebugWriteLine("CD checksums",
|
||||||
"Subheader copies differ in mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}",
|
"Subheader copies differ in mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}",
|
||||||
channel[0x00C], channel[0x00D], channel[0x00E]);
|
channel[0x00C], channel[0x00D], channel[0x00E]);
|
||||||
}
|
|
||||||
|
|
||||||
byte[] address = new byte[4];
|
byte[] address = new byte[4];
|
||||||
byte[] data = new byte[2060];
|
byte[] data = new byte[2060];
|
||||||
@@ -380,10 +374,10 @@ namespace DiscImageChef.Checksums
|
|||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
for(int j = 0; j < 24; j++) { cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F); }
|
for(int j = 0; j < 24; j++) cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F);
|
||||||
for(int j = 0; j < 24; j++) { cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F); }
|
for(int j = 0; j < 24; j++) cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F);
|
||||||
for(int j = 0; j < 24; j++) { cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F); }
|
for(int j = 0; j < 24; j++) cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F);
|
||||||
for(int j = 0; j < 24; j++) { cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F); }
|
for(int j = 0; j < 24; j++) cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F);
|
||||||
|
|
||||||
switch(cdSubRwPack1[0])
|
switch(cdSubRwPack1[0])
|
||||||
{
|
{
|
||||||
@@ -526,10 +520,7 @@ namespace DiscImageChef.Checksums
|
|||||||
static ushort CalculateCCITT_CRC16(byte[] buffer)
|
static ushort CalculateCCITT_CRC16(byte[] buffer)
|
||||||
{
|
{
|
||||||
ushort crc16 = 0;
|
ushort crc16 = 0;
|
||||||
for(int i = 0; i < buffer.Length; i++)
|
for(int i = 0; i < buffer.Length; i++) crc16 = (ushort)(CcittCrc16Table[(crc16 >> 8) ^ buffer[i]] ^ (crc16 << 8));
|
||||||
{
|
|
||||||
crc16 = (ushort)(CcittCrc16Table[(crc16 >> 8) ^ buffer[i]] ^ (crc16 << 8));
|
|
||||||
}
|
|
||||||
|
|
||||||
crc16 = (ushort)~crc16;
|
crc16 = (ushort)~crc16;
|
||||||
|
|
||||||
|
|||||||
@@ -104,10 +104,7 @@ namespace DiscImageChef.Checksums
|
|||||||
StringBuilder crc16Output = new StringBuilder();
|
StringBuilder crc16Output = new StringBuilder();
|
||||||
|
|
||||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||||
for(int i = 0; i < BigEndianBitConverter.GetBytes(hashInt).Length; i++)
|
for(int i = 0; i < BigEndianBitConverter.GetBytes(hashInt).Length; i++) crc16Output.Append(BigEndianBitConverter.GetBytes(hashInt)[i].ToString("x2"));
|
||||||
{
|
|
||||||
crc16Output.Append(BigEndianBitConverter.GetBytes(hashInt)[i].ToString("x2"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return crc16Output.ToString();
|
return crc16Output.ToString();
|
||||||
}
|
}
|
||||||
@@ -155,7 +152,7 @@ namespace DiscImageChef.Checksums
|
|||||||
|
|
||||||
StringBuilder crc16Output = new StringBuilder();
|
StringBuilder crc16Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { crc16Output.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) crc16Output.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
|
|
||||||
@@ -207,7 +204,7 @@ namespace DiscImageChef.Checksums
|
|||||||
|
|
||||||
StringBuilder crc16Output = new StringBuilder();
|
StringBuilder crc16Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { crc16Output.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) crc16Output.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
return crc16Output.ToString();
|
return crc16Output.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,10 +104,7 @@ namespace DiscImageChef.Checksums
|
|||||||
StringBuilder crc32Output = new StringBuilder();
|
StringBuilder crc32Output = new StringBuilder();
|
||||||
|
|
||||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||||
for(int i = 0; i < BigEndianBitConverter.GetBytes(hashInt).Length; i++)
|
for(int i = 0; i < BigEndianBitConverter.GetBytes(hashInt).Length; i++) crc32Output.Append(BigEndianBitConverter.GetBytes(hashInt)[i].ToString("x2"));
|
||||||
{
|
|
||||||
crc32Output.Append(BigEndianBitConverter.GetBytes(hashInt)[i].ToString("x2"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return crc32Output.ToString();
|
return crc32Output.ToString();
|
||||||
}
|
}
|
||||||
@@ -156,7 +153,7 @@ namespace DiscImageChef.Checksums
|
|||||||
|
|
||||||
StringBuilder crc32Output = new StringBuilder();
|
StringBuilder crc32Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { crc32Output.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) crc32Output.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
|
|
||||||
@@ -208,7 +205,7 @@ namespace DiscImageChef.Checksums
|
|||||||
|
|
||||||
StringBuilder crc32Output = new StringBuilder();
|
StringBuilder crc32Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { crc32Output.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) crc32Output.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
return crc32Output.ToString();
|
return crc32Output.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,10 +103,7 @@ namespace DiscImageChef.Checksums
|
|||||||
StringBuilder crc64Output = new StringBuilder();
|
StringBuilder crc64Output = new StringBuilder();
|
||||||
|
|
||||||
BigEndianBitConverter.IsLittleEndian = BigEndianBitConverter.IsLittleEndian;
|
BigEndianBitConverter.IsLittleEndian = BigEndianBitConverter.IsLittleEndian;
|
||||||
for(int i = 0; i < BigEndianBitConverter.GetBytes(hashInt).Length; i++)
|
for(int i = 0; i < BigEndianBitConverter.GetBytes(hashInt).Length; i++) crc64Output.Append(BigEndianBitConverter.GetBytes(hashInt)[i].ToString("x2"));
|
||||||
{
|
|
||||||
crc64Output.Append(BigEndianBitConverter.GetBytes(hashInt)[i].ToString("x2"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return crc64Output.ToString();
|
return crc64Output.ToString();
|
||||||
}
|
}
|
||||||
@@ -155,7 +152,7 @@ namespace DiscImageChef.Checksums
|
|||||||
|
|
||||||
StringBuilder crc64Output = new StringBuilder();
|
StringBuilder crc64Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { crc64Output.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) crc64Output.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
|
|
||||||
@@ -207,7 +204,7 @@ namespace DiscImageChef.Checksums
|
|||||||
|
|
||||||
StringBuilder crc64Output = new StringBuilder();
|
StringBuilder crc64Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { crc64Output.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) crc64Output.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
return crc64Output.ToString();
|
return crc64Output.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ namespace DiscImageChef.Checksums
|
|||||||
md5Provider.TransformFinalBlock(new byte[0], 0, 0);
|
md5Provider.TransformFinalBlock(new byte[0], 0, 0);
|
||||||
StringBuilder md5Output = new StringBuilder();
|
StringBuilder md5Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < md5Provider.Hash.Length; i++) { md5Output.Append(md5Provider.Hash[i].ToString("x2")); }
|
for(int i = 0; i < md5Provider.Hash.Length; i++) md5Output.Append(md5Provider.Hash[i].ToString("x2"));
|
||||||
|
|
||||||
return md5Output.ToString();
|
return md5Output.ToString();
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,7 @@ namespace DiscImageChef.Checksums
|
|||||||
hash = md5Provider.ComputeHash(fileStream);
|
hash = md5Provider.ComputeHash(fileStream);
|
||||||
StringBuilder md5Output = new StringBuilder();
|
StringBuilder md5Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { md5Output.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) md5Output.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ namespace DiscImageChef.Checksums
|
|||||||
hash = md5Provider.ComputeHash(data, 0, (int)len);
|
hash = md5Provider.ComputeHash(data, 0, (int)len);
|
||||||
StringBuilder md5Output = new StringBuilder();
|
StringBuilder md5Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { md5Output.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) md5Output.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
return md5Output.ToString();
|
return md5Output.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,10 +87,7 @@ namespace DiscImageChef.Checksums
|
|||||||
ripemd160Provider.TransformFinalBlock(new byte[0], 0, 0);
|
ripemd160Provider.TransformFinalBlock(new byte[0], 0, 0);
|
||||||
StringBuilder ripemd160Output = new StringBuilder();
|
StringBuilder ripemd160Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < ripemd160Provider.Hash.Length; i++)
|
for(int i = 0; i < ripemd160Provider.Hash.Length; i++) ripemd160Output.Append(ripemd160Provider.Hash[i].ToString("x2"));
|
||||||
{
|
|
||||||
ripemd160Output.Append(ripemd160Provider.Hash[i].ToString("x2"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return ripemd160Output.ToString();
|
return ripemd160Output.ToString();
|
||||||
}
|
}
|
||||||
@@ -118,7 +115,7 @@ namespace DiscImageChef.Checksums
|
|||||||
hash = ripemd160Provider.ComputeHash(fileStream);
|
hash = ripemd160Provider.ComputeHash(fileStream);
|
||||||
StringBuilder ripemd160Output = new StringBuilder();
|
StringBuilder ripemd160Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { ripemd160Output.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) ripemd160Output.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
|
|
||||||
@@ -136,7 +133,7 @@ namespace DiscImageChef.Checksums
|
|||||||
hash = ripemd160Provider.ComputeHash(data, 0, (int)len);
|
hash = ripemd160Provider.ComputeHash(data, 0, (int)len);
|
||||||
StringBuilder ripemd160Output = new StringBuilder();
|
StringBuilder ripemd160Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { ripemd160Output.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) ripemd160Output.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
return ripemd160Output.ToString();
|
return ripemd160Output.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ namespace DiscImageChef.Checksums
|
|||||||
Clear(ref bb, nn - kk);
|
Clear(ref bb, nn - kk);
|
||||||
for(i = kk - 1; i >= 0; i--)
|
for(i = kk - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if(mm != 8) { if(data[i] > nn) return -1; /* Illegal symbol */ }
|
if(mm != 8) if(data[i] > nn) return -1; /* Illegal symbol */
|
||||||
|
|
||||||
feedback = index_of[data[i] ^ bb[nn - kk - 1]];
|
feedback = index_of[data[i] ^ bb[nn - kk - 1]];
|
||||||
if(feedback != a0)
|
if(feedback != a0)
|
||||||
@@ -384,7 +384,7 @@ namespace DiscImageChef.Checksums
|
|||||||
/* data[] is in polynomial form, copy and convert to index form */
|
/* data[] is in polynomial form, copy and convert to index form */
|
||||||
for(i = nn - 1; i >= 0; i--)
|
for(i = nn - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if(mm != 8) { if(data[i] > nn) return -1; /* Illegal symbol */ }
|
if(mm != 8) if(data[i] > nn) return -1; /* Illegal symbol */
|
||||||
|
|
||||||
recd[i] = index_of[data[i]];
|
recd[i] = index_of[data[i]];
|
||||||
}
|
}
|
||||||
@@ -405,14 +405,7 @@ namespace DiscImageChef.Checksums
|
|||||||
s[i] = index_of[tmp];
|
s[i] = index_of[tmp];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(synError == 0)
|
if(synError == 0) return 0;
|
||||||
{
|
|
||||||
/*
|
|
||||||
* if syndrome is zero, data[] is a codeword and there are no
|
|
||||||
* errors to correct. So return data[] unmodified
|
|
||||||
*/
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Clear(ref lambda, nn - kk);
|
Clear(ref lambda, nn - kk);
|
||||||
lambda[0] = 1;
|
lambda[0] = 1;
|
||||||
@@ -483,13 +476,7 @@ namespace DiscImageChef.Checksums
|
|||||||
/* r is the step number */
|
/* r is the step number */
|
||||||
/* Compute discrepancy at the r-th step in poly-form */
|
/* Compute discrepancy at the r-th step in poly-form */
|
||||||
discrR = 0;
|
discrR = 0;
|
||||||
for(i = 0; i < r; i++)
|
for(i = 0; i < r; i++) if(lambda[i] != 0 && s[r - i] != a0) discrR ^= alpha_to[Modnn(index_of[lambda[i]] + s[r - i])];
|
||||||
{
|
|
||||||
if(lambda[i] != 0 && s[r - i] != a0)
|
|
||||||
{
|
|
||||||
discrR ^= alpha_to[Modnn(index_of[lambda[i]] + s[r - i])];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
discrR = index_of[discrR]; /* Index form */
|
discrR = index_of[discrR]; /* Index form */
|
||||||
if(discrR == a0)
|
if(discrR == a0)
|
||||||
@@ -503,10 +490,8 @@ namespace DiscImageChef.Checksums
|
|||||||
/* 7 lines below: T(x) <-- lambda(x) - discr_r*x*b(x) */
|
/* 7 lines below: T(x) <-- lambda(x) - discr_r*x*b(x) */
|
||||||
t[0] = lambda[0];
|
t[0] = lambda[0];
|
||||||
for(i = 0; i < nn - kk; i++)
|
for(i = 0; i < nn - kk; i++)
|
||||||
{
|
|
||||||
if(b[i] != a0) t[i + 1] = lambda[i + 1] ^ alpha_to[Modnn(discrR + b[i])];
|
if(b[i] != a0) t[i + 1] = lambda[i + 1] ^ alpha_to[Modnn(discrR + b[i])];
|
||||||
else t[i + 1] = lambda[i + 1];
|
else t[i + 1] = lambda[i + 1];
|
||||||
}
|
|
||||||
|
|
||||||
if(2 * el <= r + noEras - 1)
|
if(2 * el <= r + noEras - 1)
|
||||||
{
|
{
|
||||||
@@ -570,14 +555,7 @@ namespace DiscImageChef.Checksums
|
|||||||
DicConsole.DebugWriteLine("Reed Solomon", "\n");
|
DicConsole.DebugWriteLine("Reed Solomon", "\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(degLambda != count)
|
if(degLambda != count) return -1;
|
||||||
{
|
|
||||||
/*
|
|
||||||
* deg(lambda) unequal to number of roots => uncorrectable
|
|
||||||
* error detected
|
|
||||||
*/
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo
|
* Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo
|
||||||
* x**(NN-KK)). in index form. Also find deg(omega).
|
* x**(NN-KK)). in index form. Also find deg(omega).
|
||||||
@@ -587,10 +565,7 @@ namespace DiscImageChef.Checksums
|
|||||||
{
|
{
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
j = degLambda < i ? degLambda : i;
|
j = degLambda < i ? degLambda : i;
|
||||||
for(; j >= 0; j--)
|
for(; j >= 0; j--) if(s[i + 1 - j] != a0 && lambda[j] != a0) tmp ^= alpha_to[Modnn(s[i + 1 - j] + lambda[j])];
|
||||||
{
|
|
||||||
if(s[i + 1 - j] != a0 && lambda[j] != a0) tmp ^= alpha_to[Modnn(s[i + 1 - j] + lambda[j])];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(tmp != 0) degOmega = i;
|
if(tmp != 0) degOmega = i;
|
||||||
omega[i] = index_of[tmp];
|
omega[i] = index_of[tmp];
|
||||||
@@ -605,19 +580,13 @@ namespace DiscImageChef.Checksums
|
|||||||
for(j = count - 1; j >= 0; j--)
|
for(j = count - 1; j >= 0; j--)
|
||||||
{
|
{
|
||||||
num1 = 0;
|
num1 = 0;
|
||||||
for(i = degOmega; i >= 0; i--)
|
for(i = degOmega; i >= 0; i--) if(omega[i] != a0) num1 ^= alpha_to[Modnn(omega[i] + i * root[j])];
|
||||||
{
|
|
||||||
if(omega[i] != a0) num1 ^= alpha_to[Modnn(omega[i] + i * root[j])];
|
|
||||||
}
|
|
||||||
|
|
||||||
num2 = alpha_to[Modnn(root[j] * (B0 - 1) + nn)];
|
num2 = alpha_to[Modnn(root[j] * (B0 - 1) + nn)];
|
||||||
den = 0;
|
den = 0;
|
||||||
|
|
||||||
/* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */
|
/* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */
|
||||||
for(i = Min(degLambda, nn - kk - 1) & ~1; i >= 0; i -= 2)
|
for(i = Min(degLambda, nn - kk - 1) & ~1; i >= 0; i -= 2) if(lambda[i + 1] != a0) den ^= alpha_to[Modnn(lambda[i + 1] + i * root[j])];
|
||||||
{
|
|
||||||
if(lambda[i + 1] != a0) den ^= alpha_to[Modnn(lambda[i + 1] + i * root[j])];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(den == 0)
|
if(den == 0)
|
||||||
{
|
{
|
||||||
@@ -625,10 +594,7 @@ namespace DiscImageChef.Checksums
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* Apply error to data */
|
/* Apply error to data */
|
||||||
if(num1 != 0)
|
if(num1 != 0) data[loc[j]] ^= alpha_to[Modnn(index_of[num1] + index_of[num2] + nn - index_of[den])];
|
||||||
{
|
|
||||||
data[loc[j]] ^= alpha_to[Modnn(index_of[num1] + index_of[num2] + nn - index_of[den])];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
|||||||
@@ -87,10 +87,7 @@ namespace DiscImageChef.Checksums
|
|||||||
sha1Provider.TransformFinalBlock(new byte[0], 0, 0);
|
sha1Provider.TransformFinalBlock(new byte[0], 0, 0);
|
||||||
StringBuilder sha1Output = new StringBuilder();
|
StringBuilder sha1Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < sha1Provider.Hash.Length; i++)
|
for(int i = 0; i < sha1Provider.Hash.Length; i++) sha1Output.Append(sha1Provider.Hash[i].ToString("x2"));
|
||||||
{
|
|
||||||
sha1Output.Append(sha1Provider.Hash[i].ToString("x2"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return sha1Output.ToString();
|
return sha1Output.ToString();
|
||||||
}
|
}
|
||||||
@@ -118,7 +115,7 @@ namespace DiscImageChef.Checksums
|
|||||||
hash = sha1Provider.ComputeHash(fileStream);
|
hash = sha1Provider.ComputeHash(fileStream);
|
||||||
StringBuilder sha1Output = new StringBuilder();
|
StringBuilder sha1Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { sha1Output.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) sha1Output.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
|
|
||||||
@@ -136,7 +133,7 @@ namespace DiscImageChef.Checksums
|
|||||||
hash = sha1Provider.ComputeHash(data, 0, (int)len);
|
hash = sha1Provider.ComputeHash(data, 0, (int)len);
|
||||||
StringBuilder sha1Output = new StringBuilder();
|
StringBuilder sha1Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { sha1Output.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) sha1Output.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
return sha1Output.ToString();
|
return sha1Output.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,9 +88,7 @@ namespace DiscImageChef.Checksums
|
|||||||
StringBuilder sha256Output = new StringBuilder();
|
StringBuilder sha256Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < sha256Provider.Hash.Length; i++)
|
for(int i = 0; i < sha256Provider.Hash.Length; i++)
|
||||||
{
|
|
||||||
sha256Output.Append(sha256Provider.Hash[i].ToString("x2"));
|
sha256Output.Append(sha256Provider.Hash[i].ToString("x2"));
|
||||||
}
|
|
||||||
|
|
||||||
return sha256Output.ToString();
|
return sha256Output.ToString();
|
||||||
}
|
}
|
||||||
@@ -118,7 +116,7 @@ namespace DiscImageChef.Checksums
|
|||||||
hash = sha256Provider.ComputeHash(fileStream);
|
hash = sha256Provider.ComputeHash(fileStream);
|
||||||
StringBuilder sha256Output = new StringBuilder();
|
StringBuilder sha256Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { sha256Output.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) sha256Output.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
|
|
||||||
@@ -136,7 +134,7 @@ namespace DiscImageChef.Checksums
|
|||||||
hash = sha256Provider.ComputeHash(data, 0, (int)len);
|
hash = sha256Provider.ComputeHash(data, 0, (int)len);
|
||||||
StringBuilder sha256Output = new StringBuilder();
|
StringBuilder sha256Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { sha256Output.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) sha256Output.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
return sha256Output.ToString();
|
return sha256Output.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,10 +87,7 @@ namespace DiscImageChef.Checksums
|
|||||||
sha384Provider.TransformFinalBlock(new byte[0], 0, 0);
|
sha384Provider.TransformFinalBlock(new byte[0], 0, 0);
|
||||||
StringBuilder sha384Output = new StringBuilder();
|
StringBuilder sha384Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < sha384Provider.Hash.Length; i++)
|
for(int i = 0; i < sha384Provider.Hash.Length; i++) sha384Output.Append(sha384Provider.Hash[i].ToString("x2"));
|
||||||
{
|
|
||||||
sha384Output.Append(sha384Provider.Hash[i].ToString("x2"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return sha384Output.ToString();
|
return sha384Output.ToString();
|
||||||
}
|
}
|
||||||
@@ -118,7 +115,7 @@ namespace DiscImageChef.Checksums
|
|||||||
hash = sha384Provider.ComputeHash(fileStream);
|
hash = sha384Provider.ComputeHash(fileStream);
|
||||||
StringBuilder sha384Output = new StringBuilder();
|
StringBuilder sha384Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { sha384Output.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) sha384Output.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
|
|
||||||
@@ -136,7 +133,7 @@ namespace DiscImageChef.Checksums
|
|||||||
hash = sha384Provider.ComputeHash(data, 0, (int)len);
|
hash = sha384Provider.ComputeHash(data, 0, (int)len);
|
||||||
StringBuilder sha384Output = new StringBuilder();
|
StringBuilder sha384Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { sha384Output.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) sha384Output.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
return sha384Output.ToString();
|
return sha384Output.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,10 +87,7 @@ namespace DiscImageChef.Checksums
|
|||||||
sha512Provider.TransformFinalBlock(new byte[0], 0, 0);
|
sha512Provider.TransformFinalBlock(new byte[0], 0, 0);
|
||||||
StringBuilder sha512Output = new StringBuilder();
|
StringBuilder sha512Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < sha512Provider.Hash.Length; i++)
|
for(int i = 0; i < sha512Provider.Hash.Length; i++) sha512Output.Append(sha512Provider.Hash[i].ToString("x2"));
|
||||||
{
|
|
||||||
sha512Output.Append(sha512Provider.Hash[i].ToString("x2"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return sha512Output.ToString();
|
return sha512Output.ToString();
|
||||||
}
|
}
|
||||||
@@ -118,7 +115,7 @@ namespace DiscImageChef.Checksums
|
|||||||
hash = sha512Provider.ComputeHash(fileStream);
|
hash = sha512Provider.ComputeHash(fileStream);
|
||||||
StringBuilder sha512Output = new StringBuilder();
|
StringBuilder sha512Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { sha512Output.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) sha512Output.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
|
|
||||||
@@ -136,7 +133,7 @@ namespace DiscImageChef.Checksums
|
|||||||
hash = sha512Provider.ComputeHash(data, 0, (int)len);
|
hash = sha512Provider.ComputeHash(data, 0, (int)len);
|
||||||
StringBuilder sha512Output = new StringBuilder();
|
StringBuilder sha512Output = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0; i < hash.Length; i++) { sha512Output.Append(hash[i].ToString("x2")); }
|
for(int i = 0; i < hash.Length; i++) sha512Output.Append(hash[i].ToString("x2"));
|
||||||
|
|
||||||
return sha512Output.ToString();
|
return sha512Output.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,12 +233,7 @@ namespace DiscImageChef.Checksums
|
|||||||
/* We have hit a reset point. We now emit hashes which are
|
/* We have hit a reset point. We now emit hashes which are
|
||||||
* based on all characters in the piece of the message between
|
* based on all characters in the piece of the message between
|
||||||
* the last reset point and this one */
|
* the last reset point and this one */
|
||||||
if(0 == self.Bh[i].Dlen)
|
if(0 == self.Bh[i].Dlen) fuzzy_try_fork_blockhash();
|
||||||
{
|
|
||||||
/* Can only happen 30 times. */
|
|
||||||
/* First step for this blocksize. Clone next. */
|
|
||||||
fuzzy_try_fork_blockhash();
|
|
||||||
}
|
|
||||||
self.Bh[i].Digest[self.Bh[i].Dlen] = b64[self.Bh[i].H % 64];
|
self.Bh[i].Digest[self.Bh[i].Dlen] = b64[self.Bh[i].H % 64];
|
||||||
self.Bh[i].Halfdigest = b64[self.Bh[i].Halfh % 64];
|
self.Bh[i].Halfdigest = b64[self.Bh[i].Halfh % 64];
|
||||||
if(self.Bh[i].Dlen < SPAMSUM_LENGTH - 1)
|
if(self.Bh[i].Dlen < SPAMSUM_LENGTH - 1)
|
||||||
@@ -300,7 +295,7 @@ namespace DiscImageChef.Checksums
|
|||||||
while((ulong)SSDEEP_BS(bi) * SPAMSUM_LENGTH < self.TotalSize)
|
while((ulong)SSDEEP_BS(bi) * SPAMSUM_LENGTH < self.TotalSize)
|
||||||
{
|
{
|
||||||
++bi;
|
++bi;
|
||||||
if(bi >= NUM_BLOCKHASHES) { throw new OverflowException("The input exceeds data types."); }
|
if(bi >= NUM_BLOCKHASHES) throw new OverflowException("The input exceeds data types.");
|
||||||
}
|
}
|
||||||
/* Adapt blocksize guess to actual digest length. */
|
/* Adapt blocksize guess to actual digest length. */
|
||||||
while(bi >= self.Bhend) --bi;
|
while(bi >= self.Bhend) --bi;
|
||||||
|
|||||||
Reference in New Issue
Block a user