0

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)
  • Just to confirm my understanding: the server needs access to the private key? You can't just have the client decrypt and use it, so that the server never sees the private key's plaintext at all? – CBHacking Jan 27 '20 at 12:21
  • @CBHacking I suppose I could send the encrypted private key back to the user, then it gets decrypted client side and stored somewhere. Then when the document is requested, it is sent to the client encrypted where the user's private key can decrypt it – Grant Golden Jan 27 '20 at 21:09
  • Is it ok to store the private key in the client's local storage? – Grant Golden Jan 27 '20 at 21:18
  • You'd probably want to store it in session storage plus have some expiration on it, so that it gets removed when appropriate whether the user closes their browser or not. Otherwise, though, sure. If you can't trust the browser security, your whole app's security model is hosed. – CBHacking Jan 27 '20 at 23:10

0 Answers0