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);