I am creating an web application which processes user information. As a part of application we are storing this input user information and generated output on server. Since this input and output is sensitive, I am encrypting it using AES 128 bit symmetric key for encryption.

I want to manage the key and its rotation policy. Can somebody help me or point me at the key rotation article.

  1. Where the key should be stored in database or file?
  2. In case of key rotation should I re-encrypt all old input-output files?
  3. How should key rotation be achieved?

1 Answer 1

  1. With symmetric encryption, the level of confidentiality depends on the protection of the keys. Storing the keys on a file is easier than storing the key in a db but you'd have to have protections for the file. Database can provide a more secure storage facility but then you have to manage much more than the contents of the file. When you take into consideration key rotation, storing keys in a database will likely reduce headaches of key management in the future.

  2. It depends - if you have the facility to maintain multiple keys and a way to tie back ciphertext to key, then you wouldn't have to decrypt and re-encrypt data with the new key. This method also requires some sort of key store (see above). However, if you want to maintain just one key, each key rotation will require you decrypt data with the old key and reencrypt with a new key.

  3. Again, it depends. I'd recommend you figure out how important the data is to an adversary now and over the course of its useful life and how much effort you want to exert in this process. I wouldn't recommend rotating keys more frequently than necessary for the sake of security. That'll lead to a management nightmare and you could lock yourself out.

NIST has a great write-up on this topic. The NIST docs lays out what, how, and why. Since the NIST docs and frameworks are published for government use, it's very comprehensive and well structured.

Check out NIST's Special Publications for additional details:

  • SP 800-57 (Recommendations for Key Management) 800-57 (rev 5)
  • SP 800-130 (A framework for designing cryptographic key management systems) 800-130

You must log in to answer this question.