Next: About this document Up: Tiger: A Fast New Previous: References

Appendix --- Source for the Compression Function of Tiger

```word64 t1[256] = {...};
word64 t2[256] = {...};
word64 t3[256] = {...};
word64 t4[256] = {...};

TIGER_compression_function (state, block)
word64 state[3];
unsigned word64 block[8];
{
word64 a = state[0], b = state[1], c = state[2];
word64 x0=block[0], x1=block[1], x2=block[2], x3=block[3],
x4=block[4], x5=block[5], x6=block[6], x7=block[7];
word64 aa, bb, cc;

#define save_abc aa = a; bb = b; cc = c;

#define round(a,b,c,x,mul) \
c ^= x; \
a -= t1[((c)>>(0*8))&0xFF] ^ t2[((c)>>(2*8))&0xFF] ^ \
t3[((c)>>(4*8))&0xFF] ^ t4[((c)>>(6*8))&0xFF] ; \
b += t4[((c)>>(1*8))&0xFF] ^ t3[((c)>>(3*8))&0xFF] ^ \
t2[((c)>>(5*8))&0xFF] ^ t1[((c)>>(7*8))&0xFF] ; \
b *= mul;
```

```#define pass(a,b,c,mul) \
round(a,b,c,x0,mul) \
round(b,c,a,x1,mul) \
round(c,a,b,x2,mul) \
round(a,b,c,x3,mul) \
round(b,c,a,x4,mul) \
round(c,a,b,x5,mul) \
round(a,b,c,x6,mul) \
round(b,c,a,x7,mul)

#define key_schedule \
x0 -= x7 ^ 0xA5A5A5A5A5A5A5A5; \
x1 ^= x0; \
x2 += x1; \
x3 -= x2 ^ ((~x1)<<19); \
x4 ^= x3; \
x5 += x4; \
x6 -= x5 ^ ((~x4)>>23); \
x7 ^= x6; \
x0 += x7; \
x1 -= x0 ^ ((~x7)<<19); \
x2 ^= x1; \
x3 += x2; \
x4 -= x3 ^ ((~x2)>>23); \
x5 ^= x4; \
x6 += x5; \
x7 -= x6 ^ 0x0123456789ABCDEF;

#define feedforward a ^= aa; b -= bb; c += cc;

#define compress \
save_abc \
pass(a,b,c,5) \
key_schedule \
pass(c,a,b,7) \
key_schedule \
pass(b,c,a,9) \
feedforward

compress;

state[0] = a; state[1] = b; state[2] = c;
}
```

Eli Biham
Thu Feb 8 15:00:23 IST 1996