diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj index c274dff3..5407094b 100644 --- a/src/Core/Core.csproj +++ b/src/Core/Core.csproj @@ -59,16 +59,15 @@ - + + - - - + \ No newline at end of file diff --git a/src/Core/Services/AuthService.cs b/src/Core/Services/AuthService.cs index ca53e41f..63dcb66a 100644 --- a/src/Core/Services/AuthService.cs +++ b/src/Core/Services/AuthService.cs @@ -1,4 +1,5 @@ using Bit.Core.Models; +using Bit.Core.Utilities; using System; using System.Collections.Generic; using System.Linq; @@ -38,12 +39,12 @@ namespace Bit.Core.Services public async Task LogInAsync(string email, string masterPassword) { var normalizedEmail = email.Trim().ToLower(); - var key = CryptoService.Instance.MakeKeyFromPassword(masterPassword, normalizedEmail); + var key = Crypto.MakeKeyFromPassword(masterPassword, normalizedEmail); var request = new TokenRequest { Email = normalizedEmail, - MasterPasswordHash = CryptoService.Instance.HashPasswordBase64(key, masterPassword) + MasterPasswordHash = Crypto.HashPasswordBase64(key, masterPassword) }; var response = await ApiService.Instance.PostTokenAsync(request); @@ -74,10 +75,9 @@ namespace Bit.Core.Services public async Task LogInTwoFactorAsync(string token, string email, string masterPassword) { var normalizedEmail = email.Trim().ToLower(); - var key = CryptoService.Instance.MakeKeyFromPassword(masterPassword, normalizedEmail); + var key = Crypto.MakeKeyFromPassword(masterPassword, normalizedEmail); - var result = await LogInTwoFactorWithHashAsync(token, email, - CryptoService.Instance.HashPasswordBase64(key, masterPassword)); + var result = await LogInTwoFactorWithHashAsync(token, email, Crypto.HashPasswordBase64(key, masterPassword)); key = null; masterPassword = null; diff --git a/src/Core/Services/CryptoService.cs b/src/Core/Utilities/Crypto.cs similarity index 67% rename from src/Core/Services/CryptoService.cs rename to src/Core/Utilities/Crypto.cs index 5bbbb3e2..b2c2ff06 100644 --- a/src/Core/Services/CryptoService.cs +++ b/src/Core/Utilities/Crypto.cs @@ -2,34 +2,13 @@ using Org.BouncyCastle.Crypto.Generators; using Org.BouncyCastle.Crypto.Parameters; using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; using System.Text; -using System.Threading.Tasks; -namespace Bit.Core.Services +namespace Bit.Core.Utilities { - public class CryptoService + public static class Crypto { - private static CryptoService _instance; - - private CryptoService() { } - - public static CryptoService Instance - { - get - { - if(_instance == null) - { - _instance = new CryptoService(); - } - - return _instance; - } - } - - public byte[] MakeKeyFromPassword(string password, string salt) + public static byte[] MakeKeyFromPassword(string password, string salt) { if(password == null) { @@ -52,14 +31,14 @@ namespace Bit.Core.Services return keyBytes; } - public string MakeKeyFromPasswordBase64(string password, string salt) + public static string MakeKeyFromPasswordBase64(string password, string salt) { var key = MakeKeyFromPassword(password, salt); password = null; return Convert.ToBase64String(key); } - public byte[] HashPassword(byte[] key, string password) + public static byte[] HashPassword(byte[] key, string password) { if(key == null) { @@ -81,7 +60,7 @@ namespace Bit.Core.Services return hashBytes; } - public string HashPasswordBase64(byte[] key, string password) + public static string HashPasswordBase64(byte[] key, string password) { var hash = HashPassword(key, password); password = null; @@ -89,7 +68,7 @@ namespace Bit.Core.Services return Convert.ToBase64String(hash); } - private byte[] DeriveKey(byte[] password, byte[] salt, int rounds) + private static byte[] DeriveKey(byte[] password, byte[] salt, int rounds) { var generator = new Pkcs5S2ParametersGenerator(new Sha256Digest()); generator.Init(password, salt, rounds); diff --git a/src/Core/Utilities/Sync.cs b/src/Core/Utilities/Sync.cs new file mode 100644 index 00000000..23c6953b --- /dev/null +++ b/src/Core/Utilities/Sync.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Bit.Core.Utilities +{ + public static class Sync + { + } +}