mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2025-02-09 13:14:46 +01:00
Move some files to LibHac.Common
This commit is contained in:
parent
50dab0c7c9
commit
2bd1c05ed5
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace LibHac;
|
||||
namespace LibHac.Common;
|
||||
|
||||
public class HorizonResultException : LibHacException
|
||||
{
|
||||
@ -65,4 +65,4 @@ public class HorizonResultException : LibHacException
|
||||
return ResultValue.ToStringWithName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
namespace LibHac;
|
||||
namespace LibHac.Common;
|
||||
|
||||
public interface IProgressReport
|
||||
{
|
||||
@ -25,4 +25,4 @@ public interface IProgressReport
|
||||
/// </summary>
|
||||
/// <param name="message">The message to output.</param>
|
||||
void LogMessage(string message);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace LibHac;
|
||||
namespace LibHac.Common;
|
||||
|
||||
/// <summary>
|
||||
/// This is the exception that is thrown when an error occurs
|
||||
@ -33,4 +33,4 @@ public class LibHacException : Exception
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace LibHac;
|
||||
namespace LibHac.Common;
|
||||
|
||||
public class ProgressBar : IDisposable, IProgressReport
|
||||
{
|
||||
@ -170,4 +170,4 @@ public class ProgressBar : IDisposable, IProgressReport
|
||||
UpdateText(string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace LibHac;
|
||||
namespace LibHac.Common;
|
||||
|
||||
internal static class ThrowHelper
|
||||
{
|
||||
@ -19,4 +19,4 @@ internal static class ThrowHelper
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace LibHac;
|
||||
namespace LibHac.Common;
|
||||
|
||||
public static class Utilities
|
||||
{
|
||||
@ -299,4 +299,4 @@ public static class Utilities
|
||||
|
||||
return keyGeneration - 1;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
namespace LibHac;
|
||||
namespace LibHac.Common;
|
||||
|
||||
public enum Validity : byte
|
||||
{
|
||||
@ -6,4 +6,4 @@ public enum Validity : byte
|
||||
Invalid,
|
||||
Valid,
|
||||
MissingKey
|
||||
}
|
||||
}
|
@ -105,4 +105,4 @@ public struct AesCbcModeNi
|
||||
|
||||
Iv = iv;
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Intrinsics;
|
||||
using System.Runtime.Intrinsics.X86;
|
||||
using LibHac.Common;
|
||||
|
||||
namespace LibHac.Crypto.Impl;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using LibHac.Common;
|
||||
using LibHac.Crypto;
|
||||
using LibHac.FsSystem;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
|
||||
namespace LibHac.Diag;
|
||||
|
||||
@ -81,4 +82,4 @@ public static class Abort
|
||||
{
|
||||
throw new LibHacException($"Unexpected value passed to switch statement in {caller}");
|
||||
}
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ using System.Buffers;
|
||||
using System.Buffers.Binary;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using LibHac.Common;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.FsSystem;
|
||||
@ -71,4 +72,4 @@ public class Aes128CtrTransform
|
||||
bufL[i + 1] = BinaryPrimitives.ReverseEndianness(lo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -28,6 +28,7 @@ using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using LibHac.Common;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.FsSystem;
|
||||
@ -235,4 +236,4 @@ public class Aes128XtsTransform
|
||||
if (tt > 0)
|
||||
i[0] ^= 0x87;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
|
||||
@ -128,4 +129,4 @@ public class AesXtsFileHeader
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Util;
|
||||
|
||||
@ -275,4 +276,4 @@ public class IvfcLevelHeader
|
||||
BlockSizePower = reader.ReadInt32();
|
||||
Reserved = reader.ReadUInt32();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.IO;
|
||||
using LibHac.Common;
|
||||
using LibHac.Crypto;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Tools.FsSystem.Save;
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
using Buffer = LibHac.Mem.Buffer;
|
||||
|
||||
namespace LibHac;
|
||||
|
@ -1,6 +1,7 @@
|
||||
// ReSharper disable UnusedVariable
|
||||
using System;
|
||||
using System.IO;
|
||||
using LibHac.Common;
|
||||
|
||||
namespace LibHac.Npdm;
|
||||
|
||||
@ -60,4 +61,4 @@ public class Aci0
|
||||
new KernelAccessControl(stream, offset + kernelAccessControlOffset, kernelAccessControlSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
// ReSharper disable UnusedVariable
|
||||
using System;
|
||||
using System.IO;
|
||||
using LibHac.Common;
|
||||
using LibHac.Common.Keys;
|
||||
|
||||
namespace LibHac.Npdm;
|
||||
@ -71,4 +72,4 @@ public class Acid
|
||||
|
||||
KernelAccess = new KernelAccessControl(stream, offset + kernelAccessControlOffset, kernelAccessControlSize);
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using System;
|
||||
using System.Buffers.Binary;
|
||||
using System.IO;
|
||||
using LibHac.Common;
|
||||
using LibHac.Common.Keys;
|
||||
|
||||
namespace LibHac.Npdm;
|
||||
@ -77,4 +78,4 @@ public class NpdmBinary
|
||||
Aci0 = new Aci0(stream, aci0Offset);
|
||||
AciD = new Acid(stream, acidOffset, keySet);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using LibHac.Common;
|
||||
|
||||
namespace LibHac.Npdm;
|
||||
|
||||
@ -33,4 +34,4 @@ public class ServiceAccessControl
|
||||
bytesRead += length + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using LibHac.Common;
|
||||
using LibHac.Common.Keys;
|
||||
using LibHac.Util;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using LibHac.Common;
|
||||
using LibHac.Common.Keys;
|
||||
using LibHac.Crypto;
|
||||
using LibHac.Fs;
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Buffers.Binary;
|
||||
using System.Diagnostics;
|
||||
using LibHac.Common;
|
||||
using LibHac.Crypto;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSystem;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using LibHac.Common;
|
||||
using LibHac.Common.Keys;
|
||||
using LibHac.Crypto;
|
||||
using LibHac.Fs;
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSystem;
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSystem;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSystem;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using LibHac.Common;
|
||||
|
||||
namespace LibHac.Tools.Settings;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.Ncm;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.Common.Keys;
|
||||
using LibHac.FsSystem;
|
||||
|
||||
@ -101,4 +102,4 @@ internal class Context
|
||||
public KeySet KeySet;
|
||||
public ProgressBar Logger;
|
||||
public HorizonClient Horizon;
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Buffers.Binary;
|
||||
using System.Text;
|
||||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
|
||||
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Intrinsics;
|
||||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.Crypto;
|
||||
using LibHac.Crypto.Impl;
|
||||
using LibHac.Fs;
|
||||
@ -390,134 +390,134 @@ internal static class ProcessBench
|
||||
switch (ctx.Options.BenchType?.ToLower())
|
||||
{
|
||||
case "aesctr":
|
||||
{
|
||||
IStorage decStorage = new MemoryStorage(new byte[Size]);
|
||||
IStorage encStorage = new Aes128CtrStorage(new MemoryStorage(new byte[Size]), new byte[0x10], new byte[0x10], true);
|
||||
{
|
||||
IStorage decStorage = new MemoryStorage(new byte[Size]);
|
||||
IStorage encStorage = new Aes128CtrStorage(new MemoryStorage(new byte[Size]), new byte[0x10], new byte[0x10], true);
|
||||
|
||||
CopyBenchmark(decStorage, encStorage, Iterations, "MemoryStorage Encrypt: ", ctx.Logger);
|
||||
CopyBenchmark(encStorage, decStorage, Iterations, "MemoryStorage Decrypt: ", ctx.Logger);
|
||||
CopyBenchmark(decStorage, encStorage, Iterations, "MemoryStorage Encrypt: ", ctx.Logger);
|
||||
CopyBenchmark(encStorage, decStorage, Iterations, "MemoryStorage Decrypt: ", ctx.Logger);
|
||||
|
||||
decStorage = new NullStorage(Size);
|
||||
encStorage = new Aes128CtrStorage(new NullStorage(Size), new byte[0x10], new byte[0x10], true);
|
||||
decStorage = new NullStorage(Size);
|
||||
encStorage = new Aes128CtrStorage(new NullStorage(Size), new byte[0x10], new byte[0x10], true);
|
||||
|
||||
CopyBenchmark(decStorage, encStorage, Iterations, "NullStorage Encrypt: ", ctx.Logger);
|
||||
CopyBenchmark(encStorage, decStorage, Iterations, "NullStorage Decrypt: ", ctx.Logger);
|
||||
CopyBenchmark(decStorage, encStorage, Iterations, "NullStorage Encrypt: ", ctx.Logger);
|
||||
CopyBenchmark(encStorage, decStorage, Iterations, "NullStorage Decrypt: ", ctx.Logger);
|
||||
|
||||
decStorage = new MemoryStorage(new byte[Size]);
|
||||
encStorage = new CachedStorage(new Aes128CtrStorage(new MemoryStorage(new byte[Size]), new byte[0x10], new byte[0x10], true), 0x4000, 4, true);
|
||||
decStorage = new MemoryStorage(new byte[Size]);
|
||||
encStorage = new CachedStorage(new Aes128CtrStorage(new MemoryStorage(new byte[Size]), new byte[0x10], new byte[0x10], true), 0x4000, 4, true);
|
||||
|
||||
CopyBenchmark(decStorage, encStorage, Iterations, "CachedStorage Encrypt: ", ctx.Logger);
|
||||
CopyBenchmark(encStorage, decStorage, Iterations, "CachedStorage Decrypt: ", ctx.Logger);
|
||||
CopyBenchmark(decStorage, encStorage, Iterations, "CachedStorage Encrypt: ", ctx.Logger);
|
||||
CopyBenchmark(encStorage, decStorage, Iterations, "CachedStorage Decrypt: ", ctx.Logger);
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "aesxts":
|
||||
{
|
||||
IStorage decStorage = new MemoryStorage(new byte[Size]);
|
||||
IStorage encStorage = new Aes128XtsStorage(new MemoryStorage(new byte[Size]), new byte[0x20], 81920, true);
|
||||
{
|
||||
IStorage decStorage = new MemoryStorage(new byte[Size]);
|
||||
IStorage encStorage = new Aes128XtsStorage(new MemoryStorage(new byte[Size]), new byte[0x20], 81920, true);
|
||||
|
||||
CopyBenchmark(decStorage, encStorage, Iterations, "MemoryStorage Encrypt: ", ctx.Logger);
|
||||
CopyBenchmark(encStorage, decStorage, Iterations, "MemoryStorage Decrypt: ", ctx.Logger);
|
||||
CopyBenchmark(decStorage, encStorage, Iterations, "MemoryStorage Encrypt: ", ctx.Logger);
|
||||
CopyBenchmark(encStorage, decStorage, Iterations, "MemoryStorage Decrypt: ", ctx.Logger);
|
||||
|
||||
decStorage = new NullStorage(Size);
|
||||
encStorage = new Aes128XtsStorage(new NullStorage(Size), new byte[0x20], 81920, true);
|
||||
decStorage = new NullStorage(Size);
|
||||
encStorage = new Aes128XtsStorage(new NullStorage(Size), new byte[0x20], 81920, true);
|
||||
|
||||
CopyBenchmark(decStorage, encStorage, Iterations, "NullStorage Encrypt: ", ctx.Logger);
|
||||
CopyBenchmark(encStorage, decStorage, Iterations, "NullStorage Decrypt: ", ctx.Logger);
|
||||
CopyBenchmark(decStorage, encStorage, Iterations, "NullStorage Encrypt: ", ctx.Logger);
|
||||
CopyBenchmark(encStorage, decStorage, Iterations, "NullStorage Decrypt: ", ctx.Logger);
|
||||
|
||||
decStorage = new MemoryStorage(new byte[Size]);
|
||||
encStorage = new CachedStorage(new Aes128XtsStorage(new MemoryStorage(new byte[Size]), new byte[0x20], 0x4000, true), 4, true);
|
||||
decStorage = new MemoryStorage(new byte[Size]);
|
||||
encStorage = new CachedStorage(new Aes128XtsStorage(new MemoryStorage(new byte[Size]), new byte[0x20], 0x4000, true), 4, true);
|
||||
|
||||
CopyBenchmark(decStorage, encStorage, Iterations, "CachedStorage Encrypt: ", ctx.Logger);
|
||||
CopyBenchmark(encStorage, decStorage, Iterations, "CachedStorage Decrypt: ", ctx.Logger);
|
||||
break;
|
||||
}
|
||||
CopyBenchmark(decStorage, encStorage, Iterations, "CachedStorage Encrypt: ", ctx.Logger);
|
||||
CopyBenchmark(encStorage, decStorage, Iterations, "CachedStorage Decrypt: ", ctx.Logger);
|
||||
break;
|
||||
}
|
||||
|
||||
case "aesecbnew":
|
||||
{
|
||||
Func<ICipher> encryptorNet = () => Aes.CreateEcbEncryptor(new byte[0x10], true);
|
||||
Func<ICipher> encryptorLh = () => Aes.CreateEcbEncryptor(new byte[0x10]);
|
||||
CipherTaskSeparate encrypt = (input, output, key1, _, _, crypto) =>
|
||||
Aes.EncryptEcb128(input, output, key1, crypto);
|
||||
{
|
||||
Func<ICipher> encryptorNet = () => Aes.CreateEcbEncryptor(new byte[0x10], true);
|
||||
Func<ICipher> encryptorLh = () => Aes.CreateEcbEncryptor(new byte[0x10]);
|
||||
CipherTaskSeparate encrypt = (input, output, key1, _, _, crypto) =>
|
||||
Aes.EncryptEcb128(input, output, key1, crypto);
|
||||
|
||||
RunCipherBenchmark(encryptorNet, encryptorLh, encrypt, true, "AES-ECB encrypt", ctx.Logger);
|
||||
RunCipherBenchmark(encryptorNet, encryptorLh, encrypt, true, "AES-ECB encrypt", ctx.Logger);
|
||||
|
||||
Func<ICipher> decryptorNet = () => Aes.CreateEcbDecryptor(new byte[0x10], true);
|
||||
Func<ICipher> decryptorLh = () => Aes.CreateEcbDecryptor(new byte[0x10]);
|
||||
CipherTaskSeparate decrypt = (input, output, key1, _, _, crypto) =>
|
||||
Aes.DecryptEcb128(input, output, key1, crypto);
|
||||
Func<ICipher> decryptorNet = () => Aes.CreateEcbDecryptor(new byte[0x10], true);
|
||||
Func<ICipher> decryptorLh = () => Aes.CreateEcbDecryptor(new byte[0x10]);
|
||||
CipherTaskSeparate decrypt = (input, output, key1, _, _, crypto) =>
|
||||
Aes.DecryptEcb128(input, output, key1, crypto);
|
||||
|
||||
RunCipherBenchmark(decryptorNet, decryptorLh, decrypt, true, "AES-ECB decrypt", ctx.Logger);
|
||||
RunCipherBenchmark(decryptorNet, decryptorLh, decrypt, true, "AES-ECB decrypt", ctx.Logger);
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "aescbcnew":
|
||||
{
|
||||
Func<ICipher> encryptorNet = () => Aes.CreateCbcEncryptor(new byte[0x10], new byte[0x10], true);
|
||||
Func<ICipher> encryptorLh = () => Aes.CreateCbcEncryptor(new byte[0x10], new byte[0x10]);
|
||||
CipherTaskSeparate encrypt = (input, output, key1, _, iv, crypto) =>
|
||||
Aes.EncryptCbc128(input, output, key1, iv, crypto);
|
||||
{
|
||||
Func<ICipher> encryptorNet = () => Aes.CreateCbcEncryptor(new byte[0x10], new byte[0x10], true);
|
||||
Func<ICipher> encryptorLh = () => Aes.CreateCbcEncryptor(new byte[0x10], new byte[0x10]);
|
||||
CipherTaskSeparate encrypt = (input, output, key1, _, iv, crypto) =>
|
||||
Aes.EncryptCbc128(input, output, key1, iv, crypto);
|
||||
|
||||
RunCipherBenchmark(encryptorNet, encryptorLh, encrypt, true, "AES-CBC encrypt", ctx.Logger);
|
||||
RunCipherBenchmark(encryptorNet, encryptorLh, encrypt, true, "AES-CBC encrypt", ctx.Logger);
|
||||
|
||||
Func<ICipher> decryptorNet = () => Aes.CreateCbcDecryptor(new byte[0x10], new byte[0x10], true);
|
||||
Func<ICipher> decryptorLh = () => Aes.CreateCbcDecryptor(new byte[0x10], new byte[0x10]);
|
||||
CipherTaskSeparate decrypt = (input, output, key1, _, iv, crypto) =>
|
||||
Aes.DecryptCbc128(input, output, key1, iv, crypto);
|
||||
Func<ICipher> decryptorNet = () => Aes.CreateCbcDecryptor(new byte[0x10], new byte[0x10], true);
|
||||
Func<ICipher> decryptorLh = () => Aes.CreateCbcDecryptor(new byte[0x10], new byte[0x10]);
|
||||
CipherTaskSeparate decrypt = (input, output, key1, _, iv, crypto) =>
|
||||
Aes.DecryptCbc128(input, output, key1, iv, crypto);
|
||||
|
||||
RunCipherBenchmark(decryptorNet, decryptorLh, decrypt, true, "AES-CBC decrypt", ctx.Logger);
|
||||
RunCipherBenchmark(decryptorNet, decryptorLh, decrypt, true, "AES-CBC decrypt", ctx.Logger);
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "aesctrnew":
|
||||
{
|
||||
Func<ICipher> encryptorNet = () => Aes.CreateCtrEncryptor(new byte[0x10], new byte[0x10], true);
|
||||
Func<ICipher> encryptorLh = () => Aes.CreateCtrEncryptor(new byte[0x10], new byte[0x10]);
|
||||
CipherTaskSeparate encrypt = (input, output, key1, _, iv, crypto) =>
|
||||
Aes.EncryptCtr128(input, output, key1, iv, crypto);
|
||||
{
|
||||
Func<ICipher> encryptorNet = () => Aes.CreateCtrEncryptor(new byte[0x10], new byte[0x10], true);
|
||||
Func<ICipher> encryptorLh = () => Aes.CreateCtrEncryptor(new byte[0x10], new byte[0x10]);
|
||||
CipherTaskSeparate encrypt = (input, output, key1, _, iv, crypto) =>
|
||||
Aes.EncryptCtr128(input, output, key1, iv, crypto);
|
||||
|
||||
RunCipherBenchmark(encryptorNet, encryptorLh, encrypt, true, "AES-CTR", ctx.Logger);
|
||||
RunCipherBenchmark(encryptorNet, encryptorLh, encrypt, true, "AES-CTR", ctx.Logger);
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "aesxtsnew":
|
||||
{
|
||||
Func<ICipher> encryptorNet = () => Aes.CreateXtsEncryptor(new byte[0x10], new byte[0x10], new byte[0x10], true);
|
||||
Func<ICipher> encryptorLh = () => Aes.CreateXtsEncryptor(new byte[0x10], new byte[0x10], new byte[0x10]);
|
||||
CipherTaskSeparate encrypt = (input, output, key1, key2, iv, crypto) =>
|
||||
Aes.EncryptXts128(input, output, key1, key2, iv, crypto);
|
||||
{
|
||||
Func<ICipher> encryptorNet = () => Aes.CreateXtsEncryptor(new byte[0x10], new byte[0x10], new byte[0x10], true);
|
||||
Func<ICipher> encryptorLh = () => Aes.CreateXtsEncryptor(new byte[0x10], new byte[0x10], new byte[0x10]);
|
||||
CipherTaskSeparate encrypt = (input, output, key1, key2, iv, crypto) =>
|
||||
Aes.EncryptXts128(input, output, key1, key2, iv, crypto);
|
||||
|
||||
RunCipherBenchmark(encryptorNet, encryptorLh, encrypt, false, "AES-XTS encrypt", ctx.Logger);
|
||||
RunCipherBenchmark(encryptorNet, encryptorLh, encrypt, false, "AES-XTS encrypt", ctx.Logger);
|
||||
|
||||
Func<ICipher> decryptorNet = () => Aes.CreateXtsDecryptor(new byte[0x10], new byte[0x10], new byte[0x10], true);
|
||||
Func<ICipher> decryptorLh = () => Aes.CreateXtsDecryptor(new byte[0x10], new byte[0x10], new byte[0x10]);
|
||||
CipherTaskSeparate decrypt = (input, output, key1, key2, iv, crypto) =>
|
||||
Aes.DecryptXts128(input, output, key1, key2, iv, crypto);
|
||||
Func<ICipher> decryptorNet = () => Aes.CreateXtsDecryptor(new byte[0x10], new byte[0x10], new byte[0x10], true);
|
||||
Func<ICipher> decryptorLh = () => Aes.CreateXtsDecryptor(new byte[0x10], new byte[0x10], new byte[0x10]);
|
||||
CipherTaskSeparate decrypt = (input, output, key1, key2, iv, crypto) =>
|
||||
Aes.DecryptXts128(input, output, key1, key2, iv, crypto);
|
||||
|
||||
RunCipherBenchmark(decryptorNet, decryptorLh, decrypt, false, "AES-XTS decrypt", ctx.Logger);
|
||||
RunCipherBenchmark(decryptorNet, decryptorLh, decrypt, false, "AES-XTS decrypt", ctx.Logger);
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "crypto":
|
||||
{
|
||||
var bench = new MultiBenchmark();
|
||||
{
|
||||
var bench = new MultiBenchmark();
|
||||
|
||||
RegisterAesSequentialBenchmarks(bench);
|
||||
RegisterAesSingleBlockBenchmarks(bench);
|
||||
RegisterShaBenchmarks(bench);
|
||||
RegisterAesSequentialBenchmarks(bench);
|
||||
RegisterAesSingleBlockBenchmarks(bench);
|
||||
RegisterShaBenchmarks(bench);
|
||||
|
||||
bench.Run();
|
||||
break;
|
||||
}
|
||||
bench.Run();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
ctx.Logger.LogMessage("Unknown benchmark type.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.Crypto;
|
||||
using LibHac.Fs;
|
||||
@ -86,4 +85,4 @@ internal static class ProcessNax0
|
||||
2 => "Custom storage",
|
||||
_ => "Unknown"
|
||||
};
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ internal static class ProcessPackage
|
||||
{
|
||||
using var file = new SharedRef<IStorage>(new LocalStorage(ctx.Options.InFile, FileAccess.Read));
|
||||
|
||||
var package1 = new LibHac.Boot.Package1();
|
||||
var package1 = new Package1();
|
||||
package1.Initialize(ctx.KeySet, in file).ThrowIfFailure();
|
||||
|
||||
ctx.Logger.LogMessage(package1.Print());
|
||||
@ -54,7 +54,7 @@ internal static class ProcessPackage
|
||||
}
|
||||
}
|
||||
|
||||
private static string Print(this LibHac.Boot.Package1 package1)
|
||||
private static string Print(this Package1 package1)
|
||||
{
|
||||
int colLen = 36;
|
||||
var sb = new StringBuilder();
|
||||
@ -177,4 +177,4 @@ internal static class ProcessPackage
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.Common.Keys;
|
||||
using LibHac.Fs;
|
||||
|
@ -4,7 +4,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem;
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.Tools.Fs;
|
||||
|
@ -2,6 +2,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.Common.Keys;
|
||||
using LibHac.Diag;
|
||||
using LibHac.Fs;
|
||||
@ -221,7 +222,7 @@ public static class Program
|
||||
|
||||
var keySet = KeySet.CreateDefaultKeySet();
|
||||
|
||||
var logger = ctx.Options.DisableKeyWarns ? null : ctx.Logger;
|
||||
IProgressReport logger = ctx.Options.DisableKeyWarns ? null : ctx.Logger;
|
||||
|
||||
// If the user specifies a key file then only load that file into the mode they specified,
|
||||
// otherwise load both prod.keys and dev.keys.
|
||||
@ -286,4 +287,4 @@ public static class Program
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using LibHac.Common;
|
||||
|
||||
namespace LibHac.Tests;
|
||||
|
||||
@ -8,4 +9,4 @@ public class DebugAssertHandler : DefaultTraceListener
|
||||
{
|
||||
throw new LibHacException(message + detailMessage);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.Tests.Common;
|
||||
|
Loading…
x
Reference in New Issue
Block a user