Platforma unica de radiocomunicatii TETRA
TETRA (Terrestrial Trunked Radio) este un standard dezvoltat de European Telecommunications Standards Institute (ETSI). Este o platforma comuna de radiocomunicatii utilizata de S.T.S. ( Serviciul de Telecomunicatii Speciale) in asigurarea telecomunicatiilor guvernamentale si ale altor organisme statale.
Definitii prealabile:
-algoritm de criptare: o functie matematica ce cripteaza si decripteaza date.
-Block codes: cele mai raspandite algoritme de criptare, care cripteaza datele prin utilizarea de pachete (blocuri) de anumite marimi si transforma datele cu chei in blocuri de aceeasi marime.
-Blowfish: unul dintre cei mai puternici algoritmi de criptare, dezvoltat de guru criptografiei Bruce Schneier. Marimea blocurilor este de 64 biti iar marimea cheii de criptare pana la 448 biti.
-CAST: un algoritm dependent de o cheie de 64 biti. A fost dezvoltat de .M. Adams si S.E. Tavares ca un competitor pentru criptarea AES.
-DES: algoritm de criptare standard, folosit in SUA. Acest standard a fost compromis ( poate fi decriptat de orice computer modern in doua zile), a fost inlocuit cu algoritmul AES. A fost dezvoltat de National Institute of Standards and Technology (NIST).
-GOST: algoritm de criptare sovietic, creat de KGB la sfarsitul anilor 70. Functioneaza cu blocuri de 64 biti iar marimea cheii este de maxim 256 biti. In ciuda catorva "gauri" de securitate, este considerat a fi inca functional. Este algoritmul standard de criptare al Federatiei Ruse.
-Rijndael: algoritm de criptare dezvoltat de oan Daemen si Vincent Rijmen. Intruneste standardele AES (Advanced Encryption Standard). Foloseste chei de diferite marimi (128, 192 si 256 biti) si blocuri de marime egala.
-Twofish: algoritm care a inlocuit Blowfish. Dezvoltat de Bruce Schneier si predecesorii sai. Este considerat a fi hack-proof (nu au fost raportate spargeri ale algoritmului).
-3DES: utilizeaza algoritmul DES, la sunt aplicate de trei ori chei diferite, ceea ce ii creste nivelul de securitate in comparatie cu DES, dar care este totusi vulnerabil.
-RC4: algoritm de criptare stream, utilizat in criptarea retelelor ( de exemplu protocolul SSL utilizat la criptarea parolelor in Netscape si Windows NT). Avantaje: viteza foarte mare de criptare/decriptare si marimea ajustabila a cheilor. Algoritmul a fost dezvoltat de Ronald Rivest. RC vine de la "Ron's Code" ori "Rivest Cipher".
-Serpent: dezvoltat de faimosul criptograf si criptoanalist Lars Ramkilde Knudsen (in prezent profesor de matematica la Denmark's Technical University). Algoritmul este faimos pentru succesul unor cripto-atacuri reusite prin cateva coduri populare.
-Tea: algoritm puternic de criptare (Tiny Encryption Algorithm). Caracteristica cea mai importanta: marimea foarte mica. Tea este foarte simplu pentru ca nu utilizeaza tabele valorice si este optimizat pentru procesoare cu arhitectura de 32 biti, ceea ce face posibila utilizarea unui ASSEMBLER chiar si atunci cand marimea codului este extrem de mica. Neajunsuri: viteza mica de lucru si necesitatea utilizarii unor solutii "data scrambling" din moment ce nu sunt utilizate nici un fel de tabele criptografice.
Dictionary attack: o metoda de cripto-atac care utilizeaza dictionare digitale obisnuite care contin cuvinte populare. Aceasta metoda este ineficienta atunci cand sunt utilizate chei fara inteles.
-BruteForce: cea mai utilizata metoda de cripto-atac. A fost numita "brute force" deoarece atacatorul incearca sa descifreze cheia de criptare prin combinarea diferitelor simboluri, litere si cifre. Operatiunea este efectuata de computere. Pentru a afla o cheie de criptare de 128 biti cu ajutorul acestei metode sunt necesari cativa ani. Cu cat in parola/cheie vor fi utilizate mai multe caractere, cu atat mai lunga va fi perioada necesara decriptarii (sute de ani).
S.T.S.(SERVICIUL de TELECOMUNICATII SPECIALE ) foloseste platforma integrara de radiocomunicatii TETRA(http://www.tetramou.com/) . Acest sistem foloseste criptarea XXTea (Tea2). Metoda de criptare Tea a fost imaginata de David Wheeler si Roger Needham de la Cambridge Computer Laboratory si prezentata pentru prima data la un workshop (Fast Software Encryption) in Leuven in anul 1994.
Terminale certificate de S.T.S pentru uzul in cadrul platformei TETRA:
-Motorola MTH 500
-Motorola MTH 800
-Motorola MTH 800L
-Motorola MTP 850
-Motorola MTM 800
-Motorola MTM 800 ENH
-Motorola MTC 100
-SEPURA SRG3500
-SEPURA SRH3500 MODEL sGPS TN
-SEPURA SRM3500
-SEPURA SRH3800 sGPS
-SEPURA SRC3300 sGPS
-SEPURA SERIA STP8000 MODEL STP 8038 PSNTW201T300P0001
-EADS THR880i MODEL RC-2
-EADS THR880i MODEL RC-7
-EADS THR880i MODEL RC-9
-TELTRONIC HTT-500
-TELTRONIC MDT 400
NOTA: sunt functionale si in exploatare si Tea3 si Tea4. Tea2 a fost creat pentru utilizatorii din cadrul sistemelor de siguranta nationala din spatiul Schengen si tarile europene. Conform producatorilor, Tea2 este imbatabil atat impotriva incercarilor de interceptare, cat si a incercarilor de monitorizare si analizare a traficului radio. Tea3 si Tea4 au o plaja mare de utilizare, de la utilizari comerciale la cele care implica securitatea nationala.
Proprietati Tea:
Tea opereaza cu blocuri de 64 de biti si utilizeaza chei de 128 biti. Are o structura Feistel cu 64 de runde implementate in perechi numite cicluri. Programul de chei Tea este extrem de simplu, mixand toate cheile in exact acelasi fel pentru fiecare ciclu. Este utilizata o "constanta magica" in generarea cheilor multiple, pentru prevenirea cripto-atacurilor bazate pe simetria rundelor. Constanta magica este 2654435769 sau este alasa prin metoda ratiei de aur.
Tea are insa o serie de slabiciuni. Cea mai importanta este aceea ca Tea este vulnerabil din cauza echivalentei cheilor de criptare: fiecare cheie este echivalenta cu alte trei chei, ceea ce inseamna ca marimea efectiva a cheii de criptare este 126 biti. Rezultatul este ca Tea este vulnerabil la capitolul functiei criptografice hash. De exemplu, aceasta slabiciune a dus la hacking-ul consolei de jocuri Xbox, unde cheia utilizata a fost functie hash.
Marimea neobisnuit de mica a algoritmului Tea il face o optiune viabila pentru situatiile in care hardware-ul dispune de un RAM minim.
Vectori de test pentru algoritmul Tea:
================================================
Test Vectors for TEA and XTEA
tean values
These are made by starting with a vector of 6 zeroes,
data followed by key, and coding with one cycle then
moving the six cyclically so that n becomes n-1 modulo 6.
We repeat with 2-64 cycles printing at powers of 2 in
hexadecimal. The process is reversed decoding back
to the original zeroes which are printed.
1 0 9e3779b9 0 0 0 0
2 ec01a1de aaa0256d 0 0 0 0
4 bc3a7de2 4e238eb9 0 0 ec01a1de 114f6d74
8 31c5fa6c 241756d6 bc3a7de2 845846cf 2794a127 6b8ea8b8
16 1d8e6992 9a478905 6a1d78c8 8c86d67 2a65bfbe b4bd6e46
32 d26428af a202283 27f917b1 c1da8993 60e2acaa a6eb923d
64 7a01cbc9 b03d6068 62ee209f 69b7afc 376a8936 cdc9e923
1 0 0 0 0 0 0
tea does the same but the number of iterations
is constant at 32
1 41ea3a0a 94baa940 0 0 0 0
2 4e8e7829 7d8236d8 0 0 0 41ea3a0a
4 b84e28af b6b62088 0 41ea3a0a 4e8e7829 c88ba95e
8 5ddf75d9 7a4ce68f b84e28af a0a47295 ed650698 1024eea0
16 4ec5d2e2 5ada1d89 a9c3801a 32a1e654 8b63bb9 21410574
32 7d2c6c57 7a6adb4d 69c53e0f 60388ada df70a1f5 d9cb4e09
64 2bb0f1b3 c023ed11 5c60bff2 7072d01c 4513c5eb 8f3a38ab
1 0 0 0 0 0 0
The program used follows.
................................................................
/* make test vectors for tea xtea */
void code(long *v, long *k);
void decode(long *v, long *k);
#include
#include
#include
main(long argc, long *argv[])
{ static long pz[1024], n, m;
repeat:
for (n = 1; n < 65; n++)
{ if (m)
code(pz + n, pz + n + 2);
else
tean(pz + n, pz + n + 2, n);
if (n == (n & -n)) /* if n power of 2 */
printf("\n%3d %8x %8x %8x %8x %8x %8x",
n, pz[n], pz[n + 1], pz[n + 2],
pz[n + 3], pz[n + 4], pz[n + 5]);
pz[n + 6] = pz[n];
}
for (n = 64; n > 0; n--)
{ pz[n] = pz[n + 6];
if (m == 0)
tean(pz + n, pz + n + 2, -n);
else
decode(pz + n, pz + n + 2);
}
n = 1;
printf("\n%3d %8x %8x %8x %8x %8x %8x\n",
n, pz[n], pz[n + 1], pz[n + 2],
pz[n + 3], pz[n + 4], pz[n + 5]);
if (m++ == 0) goto repeat;
exit(0);
}
/* TEA code and decode given below */
void code(long *v, long *k)
{ unsigned long y = v[0],
z = v[1],
sum = 0, /* set up */
delta = 0x9e3779b9,
n = 32,
a = k[0],
b = k[1],
c = k[2],
d = k[3];
while (n-- > 0) /* basic cycle start */
{ sum += delta;
y += (z << 4) + a ^ z + sum ^ (z >> 5) + b;
z += (y << 4) + c ^ y + sum ^ (y >> 5) + d; /* end cycle */
}
v[0] = y;
v[1] = z;
}
void decode(long *v, long *k)
{ unsigned long n = 32,
sum,
y = v[0],
z = v[1],
delta = 0x9e3779b9,
a = k[0],
b = k[1],
c = k[2],
d = k[3];
sum = delta << 5;
/* start cycle */
while (n-- > 0)
{ z -= (y << 4) + c ^ y + sum ^ (y >> 5) + d;
y -= (z << 4) + a ^ z + sum ^ (z >> 5) + b;
sum -= delta;
}
/* end cycle */
v[0] = y;
v[1] = z;
}
/* XTEA is a version of slightly improved tea.
The plain or cypher text is in v[0], v[1].
The key is in k[n], where n = 0 - 3,
The number of coding cycles is given by N and
the number of decoding cycles given by -N */
tean(long *v, long *k, long N) /* replaces TEA's code and decode */
{ unsigned long y = v[0],
z = v[1],
DELTA = 0x9e3779b9,
limit,
sum;
if (N > 0) /* coding */
{ limit = DELTA * N;
sum = 0;
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 /* decoding */
{ 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;
return;
}
=================================================================
==va urma==
Coduri sursa pt algoritmul TEA:
=====================================================
ANSI C
void encipher(unsigned long *const v,unsigned long *const w,
const unsigned long *const k)
{
register unsigned long y=v[0],z=v[1],sum=0,delta=0x9E3779B9,
a=k[0],b=k[1],c=k[2],d=k[3],n=32;
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],sum=0xC6EF3720,
delta=0x9E3779B9,a=k[0],b=k[1],
c=k[2],d=k[3],n=32;
/* sum = delta~~5, in general sum = delta * n */
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;
}
Motorola PowerPC (Metrowerks CodeWarrior Style)
asm void encipher(register const unsigned long * const v,
register unsigned long * const w,
register const unsigned long * const k)
{
// On entry, v = r3, w = r4, k = r5
// use r3 and r5 as scratch
// r0 = v[0]
// r6 = v[1]
// r7 - r10 = k[0] - k[3]
// r11 = sum
// r12 = delta
li r11,0 // sum = 0
li r12,0x79B9 // delta =0x9E3779B9
addis r12,r12,0x9E37
li r0,16 // loop counter into count register
mtctr r0
lwz r0,0(r3) // put the contents of v and k into the registers
lwz r6,4(r3)
lwz r7,0(r5)
lwz r8,4(r5)
lwz r9,8(r5)
lwz r10,12(r5)
loop: add r11,r11,r12 // sum += delta
slwi r5,r6,4 // z ~~ 4
add r5,r5,r7 // (z ~~ 4) + a
add r3,r6,r11 // z + sum
xor r3,r5,r3 // ((z ~~ 4) + a) ^ (z + sum)
srwi r5,r6,5 // z >> 5
add r5,r5,r8 // (z >> 5) + b
xor r3,r5,r3 // ((z ~~ 4)+a)^(z+sum)^((z >> 5)+b);
add r0,r0,r3 // y += result
slwi r5,r0,4 // y ~~ 4
add r5,r5,r9 // (y ~~ 4) +c
add r3,r0,r11 // y + sum
xor r3,r5,r3 // ((y ~~ 4) +c) ^ (y + sum)
srwi r5,r0,5 // y >> 5
add r5,r5,r10 // (y >> 5) + d
xor r3,r5,r3 // ((y ~~ 4)+c)^(y+sum)^((y >> 5)+d);
add r6,r6,r3 // z += result
bdnz+ loop // decrement CTR and branch
stw r0,0(r4) // store result back in w
stw r6,4(r4)
blr
}
asm void decipher(register const unsigned long * const v,
register unsigned long * const w,
register const unsigned long * const k)
{
// On entry, v = r3, w = r4, k = r5
// use r3 and r5 as scratch
// r0 = v[0]
// r6 = v[1]
// r7 - r10 = k[0] - k[3]
// r11 = sum
// r12 = delta
li r11,0x9B90; // sum =0xE3779B90
addis r11,r11,0xE378;
li r12,0x79B9 // delta =0x9E3779B9
addis r12,r12,0x9E37
li r0,16 // loop counter into count register
mtctr r0
lwz r0,0(r3) // put the contents of v and k into the registers
lwz r6,4(r3)
lwz r7,0(r5)
lwz r8,4(r5)
lwz r9,8(r5)
lwz r10,12(r5)
loop: slwi r5,r0,4 // y ~~ 4
add r5,r5,r9 // (y ~~ 4) + c
add r3,r0,r11 // y + sum
xor r3,r5,r3 // ((y ~~ 4) + c) ^ (y + sum)
srwi r5,r0,5 // y >> 5
add r5,r5,r10 // (y >> 5) + d
xor r3,r5,r3 // ((y ~~ 4)+c)^(y+sum)^((y >> 5)+d)
sub r6,r6,r3 // z -= result
slwi r5,r6,4 // z ~~ 4
add r5,r5,r7 // (z ~~ 4) + a
add r3,r6,r11 // z + sum
xor r3,r5,r3 // ((z ~~ 4) + a) ^ (z + sum)
srwi r5,r6,5 // z >> 5
add r5,r5,r8 // (z >> 5) + b
xor r3,r5,r3 // ((z ~~ 4)+a)^(z+sum)^((z >> 5)+b);
sub r0,r0,r3 // y -= result
sub r11,r11,r12 // sum -= delta
bdnz+ loop // decrement CTR and branch
stw r0,0(r4) // store result back in w
stw r6,4(r4)
blr
}
Motorola 680x0 (Metrowerks CodeWarrior style):
asm void encipher(const unsigned long* const v,unsigned long* const w,
const unsigned long* const k)
{
fralloc
movem.l d3-d7/a2,-(a7)
/* load initial registers
d0: y = v[0]
d1: z = v[1]
d2: a = k[0]
d3: b = k[1]
d4: c = k[2]
d5: loop counter (k[3] in a2)
d6: scratch register 1
d7: scratch register 2
a0: sum
a1: delta = 0x9E3779B9;
a2: d = k[3] */
move.l v,a0
move.l (a0),d0
move.l 4(a0),d1
move.l k,a0
move.l (a0),d2
move.l 4(a0),d3
move.l 8(a0),d4
move.l 12(a0),a2
move.l #0x9E3779B9,a0
move.l #0x9E3779B9,a1
moveq.l #15,d5 // sixteen rounds
// d6 = (z<<4)+a
loop: move.l d1,d6
lsl.l #4,d6
add.l d2,d6
// d7 = z+sum
move.l d1,d7
add.l a0,d7
// d7 = ((z<<4)+a)^(z+sum)
eor.l d6,d7
// d6 = (z>>5)+b
move.l d1,d6
lsr.l #5,d6
add.l d3,d6
// d7 = ((z<<4)+a)^(z+sum)^((z>>5)+b)
eor.l d6,d7
// add back into y
add.l d7,d0
// d6 = (y<<4)+c
move.l d0,d6
lsl.l #4,d6
add.l d4,d6
// d7 = y+sum
move.l d0,d7
add.l a0,d7
// d7 = ((y<<4)+c)^(y+sum)
eor.l d6,d7
// d6 = (y>>5)+d
move.l d0,d6
lsr.l #5,d6
add.l a2,d6
// d7 = ((y<<4)+c)^(y+sum)^((y>>5)+d)
eor.l d6,d7
// add back into z
add.l d7,d1
// sum+=delta
adda.l a1,a0
// branch back and do it again
dbra d5,loop
// place the result back into w
move.l w,a0
move.l d0,(a0)
move.l d1,4(a0)
movem.l (a7)+,d3-d7/a2
frfree
rts
}
asm void decipher(const unsigned long *const v,unsigned long *const w,
const unsigned long *const k)
{
fralloc
movem.l d3-d7/a2,-(a7)
/* load initial registers
d0: y = v[0]
d1: z = v[1]
d2: a = k[0]
d3: b = k[1]
d4: c = k[2]
d5: loop counter (k[3] in a2)
d6: scratch register 1
d7: scratch register 2
a0: sum = 0xE3779B90 (delta * 16)
a1: delta = 0x9E3779B9;
a2: d = k[3] */
move.l v,a0
move.l (a0),d0
move.l 4(a0),d1
move.l k,a0
move.l (a0),d2
move.l 4(a0),d3
move.l 8(a0),d4
move.l 12(a0),a2
move.l #0xE3779B90,a0
move.l #0x9E3779B9,a1
moveq.l #15,d5 // sixteen rounds
// d6 = (y<<4)+c
loop: move.l d0,d6
lsl.l #4,d6
add.l d4,d6
// d7 = y+sum
move.l d0,d7
add.l a0,d7
// d7 = ((y<<4)+c)^(y+sum)
eor.l d6,d7
// d6 = (y>>5)+d
move.l d0,d6
lsr.l #5,d6
add.l a2,d6
// d7 = ((y<<4)+c)^(y+sum)^((y>>5)+d)
eor.l d6,d7
// subtract from z
sub.l d7,d1
// d6 = (z<<4)+a
move.l d1,d6
lsl.l #4,d6
add.l d2,d6
// d7 = z+sum
move.l d1,d7
add.l a0,d7
// d7 = ((z<<4)+a)^(z+sum)
eor.l d6,d7
// d6 = (z>>5)+b
move.l d1,d6
lsr.l #5,d6
add.l d3,d6
// d7 = ((z<<4)+a)^(z+sum)^((z>>5)+b)
eor.l d6,d7
// subtract from y
sub.l d7,d0
// sum-=delta
suba.l a1,a0
// branch back and do it again
dbra d5,loop
// place the result back into w
move.l w,a0
move.l d0,(a0)
move.l d1,4(a0)
movem.l (a7)+,d3-d7/a2
frfree
rts
}
ANSI C (New Variant)
void encipher(const unsigned long *const v,unsigned long *const w,
const unsigned long * const k)
{
register unsigned long y=v[0],z=v[1],sum=0,delta=0x9E3779B9,n=32;
while(n-->0)
{
y += (z << 4 ^ z >> 5) + z ^ sum + k[sum&3];
sum += delta;
z += (y << 4 ^ y >> 5) + y ^ sum + k[sum>>11 & 3];
}
w[0]=y; w[1]=z;
}
void decipher(const unsigned long *const v,unsigned long *const w,
const unsigned long * const k)
{
register unsigned long y=v[0],z=v[1],sum=0xC6EF3720,
delta=0x9E3779B9,n=32;
/* sum = delta<<5, in general sum = delta * n */
while(n-->0)
{
z -= (y << 4 ^ y >> 5) + y ^ sum + k[sum>>11 & 3];
sum -= delta;
y -= (z << 4 ^ z >> 5) + z ^ sum + k[sum&3];
}
w[0]=y; w[1]=z;
}
16-bit x86 (New Variant)
-Rafael R Sevilla a contribuit la aceasta versiune(implementarea algoritmului XTEA in 16-bit 80x86 )
.text
export _xtea_encipher_asm
_xtea_encipher_asm:
push bp
mov bp,sp
sub sp,#14 ; space for y, z, sum, and n
push si
push di
;; bp+8 = pointer to key information
;; bp+6 = pointer to ciphertext to return to caller
;; bp+4 = pointer to plaintext
;; bp+2 = return address from caller
;; bp = pushed bp
;; bp-2 = y high word
;; bp-4 = y low word
;; bp-6 = z high word
;; bp-8 = z low word
;; bp-10 = sum high word
;; bp-12 = sum low word
;; bp-14 = n
;; bp-16 = pushed si
;; bp-18 = pushed di
mov bx,[bp+4] ; get address of plaintext
mov ax,[bx] ; low word of first dword of plaintext
mov [bp-4],ax
mov ax,[bx+2] ; high word
mov [bp-2],ax
mov ax,[bx+4] ; second dword of plaintext (low)
mov [bp-8],ax
mov ax,[bx+6] ; (high)
mov [bp-6],ax
xor ax,ax ; zero the sum initially
mov [bp-10],ax
mov [bp-12],ax
mov byte ptr [bp-14],#32 ; set n (just 8 bits), # rounds
;; begin encryption
encipher_rounds:
;; compute new y
mov ax,[bp-8] ; low word z
mov bx,[bp-6] ; high word z
mov cx,ax ; copy to the rest of the registers
mov dx,bx
mov si,ax
mov di,bx
;; (z~~4) ^ (z>>5)
shl ax,#1 ; shift left once
rcl bx,#1
shl ax,#1 ; shift twice
rcl bx,#1
shl ax,#1 ; shift three times
rcl bx,#1
shl ax,#1 ; shift four times
rcl bx,#1
shr dx,#1 ; shift right once
rcr cx,#1
shr dx,#1 ; shift right twice
rcr cx,#1
shr dx,#1 ; shift right three times
rcr cx,#1
shr dx,#1 ; shift right four times
rcr cx,#1
shr dx,#1 ; shift right five times
rcr cx,#1
xor ax,cx ; combine
xor dx,bx ; dx:ax has result
xor si,[bp-12] ; combine to sum
xor di,[bp-10]
add ax,si ; add them together
adc dx,di
mov bx,[bp-12] ; get low word of sum (all we need for this)
and bx,#3 ; get low two bits (modulo 4)
shl bx,#1 ; convert to dword offset
shl bx,#1
add bx,[bp+8] ; add to base address of key info
add ax,[bx] ; low word of key
adc dx,[bx+2] ; high word of key
add [bp-4],ax ; add back to y
adc [bp-2],dx
;; update sum
mov ax,#0x79b9 ; low word of delta
add [bp-12],ax
mov ax,#0x9e37 ; high word of delta
adc [bp-10],ax
;; compute new z
mov ax,[bp-4] ; low word of y
mov bx,[bp-2] ; high word of y
mov cx,ax ; copy to the rest of the registers
mov dx,bx
mov si,ax
mov di,bx
;; (y~~4) ^ (y>>5)
shl ax,#1 ; shift left once
rcl bx,#1
shl ax,#1 ; shift twice
rcl bx,#1
shl ax,#1 ; shift three times
rcl bx,#1
shl ax,#1 ; shift four times
rcl bx,#1
shr dx,#1 ; shift right once
rcr cx,#1
shr dx,#1 ; shift right twice
rcr cx,#1
shr dx,#1 ; shift right three times
rcr cx,#1
shr dx,#1 ; shift right four times
rcr cx,#1
shr dx,#1 ; shift right five times
rcr cx,#1
xor ax,cx ; combine
xor dx,bx ; dx:ax has result
xor si,[bp-12] ; combine to sum
xor di,[bp-10]
add ax,si ; add them together
adc dx,di
mov bx,[bp-12] ; get sum low word
mov cx,[bp-10] ; get sum high word
shr cx,#1 ; shift right once
rcr bx,#1
shr cx,#1 ; shift right twice
rcr bx,#1
shr cx,#1 ; shift right three times
rcr bx,#1
shr cx,#1 ; shift right four times
rcr bx,#1
shr cx,#1 ; shift right five times
rcr bx,#1
shr cx,#1 ; shift right six times
rcr bx,#1
shr cx,#1 ; shift right seven times
rcr bx,#1
shr cx,#1 ; shift right eight times
rcr bx,#1
shr cx,#1 ; shift right nine times
rcr bx,#1
shr cx,#1 ; shift right ten times
rcr bx,#1
shr cx,#1 ; shift right eleven times
rcr bx,#1
and bx,#3
shl bx,#1 ; convert to dword offset
shl bx,#1
add bx,[bp+8] ; add to base address of key
add ax,[bx] ; low word of key
adc dx,[bx+2] ; high word of key
add [bp-8],ax ; add back to z
adc [bp-6],dx
dec byte ptr [bp-14] ; decrement rounds counter
jz finish_encipher
jmp near encipher_rounds
finish_encipher:
mov bx,[bp+6] ; get address of ciphertext storage
mov ax,[bp-4] ; y, low word
mov [bx],ax
mov ax,[bp-2] ; y, high word
mov [bx+2],ax
mov ax,[bp-8] ; z, low word
mov [bx+4],ax
mov ax,[bp-6] ; z, high word
mov [bx+6],ax
pop di
pop si
add sp,#14 ; discard local vars
pop bp
ret
export _xtea_decipher_asm
_xtea_decipher_asm:
push bp
mov bp,sp
sub sp,#14 ; space for y, z, sum, and n
push si
push di
;; bp+8 = pointer to key information
;; bp+6 = pointer to plaintext to return to caller
;; bp+4 = pointer to ciphertext
;; bp+2 = return address from caller
;; bp = pushed bp
;; bp-2 = y high word
;; bp-4 = y low word
;; bp-6 = z high word
;; bp-8 = z low word
;; bp-10 = sum high word
;; bp-12 = sum low word
;; bp-14 = n
;; bp-16 = pushed si
;; bp-18 = pushed di
mov bx,[bp+4] ; get address of ciphertext
mov ax,[bx] ; low word of first dword of ciphertext
mov [bp-4],ax
mov ax,[bx+2] ; high word
mov [bp-2],ax
mov ax,[bx+4] ; second dword of ciphertext (low)
mov [bp-8],ax
mov ax,[bx+6] ; (high)
mov [bp-6],ax
mov ax,#0x3720 ; low word of initial sum
mov [bp-12],ax
mov ax,#0xc6ef
mov [bp-10],ax
mov byte ptr [bp-14],#32 ; set n (just 8 bits), # rounds
;; begin decryption
decipher_rounds:
mov ax,[bp-4] ; low word of y
mov bx,[bp-2] ; high word of y
mov cx,ax ; copy to the rest of the registers
mov dx,bx
mov si,ax
mov di,bx
;; (y~~4) ^ (y>>5)
shl ax,#1 ; shift left once
rcl bx,#1
shl ax,#1 ; shift twice
rcl bx,#1
shl ax,#1 ; shift three times
rcl bx,#1
shl ax,#1 ; shift four times
rcl bx,#1
shr dx,#1 ; shift right once
rcr cx,#1
shr dx,#1 ; shift right twice
rcr cx,#1
shr dx,#1 ; shift right three times
rcr cx,#1
shr dx,#1 ; shift right four times
rcr cx,#1
shr dx,#1 ; shift right five times
rcr cx,#1
xor ax,cx ; combine
xor dx,bx ; dx:ax has result
xor si,[bp-12] ; combine to sum
xor di,[bp-10]
add ax,si ; add them together
adc dx,di
mov bx,[bp-12] ; get sum low word
mov cx,[bp-10] ; get sum high word
shr cx,#1 ; shift right once
rcr bx,#1
shr cx,#1 ; shift right twice
rcr bx,#1
shr cx,#1 ; shift right three times
rcr bx,#1
shr cx,#1 ; shift right four times
rcr bx,#1
shr cx,#1 ; shift right five times
rcr bx,#1
shr cx,#1 ; shift right six times
rcr bx,#1
shr cx,#1 ; shift right seven times
rcr bx,#1
shr cx,#1 ; shift right eight times
rcr bx,#1
shr cx,#1 ; shift right nine times
rcr bx,#1
shr cx,#1 ; shift right ten times
rcr bx,#1
shr cx,#1 ; shift right eleven times
rcr bx,#1
and bx,#3
shl bx,#1 ; convert to dword offset
shl bx,#1
add bx,[bp+8] ; add to base address of key
add ax,[bx] ; low word of key
adc dx,[bx+2] ; high word of key
sub [bp-8],ax ; subtract from z
sbb [bp-6],dx
;; update sum
mov ax,#0x79b9 ; low word of delta
sub [bp-12],ax
mov ax,#0x9e37 ; high word of delta
sbb [bp-10],ax
;; compute new y
mov ax,[bp-8] ; low word z
mov bx,[bp-6] ; high word z
mov cx,ax ; copy to the rest of the registers
mov dx,bx
mov si,ax
mov di,bx
;; (z~~4) ^ (z>>5)
shl ax,#1 ; shift left once
rcl bx,#1
shl ax,#1 ; shift twice
rcl bx,#1
shl ax,#1 ; shift three times
rcl bx,#1
shl ax,#1 ; shift four times
rcl bx,#1
shr dx,#1 ; shift right once
rcr cx,#1
shr dx,#1 ; shift right twice
rcr cx,#1
shr dx,#1 ; shift right three times
rcr cx,#1
shr dx,#1 ; shift right four times
rcr cx,#1
shr dx,#1 ; shift right five times
rcr cx,#1
xor ax,cx ; combine
xor dx,bx ; dx:ax has result
xor si,[bp-12] ; combine to sum
xor di,[bp-10]
add ax,si ; add them together
adc dx,di
mov bx,[bp-12] ; get low word of sum (all we need for this)
and bx,#3 ; get low two bits (modulo 4)
shl bx,#1 ; convert to dword offset
shl bx,#1
add bx,[bp+8] ; add to base address of key info
add ax,[bx] ; low word of key
adc dx,[bx+2] ; high word of key
sub [bp-4],ax ; subtract from y
sbb [bp-2],dx
dec byte ptr [bp-14] ; decrement rounds counter
jz finish_decipher
jmp near decipher_rounds
finish_decipher:
mov bx,[bp+6] ; get address of ciphertext storage
mov ax,[bp-4] ; y, low word
mov [bx],ax
mov ax,[bp-2] ; y, high word
mov [bx+2],ax
mov ax,[bp-8] ; z, low word
mov [bx+4],ax
mov ax,[bp-6] ; z, high word
mov [bx+6],ax
pop di
pop si
add sp,#14 ; discard local vars
pop bp
ret
============================================================
Iata si o serie de utilizatori ai algoritmului Tea:
-Serviciul de Telecomunicatii Speciale
-Austrian Ministry of Interior
-Basque Government, Department of the Interior
-BDBOS National Government Body (Germany)
-Belgian Armed Forces
-Belgian Federal Police DGS/DST/DTRC
-Copenhagen Fire Brigade
-Danish National Police
-Dansk Beredskabskommunikation
-Directorate for Emergency Communications (Norway)
-EADS Secure Networks Oy
-Hong Kong Police Force
-Insta DefSec
-Ministry Of The Interior, Republic Of Serbia
-Rheinmetall Defence Electronics GmbH
-Rohde & Schwarz Professional Mobile Radio GmbH (reputat producator de tehnologie de interceptare gsm)
-Sectra Communications AB
-Swedish Coast Guard
-Swedish Emergency Management Agency
-Swedish National Police Board
NOTA FINALA: algoritmul Tea este suficient de fezabil incat sa se preteze uzului guvernamental. Este dealtfel si algoritmul folosit de Departamentul Apararii al USA.
==va urma==
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.