System information
Appendix B. Calculating Packet
Signatures and the Signature Nullifier
The CSI signature algorithm, when applied to a block of data, produces a
unique value that is a function of the specific sequence and number of bytes
under consideration. It is a simple algorithm used in a similar manner as a
Cyclic-Redundancy-Check (CRC). We use the signature algorithm instead of
the CRC primarily for historic reasons.
The following block of code is an example implementation of the signature
algorithm in C. To generate the signature of a block of bytes, initialize the
“seed” to 0xaaaa then pass the pointer to the first byte of the block, specifying
“swath” as the number of bytes in the block. The returned value is the signature
of the block.
// signature algorithm.
// Standard signature is initialized with a seed of
// 0xaaaa. Returns signature. If the function is called
// on a partial data set, the return value should be
// used as the seed for the remainder
typedef unsigned short uint2;
typedef unsigned long uint4;
typedef unsigned char byte;
uint2 calcSigFor(void const *buff, uint4 len, uint2 seed=0xAAAA)
{
uint2 j, n;
uint2 rtn = seed;
byte const *str = (byte const *)buff;
// calculate a representative number for the byte
// block using the CSI signature algorithm.
for (n = 0; n < len; n++)
{
j = rtn;
rtn = (rtn << 1) & (uint2)0x01FF;
if (rtn >= 0x100)
rtn++;
rtn = (((rtn + (j >> 8) + str[n]) & (uint2)0xFF) | (j << 8));
}
return rtn;
} // calcSigFor
In the link level frame, a value called a signature nullifier is used. To calculate
the signature nullifier, first calculate the next “seed”. The next seed is the value
of the signature without the next byte of the sequence added in. The following
code fragment shows the generation of a signature nullifier:
uint2 calcSigNullifier(uint2 sig)
{
// calculate the value for the most significant
// byte then run this value through the signature
// algorithm using the specified signature as seed.
// The calculation is designed to cause the least
// significant byte in the signature to become zero.
B-1