Cryptography: best practices for keys in memory?

Posted by Johan on Stack Overflow See other posts from Stack Overflow or by Johan
Published on 2009-08-11T22:32:14Z Indexed on 2010/03/24 16:03 UTC
Read the original article Hit count: 286

Filed under:
|
|
|

Background: I got some data encrypted with AES (ie symmetric crypto) in a database. A server side application, running on a (assumed) secure and isolated Linux box, uses this data. It reads the encrypted data from the DB, and writes back encrypted data, only dealing with the unencrypted data in memory. So, in order to do this, the app is required to have the key stored in memory.

The question is, is there any good best practices for this? Securing the key in memory.

A few ideas:

  1. Keeping it in unswappable memory (for linux: setting SHM_LOCK with shmctl(2)?)
  2. Splitting the key over multiple memory locations.
  3. Encrypting the key. With what, and how to keep the...key key.. secure?
  4. Loading the key from file each time its required (slow and if the evildoer can read our memory, he can probably read our files too)

Some scenarios on why the key might leak: evildoer getting hold of mem dump/core dump; bad bounds checking in code leading to information leakage;

The first one seems like a good and pretty simple thing to do, but how about the rest? Other ideas? Any standard specifications/best practices?

Thanks for any input!

© Stack Overflow or respective owner

Related posts about cryptography

Related posts about aes