mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Move to .NET 5.0
This commit is contained in:
parent
46be7259d0
commit
25f8115600
20 changed files with 67 additions and 102 deletions
|
@ -1 +1 @@
|
||||||
3.1.402
|
5.0.100
|
13
build.ps1
13
build.ps1
|
@ -69,6 +69,19 @@ try {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Make sure we have a 3.1 runtime. At the time of writing GitVersion doesn't have a 5.0 build
|
||||||
|
# Remove when a 5.0 build is available
|
||||||
|
if((& $env:DOTNET_EXE --list-runtimes | Out-String) -notlike "*Microsoft.NETCore.App 3.1.*") {
|
||||||
|
|
||||||
|
# Download install script
|
||||||
|
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
|
||||||
|
New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
|
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)
|
||||||
|
|
||||||
|
ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Channel 3.1 -Runtime dotnet -NoPath }
|
||||||
|
}
|
||||||
|
|
||||||
Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)"
|
Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)"
|
||||||
|
|
||||||
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile -- $BuildArguments }
|
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile -- $BuildArguments }
|
||||||
|
|
16
build.sh
16
build.sh
|
@ -74,6 +74,22 @@ elif [[ ! (-x "$DOTNET_EXE" && (-z ${DOTNET_VERSION+x} || $($DOTNET_EXE --versio
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Make sure we have a 3.1 runtime. At the time of writing GitVersion doesn't have a 5.0 build
|
||||||
|
# Remove when a 5.0 build is available
|
||||||
|
if [[ $($DOTNET_EXE --list-runtimes) != *"Microsoft.NETCore.App 3.1."* ]]; then
|
||||||
|
|
||||||
|
# Download install script
|
||||||
|
DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh"
|
||||||
|
mkdir -p "$TEMP_DIRECTORY"
|
||||||
|
|
||||||
|
if [ ! -x "$DOTNET_INSTALL_FILE" ]; then
|
||||||
|
curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL"
|
||||||
|
chmod +x "$DOTNET_INSTALL_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel 3.1 --runtime dotnet --no-path
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)"
|
echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)"
|
||||||
|
|
||||||
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" -- ${BUILD_ARGUMENTS[@]}
|
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" -- ${BUILD_ARGUMENTS[@]}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
@ -44,7 +43,7 @@ namespace LibHacBuild
|
||||||
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
|
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
|
||||||
AbsolutePath SignedArtifactsDirectory => ArtifactsDirectory / "signed";
|
AbsolutePath SignedArtifactsDirectory => ArtifactsDirectory / "signed";
|
||||||
AbsolutePath TempDirectory => RootDirectory / ".tmp";
|
AbsolutePath TempDirectory => RootDirectory / ".tmp";
|
||||||
AbsolutePath CliCoreDir => TempDirectory / "hactoolnet_netcoreapp3.1";
|
AbsolutePath CliCoreDir => TempDirectory / "hactoolnet_net5.0";
|
||||||
AbsolutePath CliNativeDir => TempDirectory / $"hactoolnet_{HostOsName}";
|
AbsolutePath CliNativeDir => TempDirectory / $"hactoolnet_{HostOsName}";
|
||||||
AbsolutePath CliNativeExe => CliNativeDir / $"hactoolnet{NativeProgramExtension}";
|
AbsolutePath CliNativeExe => CliNativeDir / $"hactoolnet{NativeProgramExtension}";
|
||||||
AbsolutePath CliCoreZip => ArtifactsDirectory / $"hactoolnet-{VersionString}-netcore.zip";
|
AbsolutePath CliCoreZip => ArtifactsDirectory / $"hactoolnet-{VersionString}-netcore.zip";
|
||||||
|
@ -221,7 +220,7 @@ namespace LibHacBuild
|
||||||
|
|
||||||
DotNetPublish(s => publishSettings
|
DotNetPublish(s => publishSettings
|
||||||
.SetProject(HactoolnetProject)
|
.SetProject(HactoolnetProject)
|
||||||
.SetFramework("netcoreapp3.1")
|
.SetFramework("net5.0")
|
||||||
.SetOutput(CliCoreDir)
|
.SetOutput(CliCoreDir)
|
||||||
.SetNoBuild(true)
|
.SetNoBuild(true)
|
||||||
.SetProperties(VersionProps));
|
.SetProperties(VersionProps));
|
||||||
|
@ -273,7 +272,7 @@ namespace LibHacBuild
|
||||||
.EnableNoBuild()
|
.EnableNoBuild()
|
||||||
.SetConfiguration(Configuration);
|
.SetConfiguration(Configuration);
|
||||||
|
|
||||||
if (EnvironmentInfo.IsUnix) settings = settings.SetProperty("TargetFramework", "netcoreapp3.1");
|
if (EnvironmentInfo.IsUnix) settings = settings.SetProperty("TargetFramework", "net5.0");
|
||||||
|
|
||||||
DotNetTest(s => settings);
|
DotNetTest(s => settings);
|
||||||
});
|
});
|
||||||
|
@ -366,7 +365,6 @@ namespace LibHacBuild
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[SuppressMessage("ReSharper", "PossibleNullReferenceException")]
|
|
||||||
public void BuildNative()
|
public void BuildNative()
|
||||||
{
|
{
|
||||||
string buildType = Untrimmed ? "native-untrimmed" : "native";
|
string buildType = Untrimmed ? "native-untrimmed" : "native";
|
||||||
|
@ -614,7 +612,7 @@ namespace LibHacBuild
|
||||||
SignAssemblies(password, toSign.Select(x => x.ToString()).ToArray());
|
SignAssemblies(password, toSign.Select(x => x.ToString()).ToArray());
|
||||||
|
|
||||||
// Avoid having multiple signed versions of the same file
|
// Avoid having multiple signed versions of the same file
|
||||||
File.Copy(nupkgDir / "lib" / "netcoreapp3.0" / "LibHac.dll", coreFxDir / "LibHac.dll", true);
|
File.Copy(nupkgDir / "lib" / "net5.0" / "LibHac.dll", coreFxDir / "LibHac.dll", true);
|
||||||
|
|
||||||
ZipDirectory(SignedArtifactsDirectory / Path.GetFileName(nupkgFile), nupkgDir, pkgFileList);
|
ZipDirectory(SignedArtifactsDirectory / Path.GetFileName(nupkgFile), nupkgDir, pkgFileList);
|
||||||
ZipDirectory(SignedArtifactsDirectory / Path.GetFileName(CliCoreZip), coreFxDir);
|
ZipDirectory(SignedArtifactsDirectory / Path.GetFileName(CliCoreZip), coreFxDir);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||||
<RootNamespace>LibHacBuild.CodeGen</RootNamespace>
|
<RootNamespace>LibHacBuild.CodeGen</RootNamespace>
|
||||||
<IsPackable>False</IsPackable>
|
<IsPackable>False</IsPackable>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||||
<RootNamespace>LibHacBuild</RootNamespace>
|
<RootNamespace>LibHacBuild</RootNamespace>
|
||||||
<IsPackable>False</IsPackable>
|
<IsPackable>False</IsPackable>
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
// ReSharper disable AssignmentIsFullyDiscarded
|
// ReSharper disable AssignmentIsFullyDiscarded
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using LibHac.Diag;
|
|
||||||
#if HAS_INTRINSICS
|
|
||||||
using LibHac.Crypto.Detail;
|
using LibHac.Crypto.Detail;
|
||||||
|
using LibHac.Diag;
|
||||||
|
|
||||||
using AesNi = System.Runtime.Intrinsics.X86.Aes;
|
using AesNi = System.Runtime.Intrinsics.X86.Aes;
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace LibHac.Crypto
|
namespace LibHac.Crypto
|
||||||
{
|
{
|
||||||
|
@ -17,108 +15,95 @@ namespace LibHac.Crypto
|
||||||
|
|
||||||
public static bool IsAesNiSupported()
|
public static bool IsAesNiSupported()
|
||||||
{
|
{
|
||||||
#if HAS_INTRINSICS
|
|
||||||
return AesNi.IsSupported;
|
return AesNi.IsSupported;
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICipher CreateEcbDecryptor(ReadOnlySpan<byte> key, bool preferDotNetCrypto = false)
|
public static ICipher CreateEcbDecryptor(ReadOnlySpan<byte> key, bool preferDotNetCrypto = false)
|
||||||
{
|
{
|
||||||
#if HAS_INTRINSICS
|
|
||||||
if (IsAesNiSupported() && !preferDotNetCrypto)
|
if (IsAesNiSupported() && !preferDotNetCrypto)
|
||||||
{
|
{
|
||||||
return new AesEcbDecryptorNi(key);
|
return new AesEcbDecryptorNi(key);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return new AesEcbDecryptor(key);
|
return new AesEcbDecryptor(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICipher CreateEcbEncryptor(ReadOnlySpan<byte> key, bool preferDotNetCrypto = false)
|
public static ICipher CreateEcbEncryptor(ReadOnlySpan<byte> key, bool preferDotNetCrypto = false)
|
||||||
{
|
{
|
||||||
#if HAS_INTRINSICS
|
|
||||||
if (IsAesNiSupported() && !preferDotNetCrypto)
|
if (IsAesNiSupported() && !preferDotNetCrypto)
|
||||||
{
|
{
|
||||||
return new AesEcbEncryptorNi(key);
|
return new AesEcbEncryptorNi(key);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return new AesEcbEncryptor(key);
|
return new AesEcbEncryptor(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICipher CreateCbcDecryptor(ReadOnlySpan<byte> key, ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
public static ICipher CreateCbcDecryptor(ReadOnlySpan<byte> key, ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
||||||
{
|
{
|
||||||
#if HAS_INTRINSICS
|
|
||||||
if (IsAesNiSupported() && !preferDotNetCrypto)
|
if (IsAesNiSupported() && !preferDotNetCrypto)
|
||||||
{
|
{
|
||||||
return new AesCbcDecryptorNi(key, iv);
|
return new AesCbcDecryptorNi(key, iv);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return new AesCbcDecryptor(key, iv);
|
return new AesCbcDecryptor(key, iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICipher CreateCbcEncryptor(ReadOnlySpan<byte> key, ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
public static ICipher CreateCbcEncryptor(ReadOnlySpan<byte> key, ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
||||||
{
|
{
|
||||||
#if HAS_INTRINSICS
|
|
||||||
if (IsAesNiSupported() && !preferDotNetCrypto)
|
if (IsAesNiSupported() && !preferDotNetCrypto)
|
||||||
{
|
{
|
||||||
return new AesCbcEncryptorNi(key, iv);
|
return new AesCbcEncryptorNi(key, iv);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return new AesCbcEncryptor(key, iv);
|
return new AesCbcEncryptor(key, iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICipherWithIv CreateCtrDecryptor(ReadOnlySpan<byte> key, ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
public static ICipherWithIv CreateCtrDecryptor(ReadOnlySpan<byte> key, ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
||||||
{
|
{
|
||||||
#if HAS_INTRINSICS
|
|
||||||
if (IsAesNiSupported() && !preferDotNetCrypto)
|
if (IsAesNiSupported() && !preferDotNetCrypto)
|
||||||
{
|
{
|
||||||
return new AesCtrCipherNi(key, iv);
|
return new AesCtrCipherNi(key, iv);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
// Encryption and decryption in counter mode is the same operation
|
// Encryption and decryption in counter mode is the same operation
|
||||||
return CreateCtrEncryptor(key, iv, preferDotNetCrypto);
|
return CreateCtrEncryptor(key, iv, preferDotNetCrypto);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICipherWithIv CreateCtrEncryptor(ReadOnlySpan<byte> key, ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
public static ICipherWithIv CreateCtrEncryptor(ReadOnlySpan<byte> key, ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
||||||
{
|
{
|
||||||
#if HAS_INTRINSICS
|
|
||||||
if (IsAesNiSupported() && !preferDotNetCrypto)
|
if (IsAesNiSupported() && !preferDotNetCrypto)
|
||||||
{
|
{
|
||||||
return new AesCtrCipherNi(key, iv);
|
return new AesCtrCipherNi(key, iv);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return new AesCtrCipher(key, iv);
|
return new AesCtrCipher(key, iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICipherWithIv CreateXtsDecryptor(ReadOnlySpan<byte> key1, ReadOnlySpan<byte> key2,
|
public static ICipherWithIv CreateXtsDecryptor(ReadOnlySpan<byte> key1, ReadOnlySpan<byte> key2,
|
||||||
ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
||||||
{
|
{
|
||||||
#if HAS_INTRINSICS
|
|
||||||
if (IsAesNiSupported() && !preferDotNetCrypto)
|
if (IsAesNiSupported() && !preferDotNetCrypto)
|
||||||
{
|
{
|
||||||
return new AesXtsDecryptorNi(key1, key2, iv);
|
return new AesXtsDecryptorNi(key1, key2, iv);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return new AesXtsDecryptor(key1, key2, iv);
|
return new AesXtsDecryptor(key1, key2, iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICipherWithIv CreateXtsEncryptor(ReadOnlySpan<byte> key1, ReadOnlySpan<byte> key2,
|
public static ICipherWithIv CreateXtsEncryptor(ReadOnlySpan<byte> key1, ReadOnlySpan<byte> key2,
|
||||||
ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
||||||
{
|
{
|
||||||
#if HAS_INTRINSICS
|
|
||||||
if (IsAesNiSupported() && !preferDotNetCrypto)
|
if (IsAesNiSupported() && !preferDotNetCrypto)
|
||||||
{
|
{
|
||||||
return new AesXtsEncryptorNi(key1, key2, iv);
|
return new AesXtsEncryptorNi(key1, key2, iv);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return new AesXtsEncryptor(key1, key2, iv);
|
return new AesXtsEncryptor(key1, key2, iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void EncryptEcb128(ReadOnlySpan<byte> input, Span<byte> output, ReadOnlySpan<byte> key,
|
public static void EncryptEcb128(ReadOnlySpan<byte> input, Span<byte> output, ReadOnlySpan<byte> key,
|
||||||
bool preferDotNetCrypto = false)
|
bool preferDotNetCrypto = false)
|
||||||
{
|
{
|
||||||
#if HAS_INTRINSICS
|
|
||||||
if (IsAesNiSupported() && !preferDotNetCrypto)
|
if (IsAesNiSupported() && !preferDotNetCrypto)
|
||||||
{
|
{
|
||||||
AesEcbModeNi cipherNi;
|
AesEcbModeNi cipherNi;
|
||||||
|
@ -128,7 +113,7 @@ namespace LibHac.Crypto
|
||||||
cipherNi.Encrypt(input, output);
|
cipherNi.Encrypt(input, output);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
ICipher cipher = CreateEcbEncryptor(key, preferDotNetCrypto);
|
ICipher cipher = CreateEcbEncryptor(key, preferDotNetCrypto);
|
||||||
|
|
||||||
cipher.Transform(input, output);
|
cipher.Transform(input, output);
|
||||||
|
@ -138,7 +123,6 @@ namespace LibHac.Crypto
|
||||||
public static void DecryptEcb128(ReadOnlySpan<byte> input, Span<byte> output, ReadOnlySpan<byte> key,
|
public static void DecryptEcb128(ReadOnlySpan<byte> input, Span<byte> output, ReadOnlySpan<byte> key,
|
||||||
bool preferDotNetCrypto = false)
|
bool preferDotNetCrypto = false)
|
||||||
{
|
{
|
||||||
#if HAS_INTRINSICS
|
|
||||||
if (IsAesNiSupported() && !preferDotNetCrypto)
|
if (IsAesNiSupported() && !preferDotNetCrypto)
|
||||||
{
|
{
|
||||||
AesEcbModeNi cipherNi;
|
AesEcbModeNi cipherNi;
|
||||||
|
@ -148,7 +132,7 @@ namespace LibHac.Crypto
|
||||||
cipherNi.Decrypt(input, output);
|
cipherNi.Decrypt(input, output);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
ICipher cipher = CreateEcbDecryptor(key, preferDotNetCrypto);
|
ICipher cipher = CreateEcbDecryptor(key, preferDotNetCrypto);
|
||||||
|
|
||||||
cipher.Transform(input, output);
|
cipher.Transform(input, output);
|
||||||
|
@ -157,7 +141,6 @@ namespace LibHac.Crypto
|
||||||
public static void EncryptCbc128(ReadOnlySpan<byte> input, Span<byte> output, ReadOnlySpan<byte> key,
|
public static void EncryptCbc128(ReadOnlySpan<byte> input, Span<byte> output, ReadOnlySpan<byte> key,
|
||||||
ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
||||||
{
|
{
|
||||||
#if HAS_INTRINSICS
|
|
||||||
if (IsAesNiSupported() && !preferDotNetCrypto)
|
if (IsAesNiSupported() && !preferDotNetCrypto)
|
||||||
{
|
{
|
||||||
AesCbcModeNi cipherNi;
|
AesCbcModeNi cipherNi;
|
||||||
|
@ -167,7 +150,7 @@ namespace LibHac.Crypto
|
||||||
cipherNi.Encrypt(input, output);
|
cipherNi.Encrypt(input, output);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
ICipher cipher = CreateCbcEncryptor(key, iv, preferDotNetCrypto);
|
ICipher cipher = CreateCbcEncryptor(key, iv, preferDotNetCrypto);
|
||||||
|
|
||||||
cipher.Transform(input, output);
|
cipher.Transform(input, output);
|
||||||
|
@ -176,7 +159,6 @@ namespace LibHac.Crypto
|
||||||
public static void DecryptCbc128(ReadOnlySpan<byte> input, Span<byte> output, ReadOnlySpan<byte> key,
|
public static void DecryptCbc128(ReadOnlySpan<byte> input, Span<byte> output, ReadOnlySpan<byte> key,
|
||||||
ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
||||||
{
|
{
|
||||||
#if HAS_INTRINSICS
|
|
||||||
if (IsAesNiSupported() && !preferDotNetCrypto)
|
if (IsAesNiSupported() && !preferDotNetCrypto)
|
||||||
{
|
{
|
||||||
AesCbcModeNi cipherNi;
|
AesCbcModeNi cipherNi;
|
||||||
|
@ -186,7 +168,7 @@ namespace LibHac.Crypto
|
||||||
cipherNi.Decrypt(input, output);
|
cipherNi.Decrypt(input, output);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
ICipher cipher = CreateCbcDecryptor(key, iv, preferDotNetCrypto);
|
ICipher cipher = CreateCbcDecryptor(key, iv, preferDotNetCrypto);
|
||||||
|
|
||||||
cipher.Transform(input, output);
|
cipher.Transform(input, output);
|
||||||
|
@ -195,7 +177,6 @@ namespace LibHac.Crypto
|
||||||
public static void EncryptCtr128(ReadOnlySpan<byte> input, Span<byte> output, ReadOnlySpan<byte> key,
|
public static void EncryptCtr128(ReadOnlySpan<byte> input, Span<byte> output, ReadOnlySpan<byte> key,
|
||||||
ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
||||||
{
|
{
|
||||||
#if HAS_INTRINSICS
|
|
||||||
if (IsAesNiSupported() && !preferDotNetCrypto)
|
if (IsAesNiSupported() && !preferDotNetCrypto)
|
||||||
{
|
{
|
||||||
AesCtrModeNi cipherNi;
|
AesCtrModeNi cipherNi;
|
||||||
|
@ -205,7 +186,7 @@ namespace LibHac.Crypto
|
||||||
cipherNi.Transform(input, output);
|
cipherNi.Transform(input, output);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
ICipher cipher = CreateCtrEncryptor(key, iv, preferDotNetCrypto);
|
ICipher cipher = CreateCtrEncryptor(key, iv, preferDotNetCrypto);
|
||||||
|
|
||||||
cipher.Transform(input, output);
|
cipher.Transform(input, output);
|
||||||
|
@ -214,7 +195,6 @@ namespace LibHac.Crypto
|
||||||
public static void DecryptCtr128(ReadOnlySpan<byte> input, Span<byte> output, ReadOnlySpan<byte> key,
|
public static void DecryptCtr128(ReadOnlySpan<byte> input, Span<byte> output, ReadOnlySpan<byte> key,
|
||||||
ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
||||||
{
|
{
|
||||||
#if HAS_INTRINSICS
|
|
||||||
if (IsAesNiSupported() && !preferDotNetCrypto)
|
if (IsAesNiSupported() && !preferDotNetCrypto)
|
||||||
{
|
{
|
||||||
AesCtrModeNi cipherNi;
|
AesCtrModeNi cipherNi;
|
||||||
|
@ -224,7 +204,7 @@ namespace LibHac.Crypto
|
||||||
cipherNi.Transform(input, output);
|
cipherNi.Transform(input, output);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
ICipher cipher = CreateCtrDecryptor(key, iv, preferDotNetCrypto);
|
ICipher cipher = CreateCtrDecryptor(key, iv, preferDotNetCrypto);
|
||||||
|
|
||||||
cipher.Transform(input, output);
|
cipher.Transform(input, output);
|
||||||
|
@ -233,7 +213,6 @@ namespace LibHac.Crypto
|
||||||
public static void EncryptXts128(ReadOnlySpan<byte> input, Span<byte> output, ReadOnlySpan<byte> key1,
|
public static void EncryptXts128(ReadOnlySpan<byte> input, Span<byte> output, ReadOnlySpan<byte> key1,
|
||||||
ReadOnlySpan<byte> key2, ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
ReadOnlySpan<byte> key2, ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
||||||
{
|
{
|
||||||
#if HAS_INTRINSICS
|
|
||||||
if (IsAesNiSupported() && !preferDotNetCrypto)
|
if (IsAesNiSupported() && !preferDotNetCrypto)
|
||||||
{
|
{
|
||||||
AesXtsModeNi cipherNi;
|
AesXtsModeNi cipherNi;
|
||||||
|
@ -243,7 +222,7 @@ namespace LibHac.Crypto
|
||||||
cipherNi.Encrypt(input, output);
|
cipherNi.Encrypt(input, output);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
ICipher cipher = CreateXtsEncryptor(key1, key2, iv, preferDotNetCrypto);
|
ICipher cipher = CreateXtsEncryptor(key1, key2, iv, preferDotNetCrypto);
|
||||||
|
|
||||||
cipher.Transform(input, output);
|
cipher.Transform(input, output);
|
||||||
|
@ -252,7 +231,6 @@ namespace LibHac.Crypto
|
||||||
public static void DecryptXts128(ReadOnlySpan<byte> input, Span<byte> output, ReadOnlySpan<byte> key1,
|
public static void DecryptXts128(ReadOnlySpan<byte> input, Span<byte> output, ReadOnlySpan<byte> key1,
|
||||||
ReadOnlySpan<byte> key2, ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
ReadOnlySpan<byte> key2, ReadOnlySpan<byte> iv, bool preferDotNetCrypto = false)
|
||||||
{
|
{
|
||||||
#if HAS_INTRINSICS
|
|
||||||
if (IsAesNiSupported() && !preferDotNetCrypto)
|
if (IsAesNiSupported() && !preferDotNetCrypto)
|
||||||
{
|
{
|
||||||
AesXtsModeNi cipherNi;
|
AesXtsModeNi cipherNi;
|
||||||
|
@ -262,7 +240,7 @@ namespace LibHac.Crypto
|
||||||
cipherNi.Decrypt(input, output);
|
cipherNi.Decrypt(input, output);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
ICipher cipher = CreateXtsDecryptor(key1, key2, iv, preferDotNetCrypto);
|
ICipher cipher = CreateXtsDecryptor(key1, key2, iv, preferDotNetCrypto);
|
||||||
|
|
||||||
cipher.Transform(input, output);
|
cipher.Transform(input, output);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#if HAS_INTRINSICS
|
using System;
|
||||||
using System;
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.Intrinsics;
|
using System.Runtime.Intrinsics;
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
|
@ -12,7 +11,7 @@ namespace LibHac.Crypto
|
||||||
private AesCbcModeNi _baseCipher;
|
private AesCbcModeNi _baseCipher;
|
||||||
|
|
||||||
public ref Buffer16 Iv => ref Unsafe.As<Vector128<byte>, Buffer16>(ref _baseCipher.Iv);
|
public ref Buffer16 Iv => ref Unsafe.As<Vector128<byte>, Buffer16>(ref _baseCipher.Iv);
|
||||||
|
|
||||||
public AesCbcEncryptorNi(ReadOnlySpan<byte> key, ReadOnlySpan<byte> iv)
|
public AesCbcEncryptorNi(ReadOnlySpan<byte> key, ReadOnlySpan<byte> iv)
|
||||||
{
|
{
|
||||||
_baseCipher = new AesCbcModeNi();
|
_baseCipher = new AesCbcModeNi();
|
||||||
|
@ -43,4 +42,3 @@ namespace LibHac.Crypto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
|
@ -1,5 +1,4 @@
|
||||||
#if HAS_INTRINSICS
|
using System;
|
||||||
using System;
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.Intrinsics;
|
using System.Runtime.Intrinsics;
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
|
@ -25,4 +24,3 @@ namespace LibHac.Crypto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#if HAS_INTRINSICS
|
using System;
|
||||||
using System;
|
|
||||||
using LibHac.Crypto.Detail;
|
using LibHac.Crypto.Detail;
|
||||||
|
|
||||||
namespace LibHac.Crypto
|
namespace LibHac.Crypto
|
||||||
|
@ -36,4 +35,3 @@ namespace LibHac.Crypto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#if HAS_INTRINSICS
|
using System;
|
||||||
using System;
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.Intrinsics;
|
using System.Runtime.Intrinsics;
|
||||||
using LibHac.Common;
|
using LibHac.Common;
|
||||||
|
@ -43,4 +42,3 @@ namespace LibHac.Crypto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#if HAS_INTRINSICS
|
using System;
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
@ -10,9 +9,7 @@ namespace LibHac.Crypto.Detail
|
||||||
{
|
{
|
||||||
public struct AesCbcModeNi
|
public struct AesCbcModeNi
|
||||||
{
|
{
|
||||||
#pragma warning disable 649
|
|
||||||
private AesCoreNi _aesCore;
|
private AesCoreNi _aesCore;
|
||||||
#pragma warning restore 649
|
|
||||||
|
|
||||||
public Vector128<byte> Iv;
|
public Vector128<byte> Iv;
|
||||||
|
|
||||||
|
@ -110,4 +107,3 @@ namespace LibHac.Crypto.Detail
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#if HAS_INTRINSICS
|
using System;
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
@ -578,4 +577,3 @@ namespace LibHac.Crypto.Detail
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#if HAS_INTRINSICS
|
using System;
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
@ -10,9 +9,7 @@ namespace LibHac.Crypto.Detail
|
||||||
{
|
{
|
||||||
public struct AesCtrModeNi
|
public struct AesCtrModeNi
|
||||||
{
|
{
|
||||||
#pragma warning disable 649
|
|
||||||
private AesCoreNi _aesCore;
|
private AesCoreNi _aesCore;
|
||||||
#pragma warning restore 649
|
|
||||||
|
|
||||||
public Vector128<byte> Iv;
|
public Vector128<byte> Iv;
|
||||||
|
|
||||||
|
@ -126,4 +123,3 @@ namespace LibHac.Crypto.Detail
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
#if HAS_INTRINSICS
|
using System;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace LibHac.Crypto.Detail
|
namespace LibHac.Crypto.Detail
|
||||||
{
|
{
|
||||||
public struct AesEcbModeNi
|
public struct AesEcbModeNi
|
||||||
{
|
{
|
||||||
#pragma warning disable 649
|
|
||||||
private AesCoreNi _aesCore;
|
private AesCoreNi _aesCore;
|
||||||
#pragma warning restore 649
|
|
||||||
|
|
||||||
public void Initialize(ReadOnlySpan<byte> key, bool isDecrypting)
|
public void Initialize(ReadOnlySpan<byte> key, bool isDecrypting)
|
||||||
{
|
{
|
||||||
|
@ -25,4 +22,3 @@ namespace LibHac.Crypto.Detail
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#if HAS_INTRINSICS
|
using System;
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
@ -11,10 +10,8 @@ namespace LibHac.Crypto.Detail
|
||||||
{
|
{
|
||||||
public struct AesXtsModeNi
|
public struct AesXtsModeNi
|
||||||
{
|
{
|
||||||
#pragma warning disable 649
|
|
||||||
private AesCoreNi _dataAesCore;
|
private AesCoreNi _dataAesCore;
|
||||||
private AesCoreNi _tweakAesCore;
|
private AesCoreNi _tweakAesCore;
|
||||||
#pragma warning restore 649
|
|
||||||
|
|
||||||
public Vector128<byte> Iv;
|
public Vector128<byte> Iv;
|
||||||
|
|
||||||
|
@ -256,4 +253,3 @@ namespace LibHac.Crypto.Detail
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<VersionPrefix>0.12.0</VersionPrefix>
|
<VersionPrefix>0.12.0</VersionPrefix>
|
||||||
<TargetFrameworks>netcoreapp3.0;netstandard2.1</TargetFrameworks>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<LangVersion>8.0</LangVersion>
|
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -27,17 +26,9 @@
|
||||||
<PathMap Condition=" '$(BuildType)' == 'Release' and '$(HasGitDir)' == 'false' ">$(MSBuildProjectDirectory)=C:/LibHac/</PathMap>
|
<PathMap Condition=" '$(BuildType)' == 'Release' and '$(HasGitDir)' == 'false' ">$(MSBuildProjectDirectory)=C:/LibHac/</PathMap>
|
||||||
<DeterministicSourcePaths Condition=" '$(BuildType)' == 'Release' and '$(HasGitDir)' == 'true' ">true</DeterministicSourcePaths>
|
<DeterministicSourcePaths Condition=" '$(BuildType)' == 'Release' and '$(HasGitDir)' == 'true' ">true</DeterministicSourcePaths>
|
||||||
|
|
||||||
<NoWarn>$(NoWarn);1591;NU5105</NoWarn>
|
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
|
|
||||||
<DefineConstants>$(DefineConstants);HAS_INTRINSICS</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
|
|
||||||
<PackageReference Include="System.Memory" Version="4.5.3" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Condition="Exists('ResultNameResolver.Generated.cs')" Remove="ResultNameResolver.Archive.cs" />
|
<Compile Condition="Exists('ResultNameResolver.Generated.cs')" Remove="ResultNameResolver.Archive.cs" />
|
||||||
<Compile Condition="Exists('Common\Keys\DefaultKeySet.Generated.cs')" Remove="Common\Keys\DefaultKeySet.Empty.cs" />
|
<Compile Condition="Exists('Common\Keys\DefaultKeySet.Generated.cs')" Remove="Common\Keys\DefaultKeySet.Empty.cs" />
|
||||||
|
@ -45,7 +36,6 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
||||||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -16,11 +16,8 @@ namespace hactoolnet
|
||||||
{
|
{
|
||||||
if (Run(args))
|
if (Run(args))
|
||||||
{
|
{
|
||||||
// Console.ReadKey();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (MissingKeyException ex)
|
catch (MissingKeyException ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<LangVersion>8.0</LangVersion>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
Loading…
Reference in a new issue