]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/bf/asm/bf586.pl
6 # base code is in microsft
11 if ( ($ARGV[0] eq "elf"))
12 { require "x86unix.pl"; }
13 elsif ( ($ARGV[0] eq "a.out"))
14 { $aout=1; require "x86unix.pl"; }
15 elsif ( ($ARGV[0] eq "sol"))
16 { $sol=1; require "x86unix.pl"; }
17 elsif ( ($ARGV[0] eq "cpp"))
18 { $cpp=1; require "x86unix.pl"; }
19 elsif ( ($ARGV[0] eq "win32"))
20 { require "x86ms.pl"; }
24 Pick one target type from
25 elf - linux, FreeBSD etc
28 cpp - format so x86unix.cpp can be used
29 win32 - Windows 95/Windows NT
34 &comment
("Don't even think of reading this code");
35 &comment
("It was automatically generated by $prog");
36 &comment
("Which is a perl program used to generate the x86 assember for");
37 &comment
("any of elf, a.out, Win32, or Solaris");
38 &comment
("It can be found in SSLeay 0.7.0+");
39 &comment
("eric <eay\@cryptsoft.com>");
45 $BF_OFF=($BF_ROUNDS+2)*4;
54 &des_encrypt
("BF_encrypt");
62 &function_begin
($name,3,"");
65 &comment
("Load the 2 words");
66 &mov
("eax",&wparam
(0));
67 &mov
($L,&DWP
(0,"eax","",0));
68 &mov
($R,&DWP
(4,"eax","",0));
71 &comment
("P pointer, s and enc flag");
79 &mov
("ebp",&wparam
(2)); # get encrypt flag
81 &je
(&label
("start_decrypt"));
83 &xor($L,&DWP
(0,$P,"",0));
84 for ($i=0; $i<$BF_ROUNDS; $i+=2)
88 &BF_ENCRYPT
($i+1,$R,$L,$P,$tot,$tmp1,$tmp2,$tmp3);
91 &comment
("Round ".sprintf("%d",$i+1));
92 &BF_ENCRYPT
($i+2,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3);
94 &xor($R,&DWP
(($BF_ROUNDS+1)*4,$P,"",0));
96 &mov
("eax",&wparam
(0));
97 &mov
(&DWP
(0,"eax","",0),$R);
98 &mov
(&DWP
(4,"eax","",0),$L);
99 &function_end_A
($name);
101 &set_label
("start_decrypt");
103 &xor($L,&DWP
(($BF_ROUNDS+1)*4,$P,"",0));
104 for ($i=$BF_ROUNDS; $i>0; $i-=2)
107 &comment
("Round $i");
108 &BF_ENCRYPT
($i,$R,$L,$P,$tot,$tmp1,$tmp2,$tmp3);
110 &comment
("Round ".sprintf("%d",$i-1));
111 &BF_ENCRYPT
($i-1,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3);
113 &xor($R,&DWP
(0,$P,"",0));
115 &mov
("eax",&wparam
(0));
116 &mov
(&DWP
(0,"eax","",0),$R);
117 &mov
(&DWP
(4,"eax","",0),$L);
118 &function_end_A
($name);
120 &function_end_B
($name);
125 local($i,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3)=@_;
128 &mov
( $tot, &DWP
(&n2a
($i*4),$P,"",0));
130 &movb
( &LB
($tmp1), &HB
($R));
131 &movb
( &LB
($tmp2), &LB
($R));
136 &mov
( $tot, &DWP
(&n2a
($BF_OFF+0x0000),$P,$tmp1,4));
137 &mov
( $tmp3, &DWP
(&n2a
($BF_OFF+0x0400),$P,$tmp2,4));
139 &movb
( &LB
($tmp1), &HB
($R));
140 &movb
( &LB
($tmp2), &LB
($R));
143 &mov
( $tmp1, &DWP
(&n2a
($BF_OFF+0x0800),$P,$tmp1,4)); # delay
146 &mov
( $tmp3, &DWP
(&n2a
($BF_OFF+0x0C00),$P,$tmp2,4));