diff options
author | djm <> | 2010-10-01 22:59:01 +0000 |
---|---|---|
committer | djm <> | 2010-10-01 22:59:01 +0000 |
commit | fe047d8b632246cb2db3234a0a4f32e5c318857b (patch) | |
tree | 939b752540947d33507b3acc48d76a8bfb7c3dc3 /src/lib/libcrypto/des/asm | |
parent | 2ea67f4aa254b09ded62e6e14fc893bbe6381579 (diff) | |
download | openbsd-fe047d8b632246cb2db3234a0a4f32e5c318857b.tar.gz openbsd-fe047d8b632246cb2db3234a0a4f32e5c318857b.tar.bz2 openbsd-fe047d8b632246cb2db3234a0a4f32e5c318857b.zip |
resolve conflicts, fix local changes
Diffstat (limited to 'src/lib/libcrypto/des/asm')
-rw-r--r-- | src/lib/libcrypto/des/asm/crypt586.pl | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/des/asm/des-586.pl | 282 | ||||
-rw-r--r-- | src/lib/libcrypto/des/asm/des686.pl | 230 |
3 files changed, 243 insertions, 274 deletions
diff --git a/src/lib/libcrypto/des/asm/crypt586.pl b/src/lib/libcrypto/des/asm/crypt586.pl index 1d04ed6def..e36f7d44bd 100644 --- a/src/lib/libcrypto/des/asm/crypt586.pl +++ b/src/lib/libcrypto/des/asm/crypt586.pl | |||
@@ -6,7 +6,8 @@ | |||
6 | # things perfect. | 6 | # things perfect. |
7 | # | 7 | # |
8 | 8 | ||
9 | push(@INC,"perlasm","../../perlasm"); | 9 | $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; |
10 | push(@INC,"${dir}","${dir}../../perlasm"); | ||
10 | require "x86asm.pl"; | 11 | require "x86asm.pl"; |
11 | 12 | ||
12 | &asm_init($ARGV[0],"crypt586.pl"); | 13 | &asm_init($ARGV[0],"crypt586.pl"); |
@@ -22,7 +23,7 @@ sub fcrypt_body | |||
22 | { | 23 | { |
23 | local($name,$do_ip)=@_; | 24 | local($name,$do_ip)=@_; |
24 | 25 | ||
25 | &function_begin($name,"EXTRN _DES_SPtrans:DWORD"); | 26 | &function_begin($name); |
26 | 27 | ||
27 | &comment(""); | 28 | &comment(""); |
28 | &comment("Load the 2 words"); | 29 | &comment("Load the 2 words"); |
diff --git a/src/lib/libcrypto/des/asm/des-586.pl b/src/lib/libcrypto/des/asm/des-586.pl index 60d577cc8d..5b5f39cebd 100644 --- a/src/lib/libcrypto/des/asm/des-586.pl +++ b/src/lib/libcrypto/des/asm/des-586.pl | |||
@@ -4,7 +4,8 @@ | |||
4 | # Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk> | 4 | # Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk> |
5 | # | 5 | # |
6 | 6 | ||
7 | push(@INC,"perlasm","../../perlasm"); | 7 | $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; |
8 | push(@INC,"${dir}","${dir}../../perlasm"); | ||
8 | require "x86asm.pl"; | 9 | require "x86asm.pl"; |
9 | require "cbc.pl"; | 10 | require "cbc.pl"; |
10 | require "desboth.pl"; | 11 | require "desboth.pl"; |
@@ -18,33 +19,110 @@ require "desboth.pl"; | |||
18 | 19 | ||
19 | $L="edi"; | 20 | $L="edi"; |
20 | $R="esi"; | 21 | $R="esi"; |
22 | $trans="ebp"; | ||
23 | $small_footprint=1 if (grep(/\-DOPENSSL_SMALL_FOOTPRINT/,@ARGV)); | ||
24 | # one can discuss setting this variable to 1 unconditionally, as | ||
25 | # the folded loop is only 3% slower than unrolled, but >7 times smaller | ||
21 | 26 | ||
22 | &external_label("DES_SPtrans"); | 27 | &public_label("DES_SPtrans"); |
28 | |||
29 | &DES_encrypt_internal(); | ||
30 | &DES_decrypt_internal(); | ||
23 | &DES_encrypt("DES_encrypt1",1); | 31 | &DES_encrypt("DES_encrypt1",1); |
24 | &DES_encrypt("DES_encrypt2",0); | 32 | &DES_encrypt("DES_encrypt2",0); |
33 | &DES_encrypt3("DES_encrypt3",1); | ||
34 | &DES_encrypt3("DES_decrypt3",0); | ||
35 | &cbc("DES_ncbc_encrypt","DES_encrypt1","DES_encrypt1",0,4,5,3,5,-1); | ||
36 | &cbc("DES_ede3_cbc_encrypt","DES_encrypt3","DES_decrypt3",0,6,7,3,4,5); | ||
37 | &DES_SPtrans(); | ||
38 | |||
39 | &asm_finish(); | ||
25 | 40 | ||
26 | if (!$main'openbsd) | 41 | sub DES_encrypt_internal() |
27 | { | 42 | { |
28 | &DES_encrypt3("DES_encrypt3",1); | 43 | &function_begin_B("_x86_DES_encrypt"); |
29 | &DES_encrypt3("DES_decrypt3",0); | 44 | |
30 | &cbc("DES_ncbc_encrypt","DES_encrypt1","DES_encrypt1",0,4,5,3,5,-1); | 45 | if ($small_footprint) |
31 | &cbc("DES_ede3_cbc_encrypt","DES_encrypt3","DES_decrypt3",0,6,7,3,4,5); | 46 | { |
47 | &lea("edx",&DWP(128,"ecx")); | ||
48 | &push("edx"); | ||
49 | &push("ecx"); | ||
50 | &set_label("eloop"); | ||
51 | &D_ENCRYPT(0,$L,$R,0,$trans,"eax","ebx","ecx","edx",&swtmp(0)); | ||
52 | &comment(""); | ||
53 | &D_ENCRYPT(1,$R,$L,2,$trans,"eax","ebx","ecx","edx",&swtmp(0)); | ||
54 | &comment(""); | ||
55 | &add("ecx",16); | ||
56 | &cmp("ecx",&swtmp(1)); | ||
57 | &mov(&swtmp(0),"ecx"); | ||
58 | &jb(&label("eloop")); | ||
59 | &add("esp",8); | ||
60 | } | ||
61 | else | ||
62 | { | ||
63 | &push("ecx"); | ||
64 | for ($i=0; $i<16; $i+=2) | ||
65 | { | ||
66 | &comment("Round $i"); | ||
67 | &D_ENCRYPT($i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx",&swtmp(0)); | ||
68 | &comment("Round ".sprintf("%d",$i+1)); | ||
69 | &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$trans,"eax","ebx","ecx","edx",&swtmp(0)); | ||
70 | } | ||
71 | &add("esp",4); | ||
32 | } | 72 | } |
73 | &ret(); | ||
33 | 74 | ||
34 | &asm_finish(); | 75 | &function_end_B("_x86_DES_encrypt"); |
76 | } | ||
77 | |||
78 | sub DES_decrypt_internal() | ||
79 | { | ||
80 | &function_begin_B("_x86_DES_decrypt"); | ||
81 | |||
82 | if ($small_footprint) | ||
83 | { | ||
84 | &push("ecx"); | ||
85 | &lea("ecx",&DWP(128,"ecx")); | ||
86 | &push("ecx"); | ||
87 | &set_label("dloop"); | ||
88 | &D_ENCRYPT(0,$L,$R,-2,$trans,"eax","ebx","ecx","edx",&swtmp(0)); | ||
89 | &comment(""); | ||
90 | &D_ENCRYPT(1,$R,$L,-4,$trans,"eax","ebx","ecx","edx",&swtmp(0)); | ||
91 | &comment(""); | ||
92 | &sub("ecx",16); | ||
93 | &cmp("ecx",&swtmp(1)); | ||
94 | &mov(&swtmp(0),"ecx"); | ||
95 | &ja(&label("dloop")); | ||
96 | &add("esp",8); | ||
97 | } | ||
98 | else | ||
99 | { | ||
100 | &push("ecx"); | ||
101 | for ($i=15; $i>0; $i-=2) | ||
102 | { | ||
103 | &comment("Round $i"); | ||
104 | &D_ENCRYPT(15-$i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx",&swtmp(0)); | ||
105 | &comment("Round ".sprintf("%d",$i-1)); | ||
106 | &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$trans,"eax","ebx","ecx","edx",&swtmp(0)); | ||
107 | } | ||
108 | &add("esp",4); | ||
109 | } | ||
110 | &ret(); | ||
35 | 111 | ||
112 | &function_end_B("_x86_DES_decrypt"); | ||
113 | } | ||
114 | |||
36 | sub DES_encrypt | 115 | sub DES_encrypt |
37 | { | 116 | { |
38 | local($name,$do_ip)=@_; | 117 | local($name,$do_ip)=@_; |
39 | 118 | ||
40 | &function_begin_B($name,"EXTRN _DES_SPtrans:DWORD"); | 119 | &function_begin_B($name); |
41 | 120 | ||
42 | &push("esi"); | 121 | &push("esi"); |
43 | &push("edi"); | 122 | &push("edi"); |
44 | 123 | ||
45 | &comment(""); | 124 | &comment(""); |
46 | &comment("Load the 2 words"); | 125 | &comment("Load the 2 words"); |
47 | $trans="ebp"; | ||
48 | 126 | ||
49 | if ($do_ip) | 127 | if ($do_ip) |
50 | { | 128 | { |
@@ -77,39 +155,20 @@ sub DES_encrypt | |||
77 | } | 155 | } |
78 | 156 | ||
79 | # PIC-ification:-) | 157 | # PIC-ification:-) |
80 | &picmeup($trans,"DES_SPtrans"); | 158 | &call (&label("pic_point")); |
81 | #if ($cpp) { &picmeup($trans,"DES_SPtrans"); } | 159 | &set_label("pic_point"); |
82 | #else { &lea($trans,&DWP("DES_SPtrans")); } | 160 | &blindpop($trans); |
161 | &lea ($trans,&DWP(&label("DES_SPtrans")."-".&label("pic_point"),$trans)); | ||
83 | 162 | ||
84 | &mov( "ecx", &wparam(1) ); | 163 | &mov( "ecx", &wparam(1) ); |
85 | &cmp("ebx","0"); | ||
86 | &je(&label("start_decrypt")); | ||
87 | |||
88 | for ($i=0; $i<16; $i+=2) | ||
89 | { | ||
90 | &comment(""); | ||
91 | &comment("Round $i"); | ||
92 | &D_ENCRYPT($i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx"); | ||
93 | |||
94 | &comment(""); | ||
95 | &comment("Round ".sprintf("%d",$i+1)); | ||
96 | &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$trans,"eax","ebx","ecx","edx"); | ||
97 | } | ||
98 | &jmp(&label("end")); | ||
99 | 164 | ||
100 | &set_label("start_decrypt"); | 165 | &cmp("ebx","0"); |
101 | 166 | &je(&label("decrypt")); | |
102 | for ($i=15; $i>0; $i-=2) | 167 | &call("_x86_DES_encrypt"); |
103 | { | 168 | &jmp(&label("done")); |
104 | &comment(""); | 169 | &set_label("decrypt"); |
105 | &comment("Round $i"); | 170 | &call("_x86_DES_decrypt"); |
106 | &D_ENCRYPT(15-$i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx"); | 171 | &set_label("done"); |
107 | &comment(""); | ||
108 | &comment("Round ".sprintf("%d",$i-1)); | ||
109 | &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$trans,"eax","ebx","ecx","edx"); | ||
110 | } | ||
111 | |||
112 | &set_label("end"); | ||
113 | 172 | ||
114 | if ($do_ip) | 173 | if ($do_ip) |
115 | { | 174 | { |
@@ -143,7 +202,7 @@ sub DES_encrypt | |||
143 | 202 | ||
144 | sub D_ENCRYPT | 203 | sub D_ENCRYPT |
145 | { | 204 | { |
146 | local($r,$L,$R,$S,$trans,$u,$tmp1,$tmp2,$t)=@_; | 205 | local($r,$L,$R,$S,$trans,$u,$tmp1,$tmp2,$t,$wp1)=@_; |
147 | 206 | ||
148 | &mov( $u, &DWP(&n2a($S*4),$tmp2,"",0)); | 207 | &mov( $u, &DWP(&n2a($S*4),$tmp2,"",0)); |
149 | &xor( $tmp1, $tmp1); | 208 | &xor( $tmp1, $tmp1); |
@@ -170,7 +229,7 @@ sub D_ENCRYPT | |||
170 | &and( $t, "0xff" ); | 229 | &and( $t, "0xff" ); |
171 | &xor( $L, &DWP("0x600",$trans,$tmp1,0)); | 230 | &xor( $L, &DWP("0x600",$trans,$tmp1,0)); |
172 | &xor( $L, &DWP("0x700",$trans,$tmp2,0)); | 231 | &xor( $L, &DWP("0x700",$trans,$tmp2,0)); |
173 | &mov( $tmp2, &wparam(1) ); | 232 | &mov( $tmp2, $wp1 ); |
174 | &xor( $L, &DWP("0x400",$trans,$u,0)); | 233 | &xor( $L, &DWP("0x400",$trans,$u,0)); |
175 | &xor( $L, &DWP("0x500",$trans,$t,0)); | 234 | &xor( $L, &DWP("0x500",$trans,$t,0)); |
176 | } | 235 | } |
@@ -253,3 +312,142 @@ sub FP_new | |||
253 | &rotr($tt , 4); | 312 | &rotr($tt , 4); |
254 | } | 313 | } |
255 | 314 | ||
315 | sub DES_SPtrans | ||
316 | { | ||
317 | &set_label("DES_SPtrans",64); | ||
318 | &data_word(0x02080800, 0x00080000, 0x02000002, 0x02080802); | ||
319 | &data_word(0x02000000, 0x00080802, 0x00080002, 0x02000002); | ||
320 | &data_word(0x00080802, 0x02080800, 0x02080000, 0x00000802); | ||
321 | &data_word(0x02000802, 0x02000000, 0x00000000, 0x00080002); | ||
322 | &data_word(0x00080000, 0x00000002, 0x02000800, 0x00080800); | ||
323 | &data_word(0x02080802, 0x02080000, 0x00000802, 0x02000800); | ||
324 | &data_word(0x00000002, 0x00000800, 0x00080800, 0x02080002); | ||
325 | &data_word(0x00000800, 0x02000802, 0x02080002, 0x00000000); | ||
326 | &data_word(0x00000000, 0x02080802, 0x02000800, 0x00080002); | ||
327 | &data_word(0x02080800, 0x00080000, 0x00000802, 0x02000800); | ||
328 | &data_word(0x02080002, 0x00000800, 0x00080800, 0x02000002); | ||
329 | &data_word(0x00080802, 0x00000002, 0x02000002, 0x02080000); | ||
330 | &data_word(0x02080802, 0x00080800, 0x02080000, 0x02000802); | ||
331 | &data_word(0x02000000, 0x00000802, 0x00080002, 0x00000000); | ||
332 | &data_word(0x00080000, 0x02000000, 0x02000802, 0x02080800); | ||
333 | &data_word(0x00000002, 0x02080002, 0x00000800, 0x00080802); | ||
334 | # nibble 1 | ||
335 | &data_word(0x40108010, 0x00000000, 0x00108000, 0x40100000); | ||
336 | &data_word(0x40000010, 0x00008010, 0x40008000, 0x00108000); | ||
337 | &data_word(0x00008000, 0x40100010, 0x00000010, 0x40008000); | ||
338 | &data_word(0x00100010, 0x40108000, 0x40100000, 0x00000010); | ||
339 | &data_word(0x00100000, 0x40008010, 0x40100010, 0x00008000); | ||
340 | &data_word(0x00108010, 0x40000000, 0x00000000, 0x00100010); | ||
341 | &data_word(0x40008010, 0x00108010, 0x40108000, 0x40000010); | ||
342 | &data_word(0x40000000, 0x00100000, 0x00008010, 0x40108010); | ||
343 | &data_word(0x00100010, 0x40108000, 0x40008000, 0x00108010); | ||
344 | &data_word(0x40108010, 0x00100010, 0x40000010, 0x00000000); | ||
345 | &data_word(0x40000000, 0x00008010, 0x00100000, 0x40100010); | ||
346 | &data_word(0x00008000, 0x40000000, 0x00108010, 0x40008010); | ||
347 | &data_word(0x40108000, 0x00008000, 0x00000000, 0x40000010); | ||
348 | &data_word(0x00000010, 0x40108010, 0x00108000, 0x40100000); | ||
349 | &data_word(0x40100010, 0x00100000, 0x00008010, 0x40008000); | ||
350 | &data_word(0x40008010, 0x00000010, 0x40100000, 0x00108000); | ||
351 | # nibble 2 | ||
352 | &data_word(0x04000001, 0x04040100, 0x00000100, 0x04000101); | ||
353 | &data_word(0x00040001, 0x04000000, 0x04000101, 0x00040100); | ||
354 | &data_word(0x04000100, 0x00040000, 0x04040000, 0x00000001); | ||
355 | &data_word(0x04040101, 0x00000101, 0x00000001, 0x04040001); | ||
356 | &data_word(0x00000000, 0x00040001, 0x04040100, 0x00000100); | ||
357 | &data_word(0x00000101, 0x04040101, 0x00040000, 0x04000001); | ||
358 | &data_word(0x04040001, 0x04000100, 0x00040101, 0x04040000); | ||
359 | &data_word(0x00040100, 0x00000000, 0x04000000, 0x00040101); | ||
360 | &data_word(0x04040100, 0x00000100, 0x00000001, 0x00040000); | ||
361 | &data_word(0x00000101, 0x00040001, 0x04040000, 0x04000101); | ||
362 | &data_word(0x00000000, 0x04040100, 0x00040100, 0x04040001); | ||
363 | &data_word(0x00040001, 0x04000000, 0x04040101, 0x00000001); | ||
364 | &data_word(0x00040101, 0x04000001, 0x04000000, 0x04040101); | ||
365 | &data_word(0x00040000, 0x04000100, 0x04000101, 0x00040100); | ||
366 | &data_word(0x04000100, 0x00000000, 0x04040001, 0x00000101); | ||
367 | &data_word(0x04000001, 0x00040101, 0x00000100, 0x04040000); | ||
368 | # nibble 3 | ||
369 | &data_word(0x00401008, 0x10001000, 0x00000008, 0x10401008); | ||
370 | &data_word(0x00000000, 0x10400000, 0x10001008, 0x00400008); | ||
371 | &data_word(0x10401000, 0x10000008, 0x10000000, 0x00001008); | ||
372 | &data_word(0x10000008, 0x00401008, 0x00400000, 0x10000000); | ||
373 | &data_word(0x10400008, 0x00401000, 0x00001000, 0x00000008); | ||
374 | &data_word(0x00401000, 0x10001008, 0x10400000, 0x00001000); | ||
375 | &data_word(0x00001008, 0x00000000, 0x00400008, 0x10401000); | ||
376 | &data_word(0x10001000, 0x10400008, 0x10401008, 0x00400000); | ||
377 | &data_word(0x10400008, 0x00001008, 0x00400000, 0x10000008); | ||
378 | &data_word(0x00401000, 0x10001000, 0x00000008, 0x10400000); | ||
379 | &data_word(0x10001008, 0x00000000, 0x00001000, 0x00400008); | ||
380 | &data_word(0x00000000, 0x10400008, 0x10401000, 0x00001000); | ||
381 | &data_word(0x10000000, 0x10401008, 0x00401008, 0x00400000); | ||
382 | &data_word(0x10401008, 0x00000008, 0x10001000, 0x00401008); | ||
383 | &data_word(0x00400008, 0x00401000, 0x10400000, 0x10001008); | ||
384 | &data_word(0x00001008, 0x10000000, 0x10000008, 0x10401000); | ||
385 | # nibble 4 | ||
386 | &data_word(0x08000000, 0x00010000, 0x00000400, 0x08010420); | ||
387 | &data_word(0x08010020, 0x08000400, 0x00010420, 0x08010000); | ||
388 | &data_word(0x00010000, 0x00000020, 0x08000020, 0x00010400); | ||
389 | &data_word(0x08000420, 0x08010020, 0x08010400, 0x00000000); | ||
390 | &data_word(0x00010400, 0x08000000, 0x00010020, 0x00000420); | ||
391 | &data_word(0x08000400, 0x00010420, 0x00000000, 0x08000020); | ||
392 | &data_word(0x00000020, 0x08000420, 0x08010420, 0x00010020); | ||
393 | &data_word(0x08010000, 0x00000400, 0x00000420, 0x08010400); | ||
394 | &data_word(0x08010400, 0x08000420, 0x00010020, 0x08010000); | ||
395 | &data_word(0x00010000, 0x00000020, 0x08000020, 0x08000400); | ||
396 | &data_word(0x08000000, 0x00010400, 0x08010420, 0x00000000); | ||
397 | &data_word(0x00010420, 0x08000000, 0x00000400, 0x00010020); | ||
398 | &data_word(0x08000420, 0x00000400, 0x00000000, 0x08010420); | ||
399 | &data_word(0x08010020, 0x08010400, 0x00000420, 0x00010000); | ||
400 | &data_word(0x00010400, 0x08010020, 0x08000400, 0x00000420); | ||
401 | &data_word(0x00000020, 0x00010420, 0x08010000, 0x08000020); | ||
402 | # nibble 5 | ||
403 | &data_word(0x80000040, 0x00200040, 0x00000000, 0x80202000); | ||
404 | &data_word(0x00200040, 0x00002000, 0x80002040, 0x00200000); | ||
405 | &data_word(0x00002040, 0x80202040, 0x00202000, 0x80000000); | ||
406 | &data_word(0x80002000, 0x80000040, 0x80200000, 0x00202040); | ||
407 | &data_word(0x00200000, 0x80002040, 0x80200040, 0x00000000); | ||
408 | &data_word(0x00002000, 0x00000040, 0x80202000, 0x80200040); | ||
409 | &data_word(0x80202040, 0x80200000, 0x80000000, 0x00002040); | ||
410 | &data_word(0x00000040, 0x00202000, 0x00202040, 0x80002000); | ||
411 | &data_word(0x00002040, 0x80000000, 0x80002000, 0x00202040); | ||
412 | &data_word(0x80202000, 0x00200040, 0x00000000, 0x80002000); | ||
413 | &data_word(0x80000000, 0x00002000, 0x80200040, 0x00200000); | ||
414 | &data_word(0x00200040, 0x80202040, 0x00202000, 0x00000040); | ||
415 | &data_word(0x80202040, 0x00202000, 0x00200000, 0x80002040); | ||
416 | &data_word(0x80000040, 0x80200000, 0x00202040, 0x00000000); | ||
417 | &data_word(0x00002000, 0x80000040, 0x80002040, 0x80202000); | ||
418 | &data_word(0x80200000, 0x00002040, 0x00000040, 0x80200040); | ||
419 | # nibble 6 | ||
420 | &data_word(0x00004000, 0x00000200, 0x01000200, 0x01000004); | ||
421 | &data_word(0x01004204, 0x00004004, 0x00004200, 0x00000000); | ||
422 | &data_word(0x01000000, 0x01000204, 0x00000204, 0x01004000); | ||
423 | &data_word(0x00000004, 0x01004200, 0x01004000, 0x00000204); | ||
424 | &data_word(0x01000204, 0x00004000, 0x00004004, 0x01004204); | ||
425 | &data_word(0x00000000, 0x01000200, 0x01000004, 0x00004200); | ||
426 | &data_word(0x01004004, 0x00004204, 0x01004200, 0x00000004); | ||
427 | &data_word(0x00004204, 0x01004004, 0x00000200, 0x01000000); | ||
428 | &data_word(0x00004204, 0x01004000, 0x01004004, 0x00000204); | ||
429 | &data_word(0x00004000, 0x00000200, 0x01000000, 0x01004004); | ||
430 | &data_word(0x01000204, 0x00004204, 0x00004200, 0x00000000); | ||
431 | &data_word(0x00000200, 0x01000004, 0x00000004, 0x01000200); | ||
432 | &data_word(0x00000000, 0x01000204, 0x01000200, 0x00004200); | ||
433 | &data_word(0x00000204, 0x00004000, 0x01004204, 0x01000000); | ||
434 | &data_word(0x01004200, 0x00000004, 0x00004004, 0x01004204); | ||
435 | &data_word(0x01000004, 0x01004200, 0x01004000, 0x00004004); | ||
436 | # nibble 7 | ||
437 | &data_word(0x20800080, 0x20820000, 0x00020080, 0x00000000); | ||
438 | &data_word(0x20020000, 0x00800080, 0x20800000, 0x20820080); | ||
439 | &data_word(0x00000080, 0x20000000, 0x00820000, 0x00020080); | ||
440 | &data_word(0x00820080, 0x20020080, 0x20000080, 0x20800000); | ||
441 | &data_word(0x00020000, 0x00820080, 0x00800080, 0x20020000); | ||
442 | &data_word(0x20820080, 0x20000080, 0x00000000, 0x00820000); | ||
443 | &data_word(0x20000000, 0x00800000, 0x20020080, 0x20800080); | ||
444 | &data_word(0x00800000, 0x00020000, 0x20820000, 0x00000080); | ||
445 | &data_word(0x00800000, 0x00020000, 0x20000080, 0x20820080); | ||
446 | &data_word(0x00020080, 0x20000000, 0x00000000, 0x00820000); | ||
447 | &data_word(0x20800080, 0x20020080, 0x20020000, 0x00800080); | ||
448 | &data_word(0x20820000, 0x00000080, 0x00800080, 0x20020000); | ||
449 | &data_word(0x20820080, 0x00800000, 0x20800000, 0x20000080); | ||
450 | &data_word(0x00820000, 0x00020080, 0x20020080, 0x20800000); | ||
451 | &data_word(0x00000080, 0x20820000, 0x00820080, 0x00000000); | ||
452 | &data_word(0x20000000, 0x20800080, 0x00020000, 0x00820080); | ||
453 | } | ||
diff --git a/src/lib/libcrypto/des/asm/des686.pl b/src/lib/libcrypto/des/asm/des686.pl deleted file mode 100644 index d3ad5d5edd..0000000000 --- a/src/lib/libcrypto/des/asm/des686.pl +++ /dev/null | |||
@@ -1,230 +0,0 @@ | |||
1 | #!/usr/local/bin/perl | ||
2 | |||
3 | $prog="des686.pl"; | ||
4 | |||
5 | # base code is in microsft | ||
6 | # op dest, source | ||
7 | # format. | ||
8 | # | ||
9 | |||
10 | # WILL NOT WORK ANYMORE WITH desboth.pl | ||
11 | require "desboth.pl"; | ||
12 | |||
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"; } | ||
23 | else | ||
24 | { | ||
25 | print STDERR <<"EOF"; | ||
26 | Pick one target type from | ||
27 | elf - linux, FreeBSD etc | ||
28 | a.out - old linux | ||
29 | sol - x86 solaris | ||
30 | cpp - format so x86unix.cpp can be used | ||
31 | win32 - Windows 95/Windows NT | ||
32 | EOF | ||
33 | exit(1); | ||
34 | } | ||
35 | |||
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>"); | ||
42 | &comment(""); | ||
43 | |||
44 | &file("dx86xxxx"); | ||
45 | |||
46 | $L="edi"; | ||
47 | $R="esi"; | ||
48 | |||
49 | &DES_encrypt("DES_encrypt1",1); | ||
50 | &DES_encrypt("DES_encrypt2",0); | ||
51 | |||
52 | &DES_encrypt3("DES_encrypt3",1); | ||
53 | &DES_encrypt3("DES_decrypt3",0); | ||
54 | |||
55 | &file_end(); | ||
56 | |||
57 | sub DES_encrypt | ||
58 | { | ||
59 | local($name,$do_ip)=@_; | ||
60 | |||
61 | &function_begin($name,"EXTRN _DES_SPtrans:DWORD"); | ||
62 | |||
63 | &comment(""); | ||
64 | &comment("Load the 2 words"); | ||
65 | &mov("eax",&wparam(0)); | ||
66 | &mov($L,&DWP(0,"eax","",0)); | ||
67 | &mov($R,&DWP(4,"eax","",0)); | ||
68 | |||
69 | $ksp=&wparam(1); | ||
70 | |||
71 | if ($do_ip) | ||
72 | { | ||
73 | &comment(""); | ||
74 | &comment("IP"); | ||
75 | &IP_new($L,$R,"eax"); | ||
76 | } | ||
77 | |||
78 | &comment(""); | ||
79 | &comment("fixup rotate"); | ||
80 | &rotl($R,3); | ||
81 | &rotl($L,3); | ||
82 | &exch($L,$R); | ||
83 | |||
84 | &comment(""); | ||
85 | &comment("load counter, key_schedule and enc flag"); | ||
86 | &mov("eax",&wparam(2)); # get encrypt flag | ||
87 | &mov("ebp",&wparam(1)); # get ks | ||
88 | &cmp("eax","0"); | ||
89 | &je(&label("start_decrypt")); | ||
90 | |||
91 | # encrypting part | ||
92 | |||
93 | for ($i=0; $i<16; $i+=2) | ||
94 | { | ||
95 | &comment(""); | ||
96 | &comment("Round $i"); | ||
97 | &D_ENCRYPT($L,$R,$i*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx"); | ||
98 | |||
99 | &comment(""); | ||
100 | &comment("Round ".sprintf("%d",$i+1)); | ||
101 | &D_ENCRYPT($R,$L,($i+1)*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx"); | ||
102 | } | ||
103 | &jmp(&label("end")); | ||
104 | |||
105 | &set_label("start_decrypt"); | ||
106 | |||
107 | for ($i=15; $i>0; $i-=2) | ||
108 | { | ||
109 | &comment(""); | ||
110 | &comment("Round $i"); | ||
111 | &D_ENCRYPT($L,$R,$i*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx"); | ||
112 | &comment(""); | ||
113 | &comment("Round ".sprintf("%d",$i-1)); | ||
114 | &D_ENCRYPT($R,$L,($i-1)*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx"); | ||
115 | } | ||
116 | |||
117 | &set_label("end"); | ||
118 | |||
119 | &comment(""); | ||
120 | &comment("Fixup"); | ||
121 | &rotr($L,3); # r | ||
122 | &rotr($R,3); # l | ||
123 | |||
124 | if ($do_ip) | ||
125 | { | ||
126 | &comment(""); | ||
127 | &comment("FP"); | ||
128 | &FP_new($R,$L,"eax"); | ||
129 | } | ||
130 | |||
131 | &mov("eax",&wparam(0)); | ||
132 | &mov(&DWP(0,"eax","",0),$L); | ||
133 | &mov(&DWP(4,"eax","",0),$R); | ||
134 | |||
135 | &function_end($name); | ||
136 | } | ||
137 | |||
138 | |||
139 | # The logic is to load R into 2 registers and operate on both at the same time. | ||
140 | # We also load the 2 R's into 2 more registers so we can do the 'move word down a byte' | ||
141 | # while also masking the other copy and doing a lookup. We then also accumulate the | ||
142 | # L value in 2 registers then combine them at the end. | ||
143 | sub D_ENCRYPT | ||
144 | { | ||
145 | local($L,$R,$S,$ks,$desSP,$u,$t,$tmp1,$tmp2,$tmp3)=@_; | ||
146 | |||
147 | &mov( $u, &DWP(&n2a($S*4),$ks,"",0)); | ||
148 | &mov( $t, &DWP(&n2a(($S+1)*4),$ks,"",0)); | ||
149 | &xor( $u, $R ); | ||
150 | &xor( $t, $R ); | ||
151 | &rotr( $t, 4 ); | ||
152 | |||
153 | # the numbers at the end of the line are origional instruction order | ||
154 | &mov( $tmp2, $u ); # 1 2 | ||
155 | &mov( $tmp1, $t ); # 1 1 | ||
156 | &and( $tmp2, "0xfc" ); # 1 4 | ||
157 | &and( $tmp1, "0xfc" ); # 1 3 | ||
158 | &shr( $t, 8 ); # 1 5 | ||
159 | &xor( $L, &DWP("0x100+$desSP",$tmp1,"",0)); # 1 7 | ||
160 | &shr( $u, 8 ); # 1 6 | ||
161 | &mov( $tmp1, &DWP(" $desSP",$tmp2,"",0)); # 1 8 | ||
162 | |||
163 | &mov( $tmp2, $u ); # 2 2 | ||
164 | &xor( $L, $tmp1 ); # 1 9 | ||
165 | &and( $tmp2, "0xfc" ); # 2 4 | ||
166 | &mov( $tmp1, $t ); # 2 1 | ||
167 | &and( $tmp1, "0xfc" ); # 2 3 | ||
168 | &shr( $t, 8 ); # 2 5 | ||
169 | &xor( $L, &DWP("0x300+$desSP",$tmp1,"",0)); # 2 7 | ||
170 | &shr( $u, 8 ); # 2 6 | ||
171 | &mov( $tmp1, &DWP("0x200+$desSP",$tmp2,"",0)); # 2 8 | ||
172 | &mov( $tmp2, $u ); # 3 2 | ||
173 | |||
174 | &xor( $L, $tmp1 ); # 2 9 | ||
175 | &and( $tmp2, "0xfc" ); # 3 4 | ||
176 | |||
177 | &mov( $tmp1, $t ); # 3 1 | ||
178 | &shr( $u, 8 ); # 3 6 | ||
179 | &and( $tmp1, "0xfc" ); # 3 3 | ||
180 | &shr( $t, 8 ); # 3 5 | ||
181 | &xor( $L, &DWP("0x500+$desSP",$tmp1,"",0)); # 3 7 | ||
182 | &mov( $tmp1, &DWP("0x400+$desSP",$tmp2,"",0)); # 3 8 | ||
183 | |||
184 | &and( $t, "0xfc" ); # 4 1 | ||
185 | &xor( $L, $tmp1 ); # 3 9 | ||
186 | |||
187 | &and( $u, "0xfc" ); # 4 2 | ||
188 | &xor( $L, &DWP("0x700+$desSP",$t,"",0)); # 4 3 | ||
189 | &xor( $L, &DWP("0x600+$desSP",$u,"",0)); # 4 4 | ||
190 | } | ||
191 | |||
192 | sub PERM_OP | ||
193 | { | ||
194 | local($a,$b,$tt,$shift,$mask)=@_; | ||
195 | |||
196 | &mov( $tt, $a ); | ||
197 | &shr( $tt, $shift ); | ||
198 | &xor( $tt, $b ); | ||
199 | &and( $tt, $mask ); | ||
200 | &xor( $b, $tt ); | ||
201 | &shl( $tt, $shift ); | ||
202 | &xor( $a, $tt ); | ||
203 | } | ||
204 | |||
205 | sub IP_new | ||
206 | { | ||
207 | local($l,$r,$tt)=@_; | ||
208 | |||
209 | &PERM_OP($r,$l,$tt, 4,"0x0f0f0f0f"); | ||
210 | &PERM_OP($l,$r,$tt,16,"0x0000ffff"); | ||
211 | &PERM_OP($r,$l,$tt, 2,"0x33333333"); | ||
212 | &PERM_OP($l,$r,$tt, 8,"0x00ff00ff"); | ||
213 | &PERM_OP($r,$l,$tt, 1,"0x55555555"); | ||
214 | } | ||
215 | |||
216 | sub FP_new | ||
217 | { | ||
218 | local($l,$r,$tt)=@_; | ||
219 | |||
220 | &PERM_OP($l,$r,$tt, 1,"0x55555555"); | ||
221 | &PERM_OP($r,$l,$tt, 8,"0x00ff00ff"); | ||
222 | &PERM_OP($l,$r,$tt, 2,"0x33333333"); | ||
223 | &PERM_OP($r,$l,$tt,16,"0x0000ffff"); | ||
224 | &PERM_OP($l,$r,$tt, 4,"0x0f0f0f0f"); | ||
225 | } | ||
226 | |||
227 | sub n2a | ||
228 | { | ||
229 | sprintf("%d",$_[0]); | ||
230 | } | ||