It was designed by David Wheeler and Roger Needham of the Cambridge Computer Laboratory, first presented at the Fast Software Encryption workshop in Leuven in 1994, and first published in the proceedings of that workshop.
It's an ideal algorithm for testing new frameworks and modes of operation. The first caveat is to make sure your installation produces the proper outputs to reference inputs. Then you can build your framework around it confident that if your output breaks, it's the framework at fault.
The authors suggest in its reference notes that anything you can do with or to DES will work just as well with TEA.
TEA operates on two 32-bit unsigned integers, uses a 128-bit key, and chunks out similar 32-bit unsigned integers. Conveniently you can feed it pointers to character strings of this size and it will cast them to longs.
The original reference implementation accepts three pointers (input,output, key) which makes the necessary CBC mode adapters easier to attach.
Standard usage calls for 64 Feistel rounds which is 32 cycles of the algorithm.
Make n = 32.
The effective key size is 126 bits which is plenty for keeping my diary secure.
Here is the ANSI C implementation I use :
void encipher(unsigned long *const v,unsigned long *const w,
const unsigned long *const k){
register unsigned long
y=v[0],z=v[1],n=32,
sum=0,delta=0x9E3779B9,
a=k[0],b=k[1],c=k[2],d=k[3];
while(n-->0) {
sum += delta;
y += (z << 4)+a ^ z+sum ^ (z >> 5)+b;
z += (y << 4)+c ^ y+sum ^ (y >> 5)+d;
}
w[0]=y; w[1]=z;
}
void decipher(unsigned long *const v,unsigned long *const w,
const unsigned long *const k){
register unsigned long
y=v[0],z=v[1],n=32,
sum=0xC6EF3720,delta=0x9E3779B9,
a=k[0],b=k[1], c=k[2],d=k[3];
while(n-->0) {
z -= (y << 4)+c ^ y+sum ^ (y >> 5)+d;
y -= (z << 4)+a ^ z+sum ^ (z >> 5)+b;
sum -= delta;
}
w[0]=y; w[1]=z;
}
Test Vectors :
Plain Text :
Cipher Key :
Cipher Text :
No comments:
Post a Comment