From 354aec09d9813e46eb3ad34cf9361ab103de7a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Gonc=CC=A7alves?= Date: Mon, 13 May 2024 18:03:43 +0100 Subject: [PATCH] Minor refactor --- src/Core/Models/Domain/Cipher.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Core/Models/Domain/Cipher.cs b/src/Core/Models/Domain/Cipher.cs index 79152eb3c..91c5e63ec 100644 --- a/src/Core/Models/Domain/Cipher.cs +++ b/src/Core/Models/Domain/Cipher.cs @@ -135,18 +135,17 @@ namespace Bit.Core.Models.Domain model.Attachments = new List(); var tasks = new List(); async Task decryptAndAddAttachmentAsync(Attachment attachment, SymmetricCryptoKey decKey) - { + { var decAttachment = await attachment.DecryptAsync(OrganizationId, model.Key ?? decKey); model.Attachments.Add(decAttachment); } + var cryptoService = ServiceContainer.Resolve(); foreach (var attachment in Attachments) { 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 (Key == null && attachment.CipherKey != null) { - var cryptoService = ServiceContainer.Resolve(); - var orgKey = await cryptoService.GetOrgKeyAsync(OrganizationId); var key = await cryptoService.DecryptToBytesAsync(attachment.CipherKey, orgKey);