Download a file in a File Provider Extension in iOS

I am developing a cloud-based application and have integrated the FileProviderExtension. However, files larger than 20 MB are not downloading as it’s throwing a memory limit exception. In this process, I have downloaded the file data, but after downloading the data, I need to decrypt the data. I am getting a memory limit exception during decryption. I am using the below lines to decrypt the data.

      let symmetricKey = SymmetricKey(data: key)
      let sealedBox = try AES.GCM.SealedBox(combined: inputData)
      let decryptedData = try AES.GCM.open(sealedBox, using: symmetricKey)

I am getting memory limit exception at AES.GCM.open(sealedBox, using: symmetricKey)

This is pretty much the same issue as your other thread. Normally I’d just link to that, but there is one extra wrinkle here: How do you do streaming encryption with AES.GCM?

It turns out that you can’t, at least not directly when using Apple CryptoKit. See this thread.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

We are downloading the file chunk by chunk. Even with a chunk size of 5MB, it still reaches the 20MB memory limit. Additionally, we decrypt every chunk using AES.GCM for seal/open API.

5 MiB is a pretty big chunk size given your 20 MiB limit. Can you reduce that?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Download a file in a File Provider Extension in iOS
 
 
Q