The original formulation of the Corrected Block TEA algorithm, published by David Wheeler and Roger Needham, is as follows: #define DELTA 0x9e3779b9 #define MX ((z>>5^y>3^z 1) { /* Coding Part */ q = 6 + 52/n; while (q-- > 0) { sum += DELTA; e = (sum >> 2) & 3; for (p=0; p> 2) & 3; for (p=n-1; p>0; p--) z = v[p-1], y = v[p] -= MX; z = v[n-1]; y = v[0] -= MX; sum -= DELTA; } return 0; } return 1; } According to Needham and Wheeler: Note that the initialization of z is
Undefined behavior for
n #include #define DELTA 0x9e3779b9 #define MX (((z>>5^y>3^z 1) { /* Coding Part */ rounds = 6 + 52/n; sum = 0; z = v[n-1]; do { sum += DELTA; e = (sum >> 2) & 3; for (p=0; p> 2) & 3; for (p=n-1; p>0; p--) { z = v[p-1]; y = v[p] -= MX; } z = v[n-1]; y = v[0] -= MX; sum -= DELTA; } while (--rounds); } } ==See also==