diff options
Diffstat (limited to 'src/lib/libcrypto/des/asm/crypt586.pl')
-rw-r--r-- | src/lib/libcrypto/des/asm/crypt586.pl | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/src/lib/libcrypto/des/asm/crypt586.pl b/src/lib/libcrypto/des/asm/crypt586.pl index 3d41d82f69..1d04ed6def 100644 --- a/src/lib/libcrypto/des/asm/crypt586.pl +++ b/src/lib/libcrypto/des/asm/crypt586.pl | |||
@@ -26,11 +26,18 @@ sub fcrypt_body | |||
26 | 26 | ||
27 | &comment(""); | 27 | &comment(""); |
28 | &comment("Load the 2 words"); | 28 | &comment("Load the 2 words"); |
29 | $ks="ebp"; | 29 | $trans="ebp"; |
30 | 30 | ||
31 | &xor( $L, $L); | 31 | &xor( $L, $L); |
32 | &xor( $R, $R); | 32 | &xor( $R, $R); |
33 | &mov($ks,&wparam(1)); | 33 | |
34 | # PIC-ification:-) | ||
35 | &picmeup("edx","DES_SPtrans"); | ||
36 | #if ($cpp) { &picmeup("edx","DES_SPtrans"); } | ||
37 | #else { &lea("edx",&DWP("DES_SPtrans")); } | ||
38 | &push("edx"); # becomes &swtmp(1) | ||
39 | # | ||
40 | &mov($trans,&wparam(1)); # reloaded with DES_SPtrans in D_ENCRYPT | ||
34 | 41 | ||
35 | &push(&DWC(25)); # add a variable | 42 | &push(&DWC(25)); # add a variable |
36 | 43 | ||
@@ -39,11 +46,11 @@ sub fcrypt_body | |||
39 | { | 46 | { |
40 | &comment(""); | 47 | &comment(""); |
41 | &comment("Round $i"); | 48 | &comment("Round $i"); |
42 | &D_ENCRYPT($i,$L,$R,$i*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); | 49 | &D_ENCRYPT($i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx"); |
43 | 50 | ||
44 | &comment(""); | 51 | &comment(""); |
45 | &comment("Round ".sprintf("%d",$i+1)); | 52 | &comment("Round ".sprintf("%d",$i+1)); |
46 | &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); | 53 | &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$trans,"eax","ebx","ecx","edx"); |
47 | } | 54 | } |
48 | &mov("ebx", &swtmp(0)); | 55 | &mov("ebx", &swtmp(0)); |
49 | &mov("eax", $L); | 56 | &mov("eax", $L); |
@@ -61,14 +68,14 @@ sub fcrypt_body | |||
61 | &mov(&DWP(0,"edx","",0),"eax"); | 68 | &mov(&DWP(0,"edx","",0),"eax"); |
62 | &mov(&DWP(4,"edx","",0),$L); | 69 | &mov(&DWP(4,"edx","",0),$L); |
63 | 70 | ||
64 | &pop("ecx"); # remove variable | 71 | &add("esp",8); # remove variables |
65 | 72 | ||
66 | &function_end($name); | 73 | &function_end($name); |
67 | } | 74 | } |
68 | 75 | ||
69 | sub D_ENCRYPT | 76 | sub D_ENCRYPT |
70 | { | 77 | { |
71 | local($r,$L,$R,$S,$ks,$desSP,$u,$tmp1,$tmp2,$t)=@_; | 78 | local($r,$L,$R,$S,$trans,$u,$tmp1,$tmp2,$t)=@_; |
72 | 79 | ||
73 | &mov( $u, &wparam(2)); # 2 | 80 | &mov( $u, &wparam(2)); # 2 |
74 | &mov( $t, $R); | 81 | &mov( $t, $R); |
@@ -85,9 +92,9 @@ sub D_ENCRYPT | |||
85 | &shl( $tmp2, 16); # 1 | 92 | &shl( $tmp2, 16); # 1 |
86 | &xor( $u, $tmp1); # 2 | 93 | &xor( $u, $tmp1); # 2 |
87 | &xor( $t, $tmp2); # 2 | 94 | &xor( $t, $tmp2); # 2 |
88 | &mov( $tmp1, &DWP(&n2a($S*4),$ks,"",0)); # 2 | 95 | &mov( $tmp1, &DWP(&n2a($S*4),$trans,"",0)); # 2 |
89 | &xor( $u, $tmp1); | 96 | &xor( $u, $tmp1); |
90 | &mov( $tmp2, &DWP(&n2a(($S+1)*4),$ks,"",0)); # 2 | 97 | &mov( $tmp2, &DWP(&n2a(($S+1)*4),$trans,"",0)); # 2 |
91 | &xor( $u, $R); | 98 | &xor( $u, $R); |
92 | &xor( $t, $R); | 99 | &xor( $t, $R); |
93 | &xor( $t, $tmp2); | 100 | &xor( $t, $tmp2); |
@@ -99,31 +106,28 @@ sub D_ENCRYPT | |||
99 | &movb( &LB($tmp1), &LB($u) ); | 106 | &movb( &LB($tmp1), &LB($u) ); |
100 | &movb( &LB($tmp2), &HB($u) ); | 107 | &movb( &LB($tmp2), &HB($u) ); |
101 | &rotr( $t, 4 ); | 108 | &rotr( $t, 4 ); |
102 | &mov( $ks, &DWP(" $desSP",$tmp1,"",0)); | 109 | &mov( $trans, &swtmp(1)); |
110 | &xor( $L, &DWP(" ",$trans,$tmp1,0)); | ||
103 | &movb( &LB($tmp1), &LB($t) ); | 111 | &movb( &LB($tmp1), &LB($t) ); |
104 | &xor( $L, $ks); | 112 | &xor( $L, &DWP("0x200",$trans,$tmp2,0)); |
105 | &mov( $ks, &DWP("0x200+$desSP",$tmp2,"",0)); | ||
106 | &xor( $L, $ks); | ||
107 | &movb( &LB($tmp2), &HB($t) ); | 113 | &movb( &LB($tmp2), &HB($t) ); |
108 | &shr( $u, 16); | 114 | &shr( $u, 16); |
109 | &mov( $ks, &DWP("0x100+$desSP",$tmp1,"",0)); | 115 | &xor( $L, &DWP("0x100",$trans,$tmp1,0)); |
110 | &xor( $L, $ks); | ||
111 | &movb( &LB($tmp1), &HB($u) ); | 116 | &movb( &LB($tmp1), &HB($u) ); |
112 | &shr( $t, 16); | 117 | &shr( $t, 16); |
113 | &mov( $ks, &DWP("0x300+$desSP",$tmp2,"",0)); | 118 | &xor( $L, &DWP("0x300",$trans,$tmp2,0)); |
114 | &xor( $L, $ks); | ||
115 | &mov( $ks, &wparam(1)); | ||
116 | &movb( &LB($tmp2), &HB($t) ); | 119 | &movb( &LB($tmp2), &HB($t) ); |
117 | &and( $u, "0xff" ); | 120 | &and( $u, "0xff" ); |
118 | &and( $t, "0xff" ); | 121 | &and( $t, "0xff" ); |
119 | &mov( $tmp1, &DWP("0x600+$desSP",$tmp1,"",0)); | 122 | &mov( $tmp1, &DWP("0x600",$trans,$tmp1,0)); |
120 | &xor( $L, $tmp1); | 123 | &xor( $L, $tmp1); |
121 | &mov( $tmp1, &DWP("0x700+$desSP",$tmp2,"",0)); | 124 | &mov( $tmp1, &DWP("0x700",$trans,$tmp2,0)); |
122 | &xor( $L, $tmp1); | 125 | &xor( $L, $tmp1); |
123 | &mov( $tmp1, &DWP("0x400+$desSP",$u,"",0)); | 126 | &mov( $tmp1, &DWP("0x400",$trans,$u,0)); |
124 | &xor( $L, $tmp1); | 127 | &xor( $L, $tmp1); |
125 | &mov( $tmp1, &DWP("0x500+$desSP",$t,"",0)); | 128 | &mov( $tmp1, &DWP("0x500",$trans,$t,0)); |
126 | &xor( $L, $tmp1); | 129 | &xor( $L, $tmp1); |
130 | &mov( $trans, &wparam(1)); | ||
127 | } | 131 | } |
128 | 132 | ||
129 | sub n2a | 133 | sub n2a |