I am designing an end-to-end encrypted file storage system where only the user should be able to access their own data. The best I could come up with is a system designed around a master key that is used to encrypt the main user data. The private key is then encrypted and sent to each client using their respective public key at each device's login.
This system works in theory but it has a few flaws, the biggest being that if the master key is stolen it undermines the entire encryption. Then changing the master key to re-secure the data is impossible without re-encrypting all data, a highly inconvenient task.
My question is what should I be doing here? Does this method suffice?
Detailed Login Flow
To reiterate, this is how the setup/login flow works:
- Client generates new private/public key pair
- Client logs in using credentials and sends new public key
- Server decrypts master key encrypted with separate private key protected by user's password
- Server encrypts master key with user's public key and new returns encrypted private key
- Client decrypts master key and securely stores it locally
This then allows the client to decrypt all future data.