Does the Boolean XOR function represent a valid way to verify the integrity of a message ?

  • 2
    $\begingroup$ Hint: What happens if you change two bits? $\endgroup$
    – SEJPM
    Apr 22 '20 at 12:40
  • $\begingroup$ OTP integrity question $\endgroup$
    – kelalaka
    Apr 22 '20 at 13:20

It really depends how you use it.

Per se the XOR operation is not a good way to perform any kind of integrity check because it is very easy to "cancel" a change by doing another change equal to the XOR with the value you want to obtain.

A lot of integrity checks are relying on the XOR operation under the hood to "combine" blocks together, but not without performing further operations on the said blocks.

For instance the CRC-32 algorithm, an error-detecting code is working as follows (pseudo code from Wikipedia):

Function CRC32
      data:  Bytes
      crc32: UInt32 

crc32 ← 0xFFFFFFFF

for each byte in data do
   nLookupIndex ← (crc32 xor byte) and 0xFF;
   crc32 ← (crc32 shr 8) xor CRCTable[nLookupIndex] //CRCTable is an array of constants

crc32 ← crc32 xor 0xFFFFFFFF
return crc32

CRC-32 and the way it uses XOR is good to detect errors in a communication channel, but it is not good to provide an integrity check that would resist intentional, malicious alteration of data.

To resist such cases, you have to use cryptographic schemes, such as the ones discussed in that question. Also notice that hash function do not provide integrity, unlike MAC functions, hash-functions are only about collision resistance, pre-image resistance and second pre-image resistance.


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.