diff --git a/build/Build.cs b/build/Build.cs index 61f75fb4..865b3bc7 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -301,7 +301,7 @@ namespace LibHacBuild public void PrintResults() { Logger.Normal("SHA-1:"); - using (SHA1 sha = SHA1.Create()) + using (var sha = SHA1.Create()) { foreach (string filename in Directory.EnumerateFiles(ArtifactsDirectory)) { diff --git a/build/RepackNuget.cs b/build/RepackNuget.cs index 942b3340..882a1f3e 100644 --- a/build/RepackNuget.cs +++ b/build/RepackNuget.cs @@ -73,7 +73,7 @@ namespace LibHacBuild public static string CalcPsmdcpName(string libDir) { - using (SHA256 sha = SHA256.Create()) + using (var sha = SHA256.Create()) { foreach (string file in Directory.EnumerateFiles(libDir)) { @@ -104,7 +104,7 @@ namespace LibHacBuild foreach (XElement rs in doc.Root.Elements(ns + "Relationship")) { - using (SHA256 sha = SHA256.Create()) + using (var sha = SHA256.Create()) { if (rs.Attribute("Target").Value.Contains(".psmdcp")) { diff --git a/src/LibHac/Crypto/Detail/AesCore.cs b/src/LibHac/Crypto/Detail/AesCore.cs index fccf1001..b87fbf40 100644 --- a/src/LibHac/Crypto/Detail/AesCore.cs +++ b/src/LibHac/Crypto/Detail/AesCore.cs @@ -15,7 +15,7 @@ namespace LibHac.Crypto.Detail Debug.Assert(key.Length == Aes.KeySize128); Debug.Assert(iv.IsEmpty || iv.Length == Aes.BlockSize); - System.Security.Cryptography.Aes aes = System.Security.Cryptography.Aes.Create(); + var aes = System.Security.Cryptography.Aes.Create(); if (aes == null) throw new CryptographicException("Unable to create AES object"); aes.Key = key.ToArray(); diff --git a/src/LibHac/Crypto/Detail/AesCtrModeNi.cs b/src/LibHac/Crypto/Detail/AesCtrModeNi.cs index 02781901..c7e1138d 100644 --- a/src/LibHac/Crypto/Detail/AesCtrModeNi.cs +++ b/src/LibHac/Crypto/Detail/AesCtrModeNi.cs @@ -34,7 +34,7 @@ namespace LibHac.Crypto.Detail ref Vector128 outBlock = ref Unsafe.As>(ref MemoryMarshal.GetReference(output)); Vector128 byteSwapMask = Vector128.Create((ulong)0x706050403020100, 0x8090A0B0C0D0E0F).AsByte(); - Vector128 inc = Vector128.Create((ulong)0, 1); + var inc = Vector128.Create((ulong)0, 1); Vector128 iv = Iv; Vector128 bSwappedIv = Ssse3.Shuffle(iv, byteSwapMask).AsUInt64(); diff --git a/src/LibHac/CryptoOld.cs b/src/LibHac/CryptoOld.cs index bb75f7de..1e97d67f 100644 --- a/src/LibHac/CryptoOld.cs +++ b/src/LibHac/CryptoOld.cs @@ -12,7 +12,7 @@ namespace LibHac public static void DecryptEcb(byte[] key, byte[] src, int srcIndex, byte[] dest, int destIndex, int length) { - using (Aes aes = Aes.Create()) + using (var aes = Aes.Create()) { if (aes == null) throw new CryptographicException("Unable to create AES object"); aes.Key = key; @@ -27,7 +27,7 @@ namespace LibHac public static void EncryptEcb(byte[] key, byte[] src, int srcIndex, byte[] dest, int destIndex, int length) { - using (Aes aes = Aes.Create()) + using (var aes = Aes.Create()) { if (aes == null) throw new CryptographicException("Unable to create AES object"); aes.Key = key; @@ -42,7 +42,7 @@ namespace LibHac public static void DecryptCbc(byte[] key, byte[] iv, byte[] src, int srcIndex, byte[] dest, int destIndex, int length) { - using (Aes aes = Aes.Create()) + using (var aes = Aes.Create()) { if (aes == null) throw new CryptographicException("Unable to create AES object"); aes.Key = key; @@ -58,7 +58,7 @@ namespace LibHac public static void EncryptCbc(byte[] key, byte[] iv, byte[] src, int srcIndex, byte[] dest, int destIndex, int length) { - using (Aes aes = Aes.Create()) + using (var aes = Aes.Create()) { if (aes == null) throw new CryptographicException("Unable to create AES object"); aes.Key = key; @@ -140,7 +140,7 @@ namespace LibHac public static Validity Rsa2048Pkcs1Verify(byte[] data, byte[] signature, byte[] modulus) { - using (RSA rsa = RSA.Create()) + using (var rsa = RSA.Create()) { rsa.ImportParameters(new RSAParameters { Exponent = new byte[] { 1, 0, 1 }, Modulus = modulus }); @@ -152,7 +152,7 @@ namespace LibHac public static Validity Rsa2048PssVerify(byte[] data, byte[] signature, byte[] modulus) { - using (RSA rsa = RSA.Create()) + using (var rsa = RSA.Create()) { rsa.ImportParameters(new RSAParameters { Exponent = new byte[] { 1, 0, 1 }, Modulus = modulus }); @@ -164,7 +164,7 @@ namespace LibHac public static byte[] DecryptTitleKey(byte[] titleKeyblock, RSAParameters rsaParams) { - RSA rsa = RSA.Create(); + var rsa = RSA.Create(); rsa.ImportParameters(rsaParams); return rsa.Decrypt(titleKeyblock, RSAEncryptionPadding.OaepSHA256); @@ -172,7 +172,7 @@ namespace LibHac private static RSAParameters RecoverRsaParameters(BigInteger n, BigInteger e, BigInteger d) { - using (RandomNumberGenerator rng = RandomNumberGenerator.Create()) + using (var rng = RandomNumberGenerator.Create()) { BigInteger k = d * e - 1; diff --git a/src/LibHac/FsSystem/Aes128CtrTransform.cs b/src/LibHac/FsSystem/Aes128CtrTransform.cs index beaf2d7b..6ba8b971 100644 --- a/src/LibHac/FsSystem/Aes128CtrTransform.cs +++ b/src/LibHac/FsSystem/Aes128CtrTransform.cs @@ -24,7 +24,7 @@ namespace LibHac.FsSystem if (counter.Length != BlockSizeBytes) throw new ArgumentException($"{nameof(counter)} must be {BlockSizeBytes} bytes long"); - Aes aes = Aes.Create(); + var aes = Aes.Create(); if (aes == null) throw new CryptographicException("Unable to create AES object"); aes.Mode = CipherMode.ECB; aes.Padding = PaddingMode.None; diff --git a/src/LibHac/FsSystem/Aes128XtsTransform.cs b/src/LibHac/FsSystem/Aes128XtsTransform.cs index 9fc2eb55..a0279e8b 100644 --- a/src/LibHac/FsSystem/Aes128XtsTransform.cs +++ b/src/LibHac/FsSystem/Aes128XtsTransform.cs @@ -49,7 +49,7 @@ namespace LibHac.FsSystem if (key1?.Length != BlockSizeBytes || key2?.Length != BlockSizeBytes) throw new ArgumentException($"Each key must be {BlockSizeBytes} bytes long"); - Aes aes = Aes.Create(); + var aes = Aes.Create(); if (aes == null) throw new CryptographicException("Unable to create AES object"); aes.Mode = CipherMode.ECB; aes.Padding = PaddingMode.None; diff --git a/src/LibHac/Util.cs b/src/LibHac/Util.cs index f7b4ce26..b774f85f 100644 --- a/src/LibHac/Util.cs +++ b/src/LibHac/Util.cs @@ -19,7 +19,7 @@ namespace LibHac private static object InitializeJaggedArray(Type type, int index, int[] lengths) { - Array array = Array.CreateInstance(type, lengths[index]); + var array = Array.CreateInstance(type, lengths[index]); Type elementType = type.GetElementType(); if (elementType == null) return array; diff --git a/src/hactoolnet/ProcessBench.cs b/src/hactoolnet/ProcessBench.cs index 63ecb278..1ad5a270 100644 --- a/src/hactoolnet/ProcessBench.cs +++ b/src/hactoolnet/ProcessBench.cs @@ -32,7 +32,7 @@ namespace hactoolnet logger.SetTotal(iterations); - Stopwatch encryptWatch = Stopwatch.StartNew(); + var encryptWatch = Stopwatch.StartNew(); for (int i = 0; i < iterations; i++) { src.CopyTo(dst); diff --git a/src/hactoolnet/ProcessPfs.cs b/src/hactoolnet/ProcessPfs.cs index fd7bbf2b..b8334432 100644 --- a/src/hactoolnet/ProcessPfs.cs +++ b/src/hactoolnet/ProcessPfs.cs @@ -87,7 +87,7 @@ namespace hactoolnet byte[] ticketBytes = ticket.GetBytes(); builder.AddFile($"{ticket.RightsId.ToHexString()}.tik", new MemoryStream(ticketBytes).AsIFile(OpenMode.ReadWrite)); - Assembly thisAssembly = Assembly.GetExecutingAssembly(); + var thisAssembly = Assembly.GetExecutingAssembly(); Stream cert = thisAssembly.GetManifestResourceStream("hactoolnet.CA00000003_XS00000020"); builder.AddFile($"{ticket.RightsId.ToHexString()}.cert", cert.AsIFile(OpenMode.Read)); diff --git a/tests/LibHac.Tests/PathToolsTests.cs b/tests/LibHac.Tests/PathToolsTests.cs index b72de33c..1435c0a2 100644 --- a/tests/LibHac.Tests/PathToolsTests.cs +++ b/tests/LibHac.Tests/PathToolsTests.cs @@ -219,7 +219,7 @@ namespace LibHac.Tests [MemberData(nameof(NormalizedPathTestItemsU8NoMountName))] public static void NormalizePathU8NoMountName(string path, string expected, Result expectedResult) { - U8String u8Path = path.ToU8String(); + var u8Path = path.ToU8String(); Span buffer = stackalloc byte[0x301]; Result rc = PathTools.Normalize(buffer, out _, u8Path, false); @@ -237,7 +237,7 @@ namespace LibHac.Tests [MemberData(nameof(NormalizedPathTestItemsU8MountName))] public static void NormalizePathU8MountName(string path, string expected, Result expectedResult) { - U8String u8Path = path.ToU8String(); + var u8Path = path.ToU8String(); Span buffer = stackalloc byte[0x301]; Result rc = PathTools.Normalize(buffer, out _, u8Path, true); @@ -263,7 +263,7 @@ namespace LibHac.Tests [MemberData(nameof(NormalizedPathTestItemsU8TooShort))] public static void NormalizePathU8TooShortDest(string path, string expected, int destSize) { - U8String u8Path = path.ToU8String(); + var u8Path = path.ToU8String(); Span buffer = stackalloc byte[destSize];