1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-05 23:53:33 +00:00

[PM-2713] add make user key method to crypto service

This commit is contained in:
Jacob Fink
2023-07-18 10:17:47 -04:00
parent 1e30524985
commit 5ba3fac0c0
2 changed files with 6 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ namespace Bit.Core.Abstractions
Task SetUserKeyAsync(UserKey userKey);
Task<UserKey> GetUserKeyAsync(string userId = null);
Task<bool> HasUserKeyAsync(string userId = null);
Task<UserKey> MakeUserKeyAsync();
Task ClearUserKeyAsync(string userId = null);
Task SetMasterKeyEncryptedUserKeyAsync(string value, string userId = null);
Task SetMasterKeyAsync(MasterKey masterKey, string userId = null);

View File

@@ -51,6 +51,11 @@ namespace Bit.Core.Services
return await GetUserKeyAsync(userId) != null;
}
public async Task<UserKey> MakeUserKeyAsync()
{
return new UserKey(await _cryptoFunctionService.RandomBytesAsync(64));
}
public async Task ClearUserKeyAsync(string userId = null)
{
await _stateService.SetUserKeyAsync(null, userId);