I am attempting to implement these solutions for multi-user document encryption:
The user's private key is stored in a database and encrypted using a symmetrical cipher, the key to which is the user's password.
My question is how should the private key be kept around so it can be used in subsequent requests? The user's plaintext password is only available during the initial login request so that's the only time it can be used to decrypt the private key.
The options I have thought of include:
- Decrypt the private key on login, keep it in memory, then look it up on subsequent requests
- sending back the private key in the user's JWT (also ensuring the JWT is encrypted)