22 Commits
0.2.3 ... 0.2.5

Author SHA1 Message Date
Matt Nadareski
1159b677bc Bump version to 0.2.5 2023-01-06 10:14:31 -08:00
Matt Nadareski
6527d85f29 Commit hash only 2023-01-06 10:01:23 -08:00
Matt Nadareski
ff815299fb Try using a different variable 2023-01-06 09:56:43 -08:00
Matt Nadareski
c04de5700a Use different formatting for version string 2023-01-06 09:52:38 -08:00
Matt Nadareski
ab9d32f56a Attempt to use commit hash in naming 2023-01-06 09:51:40 -08:00
Matt Nadareski
8151f306ec Experiment adding version numbers 2023-01-06 09:46:37 -08:00
Matt Nadareski
fd9b94d428 Fix artifact naming 2023-01-06 09:41:43 -08:00
Matt Nadareski
9cc2b6befe Replace assembly location 2023-01-06 09:40:52 -08:00
Matt Nadareski
8c2d4d701a Move AppVeyor script, oops 2023-01-06 09:36:31 -08:00
Matt Nadareski
593e8b2b4d Add build status to README 2023-01-06 09:33:45 -08:00
Matt Nadareski
71f3295a2b Add AppVeyor config 2023-01-06 09:32:55 -08:00
Matt Nadareski
a29071e697 Modernize NDecrypt 2023-01-06 09:31:42 -08:00
Matt Nadareski
96c3c3732c Set license properly to MIT
MIT most closely matches the statement that was included previously in the README about an extremely permissive license.
2023-01-06 09:27:41 -08:00
Matt Nadareski
c8f8a7d99c Bump version to 0.2.4 2022-10-31 10:30:52 -07:00
Matt Nadareski
3ee8c2e79b Update csproj files with full info 2022-10-31 10:27:56 -07:00
Matt Nadareski
7d263886da Force reader buffer refresh to omit stale data 2022-10-27 16:41:22 -07:00
Matt Nadareski
6d1b23ffec Be less clever in code to make debugging easier 2022-10-27 15:28:34 -07:00
Matt Nadareski
92d1c3c5e5 Split NDecrypt.Library; add build targets 2022-10-27 11:27:13 -07:00
Matt Nadareski
855a353e90 Reverse library and exe naming 2022-10-27 11:06:06 -07:00
Matt Nadareski
6dac45f973 Update BouncyCastle to 1.9.0 2022-09-27 13:35:07 -07:00
Matt Nadareski
a6337e0864 Drop .NET 5 support 2022-09-27 12:27:16 -07:00
Matt Nadareski
778d5d4ffc Fix hashing because of .NET 6 2022-09-27 12:19:53 -07:00
51 changed files with 246 additions and 161 deletions

2
.vscode/launch.json vendored
View File

@@ -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/netcoreapp3.1/NDecrypt.dll",
"program": "${workspaceFolder}/NDecrypt/bin/Debug/net6.0/NDecrypt.dll",
"args": [],
"cwd": "${workspaceFolder}/NDecrypt",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console

7
LICENSE Normal file
View File

@@ -0,0 +1,7 @@
Copyright (c) 2018-2023 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:
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,12 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net48;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\NDecrypt\NDecrypt.csproj" />
</ItemGroup>
</Project>

View File

@@ -2,9 +2,9 @@ using System;
using System.IO;
using System.Linq;
using System.Numerics;
using NDecrypt.Tools;
using NDecrypt.Core.Tools;
namespace NDecrypt
namespace NDecrypt.Core
{
public class DecryptArgs
{

View File

@@ -5,9 +5,9 @@ using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Security;
namespace NDecrypt
namespace NDecrypt.Core
{
internal static class Helper
public static class Helper
{
/// <summary>
/// Add an integer value to a number represented by a byte array

View File

@@ -1,4 +1,4 @@
namespace NDecrypt
namespace NDecrypt.Core
{
public interface ITool
{

View File

@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net48;net6.0</TargetFrameworks>
<Authors>Matt Nadareski</Authors>
<Copyright>Copyright (c)2018-2023 Matt Nadareski</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<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>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BouncyCastle.NetCore" Version="1.9.0" />
</ItemGroup>
</Project>

View File

@@ -1,6 +1,6 @@
using System;
namespace NDecrypt.Tools
namespace NDecrypt.Core.Tools
{
/// <summary>
/// Available hashing types

View File

@@ -2,7 +2,7 @@
using System.Linq;
using System.Security.Cryptography;
namespace NDecrypt.Tools
namespace NDecrypt.Core.Tools
{
/// <summary>
/// Async hashing class wraper

View File

@@ -4,7 +4,7 @@ using System.IO;
using System.Linq;
using System.Text;
namespace NDecrypt.Tools
namespace NDecrypt.Core.Tools
{
public class IniReader : IDisposable
{

View File

@@ -2,8 +2,9 @@ using System;
using System.IO;
using System.Linq;
using System.Numerics;
using NDecrypt.Core;
using NDecrypt.N3DS.Headers;
using static NDecrypt.Helper;
using static NDecrypt.Core.Helper;
namespace NDecrypt.N3DS
{

View File

@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net48;net6.0</TargetFrameworks>
<Authors>Matt Nadareski</Authors>
<Copyright>Copyright (c)2018-2023 Matt Nadareski</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<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>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\NDecrypt.Core\NDecrypt.Core.csproj" />
</ItemGroup>
</Project>

View File

@@ -2,8 +2,9 @@
using System.IO;
using System.Linq;
using System.Numerics;
using NDecrypt.Core;
using NDecrypt.N3DS.Headers;
using static NDecrypt.Helper;
using static NDecrypt.Core.Helper;
namespace NDecrypt.N3DS
{
@@ -242,7 +243,9 @@ namespace NDecrypt.N3DS
Console.WriteLine($"Partition {ncchHeader.PartitionNumber} ExeFS: " + (decryptArgs.Encrypt ? "Encrypting" : "Decrypting") + ": ExHeader");
var cipher = CreateAESCipher(ncchHeader.NormalKey2C, ncchHeader.PlainIV, decryptArgs.Encrypt);
writer.Write(cipher.ProcessBytes(reader.ReadBytes(Constants.CXTExtendedDataHeaderLength)));
byte[] readBytes = reader.ReadBytes(Constants.CXTExtendedDataHeaderLength);
byte[] processedBytes = cipher.ProcessBytes(readBytes);
writer.Write(processedBytes);
writer.Flush();
return true;
}
@@ -294,7 +297,10 @@ namespace NDecrypt.N3DS
{
for (int i = 0; i < datalenM; i++)
{
writer.Write(secondCipher.ProcessBytes(firstCipher.ProcessBytes(reader.ReadBytes(1024 * 1024))));
byte[] readBytes = reader.ReadBytes(1024 * 1024);
byte[] firstProcessedBytes = firstCipher.ProcessBytes(readBytes);
byte[] secondProcessedBytes = secondCipher.ProcessBytes(firstProcessedBytes);
writer.Write(secondProcessedBytes);
writer.Flush();
Console.Write($"\rPartition {ncchHeader.PartitionNumber} ExeFS: " + (decryptArgs.Encrypt ? "Encrypting" : "Decrypting") + $": {fileHeader.ReadableFileName}... {i} / {datalenM + 1} mb...");
}
@@ -302,7 +308,10 @@ namespace NDecrypt.N3DS
if (datalenB > 0)
{
writer.Write(secondCipher.DoFinal(firstCipher.DoFinal(reader.ReadBytes((int)datalenB))));
byte[] readBytes = reader.ReadBytes((int)datalenB);
byte[] firstFinalBytes = firstCipher.DoFinal(readBytes);
byte[] secondFinalBytes = secondCipher.DoFinal(firstFinalBytes);
writer.Write(secondFinalBytes);
writer.Flush();
}
@@ -324,8 +333,15 @@ namespace NDecrypt.N3DS
Console.WriteLine($"Partition {ncchHeader.PartitionNumber} ExeFS: " + (decryptArgs.Encrypt ? "Encrypting" : "Decrypting") + $": ExeFS Filename Table");
var exeFSFilenameTable = CreateAESCipher(ncchHeader.NormalKey2C, ncchHeader.ExeFSIV, decryptArgs.Encrypt);
writer.Write(exeFSFilenameTable.ProcessBytes(reader.ReadBytes((int)ncsdHeader.MediaUnitSize)));
var cipher = CreateAESCipher(ncchHeader.NormalKey2C, ncchHeader.ExeFSIV, decryptArgs.Encrypt);
byte[] readBytes = reader.ReadBytes((int)ncsdHeader.MediaUnitSize);
byte[] processedBytes = cipher.ProcessBytes(readBytes);
writer.Write(processedBytes);
#if NET6_0_OR_GREATER
// In .NET 6.0, this operation is not picked up by the reader, so we have to force it to reload its buffer
reader.BaseStream.Seek(0, SeekOrigin.Begin);
#endif
writer.Flush();
}
@@ -344,7 +360,7 @@ namespace NDecrypt.N3DS
byte[] exefsIVWithOffset = AddToByteArray(ncchHeader.ExeFSIV, ctroffsetE);
var exeFS = CreateAESCipher(ncchHeader.NormalKey2C, exefsIVWithOffset, decryptArgs.Encrypt);
var cipher = CreateAESCipher(ncchHeader.NormalKey2C, exefsIVWithOffset, decryptArgs.Encrypt);
reader.BaseStream.Seek((ncchHeader.Entry.Offset + ncchHeader.ExeFSOffsetInMediaUnits + 1) * ncsdHeader.MediaUnitSize, SeekOrigin.Begin);
writer.BaseStream.Seek((ncchHeader.Entry.Offset + ncchHeader.ExeFSOffsetInMediaUnits + 1) * ncsdHeader.MediaUnitSize, SeekOrigin.Begin);
@@ -352,14 +368,18 @@ namespace NDecrypt.N3DS
{
for (int i = 0; i < exefsSizeM; i++)
{
writer.Write(exeFS.ProcessBytes(reader.ReadBytes(1024 * 1024)));
byte[] readBytes = reader.ReadBytes(1024 * 1024);
byte[] processedBytes = cipher.ProcessBytes(readBytes);
writer.Write(processedBytes);
writer.Flush();
Console.Write($"\rPartition {ncchHeader.PartitionNumber} ExeFS: " + (decryptArgs.Encrypt ? "Encrypting" : "Decrypting") + $": {i} / {exefsSizeM + 1} mb");
}
}
if (exefsSizeB > 0)
{
writer.Write(exeFS.DoFinal(reader.ReadBytes(exefsSizeB)));
byte[] readBytes = reader.ReadBytes(exefsSizeB);
byte[] finalBytes = cipher.DoFinal(readBytes);
writer.Write(finalBytes);
writer.Flush();
}
@@ -425,14 +445,18 @@ namespace NDecrypt.N3DS
{
for (int i = 0; i < romfsSizeM; i++)
{
writer.Write(cipher.ProcessBytes(reader.ReadBytes(1024 * 1024)));
byte[] readBytes = reader.ReadBytes(1024 * 1024);
byte[] processedBytes = cipher.ProcessBytes(readBytes);
writer.Write(processedBytes);
writer.Flush();
Console.Write($"\rPartition {ncchHeader.PartitionNumber} RomFS: Decrypting: {i} / {romfsSizeM + 1} mb");
}
}
if (romfsSizeB > 0)
{
writer.Write(cipher.DoFinal(reader.ReadBytes(romfsSizeB)));
byte[] readBytes = reader.ReadBytes(romfsSizeB);
byte[] finalBytes = cipher.DoFinal(readBytes);
writer.Write(finalBytes);
writer.Flush();
}
@@ -534,14 +558,18 @@ namespace NDecrypt.N3DS
{
for (int i = 0; i < romfsSizeM; i++)
{
writer.Write(cipher.ProcessBytes(reader.ReadBytes(1024 * 1024)));
byte[] readBytes = reader.ReadBytes(1024 * 1024);
byte[] processedBytes = cipher.ProcessBytes(readBytes);
writer.Write(processedBytes);
writer.Flush();
Console.Write($"\rPartition {ncchHeader.PartitionNumber} RomFS: Encrypting: {i} / {romfsSizeM + 1} mb");
}
}
if (romfsSizeB > 0)
{
writer.Write(cipher.DoFinal(reader.ReadBytes(romfsSizeB)));
byte[] readBytes = reader.ReadBytes(romfsSizeB);
byte[] finalBytes = cipher.DoFinal(readBytes);
writer.Write(finalBytes);
writer.Flush();
}

View File

@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Linq;
using NDecrypt.Core;
using NDecrypt.Nitro.Headers;
namespace NDecrypt.Nitro

View File

@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net48;net6.0</TargetFrameworks>
<Authors>Matt Nadareski</Authors>
<Copyright>Copyright (c)2018-2023 Matt Nadareski</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<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>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\NDecrypt.Core\NDecrypt.Core.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,16 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.156
# Visual Studio Version 17
VisualStudioVersion = 17.3.32922.545
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{31CE0445-F693-4C9A-B6CD-499C38CFF7FE}"
ProjectSection(SolutionItems) = preProject
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDecrypt", "NDecrypt\NDecrypt.csproj", "{91C54370-5741-4742-B2E9-EC498551AD1C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NDecrypt", "NDecrypt\NDecrypt.csproj", "{05566793-831F-4AE1-A6D2-F9214F36618E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDecrypt.CMD", "NDecrypt.CMD\NDecrypt.CMD.csproj", "{05566793-831F-4AE1-A6D2-F9214F36618E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NDecrypt.Core", "NDecrypt.Core\NDecrypt.Core.csproj", "{91C54370-5741-4742-B2E9-EC498551AD1C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDecrypt.N3DS", "NDecrypt.N3DS\NDecrypt.N3DS.csproj", "{F0A33533-B248-4D62-95CC-47DFC9721A11}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDecrypt.Nitro", "NDecrypt.Nitro\NDecrypt.Nitro.csproj", "{1D2AE261-86FE-44E4-A7D3-C43AA5FB8523}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -18,14 +22,22 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{91C54370-5741-4742-B2E9-EC498551AD1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91C54370-5741-4742-B2E9-EC498551AD1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91C54370-5741-4742-B2E9-EC498551AD1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91C54370-5741-4742-B2E9-EC498551AD1C}.Release|Any CPU.Build.0 = Release|Any CPU
{05566793-831F-4AE1-A6D2-F9214F36618E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{05566793-831F-4AE1-A6D2-F9214F36618E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{05566793-831F-4AE1-A6D2-F9214F36618E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{05566793-831F-4AE1-A6D2-F9214F36618E}.Release|Any CPU.Build.0 = Release|Any CPU
{91C54370-5741-4742-B2E9-EC498551AD1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91C54370-5741-4742-B2E9-EC498551AD1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91C54370-5741-4742-B2E9-EC498551AD1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91C54370-5741-4742-B2E9-EC498551AD1C}.Release|Any CPU.Build.0 = Release|Any CPU
{F0A33533-B248-4D62-95CC-47DFC9721A11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F0A33533-B248-4D62-95CC-47DFC9721A11}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0A33533-B248-4D62-95CC-47DFC9721A11}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0A33533-B248-4D62-95CC-47DFC9721A11}.Release|Any CPU.Build.0 = Release|Any CPU
{1D2AE261-86FE-44E4-A7D3-C43AA5FB8523}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D2AE261-86FE-44E4-A7D3-C43AA5FB8523}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D2AE261-86FE-44E4-A7D3-C43AA5FB8523}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D2AE261-86FE-44E4-A7D3-C43AA5FB8523}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -3,10 +3,9 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Compress.ThreadReaders;
using NDecrypt.Tools;
using NDecrypt.Core.Tools;
namespace NDecrypt.CMD
namespace NDecrypt
{
internal static class HashingHelper
{
@@ -39,10 +38,8 @@ namespace NDecrypt.CMD
};
// Initialize the hashing helpers
var loadBuffer = new ThreadLoadBuffer(inputStream);
int buffersize = 3 * 1024 * 1024;
byte[] buffer0 = new byte[buffersize];
byte[] buffer1 = new byte[buffersize];
byte[] buffer = new byte[buffersize];
/*
Please note that some of the following code is adapted from
@@ -52,38 +49,26 @@ namespace NDecrypt.CMD
been tweaked to better fit this code base.
*/
// Pre load the first buffer
// Pre load the buffer
int next = buffersize > size ? (int)size : buffersize;
int current = inputStream.Read(buffer, 0, next);
long refsize = size;
int next = refsize > buffersize ? buffersize : (int)refsize;
inputStream.Read(buffer0, 0, next);
int current = next;
refsize -= next;
bool bufferSelect = true;
while (current > 0)
while (refsize > 0)
{
// Trigger the buffer load on the second buffer
next = refsize > buffersize ? buffersize : (int)refsize;
if (next > 0)
loadBuffer.Trigger(bufferSelect ? buffer1 : buffer0, next);
byte[] buffer = bufferSelect ? buffer0 : buffer1;
// Run hashes in parallel
Parallel.ForEach(hashers, h => h.Process(buffer, current));
if (current > 0)
Parallel.ForEach(hashers, h => h.Process(buffer, current));
// Load the next buffer
refsize -= current;
next = buffersize > refsize ? (int)refsize : buffersize;
// Wait for the load buffer worker, if needed
if (next > 0)
loadBuffer.Wait();
// Setup for the next hashing step
current = next;
refsize -= next;
bufferSelect = !bufferSelect;
current = inputStream.Read(buffer, 0, next);
}
// Finalize all hashing helpers
loadBuffer.Finish();
Parallel.ForEach(hashers, h => h.Terminate());
// Get the results
@@ -94,7 +79,6 @@ namespace NDecrypt.CMD
+ $"SHA256: {ByteArrayToString(hashers.First(h => h.HashType == Hash.SHA256).GetHash()) ?? ""}\n";
// Dispose of the hashers
loadBuffer.Dispose();
hashers.ForEach(h => h.Dispose());
return result;

View File

@@ -1,11 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>net48;net6.0</TargetFrameworks>
<RuntimeIdentifiers>win-x86;win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputType>Exe</OutputType>
<Title>NDecrypt</Title>
<AssemblyName>NDecrypt</AssemblyName>
<Description>DS/3DS Encryption Tool</Description>
<Authors>Matt Nadareski</Authors>
<Product>NDecrypt</Product>
<Copyright>Copyright (c)2018-2023 Matt Nadareski</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/SabreTools/NDecrypt</RepositoryUrl>
<Version>0.2.5</Version>
<AssemblyVersion>$(Version)</AssemblyVersion>
<FileVersion>$(Version)</FileVersion>
<IncludeSource>true</IncludeSource>
<IncludeSymbols>true</IncludeSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BouncyCastle.NetCore" Version="1.8.10" />
<ProjectReference Include="..\NDecrypt.Core\NDecrypt.Core.csproj" />
<ProjectReference Include="..\NDecrypt.N3DS\NDecrypt.N3DS.csproj" />
<ProjectReference Include="..\NDecrypt.Nitro\NDecrypt.Nitro.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,10 +1,11 @@
using System;
using System.IO;
using System.Reflection;
using NDecrypt.Core;
using NDecrypt.N3DS;
using NDecrypt.Nitro;
namespace NDecrypt.CMD
namespace NDecrypt
{
class Program
{
@@ -91,9 +92,9 @@ namespace NDecrypt.CMD
if (string.IsNullOrWhiteSpace(decryptArgs.KeyFile))
{
if (decryptArgs.UseCitraKeyFile)
decryptArgs.KeyFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "aes_keys.txt");
decryptArgs.KeyFile = Path.Combine(Path.GetDirectoryName(AppContext.BaseDirectory), "aes_keys.txt");
else
decryptArgs.KeyFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "keys.bin");
decryptArgs.KeyFile = Path.Combine(Path.GetDirectoryName(AppContext.BaseDirectory), "keys.bin");
}
// If we are using a Citra keyfile, there are no development keys

View File

@@ -1,79 +0,0 @@
using System;
using System.IO;
using System.Threading;
namespace Compress.ThreadReaders
{
public class ThreadLoadBuffer : IDisposable
{
private readonly AutoResetEvent _waitEvent;
private readonly AutoResetEvent _outEvent;
private readonly Thread _tWorker;
private byte[] _buffer;
private int _size;
private readonly Stream _ds;
private bool _finished;
public bool errorState;
public int SizeRead;
public ThreadLoadBuffer(Stream ds)
{
_waitEvent = new AutoResetEvent(false);
_outEvent = new AutoResetEvent(false);
_finished = false;
_ds = ds;
errorState = false;
_tWorker = new Thread(MainLoop);
_tWorker.Start();
}
public void Dispose()
{
_waitEvent.Close();
_outEvent.Close();
}
private void MainLoop()
{
while (true)
{
_waitEvent.WaitOne();
if (_finished)
{
break;
}
try
{
SizeRead = _ds.Read(_buffer, 0, _size);
}
catch (Exception)
{
errorState = true;
}
_outEvent.Set();
}
}
public void Trigger(byte[] buffer, int size)
{
_buffer = buffer;
_size = size;
_waitEvent.Set();
}
public void Wait()
{
_outEvent.WaitOne();
}
public void Finish()
{
_finished = true;
_waitEvent.Set();
_tWorker.Join();
}
}
}

View File

@@ -1,5 +1,7 @@
# NDecrypt
[![Build status](https://ci.appveyor.com/api/projects/status/cc1n298syn6r50mq?svg=true)](https://ci.appveyor.com/project/mnadareski/ndecrypt)
A simple tool for simple people.
## What is this?
@@ -70,8 +72,6 @@ Please note the above numbers are based on the current, documented values. The n
I'd like to thank the developers of the original programs for doing the actual hard work to figure things out. I'd also like to thank everyone who helped to test this against the original programs and made code suggestions.
Unofficially, this is entirely, 100% FOSS, no strings attached. I keep forgetting what license that is.
## Disclaimer
This program is **ONLY** for use with personally dumped files and keys and is not meant for enabling illegal activity. I do not condone using this program for anything other than personal use and research. If this program is used for anything other than that, I cannot be held liable for anything that happens.

61
appveyor.yml Normal file
View File

@@ -0,0 +1,61 @@
# version format
version: 0.2.5-{build}
# pull request template
pull_requests:
do_not_increment_build_number: true
# vm template
image: Visual Studio 2022
# msbuild configuration
configuration:
- Debug
# install dependencies
install:
- cd %APPVEYOR_BUILD_FOLDER%
- git submodule update --init --recursive
# build step
build_script:
- cmd: dotnet restore
- cmd: dotnet build NDecrypt\NDecrypt.csproj --framework net48
- cmd: dotnet publish NDecrypt\NDecrypt.csproj --framework net6.0 --runtime win-x86 --self-contained true -p:PublishSingleFile=true
- cmd: dotnet publish NDecrypt\NDecrypt.csproj --framework net6.0 --runtime win-x64 --self-contained true -p:PublishSingleFile=true
- cmd: dotnet publish NDecrypt\NDecrypt.csproj --framework net6.0 --runtime linux-x64 --self-contained true -p:PublishSingleFile=true
- cmd: dotnet publish NDecrypt\NDecrypt.csproj --framework net6.0 --runtime osx-x64 --self-contained true -p:PublishSingleFile=true
# post-build script
after_build:
- cmd: cd %APPVEYOR_BUILD_FOLDER%\NDecrypt\bin\Debug\net48
- cmd: 7z a -tzip %APPVEYOR_BUILD_FOLDER%\NDecrypt-%APPVEYOR_REPO_COMMIT%_net48.zip *
- cmd: cd %APPVEYOR_BUILD_FOLDER%\NDecrypt\bin\Debug\net6.0\win-x86\publish\
- cmd: 7z a -tzip %APPVEYOR_BUILD_FOLDER%\NDecrypt-%APPVEYOR_REPO_COMMIT%_net6.0_win-x86.zip *
- cmd: cd %APPVEYOR_BUILD_FOLDER%\NDecrypt\bin\Debug\net6.0\win-x64\publish\
- cmd: 7z a -tzip %APPVEYOR_BUILD_FOLDER%\NDecrypt-%APPVEYOR_REPO_COMMIT%_net6.0_win-x64.zip *
- cmd: cd %APPVEYOR_BUILD_FOLDER%\NDecrypt\bin\Debug\net6.0\linux-x64\publish\
- cmd: 7z a -tzip %APPVEYOR_BUILD_FOLDER%\NDecrypt-%APPVEYOR_REPO_COMMIT%_net6.0_linux-x64.zip *
- cmd: cd %APPVEYOR_BUILD_FOLDER%\NDecrypt\bin\Debug\net6.0\osx-x64\publish\
- cmd: 7z a -tzip %APPVEYOR_BUILD_FOLDER%\NDecrypt-%APPVEYOR_REPO_COMMIT%_net6.0_osx-x64.zip *
# success/failure tracking
on_success:
- ps: Invoke-RestMethod https://raw.githubusercontent.com/DiscordHooks/appveyor-discord-webhook/master/send.ps1 -o send.ps1
- ps: ./send.ps1 success $env:WEBHOOK_URL
on_failure:
- ps: Invoke-RestMethod https://raw.githubusercontent.com/DiscordHooks/appveyor-discord-webhook/master/send.ps1 -o send.ps1
- ps: ./send.ps1 failure $env:WEBHOOK_URL
# artifact linking
artifacts:
- path: NDecrypt-%APPVEYOR_REPO_COMMIT%_net48.zip
name: NDecrypt (.NET Framework 4.8)
- path: NDecrypt-%APPVEYOR_REPO_COMMIT%_net6.0_win-x86.zip
name: NDecrypt (.NET 6.0, Windows x86)
- path: NDecrypt-%APPVEYOR_REPO_COMMIT%_net6.0_win-x64.zip
name: NDecrypt (.NET 6.0, Windows x64)
- path: NDecrypt-%APPVEYOR_REPO_COMMIT%_net6.0_linux-x64.zip
name: NDecrypt (.NET 6.0, Linux x64)
- path: NDecrypt-%APPVEYOR_REPO_COMMIT%_net6.0_osx-x64.zip
name: NDecrypt (.NET 6.0, OSX x64)