what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

tean.c

tean.c
Posted Dec 21, 1999

tean.c

tags | encryption
SHA-256 | bf326c1977254a4b310d4d2076a0b091fa304abd123a69352df7a647cb6aac8f

tean.c

Change Mirror Download
/**********************************************************
TEA - Tiny Encryption Algorithm
Feistel cipher by David Wheeler & Roger M. Needham
(extended version)
**********************************************************/

#define ROUNDS 32
#define DELTA 0x9e3779b9 /* sqr(5)-1 * 2^31 */

#include "ctypes.h"

/**********************************************************
Input values: k[4] 128-bit key
v[2] 64-bit plaintext block
Output values: v[2] 64-bit ciphertext block
**********************************************************/

void tean(word32 *k, word32 *v, long N) {
word32 y=v[0], z=v[1];
word32 limit,sum=0;
if(N>0) { /* ENCRYPT */
limit=DELTA*N;
while(sum!=limit) {
y+=((z<<4)^(z>>5)) + (z^sum) + k[sum&3];
sum+=DELTA;
z+=((y<<4)^(y>>5)) + (y^sum) + k[(sum>>11)&3];
}
} else { /* DECRYPT */
sum=DELTA*(-N);
while(sum) {
z-=((y<<4)^(y>>5)) + (y^sum) + k[(sum>>11)&3];
sum-=DELTA;
y-=((z<<4)^(z>>5)) + (z^sum) + k[sum&3];
}
}
v[0]=y; v[1]=z;
}

void cl_enc_block(word32 *k, word32 *v) {
tean(k,v,ROUNDS);
}

void cl_dec_block(word32 *k, word32 *v) {
tean(k,v,-ROUNDS);
}
Login or Register to add favorites

File Archive:

September 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Sep 1st
    261 Files
  • 2
    Sep 2nd
    17 Files
  • 3
    Sep 3rd
    38 Files
  • 4
    Sep 4th
    52 Files
  • 5
    Sep 5th
    23 Files
  • 6
    Sep 6th
    27 Files
  • 7
    Sep 7th
    0 Files
  • 8
    Sep 8th
    1 Files
  • 9
    Sep 9th
    16 Files
  • 10
    Sep 10th
    38 Files
  • 11
    Sep 11th
    21 Files
  • 12
    Sep 12th
    40 Files
  • 13
    Sep 13th
    18 Files
  • 14
    Sep 14th
    0 Files
  • 15
    Sep 15th
    0 Files
  • 16
    Sep 16th
    21 Files
  • 17
    Sep 17th
    51 Files
  • 18
    Sep 18th
    23 Files
  • 19
    Sep 19th
    48 Files
  • 20
    Sep 20th
    36 Files
  • 21
    Sep 21st
    0 Files
  • 22
    Sep 22nd
    0 Files
  • 23
    Sep 23rd
    38 Files
  • 24
    Sep 24th
    0 Files
  • 25
    Sep 25th
    0 Files
  • 26
    Sep 26th
    0 Files
  • 27
    Sep 27th
    0 Files
  • 28
    Sep 28th
    0 Files
  • 29
    Sep 29th
    0 Files
  • 30
    Sep 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close