I want to assure integrity and authenticity in data sent trough a TLS channel. What are the best techniques? For integrity a hash (sha, bcrypt,...) should do the job right? And for authenticity? Should i use MAC? Or is it the best way to use HMAC and achieve both integrity and authenticity? Thanks for your time!


There is no need to do that manually. A TLS tunnel is not only encrypting the data, it is also guaranteeing the authenticity (and thus integrity) of the data it transmits. This used to be done by a seperate MAC (HMAC, usually), but these days (TLS $\geq 1.2$ and with modern cipher suites) you rather use an AEAD mode for encryption like AES-GCM or ChaCha20-Poly1305.

  • $\begingroup$ If the server certificate is compromised, a hacker can get autenticoty and do man in the midle. Besides that, TLS, does not garantee integrity. If i have the symmetric or both assimetryc key, and the cipher text, and can decrypt, change it , encrypt and send it again, with no trace of changes! So i think i need another method for assuring integrity, with hash key values. $\endgroup$ – rew1nd Jul 12 '17 at 10:19
  • $\begingroup$ Of course, TLS guarantees integrity along with authenticity (of the communication partners who participated in the hadshake). If you servers gets completely compromised and the attackers are able to steal your long term TLS certificate keys along with short term symmetric keys from the memory, than all other measures you devise inside the tunnel will probably fail, too. There might be special circumstances under which encrypting & authenticating data within a TLS tunnel can make sense, but your question doesn't state those. What is your actual use case? What is your threat model? $\endgroup$ – mat Jul 12 '17 at 14:52

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.