I'm making a service that will store personal data written about a given user, that should be viewable only by the author and the target. I would like to perform the encryption client-side and store only the resulting garbage on the server.
The internet tells me to use , this will work well for a single users's data.
Problem
For my service, other users are able to enter data that should be viewable only by them and the target user - how might this be accomplished with client side encryption?
Is it possible to do this purely client side?
Update
After considering this, I doubt it can be done purely client side. I have come up with the following possible method:
All traffic uses SSL connection
- Generate a RSA keys, encrypt the private key with AES (using a salted passphrase)
- Salt generated in-browser
- Store the passphrase salt, public key, encrypted private key on the server
All user data encrypted with their public key, decrypted by having them first decrypt their private key in-browser by entering their passphrase, then using the RSA private key to decrypt the data
If the user wishes to share data with another, encrypt said data with the other user's public key
Is my suggested method secure?
Example of what would be stored on server:
+----------+---------------------+---------------+
|Public Key|Encrypted Private Key|Passphrase Salt|
+----------+---------------------+---------------+