CRC and CheckSum - CIS 3360 Security in Computing Spring 2010 Handout – Checksum and CRC Prepared by Shafaq Chaudhry Checksum Checksum is a

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CIS 3360 Security in Computing Spring 2010 Handout – Checksum and CRC Prepared by: Shafaq Chaudhry Checksum Checksum is a fixed‐length error‐detecting code that is calculated by the sender for each data block. The data block is then transmitted with the Checksum bits appending at the end. The receiver can check the integrity of the message by computing its own value for the checksum and comparing it with the one received. If the checksums do not match, there was an error in the data block sent. To compute an n‐bit checksum on a data block of m bits, m>n, add the first n bits to the second n bits, ignore the carry bit. Add the third set of n bits to the result, ignore the carry bit. Repeat this process for next n bits in the m bits and so on. Take the 2’s complement of the answer to get the checksum value. Example: Compute the four bit check sum for the message 1001 0011 0101 1010 1001 0011+ 1100 0101+ 0001 1010+ 1011 1’s compliment: 0100 2’s compliment: 0101 Append checksum to the original message, we get: 1001 0011 0101 1010 0101 Example: Compute the four bit check sum for the message 1010 1011 1011 1100 0011 1010 1011+ 0101 1011+ 0000 1100+ 1100 0011+ 1111 1’s compliment: 0000 2’s compliment: 0001 Append checksum to the original message, we get: 1010 1011 1011 1100 0011 0001 Diagrams courtesy Wikipedia http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation Example: Verify the four bit check sum in the message 1010 1101 0101 1011 1010 1010 1101+ 0111 0101+ 1100 1011+ 0111 1010+ 0001 As the result is not 0000, checksum check fails. Example: Verify the four bit check sum in the message 1010 1011 0001 1010 1010 1011 + 0101 0001 + 0110 1010+ 0000 As the result is 0000, checksum succeeds. Cyclic Redundancy Check (CRC) The CRC is a fixed‐length error‐detecting code that is calculated by the sender for each data block and added to the end of the data block sent. The receiver in turn will calculate the CRC and tally it with the CRC received. If both CRCs match, we can assume that the data block arrived without error. If the two CRCs do not match, then an error has occurred and the data needs to be resent. To calculate the CRC, polynomials that follow certain properties are used to perform division on the data block. The remainder of this division is the CRC. We will only consider some of these polynomials and not go into the details of the properties. For four‐bit CRC, some example polynomials are: x4 + x + 1 Coefficients: 1 0011 Coefficients: 1 1011 x4 + x3 + x + 1 For eight‐bit CRC, some example polynomials are: Diagrams courtesy Wikipedia http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation x8 + x2 + x + 1 x8 + x7+ x3 + x2 + 1 Coefficients: 1 0000 0111 Coefficients: 1 1000 1101 Example: Compute the four bit CRC for the message 1001 0011 0101 1010 using the polynomial x4 + x3 + x + 1 NOTE: To compute the n bit CRC, append n 0 bits to the end (x4+x3+x+1) 11011 1001 0011 0101 1010 0000 1101 1000 0000 0000 0000 XOR 0100 1011 0101 1010 0000 0110 1100 0000 0000 0000 XOR 0010 0111 0101 1010 0000 0011 0110 0000 0000 0000 XOR 0001 0001 0101 1010 0000 0001 1011 0000 0000 0000 XOR 0000 1010 0101 1010 0000 0000 1101 1000 0000 0000 XOR 0000 0111 1101 1010 0000 0000 0110 1100 0000 0000 XOR 0000 0001 0001 1010 0000 0000 0001 1011 0000 0000 XOR 0000 0000 1010 1010 0000 0000 0000 1101 1000 0000 XOR 0000 0000 0111 0010 0000 0000 0000 0110 1100 0000 XOR 0000 0000 0001 1110 0000 0000 0000 0001 1011 0000 XOR 0000 0000 0000 0101 0000 0000 0000 0000 0110 1100 XOR Diagrams courtesy Wikipedia http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation 0000 0000 0000 0011 1100 0000 0000 0000 0011 0110 XOR 0000 0000 0000 0000 1010 Append CRC bits to the original message, we get: 1001 0011 0101 1010 1010 Example: Verify the four bit CRC in the message 1010 1101 0101 1011 1010 using the polynomial x4 + x3 + x + 1 (x4+x3+x+1) 11011 1010 1101 0101 1011 1010 1101 1000 0000 0000 0000 XOR 0111 0101 0101 1011 1010 0110 1100 0000 0000 0000 XOR 0001 1001 0101 1011 1010 0001 1011 0000 0000 0000 XOR 0000 0010 0101 1011 1010 0000 0011 0110 0000 0000 XOR 0000 0001 0011 1011 1010 0000 0001 1011 0000 0000 XOR 0000 0000 1000 1011 1010 0000 0000 1101 1000 0000 XOR 0000 0000 0101 0011 1010 0000 0000 0110 1100 0000 XOR 0000 0000 0011 1111 1010 0000 0000 0011 0110 0000 XOR 0000 0000 0000 1001 1010 0000 0000 0000 1101 1000 XOR 0000 0000 0000 0100 0010 0000 0000 0000 0110 1100 XOR Diagrams courtesy Wikipedia http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation 0000 0000 0000 0010 1110 0000 0000 0000 0011 0110 XOR 0000 0000 0000 0001 1000 0000 0000 0000 0001 1011 XOR 0000 0000 0000 0000 0011 As the answer is not 0, CRC check fails. Example: Verify the four bit CRC in the message 1010 1011 0001 using the polynomial x4 + x3 + x + 1 (x4+x3+x+1) 11011 1010 1011 0001 1101 1000 0000 XOR 0111 0011 0001 0110 1100 0000 XOR 0001 1111 0001 0001 1011 0000 XOR 0000 0100 0001 0000 0110 1100 XOR 0000 0010 1101 0000 0011 0110 XOR 0000 0001 1011 0000 0001 1011 XOR 0000 0000 0000 CRC check passes. Example: Verify the four bit CRC in the message 1010 1111 1001 1101 using the polynomial x4 + x3 + x + 1 1010 1111 1001 1101 1101 1000 0000 0000 XOR 0111 0111 1001 1101 Diagrams courtesy Wikipedia http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation 0110 1100 0000 0000 XOR 0001 1011 1001 1101 0001 1011 0000 0000 XOR 0000 0000 1001 1101 0000 0000 1101 1000 XOR 0000 0000 0100 0101 0000 0000 0110 1100 XOR 0000 0000 0010 1001 0000 0000 0011 0110 XOR 0000 0000 0001 1111 0000 0000 0001 1011 XOR 0000 0000 0000 0100 The answer is not 0, CRC check fails. Diagrams courtesy Wikipedia http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation ...
View Full Document

This note was uploaded on 10/05/2010 for the course CIS CIS 3360 taught by Professor Guha during the Spring '10 term at University of Central Florida.

Ask a homework question - tutors are online