Skip to content

Commit

Permalink
Modernize NDecrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
mnadareski committed Jul 21, 2024
1 parent e2c2c80 commit 2df30d0
Show file tree
Hide file tree
Showing 48 changed files with 852 additions and 994 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/build_program.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build Program

on:
push:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
project: [NDecrypt]
runtime: [win-x86, win-x64, win-arm64, linux-x64, linux-arm64, osx-x64]
framework: [net8.0] #[net20, net35, net40, net452, net472, net48, netcoreapp3.1, net5.0, net6.0, net7.0, net8.0]
conf: [Release, Debug]

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c ${{ matrix.conf == 'Release' && 'Release -p:DebugType=None -p:DebugSymbols=false' || 'Debug'}} --self-contained true --version-suffix ${{ github.sha }} ${{ (startsWith(matrix.framework, 'net5') || startsWith(matrix.framework, 'net6') || startsWith(matrix.framework, 'net7') || startsWith(matrix.framework, 'net8')) && '-p:PublishSingleFile=true' || ''}}

- name: Archive build
run: zip -r ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }}.zip ${{ matrix.project }}/bin/${{ matrix.conf }}/${{ matrix.framework }}/${{ matrix.runtime }}/publish/

- name: Upload build
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }}
path: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }}.zip

- name: Upload to rolling
uses: ncipollo/[email protected]
with:
allowUpdates: True
artifacts: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }}.zip
body: 'Last built commit: ${{ github.sha }}'
name: 'Rolling Release'
prerelease: True
replacesArtifacts: True
tag: "rolling"
updateOnlyUnreleased: True
17 changes: 17 additions & 0 deletions .github/workflows/check_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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: 8.0.x

- name: Build
run: dotnet build
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2018-2023 Matt Nadareski
Copyright (c) 2018-2024 Matt Nadareski

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
16 changes: 8 additions & 8 deletions NDecrypt.Core/DecryptArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.IO;
using System.Linq;
using System.Numerics;
using NDecrypt.Core.Tools;
using SabreTools.IO.Readers;

namespace NDecrypt.Core
{
Expand Down Expand Up @@ -37,7 +37,7 @@ public class DecryptArgs
/// <summary>
/// Path to the keyfile [3DS only]
/// </summary>
public string KeyFile { get; set; }
public string? KeyFile { get; set; }

/// <summary>
/// Flag to indicate keyfile format to use [3DS only]
Expand Down Expand Up @@ -119,17 +119,17 @@ public void Initialize()
/// Setup all of the necessary constants from aes_keys.txt
/// </summary>
/// <param name="keyfile">Path to aes_keys.txt</param>
private void InitAesKeysTxt(string keyfile)
private void InitAesKeysTxt(string? keyfile)
{
if (!File.Exists(keyfile))
if (keyfile == null || !File.Exists(keyfile))
{
IsReady = false;
return;
}

try
{
using (IniReader reader = new IniReader(keyfile))
using (var reader = new IniReader(keyfile))
{
// This is required to preserve sign for BigInteger
byte[] signByte = new byte[] { 0x00 };
Expand All @@ -142,7 +142,7 @@ private void InitAesKeysTxt(string keyfile)
if (reader.KeyValuePair == null || string.IsNullOrWhiteSpace(reader.KeyValuePair?.Key))
break;

var kvp = reader.KeyValuePair.Value;
var kvp = reader.KeyValuePair!.Value;
byte[] value = StringToByteArray(kvp.Value).Reverse().ToArray();
byte[] valueWithSign = value.Concat(signByte).ToArray();

Expand Down Expand Up @@ -240,9 +240,9 @@ private void InitAesKeysTxt(string keyfile)
/// </summary>
/// <param name="keyfile">Path to keys.bin</param>
/// <remarks>keys.bin should be in little endian format</remarks>
private void InitKeysBin(string keyfile)
private void InitKeysBin(string? keyfile)
{
if (!File.Exists(keyfile))
if (keyfile == null || !File.Exists(keyfile))
{
IsReady = false;
return;
Expand Down
49 changes: 41 additions & 8 deletions NDecrypt.Core/NDecrypt.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,54 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net48;net6.0</TargetFrameworks>
<!-- Assembly Properties -->
<TargetFrameworks>net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<VersionPrefix>0.2.5</VersionPrefix>

<!-- Package Properties -->
<Authors>Matt Nadareski</Authors>
<Copyright>Copyright (c)2018-2023 Matt Nadareski</Copyright>
<Description>Common code for all NDecrypt processors</Description>
<Copyright>Copyright (c) Matt Nadareski 2019-2024</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/SabreTools/</PackageProjectUrl>
<RepositoryUrl>https://github.com/SabreTools/NDecrypt</RepositoryUrl>
<Version>0.2.5</Version>
<AssemblyVersion>$(Version)</AssemblyVersion>
<FileVersion>$(Version)</FileVersion>
<IncludeSource>true</IncludeSource>
<IncludeSymbols>true</IncludeSymbols>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RepositoryType>git</RepositoryType>
</PropertyGroup>

<!-- Support All Frameworks -->
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net4`))">
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith(`netcoreapp`)) OR $(TargetFramework.StartsWith(`net5`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith(`osx-arm`))">
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>

<!-- Support for old .NET versions -->
<ItemGroup Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net40`))">
<PackageReference Include="MinAsyncBridge" Version="0.12.4" />
<PackageReference Include="MinTasksExtensionsBridge" Version="0.3.4" />
<PackageReference Include="MinThreadingBridge" Version="0.11.4" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith(`net4`)) AND !$(TargetFramework.StartsWith(`net40`))">
<PackageReference Include="IndexRange" Version="1.0.3" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="BouncyCastle.NetCore" Version="1.9.0" />
<PackageReference Include="SabreTools.Hashing" Version="1.2.1" />
<PackageReference Include="SabreTools.IO" Version="1.4.11" />
</ItemGroup>

</Project>
36 changes: 0 additions & 36 deletions NDecrypt.Core/Tools/Enums.cs

This file was deleted.

123 changes: 0 additions & 123 deletions NDecrypt.Core/Tools/Hasher.cs

This file was deleted.

Loading

0 comments on commit 2df30d0

Please sign in to comment.