From 8f4895e8a5bd1549f41bc1d4d2b31d03cff689ad Mon Sep 17 00:00:00 2001 From: Phallacy Date: Thu, 7 Mar 2019 03:11:41 -0800 Subject: more fixes for perf and style --- .../Cryptography/CryptographyProvider.cs | 35 ++++++++++++---------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'Emby.Server.Implementations') diff --git a/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs b/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs index 2e882cefe..e27738f69 100644 --- a/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs +++ b/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs @@ -17,7 +17,7 @@ namespace Emby.Server.Implementations.Cryptography private RandomNumberGenerator _randomNumberGenerator; - private int _defaultIterations = 1000; + private const int _defaultIterations = 1000; public CryptographyProvider() { @@ -27,20 +27,20 @@ namespace Emby.Server.Implementations.Cryptography //Please note the default method of PBKDF2 is not included, it cannot be used to generate hashes cleanly as it is actually a pbkdf with sha1 _supportedHashMethods = new HashSet() { - "MD5" - ,"System.Security.Cryptography.MD5" - ,"SHA" - ,"SHA1" - ,"System.Security.Cryptography.SHA1" - ,"SHA256" - ,"SHA-256" - ,"System.Security.Cryptography.SHA256" - ,"SHA384" - ,"SHA-384" - ,"System.Security.Cryptography.SHA384" - ,"SHA512" - ,"SHA-512" - ,"System.Security.Cryptography.SHA512" + "MD5", + "System.Security.Cryptography.MD5", + "SHA", + "SHA1", + "System.Security.Cryptography.SHA1", + "SHA256", + "SHA-256", + "System.Security.Cryptography.SHA256", + "SHA384", + "SHA-384", + "System.Security.Cryptography.SHA384", + "SHA512", + "SHA-512", + "System.Security.Cryptography.SHA512" }; _randomNumberGenerator = RandomNumberGenerator.Create(); } @@ -120,7 +120,10 @@ namespace Emby.Server.Implementations.Cryptography } else { - return h.ComputeHash(bytes.Concat(salt).ToArray()); + byte[] salted = new byte[bytes.Length + salt.Length]; + Array.Copy(bytes, salted, bytes.Length); + Array.Copy(salt, 0, salted, bytes.Length, salt.Length); + return h.ComputeHash(salted); } } } -- cgit v1.2.3