I have previously implement Client Side Data Encryption using Azure Key Vault using the following approach:
- Every record that needs to be encrypted gets a Content Encryption Key (CEK)
- The content is encrypted symmetrically using this CEK.
- The CEK is then encrypted asymmetrically using a Master Key which is stored in Azure Key Vault.
- The encrypted CEK, the Master Key identifier and the encrypted data are persisted to the Mongo DB.
Decryption Approach: 1. When a User needs decrypted information, the encrypted CEK is first decrypted using the Master Key 2. The decrypted CEK is then used to symmetrically decrypt the encrypted data.
This approach works great if you want to decrypt records one record at a time.
This approach has a performance overhead when you consider decrypting 100s of records at the same time.
For each record, you need to first decrypt the CEK. This is an expensive call over the network using Azure Key Vault Rest API. Imagine someone wanting to export 1000s of decrypted records (as is the case in my scenario now). This would be not just a time consuming operation, but also an expensive one.
Does anyone have any suggestions on how to accomplish this? I have dabbled with the following approaches:
Establish a Key Daily (or Monthly) and use it as a CEK for all of the Day/Month's Orders so that the number of CEKs to decrypt reduces when exporting/pulling reports to view en-masse. Use in-memory caching strategies to cache decrypted CEKs and only make a network call when not decrypted CEK not found in cache.
Establish a one time CEK for the Client and use it for all records.
Don't use a CEK at all and simply encrypt all data using a master key (suicide in my opinion as asymmetric encryption of large data is not recommended at all) and will increase overheads.
Wondering if people have any suggestions!