From c2d4fa4429b92c9ba111ab46c4bb65bce80e0a09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bispo?= Date: Tue, 11 Jul 2023 23:05:35 +0100 Subject: [PATCH] [PM-2583] Answer auth request with mp field as null if doesn't have it. (#2609) --- src/Core/Services/AuthService.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Core/Services/AuthService.cs b/src/Core/Services/AuthService.cs index 92cbadd3b..9a65072c3 100644 --- a/src/Core/Services/AuthService.cs +++ b/src/Core/Services/AuthService.cs @@ -592,9 +592,14 @@ namespace Bit.Core.Services var publicKey = CoreHelpers.Base64UrlDecode(pubKey); var masterKey = await _cryptoService.GetKeyAsync(); var encryptedKey = await _cryptoService.RsaEncryptAsync(masterKey.EncKey, publicKey); - var encryptedMasterPassword = await _cryptoService.RsaEncryptAsync(Encoding.UTF8.GetBytes(await _stateService.GetKeyHashAsync()), publicKey); + var keyHash = await _stateService.GetKeyHashAsync(); + EncString encryptedMasterPassword = null; + if (!string.IsNullOrEmpty(keyHash)) + { + encryptedMasterPassword = await _cryptoService.RsaEncryptAsync(Encoding.UTF8.GetBytes(keyHash), publicKey); + } var deviceId = await _appIdService.GetAppIdAsync(); - var response = await _apiService.PutAuthRequestAsync(id, encryptedKey.EncryptedString, encryptedMasterPassword.EncryptedString, deviceId, requestApproved); + var response = await _apiService.PutAuthRequestAsync(id, encryptedKey.EncryptedString, encryptedMasterPassword?.EncryptedString, deviceId, requestApproved); return await PopulateFingerprintPhraseAsync(response, await _stateService.GetEmailAsync()); }