diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index c6dfdf7..1eca5c3 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -1,48 +1,48 @@ name: Build and Test on: - push: - branches: [ "master" ] + push: + branches: ["master"] jobs: - build: - runs-on: ubuntu-latest + build: + runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: | - 6.0.x - 8.0.x - 9.0.x - - - name: Run tests - run: dotnet test - - - name: Run publish script - run: ./publish-nix.sh -d + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 - - name: Update rolling tag - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git tag -f rolling - git push origin :refs/tags/rolling || true - git push origin rolling --force + - name: Setup .NET + uses: actions/setup-dotnet@v5 + with: + dotnet-version: | + 8.0.x + 9.0.x + 10.0.x - - name: Upload to rolling - uses: ncipollo/release-action@v1.14.0 - with: - allowUpdates: True - artifacts: "*.nupkg,*.snupkg,*.zip" - body: 'Last built commit: ${{ github.sha }}' - name: 'Rolling Release' - prerelease: True - replacesArtifacts: True - tag: "rolling" - updateOnlyUnreleased: True + - name: Run tests + run: dotnet test + + - name: Run publish script + run: ./publish-nix.sh -d + + - name: Update rolling tag + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag -f rolling + git push origin :refs/tags/rolling || true + git push origin rolling --force + + - name: Upload to rolling + uses: ncipollo/release-action@v1.20.0 + with: + allowUpdates: True + artifacts: "*.nupkg,*.snupkg,*.zip" + body: "Last built commit: ${{ github.sha }}" + name: "Rolling Release" + prerelease: True + replacesArtifacts: True + tag: "rolling" + updateOnlyUnreleased: True diff --git a/.github/workflows/check_pr.yml b/.github/workflows/check_pr.yml index ade4ae2..a50ffba 100644 --- a/.github/workflows/check_pr.yml +++ b/.github/workflows/check_pr.yml @@ -3,18 +3,18 @@ name: Build PR on: [pull_request] jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: | - 6.0.x - 8.0.x - 9.0.x - - - name: Build - run: dotnet build \ No newline at end of file + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + + - name: Setup .NET + uses: actions/setup-dotnet@v5 + with: + dotnet-version: | + 8.0.x + 9.0.x + 10.0.x + + - name: Build + run: dotnet build diff --git a/.vscode/launch.json b/.vscode/launch.json index edd6a47..789aa64 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/NDecrypt/bin/Debug/net9.0/NDecrypt.dll", + "program": "${workspaceFolder}/NDecrypt/bin/Debug/net10.0/NDecrypt.dll", "args": [], "cwd": "${workspaceFolder}/NDecrypt", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console diff --git a/NDecrypt.Core/DSTool.cs b/NDecrypt.Core/DSTool.cs index cd121ff..9adf031 100644 --- a/NDecrypt.Core/DSTool.cs +++ b/NDecrypt.Core/DSTool.cs @@ -1,7 +1,9 @@ using System; using System.IO; using System.Text; +#if NETFRAMEWORK || NETSTANDARD2_0_OR_GREATER using SabreTools.IO.Extensions; +#endif using SabreTools.Serialization.Wrappers; namespace NDecrypt.Core diff --git a/NDecrypt.Core/DecryptArgs.cs b/NDecrypt.Core/DecryptArgs.cs index 34d3a2f..cc4c36b 100644 --- a/NDecrypt.Core/DecryptArgs.cs +++ b/NDecrypt.Core/DecryptArgs.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using SabreTools.Hashing; using SabreTools.IO.Encryption; using SabreTools.IO.Extensions; @@ -282,9 +283,8 @@ namespace NDecrypt.Core // NitroEncryptionData if (NitroEncryptionData.Length > 0) { - using var hasher = System.Security.Cryptography.SHA512.Create(); - byte[] actual = hasher.ComputeHash(NitroEncryptionData); - if (!actual.EqualsExactly(ExpectedNitroSha512Hash)) + byte[]? actual = HashTool.GetByteArrayHashArray(NitroEncryptionData, HashType.SHA512); + if (actual == null || !actual.EqualsExactly(ExpectedNitroSha512Hash)) { Console.WriteLine($"NitroEncryptionData invalid value, disabling..."); NitroEncryptionData = []; @@ -388,4 +388,4 @@ namespace NDecrypt.Core } } } -} \ No newline at end of file +} diff --git a/NDecrypt.Core/NDecrypt.Core.csproj b/NDecrypt.Core/NDecrypt.Core.csproj index 3891158..2cbc1c7 100644 --- a/NDecrypt.Core/NDecrypt.Core.csproj +++ b/NDecrypt.Core/NDecrypt.Core.csproj @@ -2,7 +2,7 @@ - net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0;netstandard2.0;netstandard2.1 + net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0;net10.0;netstandard2.0;netstandard2.1 false false true @@ -30,17 +30,17 @@ win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64 - + win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64 - net6.0;net7.0;net8.0;net9.0 + net6.0;net7.0;net8.0;net9.0;net10.0 - - - + + + diff --git a/NDecrypt.Core/PartitionKeys.cs b/NDecrypt.Core/PartitionKeys.cs index 89239a7..baf1279 100644 --- a/NDecrypt.Core/PartitionKeys.cs +++ b/NDecrypt.Core/PartitionKeys.cs @@ -43,7 +43,7 @@ namespace NDecrypt.Core if (args.IsReady != true) throw new InvalidOperationException($"{nameof(args)} must be initialized before use"); if (signature != null && signature.Length < 16) - throw new ArgumentOutOfRangeException($"{nameof(signature)} must be at least 16 bytes"); + throw new ArgumentOutOfRangeException(nameof(signature), $"{nameof(signature)} must be at least 16 bytes"); // Set fields for future use _decryptArgs = args; @@ -135,4 +135,4 @@ namespace NDecrypt.Core NormalKey = NormalKey.RotateLeft(87); } } -} \ No newline at end of file +} diff --git a/NDecrypt.Core/ThreeDSTool.cs b/NDecrypt.Core/ThreeDSTool.cs index c711cc5..5d8ad1d 100644 --- a/NDecrypt.Core/ThreeDSTool.cs +++ b/NDecrypt.Core/ThreeDSTool.cs @@ -273,7 +273,7 @@ namespace NDecrypt.Core cipher, reader, writer, - (string s) => Console.WriteLine($"\rPartition {index} ExeFS: Decrypting - {s}")); + s => Console.WriteLine($"\rPartition {index} ExeFS: Decrypting - {s}")); return true; } @@ -375,7 +375,7 @@ namespace NDecrypt.Core secondCipher, reader, writer, - (string s) => Console.WriteLine($"\rPartition {index} ExeFS: Decrypting - {fileHeader.FileName}...{s}")); + s => Console.WriteLine($"\rPartition {index} ExeFS: Decrypting - {fileHeader.FileName}...{s}")); } } @@ -415,7 +415,7 @@ namespace NDecrypt.Core cipher, reader, writer, - (string s) => Console.WriteLine($"\rPartition {index} RomFS: Decrypting - {s}")); + s => Console.WriteLine($"\rPartition {index} RomFS: Decrypting - {s}")); return true; } @@ -699,7 +699,7 @@ namespace NDecrypt.Core cipher, reader, writer, - (string s) => Console.WriteLine($"\rPartition {index} ExeFS: Encrypting - {s}")); + s => Console.WriteLine($"\rPartition {index} ExeFS: Encrypting - {s}")); return true; } @@ -798,7 +798,7 @@ namespace NDecrypt.Core secondCipher, reader, writer, - (string s) => Console.WriteLine($"\rPartition {index} ExeFS: Encrypting - {fileHeader.FileName}...{s}")); + s => Console.WriteLine($"\rPartition {index} ExeFS: Encrypting - {fileHeader.FileName}...{s}")); } } @@ -845,7 +845,7 @@ namespace NDecrypt.Core cipher, reader, writer, - (string s) => Console.WriteLine($"\rPartition {index} RomFS: Encrypting - {s}")); + s => Console.WriteLine($"\rPartition {index} RomFS: Encrypting - {s}")); return true; } diff --git a/NDecrypt/Enumerations.cs b/NDecrypt/Enumerations.cs index 6cde69d..25a0b54 100644 --- a/NDecrypt/Enumerations.cs +++ b/NDecrypt/Enumerations.cs @@ -12,4 +12,4 @@ namespace NDecrypt N3DS, iQue3DS, } -} \ No newline at end of file +} diff --git a/NDecrypt/Features/BaseFeature.cs b/NDecrypt/Features/BaseFeature.cs index 49c313d..f223d3c 100644 --- a/NDecrypt/Features/BaseFeature.cs +++ b/NDecrypt/Features/BaseFeature.cs @@ -125,7 +125,11 @@ namespace NDecrypt.Features // TODO: Ensure that the input and output aren't the same // If the extension does not include a leading period +#if NETCOREAPP || NETSTANDARD2_0_OR_GREATER + if (!extension.StartsWith('.')) +#else if (!extension.StartsWith(".")) +#endif extension = $".{extension}"; // Append the extension and return @@ -158,7 +162,7 @@ namespace NDecrypt.Features /// /// Filename to derive the type from /// FileType value, if possible - private FileType DetermineFileType(string filename) + private static FileType DetermineFileType(string filename) { if (filename.EndsWith(".nds", StringComparison.OrdinalIgnoreCase) // Standard carts || filename.EndsWith(".nds.dec", StringComparison.OrdinalIgnoreCase) // Carts/images with secure area decrypted @@ -191,4 +195,4 @@ namespace NDecrypt.Features return FileType.NULL; } } -} \ No newline at end of file +} diff --git a/NDecrypt/HashingHelper.cs b/NDecrypt/HashingHelper.cs index 37bbcea..94d0f09 100644 --- a/NDecrypt/HashingHelper.cs +++ b/NDecrypt/HashingHelper.cs @@ -24,10 +24,10 @@ namespace NDecrypt // Get the results return $"Size: {size}\n" - + $"CRC-32: {(hashDict.ContainsKey(HashType.CRC32) ? hashDict[HashType.CRC32] : string.Empty)}\n" - + $"MD5: {(hashDict.ContainsKey(HashType.MD5) ? hashDict[HashType.MD5] : string.Empty)}\n" - + $"SHA-1: {(hashDict.ContainsKey(HashType.SHA1) ? hashDict[HashType.SHA1] : string.Empty)}\n" - + $"SHA-256: {(hashDict.ContainsKey(HashType.SHA256) ? hashDict[HashType.SHA256] : string.Empty)}\n"; + + $"CRC-32: {(hashDict.TryGetValue(HashType.CRC32, out string? value) ? value : string.Empty)}\n" + + $"MD5: {(hashDict.TryGetValue(HashType.MD5, out string? value1) ? value1 : string.Empty)}\n" + + $"SHA-1: {(hashDict.TryGetValue(HashType.SHA1, out string? value2) ? value2 : string.Empty)}\n" + + $"SHA-256: {(hashDict.TryGetValue(HashType.SHA256, out string? value3) ? value3 : string.Empty)}\n"; } } } diff --git a/NDecrypt/NDecrypt.csproj b/NDecrypt/NDecrypt.csproj index c603464..9ffdcc2 100644 --- a/NDecrypt/NDecrypt.csproj +++ b/NDecrypt/NDecrypt.csproj @@ -2,7 +2,7 @@ - net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0 + net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0;net10.0 Exe false true @@ -31,11 +31,11 @@ win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64 - + win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64 - net6.0;net7.0;net8.0;net9.0 + net6.0;net7.0;net8.0;net9.0;net10.0 @@ -44,7 +44,7 @@ - + diff --git a/publish-nix.sh b/publish-nix.sh index de1e487..935c36f 100755 --- a/publish-nix.sh +++ b/publish-nix.sh @@ -49,18 +49,18 @@ echo " No archive (-a) $NO_ARCHIVE" echo " " # Create the build matrix arrays -FRAMEWORKS=("net9.0") +FRAMEWORKS=("net10.0") RUNTIMES=("win-x86" "win-x64" "win-arm64" "linux-x64" "linux-arm64" "osx-x64" "osx-arm64") # Use expanded lists, if requested if [ $USE_ALL = true ]; then - FRAMEWORKS=("net20" "net35" "net40" "net452" "net462" "net472" "net48" "netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0" "net9.0") + FRAMEWORKS=("net20" "net35" "net40" "net452" "net462" "net472" "net48" "netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0" "net9.0" "net10.0") fi # Create the filter arrays -SINGLE_FILE_CAPABLE=("net5.0" "net6.0" "net7.0" "net8.0" "net9.0") -VALID_APPLE_FRAMEWORKS=("net6.0" "net7.0" "net8.0" "net9.0") -VALID_CROSS_PLATFORM_FRAMEWORKS=("netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0" "net9.0") +SINGLE_FILE_CAPABLE=("net5.0" "net6.0" "net7.0" "net8.0" "net9.0" "net10.0") +VALID_APPLE_FRAMEWORKS=("net6.0" "net7.0" "net8.0" "net9.0" "net10.0") +VALID_CROSS_PLATFORM_FRAMEWORKS=("netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0" "net9.0" "net10.0") VALID_CROSS_PLATFORM_RUNTIMES=("win-arm64" "linux-x64" "linux-arm64" "osx-x64" "osx-arm64") # Only build if requested diff --git a/publish-win.ps1 b/publish-win.ps1 index e9a90a4..c8a0846 100644 --- a/publish-win.ps1 +++ b/publish-win.ps1 @@ -40,18 +40,18 @@ Write-Host " No archive (-NoArchive) $NO_ARCHIVE" Write-Host " " # Create the build matrix arrays -$FRAMEWORKS = @('net9.0') +$FRAMEWORKS = @('net10.0') $RUNTIMES = @('win-x86', 'win-x64', 'win-arm64', 'linux-x64', 'linux-arm64', 'osx-x64', 'osx-arm64') # Use expanded lists, if requested if ($USE_ALL.IsPresent) { - $FRAMEWORKS = @('net20', 'net35', 'net40', 'net452', 'net462', 'net472', 'net48', 'netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0') + $FRAMEWORKS = @('net20', 'net35', 'net40', 'net452', 'net462', 'net472', 'net48', 'netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0', 'net10.0') } # Create the filter arrays -$SINGLE_FILE_CAPABLE = @('net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0') -$VALID_APPLE_FRAMEWORKS = @('net6.0', 'net7.0', 'net8.0', 'net9.0') -$VALID_CROSS_PLATFORM_FRAMEWORKS = @('netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0') +$SINGLE_FILE_CAPABLE = @('net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0', 'net10.0') +$VALID_APPLE_FRAMEWORKS = @('net6.0', 'net7.0', 'net8.0', 'net9.0', 'net10.0') +$VALID_CROSS_PLATFORM_FRAMEWORKS = @('netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0', 'net9.0', 'net10.0') $VALID_CROSS_PLATFORM_RUNTIMES = @('win-arm64', 'linux-x64', 'linux-arm64', 'osx-x64', 'osx-arm64') # Only build if requested