diff options
Diffstat (limited to 'src/lib/libcrypto/des')
30 files changed, 0 insertions, 5157 deletions
diff --git a/src/lib/libcrypto/des/COPYRIGHT b/src/lib/libcrypto/des/COPYRIGHT deleted file mode 100644 index 5469e1e469..0000000000 --- a/src/lib/libcrypto/des/COPYRIGHT +++ /dev/null | |||
@@ -1,50 +0,0 @@ | |||
1 | Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) | ||
2 | All rights reserved. | ||
3 | |||
4 | This package is an DES implementation written by Eric Young (eay@cryptsoft.com). | ||
5 | The implementation was written so as to conform with MIT's libdes. | ||
6 | |||
7 | This library is free for commercial and non-commercial use as long as | ||
8 | the following conditions are aheared to. The following conditions | ||
9 | apply to all code found in this distribution. | ||
10 | |||
11 | Copyright remains Eric Young's, and as such any Copyright notices in | ||
12 | the code are not to be removed. | ||
13 | If this package is used in a product, Eric Young should be given attribution | ||
14 | as the author of that the SSL library. This can be in the form of a textual | ||
15 | message at program startup or in documentation (online or textual) provided | ||
16 | with the package. | ||
17 | |||
18 | Redistribution and use in source and binary forms, with or without | ||
19 | modification, are permitted provided that the following conditions | ||
20 | are met: | ||
21 | 1. Redistributions of source code must retain the copyright | ||
22 | notice, this list of conditions and the following disclaimer. | ||
23 | 2. Redistributions in binary form must reproduce the above copyright | ||
24 | notice, this list of conditions and the following disclaimer in the | ||
25 | documentation and/or other materials provided with the distribution. | ||
26 | 3. All advertising materials mentioning features or use of this software | ||
27 | must display the following acknowledgement: | ||
28 | This product includes software developed by Eric Young (eay@cryptsoft.com) | ||
29 | |||
30 | THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
31 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
32 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
33 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
34 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
35 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
36 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
37 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
38 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
39 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
40 | SUCH DAMAGE. | ||
41 | |||
42 | The license and distribution terms for any publically available version or | ||
43 | derivative of this code cannot be changed. i.e. this code cannot simply be | ||
44 | copied and put under another distrubution license | ||
45 | [including the GNU Public License.] | ||
46 | |||
47 | The reason behind this being stated in this direct manner is past | ||
48 | experience in code simply being copied and the attribution removed | ||
49 | from it and then being distributed as part of other packages. This | ||
50 | implementation was a non-trivial and unpaid effort. | ||
diff --git a/src/lib/libcrypto/des/asm/crypt586.pl b/src/lib/libcrypto/des/asm/crypt586.pl deleted file mode 100644 index 197c413ea6..0000000000 --- a/src/lib/libcrypto/des/asm/crypt586.pl +++ /dev/null | |||
@@ -1,204 +0,0 @@ | |||
1 | #!/usr/local/bin/perl | ||
2 | # | ||
3 | # The inner loop instruction sequence and the IP/FP modifications are from | ||
4 | # Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk> | ||
5 | # I've added the stuff needed for crypt() but I've not worried about making | ||
6 | # things perfect. | ||
7 | # | ||
8 | |||
9 | push(@INC,"perlasm","../../perlasm"); | ||
10 | require "x86asm.pl"; | ||
11 | |||
12 | &asm_init($ARGV[0],"crypt586.pl"); | ||
13 | |||
14 | $L="edi"; | ||
15 | $R="esi"; | ||
16 | |||
17 | &external_label("des_SPtrans"); | ||
18 | &fcrypt_body("fcrypt_body"); | ||
19 | &asm_finish(); | ||
20 | |||
21 | sub fcrypt_body | ||
22 | { | ||
23 | local($name,$do_ip)=@_; | ||
24 | |||
25 | &function_begin($name,"EXTRN _des_SPtrans:DWORD"); | ||
26 | |||
27 | &comment(""); | ||
28 | &comment("Load the 2 words"); | ||
29 | $ks="ebp"; | ||
30 | |||
31 | &xor( $L, $L); | ||
32 | &xor( $R, $R); | ||
33 | &mov($ks,&wparam(1)); | ||
34 | |||
35 | &push(&DWC(25)); # add a variable | ||
36 | |||
37 | &set_label("start"); | ||
38 | for ($i=0; $i<16; $i+=2) | ||
39 | { | ||
40 | &comment(""); | ||
41 | &comment("Round $i"); | ||
42 | &D_ENCRYPT($i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx"); | ||
43 | |||
44 | &comment(""); | ||
45 | &comment("Round ".sprintf("%d",$i+1)); | ||
46 | &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx"); | ||
47 | } | ||
48 | &mov("ebx", &swtmp(0)); | ||
49 | &mov("eax", $L); | ||
50 | &dec("ebx"); | ||
51 | &mov($L, $R); | ||
52 | &mov($R, "eax"); | ||
53 | &mov(&swtmp(0), "ebx"); | ||
54 | &jnz(&label("start")); | ||
55 | |||
56 | &comment(""); | ||
57 | &comment("FP"); | ||
58 | &mov("edx",&wparam(0)); | ||
59 | |||
60 | &FP_new($R,$L,"eax",3); | ||
61 | &mov(&DWP(0,"edx","",0),"eax"); | ||
62 | &mov(&DWP(4,"edx","",0),$L); | ||
63 | |||
64 | &pop("ecx"); # remove variable | ||
65 | |||
66 | &function_end($name); | ||
67 | } | ||
68 | |||
69 | sub D_ENCRYPT | ||
70 | { | ||
71 | local($r,$L,$R,$S,$ks,$desSP,$u,$tmp1,$tmp2,$t)=@_; | ||
72 | |||
73 | &mov( $u, &wparam(2)); # 2 | ||
74 | &mov( $t, $R); | ||
75 | &shr( $t, 16); # 1 | ||
76 | &mov( $tmp2, &wparam(3)); # 2 | ||
77 | &xor( $t, $R); # 1 | ||
78 | |||
79 | &and( $u, $t); # 2 | ||
80 | &and( $t, $tmp2); # 2 | ||
81 | |||
82 | &mov( $tmp1, $u); | ||
83 | &shl( $tmp1, 16); # 1 | ||
84 | &mov( $tmp2, $t); | ||
85 | &shl( $tmp2, 16); # 1 | ||
86 | &xor( $u, $tmp1); # 2 | ||
87 | &xor( $t, $tmp2); # 2 | ||
88 | &mov( $tmp1, &DWP(&n2a($S*4),$ks,"",0)); # 2 | ||
89 | &xor( $u, $tmp1); | ||
90 | &mov( $tmp2, &DWP(&n2a(($S+1)*4),$ks,"",0)); # 2 | ||
91 | &xor( $u, $R); | ||
92 | &xor( $t, $R); | ||
93 | &xor( $t, $tmp2); | ||
94 | |||
95 | &and( $u, "0xfcfcfcfc" ); # 2 | ||
96 | &xor( $tmp1, $tmp1); # 1 | ||
97 | &and( $t, "0xcfcfcfcf" ); # 2 | ||
98 | &xor( $tmp2, $tmp2); | ||
99 | &movb( &LB($tmp1), &LB($u) ); | ||
100 | &movb( &LB($tmp2), &HB($u) ); | ||
101 | &rotr( $t, 4 ); | ||
102 | &mov( $ks, &DWP(" $desSP",$tmp1,"",0)); | ||
103 | &movb( &LB($tmp1), &LB($t) ); | ||
104 | &xor( $L, $ks); | ||
105 | &mov( $ks, &DWP("0x200+$desSP",$tmp2,"",0)); | ||
106 | &xor( $L, $ks); | ||
107 | &movb( &LB($tmp2), &HB($t) ); | ||
108 | &shr( $u, 16); | ||
109 | &mov( $ks, &DWP("0x100+$desSP",$tmp1,"",0)); | ||
110 | &xor( $L, $ks); | ||
111 | &movb( &LB($tmp1), &HB($u) ); | ||
112 | &shr( $t, 16); | ||
113 | &mov( $ks, &DWP("0x300+$desSP",$tmp2,"",0)); | ||
114 | &xor( $L, $ks); | ||
115 | &mov( $ks, &wparam(1)); | ||
116 | &movb( &LB($tmp2), &HB($t) ); | ||
117 | &and( $u, "0xff" ); | ||
118 | &and( $t, "0xff" ); | ||
119 | &mov( $tmp1, &DWP("0x600+$desSP",$tmp1,"",0)); | ||
120 | &xor( $L, $tmp1); | ||
121 | &mov( $tmp1, &DWP("0x700+$desSP",$tmp2,"",0)); | ||
122 | &xor( $L, $tmp1); | ||
123 | &mov( $tmp1, &DWP("0x400+$desSP",$u,"",0)); | ||
124 | &xor( $L, $tmp1); | ||
125 | &mov( $tmp1, &DWP("0x500+$desSP",$t,"",0)); | ||
126 | &xor( $L, $tmp1); | ||
127 | } | ||
128 | |||
129 | sub n2a | ||
130 | { | ||
131 | sprintf("%d",$_[0]); | ||
132 | } | ||
133 | |||
134 | # now has a side affect of rotating $a by $shift | ||
135 | sub R_PERM_OP | ||
136 | { | ||
137 | local($a,$b,$tt,$shift,$mask,$last)=@_; | ||
138 | |||
139 | &rotl( $a, $shift ) if ($shift != 0); | ||
140 | &mov( $tt, $a ); | ||
141 | &xor( $a, $b ); | ||
142 | &and( $a, $mask ); | ||
143 | if ($notlast eq $b) | ||
144 | { | ||
145 | &xor( $b, $a ); | ||
146 | &xor( $tt, $a ); | ||
147 | } | ||
148 | else | ||
149 | { | ||
150 | &xor( $tt, $a ); | ||
151 | &xor( $b, $a ); | ||
152 | } | ||
153 | &comment(""); | ||
154 | } | ||
155 | |||
156 | sub IP_new | ||
157 | { | ||
158 | local($l,$r,$tt,$lr)=@_; | ||
159 | |||
160 | &R_PERM_OP($l,$r,$tt, 4,"0xf0f0f0f0",$l); | ||
161 | &R_PERM_OP($r,$tt,$l,20,"0xfff0000f",$l); | ||
162 | &R_PERM_OP($l,$tt,$r,14,"0x33333333",$r); | ||
163 | &R_PERM_OP($tt,$r,$l,22,"0x03fc03fc",$r); | ||
164 | &R_PERM_OP($l,$r,$tt, 9,"0xaaaaaaaa",$r); | ||
165 | |||
166 | if ($lr != 3) | ||
167 | { | ||
168 | if (($lr-3) < 0) | ||
169 | { &rotr($tt, 3-$lr); } | ||
170 | else { &rotl($tt, $lr-3); } | ||
171 | } | ||
172 | if ($lr != 2) | ||
173 | { | ||
174 | if (($lr-2) < 0) | ||
175 | { &rotr($r, 2-$lr); } | ||
176 | else { &rotl($r, $lr-2); } | ||
177 | } | ||
178 | } | ||
179 | |||
180 | sub FP_new | ||
181 | { | ||
182 | local($l,$r,$tt,$lr)=@_; | ||
183 | |||
184 | if ($lr != 2) | ||
185 | { | ||
186 | if (($lr-2) < 0) | ||
187 | { &rotl($r, 2-$lr); } | ||
188 | else { &rotr($r, $lr-2); } | ||
189 | } | ||
190 | if ($lr != 3) | ||
191 | { | ||
192 | if (($lr-3) < 0) | ||
193 | { &rotl($l, 3-$lr); } | ||
194 | else { &rotr($l, $lr-3); } | ||
195 | } | ||
196 | |||
197 | &R_PERM_OP($l,$r,$tt, 0,"0xaaaaaaaa",$r); | ||
198 | &R_PERM_OP($tt,$r,$l,23,"0x03fc03fc",$r); | ||
199 | &R_PERM_OP($l,$r,$tt,10,"0x33333333",$l); | ||
200 | &R_PERM_OP($r,$tt,$l,18,"0xfff0000f",$l); | ||
201 | &R_PERM_OP($l,$tt,$r,12,"0xf0f0f0f0",$r); | ||
202 | &rotr($tt , 4); | ||
203 | } | ||
204 | |||
diff --git a/src/lib/libcrypto/des/asm/des-586.pl b/src/lib/libcrypto/des/asm/des-586.pl deleted file mode 100644 index c890766bc9..0000000000 --- a/src/lib/libcrypto/des/asm/des-586.pl +++ /dev/null | |||
@@ -1,253 +0,0 @@ | |||
1 | #!/usr/local/bin/perl | ||
2 | # | ||
3 | # The inner loop instruction sequence and the IP/FP modifications are from | ||
4 | # Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk> | ||
5 | # | ||
6 | |||
7 | push(@INC,"perlasm","../../perlasm"); | ||
8 | require "x86asm.pl"; | ||
9 | require "cbc.pl"; | ||
10 | require "desboth.pl"; | ||
11 | |||
12 | # base code is in microsft | ||
13 | # op dest, source | ||
14 | # format. | ||
15 | # | ||
16 | |||
17 | &asm_init($ARGV[0],"des-586.pl"); | ||
18 | |||
19 | $L="edi"; | ||
20 | $R="esi"; | ||
21 | |||
22 | &external_label("des_SPtrans"); | ||
23 | &des_encrypt("des_encrypt1",1); | ||
24 | &des_encrypt("des_encrypt2",0); | ||
25 | &des_encrypt3("des_encrypt3",1); | ||
26 | &des_encrypt3("des_decrypt3",0); | ||
27 | &cbc("des_ncbc_encrypt","des_encrypt1","des_encrypt1",0,4,5,3,5,-1); | ||
28 | &cbc("des_ede3_cbc_encrypt","des_encrypt3","des_decrypt3",0,6,7,3,4,5); | ||
29 | |||
30 | &asm_finish(); | ||
31 | |||
32 | sub des_encrypt | ||
33 | { | ||
34 | local($name,$do_ip)=@_; | ||
35 | |||
36 | &function_begin_B($name,"EXTRN _des_SPtrans:DWORD"); | ||
37 | |||
38 | &push("esi"); | ||
39 | &push("edi"); | ||
40 | |||
41 | &comment(""); | ||
42 | &comment("Load the 2 words"); | ||
43 | $ks="ebp"; | ||
44 | |||
45 | if ($do_ip) | ||
46 | { | ||
47 | &mov($R,&wparam(0)); | ||
48 | &xor( "ecx", "ecx" ); | ||
49 | |||
50 | &push("ebx"); | ||
51 | &push("ebp"); | ||
52 | |||
53 | &mov("eax",&DWP(0,$R,"",0)); | ||
54 | &mov("ebx",&wparam(2)); # get encrypt flag | ||
55 | &mov($L,&DWP(4,$R,"",0)); | ||
56 | &comment(""); | ||
57 | &comment("IP"); | ||
58 | &IP_new("eax",$L,$R,3); | ||
59 | } | ||
60 | else | ||
61 | { | ||
62 | &mov("eax",&wparam(0)); | ||
63 | &xor( "ecx", "ecx" ); | ||
64 | |||
65 | &push("ebx"); | ||
66 | &push("ebp"); | ||
67 | |||
68 | &mov($R,&DWP(0,"eax","",0)); | ||
69 | &mov("ebx",&wparam(2)); # get encrypt flag | ||
70 | &rotl($R,3); | ||
71 | &mov($L,&DWP(4,"eax","",0)); | ||
72 | &rotl($L,3); | ||
73 | } | ||
74 | |||
75 | &mov( $ks, &wparam(1) ); | ||
76 | &cmp("ebx","0"); | ||
77 | &je(&label("start_decrypt")); | ||
78 | |||
79 | for ($i=0; $i<16; $i+=2) | ||
80 | { | ||
81 | &comment(""); | ||
82 | &comment("Round $i"); | ||
83 | &D_ENCRYPT($i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx"); | ||
84 | |||
85 | &comment(""); | ||
86 | &comment("Round ".sprintf("%d",$i+1)); | ||
87 | &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx"); | ||
88 | } | ||
89 | &jmp(&label("end")); | ||
90 | |||
91 | &set_label("start_decrypt"); | ||
92 | |||
93 | for ($i=15; $i>0; $i-=2) | ||
94 | { | ||
95 | &comment(""); | ||
96 | &comment("Round $i"); | ||
97 | &D_ENCRYPT(15-$i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx"); | ||
98 | &comment(""); | ||
99 | &comment("Round ".sprintf("%d",$i-1)); | ||
100 | &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx"); | ||
101 | } | ||
102 | |||
103 | &set_label("end"); | ||
104 | |||
105 | if ($do_ip) | ||
106 | { | ||
107 | &comment(""); | ||
108 | &comment("FP"); | ||
109 | &mov("edx",&wparam(0)); | ||
110 | &FP_new($L,$R,"eax",3); | ||
111 | |||
112 | &mov(&DWP(0,"edx","",0),"eax"); | ||
113 | &mov(&DWP(4,"edx","",0),$R); | ||
114 | } | ||
115 | else | ||
116 | { | ||
117 | &comment(""); | ||
118 | &comment("Fixup"); | ||
119 | &rotr($L,3); # r | ||
120 | &mov("eax",&wparam(0)); | ||
121 | &rotr($R,3); # l | ||
122 | &mov(&DWP(0,"eax","",0),$L); | ||
123 | &mov(&DWP(4,"eax","",0),$R); | ||
124 | } | ||
125 | |||
126 | &pop("ebp"); | ||
127 | &pop("ebx"); | ||
128 | &pop("edi"); | ||
129 | &pop("esi"); | ||
130 | &ret(); | ||
131 | |||
132 | &function_end_B($name); | ||
133 | } | ||
134 | |||
135 | sub D_ENCRYPT | ||
136 | { | ||
137 | local($r,$L,$R,$S,$ks,$desSP,$u,$tmp1,$tmp2,$t)=@_; | ||
138 | |||
139 | &mov( $u, &DWP(&n2a($S*4),$ks,"",0)); | ||
140 | &xor( $tmp1, $tmp1); | ||
141 | &mov( $t, &DWP(&n2a(($S+1)*4),$ks,"",0)); | ||
142 | &xor( $u, $R); | ||
143 | &xor( $t, $R); | ||
144 | &and( $u, "0xfcfcfcfc" ); | ||
145 | &and( $t, "0xcfcfcfcf" ); | ||
146 | &movb( &LB($tmp1), &LB($u) ); | ||
147 | &movb( &LB($tmp2), &HB($u) ); | ||
148 | &rotr( $t, 4 ); | ||
149 | &mov( $ks, &DWP(" $desSP",$tmp1,"",0)); | ||
150 | &movb( &LB($tmp1), &LB($t) ); | ||
151 | &xor( $L, $ks); | ||
152 | &mov( $ks, &DWP("0x200+$desSP",$tmp2,"",0)); | ||
153 | &xor( $L, $ks); ###### | ||
154 | &movb( &LB($tmp2), &HB($t) ); | ||
155 | &shr( $u, 16); | ||
156 | &mov( $ks, &DWP("0x100+$desSP",$tmp1,"",0)); | ||
157 | &xor( $L, $ks); ###### | ||
158 | &movb( &LB($tmp1), &HB($u) ); | ||
159 | &shr( $t, 16); | ||
160 | &mov( $ks, &DWP("0x300+$desSP",$tmp2,"",0)); | ||
161 | &xor( $L, $ks); | ||
162 | &mov( $ks, &wparam(1) ); | ||
163 | &movb( &LB($tmp2), &HB($t) ); | ||
164 | &and( $u, "0xff" ); | ||
165 | &and( $t, "0xff" ); | ||
166 | &mov( $tmp1, &DWP("0x600+$desSP",$tmp1,"",0)); | ||
167 | &xor( $L, $tmp1); | ||
168 | &mov( $tmp1, &DWP("0x700+$desSP",$tmp2,"",0)); | ||
169 | &xor( $L, $tmp1); | ||
170 | &mov( $tmp1, &DWP("0x400+$desSP",$u,"",0)); | ||
171 | &xor( $L, $tmp1); | ||
172 | &mov( $tmp1, &DWP("0x500+$desSP",$t,"",0)); | ||
173 | &xor( $L, $tmp1); | ||
174 | } | ||
175 | |||
176 | sub n2a | ||
177 | { | ||
178 | sprintf("%d",$_[0]); | ||
179 | } | ||
180 | |||
181 | # now has a side affect of rotating $a by $shift | ||
182 | sub R_PERM_OP | ||
183 | { | ||
184 | local($a,$b,$tt,$shift,$mask,$last)=@_; | ||
185 | |||
186 | &rotl( $a, $shift ) if ($shift != 0); | ||
187 | &mov( $tt, $a ); | ||
188 | &xor( $a, $b ); | ||
189 | &and( $a, $mask ); | ||
190 | # This can never succeed, and besides it is difficult to see what the | ||
191 | # idea was - Ben 13 Feb 99 | ||
192 | if (!$last eq $b) | ||
193 | { | ||
194 | &xor( $b, $a ); | ||
195 | &xor( $tt, $a ); | ||
196 | } | ||
197 | else | ||
198 | { | ||
199 | &xor( $tt, $a ); | ||
200 | &xor( $b, $a ); | ||
201 | } | ||
202 | &comment(""); | ||
203 | } | ||
204 | |||
205 | sub IP_new | ||
206 | { | ||
207 | local($l,$r,$tt,$lr)=@_; | ||
208 | |||
209 | &R_PERM_OP($l,$r,$tt, 4,"0xf0f0f0f0",$l); | ||
210 | &R_PERM_OP($r,$tt,$l,20,"0xfff0000f",$l); | ||
211 | &R_PERM_OP($l,$tt,$r,14,"0x33333333",$r); | ||
212 | &R_PERM_OP($tt,$r,$l,22,"0x03fc03fc",$r); | ||
213 | &R_PERM_OP($l,$r,$tt, 9,"0xaaaaaaaa",$r); | ||
214 | |||
215 | if ($lr != 3) | ||
216 | { | ||
217 | if (($lr-3) < 0) | ||
218 | { &rotr($tt, 3-$lr); } | ||
219 | else { &rotl($tt, $lr-3); } | ||
220 | } | ||
221 | if ($lr != 2) | ||
222 | { | ||
223 | if (($lr-2) < 0) | ||
224 | { &rotr($r, 2-$lr); } | ||
225 | else { &rotl($r, $lr-2); } | ||
226 | } | ||
227 | } | ||
228 | |||
229 | sub FP_new | ||
230 | { | ||
231 | local($l,$r,$tt,$lr)=@_; | ||
232 | |||
233 | if ($lr != 2) | ||
234 | { | ||
235 | if (($lr-2) < 0) | ||
236 | { &rotl($r, 2-$lr); } | ||
237 | else { &rotr($r, $lr-2); } | ||
238 | } | ||
239 | if ($lr != 3) | ||
240 | { | ||
241 | if (($lr-3) < 0) | ||
242 | { &rotl($l, 3-$lr); } | ||
243 | else { &rotr($l, $lr-3); } | ||
244 | } | ||
245 | |||
246 | &R_PERM_OP($l,$r,$tt, 0,"0xaaaaaaaa",$r); | ||
247 | &R_PERM_OP($tt,$r,$l,23,"0x03fc03fc",$r); | ||
248 | &R_PERM_OP($l,$r,$tt,10,"0x33333333",$l); | ||
249 | &R_PERM_OP($r,$tt,$l,18,"0xfff0000f",$l); | ||
250 | &R_PERM_OP($l,$tt,$r,12,"0xf0f0f0f0",$r); | ||
251 | &rotr($tt , 4); | ||
252 | } | ||
253 | |||
diff --git a/src/lib/libcrypto/des/asm/desboth.pl b/src/lib/libcrypto/des/asm/desboth.pl deleted file mode 100644 index d5106414db..0000000000 --- a/src/lib/libcrypto/des/asm/desboth.pl +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | #!/usr/local/bin/perl | ||
2 | |||
3 | $L="edi"; | ||
4 | $R="esi"; | ||
5 | |||
6 | sub des_encrypt3 | ||
7 | { | ||
8 | local($name,$enc)=@_; | ||
9 | |||
10 | &function_begin_B($name,""); | ||
11 | &push("ebx"); | ||
12 | &mov("ebx",&wparam(0)); | ||
13 | |||
14 | &push("ebp"); | ||
15 | &push("esi"); | ||
16 | |||
17 | &push("edi"); | ||
18 | |||
19 | &comment(""); | ||
20 | &comment("Load the data words"); | ||
21 | &mov($L,&DWP(0,"ebx","",0)); | ||
22 | &mov($R,&DWP(4,"ebx","",0)); | ||
23 | &stack_push(3); | ||
24 | |||
25 | &comment(""); | ||
26 | &comment("IP"); | ||
27 | &IP_new($L,$R,"edx",0); | ||
28 | |||
29 | # put them back | ||
30 | |||
31 | if ($enc) | ||
32 | { | ||
33 | &mov(&DWP(4,"ebx","",0),$R); | ||
34 | &mov("eax",&wparam(1)); | ||
35 | &mov(&DWP(0,"ebx","",0),"edx"); | ||
36 | &mov("edi",&wparam(2)); | ||
37 | &mov("esi",&wparam(3)); | ||
38 | } | ||
39 | else | ||
40 | { | ||
41 | &mov(&DWP(4,"ebx","",0),$R); | ||
42 | &mov("esi",&wparam(1)); | ||
43 | &mov(&DWP(0,"ebx","",0),"edx"); | ||
44 | &mov("edi",&wparam(2)); | ||
45 | &mov("eax",&wparam(3)); | ||
46 | } | ||
47 | &mov(&swtmp(2), (DWC(($enc)?"1":"0"))); | ||
48 | &mov(&swtmp(1), "eax"); | ||
49 | &mov(&swtmp(0), "ebx"); | ||
50 | &call("des_encrypt2"); | ||
51 | &mov(&swtmp(2), (DWC(($enc)?"0":"1"))); | ||
52 | &mov(&swtmp(1), "edi"); | ||
53 | &mov(&swtmp(0), "ebx"); | ||
54 | &call("des_encrypt2"); | ||
55 | &mov(&swtmp(2), (DWC(($enc)?"1":"0"))); | ||
56 | &mov(&swtmp(1), "esi"); | ||
57 | &mov(&swtmp(0), "ebx"); | ||
58 | &call("des_encrypt2"); | ||
59 | |||
60 | &stack_pop(3); | ||
61 | &mov($L,&DWP(0,"ebx","",0)); | ||
62 | &mov($R,&DWP(4,"ebx","",0)); | ||
63 | |||
64 | &comment(""); | ||
65 | &comment("FP"); | ||
66 | &FP_new($L,$R,"eax",0); | ||
67 | |||
68 | &mov(&DWP(0,"ebx","",0),"eax"); | ||
69 | &mov(&DWP(4,"ebx","",0),$R); | ||
70 | |||
71 | &pop("edi"); | ||
72 | &pop("esi"); | ||
73 | &pop("ebp"); | ||
74 | &pop("ebx"); | ||
75 | &ret(); | ||
76 | &function_end_B($name); | ||
77 | } | ||
78 | |||
79 | |||
diff --git a/src/lib/libcrypto/des/cbc_cksm.c b/src/lib/libcrypto/des/cbc_cksm.c deleted file mode 100644 index b857df0985..0000000000 --- a/src/lib/libcrypto/des/cbc_cksm.c +++ /dev/null | |||
@@ -1,97 +0,0 @@ | |||
1 | /* crypto/des/cbc_cksm.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include "des_locl.h" | ||
60 | |||
61 | DES_LONG des_cbc_cksum(const unsigned char *in, des_cblock *output, | ||
62 | long length, | ||
63 | des_key_schedule schedule, const_des_cblock *ivec) | ||
64 | { | ||
65 | register DES_LONG tout0,tout1,tin0,tin1; | ||
66 | register long l=length; | ||
67 | DES_LONG tin[2]; | ||
68 | unsigned char *out = &(*output)[0]; | ||
69 | const unsigned char *iv = &(*ivec)[0]; | ||
70 | |||
71 | c2l(iv,tout0); | ||
72 | c2l(iv,tout1); | ||
73 | for (; l>0; l-=8) | ||
74 | { | ||
75 | if (l >= 8) | ||
76 | { | ||
77 | c2l(in,tin0); | ||
78 | c2l(in,tin1); | ||
79 | } | ||
80 | else | ||
81 | c2ln(in,tin0,tin1,l); | ||
82 | |||
83 | tin0^=tout0; tin[0]=tin0; | ||
84 | tin1^=tout1; tin[1]=tin1; | ||
85 | des_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT); | ||
86 | /* fix 15/10/91 eay - thanks to keithr@sco.COM */ | ||
87 | tout0=tin[0]; | ||
88 | tout1=tin[1]; | ||
89 | } | ||
90 | if (out != NULL) | ||
91 | { | ||
92 | l2c(tout0,out); | ||
93 | l2c(tout1,out); | ||
94 | } | ||
95 | tout0=tin0=tin1=tin[0]=tin[1]=0; | ||
96 | return(tout1); | ||
97 | } | ||
diff --git a/src/lib/libcrypto/des/cbc_enc.c b/src/lib/libcrypto/des/cbc_enc.c deleted file mode 100644 index 677903ae4e..0000000000 --- a/src/lib/libcrypto/des/cbc_enc.c +++ /dev/null | |||
@@ -1,61 +0,0 @@ | |||
1 | /* crypto/des/cbc_enc.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #define CBC_ENC_C__DONT_UPDATE_IV | ||
60 | |||
61 | #include "ncbc_enc.c" /* des_cbc_encrypt */ | ||
diff --git a/src/lib/libcrypto/des/cfb64ede.c b/src/lib/libcrypto/des/cfb64ede.c deleted file mode 100644 index 5362a551bf..0000000000 --- a/src/lib/libcrypto/des/cfb64ede.c +++ /dev/null | |||
@@ -1,141 +0,0 @@ | |||
1 | /* crypto/des/cfb64ede.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include "des_locl.h" | ||
60 | |||
61 | /* The input and output encrypted as though 64bit cfb mode is being | ||
62 | * used. The extra state information to record how much of the | ||
63 | * 64bit block we have used is contained in *num; | ||
64 | */ | ||
65 | |||
66 | void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, | ||
67 | long length, des_key_schedule ks1, des_key_schedule ks2, | ||
68 | des_key_schedule ks3, des_cblock *ivec, int *num, int enc) | ||
69 | { | ||
70 | register DES_LONG v0,v1; | ||
71 | register long l=length; | ||
72 | register int n= *num; | ||
73 | DES_LONG ti[2]; | ||
74 | unsigned char *iv,c,cc; | ||
75 | |||
76 | iv=&(*ivec)[0]; | ||
77 | if (enc) | ||
78 | { | ||
79 | while (l--) | ||
80 | { | ||
81 | if (n == 0) | ||
82 | { | ||
83 | c2l(iv,v0); | ||
84 | c2l(iv,v1); | ||
85 | |||
86 | ti[0]=v0; | ||
87 | ti[1]=v1; | ||
88 | des_encrypt3(ti,ks1,ks2,ks3); | ||
89 | v0=ti[0]; | ||
90 | v1=ti[1]; | ||
91 | |||
92 | iv = &(*ivec)[0]; | ||
93 | l2c(v0,iv); | ||
94 | l2c(v1,iv); | ||
95 | iv = &(*ivec)[0]; | ||
96 | } | ||
97 | c= *(in++)^iv[n]; | ||
98 | *(out++)=c; | ||
99 | iv[n]=c; | ||
100 | n=(n+1)&0x07; | ||
101 | } | ||
102 | } | ||
103 | else | ||
104 | { | ||
105 | while (l--) | ||
106 | { | ||
107 | if (n == 0) | ||
108 | { | ||
109 | c2l(iv,v0); | ||
110 | c2l(iv,v1); | ||
111 | |||
112 | ti[0]=v0; | ||
113 | ti[1]=v1; | ||
114 | des_encrypt3(ti,ks1,ks2,ks3); | ||
115 | v0=ti[0]; | ||
116 | v1=ti[1]; | ||
117 | |||
118 | iv = &(*ivec)[0]; | ||
119 | l2c(v0,iv); | ||
120 | l2c(v1,iv); | ||
121 | iv = &(*ivec)[0]; | ||
122 | } | ||
123 | cc= *(in++); | ||
124 | c=iv[n]; | ||
125 | iv[n]=cc; | ||
126 | *(out++)=c^cc; | ||
127 | n=(n+1)&0x07; | ||
128 | } | ||
129 | } | ||
130 | v0=v1=ti[0]=ti[1]=c=cc=0; | ||
131 | *num=n; | ||
132 | } | ||
133 | |||
134 | #ifdef undef /* MACRO */ | ||
135 | void des_ede2_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, | ||
136 | des_key_schedule ks1, des_key_schedule ks2, des_cblock (*ivec), | ||
137 | int *num, int enc) | ||
138 | { | ||
139 | des_ede3_cfb64_encrypt(in,out,length,ks1,ks2,ks1,ivec,num,enc); | ||
140 | } | ||
141 | #endif | ||
diff --git a/src/lib/libcrypto/des/cfb64enc.c b/src/lib/libcrypto/des/cfb64enc.c deleted file mode 100644 index 105530dfa3..0000000000 --- a/src/lib/libcrypto/des/cfb64enc.c +++ /dev/null | |||
@@ -1,121 +0,0 @@ | |||
1 | /* crypto/des/cfb64enc.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include "des_locl.h" | ||
60 | |||
61 | /* The input and output encrypted as though 64bit cfb mode is being | ||
62 | * used. The extra state information to record how much of the | ||
63 | * 64bit block we have used is contained in *num; | ||
64 | */ | ||
65 | |||
66 | void des_cfb64_encrypt(const unsigned char *in, unsigned char *out, | ||
67 | long length, des_key_schedule schedule, des_cblock *ivec, | ||
68 | int *num, int enc) | ||
69 | { | ||
70 | register DES_LONG v0,v1; | ||
71 | register long l=length; | ||
72 | register int n= *num; | ||
73 | DES_LONG ti[2]; | ||
74 | unsigned char *iv,c,cc; | ||
75 | |||
76 | iv = &(*ivec)[0]; | ||
77 | if (enc) | ||
78 | { | ||
79 | while (l--) | ||
80 | { | ||
81 | if (n == 0) | ||
82 | { | ||
83 | c2l(iv,v0); ti[0]=v0; | ||
84 | c2l(iv,v1); ti[1]=v1; | ||
85 | des_encrypt1(ti,schedule,DES_ENCRYPT); | ||
86 | iv = &(*ivec)[0]; | ||
87 | v0=ti[0]; l2c(v0,iv); | ||
88 | v0=ti[1]; l2c(v0,iv); | ||
89 | iv = &(*ivec)[0]; | ||
90 | } | ||
91 | c= *(in++)^iv[n]; | ||
92 | *(out++)=c; | ||
93 | iv[n]=c; | ||
94 | n=(n+1)&0x07; | ||
95 | } | ||
96 | } | ||
97 | else | ||
98 | { | ||
99 | while (l--) | ||
100 | { | ||
101 | if (n == 0) | ||
102 | { | ||
103 | c2l(iv,v0); ti[0]=v0; | ||
104 | c2l(iv,v1); ti[1]=v1; | ||
105 | des_encrypt1(ti,schedule,DES_ENCRYPT); | ||
106 | iv = &(*ivec)[0]; | ||
107 | v0=ti[0]; l2c(v0,iv); | ||
108 | v0=ti[1]; l2c(v0,iv); | ||
109 | iv = &(*ivec)[0]; | ||
110 | } | ||
111 | cc= *(in++); | ||
112 | c=iv[n]; | ||
113 | iv[n]=cc; | ||
114 | *(out++)=c^cc; | ||
115 | n=(n+1)&0x07; | ||
116 | } | ||
117 | } | ||
118 | v0=v1=ti[0]=ti[1]=c=cc=0; | ||
119 | *num=n; | ||
120 | } | ||
121 | |||
diff --git a/src/lib/libcrypto/des/cfb_enc.c b/src/lib/libcrypto/des/cfb_enc.c deleted file mode 100644 index ec4fd4ea67..0000000000 --- a/src/lib/libcrypto/des/cfb_enc.c +++ /dev/null | |||
@@ -1,165 +0,0 @@ | |||
1 | /* crypto/des/cfb_enc.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include "des_locl.h" | ||
60 | |||
61 | /* The input and output are loaded in multiples of 8 bits. | ||
62 | * What this means is that if you hame numbits=12 and length=2 | ||
63 | * the first 12 bits will be retrieved from the first byte and half | ||
64 | * the second. The second 12 bits will come from the 3rd and half the 4th | ||
65 | * byte. | ||
66 | */ | ||
67 | void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | ||
68 | long length, des_key_schedule schedule, des_cblock *ivec, int enc) | ||
69 | { | ||
70 | register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8; | ||
71 | register DES_LONG mask0,mask1; | ||
72 | register unsigned long l=length; | ||
73 | register int num=numbits; | ||
74 | DES_LONG ti[2]; | ||
75 | unsigned char *iv; | ||
76 | |||
77 | if (num > 64) return; | ||
78 | if (num > 32) | ||
79 | { | ||
80 | mask0=0xffffffffL; | ||
81 | if (num == 64) | ||
82 | mask1=mask0; | ||
83 | else mask1=(1L<<(num-32))-1; | ||
84 | } | ||
85 | else | ||
86 | { | ||
87 | if (num == 32) | ||
88 | mask0=0xffffffffL; | ||
89 | else mask0=(1L<<num)-1; | ||
90 | mask1=0x00000000L; | ||
91 | } | ||
92 | |||
93 | iv = &(*ivec)[0]; | ||
94 | c2l(iv,v0); | ||
95 | c2l(iv,v1); | ||
96 | if (enc) | ||
97 | { | ||
98 | while (l >= n) | ||
99 | { | ||
100 | l-=n; | ||
101 | ti[0]=v0; | ||
102 | ti[1]=v1; | ||
103 | des_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); | ||
104 | c2ln(in,d0,d1,n); | ||
105 | in+=n; | ||
106 | d0=(d0^ti[0])&mask0; | ||
107 | d1=(d1^ti[1])&mask1; | ||
108 | l2cn(d0,d1,out,n); | ||
109 | out+=n; | ||
110 | /* 30-08-94 - eay - changed because l>>32 and | ||
111 | * l<<32 are bad under gcc :-( */ | ||
112 | if (num == 32) | ||
113 | { v0=v1; v1=d0; } | ||
114 | else if (num == 64) | ||
115 | { v0=d0; v1=d1; } | ||
116 | else if (num > 32) /* && num != 64 */ | ||
117 | { | ||
118 | v0=((v1>>(num-32))|(d0<<(64-num)))&0xffffffffL; | ||
119 | v1=((d0>>(num-32))|(d1<<(64-num)))&0xffffffffL; | ||
120 | } | ||
121 | else /* num < 32 */ | ||
122 | { | ||
123 | v0=((v0>>num)|(v1<<(32-num)))&0xffffffffL; | ||
124 | v1=((v1>>num)|(d0<<(32-num)))&0xffffffffL; | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | else | ||
129 | { | ||
130 | while (l >= n) | ||
131 | { | ||
132 | l-=n; | ||
133 | ti[0]=v0; | ||
134 | ti[1]=v1; | ||
135 | des_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); | ||
136 | c2ln(in,d0,d1,n); | ||
137 | in+=n; | ||
138 | /* 30-08-94 - eay - changed because l>>32 and | ||
139 | * l<<32 are bad under gcc :-( */ | ||
140 | if (num == 32) | ||
141 | { v0=v1; v1=d0; } | ||
142 | else if (num == 64) | ||
143 | { v0=d0; v1=d1; } | ||
144 | else if (num > 32) /* && num != 64 */ | ||
145 | { | ||
146 | v0=((v1>>(num-32))|(d0<<(64-num)))&0xffffffffL; | ||
147 | v1=((d0>>(num-32))|(d1<<(64-num)))&0xffffffffL; | ||
148 | } | ||
149 | else /* num < 32 */ | ||
150 | { | ||
151 | v0=((v0>>num)|(v1<<(32-num)))&0xffffffffL; | ||
152 | v1=((v1>>num)|(d0<<(32-num)))&0xffffffffL; | ||
153 | } | ||
154 | d0=(d0^ti[0])&mask0; | ||
155 | d1=(d1^ti[1])&mask1; | ||
156 | l2cn(d0,d1,out,n); | ||
157 | out+=n; | ||
158 | } | ||
159 | } | ||
160 | iv = &(*ivec)[0]; | ||
161 | l2c(v0,iv); | ||
162 | l2c(v1,iv); | ||
163 | v0=v1=d0=d1=ti[0]=ti[1]=0; | ||
164 | } | ||
165 | |||
diff --git a/src/lib/libcrypto/des/des.h b/src/lib/libcrypto/des/des.h deleted file mode 100644 index 6b8a7ee11b..0000000000 --- a/src/lib/libcrypto/des/des.h +++ /dev/null | |||
@@ -1,266 +0,0 @@ | |||
1 | /* crypto/des/des.h */ | ||
2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #ifndef HEADER_DES_H | ||
60 | #define HEADER_DES_H | ||
61 | |||
62 | #ifdef NO_DES | ||
63 | #error DES is disabled. | ||
64 | #endif | ||
65 | |||
66 | #ifdef _KERBEROS_DES_H | ||
67 | #error <openssl/des.h> replaces <kerberos/des.h>. | ||
68 | #endif | ||
69 | |||
70 | #include <openssl/opensslconf.h> /* DES_LONG */ | ||
71 | #include <openssl/e_os2.h> /* OPENSSL_EXTERN */ | ||
72 | |||
73 | #ifdef __cplusplus | ||
74 | extern "C" { | ||
75 | #endif | ||
76 | |||
77 | typedef unsigned char des_cblock[8]; | ||
78 | typedef /* const */ unsigned char const_des_cblock[8]; | ||
79 | /* With "const", gcc 2.8.1 on Solaris thinks that des_cblock * | ||
80 | * and const_des_cblock * are incompatible pointer types. */ | ||
81 | |||
82 | typedef struct des_ks_struct | ||
83 | { | ||
84 | union { | ||
85 | des_cblock cblock; | ||
86 | /* make sure things are correct size on machines with | ||
87 | * 8 byte longs */ | ||
88 | DES_LONG deslong[2]; | ||
89 | } ks; | ||
90 | int weak_key; | ||
91 | } des_key_schedule[16]; | ||
92 | |||
93 | #define DES_KEY_SZ (sizeof(des_cblock)) | ||
94 | #define DES_SCHEDULE_SZ (sizeof(des_key_schedule)) | ||
95 | |||
96 | #define DES_ENCRYPT 1 | ||
97 | #define DES_DECRYPT 0 | ||
98 | |||
99 | #define DES_CBC_MODE 0 | ||
100 | #define DES_PCBC_MODE 1 | ||
101 | |||
102 | #define des_ecb2_encrypt(i,o,k1,k2,e) \ | ||
103 | des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) | ||
104 | |||
105 | #define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ | ||
106 | des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) | ||
107 | |||
108 | #define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ | ||
109 | des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) | ||
110 | |||
111 | #define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ | ||
112 | des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) | ||
113 | |||
114 | OPENSSL_EXTERN int des_check_key; /* defaults to false */ | ||
115 | OPENSSL_EXTERN int des_rw_mode; /* defaults to DES_PCBC_MODE */ | ||
116 | OPENSSL_EXTERN int des_set_weak_key_flag; /* set the weak key flag */ | ||
117 | |||
118 | const char *des_options(void); | ||
119 | void des_ecb3_encrypt(const_des_cblock *input, des_cblock *output, | ||
120 | des_key_schedule ks1,des_key_schedule ks2, | ||
121 | des_key_schedule ks3, int enc); | ||
122 | DES_LONG des_cbc_cksum(const unsigned char *input,des_cblock *output, | ||
123 | long length,des_key_schedule schedule, | ||
124 | const_des_cblock *ivec); | ||
125 | /* des_cbc_encrypt does not update the IV! Use des_ncbc_encrypt instead. */ | ||
126 | void des_cbc_encrypt(const unsigned char *input,unsigned char *output, | ||
127 | long length,des_key_schedule schedule,des_cblock *ivec, | ||
128 | int enc); | ||
129 | void des_ncbc_encrypt(const unsigned char *input,unsigned char *output, | ||
130 | long length,des_key_schedule schedule,des_cblock *ivec, | ||
131 | int enc); | ||
132 | void des_xcbc_encrypt(const unsigned char *input,unsigned char *output, | ||
133 | long length,des_key_schedule schedule,des_cblock *ivec, | ||
134 | const_des_cblock *inw,const_des_cblock *outw,int enc); | ||
135 | void des_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits, | ||
136 | long length,des_key_schedule schedule,des_cblock *ivec, | ||
137 | int enc); | ||
138 | void des_ecb_encrypt(const_des_cblock *input,des_cblock *output, | ||
139 | des_key_schedule ks,int enc); | ||
140 | |||
141 | /* This is the DES encryption function that gets called by just about | ||
142 | every other DES routine in the library. You should not use this | ||
143 | function except to implement 'modes' of DES. I say this because the | ||
144 | functions that call this routine do the conversion from 'char *' to | ||
145 | long, and this needs to be done to make sure 'non-aligned' memory | ||
146 | access do not occur. The characters are loaded 'little endian'. | ||
147 | Data is a pointer to 2 unsigned long's and ks is the | ||
148 | des_key_schedule to use. enc, is non zero specifies encryption, | ||
149 | zero if decryption. */ | ||
150 | void des_encrypt1(DES_LONG *data,des_key_schedule ks, int enc); | ||
151 | |||
152 | /* This functions is the same as des_encrypt1() except that the DES | ||
153 | initial permutation (IP) and final permutation (FP) have been left | ||
154 | out. As for des_encrypt1(), you should not use this function. | ||
155 | It is used by the routines in the library that implement triple DES. | ||
156 | IP() des_encrypt2() des_encrypt2() des_encrypt2() FP() is the same | ||
157 | as des_encrypt1() des_encrypt1() des_encrypt1() except faster :-). */ | ||
158 | void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc); | ||
159 | |||
160 | void des_encrypt3(DES_LONG *data, des_key_schedule ks1, | ||
161 | des_key_schedule ks2, des_key_schedule ks3); | ||
162 | void des_decrypt3(DES_LONG *data, des_key_schedule ks1, | ||
163 | des_key_schedule ks2, des_key_schedule ks3); | ||
164 | void des_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output, | ||
165 | long length, | ||
166 | des_key_schedule ks1,des_key_schedule ks2, | ||
167 | des_key_schedule ks3,des_cblock *ivec,int enc); | ||
168 | void des_ede3_cbcm_encrypt(const unsigned char *in,unsigned char *out, | ||
169 | long length, | ||
170 | des_key_schedule ks1,des_key_schedule ks2, | ||
171 | des_key_schedule ks3, | ||
172 | des_cblock *ivec1,des_cblock *ivec2, | ||
173 | int enc); | ||
174 | void des_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out, | ||
175 | long length,des_key_schedule ks1, | ||
176 | des_key_schedule ks2,des_key_schedule ks3, | ||
177 | des_cblock *ivec,int *num,int enc); | ||
178 | void des_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out, | ||
179 | long length,des_key_schedule ks1, | ||
180 | des_key_schedule ks2,des_key_schedule ks3, | ||
181 | des_cblock *ivec,int *num); | ||
182 | |||
183 | void des_xwhite_in2out(const_des_cblock *des_key,const_des_cblock *in_white, | ||
184 | des_cblock *out_white); | ||
185 | |||
186 | int des_enc_read(int fd,void *buf,int len,des_key_schedule sched, | ||
187 | des_cblock *iv); | ||
188 | int des_enc_write(int fd,const void *buf,int len,des_key_schedule sched, | ||
189 | des_cblock *iv); | ||
190 | char *des_fcrypt(const char *buf,const char *salt, char *ret); | ||
191 | char *des_crypt(const char *buf,const char *salt); | ||
192 | #if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) | ||
193 | char *crypt(const char *buf,const char *salt); | ||
194 | #endif | ||
195 | void des_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits, | ||
196 | long length,des_key_schedule schedule,des_cblock *ivec); | ||
197 | void des_pcbc_encrypt(const unsigned char *input,unsigned char *output, | ||
198 | long length,des_key_schedule schedule,des_cblock *ivec, | ||
199 | int enc); | ||
200 | DES_LONG des_quad_cksum(const unsigned char *input,des_cblock output[], | ||
201 | long length,int out_count,des_cblock *seed); | ||
202 | void des_random_seed(des_cblock *key); | ||
203 | int des_random_key(des_cblock *ret); | ||
204 | int des_read_password(des_cblock *key,const char *prompt,int verify); | ||
205 | int des_read_2passwords(des_cblock *key1,des_cblock *key2, | ||
206 | const char *prompt,int verify); | ||
207 | int des_read_pw_string(char *buf,int length,const char *prompt,int verify); | ||
208 | void des_set_odd_parity(des_cblock *key); | ||
209 | int des_check_key_parity(const_des_cblock *key); | ||
210 | int des_is_weak_key(const_des_cblock *key); | ||
211 | /* des_set_key (= set_key = des_key_sched = key_sched) calls | ||
212 | * des_set_key_checked if global variable des_check_key is set, | ||
213 | * des_set_key_unchecked otherwise. */ | ||
214 | int des_set_key(const_des_cblock *key,des_key_schedule schedule); | ||
215 | int des_key_sched(const_des_cblock *key,des_key_schedule schedule); | ||
216 | int des_set_key_checked(const_des_cblock *key,des_key_schedule schedule); | ||
217 | void des_set_key_unchecked(const_des_cblock *key,des_key_schedule schedule); | ||
218 | void des_string_to_key(const char *str,des_cblock *key); | ||
219 | void des_string_to_2keys(const char *str,des_cblock *key1,des_cblock *key2); | ||
220 | void des_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length, | ||
221 | des_key_schedule schedule,des_cblock *ivec,int *num, | ||
222 | int enc); | ||
223 | void des_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length, | ||
224 | des_key_schedule schedule,des_cblock *ivec,int *num); | ||
225 | int des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); | ||
226 | |||
227 | /* The following definitions provide compatibility with the MIT Kerberos | ||
228 | * library. The des_key_schedule structure is not binary compatible. */ | ||
229 | |||
230 | #define _KERBEROS_DES_H | ||
231 | |||
232 | #define KRBDES_ENCRYPT DES_ENCRYPT | ||
233 | #define KRBDES_DECRYPT DES_DECRYPT | ||
234 | |||
235 | #ifdef KERBEROS | ||
236 | # define ENCRYPT DES_ENCRYPT | ||
237 | # define DECRYPT DES_DECRYPT | ||
238 | #endif | ||
239 | |||
240 | #ifndef NCOMPAT | ||
241 | # define C_Block des_cblock | ||
242 | # define Key_schedule des_key_schedule | ||
243 | # define KEY_SZ DES_KEY_SZ | ||
244 | # define string_to_key des_string_to_key | ||
245 | # define read_pw_string des_read_pw_string | ||
246 | # define random_key des_random_key | ||
247 | # define pcbc_encrypt des_pcbc_encrypt | ||
248 | # define set_key des_set_key | ||
249 | # define key_sched des_key_sched | ||
250 | # define ecb_encrypt des_ecb_encrypt | ||
251 | # define cbc_encrypt des_cbc_encrypt | ||
252 | # define ncbc_encrypt des_ncbc_encrypt | ||
253 | # define xcbc_encrypt des_xcbc_encrypt | ||
254 | # define cbc_cksum des_cbc_cksum | ||
255 | # define quad_cksum des_quad_cksum | ||
256 | # define check_parity des_check_key_parity | ||
257 | #endif | ||
258 | |||
259 | typedef des_key_schedule bit_64; | ||
260 | #define des_fixup_key_parity des_set_odd_parity | ||
261 | |||
262 | #ifdef __cplusplus | ||
263 | } | ||
264 | #endif | ||
265 | |||
266 | #endif | ||
diff --git a/src/lib/libcrypto/des/des_enc.c b/src/lib/libcrypto/des/des_enc.c deleted file mode 100644 index 0bd9fa39bc..0000000000 --- a/src/lib/libcrypto/des/des_enc.c +++ /dev/null | |||
@@ -1,406 +0,0 @@ | |||
1 | /* crypto/des/des_enc.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include "des_locl.h" | ||
60 | |||
61 | void des_encrypt1(DES_LONG *data, des_key_schedule ks, int enc) | ||
62 | { | ||
63 | register DES_LONG l,r,t,u; | ||
64 | #ifdef DES_PTR | ||
65 | register const unsigned char *des_SP=(const unsigned char *)des_SPtrans; | ||
66 | #endif | ||
67 | #ifndef DES_UNROLL | ||
68 | register int i; | ||
69 | #endif | ||
70 | register DES_LONG *s; | ||
71 | |||
72 | r=data[0]; | ||
73 | l=data[1]; | ||
74 | |||
75 | IP(r,l); | ||
76 | /* Things have been modified so that the initial rotate is | ||
77 | * done outside the loop. This required the | ||
78 | * des_SPtrans values in sp.h to be rotated 1 bit to the right. | ||
79 | * One perl script later and things have a 5% speed up on a sparc2. | ||
80 | * Thanks to Richard Outerbridge <71755.204@CompuServe.COM> | ||
81 | * for pointing this out. */ | ||
82 | /* clear the top bits on machines with 8byte longs */ | ||
83 | /* shift left by 2 */ | ||
84 | r=ROTATE(r,29)&0xffffffffL; | ||
85 | l=ROTATE(l,29)&0xffffffffL; | ||
86 | |||
87 | s=ks->ks.deslong; | ||
88 | /* I don't know if it is worth the effort of loop unrolling the | ||
89 | * inner loop */ | ||
90 | if (enc) | ||
91 | { | ||
92 | #ifdef DES_UNROLL | ||
93 | D_ENCRYPT(l,r, 0); /* 1 */ | ||
94 | D_ENCRYPT(r,l, 2); /* 2 */ | ||
95 | D_ENCRYPT(l,r, 4); /* 3 */ | ||
96 | D_ENCRYPT(r,l, 6); /* 4 */ | ||
97 | D_ENCRYPT(l,r, 8); /* 5 */ | ||
98 | D_ENCRYPT(r,l,10); /* 6 */ | ||
99 | D_ENCRYPT(l,r,12); /* 7 */ | ||
100 | D_ENCRYPT(r,l,14); /* 8 */ | ||
101 | D_ENCRYPT(l,r,16); /* 9 */ | ||
102 | D_ENCRYPT(r,l,18); /* 10 */ | ||
103 | D_ENCRYPT(l,r,20); /* 11 */ | ||
104 | D_ENCRYPT(r,l,22); /* 12 */ | ||
105 | D_ENCRYPT(l,r,24); /* 13 */ | ||
106 | D_ENCRYPT(r,l,26); /* 14 */ | ||
107 | D_ENCRYPT(l,r,28); /* 15 */ | ||
108 | D_ENCRYPT(r,l,30); /* 16 */ | ||
109 | #else | ||
110 | for (i=0; i<32; i+=8) | ||
111 | { | ||
112 | D_ENCRYPT(l,r,i+0); /* 1 */ | ||
113 | D_ENCRYPT(r,l,i+2); /* 2 */ | ||
114 | D_ENCRYPT(l,r,i+4); /* 3 */ | ||
115 | D_ENCRYPT(r,l,i+6); /* 4 */ | ||
116 | } | ||
117 | #endif | ||
118 | } | ||
119 | else | ||
120 | { | ||
121 | #ifdef DES_UNROLL | ||
122 | D_ENCRYPT(l,r,30); /* 16 */ | ||
123 | D_ENCRYPT(r,l,28); /* 15 */ | ||
124 | D_ENCRYPT(l,r,26); /* 14 */ | ||
125 | D_ENCRYPT(r,l,24); /* 13 */ | ||
126 | D_ENCRYPT(l,r,22); /* 12 */ | ||
127 | D_ENCRYPT(r,l,20); /* 11 */ | ||
128 | D_ENCRYPT(l,r,18); /* 10 */ | ||
129 | D_ENCRYPT(r,l,16); /* 9 */ | ||
130 | D_ENCRYPT(l,r,14); /* 8 */ | ||
131 | D_ENCRYPT(r,l,12); /* 7 */ | ||
132 | D_ENCRYPT(l,r,10); /* 6 */ | ||
133 | D_ENCRYPT(r,l, 8); /* 5 */ | ||
134 | D_ENCRYPT(l,r, 6); /* 4 */ | ||
135 | D_ENCRYPT(r,l, 4); /* 3 */ | ||
136 | D_ENCRYPT(l,r, 2); /* 2 */ | ||
137 | D_ENCRYPT(r,l, 0); /* 1 */ | ||
138 | #else | ||
139 | for (i=30; i>0; i-=8) | ||
140 | { | ||
141 | D_ENCRYPT(l,r,i-0); /* 16 */ | ||
142 | D_ENCRYPT(r,l,i-2); /* 15 */ | ||
143 | D_ENCRYPT(l,r,i-4); /* 14 */ | ||
144 | D_ENCRYPT(r,l,i-6); /* 13 */ | ||
145 | } | ||
146 | #endif | ||
147 | } | ||
148 | |||
149 | /* rotate and clear the top bits on machines with 8byte longs */ | ||
150 | l=ROTATE(l,3)&0xffffffffL; | ||
151 | r=ROTATE(r,3)&0xffffffffL; | ||
152 | |||
153 | FP(r,l); | ||
154 | data[0]=l; | ||
155 | data[1]=r; | ||
156 | l=r=t=u=0; | ||
157 | } | ||
158 | |||
159 | void des_encrypt2(DES_LONG *data, des_key_schedule ks, int enc) | ||
160 | { | ||
161 | register DES_LONG l,r,t,u; | ||
162 | #ifdef DES_PTR | ||
163 | register const unsigned char *des_SP=(const unsigned char *)des_SPtrans; | ||
164 | #endif | ||
165 | #ifndef DES_UNROLL | ||
166 | register int i; | ||
167 | #endif | ||
168 | register DES_LONG *s; | ||
169 | |||
170 | r=data[0]; | ||
171 | l=data[1]; | ||
172 | |||
173 | /* Things have been modified so that the initial rotate is | ||
174 | * done outside the loop. This required the | ||
175 | * des_SPtrans values in sp.h to be rotated 1 bit to the right. | ||
176 | * One perl script later and things have a 5% speed up on a sparc2. | ||
177 | * Thanks to Richard Outerbridge <71755.204@CompuServe.COM> | ||
178 | * for pointing this out. */ | ||
179 | /* clear the top bits on machines with 8byte longs */ | ||
180 | r=ROTATE(r,29)&0xffffffffL; | ||
181 | l=ROTATE(l,29)&0xffffffffL; | ||
182 | |||
183 | s=ks->ks.deslong; | ||
184 | /* I don't know if it is worth the effort of loop unrolling the | ||
185 | * inner loop */ | ||
186 | if (enc) | ||
187 | { | ||
188 | #ifdef DES_UNROLL | ||
189 | D_ENCRYPT(l,r, 0); /* 1 */ | ||
190 | D_ENCRYPT(r,l, 2); /* 2 */ | ||
191 | D_ENCRYPT(l,r, 4); /* 3 */ | ||
192 | D_ENCRYPT(r,l, 6); /* 4 */ | ||
193 | D_ENCRYPT(l,r, 8); /* 5 */ | ||
194 | D_ENCRYPT(r,l,10); /* 6 */ | ||
195 | D_ENCRYPT(l,r,12); /* 7 */ | ||
196 | D_ENCRYPT(r,l,14); /* 8 */ | ||
197 | D_ENCRYPT(l,r,16); /* 9 */ | ||
198 | D_ENCRYPT(r,l,18); /* 10 */ | ||
199 | D_ENCRYPT(l,r,20); /* 11 */ | ||
200 | D_ENCRYPT(r,l,22); /* 12 */ | ||
201 | D_ENCRYPT(l,r,24); /* 13 */ | ||
202 | D_ENCRYPT(r,l,26); /* 14 */ | ||
203 | D_ENCRYPT(l,r,28); /* 15 */ | ||
204 | D_ENCRYPT(r,l,30); /* 16 */ | ||
205 | #else | ||
206 | for (i=0; i<32; i+=8) | ||
207 | { | ||
208 | D_ENCRYPT(l,r,i+0); /* 1 */ | ||
209 | D_ENCRYPT(r,l,i+2); /* 2 */ | ||
210 | D_ENCRYPT(l,r,i+4); /* 3 */ | ||
211 | D_ENCRYPT(r,l,i+6); /* 4 */ | ||
212 | } | ||
213 | #endif | ||
214 | } | ||
215 | else | ||
216 | { | ||
217 | #ifdef DES_UNROLL | ||
218 | D_ENCRYPT(l,r,30); /* 16 */ | ||
219 | D_ENCRYPT(r,l,28); /* 15 */ | ||
220 | D_ENCRYPT(l,r,26); /* 14 */ | ||
221 | D_ENCRYPT(r,l,24); /* 13 */ | ||
222 | D_ENCRYPT(l,r,22); /* 12 */ | ||
223 | D_ENCRYPT(r,l,20); /* 11 */ | ||
224 | D_ENCRYPT(l,r,18); /* 10 */ | ||
225 | D_ENCRYPT(r,l,16); /* 9 */ | ||
226 | D_ENCRYPT(l,r,14); /* 8 */ | ||
227 | D_ENCRYPT(r,l,12); /* 7 */ | ||
228 | D_ENCRYPT(l,r,10); /* 6 */ | ||
229 | D_ENCRYPT(r,l, 8); /* 5 */ | ||
230 | D_ENCRYPT(l,r, 6); /* 4 */ | ||
231 | D_ENCRYPT(r,l, 4); /* 3 */ | ||
232 | D_ENCRYPT(l,r, 2); /* 2 */ | ||
233 | D_ENCRYPT(r,l, 0); /* 1 */ | ||
234 | #else | ||
235 | for (i=30; i>0; i-=8) | ||
236 | { | ||
237 | D_ENCRYPT(l,r,i-0); /* 16 */ | ||
238 | D_ENCRYPT(r,l,i-2); /* 15 */ | ||
239 | D_ENCRYPT(l,r,i-4); /* 14 */ | ||
240 | D_ENCRYPT(r,l,i-6); /* 13 */ | ||
241 | } | ||
242 | #endif | ||
243 | } | ||
244 | /* rotate and clear the top bits on machines with 8byte longs */ | ||
245 | data[0]=ROTATE(l,3)&0xffffffffL; | ||
246 | data[1]=ROTATE(r,3)&0xffffffffL; | ||
247 | l=r=t=u=0; | ||
248 | } | ||
249 | |||
250 | void des_encrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2, | ||
251 | des_key_schedule ks3) | ||
252 | { | ||
253 | register DES_LONG l,r; | ||
254 | |||
255 | l=data[0]; | ||
256 | r=data[1]; | ||
257 | IP(l,r); | ||
258 | data[0]=l; | ||
259 | data[1]=r; | ||
260 | des_encrypt2((DES_LONG *)data,ks1,DES_ENCRYPT); | ||
261 | des_encrypt2((DES_LONG *)data,ks2,DES_DECRYPT); | ||
262 | des_encrypt2((DES_LONG *)data,ks3,DES_ENCRYPT); | ||
263 | l=data[0]; | ||
264 | r=data[1]; | ||
265 | FP(r,l); | ||
266 | data[0]=l; | ||
267 | data[1]=r; | ||
268 | } | ||
269 | |||
270 | void des_decrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2, | ||
271 | des_key_schedule ks3) | ||
272 | { | ||
273 | register DES_LONG l,r; | ||
274 | |||
275 | l=data[0]; | ||
276 | r=data[1]; | ||
277 | IP(l,r); | ||
278 | data[0]=l; | ||
279 | data[1]=r; | ||
280 | des_encrypt2((DES_LONG *)data,ks3,DES_DECRYPT); | ||
281 | des_encrypt2((DES_LONG *)data,ks2,DES_ENCRYPT); | ||
282 | des_encrypt2((DES_LONG *)data,ks1,DES_DECRYPT); | ||
283 | l=data[0]; | ||
284 | r=data[1]; | ||
285 | FP(r,l); | ||
286 | data[0]=l; | ||
287 | data[1]=r; | ||
288 | } | ||
289 | |||
290 | #ifndef DES_DEFAULT_OPTIONS | ||
291 | |||
292 | #undef CBC_ENC_C__DONT_UPDATE_IV | ||
293 | #include "ncbc_enc.c" /* des_ncbc_encrypt */ | ||
294 | |||
295 | void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, | ||
296 | long length, des_key_schedule ks1, des_key_schedule ks2, | ||
297 | des_key_schedule ks3, des_cblock *ivec, int enc) | ||
298 | { | ||
299 | register DES_LONG tin0,tin1; | ||
300 | register DES_LONG tout0,tout1,xor0,xor1; | ||
301 | register const unsigned char *in; | ||
302 | unsigned char *out; | ||
303 | register long l=length; | ||
304 | DES_LONG tin[2]; | ||
305 | unsigned char *iv; | ||
306 | |||
307 | in=input; | ||
308 | out=output; | ||
309 | iv = &(*ivec)[0]; | ||
310 | |||
311 | if (enc) | ||
312 | { | ||
313 | c2l(iv,tout0); | ||
314 | c2l(iv,tout1); | ||
315 | for (l-=8; l>=0; l-=8) | ||
316 | { | ||
317 | c2l(in,tin0); | ||
318 | c2l(in,tin1); | ||
319 | tin0^=tout0; | ||
320 | tin1^=tout1; | ||
321 | |||
322 | tin[0]=tin0; | ||
323 | tin[1]=tin1; | ||
324 | des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); | ||
325 | tout0=tin[0]; | ||
326 | tout1=tin[1]; | ||
327 | |||
328 | l2c(tout0,out); | ||
329 | l2c(tout1,out); | ||
330 | } | ||
331 | if (l != -8) | ||
332 | { | ||
333 | c2ln(in,tin0,tin1,l+8); | ||
334 | tin0^=tout0; | ||
335 | tin1^=tout1; | ||
336 | |||
337 | tin[0]=tin0; | ||
338 | tin[1]=tin1; | ||
339 | des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); | ||
340 | tout0=tin[0]; | ||
341 | tout1=tin[1]; | ||
342 | |||
343 | l2c(tout0,out); | ||
344 | l2c(tout1,out); | ||
345 | } | ||
346 | iv = &(*ivec)[0]; | ||
347 | l2c(tout0,iv); | ||
348 | l2c(tout1,iv); | ||
349 | } | ||
350 | else | ||
351 | { | ||
352 | register DES_LONG t0,t1; | ||
353 | |||
354 | c2l(iv,xor0); | ||
355 | c2l(iv,xor1); | ||
356 | for (l-=8; l>=0; l-=8) | ||
357 | { | ||
358 | c2l(in,tin0); | ||
359 | c2l(in,tin1); | ||
360 | |||
361 | t0=tin0; | ||
362 | t1=tin1; | ||
363 | |||
364 | tin[0]=tin0; | ||
365 | tin[1]=tin1; | ||
366 | des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); | ||
367 | tout0=tin[0]; | ||
368 | tout1=tin[1]; | ||
369 | |||
370 | tout0^=xor0; | ||
371 | tout1^=xor1; | ||
372 | l2c(tout0,out); | ||
373 | l2c(tout1,out); | ||
374 | xor0=t0; | ||
375 | xor1=t1; | ||
376 | } | ||
377 | if (l != -8) | ||
378 | { | ||
379 | c2l(in,tin0); | ||
380 | c2l(in,tin1); | ||
381 | |||
382 | t0=tin0; | ||
383 | t1=tin1; | ||
384 | |||
385 | tin[0]=tin0; | ||
386 | tin[1]=tin1; | ||
387 | des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); | ||
388 | tout0=tin[0]; | ||
389 | tout1=tin[1]; | ||
390 | |||
391 | tout0^=xor0; | ||
392 | tout1^=xor1; | ||
393 | l2cn(tout0,tout1,out,l+8); | ||
394 | xor0=t0; | ||
395 | xor1=t1; | ||
396 | } | ||
397 | |||
398 | iv = &(*ivec)[0]; | ||
399 | l2c(xor0,iv); | ||
400 | l2c(xor1,iv); | ||
401 | } | ||
402 | tin0=tin1=tout0=tout1=xor0=xor1=0; | ||
403 | tin[0]=tin[1]=0; | ||
404 | } | ||
405 | |||
406 | #endif /* DES_DEFAULT_OPTIONS */ | ||
diff --git a/src/lib/libcrypto/des/des_locl.h b/src/lib/libcrypto/des/des_locl.h deleted file mode 100644 index 1ace8f5930..0000000000 --- a/src/lib/libcrypto/des/des_locl.h +++ /dev/null | |||
@@ -1,412 +0,0 @@ | |||
1 | /* crypto/des/des_locl.h */ | ||
2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #ifndef HEADER_DES_LOCL_H | ||
60 | #define HEADER_DES_LOCL_H | ||
61 | |||
62 | #if defined(WIN32) || defined(WIN16) | ||
63 | #ifndef MSDOS | ||
64 | #define MSDOS | ||
65 | #endif | ||
66 | #endif | ||
67 | |||
68 | #include <stdio.h> | ||
69 | #include <stdlib.h> | ||
70 | |||
71 | #include <openssl/opensslconf.h> | ||
72 | |||
73 | #ifndef MSDOS | ||
74 | #if !defined(VMS) || defined(__DECC) | ||
75 | #ifdef OPENSSL_UNISTD | ||
76 | # include OPENSSL_UNISTD | ||
77 | #else | ||
78 | # include <unistd.h> | ||
79 | #endif | ||
80 | #include <math.h> | ||
81 | #endif | ||
82 | #endif | ||
83 | #include <openssl/des.h> | ||
84 | |||
85 | #ifdef MSDOS /* Visual C++ 2.1 (Windows NT/95) */ | ||
86 | #include <stdlib.h> | ||
87 | #include <errno.h> | ||
88 | #include <time.h> | ||
89 | #include <io.h> | ||
90 | #endif | ||
91 | |||
92 | #if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS) | ||
93 | #include <string.h> | ||
94 | #endif | ||
95 | |||
96 | #define ITERATIONS 16 | ||
97 | #define HALF_ITERATIONS 8 | ||
98 | |||
99 | /* used in des_read and des_write */ | ||
100 | #define MAXWRITE (1024*16) | ||
101 | #define BSIZE (MAXWRITE+4) | ||
102 | |||
103 | #define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \ | ||
104 | l|=((DES_LONG)(*((c)++)))<< 8L, \ | ||
105 | l|=((DES_LONG)(*((c)++)))<<16L, \ | ||
106 | l|=((DES_LONG)(*((c)++)))<<24L) | ||
107 | |||
108 | /* NOTE - c is not incremented as per c2l */ | ||
109 | #define c2ln(c,l1,l2,n) { \ | ||
110 | c+=n; \ | ||
111 | l1=l2=0; \ | ||
112 | switch (n) { \ | ||
113 | case 8: l2 =((DES_LONG)(*(--(c))))<<24L; \ | ||
114 | case 7: l2|=((DES_LONG)(*(--(c))))<<16L; \ | ||
115 | case 6: l2|=((DES_LONG)(*(--(c))))<< 8L; \ | ||
116 | case 5: l2|=((DES_LONG)(*(--(c)))); \ | ||
117 | case 4: l1 =((DES_LONG)(*(--(c))))<<24L; \ | ||
118 | case 3: l1|=((DES_LONG)(*(--(c))))<<16L; \ | ||
119 | case 2: l1|=((DES_LONG)(*(--(c))))<< 8L; \ | ||
120 | case 1: l1|=((DES_LONG)(*(--(c)))); \ | ||
121 | } \ | ||
122 | } | ||
123 | |||
124 | #define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ | ||
125 | *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ | ||
126 | *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ | ||
127 | *((c)++)=(unsigned char)(((l)>>24L)&0xff)) | ||
128 | |||
129 | /* replacements for htonl and ntohl since I have no idea what to do | ||
130 | * when faced with machines with 8 byte longs. */ | ||
131 | #define HDRSIZE 4 | ||
132 | |||
133 | #define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \ | ||
134 | l|=((DES_LONG)(*((c)++)))<<16L, \ | ||
135 | l|=((DES_LONG)(*((c)++)))<< 8L, \ | ||
136 | l|=((DES_LONG)(*((c)++)))) | ||
137 | |||
138 | #define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ | ||
139 | *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ | ||
140 | *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ | ||
141 | *((c)++)=(unsigned char)(((l) )&0xff)) | ||
142 | |||
143 | /* NOTE - c is not incremented as per l2c */ | ||
144 | #define l2cn(l1,l2,c,n) { \ | ||
145 | c+=n; \ | ||
146 | switch (n) { \ | ||
147 | case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ | ||
148 | case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ | ||
149 | case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ | ||
150 | case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ | ||
151 | case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ | ||
152 | case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ | ||
153 | case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ | ||
154 | case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ | ||
155 | } \ | ||
156 | } | ||
157 | |||
158 | #if defined(WIN32) && defined(_MSC_VER) | ||
159 | #define ROTATE(a,n) (_lrotr(a,n)) | ||
160 | #else | ||
161 | #define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n)))) | ||
162 | #endif | ||
163 | |||
164 | /* Don't worry about the LOAD_DATA() stuff, that is used by | ||
165 | * fcrypt() to add it's little bit to the front */ | ||
166 | |||
167 | #ifdef DES_FCRYPT | ||
168 | |||
169 | #define LOAD_DATA_tmp(R,S,u,t,E0,E1) \ | ||
170 | { DES_LONG tmp; LOAD_DATA(R,S,u,t,E0,E1,tmp); } | ||
171 | |||
172 | #define LOAD_DATA(R,S,u,t,E0,E1,tmp) \ | ||
173 | t=R^(R>>16L); \ | ||
174 | u=t&E0; t&=E1; \ | ||
175 | tmp=(u<<16); u^=R^s[S ]; u^=tmp; \ | ||
176 | tmp=(t<<16); t^=R^s[S+1]; t^=tmp | ||
177 | #else | ||
178 | #define LOAD_DATA_tmp(a,b,c,d,e,f) LOAD_DATA(a,b,c,d,e,f,g) | ||
179 | #define LOAD_DATA(R,S,u,t,E0,E1,tmp) \ | ||
180 | u=R^s[S ]; \ | ||
181 | t=R^s[S+1] | ||
182 | #endif | ||
183 | |||
184 | /* The changes to this macro may help or hinder, depending on the | ||
185 | * compiler and the architecture. gcc2 always seems to do well :-). | ||
186 | * Inspired by Dana How <how@isl.stanford.edu> | ||
187 | * DO NOT use the alternative version on machines with 8 byte longs. | ||
188 | * It does not seem to work on the Alpha, even when DES_LONG is 4 | ||
189 | * bytes, probably an issue of accessing non-word aligned objects :-( */ | ||
190 | #ifdef DES_PTR | ||
191 | |||
192 | /* It recently occurred to me that 0^0^0^0^0^0^0 == 0, so there | ||
193 | * is no reason to not xor all the sub items together. This potentially | ||
194 | * saves a register since things can be xored directly into L */ | ||
195 | |||
196 | #if defined(DES_RISC1) || defined(DES_RISC2) | ||
197 | #ifdef DES_RISC1 | ||
198 | #define D_ENCRYPT(LL,R,S) { \ | ||
199 | unsigned int u1,u2,u3; \ | ||
200 | LOAD_DATA(R,S,u,t,E0,E1,u1); \ | ||
201 | u2=(int)u>>8L; \ | ||
202 | u1=(int)u&0xfc; \ | ||
203 | u2&=0xfc; \ | ||
204 | t=ROTATE(t,4); \ | ||
205 | u>>=16L; \ | ||
206 | LL^= *(const DES_LONG *)(des_SP +u1); \ | ||
207 | LL^= *(const DES_LONG *)(des_SP+0x200+u2); \ | ||
208 | u3=(int)(u>>8L); \ | ||
209 | u1=(int)u&0xfc; \ | ||
210 | u3&=0xfc; \ | ||
211 | LL^= *(const DES_LONG *)(des_SP+0x400+u1); \ | ||
212 | LL^= *(const DES_LONG *)(des_SP+0x600+u3); \ | ||
213 | u2=(int)t>>8L; \ | ||
214 | u1=(int)t&0xfc; \ | ||
215 | u2&=0xfc; \ | ||
216 | t>>=16L; \ | ||
217 | LL^= *(const DES_LONG *)(des_SP+0x100+u1); \ | ||
218 | LL^= *(const DES_LONG *)(des_SP+0x300+u2); \ | ||
219 | u3=(int)t>>8L; \ | ||
220 | u1=(int)t&0xfc; \ | ||
221 | u3&=0xfc; \ | ||
222 | LL^= *(const DES_LONG *)(des_SP+0x500+u1); \ | ||
223 | LL^= *(const DES_LONG *)(des_SP+0x700+u3); } | ||
224 | #endif | ||
225 | #ifdef DES_RISC2 | ||
226 | #define D_ENCRYPT(LL,R,S) { \ | ||
227 | unsigned int u1,u2,s1,s2; \ | ||
228 | LOAD_DATA(R,S,u,t,E0,E1,u1); \ | ||
229 | u2=(int)u>>8L; \ | ||
230 | u1=(int)u&0xfc; \ | ||
231 | u2&=0xfc; \ | ||
232 | t=ROTATE(t,4); \ | ||
233 | LL^= *(const DES_LONG *)(des_SP +u1); \ | ||
234 | LL^= *(const DES_LONG *)(des_SP+0x200+u2); \ | ||
235 | s1=(int)(u>>16L); \ | ||
236 | s2=(int)(u>>24L); \ | ||
237 | s1&=0xfc; \ | ||
238 | s2&=0xfc; \ | ||
239 | LL^= *(const DES_LONG *)(des_SP+0x400+s1); \ | ||
240 | LL^= *(const DES_LONG *)(des_SP+0x600+s2); \ | ||
241 | u2=(int)t>>8L; \ | ||
242 | u1=(int)t&0xfc; \ | ||
243 | u2&=0xfc; \ | ||
244 | LL^= *(const DES_LONG *)(des_SP+0x100+u1); \ | ||
245 | LL^= *(const DES_LONG *)(des_SP+0x300+u2); \ | ||
246 | s1=(int)(t>>16L); \ | ||
247 | s2=(int)(t>>24L); \ | ||
248 | s1&=0xfc; \ | ||
249 | s2&=0xfc; \ | ||
250 | LL^= *(const DES_LONG *)(des_SP+0x500+s1); \ | ||
251 | LL^= *(const DES_LONG *)(des_SP+0x700+s2); } | ||
252 | #endif | ||
253 | #else | ||
254 | #define D_ENCRYPT(LL,R,S) { \ | ||
255 | LOAD_DATA_tmp(R,S,u,t,E0,E1); \ | ||
256 | t=ROTATE(t,4); \ | ||
257 | LL^= \ | ||
258 | *(const DES_LONG *)(des_SP +((u )&0xfc))^ \ | ||
259 | *(const DES_LONG *)(des_SP+0x200+((u>> 8L)&0xfc))^ \ | ||
260 | *(const DES_LONG *)(des_SP+0x400+((u>>16L)&0xfc))^ \ | ||
261 | *(const DES_LONG *)(des_SP+0x600+((u>>24L)&0xfc))^ \ | ||
262 | *(const DES_LONG *)(des_SP+0x100+((t )&0xfc))^ \ | ||
263 | *(const DES_LONG *)(des_SP+0x300+((t>> 8L)&0xfc))^ \ | ||
264 | *(const DES_LONG *)(des_SP+0x500+((t>>16L)&0xfc))^ \ | ||
265 | *(const DES_LONG *)(des_SP+0x700+((t>>24L)&0xfc)); } | ||
266 | #endif | ||
267 | |||
268 | #else /* original version */ | ||
269 | |||
270 | #if defined(DES_RISC1) || defined(DES_RISC2) | ||
271 | #ifdef DES_RISC1 | ||
272 | #define D_ENCRYPT(LL,R,S) {\ | ||
273 | unsigned int u1,u2,u3; \ | ||
274 | LOAD_DATA(R,S,u,t,E0,E1,u1); \ | ||
275 | u>>=2L; \ | ||
276 | t=ROTATE(t,6); \ | ||
277 | u2=(int)u>>8L; \ | ||
278 | u1=(int)u&0x3f; \ | ||
279 | u2&=0x3f; \ | ||
280 | u>>=16L; \ | ||
281 | LL^=des_SPtrans[0][u1]; \ | ||
282 | LL^=des_SPtrans[2][u2]; \ | ||
283 | u3=(int)u>>8L; \ | ||
284 | u1=(int)u&0x3f; \ | ||
285 | u3&=0x3f; \ | ||
286 | LL^=des_SPtrans[4][u1]; \ | ||
287 | LL^=des_SPtrans[6][u3]; \ | ||
288 | u2=(int)t>>8L; \ | ||
289 | u1=(int)t&0x3f; \ | ||
290 | u2&=0x3f; \ | ||
291 | t>>=16L; \ | ||
292 | LL^=des_SPtrans[1][u1]; \ | ||
293 | LL^=des_SPtrans[3][u2]; \ | ||
294 | u3=(int)t>>8L; \ | ||
295 | u1=(int)t&0x3f; \ | ||
296 | u3&=0x3f; \ | ||
297 | LL^=des_SPtrans[5][u1]; \ | ||
298 | LL^=des_SPtrans[7][u3]; } | ||
299 | #endif | ||
300 | #ifdef DES_RISC2 | ||
301 | #define D_ENCRYPT(LL,R,S) {\ | ||
302 | unsigned int u1,u2,s1,s2; \ | ||
303 | LOAD_DATA(R,S,u,t,E0,E1,u1); \ | ||
304 | u>>=2L; \ | ||
305 | t=ROTATE(t,6); \ | ||
306 | u2=(int)u>>8L; \ | ||
307 | u1=(int)u&0x3f; \ | ||
308 | u2&=0x3f; \ | ||
309 | LL^=des_SPtrans[0][u1]; \ | ||
310 | LL^=des_SPtrans[2][u2]; \ | ||
311 | s1=(int)u>>16L; \ | ||
312 | s2=(int)u>>24L; \ | ||
313 | s1&=0x3f; \ | ||
314 | s2&=0x3f; \ | ||
315 | LL^=des_SPtrans[4][s1]; \ | ||
316 | LL^=des_SPtrans[6][s2]; \ | ||
317 | u2=(int)t>>8L; \ | ||
318 | u1=(int)t&0x3f; \ | ||
319 | u2&=0x3f; \ | ||
320 | LL^=des_SPtrans[1][u1]; \ | ||
321 | LL^=des_SPtrans[3][u2]; \ | ||
322 | s1=(int)t>>16; \ | ||
323 | s2=(int)t>>24L; \ | ||
324 | s1&=0x3f; \ | ||
325 | s2&=0x3f; \ | ||
326 | LL^=des_SPtrans[5][s1]; \ | ||
327 | LL^=des_SPtrans[7][s2]; } | ||
328 | #endif | ||
329 | |||
330 | #else | ||
331 | |||
332 | #define D_ENCRYPT(LL,R,S) {\ | ||
333 | LOAD_DATA_tmp(R,S,u,t,E0,E1); \ | ||
334 | t=ROTATE(t,4); \ | ||
335 | LL^=\ | ||
336 | des_SPtrans[0][(u>> 2L)&0x3f]^ \ | ||
337 | des_SPtrans[2][(u>>10L)&0x3f]^ \ | ||
338 | des_SPtrans[4][(u>>18L)&0x3f]^ \ | ||
339 | des_SPtrans[6][(u>>26L)&0x3f]^ \ | ||
340 | des_SPtrans[1][(t>> 2L)&0x3f]^ \ | ||
341 | des_SPtrans[3][(t>>10L)&0x3f]^ \ | ||
342 | des_SPtrans[5][(t>>18L)&0x3f]^ \ | ||
343 | des_SPtrans[7][(t>>26L)&0x3f]; } | ||
344 | #endif | ||
345 | #endif | ||
346 | |||
347 | /* IP and FP | ||
348 | * The problem is more of a geometric problem that random bit fiddling. | ||
349 | 0 1 2 3 4 5 6 7 62 54 46 38 30 22 14 6 | ||
350 | 8 9 10 11 12 13 14 15 60 52 44 36 28 20 12 4 | ||
351 | 16 17 18 19 20 21 22 23 58 50 42 34 26 18 10 2 | ||
352 | 24 25 26 27 28 29 30 31 to 56 48 40 32 24 16 8 0 | ||
353 | |||
354 | 32 33 34 35 36 37 38 39 63 55 47 39 31 23 15 7 | ||
355 | 40 41 42 43 44 45 46 47 61 53 45 37 29 21 13 5 | ||
356 | 48 49 50 51 52 53 54 55 59 51 43 35 27 19 11 3 | ||
357 | 56 57 58 59 60 61 62 63 57 49 41 33 25 17 9 1 | ||
358 | |||
359 | The output has been subject to swaps of the form | ||
360 | 0 1 -> 3 1 but the odd and even bits have been put into | ||
361 | 2 3 2 0 | ||
362 | different words. The main trick is to remember that | ||
363 | t=((l>>size)^r)&(mask); | ||
364 | r^=t; | ||
365 | l^=(t<<size); | ||
366 | can be used to swap and move bits between words. | ||
367 | |||
368 | So l = 0 1 2 3 r = 16 17 18 19 | ||
369 | 4 5 6 7 20 21 22 23 | ||
370 | 8 9 10 11 24 25 26 27 | ||
371 | 12 13 14 15 28 29 30 31 | ||
372 | becomes (for size == 2 and mask == 0x3333) | ||
373 | t = 2^16 3^17 -- -- l = 0 1 16 17 r = 2 3 18 19 | ||
374 | 6^20 7^21 -- -- 4 5 20 21 6 7 22 23 | ||
375 | 10^24 11^25 -- -- 8 9 24 25 10 11 24 25 | ||
376 | 14^28 15^29 -- -- 12 13 28 29 14 15 28 29 | ||
377 | |||
378 | Thanks for hints from Richard Outerbridge - he told me IP&FP | ||
379 | could be done in 15 xor, 10 shifts and 5 ands. | ||
380 | When I finally started to think of the problem in 2D | ||
381 | I first got ~42 operations without xors. When I remembered | ||
382 | how to use xors :-) I got it to its final state. | ||
383 | */ | ||
384 | #define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\ | ||
385 | (b)^=(t),\ | ||
386 | (a)^=((t)<<(n))) | ||
387 | |||
388 | #define IP(l,r) \ | ||
389 | { \ | ||
390 | register DES_LONG tt; \ | ||
391 | PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \ | ||
392 | PERM_OP(l,r,tt,16,0x0000ffffL); \ | ||
393 | PERM_OP(r,l,tt, 2,0x33333333L); \ | ||
394 | PERM_OP(l,r,tt, 8,0x00ff00ffL); \ | ||
395 | PERM_OP(r,l,tt, 1,0x55555555L); \ | ||
396 | } | ||
397 | |||
398 | #define FP(l,r) \ | ||
399 | { \ | ||
400 | register DES_LONG tt; \ | ||
401 | PERM_OP(l,r,tt, 1,0x55555555L); \ | ||
402 | PERM_OP(r,l,tt, 8,0x00ff00ffL); \ | ||
403 | PERM_OP(l,r,tt, 2,0x33333333L); \ | ||
404 | PERM_OP(r,l,tt,16,0x0000ffffL); \ | ||
405 | PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \ | ||
406 | } | ||
407 | |||
408 | OPENSSL_EXTERN const DES_LONG des_SPtrans[8][64]; | ||
409 | |||
410 | void fcrypt_body(DES_LONG *out,des_key_schedule ks, | ||
411 | DES_LONG Eswap0, DES_LONG Eswap1); | ||
412 | #endif | ||
diff --git a/src/lib/libcrypto/des/ecb3_enc.c b/src/lib/libcrypto/des/ecb3_enc.c deleted file mode 100644 index fb28b97e1a..0000000000 --- a/src/lib/libcrypto/des/ecb3_enc.c +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
1 | /* crypto/des/ecb3_enc.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include "des_locl.h" | ||
60 | |||
61 | void des_ecb3_encrypt(const_des_cblock *input, des_cblock *output, | ||
62 | des_key_schedule ks1, des_key_schedule ks2, des_key_schedule ks3, | ||
63 | int enc) | ||
64 | { | ||
65 | register DES_LONG l0,l1; | ||
66 | DES_LONG ll[2]; | ||
67 | const unsigned char *in = &(*input)[0]; | ||
68 | unsigned char *out = &(*output)[0]; | ||
69 | |||
70 | c2l(in,l0); | ||
71 | c2l(in,l1); | ||
72 | ll[0]=l0; | ||
73 | ll[1]=l1; | ||
74 | if (enc) | ||
75 | des_encrypt3(ll,ks1,ks2,ks3); | ||
76 | else | ||
77 | des_decrypt3(ll,ks1,ks2,ks3); | ||
78 | l0=ll[0]; | ||
79 | l1=ll[1]; | ||
80 | l2c(l0,out); | ||
81 | l2c(l1,out); | ||
82 | } | ||
diff --git a/src/lib/libcrypto/des/ecb_enc.c b/src/lib/libcrypto/des/ecb_enc.c deleted file mode 100644 index d481327ef3..0000000000 --- a/src/lib/libcrypto/des/ecb_enc.c +++ /dev/null | |||
@@ -1,122 +0,0 @@ | |||
1 | /* crypto/des/ecb_enc.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include "des_locl.h" | ||
60 | #include "spr.h" | ||
61 | #include <openssl/opensslv.h> | ||
62 | |||
63 | OPENSSL_GLOBAL const char *libdes_version="libdes" OPENSSL_VERSION_PTEXT; | ||
64 | OPENSSL_GLOBAL const char *DES_version="DES" OPENSSL_VERSION_PTEXT; | ||
65 | |||
66 | const char *des_options(void) | ||
67 | { | ||
68 | static int init=1; | ||
69 | static char buf[32]; | ||
70 | |||
71 | if (init) | ||
72 | { | ||
73 | const char *ptr,*unroll,*risc,*size; | ||
74 | |||
75 | #ifdef DES_PTR | ||
76 | ptr="ptr"; | ||
77 | #else | ||
78 | ptr="idx"; | ||
79 | #endif | ||
80 | #if defined(DES_RISC1) || defined(DES_RISC2) | ||
81 | #ifdef DES_RISC1 | ||
82 | risc="risc1"; | ||
83 | #endif | ||
84 | #ifdef DES_RISC2 | ||
85 | risc="risc2"; | ||
86 | #endif | ||
87 | #else | ||
88 | risc="cisc"; | ||
89 | #endif | ||
90 | #ifdef DES_UNROLL | ||
91 | unroll="16"; | ||
92 | #else | ||
93 | unroll="4"; | ||
94 | #endif | ||
95 | if (sizeof(DES_LONG) != sizeof(long)) | ||
96 | size="int"; | ||
97 | else | ||
98 | size="long"; | ||
99 | sprintf(buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,size); | ||
100 | init=0; | ||
101 | } | ||
102 | return(buf); | ||
103 | } | ||
104 | |||
105 | |||
106 | void des_ecb_encrypt(const_des_cblock *input, des_cblock *output, | ||
107 | des_key_schedule ks, | ||
108 | int enc) | ||
109 | { | ||
110 | register DES_LONG l; | ||
111 | DES_LONG ll[2]; | ||
112 | const unsigned char *in = &(*input)[0]; | ||
113 | unsigned char *out = &(*output)[0]; | ||
114 | |||
115 | c2l(in,l); ll[0]=l; | ||
116 | c2l(in,l); ll[1]=l; | ||
117 | des_encrypt1(ll,ks,enc); | ||
118 | l=ll[0]; l2c(l,out); | ||
119 | l=ll[1]; l2c(l,out); | ||
120 | l=ll[0]=ll[1]=0; | ||
121 | } | ||
122 | |||
diff --git a/src/lib/libcrypto/des/ede_cbcm_enc.c b/src/lib/libcrypto/des/ede_cbcm_enc.c deleted file mode 100644 index b98f7e17af..0000000000 --- a/src/lib/libcrypto/des/ede_cbcm_enc.c +++ /dev/null | |||
@@ -1,197 +0,0 @@ | |||
1 | /* ede_cbcm_enc.c */ | ||
2 | /* Written by Ben Laurie <ben@algroup.co.uk> for the OpenSSL | ||
3 | * project 13 Feb 1999. | ||
4 | */ | ||
5 | /* ==================================================================== | ||
6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in | ||
17 | * the documentation and/or other materials provided with the | ||
18 | * distribution. | ||
19 | * | ||
20 | * 3. All advertising materials mentioning features or use of this | ||
21 | * software must display the following acknowledgment: | ||
22 | * "This product includes software developed by the OpenSSL Project | ||
23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
24 | * | ||
25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
26 | * endorse or promote products derived from this software without | ||
27 | * prior written permission. For written permission, please contact | ||
28 | * licensing@OpenSSL.org. | ||
29 | * | ||
30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
31 | * nor may "OpenSSL" appear in their names without prior written | ||
32 | * permission of the OpenSSL Project. | ||
33 | * | ||
34 | * 6. Redistributions of any form whatsoever must retain the following | ||
35 | * acknowledgment: | ||
36 | * "This product includes software developed by the OpenSSL Project | ||
37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
38 | * | ||
39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
51 | * ==================================================================== | ||
52 | * | ||
53 | * This product includes cryptographic software written by Eric Young | ||
54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
55 | * Hudson (tjh@cryptsoft.com). | ||
56 | * | ||
57 | */ | ||
58 | |||
59 | /* | ||
60 | |||
61 | This is an implementation of Triple DES Cipher Block Chaining with Output | ||
62 | Feedback Masking, by Coppersmith, Johnson and Matyas, (IBM and Certicom). | ||
63 | |||
64 | Note that there is a known attack on this by Biham and Knudsen but it takes | ||
65 | a lot of work: | ||
66 | |||
67 | http://www.cs.technion.ac.il/users/wwwb/cgi-bin/tr-get.cgi/1998/CS/CS0928.ps.gz | ||
68 | |||
69 | */ | ||
70 | |||
71 | #ifndef NO_DESCBCM | ||
72 | #include "des_locl.h" | ||
73 | |||
74 | void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, | ||
75 | long length, des_key_schedule ks1, des_key_schedule ks2, | ||
76 | des_key_schedule ks3, des_cblock *ivec1, des_cblock *ivec2, | ||
77 | int enc) | ||
78 | { | ||
79 | register DES_LONG tin0,tin1; | ||
80 | register DES_LONG tout0,tout1,xor0,xor1,m0,m1; | ||
81 | register long l=length; | ||
82 | DES_LONG tin[2]; | ||
83 | unsigned char *iv1,*iv2; | ||
84 | |||
85 | iv1 = &(*ivec1)[0]; | ||
86 | iv2 = &(*ivec2)[0]; | ||
87 | |||
88 | if (enc) | ||
89 | { | ||
90 | c2l(iv1,m0); | ||
91 | c2l(iv1,m1); | ||
92 | c2l(iv2,tout0); | ||
93 | c2l(iv2,tout1); | ||
94 | for (l-=8; l>=-7; l-=8) | ||
95 | { | ||
96 | tin[0]=m0; | ||
97 | tin[1]=m1; | ||
98 | des_encrypt1(tin,ks3,1); | ||
99 | m0=tin[0]; | ||
100 | m1=tin[1]; | ||
101 | |||
102 | if(l < 0) | ||
103 | { | ||
104 | c2ln(in,tin0,tin1,l+8); | ||
105 | } | ||
106 | else | ||
107 | { | ||
108 | c2l(in,tin0); | ||
109 | c2l(in,tin1); | ||
110 | } | ||
111 | tin0^=tout0; | ||
112 | tin1^=tout1; | ||
113 | |||
114 | tin[0]=tin0; | ||
115 | tin[1]=tin1; | ||
116 | des_encrypt1(tin,ks1,1); | ||
117 | tin[0]^=m0; | ||
118 | tin[1]^=m1; | ||
119 | des_encrypt1(tin,ks2,0); | ||
120 | tin[0]^=m0; | ||
121 | tin[1]^=m1; | ||
122 | des_encrypt1(tin,ks1,1); | ||
123 | tout0=tin[0]; | ||
124 | tout1=tin[1]; | ||
125 | |||
126 | l2c(tout0,out); | ||
127 | l2c(tout1,out); | ||
128 | } | ||
129 | iv1=&(*ivec1)[0]; | ||
130 | l2c(m0,iv1); | ||
131 | l2c(m1,iv1); | ||
132 | |||
133 | iv2=&(*ivec2)[0]; | ||
134 | l2c(tout0,iv2); | ||
135 | l2c(tout1,iv2); | ||
136 | } | ||
137 | else | ||
138 | { | ||
139 | register DES_LONG t0,t1; | ||
140 | |||
141 | c2l(iv1,m0); | ||
142 | c2l(iv1,m1); | ||
143 | c2l(iv2,xor0); | ||
144 | c2l(iv2,xor1); | ||
145 | for (l-=8; l>=-7; l-=8) | ||
146 | { | ||
147 | tin[0]=m0; | ||
148 | tin[1]=m1; | ||
149 | des_encrypt1(tin,ks3,1); | ||
150 | m0=tin[0]; | ||
151 | m1=tin[1]; | ||
152 | |||
153 | c2l(in,tin0); | ||
154 | c2l(in,tin1); | ||
155 | |||
156 | t0=tin0; | ||
157 | t1=tin1; | ||
158 | |||
159 | tin[0]=tin0; | ||
160 | tin[1]=tin1; | ||
161 | des_encrypt1(tin,ks1,0); | ||
162 | tin[0]^=m0; | ||
163 | tin[1]^=m1; | ||
164 | des_encrypt1(tin,ks2,1); | ||
165 | tin[0]^=m0; | ||
166 | tin[1]^=m1; | ||
167 | des_encrypt1(tin,ks1,0); | ||
168 | tout0=tin[0]; | ||
169 | tout1=tin[1]; | ||
170 | |||
171 | tout0^=xor0; | ||
172 | tout1^=xor1; | ||
173 | if(l < 0) | ||
174 | { | ||
175 | l2cn(tout0,tout1,out,l+8); | ||
176 | } | ||
177 | else | ||
178 | { | ||
179 | l2c(tout0,out); | ||
180 | l2c(tout1,out); | ||
181 | } | ||
182 | xor0=t0; | ||
183 | xor1=t1; | ||
184 | } | ||
185 | |||
186 | iv1=&(*ivec1)[0]; | ||
187 | l2c(m0,iv1); | ||
188 | l2c(m1,iv1); | ||
189 | |||
190 | iv2=&(*ivec2)[0]; | ||
191 | l2c(xor0,iv2); | ||
192 | l2c(xor1,iv2); | ||
193 | } | ||
194 | tin0=tin1=tout0=tout1=xor0=xor1=0; | ||
195 | tin[0]=tin[1]=0; | ||
196 | } | ||
197 | #endif | ||
diff --git a/src/lib/libcrypto/des/enc_read.c b/src/lib/libcrypto/des/enc_read.c deleted file mode 100644 index af2d9177d2..0000000000 --- a/src/lib/libcrypto/des/enc_read.c +++ /dev/null | |||
@@ -1,228 +0,0 @@ | |||
1 | /* crypto/des/enc_read.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include <stdio.h> | ||
60 | #include <errno.h> | ||
61 | #include "cryptlib.h" | ||
62 | #include "des_locl.h" | ||
63 | |||
64 | /* This has some uglies in it but it works - even over sockets. */ | ||
65 | /*extern int errno;*/ | ||
66 | OPENSSL_GLOBAL int des_rw_mode=DES_PCBC_MODE; | ||
67 | |||
68 | |||
69 | /* | ||
70 | * WARNINGS: | ||
71 | * | ||
72 | * - The data format used by des_enc_write() and des_enc_read() | ||
73 | * has a cryptographic weakness: When asked to write more | ||
74 | * than MAXWRITE bytes, des_enc_write will split the data | ||
75 | * into several chunks that are all encrypted | ||
76 | * using the same IV. So don't use these functions unless you | ||
77 | * are sure you know what you do (in which case you might | ||
78 | * not want to use them anyway). | ||
79 | * | ||
80 | * - This code cannot handle non-blocking sockets. | ||
81 | * | ||
82 | * - This function uses an internal state and thus cannot be | ||
83 | * used on multiple files. | ||
84 | */ | ||
85 | |||
86 | |||
87 | int des_enc_read(int fd, void *buf, int len, des_key_schedule sched, | ||
88 | des_cblock *iv) | ||
89 | { | ||
90 | /* data to be unencrypted */ | ||
91 | int net_num=0; | ||
92 | static unsigned char *net=NULL; | ||
93 | /* extra unencrypted data | ||
94 | * for when a block of 100 comes in but is des_read one byte at | ||
95 | * a time. */ | ||
96 | static unsigned char *unnet=NULL; | ||
97 | static int unnet_start=0; | ||
98 | static int unnet_left=0; | ||
99 | static unsigned char *tmpbuf=NULL; | ||
100 | int i; | ||
101 | long num=0,rnum; | ||
102 | unsigned char *p; | ||
103 | |||
104 | if (tmpbuf == NULL) | ||
105 | { | ||
106 | tmpbuf=OPENSSL_malloc(BSIZE); | ||
107 | if (tmpbuf == NULL) return(-1); | ||
108 | } | ||
109 | if (net == NULL) | ||
110 | { | ||
111 | net=OPENSSL_malloc(BSIZE); | ||
112 | if (net == NULL) return(-1); | ||
113 | } | ||
114 | if (unnet == NULL) | ||
115 | { | ||
116 | unnet=OPENSSL_malloc(BSIZE); | ||
117 | if (unnet == NULL) return(-1); | ||
118 | } | ||
119 | /* left over data from last decrypt */ | ||
120 | if (unnet_left != 0) | ||
121 | { | ||
122 | if (unnet_left < len) | ||
123 | { | ||
124 | /* we still still need more data but will return | ||
125 | * with the number of bytes we have - should always | ||
126 | * check the return value */ | ||
127 | memcpy(buf,&(unnet[unnet_start]), | ||
128 | unnet_left); | ||
129 | /* eay 26/08/92 I had the next 2 lines | ||
130 | * reversed :-( */ | ||
131 | i=unnet_left; | ||
132 | unnet_start=unnet_left=0; | ||
133 | } | ||
134 | else | ||
135 | { | ||
136 | memcpy(buf,&(unnet[unnet_start]),len); | ||
137 | unnet_start+=len; | ||
138 | unnet_left-=len; | ||
139 | i=len; | ||
140 | } | ||
141 | return(i); | ||
142 | } | ||
143 | |||
144 | /* We need to get more data. */ | ||
145 | if (len > MAXWRITE) len=MAXWRITE; | ||
146 | |||
147 | /* first - get the length */ | ||
148 | while (net_num < HDRSIZE) | ||
149 | { | ||
150 | i=read(fd,(void *)&(net[net_num]),HDRSIZE-net_num); | ||
151 | #ifdef EINTR | ||
152 | if ((i == -1) && (errno == EINTR)) continue; | ||
153 | #endif | ||
154 | if (i <= 0) return(0); | ||
155 | net_num+=i; | ||
156 | } | ||
157 | |||
158 | /* we now have at net_num bytes in net */ | ||
159 | p=net; | ||
160 | /* num=0; */ | ||
161 | n2l(p,num); | ||
162 | /* num should be rounded up to the next group of eight | ||
163 | * we make sure that we have read a multiple of 8 bytes from the net. | ||
164 | */ | ||
165 | if ((num > MAXWRITE) || (num < 0)) /* error */ | ||
166 | return(-1); | ||
167 | rnum=(num < 8)?8:((num+7)/8*8); | ||
168 | |||
169 | net_num=0; | ||
170 | while (net_num < rnum) | ||
171 | { | ||
172 | i=read(fd,(void *)&(net[net_num]),rnum-net_num); | ||
173 | #ifdef EINTR | ||
174 | if ((i == -1) && (errno == EINTR)) continue; | ||
175 | #endif | ||
176 | if (i <= 0) return(0); | ||
177 | net_num+=i; | ||
178 | } | ||
179 | |||
180 | /* Check if there will be data left over. */ | ||
181 | if (len < num) | ||
182 | { | ||
183 | if (des_rw_mode & DES_PCBC_MODE) | ||
184 | des_pcbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT); | ||
185 | else | ||
186 | des_cbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT); | ||
187 | memcpy(buf,unnet,len); | ||
188 | unnet_start=len; | ||
189 | unnet_left=num-len; | ||
190 | |||
191 | /* The following line is done because we return num | ||
192 | * as the number of bytes read. */ | ||
193 | num=len; | ||
194 | } | ||
195 | else | ||
196 | { | ||
197 | /* >output is a multiple of 8 byes, if len < rnum | ||
198 | * >we must be careful. The user must be aware that this | ||
199 | * >routine will write more bytes than he asked for. | ||
200 | * >The length of the buffer must be correct. | ||
201 | * FIXED - Should be ok now 18-9-90 - eay */ | ||
202 | if (len < rnum) | ||
203 | { | ||
204 | |||
205 | if (des_rw_mode & DES_PCBC_MODE) | ||
206 | des_pcbc_encrypt(net,tmpbuf,num,sched,iv, | ||
207 | DES_DECRYPT); | ||
208 | else | ||
209 | des_cbc_encrypt(net,tmpbuf,num,sched,iv, | ||
210 | DES_DECRYPT); | ||
211 | |||
212 | /* eay 26/08/92 fix a bug that returned more | ||
213 | * bytes than you asked for (returned len bytes :-( */ | ||
214 | memcpy(buf,tmpbuf,num); | ||
215 | } | ||
216 | else | ||
217 | { | ||
218 | if (des_rw_mode & DES_PCBC_MODE) | ||
219 | des_pcbc_encrypt(net,buf,num,sched,iv, | ||
220 | DES_DECRYPT); | ||
221 | else | ||
222 | des_cbc_encrypt(net,buf,num,sched,iv, | ||
223 | DES_DECRYPT); | ||
224 | } | ||
225 | } | ||
226 | return num; | ||
227 | } | ||
228 | |||
diff --git a/src/lib/libcrypto/des/enc_writ.c b/src/lib/libcrypto/des/enc_writ.c deleted file mode 100644 index cc2b50fb50..0000000000 --- a/src/lib/libcrypto/des/enc_writ.c +++ /dev/null | |||
@@ -1,171 +0,0 @@ | |||
1 | /* crypto/des/enc_writ.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include <errno.h> | ||
60 | #include <time.h> | ||
61 | #include <stdio.h> | ||
62 | #include "cryptlib.h" | ||
63 | #include "des_locl.h" | ||
64 | #include <openssl/rand.h> | ||
65 | |||
66 | /* | ||
67 | * WARNINGS: | ||
68 | * | ||
69 | * - The data format used by des_enc_write() and des_enc_read() | ||
70 | * has a cryptographic weakness: When asked to write more | ||
71 | * than MAXWRITE bytes, des_enc_write will split the data | ||
72 | * into several chunks that are all encrypted | ||
73 | * using the same IV. So don't use these functions unless you | ||
74 | * are sure you know what you do (in which case you might | ||
75 | * not want to use them anyway). | ||
76 | * | ||
77 | * - This code cannot handle non-blocking sockets. | ||
78 | */ | ||
79 | |||
80 | int des_enc_write(int fd, const void *_buf, int len, | ||
81 | des_key_schedule sched, des_cblock *iv) | ||
82 | { | ||
83 | #ifdef _LIBC | ||
84 | extern unsigned long time(); | ||
85 | extern int write(); | ||
86 | #endif | ||
87 | const unsigned char *buf=_buf; | ||
88 | long rnum; | ||
89 | int i,j,k,outnum; | ||
90 | static unsigned char *outbuf=NULL; | ||
91 | unsigned char shortbuf[8]; | ||
92 | unsigned char *p; | ||
93 | const unsigned char *cp; | ||
94 | static int start=1; | ||
95 | |||
96 | if (outbuf == NULL) | ||
97 | { | ||
98 | outbuf=OPENSSL_malloc(BSIZE+HDRSIZE); | ||
99 | if (outbuf == NULL) return(-1); | ||
100 | } | ||
101 | /* If we are sending less than 8 bytes, the same char will look | ||
102 | * the same if we don't pad it out with random bytes */ | ||
103 | if (start) | ||
104 | { | ||
105 | start=0; | ||
106 | } | ||
107 | |||
108 | /* lets recurse if we want to send the data in small chunks */ | ||
109 | if (len > MAXWRITE) | ||
110 | { | ||
111 | j=0; | ||
112 | for (i=0; i<len; i+=k) | ||
113 | { | ||
114 | k=des_enc_write(fd,&(buf[i]), | ||
115 | ((len-i) > MAXWRITE)?MAXWRITE:(len-i),sched,iv); | ||
116 | if (k < 0) | ||
117 | return(k); | ||
118 | else | ||
119 | j+=k; | ||
120 | } | ||
121 | return(j); | ||
122 | } | ||
123 | |||
124 | /* write length first */ | ||
125 | p=outbuf; | ||
126 | l2n(len,p); | ||
127 | |||
128 | /* pad short strings */ | ||
129 | if (len < 8) | ||
130 | { | ||
131 | cp=shortbuf; | ||
132 | memcpy(shortbuf,buf,len); | ||
133 | RAND_pseudo_bytes(shortbuf+len, 8-len); | ||
134 | rnum=8; | ||
135 | } | ||
136 | else | ||
137 | { | ||
138 | cp=buf; | ||
139 | rnum=((len+7)/8*8); /* round up to nearest eight */ | ||
140 | } | ||
141 | |||
142 | if (des_rw_mode & DES_PCBC_MODE) | ||
143 | des_pcbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv, | ||
144 | DES_ENCRYPT); | ||
145 | else | ||
146 | des_cbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv, | ||
147 | DES_ENCRYPT); | ||
148 | |||
149 | /* output */ | ||
150 | outnum=rnum+HDRSIZE; | ||
151 | |||
152 | for (j=0; j<outnum; j+=i) | ||
153 | { | ||
154 | /* eay 26/08/92 I was not doing writing from where we | ||
155 | * got up to. */ | ||
156 | i=write(fd,(void *)&(outbuf[j]),outnum-j); | ||
157 | if (i == -1) | ||
158 | { | ||
159 | #ifdef EINTR | ||
160 | if (errno == EINTR) | ||
161 | i=0; | ||
162 | else | ||
163 | #endif | ||
164 | /* This is really a bad error - very bad | ||
165 | * It will stuff-up both ends. */ | ||
166 | return(-1); | ||
167 | } | ||
168 | } | ||
169 | |||
170 | return(len); | ||
171 | } | ||
diff --git a/src/lib/libcrypto/des/fcrypt.c b/src/lib/libcrypto/des/fcrypt.c deleted file mode 100644 index 9b21f81cc2..0000000000 --- a/src/lib/libcrypto/des/fcrypt.c +++ /dev/null | |||
@@ -1,152 +0,0 @@ | |||
1 | /* NOCW */ | ||
2 | #include <stdio.h> | ||
3 | |||
4 | /* This version of crypt has been developed from my MIT compatible | ||
5 | * DES library. | ||
6 | * Eric Young (eay@cryptsoft.com) | ||
7 | */ | ||
8 | |||
9 | /* Modification by Jens Kupferschmidt (Cu) | ||
10 | * I have included directive PARA for shared memory computers. | ||
11 | * I have included a directive LONGCRYPT to using this routine to cipher | ||
12 | * passwords with more then 8 bytes like HP-UX 10.x it used. The MAXPLEN | ||
13 | * definition is the maximum of length of password and can changed. I have | ||
14 | * defined 24. | ||
15 | */ | ||
16 | |||
17 | #include "des_locl.h" | ||
18 | |||
19 | /* Added more values to handle illegal salt values the way normal | ||
20 | * crypt() implementations do. The patch was sent by | ||
21 | * Bjorn Gronvall <bg@sics.se> | ||
22 | */ | ||
23 | static unsigned const char con_salt[128]={ | ||
24 | 0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9, | ||
25 | 0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,0xE0,0xE1, | ||
26 | 0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9, | ||
27 | 0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1, | ||
28 | 0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9, | ||
29 | 0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,0x00,0x01, | ||
30 | 0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09, | ||
31 | 0x0A,0x0B,0x05,0x06,0x07,0x08,0x09,0x0A, | ||
32 | 0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12, | ||
33 | 0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A, | ||
34 | 0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22, | ||
35 | 0x23,0x24,0x25,0x20,0x21,0x22,0x23,0x24, | ||
36 | 0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C, | ||
37 | 0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34, | ||
38 | 0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C, | ||
39 | 0x3D,0x3E,0x3F,0x40,0x41,0x42,0x43,0x44, | ||
40 | }; | ||
41 | |||
42 | static unsigned const char cov_2char[64]={ | ||
43 | 0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35, | ||
44 | 0x36,0x37,0x38,0x39,0x41,0x42,0x43,0x44, | ||
45 | 0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C, | ||
46 | 0x4D,0x4E,0x4F,0x50,0x51,0x52,0x53,0x54, | ||
47 | 0x55,0x56,0x57,0x58,0x59,0x5A,0x61,0x62, | ||
48 | 0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A, | ||
49 | 0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72, | ||
50 | 0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A | ||
51 | }; | ||
52 | |||
53 | #ifndef NOPROTO | ||
54 | void fcrypt_body(DES_LONG *out,des_key_schedule ks, | ||
55 | DES_LONG Eswap0, DES_LONG Eswap1); | ||
56 | |||
57 | #if defined(PERL5) || defined(FreeBSD) || defined(__OpenBSD__) | ||
58 | char *des_crypt(const char *buf,const char *salt); | ||
59 | #else | ||
60 | char *crypt(const char *buf,const char *salt); | ||
61 | #endif | ||
62 | #else | ||
63 | void fcrypt_body(); | ||
64 | #ifdef PERL5 | ||
65 | char *des_crypt(); | ||
66 | #else | ||
67 | char *crypt(); | ||
68 | #endif | ||
69 | #endif | ||
70 | |||
71 | #if defined(PERL5) || defined(FreeBSD) || defined(__OpenBSD__) | ||
72 | char *des_crypt(buf,salt) | ||
73 | #else | ||
74 | char *crypt(buf,salt) | ||
75 | #endif | ||
76 | const char *buf; | ||
77 | const char *salt; | ||
78 | { | ||
79 | static char buff[14]; | ||
80 | |||
81 | return(des_fcrypt(buf,salt,buff)); | ||
82 | } | ||
83 | |||
84 | |||
85 | char *des_fcrypt(buf,salt,ret) | ||
86 | const char *buf; | ||
87 | const char *salt; | ||
88 | char *ret; | ||
89 | { | ||
90 | unsigned int i,j,x,y; | ||
91 | DES_LONG Eswap0,Eswap1; | ||
92 | DES_LONG out[2],ll; | ||
93 | des_cblock key; | ||
94 | des_key_schedule ks; | ||
95 | unsigned char bb[9]; | ||
96 | unsigned char *b=bb; | ||
97 | unsigned char c,u; | ||
98 | |||
99 | /* eay 25/08/92 | ||
100 | * If you call crypt("pwd","*") as often happens when you | ||
101 | * have * as the pwd field in /etc/passwd, the function | ||
102 | * returns *\0XXXXXXXXX | ||
103 | * The \0 makes the string look like * so the pwd "*" would | ||
104 | * crypt to "*". This was found when replacing the crypt in | ||
105 | * our shared libraries. People found that the disabled | ||
106 | * accounts effectively had no passwd :-(. */ | ||
107 | x=ret[0]=((salt[0] == '\0')?'A':salt[0]); | ||
108 | Eswap0=con_salt[x]<<2; | ||
109 | x=ret[1]=((salt[1] == '\0')?'A':salt[1]); | ||
110 | Eswap1=con_salt[x]<<6; | ||
111 | |||
112 | /* EAY | ||
113 | r=strlen(buf); | ||
114 | r=(r+7)/8; | ||
115 | */ | ||
116 | for (i=0; i<8; i++) | ||
117 | { | ||
118 | c= *(buf++); | ||
119 | if (!c) break; | ||
120 | key[i]=(c<<1); | ||
121 | } | ||
122 | for (; i<8; i++) | ||
123 | key[i]=0; | ||
124 | |||
125 | des_set_key_unchecked(&key,ks); | ||
126 | fcrypt_body(&(out[0]),ks,Eswap0,Eswap1); | ||
127 | |||
128 | ll=out[0]; l2c(ll,b); | ||
129 | ll=out[1]; l2c(ll,b); | ||
130 | y=0; | ||
131 | u=0x80; | ||
132 | bb[8]=0; | ||
133 | for (i=2; i<13; i++) | ||
134 | { | ||
135 | c=0; | ||
136 | for (j=0; j<6; j++) | ||
137 | { | ||
138 | c<<=1; | ||
139 | if (bb[y] & u) c|=1; | ||
140 | u>>=1; | ||
141 | if (!u) | ||
142 | { | ||
143 | y++; | ||
144 | u=0x80; | ||
145 | } | ||
146 | } | ||
147 | ret[i]=cov_2char[c]; | ||
148 | } | ||
149 | ret[13]='\0'; | ||
150 | return(ret); | ||
151 | } | ||
152 | |||
diff --git a/src/lib/libcrypto/des/fcrypt_b.c b/src/lib/libcrypto/des/fcrypt_b.c deleted file mode 100644 index 22c87f5983..0000000000 --- a/src/lib/libcrypto/des/fcrypt_b.c +++ /dev/null | |||
@@ -1,145 +0,0 @@ | |||
1 | /* crypto/des/fcrypt_b.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include <stdio.h> | ||
60 | |||
61 | /* This version of crypt has been developed from my MIT compatible | ||
62 | * DES library. | ||
63 | * The library is available at pub/Crypto/DES at ftp.psy.uq.oz.au | ||
64 | * Eric Young (eay@cryptsoft.com) | ||
65 | */ | ||
66 | |||
67 | #define DES_FCRYPT | ||
68 | #include "des_locl.h" | ||
69 | #undef DES_FCRYPT | ||
70 | |||
71 | #undef PERM_OP | ||
72 | #define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\ | ||
73 | (b)^=(t),\ | ||
74 | (a)^=((t)<<(n))) | ||
75 | |||
76 | #undef HPERM_OP | ||
77 | #define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ | ||
78 | (a)=(a)^(t)^(t>>(16-(n))))\ | ||
79 | |||
80 | void fcrypt_body(DES_LONG *out, des_key_schedule ks, DES_LONG Eswap0, | ||
81 | DES_LONG Eswap1) | ||
82 | { | ||
83 | register DES_LONG l,r,t,u; | ||
84 | #ifdef DES_PTR | ||
85 | register const unsigned char *des_SP=(const unsigned char *)des_SPtrans; | ||
86 | #endif | ||
87 | register DES_LONG *s; | ||
88 | register int j; | ||
89 | register DES_LONG E0,E1; | ||
90 | |||
91 | l=0; | ||
92 | r=0; | ||
93 | |||
94 | s=(DES_LONG *)ks; | ||
95 | E0=Eswap0; | ||
96 | E1=Eswap1; | ||
97 | |||
98 | for (j=0; j<25; j++) | ||
99 | { | ||
100 | #ifndef DES_UNROLL | ||
101 | register int i; | ||
102 | |||
103 | for (i=0; i<32; i+=8) | ||
104 | { | ||
105 | D_ENCRYPT(l,r,i+0); /* 1 */ | ||
106 | D_ENCRYPT(r,l,i+2); /* 2 */ | ||
107 | D_ENCRYPT(l,r,i+4); /* 1 */ | ||
108 | D_ENCRYPT(r,l,i+6); /* 2 */ | ||
109 | } | ||
110 | #else | ||
111 | D_ENCRYPT(l,r, 0); /* 1 */ | ||
112 | D_ENCRYPT(r,l, 2); /* 2 */ | ||
113 | D_ENCRYPT(l,r, 4); /* 3 */ | ||
114 | D_ENCRYPT(r,l, 6); /* 4 */ | ||
115 | D_ENCRYPT(l,r, 8); /* 5 */ | ||
116 | D_ENCRYPT(r,l,10); /* 6 */ | ||
117 | D_ENCRYPT(l,r,12); /* 7 */ | ||
118 | D_ENCRYPT(r,l,14); /* 8 */ | ||
119 | D_ENCRYPT(l,r,16); /* 9 */ | ||
120 | D_ENCRYPT(r,l,18); /* 10 */ | ||
121 | D_ENCRYPT(l,r,20); /* 11 */ | ||
122 | D_ENCRYPT(r,l,22); /* 12 */ | ||
123 | D_ENCRYPT(l,r,24); /* 13 */ | ||
124 | D_ENCRYPT(r,l,26); /* 14 */ | ||
125 | D_ENCRYPT(l,r,28); /* 15 */ | ||
126 | D_ENCRYPT(r,l,30); /* 16 */ | ||
127 | #endif | ||
128 | |||
129 | t=l; | ||
130 | l=r; | ||
131 | r=t; | ||
132 | } | ||
133 | l=ROTATE(l,3)&0xffffffffL; | ||
134 | r=ROTATE(r,3)&0xffffffffL; | ||
135 | |||
136 | PERM_OP(l,r,t, 1,0x55555555L); | ||
137 | PERM_OP(r,l,t, 8,0x00ff00ffL); | ||
138 | PERM_OP(l,r,t, 2,0x33333333L); | ||
139 | PERM_OP(r,l,t,16,0x0000ffffL); | ||
140 | PERM_OP(l,r,t, 4,0x0f0f0f0fL); | ||
141 | |||
142 | out[0]=r; | ||
143 | out[1]=l; | ||
144 | } | ||
145 | |||
diff --git a/src/lib/libcrypto/des/ncbc_enc.c b/src/lib/libcrypto/des/ncbc_enc.c deleted file mode 100644 index b8db07b199..0000000000 --- a/src/lib/libcrypto/des/ncbc_enc.c +++ /dev/null | |||
@@ -1,148 +0,0 @@ | |||
1 | /* crypto/des/ncbc_enc.c */ | ||
2 | /* | ||
3 | * #included by: | ||
4 | * cbc_enc.c (des_cbc_encrypt) | ||
5 | * des_enc.c (des_ncbc_encrypt) | ||
6 | */ | ||
7 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
8 | * All rights reserved. | ||
9 | * | ||
10 | * This package is an SSL implementation written | ||
11 | * by Eric Young (eay@cryptsoft.com). | ||
12 | * The implementation was written so as to conform with Netscapes SSL. | ||
13 | * | ||
14 | * This library is free for commercial and non-commercial use as long as | ||
15 | * the following conditions are aheared to. The following conditions | ||
16 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
17 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
18 | * included with this distribution is covered by the same copyright terms | ||
19 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
20 | * | ||
21 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
22 | * the code are not to be removed. | ||
23 | * If this package is used in a product, Eric Young should be given attribution | ||
24 | * as the author of the parts of the library used. | ||
25 | * This can be in the form of a textual message at program startup or | ||
26 | * in documentation (online or textual) provided with the package. | ||
27 | * | ||
28 | * Redistribution and use in source and binary forms, with or without | ||
29 | * modification, are permitted provided that the following conditions | ||
30 | * are met: | ||
31 | * 1. Redistributions of source code must retain the copyright | ||
32 | * notice, this list of conditions and the following disclaimer. | ||
33 | * 2. Redistributions in binary form must reproduce the above copyright | ||
34 | * notice, this list of conditions and the following disclaimer in the | ||
35 | * documentation and/or other materials provided with the distribution. | ||
36 | * 3. All advertising materials mentioning features or use of this software | ||
37 | * must display the following acknowledgement: | ||
38 | * "This product includes cryptographic software written by | ||
39 | * Eric Young (eay@cryptsoft.com)" | ||
40 | * The word 'cryptographic' can be left out if the rouines from the library | ||
41 | * being used are not cryptographic related :-). | ||
42 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
43 | * the apps directory (application code) you must include an acknowledgement: | ||
44 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
45 | * | ||
46 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
47 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
48 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
49 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
50 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
51 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
52 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
53 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
54 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
55 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
56 | * SUCH DAMAGE. | ||
57 | * | ||
58 | * The licence and distribution terms for any publically available version or | ||
59 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
60 | * copied and put under another distribution licence | ||
61 | * [including the GNU Public Licence.] | ||
62 | */ | ||
63 | |||
64 | #include "des_locl.h" | ||
65 | |||
66 | #ifdef CBC_ENC_C__DONT_UPDATE_IV | ||
67 | void des_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, | ||
68 | des_key_schedule schedule, des_cblock *ivec, int enc) | ||
69 | #else | ||
70 | void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, | ||
71 | des_key_schedule schedule, des_cblock *ivec, int enc) | ||
72 | #endif | ||
73 | { | ||
74 | register DES_LONG tin0,tin1; | ||
75 | register DES_LONG tout0,tout1,xor0,xor1; | ||
76 | register long l=length; | ||
77 | DES_LONG tin[2]; | ||
78 | unsigned char *iv; | ||
79 | |||
80 | iv = &(*ivec)[0]; | ||
81 | |||
82 | if (enc) | ||
83 | { | ||
84 | c2l(iv,tout0); | ||
85 | c2l(iv,tout1); | ||
86 | for (l-=8; l>=0; l-=8) | ||
87 | { | ||
88 | c2l(in,tin0); | ||
89 | c2l(in,tin1); | ||
90 | tin0^=tout0; tin[0]=tin0; | ||
91 | tin1^=tout1; tin[1]=tin1; | ||
92 | des_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT); | ||
93 | tout0=tin[0]; l2c(tout0,out); | ||
94 | tout1=tin[1]; l2c(tout1,out); | ||
95 | } | ||
96 | if (l != -8) | ||
97 | { | ||
98 | c2ln(in,tin0,tin1,l+8); | ||
99 | tin0^=tout0; tin[0]=tin0; | ||
100 | tin1^=tout1; tin[1]=tin1; | ||
101 | des_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT); | ||
102 | tout0=tin[0]; l2c(tout0,out); | ||
103 | tout1=tin[1]; l2c(tout1,out); | ||
104 | } | ||
105 | #ifndef CBC_ENC_C__DONT_UPDATE_IV | ||
106 | iv = &(*ivec)[0]; | ||
107 | l2c(tout0,iv); | ||
108 | l2c(tout1,iv); | ||
109 | #endif | ||
110 | } | ||
111 | else | ||
112 | { | ||
113 | c2l(iv,xor0); | ||
114 | c2l(iv,xor1); | ||
115 | for (l-=8; l>=0; l-=8) | ||
116 | { | ||
117 | c2l(in,tin0); tin[0]=tin0; | ||
118 | c2l(in,tin1); tin[1]=tin1; | ||
119 | des_encrypt1((DES_LONG *)tin,schedule,DES_DECRYPT); | ||
120 | tout0=tin[0]^xor0; | ||
121 | tout1=tin[1]^xor1; | ||
122 | l2c(tout0,out); | ||
123 | l2c(tout1,out); | ||
124 | xor0=tin0; | ||
125 | xor1=tin1; | ||
126 | } | ||
127 | if (l != -8) | ||
128 | { | ||
129 | c2l(in,tin0); tin[0]=tin0; | ||
130 | c2l(in,tin1); tin[1]=tin1; | ||
131 | des_encrypt1((DES_LONG *)tin,schedule,DES_DECRYPT); | ||
132 | tout0=tin[0]^xor0; | ||
133 | tout1=tin[1]^xor1; | ||
134 | l2cn(tout0,tout1,out,l+8); | ||
135 | #ifndef CBC_ENC_C__DONT_UPDATE_IV | ||
136 | xor0=tin0; | ||
137 | xor1=tin1; | ||
138 | #endif | ||
139 | } | ||
140 | #ifndef CBC_ENC_C__DONT_UPDATE_IV | ||
141 | iv = &(*ivec)[0]; | ||
142 | l2c(xor0,iv); | ||
143 | l2c(xor1,iv); | ||
144 | #endif | ||
145 | } | ||
146 | tin0=tin1=tout0=tout1=xor0=xor1=0; | ||
147 | tin[0]=tin[1]=0; | ||
148 | } | ||
diff --git a/src/lib/libcrypto/des/ofb64ede.c b/src/lib/libcrypto/des/ofb64ede.c deleted file mode 100644 index 6eafe908da..0000000000 --- a/src/lib/libcrypto/des/ofb64ede.c +++ /dev/null | |||
@@ -1,124 +0,0 @@ | |||
1 | /* crypto/des/ofb64ede.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include "des_locl.h" | ||
60 | |||
61 | /* The input and output encrypted as though 64bit ofb mode is being | ||
62 | * used. The extra state information to record how much of the | ||
63 | * 64bit block we have used is contained in *num; | ||
64 | */ | ||
65 | void des_ede3_ofb64_encrypt(register const unsigned char *in, | ||
66 | register unsigned char *out, long length, des_key_schedule k1, | ||
67 | des_key_schedule k2, des_key_schedule k3, des_cblock *ivec, | ||
68 | int *num) | ||
69 | { | ||
70 | register DES_LONG v0,v1; | ||
71 | register int n= *num; | ||
72 | register long l=length; | ||
73 | des_cblock d; | ||
74 | register char *dp; | ||
75 | DES_LONG ti[2]; | ||
76 | unsigned char *iv; | ||
77 | int save=0; | ||
78 | |||
79 | iv = &(*ivec)[0]; | ||
80 | c2l(iv,v0); | ||
81 | c2l(iv,v1); | ||
82 | ti[0]=v0; | ||
83 | ti[1]=v1; | ||
84 | dp=(char *)d; | ||
85 | l2c(v0,dp); | ||
86 | l2c(v1,dp); | ||
87 | while (l--) | ||
88 | { | ||
89 | if (n == 0) | ||
90 | { | ||
91 | /* ti[0]=v0; */ | ||
92 | /* ti[1]=v1; */ | ||
93 | des_encrypt3(ti,k1,k2,k3); | ||
94 | v0=ti[0]; | ||
95 | v1=ti[1]; | ||
96 | |||
97 | dp=(char *)d; | ||
98 | l2c(v0,dp); | ||
99 | l2c(v1,dp); | ||
100 | save++; | ||
101 | } | ||
102 | *(out++)= *(in++)^d[n]; | ||
103 | n=(n+1)&0x07; | ||
104 | } | ||
105 | if (save) | ||
106 | { | ||
107 | /* v0=ti[0]; | ||
108 | v1=ti[1];*/ | ||
109 | iv = &(*ivec)[0]; | ||
110 | l2c(v0,iv); | ||
111 | l2c(v1,iv); | ||
112 | } | ||
113 | v0=v1=ti[0]=ti[1]=0; | ||
114 | *num=n; | ||
115 | } | ||
116 | |||
117 | #ifdef undef /* MACRO */ | ||
118 | void des_ede2_ofb64_encrypt(register unsigned char *in, | ||
119 | register unsigned char *out, long length, des_key_schedule k1, | ||
120 | des_key_schedule k2, des_cblock (*ivec), int *num) | ||
121 | { | ||
122 | des_ede3_ofb64_encrypt(in, out, length, k1,k2,k1, ivec, num); | ||
123 | } | ||
124 | #endif | ||
diff --git a/src/lib/libcrypto/des/ofb64enc.c b/src/lib/libcrypto/des/ofb64enc.c deleted file mode 100644 index 1a1d1f1ac4..0000000000 --- a/src/lib/libcrypto/des/ofb64enc.c +++ /dev/null | |||
@@ -1,110 +0,0 @@ | |||
1 | /* crypto/des/ofb64enc.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include "des_locl.h" | ||
60 | |||
61 | /* The input and output encrypted as though 64bit ofb mode is being | ||
62 | * used. The extra state information to record how much of the | ||
63 | * 64bit block we have used is contained in *num; | ||
64 | */ | ||
65 | void des_ofb64_encrypt(register const unsigned char *in, | ||
66 | register unsigned char *out, long length, des_key_schedule schedule, | ||
67 | des_cblock *ivec, int *num) | ||
68 | { | ||
69 | register DES_LONG v0,v1,t; | ||
70 | register int n= *num; | ||
71 | register long l=length; | ||
72 | des_cblock d; | ||
73 | register unsigned char *dp; | ||
74 | DES_LONG ti[2]; | ||
75 | unsigned char *iv; | ||
76 | int save=0; | ||
77 | |||
78 | iv = &(*ivec)[0]; | ||
79 | c2l(iv,v0); | ||
80 | c2l(iv,v1); | ||
81 | ti[0]=v0; | ||
82 | ti[1]=v1; | ||
83 | dp=d; | ||
84 | l2c(v0,dp); | ||
85 | l2c(v1,dp); | ||
86 | while (l--) | ||
87 | { | ||
88 | if (n == 0) | ||
89 | { | ||
90 | des_encrypt1(ti,schedule,DES_ENCRYPT); | ||
91 | dp=d; | ||
92 | t=ti[0]; l2c(t,dp); | ||
93 | t=ti[1]; l2c(t,dp); | ||
94 | save++; | ||
95 | } | ||
96 | *(out++)= *(in++)^d[n]; | ||
97 | n=(n+1)&0x07; | ||
98 | } | ||
99 | if (save) | ||
100 | { | ||
101 | v0=ti[0]; | ||
102 | v1=ti[1]; | ||
103 | iv = &(*ivec)[0]; | ||
104 | l2c(v0,iv); | ||
105 | l2c(v1,iv); | ||
106 | } | ||
107 | t=v0=v1=ti[0]=ti[1]=0; | ||
108 | *num=n; | ||
109 | } | ||
110 | |||
diff --git a/src/lib/libcrypto/des/ofb_enc.c b/src/lib/libcrypto/des/ofb_enc.c deleted file mode 100644 index 70493e632c..0000000000 --- a/src/lib/libcrypto/des/ofb_enc.c +++ /dev/null | |||
@@ -1,134 +0,0 @@ | |||
1 | /* crypto/des/ofb_enc.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include "des_locl.h" | ||
60 | |||
61 | /* The input and output are loaded in multiples of 8 bits. | ||
62 | * What this means is that if you hame numbits=12 and length=2 | ||
63 | * the first 12 bits will be retrieved from the first byte and half | ||
64 | * the second. The second 12 bits will come from the 3rd and half the 4th | ||
65 | * byte. | ||
66 | */ | ||
67 | void des_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | ||
68 | long length, des_key_schedule schedule, des_cblock *ivec) | ||
69 | { | ||
70 | register DES_LONG d0,d1,vv0,vv1,v0,v1,n=(numbits+7)/8; | ||
71 | register DES_LONG mask0,mask1; | ||
72 | register long l=length; | ||
73 | register int num=numbits; | ||
74 | DES_LONG ti[2]; | ||
75 | unsigned char *iv; | ||
76 | |||
77 | if (num > 64) return; | ||
78 | if (num > 32) | ||
79 | { | ||
80 | mask0=0xffffffffL; | ||
81 | if (num >= 64) | ||
82 | mask1=mask0; | ||
83 | else | ||
84 | mask1=(1L<<(num-32))-1; | ||
85 | } | ||
86 | else | ||
87 | { | ||
88 | if (num == 32) | ||
89 | mask0=0xffffffffL; | ||
90 | else | ||
91 | mask0=(1L<<num)-1; | ||
92 | mask1=0x00000000L; | ||
93 | } | ||
94 | |||
95 | iv = &(*ivec)[0]; | ||
96 | c2l(iv,v0); | ||
97 | c2l(iv,v1); | ||
98 | ti[0]=v0; | ||
99 | ti[1]=v1; | ||
100 | while (l-- > 0) | ||
101 | { | ||
102 | ti[0]=v0; | ||
103 | ti[1]=v1; | ||
104 | des_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); | ||
105 | vv0=ti[0]; | ||
106 | vv1=ti[1]; | ||
107 | c2ln(in,d0,d1,n); | ||
108 | in+=n; | ||
109 | d0=(d0^vv0)&mask0; | ||
110 | d1=(d1^vv1)&mask1; | ||
111 | l2cn(d0,d1,out,n); | ||
112 | out+=n; | ||
113 | |||
114 | if (num == 32) | ||
115 | { v0=v1; v1=vv0; } | ||
116 | else if (num == 64) | ||
117 | { v0=vv0; v1=vv1; } | ||
118 | else if (num > 32) /* && num != 64 */ | ||
119 | { | ||
120 | v0=((v1>>(num-32))|(vv0<<(64-num)))&0xffffffffL; | ||
121 | v1=((vv0>>(num-32))|(vv1<<(64-num)))&0xffffffffL; | ||
122 | } | ||
123 | else /* num < 32 */ | ||
124 | { | ||
125 | v0=((v0>>num)|(v1<<(32-num)))&0xffffffffL; | ||
126 | v1=((v1>>num)|(vv0<<(32-num)))&0xffffffffL; | ||
127 | } | ||
128 | } | ||
129 | iv = &(*ivec)[0]; | ||
130 | l2c(v0,iv); | ||
131 | l2c(v1,iv); | ||
132 | v0=v1=d0=d1=ti[0]=ti[1]=vv0=vv1=0; | ||
133 | } | ||
134 | |||
diff --git a/src/lib/libcrypto/des/pcbc_enc.c b/src/lib/libcrypto/des/pcbc_enc.c deleted file mode 100644 index 5b987f074d..0000000000 --- a/src/lib/libcrypto/des/pcbc_enc.c +++ /dev/null | |||
@@ -1,122 +0,0 @@ | |||
1 | /* crypto/des/pcbc_enc.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include "des_locl.h" | ||
60 | |||
61 | void des_pcbc_encrypt(const unsigned char *input, unsigned char *output, | ||
62 | long length, des_key_schedule schedule, des_cblock *ivec, int enc) | ||
63 | { | ||
64 | register DES_LONG sin0,sin1,xor0,xor1,tout0,tout1; | ||
65 | DES_LONG tin[2]; | ||
66 | const unsigned char *in; | ||
67 | unsigned char *out,*iv; | ||
68 | |||
69 | in=input; | ||
70 | out=output; | ||
71 | iv = &(*ivec)[0]; | ||
72 | |||
73 | if (enc) | ||
74 | { | ||
75 | c2l(iv,xor0); | ||
76 | c2l(iv,xor1); | ||
77 | for (; length>0; length-=8) | ||
78 | { | ||
79 | if (length >= 8) | ||
80 | { | ||
81 | c2l(in,sin0); | ||
82 | c2l(in,sin1); | ||
83 | } | ||
84 | else | ||
85 | c2ln(in,sin0,sin1,length); | ||
86 | tin[0]=sin0^xor0; | ||
87 | tin[1]=sin1^xor1; | ||
88 | des_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT); | ||
89 | tout0=tin[0]; | ||
90 | tout1=tin[1]; | ||
91 | xor0=sin0^tout0; | ||
92 | xor1=sin1^tout1; | ||
93 | l2c(tout0,out); | ||
94 | l2c(tout1,out); | ||
95 | } | ||
96 | } | ||
97 | else | ||
98 | { | ||
99 | c2l(iv,xor0); c2l(iv,xor1); | ||
100 | for (; length>0; length-=8) | ||
101 | { | ||
102 | c2l(in,sin0); | ||
103 | c2l(in,sin1); | ||
104 | tin[0]=sin0; | ||
105 | tin[1]=sin1; | ||
106 | des_encrypt1((DES_LONG *)tin,schedule,DES_DECRYPT); | ||
107 | tout0=tin[0]^xor0; | ||
108 | tout1=tin[1]^xor1; | ||
109 | if (length >= 8) | ||
110 | { | ||
111 | l2c(tout0,out); | ||
112 | l2c(tout1,out); | ||
113 | } | ||
114 | else | ||
115 | l2cn(tout0,tout1,out,length); | ||
116 | xor0=tout0^sin0; | ||
117 | xor1=tout1^sin1; | ||
118 | } | ||
119 | } | ||
120 | tin[0]=tin[1]=0; | ||
121 | sin0=sin1=xor0=xor1=tout0=tout1=0; | ||
122 | } | ||
diff --git a/src/lib/libcrypto/des/qud_cksm.c b/src/lib/libcrypto/des/qud_cksm.c deleted file mode 100644 index 9fff989edb..0000000000 --- a/src/lib/libcrypto/des/qud_cksm.c +++ /dev/null | |||
@@ -1,139 +0,0 @@ | |||
1 | /* crypto/des/qud_cksm.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | /* From "Message Authentication" R.R. Jueneman, S.M. Matyas, C.H. Meyer | ||
60 | * IEEE Communications Magazine Sept 1985 Vol. 23 No. 9 p 29-40 | ||
61 | * This module in only based on the code in this paper and is | ||
62 | * almost definitely not the same as the MIT implementation. | ||
63 | */ | ||
64 | #include "des_locl.h" | ||
65 | |||
66 | /* bug fix for dos - 7/6/91 - Larry hughes@logos.ucs.indiana.edu */ | ||
67 | #define Q_B0(a) (((DES_LONG)(a))) | ||
68 | #define Q_B1(a) (((DES_LONG)(a))<<8) | ||
69 | #define Q_B2(a) (((DES_LONG)(a))<<16) | ||
70 | #define Q_B3(a) (((DES_LONG)(a))<<24) | ||
71 | |||
72 | /* used to scramble things a bit */ | ||
73 | /* Got the value MIT uses via brute force :-) 2/10/90 eay */ | ||
74 | #define NOISE ((DES_LONG)83653421L) | ||
75 | |||
76 | DES_LONG des_quad_cksum(const unsigned char *input, des_cblock output[], | ||
77 | long length, int out_count, des_cblock *seed) | ||
78 | { | ||
79 | DES_LONG z0,z1,t0,t1; | ||
80 | int i; | ||
81 | long l; | ||
82 | const unsigned char *cp; | ||
83 | #ifdef _CRAY | ||
84 | struct lp_st { int a:32; int b:32; } *lp; | ||
85 | #else | ||
86 | DES_LONG *lp; | ||
87 | #endif | ||
88 | |||
89 | if (out_count < 1) out_count=1; | ||
90 | #ifdef _CRAY | ||
91 | lp = (struct lp_st *) &(output[0])[0]; | ||
92 | #else | ||
93 | lp = (DES_LONG *) &(output[0])[0]; | ||
94 | #endif | ||
95 | |||
96 | z0=Q_B0((*seed)[0])|Q_B1((*seed)[1])|Q_B2((*seed)[2])|Q_B3((*seed)[3]); | ||
97 | z1=Q_B0((*seed)[4])|Q_B1((*seed)[5])|Q_B2((*seed)[6])|Q_B3((*seed)[7]); | ||
98 | |||
99 | for (i=0; ((i<4)&&(i<out_count)); i++) | ||
100 | { | ||
101 | cp=input; | ||
102 | l=length; | ||
103 | while (l > 0) | ||
104 | { | ||
105 | if (l > 1) | ||
106 | { | ||
107 | t0= (DES_LONG)(*(cp++)); | ||
108 | t0|=(DES_LONG)Q_B1(*(cp++)); | ||
109 | l--; | ||
110 | } | ||
111 | else | ||
112 | t0= (DES_LONG)(*(cp++)); | ||
113 | l--; | ||
114 | /* add */ | ||
115 | t0+=z0; | ||
116 | t0&=0xffffffffL; | ||
117 | t1=z1; | ||
118 | /* square, well sort of square */ | ||
119 | z0=((((t0*t0)&0xffffffffL)+((t1*t1)&0xffffffffL)) | ||
120 | &0xffffffffL)%0x7fffffffL; | ||
121 | z1=((t0*((t1+NOISE)&0xffffffffL))&0xffffffffL)%0x7fffffffL; | ||
122 | } | ||
123 | if (lp != NULL) | ||
124 | { | ||
125 | /* The MIT library assumes that the checksum is | ||
126 | * composed of 2*out_count 32 bit ints */ | ||
127 | #ifdef _CRAY | ||
128 | (*lp).a = z0; | ||
129 | (*lp).b = z1; | ||
130 | lp++; | ||
131 | #else | ||
132 | *lp++ = z0; | ||
133 | *lp++ = z1; | ||
134 | #endif | ||
135 | } | ||
136 | } | ||
137 | return(z0); | ||
138 | } | ||
139 | |||
diff --git a/src/lib/libcrypto/des/rand_key.c b/src/lib/libcrypto/des/rand_key.c deleted file mode 100644 index ee1a6c274e..0000000000 --- a/src/lib/libcrypto/des/rand_key.c +++ /dev/null | |||
@@ -1,73 +0,0 @@ | |||
1 | /* crypto/des/rand_key.c */ | ||
2 | /* ==================================================================== | ||
3 | * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * | ||
9 | * 1. Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in | ||
14 | * the documentation and/or other materials provided with the | ||
15 | * distribution. | ||
16 | * | ||
17 | * 3. All advertising materials mentioning features or use of this | ||
18 | * software must display the following acknowledgment: | ||
19 | * "This product includes software developed by the OpenSSL Project | ||
20 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
21 | * | ||
22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
23 | * endorse or promote products derived from this software without | ||
24 | * prior written permission. For written permission, please contact | ||
25 | * openssl-core@openssl.org. | ||
26 | * | ||
27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
28 | * nor may "OpenSSL" appear in their names without prior written | ||
29 | * permission of the OpenSSL Project. | ||
30 | * | ||
31 | * 6. Redistributions of any form whatsoever must retain the following | ||
32 | * acknowledgment: | ||
33 | * "This product includes software developed by the OpenSSL Project | ||
34 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
35 | * | ||
36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
48 | * ==================================================================== | ||
49 | * | ||
50 | * This product includes cryptographic software written by Eric Young | ||
51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
52 | * Hudson (tjh@cryptsoft.com). | ||
53 | * | ||
54 | */ | ||
55 | |||
56 | #include <openssl/des.h> | ||
57 | #include <openssl/rand.h> | ||
58 | |||
59 | void des_random_seed(des_cblock *key) | ||
60 | { | ||
61 | RAND_seed(key, sizeof(des_cblock)); | ||
62 | } | ||
63 | |||
64 | int des_random_key(des_cblock *ret) | ||
65 | { | ||
66 | do | ||
67 | { | ||
68 | if (RAND_bytes((unsigned char *)ret, sizeof(des_cblock)) != 1) | ||
69 | return (0); | ||
70 | } while (des_is_weak_key(ret)); | ||
71 | des_set_odd_parity(ret); | ||
72 | return (1); | ||
73 | } | ||
diff --git a/src/lib/libcrypto/des/set_key.c b/src/lib/libcrypto/des/set_key.c deleted file mode 100644 index 09afd4fc03..0000000000 --- a/src/lib/libcrypto/des/set_key.c +++ /dev/null | |||
@@ -1,402 +0,0 @@ | |||
1 | /* crypto/des/set_key.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | /* set_key.c v 1.4 eay 24/9/91 | ||
60 | * 1.4 Speed up by 400% :-) | ||
61 | * 1.3 added register declarations. | ||
62 | * 1.2 unrolled make_key_sched a bit more | ||
63 | * 1.1 added norm_expand_bits | ||
64 | * 1.0 First working version | ||
65 | */ | ||
66 | #include "des_locl.h" | ||
67 | |||
68 | OPENSSL_GLOBAL int des_check_key=0; | ||
69 | |||
70 | static const unsigned char odd_parity[256]={ | ||
71 | 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14, | ||
72 | 16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31, | ||
73 | 32, 32, 35, 35, 37, 37, 38, 38, 41, 41, 42, 42, 44, 44, 47, 47, | ||
74 | 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 59, 59, 61, 61, 62, 62, | ||
75 | 64, 64, 67, 67, 69, 69, 70, 70, 73, 73, 74, 74, 76, 76, 79, 79, | ||
76 | 81, 81, 82, 82, 84, 84, 87, 87, 88, 88, 91, 91, 93, 93, 94, 94, | ||
77 | 97, 97, 98, 98,100,100,103,103,104,104,107,107,109,109,110,110, | ||
78 | 112,112,115,115,117,117,118,118,121,121,122,122,124,124,127,127, | ||
79 | 128,128,131,131,133,133,134,134,137,137,138,138,140,140,143,143, | ||
80 | 145,145,146,146,148,148,151,151,152,152,155,155,157,157,158,158, | ||
81 | 161,161,162,162,164,164,167,167,168,168,171,171,173,173,174,174, | ||
82 | 176,176,179,179,181,181,182,182,185,185,186,186,188,188,191,191, | ||
83 | 193,193,194,194,196,196,199,199,200,200,203,203,205,205,206,206, | ||
84 | 208,208,211,211,213,213,214,214,217,217,218,218,220,220,223,223, | ||
85 | 224,224,227,227,229,229,230,230,233,233,234,234,236,236,239,239, | ||
86 | 241,241,242,242,244,244,247,247,248,248,251,251,253,253,254,254}; | ||
87 | |||
88 | void des_set_odd_parity(des_cblock *key) | ||
89 | { | ||
90 | int i; | ||
91 | |||
92 | for (i=0; i<DES_KEY_SZ; i++) | ||
93 | (*key)[i]=odd_parity[(*key)[i]]; | ||
94 | } | ||
95 | |||
96 | int des_check_key_parity(const_des_cblock *key) | ||
97 | { | ||
98 | int i; | ||
99 | |||
100 | for (i=0; i<DES_KEY_SZ; i++) | ||
101 | { | ||
102 | if ((*key)[i] != odd_parity[(*key)[i]]) | ||
103 | return(0); | ||
104 | } | ||
105 | return(1); | ||
106 | } | ||
107 | |||
108 | /* Weak and semi week keys as take from | ||
109 | * %A D.W. Davies | ||
110 | * %A W.L. Price | ||
111 | * %T Security for Computer Networks | ||
112 | * %I John Wiley & Sons | ||
113 | * %D 1984 | ||
114 | * Many thanks to smb@ulysses.att.com (Steven Bellovin) for the reference | ||
115 | * (and actual cblock values). | ||
116 | */ | ||
117 | #define NUM_WEAK_KEY 16 | ||
118 | static des_cblock weak_keys[NUM_WEAK_KEY]={ | ||
119 | /* weak keys */ | ||
120 | {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01}, | ||
121 | {0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE}, | ||
122 | {0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E}, | ||
123 | {0xE0,0xE0,0xE0,0xE0,0xF1,0xF1,0xF1,0xF1}, | ||
124 | /* semi-weak keys */ | ||
125 | {0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE}, | ||
126 | {0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01}, | ||
127 | {0x1F,0xE0,0x1F,0xE0,0x0E,0xF1,0x0E,0xF1}, | ||
128 | {0xE0,0x1F,0xE0,0x1F,0xF1,0x0E,0xF1,0x0E}, | ||
129 | {0x01,0xE0,0x01,0xE0,0x01,0xF1,0x01,0xF1}, | ||
130 | {0xE0,0x01,0xE0,0x01,0xF1,0x01,0xF1,0x01}, | ||
131 | {0x1F,0xFE,0x1F,0xFE,0x0E,0xFE,0x0E,0xFE}, | ||
132 | {0xFE,0x1F,0xFE,0x1F,0xFE,0x0E,0xFE,0x0E}, | ||
133 | {0x01,0x1F,0x01,0x1F,0x01,0x0E,0x01,0x0E}, | ||
134 | {0x1F,0x01,0x1F,0x01,0x0E,0x01,0x0E,0x01}, | ||
135 | {0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE}, | ||
136 | {0xFE,0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1}}; | ||
137 | |||
138 | int des_is_weak_key(const_des_cblock *key) | ||
139 | { | ||
140 | int i; | ||
141 | |||
142 | for (i=0; i<NUM_WEAK_KEY; i++) | ||
143 | /* Added == 0 to comparison, I obviously don't run | ||
144 | * this section very often :-(, thanks to | ||
145 | * engineering@MorningStar.Com for the fix | ||
146 | * eay 93/06/29 | ||
147 | * Another problem, I was comparing only the first 4 | ||
148 | * bytes, 97/03/18 */ | ||
149 | if (memcmp(weak_keys[i],key,sizeof(des_cblock)) == 0) return(1); | ||
150 | return(0); | ||
151 | } | ||
152 | |||
153 | /* NOW DEFINED IN des_local.h | ||
154 | * See ecb_encrypt.c for a pseudo description of these macros. | ||
155 | * #define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\ | ||
156 | * (b)^=(t),\ | ||
157 | * (a)=((a)^((t)<<(n)))) | ||
158 | */ | ||
159 | |||
160 | #define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ | ||
161 | (a)=(a)^(t)^(t>>(16-(n)))) | ||
162 | |||
163 | static const DES_LONG des_skb[8][64]={ | ||
164 | { | ||
165 | /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ | ||
166 | 0x00000000L,0x00000010L,0x20000000L,0x20000010L, | ||
167 | 0x00010000L,0x00010010L,0x20010000L,0x20010010L, | ||
168 | 0x00000800L,0x00000810L,0x20000800L,0x20000810L, | ||
169 | 0x00010800L,0x00010810L,0x20010800L,0x20010810L, | ||
170 | 0x00000020L,0x00000030L,0x20000020L,0x20000030L, | ||
171 | 0x00010020L,0x00010030L,0x20010020L,0x20010030L, | ||
172 | 0x00000820L,0x00000830L,0x20000820L,0x20000830L, | ||
173 | 0x00010820L,0x00010830L,0x20010820L,0x20010830L, | ||
174 | 0x00080000L,0x00080010L,0x20080000L,0x20080010L, | ||
175 | 0x00090000L,0x00090010L,0x20090000L,0x20090010L, | ||
176 | 0x00080800L,0x00080810L,0x20080800L,0x20080810L, | ||
177 | 0x00090800L,0x00090810L,0x20090800L,0x20090810L, | ||
178 | 0x00080020L,0x00080030L,0x20080020L,0x20080030L, | ||
179 | 0x00090020L,0x00090030L,0x20090020L,0x20090030L, | ||
180 | 0x00080820L,0x00080830L,0x20080820L,0x20080830L, | ||
181 | 0x00090820L,0x00090830L,0x20090820L,0x20090830L, | ||
182 | },{ | ||
183 | /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ | ||
184 | 0x00000000L,0x02000000L,0x00002000L,0x02002000L, | ||
185 | 0x00200000L,0x02200000L,0x00202000L,0x02202000L, | ||
186 | 0x00000004L,0x02000004L,0x00002004L,0x02002004L, | ||
187 | 0x00200004L,0x02200004L,0x00202004L,0x02202004L, | ||
188 | 0x00000400L,0x02000400L,0x00002400L,0x02002400L, | ||
189 | 0x00200400L,0x02200400L,0x00202400L,0x02202400L, | ||
190 | 0x00000404L,0x02000404L,0x00002404L,0x02002404L, | ||
191 | 0x00200404L,0x02200404L,0x00202404L,0x02202404L, | ||
192 | 0x10000000L,0x12000000L,0x10002000L,0x12002000L, | ||
193 | 0x10200000L,0x12200000L,0x10202000L,0x12202000L, | ||
194 | 0x10000004L,0x12000004L,0x10002004L,0x12002004L, | ||
195 | 0x10200004L,0x12200004L,0x10202004L,0x12202004L, | ||
196 | 0x10000400L,0x12000400L,0x10002400L,0x12002400L, | ||
197 | 0x10200400L,0x12200400L,0x10202400L,0x12202400L, | ||
198 | 0x10000404L,0x12000404L,0x10002404L,0x12002404L, | ||
199 | 0x10200404L,0x12200404L,0x10202404L,0x12202404L, | ||
200 | },{ | ||
201 | /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ | ||
202 | 0x00000000L,0x00000001L,0x00040000L,0x00040001L, | ||
203 | 0x01000000L,0x01000001L,0x01040000L,0x01040001L, | ||
204 | 0x00000002L,0x00000003L,0x00040002L,0x00040003L, | ||
205 | 0x01000002L,0x01000003L,0x01040002L,0x01040003L, | ||
206 | 0x00000200L,0x00000201L,0x00040200L,0x00040201L, | ||
207 | 0x01000200L,0x01000201L,0x01040200L,0x01040201L, | ||
208 | 0x00000202L,0x00000203L,0x00040202L,0x00040203L, | ||
209 | 0x01000202L,0x01000203L,0x01040202L,0x01040203L, | ||
210 | 0x08000000L,0x08000001L,0x08040000L,0x08040001L, | ||
211 | 0x09000000L,0x09000001L,0x09040000L,0x09040001L, | ||
212 | 0x08000002L,0x08000003L,0x08040002L,0x08040003L, | ||
213 | 0x09000002L,0x09000003L,0x09040002L,0x09040003L, | ||
214 | 0x08000200L,0x08000201L,0x08040200L,0x08040201L, | ||
215 | 0x09000200L,0x09000201L,0x09040200L,0x09040201L, | ||
216 | 0x08000202L,0x08000203L,0x08040202L,0x08040203L, | ||
217 | 0x09000202L,0x09000203L,0x09040202L,0x09040203L, | ||
218 | },{ | ||
219 | /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ | ||
220 | 0x00000000L,0x00100000L,0x00000100L,0x00100100L, | ||
221 | 0x00000008L,0x00100008L,0x00000108L,0x00100108L, | ||
222 | 0x00001000L,0x00101000L,0x00001100L,0x00101100L, | ||
223 | 0x00001008L,0x00101008L,0x00001108L,0x00101108L, | ||
224 | 0x04000000L,0x04100000L,0x04000100L,0x04100100L, | ||
225 | 0x04000008L,0x04100008L,0x04000108L,0x04100108L, | ||
226 | 0x04001000L,0x04101000L,0x04001100L,0x04101100L, | ||
227 | 0x04001008L,0x04101008L,0x04001108L,0x04101108L, | ||
228 | 0x00020000L,0x00120000L,0x00020100L,0x00120100L, | ||
229 | 0x00020008L,0x00120008L,0x00020108L,0x00120108L, | ||
230 | 0x00021000L,0x00121000L,0x00021100L,0x00121100L, | ||
231 | 0x00021008L,0x00121008L,0x00021108L,0x00121108L, | ||
232 | 0x04020000L,0x04120000L,0x04020100L,0x04120100L, | ||
233 | 0x04020008L,0x04120008L,0x04020108L,0x04120108L, | ||
234 | 0x04021000L,0x04121000L,0x04021100L,0x04121100L, | ||
235 | 0x04021008L,0x04121008L,0x04021108L,0x04121108L, | ||
236 | },{ | ||
237 | /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ | ||
238 | 0x00000000L,0x10000000L,0x00010000L,0x10010000L, | ||
239 | 0x00000004L,0x10000004L,0x00010004L,0x10010004L, | ||
240 | 0x20000000L,0x30000000L,0x20010000L,0x30010000L, | ||
241 | 0x20000004L,0x30000004L,0x20010004L,0x30010004L, | ||
242 | 0x00100000L,0x10100000L,0x00110000L,0x10110000L, | ||
243 | 0x00100004L,0x10100004L,0x00110004L,0x10110004L, | ||
244 | 0x20100000L,0x30100000L,0x20110000L,0x30110000L, | ||
245 | 0x20100004L,0x30100004L,0x20110004L,0x30110004L, | ||
246 | 0x00001000L,0x10001000L,0x00011000L,0x10011000L, | ||
247 | 0x00001004L,0x10001004L,0x00011004L,0x10011004L, | ||
248 | 0x20001000L,0x30001000L,0x20011000L,0x30011000L, | ||
249 | 0x20001004L,0x30001004L,0x20011004L,0x30011004L, | ||
250 | 0x00101000L,0x10101000L,0x00111000L,0x10111000L, | ||
251 | 0x00101004L,0x10101004L,0x00111004L,0x10111004L, | ||
252 | 0x20101000L,0x30101000L,0x20111000L,0x30111000L, | ||
253 | 0x20101004L,0x30101004L,0x20111004L,0x30111004L, | ||
254 | },{ | ||
255 | /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ | ||
256 | 0x00000000L,0x08000000L,0x00000008L,0x08000008L, | ||
257 | 0x00000400L,0x08000400L,0x00000408L,0x08000408L, | ||
258 | 0x00020000L,0x08020000L,0x00020008L,0x08020008L, | ||
259 | 0x00020400L,0x08020400L,0x00020408L,0x08020408L, | ||
260 | 0x00000001L,0x08000001L,0x00000009L,0x08000009L, | ||
261 | 0x00000401L,0x08000401L,0x00000409L,0x08000409L, | ||
262 | 0x00020001L,0x08020001L,0x00020009L,0x08020009L, | ||
263 | 0x00020401L,0x08020401L,0x00020409L,0x08020409L, | ||
264 | 0x02000000L,0x0A000000L,0x02000008L,0x0A000008L, | ||
265 | 0x02000400L,0x0A000400L,0x02000408L,0x0A000408L, | ||
266 | 0x02020000L,0x0A020000L,0x02020008L,0x0A020008L, | ||
267 | 0x02020400L,0x0A020400L,0x02020408L,0x0A020408L, | ||
268 | 0x02000001L,0x0A000001L,0x02000009L,0x0A000009L, | ||
269 | 0x02000401L,0x0A000401L,0x02000409L,0x0A000409L, | ||
270 | 0x02020001L,0x0A020001L,0x02020009L,0x0A020009L, | ||
271 | 0x02020401L,0x0A020401L,0x02020409L,0x0A020409L, | ||
272 | },{ | ||
273 | /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ | ||
274 | 0x00000000L,0x00000100L,0x00080000L,0x00080100L, | ||
275 | 0x01000000L,0x01000100L,0x01080000L,0x01080100L, | ||
276 | 0x00000010L,0x00000110L,0x00080010L,0x00080110L, | ||
277 | 0x01000010L,0x01000110L,0x01080010L,0x01080110L, | ||
278 | 0x00200000L,0x00200100L,0x00280000L,0x00280100L, | ||
279 | 0x01200000L,0x01200100L,0x01280000L,0x01280100L, | ||
280 | 0x00200010L,0x00200110L,0x00280010L,0x00280110L, | ||
281 | 0x01200010L,0x01200110L,0x01280010L,0x01280110L, | ||
282 | 0x00000200L,0x00000300L,0x00080200L,0x00080300L, | ||
283 | 0x01000200L,0x01000300L,0x01080200L,0x01080300L, | ||
284 | 0x00000210L,0x00000310L,0x00080210L,0x00080310L, | ||
285 | 0x01000210L,0x01000310L,0x01080210L,0x01080310L, | ||
286 | 0x00200200L,0x00200300L,0x00280200L,0x00280300L, | ||
287 | 0x01200200L,0x01200300L,0x01280200L,0x01280300L, | ||
288 | 0x00200210L,0x00200310L,0x00280210L,0x00280310L, | ||
289 | 0x01200210L,0x01200310L,0x01280210L,0x01280310L, | ||
290 | },{ | ||
291 | /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ | ||
292 | 0x00000000L,0x04000000L,0x00040000L,0x04040000L, | ||
293 | 0x00000002L,0x04000002L,0x00040002L,0x04040002L, | ||
294 | 0x00002000L,0x04002000L,0x00042000L,0x04042000L, | ||
295 | 0x00002002L,0x04002002L,0x00042002L,0x04042002L, | ||
296 | 0x00000020L,0x04000020L,0x00040020L,0x04040020L, | ||
297 | 0x00000022L,0x04000022L,0x00040022L,0x04040022L, | ||
298 | 0x00002020L,0x04002020L,0x00042020L,0x04042020L, | ||
299 | 0x00002022L,0x04002022L,0x00042022L,0x04042022L, | ||
300 | 0x00000800L,0x04000800L,0x00040800L,0x04040800L, | ||
301 | 0x00000802L,0x04000802L,0x00040802L,0x04040802L, | ||
302 | 0x00002800L,0x04002800L,0x00042800L,0x04042800L, | ||
303 | 0x00002802L,0x04002802L,0x00042802L,0x04042802L, | ||
304 | 0x00000820L,0x04000820L,0x00040820L,0x04040820L, | ||
305 | 0x00000822L,0x04000822L,0x00040822L,0x04040822L, | ||
306 | 0x00002820L,0x04002820L,0x00042820L,0x04042820L, | ||
307 | 0x00002822L,0x04002822L,0x00042822L,0x04042822L, | ||
308 | }}; | ||
309 | |||
310 | int des_set_key(const_des_cblock *key, des_key_schedule schedule) | ||
311 | { | ||
312 | if (des_check_key) | ||
313 | { | ||
314 | return des_set_key_checked(key, schedule); | ||
315 | } | ||
316 | else | ||
317 | { | ||
318 | des_set_key_unchecked(key, schedule); | ||
319 | return 0; | ||
320 | } | ||
321 | } | ||
322 | |||
323 | /* return 0 if key parity is odd (correct), | ||
324 | * return -1 if key parity error, | ||
325 | * return -2 if illegal weak key. | ||
326 | */ | ||
327 | int des_set_key_checked(const_des_cblock *key, des_key_schedule schedule) | ||
328 | { | ||
329 | if (!des_check_key_parity(key)) | ||
330 | return(-1); | ||
331 | if (des_is_weak_key(key)) | ||
332 | return(-2); | ||
333 | des_set_key_unchecked(key, schedule); | ||
334 | return 0; | ||
335 | } | ||
336 | |||
337 | void des_set_key_unchecked(const_des_cblock *key, des_key_schedule schedule) | ||
338 | { | ||
339 | static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; | ||
340 | register DES_LONG c,d,t,s,t2; | ||
341 | register const unsigned char *in; | ||
342 | register DES_LONG *k; | ||
343 | register int i; | ||
344 | |||
345 | k = &schedule->ks.deslong[0]; | ||
346 | in = &(*key)[0]; | ||
347 | |||
348 | c2l(in,c); | ||
349 | c2l(in,d); | ||
350 | |||
351 | /* do PC1 in 47 simple operations :-) | ||
352 | * Thanks to John Fletcher (john_fletcher@lccmail.ocf.llnl.gov) | ||
353 | * for the inspiration. :-) */ | ||
354 | PERM_OP (d,c,t,4,0x0f0f0f0fL); | ||
355 | HPERM_OP(c,t,-2,0xcccc0000L); | ||
356 | HPERM_OP(d,t,-2,0xcccc0000L); | ||
357 | PERM_OP (d,c,t,1,0x55555555L); | ||
358 | PERM_OP (c,d,t,8,0x00ff00ffL); | ||
359 | PERM_OP (d,c,t,1,0x55555555L); | ||
360 | d= (((d&0x000000ffL)<<16L)| (d&0x0000ff00L) | | ||
361 | ((d&0x00ff0000L)>>16L)|((c&0xf0000000L)>>4L)); | ||
362 | c&=0x0fffffffL; | ||
363 | |||
364 | for (i=0; i<ITERATIONS; i++) | ||
365 | { | ||
366 | if (shifts2[i]) | ||
367 | { c=((c>>2L)|(c<<26L)); d=((d>>2L)|(d<<26L)); } | ||
368 | else | ||
369 | { c=((c>>1L)|(c<<27L)); d=((d>>1L)|(d<<27L)); } | ||
370 | c&=0x0fffffffL; | ||
371 | d&=0x0fffffffL; | ||
372 | /* could be a few less shifts but I am to lazy at this | ||
373 | * point in time to investigate */ | ||
374 | s= des_skb[0][ (c )&0x3f ]| | ||
375 | des_skb[1][((c>> 6L)&0x03)|((c>> 7L)&0x3c)]| | ||
376 | des_skb[2][((c>>13L)&0x0f)|((c>>14L)&0x30)]| | ||
377 | des_skb[3][((c>>20L)&0x01)|((c>>21L)&0x06) | | ||
378 | ((c>>22L)&0x38)]; | ||
379 | t= des_skb[4][ (d )&0x3f ]| | ||
380 | des_skb[5][((d>> 7L)&0x03)|((d>> 8L)&0x3c)]| | ||
381 | des_skb[6][ (d>>15L)&0x3f ]| | ||
382 | des_skb[7][((d>>21L)&0x0f)|((d>>22L)&0x30)]; | ||
383 | |||
384 | /* table contained 0213 4657 */ | ||
385 | t2=((t<<16L)|(s&0x0000ffffL))&0xffffffffL; | ||
386 | *(k++)=ROTATE(t2,30)&0xffffffffL; | ||
387 | |||
388 | t2=((s>>16L)|(t&0xffff0000L)); | ||
389 | *(k++)=ROTATE(t2,26)&0xffffffffL; | ||
390 | } | ||
391 | } | ||
392 | |||
393 | int des_key_sched(const_des_cblock *key, des_key_schedule schedule) | ||
394 | { | ||
395 | return(des_set_key(key,schedule)); | ||
396 | } | ||
397 | |||
398 | #undef des_fixup_key_parity | ||
399 | void des_fixup_key_parity(des_cblock *key) | ||
400 | { | ||
401 | des_set_odd_parity(key); | ||
402 | } | ||
diff --git a/src/lib/libcrypto/des/spr.h b/src/lib/libcrypto/des/spr.h deleted file mode 100644 index b8fbdcf8d3..0000000000 --- a/src/lib/libcrypto/des/spr.h +++ /dev/null | |||
@@ -1,204 +0,0 @@ | |||
1 | /* crypto/des/spr.h */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | OPENSSL_GLOBAL const DES_LONG des_SPtrans[8][64]={ | ||
60 | { | ||
61 | /* nibble 0 */ | ||
62 | 0x02080800L, 0x00080000L, 0x02000002L, 0x02080802L, | ||
63 | 0x02000000L, 0x00080802L, 0x00080002L, 0x02000002L, | ||
64 | 0x00080802L, 0x02080800L, 0x02080000L, 0x00000802L, | ||
65 | 0x02000802L, 0x02000000L, 0x00000000L, 0x00080002L, | ||
66 | 0x00080000L, 0x00000002L, 0x02000800L, 0x00080800L, | ||
67 | 0x02080802L, 0x02080000L, 0x00000802L, 0x02000800L, | ||
68 | 0x00000002L, 0x00000800L, 0x00080800L, 0x02080002L, | ||
69 | 0x00000800L, 0x02000802L, 0x02080002L, 0x00000000L, | ||
70 | 0x00000000L, 0x02080802L, 0x02000800L, 0x00080002L, | ||
71 | 0x02080800L, 0x00080000L, 0x00000802L, 0x02000800L, | ||
72 | 0x02080002L, 0x00000800L, 0x00080800L, 0x02000002L, | ||
73 | 0x00080802L, 0x00000002L, 0x02000002L, 0x02080000L, | ||
74 | 0x02080802L, 0x00080800L, 0x02080000L, 0x02000802L, | ||
75 | 0x02000000L, 0x00000802L, 0x00080002L, 0x00000000L, | ||
76 | 0x00080000L, 0x02000000L, 0x02000802L, 0x02080800L, | ||
77 | 0x00000002L, 0x02080002L, 0x00000800L, 0x00080802L, | ||
78 | },{ | ||
79 | /* nibble 1 */ | ||
80 | 0x40108010L, 0x00000000L, 0x00108000L, 0x40100000L, | ||
81 | 0x40000010L, 0x00008010L, 0x40008000L, 0x00108000L, | ||
82 | 0x00008000L, 0x40100010L, 0x00000010L, 0x40008000L, | ||
83 | 0x00100010L, 0x40108000L, 0x40100000L, 0x00000010L, | ||
84 | 0x00100000L, 0x40008010L, 0x40100010L, 0x00008000L, | ||
85 | 0x00108010L, 0x40000000L, 0x00000000L, 0x00100010L, | ||
86 | 0x40008010L, 0x00108010L, 0x40108000L, 0x40000010L, | ||
87 | 0x40000000L, 0x00100000L, 0x00008010L, 0x40108010L, | ||
88 | 0x00100010L, 0x40108000L, 0x40008000L, 0x00108010L, | ||
89 | 0x40108010L, 0x00100010L, 0x40000010L, 0x00000000L, | ||
90 | 0x40000000L, 0x00008010L, 0x00100000L, 0x40100010L, | ||
91 | 0x00008000L, 0x40000000L, 0x00108010L, 0x40008010L, | ||
92 | 0x40108000L, 0x00008000L, 0x00000000L, 0x40000010L, | ||
93 | 0x00000010L, 0x40108010L, 0x00108000L, 0x40100000L, | ||
94 | 0x40100010L, 0x00100000L, 0x00008010L, 0x40008000L, | ||
95 | 0x40008010L, 0x00000010L, 0x40100000L, 0x00108000L, | ||
96 | },{ | ||
97 | /* nibble 2 */ | ||
98 | 0x04000001L, 0x04040100L, 0x00000100L, 0x04000101L, | ||
99 | 0x00040001L, 0x04000000L, 0x04000101L, 0x00040100L, | ||
100 | 0x04000100L, 0x00040000L, 0x04040000L, 0x00000001L, | ||
101 | 0x04040101L, 0x00000101L, 0x00000001L, 0x04040001L, | ||
102 | 0x00000000L, 0x00040001L, 0x04040100L, 0x00000100L, | ||
103 | 0x00000101L, 0x04040101L, 0x00040000L, 0x04000001L, | ||
104 | 0x04040001L, 0x04000100L, 0x00040101L, 0x04040000L, | ||
105 | 0x00040100L, 0x00000000L, 0x04000000L, 0x00040101L, | ||
106 | 0x04040100L, 0x00000100L, 0x00000001L, 0x00040000L, | ||
107 | 0x00000101L, 0x00040001L, 0x04040000L, 0x04000101L, | ||
108 | 0x00000000L, 0x04040100L, 0x00040100L, 0x04040001L, | ||
109 | 0x00040001L, 0x04000000L, 0x04040101L, 0x00000001L, | ||
110 | 0x00040101L, 0x04000001L, 0x04000000L, 0x04040101L, | ||
111 | 0x00040000L, 0x04000100L, 0x04000101L, 0x00040100L, | ||
112 | 0x04000100L, 0x00000000L, 0x04040001L, 0x00000101L, | ||
113 | 0x04000001L, 0x00040101L, 0x00000100L, 0x04040000L, | ||
114 | },{ | ||
115 | /* nibble 3 */ | ||
116 | 0x00401008L, 0x10001000L, 0x00000008L, 0x10401008L, | ||
117 | 0x00000000L, 0x10400000L, 0x10001008L, 0x00400008L, | ||
118 | 0x10401000L, 0x10000008L, 0x10000000L, 0x00001008L, | ||
119 | 0x10000008L, 0x00401008L, 0x00400000L, 0x10000000L, | ||
120 | 0x10400008L, 0x00401000L, 0x00001000L, 0x00000008L, | ||
121 | 0x00401000L, 0x10001008L, 0x10400000L, 0x00001000L, | ||
122 | 0x00001008L, 0x00000000L, 0x00400008L, 0x10401000L, | ||
123 | 0x10001000L, 0x10400008L, 0x10401008L, 0x00400000L, | ||
124 | 0x10400008L, 0x00001008L, 0x00400000L, 0x10000008L, | ||
125 | 0x00401000L, 0x10001000L, 0x00000008L, 0x10400000L, | ||
126 | 0x10001008L, 0x00000000L, 0x00001000L, 0x00400008L, | ||
127 | 0x00000000L, 0x10400008L, 0x10401000L, 0x00001000L, | ||
128 | 0x10000000L, 0x10401008L, 0x00401008L, 0x00400000L, | ||
129 | 0x10401008L, 0x00000008L, 0x10001000L, 0x00401008L, | ||
130 | 0x00400008L, 0x00401000L, 0x10400000L, 0x10001008L, | ||
131 | 0x00001008L, 0x10000000L, 0x10000008L, 0x10401000L, | ||
132 | },{ | ||
133 | /* nibble 4 */ | ||
134 | 0x08000000L, 0x00010000L, 0x00000400L, 0x08010420L, | ||
135 | 0x08010020L, 0x08000400L, 0x00010420L, 0x08010000L, | ||
136 | 0x00010000L, 0x00000020L, 0x08000020L, 0x00010400L, | ||
137 | 0x08000420L, 0x08010020L, 0x08010400L, 0x00000000L, | ||
138 | 0x00010400L, 0x08000000L, 0x00010020L, 0x00000420L, | ||
139 | 0x08000400L, 0x00010420L, 0x00000000L, 0x08000020L, | ||
140 | 0x00000020L, 0x08000420L, 0x08010420L, 0x00010020L, | ||
141 | 0x08010000L, 0x00000400L, 0x00000420L, 0x08010400L, | ||
142 | 0x08010400L, 0x08000420L, 0x00010020L, 0x08010000L, | ||
143 | 0x00010000L, 0x00000020L, 0x08000020L, 0x08000400L, | ||
144 | 0x08000000L, 0x00010400L, 0x08010420L, 0x00000000L, | ||
145 | 0x00010420L, 0x08000000L, 0x00000400L, 0x00010020L, | ||
146 | 0x08000420L, 0x00000400L, 0x00000000L, 0x08010420L, | ||
147 | 0x08010020L, 0x08010400L, 0x00000420L, 0x00010000L, | ||
148 | 0x00010400L, 0x08010020L, 0x08000400L, 0x00000420L, | ||
149 | 0x00000020L, 0x00010420L, 0x08010000L, 0x08000020L, | ||
150 | },{ | ||
151 | /* nibble 5 */ | ||
152 | 0x80000040L, 0x00200040L, 0x00000000L, 0x80202000L, | ||
153 | 0x00200040L, 0x00002000L, 0x80002040L, 0x00200000L, | ||
154 | 0x00002040L, 0x80202040L, 0x00202000L, 0x80000000L, | ||
155 | 0x80002000L, 0x80000040L, 0x80200000L, 0x00202040L, | ||
156 | 0x00200000L, 0x80002040L, 0x80200040L, 0x00000000L, | ||
157 | 0x00002000L, 0x00000040L, 0x80202000L, 0x80200040L, | ||
158 | 0x80202040L, 0x80200000L, 0x80000000L, 0x00002040L, | ||
159 | 0x00000040L, 0x00202000L, 0x00202040L, 0x80002000L, | ||
160 | 0x00002040L, 0x80000000L, 0x80002000L, 0x00202040L, | ||
161 | 0x80202000L, 0x00200040L, 0x00000000L, 0x80002000L, | ||
162 | 0x80000000L, 0x00002000L, 0x80200040L, 0x00200000L, | ||
163 | 0x00200040L, 0x80202040L, 0x00202000L, 0x00000040L, | ||
164 | 0x80202040L, 0x00202000L, 0x00200000L, 0x80002040L, | ||
165 | 0x80000040L, 0x80200000L, 0x00202040L, 0x00000000L, | ||
166 | 0x00002000L, 0x80000040L, 0x80002040L, 0x80202000L, | ||
167 | 0x80200000L, 0x00002040L, 0x00000040L, 0x80200040L, | ||
168 | },{ | ||
169 | /* nibble 6 */ | ||
170 | 0x00004000L, 0x00000200L, 0x01000200L, 0x01000004L, | ||
171 | 0x01004204L, 0x00004004L, 0x00004200L, 0x00000000L, | ||
172 | 0x01000000L, 0x01000204L, 0x00000204L, 0x01004000L, | ||
173 | 0x00000004L, 0x01004200L, 0x01004000L, 0x00000204L, | ||
174 | 0x01000204L, 0x00004000L, 0x00004004L, 0x01004204L, | ||
175 | 0x00000000L, 0x01000200L, 0x01000004L, 0x00004200L, | ||
176 | 0x01004004L, 0x00004204L, 0x01004200L, 0x00000004L, | ||
177 | 0x00004204L, 0x01004004L, 0x00000200L, 0x01000000L, | ||
178 | 0x00004204L, 0x01004000L, 0x01004004L, 0x00000204L, | ||
179 | 0x00004000L, 0x00000200L, 0x01000000L, 0x01004004L, | ||
180 | 0x01000204L, 0x00004204L, 0x00004200L, 0x00000000L, | ||
181 | 0x00000200L, 0x01000004L, 0x00000004L, 0x01000200L, | ||
182 | 0x00000000L, 0x01000204L, 0x01000200L, 0x00004200L, | ||
183 | 0x00000204L, 0x00004000L, 0x01004204L, 0x01000000L, | ||
184 | 0x01004200L, 0x00000004L, 0x00004004L, 0x01004204L, | ||
185 | 0x01000004L, 0x01004200L, 0x01004000L, 0x00004004L, | ||
186 | },{ | ||
187 | /* nibble 7 */ | ||
188 | 0x20800080L, 0x20820000L, 0x00020080L, 0x00000000L, | ||
189 | 0x20020000L, 0x00800080L, 0x20800000L, 0x20820080L, | ||
190 | 0x00000080L, 0x20000000L, 0x00820000L, 0x00020080L, | ||
191 | 0x00820080L, 0x20020080L, 0x20000080L, 0x20800000L, | ||
192 | 0x00020000L, 0x00820080L, 0x00800080L, 0x20020000L, | ||
193 | 0x20820080L, 0x20000080L, 0x00000000L, 0x00820000L, | ||
194 | 0x20000000L, 0x00800000L, 0x20020080L, 0x20800080L, | ||
195 | 0x00800000L, 0x00020000L, 0x20820000L, 0x00000080L, | ||
196 | 0x00800000L, 0x00020000L, 0x20000080L, 0x20820080L, | ||
197 | 0x00020080L, 0x20000000L, 0x00000000L, 0x00820000L, | ||
198 | 0x20800080L, 0x20020080L, 0x20020000L, 0x00800080L, | ||
199 | 0x20820000L, 0x00000080L, 0x00800080L, 0x20020000L, | ||
200 | 0x20820080L, 0x00800000L, 0x20800000L, 0x20000080L, | ||
201 | 0x00820000L, 0x00020080L, 0x20020080L, 0x20800000L, | ||
202 | 0x00000080L, 0x20820000L, 0x00820080L, 0x00000000L, | ||
203 | 0x20000000L, 0x20800080L, 0x00020000L, 0x00820080L, | ||
204 | }}; | ||
diff --git a/src/lib/libcrypto/des/str2key.c b/src/lib/libcrypto/des/str2key.c deleted file mode 100644 index c6abb87201..0000000000 --- a/src/lib/libcrypto/des/str2key.c +++ /dev/null | |||
@@ -1,155 +0,0 @@ | |||
1 | /* crypto/des/str2key.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include "des_locl.h" | ||
60 | |||
61 | void des_string_to_key(const char *str, des_cblock *key) | ||
62 | { | ||
63 | des_key_schedule ks; | ||
64 | int i,length; | ||
65 | register unsigned char j; | ||
66 | |||
67 | memset(key,0,8); | ||
68 | length=strlen(str); | ||
69 | #ifdef OLD_STR_TO_KEY | ||
70 | for (i=0; i<length; i++) | ||
71 | (*key)[i%8]^=(str[i]<<1); | ||
72 | #else /* MIT COMPATIBLE */ | ||
73 | for (i=0; i<length; i++) | ||
74 | { | ||
75 | j=str[i]; | ||
76 | if ((i%16) < 8) | ||
77 | (*key)[i%8]^=(j<<1); | ||
78 | else | ||
79 | { | ||
80 | /* Reverse the bit order 05/05/92 eay */ | ||
81 | j=((j<<4)&0xf0)|((j>>4)&0x0f); | ||
82 | j=((j<<2)&0xcc)|((j>>2)&0x33); | ||
83 | j=((j<<1)&0xaa)|((j>>1)&0x55); | ||
84 | (*key)[7-(i%8)]^=j; | ||
85 | } | ||
86 | } | ||
87 | #endif | ||
88 | des_set_odd_parity(key); | ||
89 | des_set_key_unchecked(key,ks); | ||
90 | des_cbc_cksum((const unsigned char*)str,key,length,ks,key); | ||
91 | memset(ks,0,sizeof(ks)); | ||
92 | des_set_odd_parity(key); | ||
93 | } | ||
94 | |||
95 | void des_string_to_2keys(const char *str, des_cblock *key1, des_cblock *key2) | ||
96 | { | ||
97 | des_key_schedule ks; | ||
98 | int i,length; | ||
99 | register unsigned char j; | ||
100 | |||
101 | memset(key1,0,8); | ||
102 | memset(key2,0,8); | ||
103 | length=strlen(str); | ||
104 | #ifdef OLD_STR_TO_KEY | ||
105 | if (length <= 8) | ||
106 | { | ||
107 | for (i=0; i<length; i++) | ||
108 | { | ||
109 | (*key2)[i]=(*key1)[i]=(str[i]<<1); | ||
110 | } | ||
111 | } | ||
112 | else | ||
113 | { | ||
114 | for (i=0; i<length; i++) | ||
115 | { | ||
116 | if ((i/8)&1) | ||
117 | (*key2)[i%8]^=(str[i]<<1); | ||
118 | else | ||
119 | (*key1)[i%8]^=(str[i]<<1); | ||
120 | } | ||
121 | } | ||
122 | #else /* MIT COMPATIBLE */ | ||
123 | for (i=0; i<length; i++) | ||
124 | { | ||
125 | j=str[i]; | ||
126 | if ((i%32) < 16) | ||
127 | { | ||
128 | if ((i%16) < 8) | ||
129 | (*key1)[i%8]^=(j<<1); | ||
130 | else | ||
131 | (*key2)[i%8]^=(j<<1); | ||
132 | } | ||
133 | else | ||
134 | { | ||
135 | j=((j<<4)&0xf0)|((j>>4)&0x0f); | ||
136 | j=((j<<2)&0xcc)|((j>>2)&0x33); | ||
137 | j=((j<<1)&0xaa)|((j>>1)&0x55); | ||
138 | if ((i%16) < 8) | ||
139 | (*key1)[7-(i%8)]^=j; | ||
140 | else | ||
141 | (*key2)[7-(i%8)]^=j; | ||
142 | } | ||
143 | } | ||
144 | if (length <= 8) memcpy(key2,key1,8); | ||
145 | #endif | ||
146 | des_set_odd_parity(key1); | ||
147 | des_set_odd_parity(key2); | ||
148 | des_set_key_unchecked(key1,ks); | ||
149 | des_cbc_cksum((const unsigned char*)str,key1,length,ks,key1); | ||
150 | des_set_key_unchecked(key2,ks); | ||
151 | des_cbc_cksum((const unsigned char*)str,key2,length,ks,key2); | ||
152 | memset(ks,0,sizeof(ks)); | ||
153 | des_set_odd_parity(key1); | ||
154 | des_set_odd_parity(key2); | ||
155 | } | ||
diff --git a/src/lib/libcrypto/des/xcbc_enc.c b/src/lib/libcrypto/des/xcbc_enc.c deleted file mode 100644 index ccfede13ac..0000000000 --- a/src/lib/libcrypto/des/xcbc_enc.c +++ /dev/null | |||
@@ -1,194 +0,0 @@ | |||
1 | /* crypto/des/xcbc_enc.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include "des_locl.h" | ||
60 | |||
61 | /* RSA's DESX */ | ||
62 | |||
63 | static unsigned char desx_white_in2out[256]={ | ||
64 | 0xBD,0x56,0xEA,0xF2,0xA2,0xF1,0xAC,0x2A,0xB0,0x93,0xD1,0x9C,0x1B,0x33,0xFD,0xD0, | ||
65 | 0x30,0x04,0xB6,0xDC,0x7D,0xDF,0x32,0x4B,0xF7,0xCB,0x45,0x9B,0x31,0xBB,0x21,0x5A, | ||
66 | 0x41,0x9F,0xE1,0xD9,0x4A,0x4D,0x9E,0xDA,0xA0,0x68,0x2C,0xC3,0x27,0x5F,0x80,0x36, | ||
67 | 0x3E,0xEE,0xFB,0x95,0x1A,0xFE,0xCE,0xA8,0x34,0xA9,0x13,0xF0,0xA6,0x3F,0xD8,0x0C, | ||
68 | 0x78,0x24,0xAF,0x23,0x52,0xC1,0x67,0x17,0xF5,0x66,0x90,0xE7,0xE8,0x07,0xB8,0x60, | ||
69 | 0x48,0xE6,0x1E,0x53,0xF3,0x92,0xA4,0x72,0x8C,0x08,0x15,0x6E,0x86,0x00,0x84,0xFA, | ||
70 | 0xF4,0x7F,0x8A,0x42,0x19,0xF6,0xDB,0xCD,0x14,0x8D,0x50,0x12,0xBA,0x3C,0x06,0x4E, | ||
71 | 0xEC,0xB3,0x35,0x11,0xA1,0x88,0x8E,0x2B,0x94,0x99,0xB7,0x71,0x74,0xD3,0xE4,0xBF, | ||
72 | 0x3A,0xDE,0x96,0x0E,0xBC,0x0A,0xED,0x77,0xFC,0x37,0x6B,0x03,0x79,0x89,0x62,0xC6, | ||
73 | 0xD7,0xC0,0xD2,0x7C,0x6A,0x8B,0x22,0xA3,0x5B,0x05,0x5D,0x02,0x75,0xD5,0x61,0xE3, | ||
74 | 0x18,0x8F,0x55,0x51,0xAD,0x1F,0x0B,0x5E,0x85,0xE5,0xC2,0x57,0x63,0xCA,0x3D,0x6C, | ||
75 | 0xB4,0xC5,0xCC,0x70,0xB2,0x91,0x59,0x0D,0x47,0x20,0xC8,0x4F,0x58,0xE0,0x01,0xE2, | ||
76 | 0x16,0x38,0xC4,0x6F,0x3B,0x0F,0x65,0x46,0xBE,0x7E,0x2D,0x7B,0x82,0xF9,0x40,0xB5, | ||
77 | 0x1D,0x73,0xF8,0xEB,0x26,0xC7,0x87,0x97,0x25,0x54,0xB1,0x28,0xAA,0x98,0x9D,0xA5, | ||
78 | 0x64,0x6D,0x7A,0xD4,0x10,0x81,0x44,0xEF,0x49,0xD6,0xAE,0x2E,0xDD,0x76,0x5C,0x2F, | ||
79 | 0xA7,0x1C,0xC9,0x09,0x69,0x9A,0x83,0xCF,0x29,0x39,0xB9,0xE9,0x4C,0xFF,0x43,0xAB, | ||
80 | }; | ||
81 | |||
82 | void des_xwhite_in2out(const_des_cblock *des_key, const_des_cblock *in_white, | ||
83 | des_cblock *out_white) | ||
84 | { | ||
85 | int out0,out1; | ||
86 | int i; | ||
87 | const unsigned char *key = &(*des_key)[0]; | ||
88 | const unsigned char *in = &(*in_white)[0]; | ||
89 | unsigned char *out = &(*out_white)[0]; | ||
90 | |||
91 | out[0]=out[1]=out[2]=out[3]=out[4]=out[5]=out[6]=out[7]=0; | ||
92 | out0=out1=0; | ||
93 | for (i=0; i<8; i++) | ||
94 | { | ||
95 | out[i]=key[i]^desx_white_in2out[out0^out1]; | ||
96 | out0=out1; | ||
97 | out1=(int)out[i&0x07]; | ||
98 | } | ||
99 | |||
100 | out0=out[0]; | ||
101 | out1=out[i]; | ||
102 | for (i=0; i<8; i++) | ||
103 | { | ||
104 | out[i]=in[i]^desx_white_in2out[out0^out1]; | ||
105 | out0=out1; | ||
106 | out1=(int)out[i&0x07]; | ||
107 | } | ||
108 | } | ||
109 | |||
110 | void des_xcbc_encrypt(const unsigned char *in, unsigned char *out, | ||
111 | long length, des_key_schedule schedule, des_cblock *ivec, | ||
112 | const_des_cblock *inw, const_des_cblock *outw, int enc) | ||
113 | { | ||
114 | register DES_LONG tin0,tin1; | ||
115 | register DES_LONG tout0,tout1,xor0,xor1; | ||
116 | register DES_LONG inW0,inW1,outW0,outW1; | ||
117 | register const unsigned char *in2; | ||
118 | register long l=length; | ||
119 | DES_LONG tin[2]; | ||
120 | unsigned char *iv; | ||
121 | |||
122 | in2 = &(*inw)[0]; | ||
123 | c2l(in2,inW0); | ||
124 | c2l(in2,inW1); | ||
125 | in2 = &(*outw)[0]; | ||
126 | c2l(in2,outW0); | ||
127 | c2l(in2,outW1); | ||
128 | |||
129 | iv = &(*ivec)[0]; | ||
130 | |||
131 | if (enc) | ||
132 | { | ||
133 | c2l(iv,tout0); | ||
134 | c2l(iv,tout1); | ||
135 | for (l-=8; l>=0; l-=8) | ||
136 | { | ||
137 | c2l(in,tin0); | ||
138 | c2l(in,tin1); | ||
139 | tin0^=tout0^inW0; tin[0]=tin0; | ||
140 | tin1^=tout1^inW1; tin[1]=tin1; | ||
141 | des_encrypt1(tin,schedule,DES_ENCRYPT); | ||
142 | tout0=tin[0]^outW0; l2c(tout0,out); | ||
143 | tout1=tin[1]^outW1; l2c(tout1,out); | ||
144 | } | ||
145 | if (l != -8) | ||
146 | { | ||
147 | c2ln(in,tin0,tin1,l+8); | ||
148 | tin0^=tout0^inW0; tin[0]=tin0; | ||
149 | tin1^=tout1^inW1; tin[1]=tin1; | ||
150 | des_encrypt1(tin,schedule,DES_ENCRYPT); | ||
151 | tout0=tin[0]^outW0; l2c(tout0,out); | ||
152 | tout1=tin[1]^outW1; l2c(tout1,out); | ||
153 | } | ||
154 | iv = &(*ivec)[0]; | ||
155 | l2c(tout0,iv); | ||
156 | l2c(tout1,iv); | ||
157 | } | ||
158 | else | ||
159 | { | ||
160 | c2l(iv,xor0); | ||
161 | c2l(iv,xor1); | ||
162 | for (l-=8; l>0; l-=8) | ||
163 | { | ||
164 | c2l(in,tin0); tin[0]=tin0^outW0; | ||
165 | c2l(in,tin1); tin[1]=tin1^outW1; | ||
166 | des_encrypt1(tin,schedule,DES_DECRYPT); | ||
167 | tout0=tin[0]^xor0^inW0; | ||
168 | tout1=tin[1]^xor1^inW1; | ||
169 | l2c(tout0,out); | ||
170 | l2c(tout1,out); | ||
171 | xor0=tin0; | ||
172 | xor1=tin1; | ||
173 | } | ||
174 | if (l != -8) | ||
175 | { | ||
176 | c2l(in,tin0); tin[0]=tin0^outW0; | ||
177 | c2l(in,tin1); tin[1]=tin1^outW1; | ||
178 | des_encrypt1(tin,schedule,DES_DECRYPT); | ||
179 | tout0=tin[0]^xor0^inW0; | ||
180 | tout1=tin[1]^xor1^inW1; | ||
181 | l2cn(tout0,tout1,out,l+8); | ||
182 | xor0=tin0; | ||
183 | xor1=tin1; | ||
184 | } | ||
185 | |||
186 | iv = &(*ivec)[0]; | ||
187 | l2c(xor0,iv); | ||
188 | l2c(xor1,iv); | ||
189 | } | ||
190 | tin0=tin1=tout0=tout1=xor0=xor1=0; | ||
191 | inW0=inW1=outW0=outW1=0; | ||
192 | tin[0]=tin[1]=0; | ||
193 | } | ||
194 | |||