3

I've built a CMS system to allow users to create and manage online forms on my client's intranet app.

Of course some of the data handled by the forms may need to be encrypted e.g. if the system is used to build a form that handles salary specifics or whatever. So I'm using the AESManaged class to symmetrically encrypt this sort of data prior to it going into our application db.

All is fine, but now, prior to release, I could do with a steer regarding the shared secret and salt.

My original idea was to make a (dynamic) shared secret by combining the (GUID-based) ID of the Form containing the encrypted field with the (again, GUID-based) id of the Question the field is the answer to:

FormId:QuestionId

My Salt is currently generated the same way, only with the order of Guids reversed ie.

QuestionID:FormID.

I'm new to this stuff so not sure if this a sensible strategy or if I should be doing it some other way?

1
  • 2
    Since it's encryption, it's an IV, not a salt. As kennbrodhagen points out, it should be randomly generated. Also, there's really not a great deal of point encrypting something, then storing it alongside the encryption key. You need to decide what your threat model is, and design your system with that in mind. Mar 8, 2011 at 7:13

1 Answer 1

1

The salt should be a randomly generated value. Its purpose is to make dictionary/brute force attacks more difficult to execute. Wikipedia has a nice article on cryptographic salts: http://en.wikipedia.org/wiki/Salt_(cryptography)

For the shared secret ideally it would not be a value that was stored unencrypted with the data that it was encrypting (such as your ids). It's generally a best practice that the key be chosen somehow by the end-user or admin so that they could rotate it periodically or if some sort of security breach occurred. This password key could be owned by each user of the CMS or perhaps by an admin account. If you have very serious security requirements you could pursue a third-party Key Management Server.

If the main goal here is more of obfuscation and the CMS will not be subject to some form of security audit then something along the lines of your initial idea would do. It would prevent the casual access of the data but would probably not pass an audit against formal standards that would require a random salt, a way to rotate the keys, and a way for the "owner" of the system to change the password such that you yourself could not access the data.

4
  • Thanks for the speedy response. My goal is obfuscation - the system is hosted on a secure intranet and currently doesn't hold state secrets but as its a CMS once running I won't have any say over what it w i l l hold so I guess it should be built as securely as possible. The decryption will be done by the system when, for example, an appropriately authorised super/admin user wants to generate a document based on the form data posted. In this scenario should I persist a global (read 'forms CMS-wide') salt string and persist it somewhere so it can be used to perform the decryption?
    – immutabl
    Mar 4, 2011 at 12:12
  • You'll need the salt to decrypt your content. If you had a unique salt per form the data would be more difficult to crack because you would not have as large amount of data with one thing in common (the salt). Mar 5, 2011 at 12:21
  • 1
    If you go with more obfuscation than audit-proof cryptography you may want to think about how might later on add strong encryption if asked. You might have to add some sort of a "cryptography version" to track so you would know whether to use the obfuscated method or the stronger encryption. Mar 5, 2011 at 12:28
  • 1
    My background is in encrypting files on a disk so we wound up creating a custom file format with a header that could contain metadata describing what encryption algorithm we used and other details. It's paid off because we wound up having to change some details about the encryption later on and we did not have the ability to update all of our existing data so we needed to be able to identify the old method vs. the new when trying to decrypt. Mar 5, 2011 at 12:28

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.