summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/des/asm
diff options
context:
space:
mode:
authormarkus <>2003-05-11 21:36:58 +0000
committermarkus <>2003-05-11 21:36:58 +0000
commit1c98a87f0daac81245653c227eb2f2508a22a965 (patch)
tree3de6d603296ec563b936da4e6a8a1e33d48f8884 /src/lib/libcrypto/des/asm
parent31392c89d1135cf2a416f97295f6d21681b3fbc4 (diff)
downloadopenbsd-1c98a87f0daac81245653c227eb2f2508a22a965.tar.gz
openbsd-1c98a87f0daac81245653c227eb2f2508a22a965.tar.bz2
openbsd-1c98a87f0daac81245653c227eb2f2508a22a965.zip
import 0.9.7b (without idea and rc5)
Diffstat (limited to 'src/lib/libcrypto/des/asm')
-rw-r--r--src/lib/libcrypto/des/asm/crypt586.pl46
-rw-r--r--src/lib/libcrypto/des/asm/des-586.pl50
2 files changed, 49 insertions, 47 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
69sub D_ENCRYPT 76sub 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
129sub n2a 133sub n2a
diff --git a/src/lib/libcrypto/des/asm/des-586.pl b/src/lib/libcrypto/des/asm/des-586.pl
index 0d08e8a3a9..b75d3c6b3a 100644
--- a/src/lib/libcrypto/des/asm/des-586.pl
+++ b/src/lib/libcrypto/des/asm/des-586.pl
@@ -40,7 +40,7 @@ sub DES_encrypt
40 40
41 &comment(""); 41 &comment("");
42 &comment("Load the 2 words"); 42 &comment("Load the 2 words");
43 $ks="ebp"; 43 $trans="ebp";
44 44
45 if ($do_ip) 45 if ($do_ip)
46 { 46 {
@@ -72,7 +72,12 @@ sub DES_encrypt
72 &rotl($L,3); 72 &rotl($L,3);
73 } 73 }
74 74
75 &mov( $ks, &wparam(1) ); 75 # PIC-ification:-)
76 &picmeup($trans,"DES_SPtrans");
77 #if ($cpp) { &picmeup($trans,"DES_SPtrans"); }
78 #else { &lea($trans,&DWP("DES_SPtrans")); }
79
80 &mov( "ecx", &wparam(1) );
76 &cmp("ebx","0"); 81 &cmp("ebx","0");
77 &je(&label("start_decrypt")); 82 &je(&label("start_decrypt"));
78 83
@@ -80,11 +85,11 @@ sub DES_encrypt
80 { 85 {
81 &comment(""); 86 &comment("");
82 &comment("Round $i"); 87 &comment("Round $i");
83 &D_ENCRYPT($i,$L,$R,$i*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); 88 &D_ENCRYPT($i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx");
84 89
85 &comment(""); 90 &comment("");
86 &comment("Round ".sprintf("%d",$i+1)); 91 &comment("Round ".sprintf("%d",$i+1));
87 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); 92 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$trans,"eax","ebx","ecx","edx");
88 } 93 }
89 &jmp(&label("end")); 94 &jmp(&label("end"));
90 95
@@ -94,10 +99,10 @@ sub DES_encrypt
94 { 99 {
95 &comment(""); 100 &comment("");
96 &comment("Round $i"); 101 &comment("Round $i");
97 &D_ENCRYPT(15-$i,$L,$R,$i*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); 102 &D_ENCRYPT(15-$i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx");
98 &comment(""); 103 &comment("");
99 &comment("Round ".sprintf("%d",$i-1)); 104 &comment("Round ".sprintf("%d",$i-1));
100 &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); 105 &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$trans,"eax","ebx","ecx","edx");
101 } 106 }
102 107
103 &set_label("end"); 108 &set_label("end");
@@ -134,43 +139,36 @@ sub DES_encrypt
134 139
135sub D_ENCRYPT 140sub D_ENCRYPT
136 { 141 {
137 local($r,$L,$R,$S,$ks,$desSP,$u,$tmp1,$tmp2,$t)=@_; 142 local($r,$L,$R,$S,$trans,$u,$tmp1,$tmp2,$t)=@_;
138 143
139 &mov( $u, &DWP(&n2a($S*4),$ks,"",0)); 144 &mov( $u, &DWP(&n2a($S*4),$tmp2,"",0));
140 &xor( $tmp1, $tmp1); 145 &xor( $tmp1, $tmp1);
141 &mov( $t, &DWP(&n2a(($S+1)*4),$ks,"",0)); 146 &mov( $t, &DWP(&n2a(($S+1)*4),$tmp2,"",0));
142 &xor( $u, $R); 147 &xor( $u, $R);
148 &xor( $tmp2, $tmp2);
143 &xor( $t, $R); 149 &xor( $t, $R);
144 &and( $u, "0xfcfcfcfc" ); 150 &and( $u, "0xfcfcfcfc" );
145 &and( $t, "0xcfcfcfcf" ); 151 &and( $t, "0xcfcfcfcf" );
146 &movb( &LB($tmp1), &LB($u) ); 152 &movb( &LB($tmp1), &LB($u) );
147 &movb( &LB($tmp2), &HB($u) ); 153 &movb( &LB($tmp2), &HB($u) );
148 &rotr( $t, 4 ); 154 &rotr( $t, 4 );
149 &mov( $ks, &DWP(" $desSP",$tmp1,"",0)); 155 &xor( $L, &DWP(" ",$trans,$tmp1,0));
150 &movb( &LB($tmp1), &LB($t) ); 156 &movb( &LB($tmp1), &LB($t) );
151 &xor( $L, $ks); 157 &xor( $L, &DWP("0x200",$trans,$tmp2,0));
152 &mov( $ks, &DWP("0x200+$desSP",$tmp2,"",0));
153 &xor( $L, $ks); ######
154 &movb( &LB($tmp2), &HB($t) ); 158 &movb( &LB($tmp2), &HB($t) );
155 &shr( $u, 16); 159 &shr( $u, 16);
156 &mov( $ks, &DWP("0x100+$desSP",$tmp1,"",0)); 160 &xor( $L, &DWP("0x100",$trans,$tmp1,0));
157 &xor( $L, $ks); ######
158 &movb( &LB($tmp1), &HB($u) ); 161 &movb( &LB($tmp1), &HB($u) );
159 &shr( $t, 16); 162 &shr( $t, 16);
160 &mov( $ks, &DWP("0x300+$desSP",$tmp2,"",0)); 163 &xor( $L, &DWP("0x300",$trans,$tmp2,0));
161 &xor( $L, $ks);
162 &mov( $ks, &wparam(1) );
163 &movb( &LB($tmp2), &HB($t) ); 164 &movb( &LB($tmp2), &HB($t) );
164 &and( $u, "0xff" ); 165 &and( $u, "0xff" );
165 &and( $t, "0xff" ); 166 &and( $t, "0xff" );
166 &mov( $tmp1, &DWP("0x600+$desSP",$tmp1,"",0)); 167 &xor( $L, &DWP("0x600",$trans,$tmp1,0));
167 &xor( $L, $tmp1); 168 &xor( $L, &DWP("0x700",$trans,$tmp2,0));
168 &mov( $tmp1, &DWP("0x700+$desSP",$tmp2,"",0)); 169 &mov( $tmp2, &wparam(1) );
169 &xor( $L, $tmp1); 170 &xor( $L, &DWP("0x400",$trans,$u,0));
170 &mov( $tmp1, &DWP("0x400+$desSP",$u,"",0)); 171 &xor( $L, &DWP("0x500",$trans,$t,0));
171 &xor( $L, $tmp1);
172 &mov( $tmp1, &DWP("0x500+$desSP",$t,"",0));
173 &xor( $L, $tmp1);
174 } 172 }
175 173
176sub n2a 174sub n2a