17

I have an app server and a db server. I want to send certain data to the db encrypted, using a DEK (data encryption key). Ideally, this DEK is read protected on the linux file system and encrypted using a KEK (key encryption key). On Windows, I would use DPAPI to protect the KEK, but on Linux, I am unsure the best way to keep this key secure (without an HSM).

I am open to alternate common architectures or paradigms that people use to solve this problem.

1 Answer 1

9

If malicious code can run in the context of the user, DPAPI provides no protection, since said malicious code can simply ask DPAPI to decrypt it.

The only scenario it protects against, is if the data or disk is stolen, but the password is not known. The password can be reset easily but this makes the DPAPI protected data inaccessible. An attacker would have to crack the password hash from the Windows credential cache, but be aware that this is generally a very do-able task. If you know that this is what you have to do you can probably do it in most cases.

Your real problem is "how to easily manage the KEK".

DPAPI takes care of key management by piggy-backing on the Windows password. You would need a PAM module to do this on Linux, and there isn't one.

You should consider piggy-backing on whatever the user is already using, e.g. OSX Keychain, KDE's KWallet, Gnome's GnomeKeyring etc, which I believe have APIs.

If you were using Python, you should consider something like this:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .