Take the 2-minute tour ×  so I am busy writing a TCP protocol in
which I send a "packet header" with each packet of data. This
packet header is a structure that contains information about the
data that was sent. I want to verify whether the header was
tampered with in some manner and I am thinking of using a hash
of the header to ensure it was not tampered with. I want to know
if it is possible to include this hash in the header itself.
Here is what the packet header looks like.      DWORD dwMagic;
BYTE lpvChecksum[32];  ... Rest of header follows  I am not sure
if this method will work and I am open to any other suggestions
on how to verify the header.   share|improve this question add
comment  1 Answer  up vote 3 down vote accepted  First, a hash
does not provide integrity. You would need a MAC (like HMAC) or
a digital signature to ensure the message hasn't changed in
transit.  You'll have to put some standard value (say all zeros)
into the field which holds the MAC, compute the MAC, then insert
the val