10
$\begingroup$

I'm currently migrating a project to use the bouncy castle GCM mode. I understand that using an authenticated mode removes the need for a HMAC, however I want to be sure that I'm using this mode correctly. When applying a HMAC to ciphertext, I know it's imperative to include in the HMAC'd data any params that could affect the outcome of the decryption (IV, block-size, algorithm name, etc). The bouncy castle GCM implementation accepts AEAD parameters, one of which is 'Associated Text'.

With authenticated modes, is it correct to:

  • use encryption params as Associated Text
  • encrypt cleartext (without params appended)
  • append params to ciphertext (in cleartext) to facilitate future decryption

I assume this workflow applies to EAX mode as well?

$\endgroup$

1 Answer 1

10
$\begingroup$

GCM mode already incorporates any params that could affect the outcome of the decryption. The associated authenticated data is there to allow you to rely on context for your decryption.

For example, say you are encrypting some records associated with a user. You may want to include the user's database ID as the authenticated data. If a user found a way to copy another user's data and key into his own record, it would still fail to decrypt since his database ID is not the same.

In general, you would like it to be something that's inherently managed separately from the nonce and ciphertext.

$\endgroup$
7
  • 1
    $\begingroup$ Those aren't really useful to include. The KDF should be assumed to be collisionless, so the mere fact that they have the key should be sufficient to prove that they know the password and salt. Also, I believe that the AAD should not be used for any data that must be kept secret (which the password and nonce must be). $\endgroup$ Commented Mar 18, 2013 at 5:43
  • 1
    $\begingroup$ the nonce must be kept secret? I've never used CTR or GCM mode in production, but I understood that it's similar to the IV in CBC mode in that it isn't secret, and can be prepended to the ciphertext in the clear. Is that incorrect? $\endgroup$
    – hunter
    Commented Mar 18, 2013 at 14:38
  • 1
    $\begingroup$ Sorry, the salt for the password should be kept secret. Not the nonce for encryption. $\endgroup$ Commented Mar 18, 2013 at 16:30
  • 1
    $\begingroup$ Sorry to be a pain in the a$$ but I was under the impression that salts (whether for hashes or KDFs) didn't need to be secret. Is there an advantage to keeping them secret? $\endgroup$
    – hunter
    Commented Mar 18, 2013 at 17:02
  • 3
    $\begingroup$ Yep, I'm an idiot. The password is the only component that needs to be kept secret. $\endgroup$ Commented Mar 18, 2013 at 17:40

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.