How to use the Tiny Encryption Algorithm to Encrypt and Decrypt

By: Anita Has        Partner: Kristina Suen        Group 2
 

 

The following C code can be used to enipher and decipher a 64-bit packet. The C code should run on most machines.The encipher and decipher routines can be made shorter or faster but this version is meant act as a template for the algorithm.

"This type of algorithm can replace DES in software and is short enough to
write into almost any program on any computer. Although speed is not a strong
objective with 32 cycles( 64 rounds), on one implementation it is three times
as fast as a good software implementation of DES which has 16 rounds."

SOURCE CODE DESCRIPTION


The routines below use addition and subtraction as the reversible operators to provide non linearity.The shift makes all bits of the key and data to be mixed and scattered even further.

INPUT

64 - Bit Data:
Store your data for encryption in long v,
v[0]
v[1]

128 - Bit Key:
Store your keys for encryption in long k,
k[0]
k[1]
k[2]
k[3]

SOURCE CODE

Encipher Routine

Decipher Routine

SAMPLE INPUT/OUTPUT

v[0] = 0x11111111
v[1] = 0x33333333

k[0] = 0x23DD7;
k[1] = 0xF7726;
k[2] = 0x99F2;
k[3] = 0x35313;

>> called encipher routine <<

v[0] = 0xFB5319C8
v[1] = 0x52CE67EA

>> called decipher routine<<

v[0] = 0x11111111
v[1] = 0x33333333