I want to use AES GCM to encrypt data at rest. When retrieving the data, I want to make sure that the key is valid and the data has not been tempered with. Can I store the nonce/iv along with the ciphertext in the database?

  • i thought GCM was authenticated anyway; if you can decrypt it, it hasn't been tampered with...
    – dandavis
    May 30 '16 at 6:35

Absolutely. There is no risk from appending the nounce/iv to encrypted text.

  • > There is know risk from appending the nounce/iv to encrypted text. Did you mean there is no risk?
    – machete
    May 28 '16 at 23:17
  • sorry. Yep I mean NO risk.
    – BMC
    May 29 '16 at 6:26
  • @machete It's funny that you pointed out a spelling error when you wrote "tempered" instead of "tampered"!
    – CJ Dennis
    Mar 29 '18 at 1:48
  • @cj-dennis what is really funny is you picking on a two year old question with a senseless comment like that. There is a huge difference between „no“ and „known“ security vulnerability (in case you didn’t notice). Obviously it’s important to sort that out, which happened. Thank you for your contribution though...
    – machete
    Mar 29 '18 at 12:31
  • 1
    @machete It doesn't matter how old the question is. I had the same question today, which is how I found yours. Two other people have already found your question useful and who knows how many people might visit this question in the future. If I don't know what "nonce" means, I might think that there is a technical term called "tempering the data". It's best to be clear, as you discovered yourself. ;-)
    – CJ Dennis
    Mar 29 '18 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.