diff --git a/src/Core/Abstractions/ICryptoService.cs b/src/Core/Abstractions/ICryptoService.cs index 4bebc3ea9..529e6e835 100644 --- a/src/Core/Abstractions/ICryptoService.cs +++ b/src/Core/Abstractions/ICryptoService.cs @@ -12,6 +12,7 @@ namespace Bit.Core.Abstractions Task SetUserKeyAsync(UserKey userKey); Task GetUserKeyAsync(string userId = null); Task HasUserKeyAsync(string userId = null); + Task MakeUserKeyAsync(); Task ClearUserKeyAsync(string userId = null); Task SetMasterKeyEncryptedUserKeyAsync(string value, string userId = null); Task SetMasterKeyAsync(MasterKey masterKey, string userId = null); diff --git a/src/Core/Services/CryptoService.cs b/src/Core/Services/CryptoService.cs index fcd15b367..50a50b48d 100644 --- a/src/Core/Services/CryptoService.cs +++ b/src/Core/Services/CryptoService.cs @@ -51,6 +51,11 @@ namespace Bit.Core.Services return await GetUserKeyAsync(userId) != null; } + public async Task MakeUserKeyAsync() + { + return new UserKey(await _cryptoFunctionService.RandomBytesAsync(64)); + } + public async Task ClearUserKeyAsync(string userId = null) { await _stateService.SetUserKeyAsync(null, userId);