I'm building a cloud storage application that will store files on my servers.
I want these files to be encrypted with AES in CTR mode and the key will be always the same.
I'm wondering what would be the best way to derive an IV.
The encryption will happen on many servers so I can't use progressive values (e.g. incrementing first 8 bytes for every different encrypted file) since I can't keep count across servers.
Numbers of stored files can reach tens of billions.
What's the best practise in this scenario to derive the IV (or maybe a Key + IV)?
- Should I use only one key that never changes?
- Should I derive a new key for every encrypted file (from the master key)?
If key mustn't be the same, would it be secure to do the following:
- A new key (256-bit) is randomly-generated for every file.
- This key is encrypted with the masterkey in ECB mode (since it's highly entropy data, do we need CBC?)
- The file key is appended at the beginning of the file.