Tiny Encryption Algorithm (TEA)

TEA is an iterated block cipher that encrypts 64 bit blocks using a 128 bit key. It uses a relatively weak nonlinear mixing function over many rounds. The suggested number of rounds in 32, though fewer would probably suffice. There are no precomputed tables, key schedules, etc. TEA is not a Feistel cipher.


Assuming 32 bit words, TEA encryption is given by

(K[0],K[1],K[2],K[3]) = 128 bit key

(L,R) = plaintext

delta = 0x9e3779b9
sum = 0;
for i = 1 to NumberOfRounds
     sum += delta;
     L += ((R << 4) + K[0]) ^ (R + sum) ^ ((R >> 5) + K[1]);
     R += ((L << 4) + K[2]) ^ (L + sum) ^ ((L >> 5) + K[3]);
next i
    
ciphertext = (L,R)

Assuming NumberOfRounds is 32 (otherwise the initial value of sum would need to change), then decryption is accomplished via


sum = delta << 5;
for i = 1 to NumberOfRounds
     R -= ((L << 4) + K[2]) ^ (L + sum) ^ ((L >> 5) + K[3]);
     L -= ((R << 4) + K[0]) ^ (R + sum) ^ ((R >> 5) + K[1]);
     sum -= delta;
next i
    
plaintext = (L,R)