Goodbye .NET Framework 4.8 and RIPEMD160

This commit is contained in:
Matt Nadareski
2020-12-14 15:22:14 -08:00
parent 2ae180fb53
commit 7f7c3ec314
52 changed files with 59 additions and 3033 deletions

View File

@@ -15,14 +15,6 @@
0x8f, 0x00, 0xb2, 0x04,
0xe9, 0x80, 0x09, 0x98,
0xec, 0xf8, 0x42, 0x7e };
#if NET_FRAMEWORK
public const string RIPEMD160Zero = "9c1185a5c5e9fc54612808977ee8f548b2258d31";
public static readonly byte[] RIPEMD160ZeroBytes = { 0x9c, 0x11, 0x85, 0xa5,
0xc5, 0xe9, 0xfc, 0x54,
0x61, 0x28, 0x08, 0x97,
0x7e, 0xe8, 0xf5, 0x48,
0xb2, 0x25, 0x8d, 0x31 };
#endif
public const string SHA1Zero = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
public static readonly byte[] SHA1ZeroBytes = { 0xda, 0x39, 0xa3, 0xee,
0x5e, 0x6b, 0x4b, 0x0d,
@@ -77,9 +69,6 @@
public const int CRCLength = 8;
public const int MD5Length = 32;
#if NET_FRAMEWORK
public const int RIPEMD160Length = 40;
#endif
public const int SHA1Length = 40;
public const int SHA256Length = 64;
public const int SHA384Length = 96;

View File

@@ -13,24 +13,16 @@ namespace SabreTools.Core
{
CRC = 1 << 0,
MD5 = 1 << 1,
#if NET_FRAMEWORK
RIPEMD160 = 1 << 2,
#endif
SHA1 = 1 << 3,
SHA256 = 1 << 4,
SHA384 = 1 << 5,
SHA512 = 1 << 6,
SpamSum = 1 << 7,
SHA1 = 1 << 2,
SHA256 = 1 << 3,
SHA384 = 1 << 4,
SHA512 = 1 << 5,
SpamSum = 1 << 6,
// Special combinations
Standard = CRC | MD5 | SHA1,
#if NET_FRAMEWORK
DeepHashes = RIPEMD160 | SHA256 | SHA384 | SHA512 | SpamSum,
SecureHashes = MD5 | RIPEMD160 | SHA1 | SHA256 | SHA384 | SHA512 | SpamSum,
#else
DeepHashes = SHA256 | SHA384 | SHA512 | SpamSum,
SecureHashes = MD5 | SHA1 | SHA256 | SHA384 | SHA512 | SpamSum,
#endif
}
/// <summary>
@@ -621,9 +613,6 @@ namespace SabreTools.Core
DatItem_Size,
DatItem_CRC,
DatItem_MD5,
#if NET_FRAMEWORK
DatItem_RIPEMD160,
#endif
DatItem_SHA1,
DatItem_SHA256,
DatItem_SHA384,
@@ -884,9 +873,6 @@ namespace SabreTools.Core
Size,
CRC,
MD5,
#if NET_FRAMEWORK
RIPEMD160,
#endif
SHA1,
SHA256,
SHA384,

View File

@@ -12,8 +12,8 @@ namespace SabreTools.Core
/// <summary>
/// The current toolset version to be used by all child applications
/// </summary>
public readonly static string Version = $"v1.0.5";
//public readonly static string Version = $"v1.0.5-{File.GetCreationTime(Assembly.GetExecutingAssembly().Location):yyyy-MM-dd HH:mm:ss}";
//public readonly static string Version = $"v1.0.5";
public readonly static string Version = $"v1.0.5-{File.GetCreationTime(Assembly.GetExecutingAssembly().Location):yyyy-MM-dd HH:mm:ss}";
/// <summary>
/// Readies the console and outputs the header
@@ -33,7 +33,7 @@ namespace SabreTools.Core
// Set the console to ready state
ConsoleColor formertext = ConsoleColor.White;
ConsoleColor formerback = ConsoleColor.Black;
if (!MonoOrCoreEnvironment)
if (!CoreEnvironment)
{
Console.SetBufferSize(Console.BufferWidth, 999);
formertext = Console.ForegroundColor;
@@ -51,7 +51,7 @@ namespace SabreTools.Core
Console.WriteLine();
// Return the console to the original text and background colors
if (!MonoOrCoreEnvironment)
if (!CoreEnvironment)
{
Console.ForegroundColor = formertext;
Console.BackgroundColor = formerback;
@@ -60,18 +60,14 @@ namespace SabreTools.Core
}
/// <summary>
/// Returns true if running in a Mono or .NET Core environment
/// Returns true if running in a .NET Core environment
/// </summary>
/// TODO: Investigate if this is needed when removing .NET Framework 4.8 support
private static bool MonoOrCoreEnvironment
private static bool CoreEnvironment
{
get
{
#if NET_FRAMEWORK
return Type.GetType("Mono.Runtime") != null;
#else
return true;
#endif
}
}
}

View File

@@ -209,10 +209,6 @@ Options:
This allows the user to skip calculating the MD5 for each of the
files which will speed up the creation of the DAT.
-nr160, --skip-ripemd160 Include RIPEMD160 in output
This allows the user to include calculating the RIPEMD160 for each of
the files. .NET Framework 4.8 only.
-ns, --skip-sha1 Don't include SHA-1 in output
This allows the user to skip calculating the SHA-1 for each of the
files which will speed up the creation of the DAT.
@@ -269,7 +265,6 @@ Options:
msx, openmsx - openMSX Software List
ol, offlinelist - OfflineList XML
rc, romcenter - RomCenter
ripemd160 - RIPEMD160 (.NET Framework 4.8 only)
sj, sabrejson - SabreJSON
sx, sabrexml - SabreDAT XML
sfv - SFV
@@ -632,7 +627,6 @@ Options:
msx, openmsx - openMSX Software List
ol, offlinelist - OfflineList XML
rc, romcenter - RomCenter
ripemd160 - RIPEMD160 (.NET Framework 4.8 only)
sj, sabrejson - SabreJSON
sx, sabrexml - SabreDAT XML
sfv - SFV
@@ -787,7 +781,6 @@ Options:
msx, openmsx - openMSX Software List
ol, offlinelist - OfflineList XML
rc, romcenter - RomCenter
ripemd160 - RIPEMD160 (.NET Framework 4.8 only)
sj, sabrejson - SabreJSON
sx, sabrexml - SabreDAT XML
sfv - SFV
@@ -816,7 +809,6 @@ Options:
- %category% - Replaced with game Category
- %crc% - Replaced with the CRC
- %md5% - Replaced with the MD5
- %ripemd160% - Replaced with the RIPEMD160 (.NET Framework 4.8 only)
- %sha1% - Replaced with the SHA-1
- %sha256% - Replaced with the SHA-256
- %sha384% - Replaced with the SHA-384
@@ -1404,7 +1396,6 @@ has been a new stable release.
-ool, --output-ol -> -ot=ol, --output-type=offlinelist
-ool, --output-offlinelist -> -ot=ol, --output-type=offlinelist
-or, --output-rc -> -ot=rc, --output-type=romcenter
-oripemd160, --output-ripemd160 -> -ot=ripemd160, --output-type=ripemd160
-or, --output-romcenter -> -ot=rc, --output-type=romcenter
-os, --output-sd -> -ot=sd, --output-type=sabredat
-os, --output-sabredat -> -ot=sd, --output-type=sabredat
@@ -1449,11 +1440,10 @@ has been a new stable release.
-udd, --update-desc -> -uf=machine.description, --update-field=machine.description
-udd, --update-description -> -uf=machine.description, --update-field=machine.description
-ugt, --update-game-type -> -uf=machine.type, --update-field=machine.type
-uh, --update-hashes -> (-uf=item.crc -uf=item.md5 -uf=item.ripemd160
-uf=item.sha1 -uf=item.sha256 -uf=item.sha384 -uf=item.sha512 -uf=item.spamsum),
(--update-field=item.crc --update-field=item.md5 --update-field=item.ripemd160
--update-field=item.sha1 --update-field=item.sha256 --update-field=item.sha384
--update-field=item.sha512 --update-field=item.spamsum)
-uh, --update-hashes -> (-uf=item.crc -uf=item.md5 -uf=item.sha1 -uf=item.sha256
-uf=item.sha384 -uf=item.sha512 -uf=item.spamsum), (--update-field=item.crc
--update-field=item.md5 --update-field=item.sha1 --update-field=item.sha256
--update-field=item.sha384 --update-field=item.sha512 --update-field=item.spamsum)
-um, --update-manu -> -uf=machine.manufacturer, --update-field=machine.manufacturer
-um, --update-manufacturer -> -uf=machine.manufacturer, --update-field=machine.manufacturer
-un, --update-names -> -uf=item.name, --update-field=item.name

View File

@@ -1,16 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net48;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
<RuntimeIdentifiers>win10-x64;win7-x86</RuntimeIdentifiers>
<Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='net48'">
<DefineConstants>NET_FRAMEWORK</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

View File

@@ -506,13 +506,7 @@ namespace Aaru.Checksums
count++;
}
#if NET_FRAMEWORK
byte[] newString = new byte[count];
Array.Copy(cString, newString, count);
return newString;
#else
return new ReadOnlySpan<byte>(cString, 0, count).ToArray();
#endif
}
public void Dispose()

File diff suppressed because it is too large Load Diff

View File

@@ -35,12 +35,6 @@ namespace SabreTools.Core.Tools
_hasher = MD5.Create();
break;
#if NET_FRAMEWORK
case Hash.RIPEMD160:
_hasher = RIPEMD160.Create();
break;
#endif
case Hash.SHA1:
_hasher = SHA1.Create();
break;
@@ -80,9 +74,6 @@ namespace SabreTools.Core.Tools
break;
case Hash.MD5:
#if NET_FRAMEWORK
case Hash.RIPEMD160:
#endif
case Hash.SHA1:
case Hash.SHA256:
case Hash.SHA384:
@@ -109,9 +100,6 @@ namespace SabreTools.Core.Tools
break;
case Hash.MD5:
#if NET_FRAMEWORK
case Hash.RIPEMD160:
#endif
case Hash.SHA1:
case Hash.SHA256:
case Hash.SHA384:
@@ -136,9 +124,6 @@ namespace SabreTools.Core.Tools
return BitConverter.GetBytes((_hasher as OptimizedCRC.OptimizedCRC).Value).Reverse().ToArray();
case Hash.MD5:
#if NET_FRAMEWORK
case Hash.RIPEMD160:
#endif
case Hash.SHA1:
case Hash.SHA256:
case Hash.SHA384:

View File

@@ -163,7 +163,6 @@ namespace SabreTools.Core.Tools
case "dat":
case "json":
case "md5":
case "ripemd160":
case "sfv":
case "sha1":
case "sha256":