]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/des/asm/des586.pl
5 # base code is in microsft
10 # WILL NOT WORK ANYMORE WITH desboth.pl
13 if ( ($ARGV[0] eq "elf"))
14 { require "x86unix.pl"; }
15 elsif ( ($ARGV[0] eq "a.out"))
16 { $aout=1; require "x86unix.pl"; }
17 elsif ( ($ARGV[0] eq "sol"))
18 { $sol=1; require "x86unix.pl"; }
19 elsif ( ($ARGV[0] eq "cpp"))
20 { $cpp=1; require "x86unix.pl"; }
21 elsif ( ($ARGV[0] eq "win32"))
22 { require "x86ms.pl"; }
26 Pick one target type from
27 elf - linux, FreeBSD etc
30 cpp - format so x86unix.cpp can be used
31 win32 - Windows 95/Windows NT
36 &comment
("Don't even think of reading this code");
37 &comment
("It was automatically generated by $prog");
38 &comment
("Which is a perl program used to generate the x86 assember for");
39 &comment
("any of elf, a.out, Win32, or Solaris");
40 &comment
("It can be found in SSLeay 0.6.5+ or in libdes 3.26+");
41 &comment
("eric <eay\@cryptsoft.com>");
49 &des_encrypt
("des_encrypt",1);
50 &des_encrypt
("des_encrypt2",0);
52 &des_encrypt3
("des_encrypt3",1);
53 &des_encrypt3
("des_decrypt3",0);
59 local($name,$do_ip)=@_;
61 &function_begin
($name,3,"EXTRN _des_SPtrans:DWORD");
64 &comment
("Load the 2 words");
65 &mov
("eax",&wparam
(0));
66 &mov
($R,&DWP
(0,"eax","",0));
67 &mov
($L,&DWP
(4,"eax","",0));
77 &comment
("fixup rotate");
82 &comment
("load counter, key_schedule and enc flag");
88 &mov
("eax",&wparam
(2)); # get encrypt flag
91 &mov
( $ks, &wparam
(1) );
92 &je
(&label
("start_decrypt"));
94 for ($i=0; $i<16; $i+=2)
98 &D_ENCRYPT
($i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
101 &comment
("Round ".sprintf("%d",$i+1));
102 &D_ENCRYPT
($i+1,$R,$L,($i+1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
106 &set_label
("start_decrypt");
108 for ($i=15; $i>0; $i-=2)
111 &comment
("Round $i");
112 &D_ENCRYPT
(15-$i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
114 &comment
("Round ".sprintf("%d",$i-1));
115 &D_ENCRYPT
(15-$i+1,$R,$L,($i-1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx");
132 &mov
("eax",&wparam
(0));
133 &mov
(&DWP
(0,"eax","",0),$L);
134 &mov
(&DWP
(4,"eax","",0),$R);
136 &function_end
($name);
141 local($r,$L,$R,$S,$ks,$desSP,$u,$tmp1,$tmp2,$t)=@_;
143 &mov
( $t, &DWP
(&n2a
(($S+1)*4),$ks,"",0));
144 &mov
( $u, &DWP
(&n2a
($S*4),$ks,"",0));
148 &and( $u, "0xfcfcfcfc" );
149 &and( $t, "0xfcfcfcfc" );
150 &movb
( &LB
($tmp1), &LB
($u) );
151 &movb
( &LB
($tmp2), &HB
($u) );
152 &xor( $L, &DWP
(" $desSP",$tmp1,"",0));
154 &xor( $L, &DWP
("0x200+$desSP",$tmp2,"",0));
155 &movb
( &LB
($tmp1), &LB
($u) );
156 &movb
( &LB
($tmp2), &HB
($u) );
157 &xor( $L, &DWP
("0x400+$desSP",$tmp1,"",0));
158 &mov
( $u, &DWP
("0x600+$desSP",$tmp2,"",0));
160 &movb
( &LB
($tmp1), &LB
($t) );
161 &movb
( &LB
($tmp2), &HB
($t) );
162 &xor( $L, &DWP
("0x100+$desSP",$tmp1,"",0));
164 &xor( $u, &DWP
("0x300+$desSP",$tmp2,"",0));
165 &movb
( &LB
($tmp1), &LB
($t) );
166 &movb
( &LB
($tmp2), &HB
($t) );
167 &xor( $L, &DWP
("0x500+$desSP",$tmp1,"",0));
168 &xor( $u, &DWP
("0x700+$desSP",$tmp2,"",0));
174 local($a,$b,$tt,$shift,$mask)=@_;
189 &PERM_OP
($r,$l,$tt, 4,"0x0f0f0f0f");
190 &PERM_OP
($l,$r,$tt,16,"0x0000ffff");
191 &PERM_OP
($r,$l,$tt, 2,"0x33333333");
192 &PERM_OP
($l,$r,$tt, 8,"0x00ff00ff");
193 &PERM_OP
($r,$l,$tt, 1,"0x55555555");
200 &PERM_OP
($l,$r,$tt, 1,"0x55555555");
201 &PERM_OP
($r,$l,$tt, 8,"0x00ff00ff");
202 &PERM_OP
($l,$r,$tt, 2,"0x33333333");
203 &PERM_OP
($r,$l,$tt,16,"0x0000ffff");
204 &PERM_OP
($l,$r,$tt, 4,"0x0f0f0f0f");