I am planning on writing a web-based password management software, in order to provide sharing and permissions functionalities within team groups and members.
EDIT:
As mentioned below by Luke Park, I wanted to add that I am using a user-password authorisation with tokens (which expire). The token is provided on all authorised API calls making these calls only accessible by registered users. And yes, the application is wrapped by SSL making communication between server and client more secure.
END OF EDIT
Currently I have done a lot of research about finding a correct pattern for handling password encryption. The pattern that I am looking at is called Hybrid Encryption since it works with multiple clients and can be implemented securely. Here's how I would implement this pattern in my application logic:
CLIENT WANTS TO CREATE A PASSWORD
- Andre creates a password and provides the password as plain text
- The frontend app generates a symmetric key which is called session key
- The client encrypts the plain password with the session key
- Andre chooses to share the password to Bob
- The client retrieves the Bob's public key from the server application via REST
- The client encrypts the session key with Bob's public key
- Client transfers the encrypted session key and the encrypted password to the server
SERVER APPLICATION HANDLES PASSWORD SUBMISSION
- The server application encrypts the data with a private salt, which is only known by the server application
- Sever stores the data into a database
RETRIEVING SHARED PASSWORDS
- Bob requests Andre's recently shared password
- Server decrypts the requested dataset with the private salt and sends it to the client
- The client decrypts the session key using Bob's private key (which is provided by Bob's computer)
- Using the decrypted session key, the client can decrypt now the password (Now it can be copied for example)
So far, I see this pattern secure enough, since all private keys of the clients are not public and only visible to the clients. In order to implement this in a web-based application, I found openpgpjs.org which can generate public and private keys on client side and encrypt or decrypt data aswell using these keys. On top of that, private key strings can be protected by a secret passphrase.
My question is, how can I implement the private key file into my frontend application without messing up the user experience? I don't want to force the user to manage his private key manually and force him to provide the key on each password request. Is it secure to store the private key file into the browser's local storage and get the private key from local storage on each password request?