How to provide encryption of user's data that can be performed by multiple (specific) users? Let me explain my dilemma. I'm a software developer and I'm writing a Windows application that should provide encryption of user's data. There could be multiple users in the database, each having their own username and password.

I currently encrypt data as such:


When a user logs in, I use PBKDF2 to authenticate their user name &amp; password.
If login succeeds I keep the hash part from PBKDF2 in RAM &amp; use it later as a key to encrypt and decrypt that user's data using AES-256 algorithm.


This seems to work, except that I now have a new set of requirements that don't work with my scheme above:


There are two types of users: employees and administrators.
Employees can access only their own accounts.
Administrators can access accounts of any other non-admin users.
When new administrators are added, they too should be able to access data of existing non-admin users.


So I was trying to devise a plan for encryption but I can't seem to figure it out.

Any suggestions?
First of all, reuse of keys for multiple purposes is severely frowned upon when it comes to key management. If you just derive a single secret from PBKDF2 for authentication then you can still split it further into multiple keys / password hashes using a KBKDF such as HKDF.

Furthermore, if you want to decrypt data with multiple keys then you can simply create a random "data key" and encrypt that with the keys required.

If the key is a symmetric key then that key may however not be available, especially for the administrators. In that case you could just encrypt with a public key of a key pair generated for that administrator. You can encrypt the private key of that key pair using the symmetric key derived using PBKDF2 and the KBKDF. That way you only need the admin to log in when decryption is required instead of for encryption and decryption.



That said, I'd strongly advice you to hire a data encryption expert if you've got these kind of questions. There may be a lot of other requirements to secure the system.