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:

  1. When a user logs in, I use PBKDF2 to authenticate their user name & password.

  2. If login succeeds I keep the hash part from PBKDF2 in RAM & 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?


1 Answer 1


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.

  • $\begingroup$ Thanks. I understand your concern. My goal here is to better understand the encryption part. At this point my application is not distributed for public use. $\endgroup$
    – c00000fd
    Jan 20, 2017 at 18:12
  • $\begingroup$ Just to add up to my research, found this info once I knew what to look for. $\endgroup$
    – c00000fd
    Jan 20, 2017 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.