Article View: sci.crypt
Article #5035Re: TEA problems with temporarely created variables ?
From: Skybuck Flying
Date: Tue, 27 Aug 2002 00:14
Date: Tue, 27 Aug 2002 00:14
158 lines
7089 bytes
7089 bytes
This is the disassembled code of visual c:
Now how to tell in which order the operations are done.
I am not that good in assembler.
45: void encipher(unsigned long *const v,unsigned long *const w,
46: const unsigned long *const k)
47: {
0040B760 push ebp
0040B761 mov ebp,esp
0040B763 sub esp,64h
0040B766 push ebx
0040B767 push esi
0040B768 push edi
0040B769 lea edi,[ebp-64h]
0040B76C mov ecx,19h
0040B771 mov eax,0CCCCCCCCh
0040B776 rep stos dword ptr [edi]
48: register unsigned long y=v[0],z=v[1],sum=0,delta=0x9E3779B9,
0040B778 mov eax,dword ptr [ebp+8]
0040B77B mov ecx,dword ptr [eax]
0040B77D mov dword ptr [ebp-4],ecx
0040B780 mov edx,dword ptr [ebp+8]
0040B783 mov eax,dword ptr [edx+4]
0040B786 mov dword ptr [ebp-8],eax
0040B789 mov dword ptr [ebp-0Ch],0
0040B790 mov dword ptr [ebp-10h],9E3779B9h
49: a=k[0],b=k[1],c=k[2],d=k[3],n=32;
0040B797 mov ecx,dword ptr [ebp+10h]
0040B79A mov edx,dword ptr [ecx]
0040B79C mov dword ptr [ebp-14h],edx
0040B79F mov eax,dword ptr [ebp+10h]
0040B7A2 mov ecx,dword ptr [eax+4]
0040B7A5 mov dword ptr [ebp-18h],ecx
0040B7A8 mov edx,dword ptr [ebp+10h]
0040B7AB mov eax,dword ptr [edx+8]
0040B7AE mov dword ptr [ebp-1Ch],eax
0040B7B1 mov ecx,dword ptr [ebp+10h]
0040B7B4 mov edx,dword ptr [ecx+0Ch]
0040B7B7 mov dword ptr [ebp-20h],edx
0040B7BA mov dword ptr [ebp-24h],20h
50:
51: while(n-->0)
0040B7C1 mov eax,dword ptr [ebp-24h]
0040B7C4 mov ecx,dword ptr [ebp-24h]
0040B7C7 sub ecx,1
0040B7CA mov dword ptr [ebp-24h],ecx
0040B7CD test eax,eax
0040B7CF jbe encipher+0C4h (0040b824)
52: {
53: sum += delta;
0040B7D1 mov edx,dword ptr [ebp-0Ch]
0040B7D4 add edx,dword ptr [ebp-10h]
0040B7D7 mov dword ptr [ebp-0Ch],edx
54: y += (z<<4)+a ^ z+sum ^ (z>>5)+b;
0040B7DA mov eax,dword ptr [ebp-8]
0040B7DD shl eax,4
0040B7E0 add eax,dword ptr [ebp-14h]
0040B7E3 mov ecx,dword ptr [ebp-8]
0040B7E6 add ecx,dword ptr [ebp-0Ch]
0040B7E9 xor eax,ecx
0040B7EB mov edx,dword ptr [ebp-8]
0040B7EE shr edx,5
0040B7F1 add edx,dword ptr [ebp-18h]
0040B7F4 xor eax,edx
0040B7F6 mov ecx,dword ptr [ebp-4]
0040B7F9 add ecx,eax
0040B7FB mov dword ptr [ebp-4],ecx
55: z += (y<<4)+c ^ y+sum ^ (y>>5)+d;
0040B7FE mov edx,dword ptr [ebp-4]
0040B801 shl edx,4
0040B804 add edx,dword ptr [ebp-1Ch]
0040B807 mov eax,dword ptr [ebp-4]
0040B80A add eax,dword ptr [ebp-0Ch]
0040B80D xor edx,eax
0040B80F mov ecx,dword ptr [ebp-4]
0040B812 shr ecx,5
0040B815 add ecx,dword ptr [ebp-20h]
0040B818 xor edx,ecx
0040B81A mov eax,dword ptr [ebp-8]
0040B81D add eax,edx
0040B81F mov dword ptr [ebp-8],eax
56: }
0040B822 jmp encipher+61h (0040b7c1)
57:
58: w[0]=y; w[1]=z;
0040B824 mov ecx,dword ptr [ebp+0Ch]
0040B827 mov edx,dword ptr [ebp-4]
0040B82A mov dword ptr [ecx],edx
0040B82C mov eax,dword ptr [ebp+0Ch]
0040B82F mov ecx,dword ptr [ebp-8]
0040B832 mov dword ptr [eax+4],ecx
59: }
0040B835 pop edi
0040B836 pop esi
0040B837 pop ebx
0040B838 mov esp,ebp
0040B83A pop ebp
0040B83B ret
"skybuck" <skybuck2000@hotmail.com> wrote in message
news:65fc3031.0208261208.6199fcc1@posting.google.com...
> disastry@saiknes.lv.NO.SPaM.NET wrote in message
news:<3D69F6F6.E43591E6@saiknes.lv.NO.SPaM.NET>...
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: RIPEMD160
> >
> > skybuck wrote:
> > > The problems are probably with these lines of code:
>
> For those that don't what the problem might be... compilers create
> temporarely variables to store the sub results of the calculation of
> these lines of code.
> Apperently... compiler do that differently...
>
>
> > > c version:
> > >
> > > y += (z<<4)+a ^ z+sum ^ (z>>5)+b;
> > > z += (y<<4)+c ^ y+sum ^ (y>>5)+d;
> > >
> > > pascal version:
> > >
> > > y := y + (z shl 4) + a xor z + _sum xor (z shr 5) + b;
> > > z := z + (y shl 4) + c xor y + _sum xor (y shr 5) + d;
> >
> > 1) try:
> > y := y + ((z shl 4) + a xor z + _sum xor (z shr 5) + b);
>
> Nope, I tried this one, it doesn't work in delphi 6.
>
>
>
> > or even
> > y := y + (((z shl 4) + a) xor (z + _sum) xor ((z shr 5) + b));
> >
>
> Nope, this one also doesn't work in delphi.
>
> > 2) better use XTEA (aka (TEAN)
>
> Hmm.. what's that... I go check it out :)
>
> > __
> > Disastry http://disastry.dhs.org/
> > http://disastry.dhs.org/pgp <----PGP plugins for Netscape and MDaemon
> > ^----PGP 2.6.3ia-multi06 (supports IDEA, CAST5, BLOWFISH, TWOFISH,
> > AES, 3DES ciphers and MD5, SHA1, RIPEMD160, SHA2 hashes)
> > -----BEGIN PGP SIGNATURE-----
> > Version: Netscape PGP half-Plugin 0.15 by Disastry / PGPsdk v1.7.1
> >
> > iQA/AwUBPWnayDBaTVEuJQxkEQMpGACfZIT4l3qmDgc6vFEefc8IaltkSfAAoLXz
> > hQBQJElRGLhZ0OyB59/rQvpn
> > =ouN1
> > -----END PGP SIGNATURE-----
Technical Details
Message-ID:
<cmza9.3149$28.498334@zwoll1.home.nl>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeed1.bredband.com!bredband!news01.chello.se!amsnews01.chello.com!newshub1.nl.home.com!news.nl.home.com!zwoll1.home.nl.POSTED!not-for-mailReferences:
<65fc3031.0208260053.300165ba@posting.google.com> <3D69F6F6.E43591E6@saiknes.lv.NO.SPaM.NET> <65fc3031.0208261208.6199fcc1@posting.google.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb57f,ddba2a7b81ed925a X-Google-Attributes: gidfb57f,public X-Google-Thread: 1043cf,ddba2a7b81ed925a X-Google-Attributes: gid1043cf,public X-Google-Thread: 1014db,ddba2a7b81ed925a X-Google-Attributes: gid1014db,public X-Google-Thread: 10cc59,ddba2a7b81ed925a X-Google-Attributes: gid10cc59,public X-Google-ArrivalTime: 2002-08-26 17:15:18 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeed1.bredband.com!bredband!news01.chello.se!amsnews01.chello.com!newshub1.nl.home.com!news.nl.home.com!zwoll1.home.nl.POSTED!not-for-mail From: "Skybuck Flying" <skybuck2000@hotmail.com> Newsgroups: sci.crypt,comp.lang.pascal,borland.public.delphi.objectpascal,comp.lang.c References: <65fc3031.0208260053.300165ba@posting.google.com> <3D69F6F6.E43591E6@saiknes.lv.NO.SPaM.NET> <65fc3031.0208261208.6199fcc1@posting.google.com> Subject: Re: TEA problems with temporarely created variables ? Lines: 160 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: <cmza9.3149$28.498334@zwoll1.home.nl> Date: Tue, 27 Aug 2002 02:14:47 +0200 NNTP-Posting-Host: 217.121.93.57 X-Complaints-To: abuse@home.nl X-Trace: zwoll1.home.nl 1030406664 217.121.93.57 (Tue, 27 Aug 2002 02:04:24 MEST) NNTP-Posting-Date: Tue, 27 Aug 2002 02:04:24 MEST Organization: @Home Network