SYSV checksum
{{short description|Commonly used, legacy checksum algorithm}}
The SYSV checksum algorithm was a commonly used, legacy checksum algorithm.
It has been implemented in UNIX System V and is also available through the sum command line utility.
This algorithm is useless on a security perspective, and is weaker than the CRC-32 cksum for error detection.{{man/format|1|sum|https://www.gnu.org/software/coreutils/manual/html_node/sum-invocation.html}} — manual pages from GNU coreutils{{man|1|sum|FreeBSD}}
Description of the algorithm
The main part of this algorithm is simply adding up all bytes in a 32-bit sum. As a result, this algorithm has the characteristics of a simple sum:
- re-arranging the same bytes in another order (e.g. moving text from one place to another place) does not change the checksum.
- increasing one byte and decreasing another byte by the same amount does not change the checksum.
- adding or removing zero bytes does not change the checksum.
As a result, many common changes to text data are not detected by this method.
The FreeBSD pseudocode for this algorithm is:
s = sum of all bytes;
r = s % 2^16 + (s % 2^32) / 2^16;
cksum = (r % 2^16) + r / 2^16;
The last part folds the value into 16 bits.
References
{{Reflist}}
Sources
- [https://www.gnu.org/software/coreutils/manual/html_node/sum-invocation.html official GNU sum manual page]
- [https://git.savannah.gnu.org/cgit/coreutils.git/tree/src/sum.c GNU sum source code]