mirror of
https://github.com/bitwarden/mobile
synced 2025-12-05 23:53:33 +00:00
Minor refactor
This commit is contained in:
@@ -135,18 +135,17 @@ namespace Bit.Core.Models.Domain
|
|||||||
model.Attachments = new List<AttachmentView>();
|
model.Attachments = new List<AttachmentView>();
|
||||||
var tasks = new List<Task>();
|
var tasks = new List<Task>();
|
||||||
async Task decryptAndAddAttachmentAsync(Attachment attachment, SymmetricCryptoKey decKey)
|
async Task decryptAndAddAttachmentAsync(Attachment attachment, SymmetricCryptoKey decKey)
|
||||||
{
|
{
|
||||||
var decAttachment = await attachment.DecryptAsync(OrganizationId, model.Key ?? decKey);
|
var decAttachment = await attachment.DecryptAsync(OrganizationId, model.Key ?? decKey);
|
||||||
model.Attachments.Add(decAttachment);
|
model.Attachments.Add(decAttachment);
|
||||||
}
|
}
|
||||||
|
var cryptoService = ServiceContainer.Resolve<ICryptoService>();
|
||||||
foreach (var attachment in Attachments)
|
foreach (var attachment in Attachments)
|
||||||
{
|
{
|
||||||
SymmetricCryptoKey decKey = null;
|
SymmetricCryptoKey decKey = null;
|
||||||
//If the cipher.key is null but the attachment.cipherKey has a value we will use it to decrypt the attachment
|
//If the cipher.key is null but the attachment.cipherKey has a value we will use it to decrypt the attachment
|
||||||
if (Key == null && attachment.CipherKey != null)
|
if (Key == null && attachment.CipherKey != null)
|
||||||
{
|
{
|
||||||
var cryptoService = ServiceContainer.Resolve<ICryptoService>();
|
|
||||||
|
|
||||||
var orgKey = await cryptoService.GetOrgKeyAsync(OrganizationId);
|
var orgKey = await cryptoService.GetOrgKeyAsync(OrganizationId);
|
||||||
|
|
||||||
var key = await cryptoService.DecryptToBytesAsync(attachment.CipherKey, orgKey);
|
var key = await cryptoService.DecryptToBytesAsync(attachment.CipherKey, orgKey);
|
||||||
|
|||||||
Reference in New Issue
Block a user