OpenSSL 1.0.2f
[tomato.git] / release / src / router / openssl / crypto / des / des_old.c
blobc5c5a00f00c101f57068fbf4fed774ec264d682c
1 /* crypto/des/des_old.c */
3 /*-
4 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
6 * The function names in here are deprecated and are only present to
7 * provide an interface compatible with libdes. OpenSSL now provides
8 * functions where "des_" has been replaced with "DES_" in the names,
9 * to make it possible to make incompatible changes that are needed
10 * for C type security and other stuff.
12 * Please consider starting to use the DES_ functions rather than the
13 * des_ ones. The des_ functions will dissapear completely before
14 * OpenSSL 1.0!
16 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
20 * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project
21 * 2001.
23 /* ====================================================================
24 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
26 * Redistribution and use in source and binary forms, with or without
27 * modification, are permitted provided that the following conditions
28 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 * 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
35 * the documentation and/or other materials provided with the
36 * distribution.
38 * 3. All advertising materials mentioning features or use of this
39 * software must display the following acknowledgment:
40 * "This product includes software developed by the OpenSSL Project
41 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
43 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44 * endorse or promote products derived from this software without
45 * prior written permission. For written permission, please contact
46 * openssl-core@openssl.org.
48 * 5. Products derived from this software may not be called "OpenSSL"
49 * nor may "OpenSSL" appear in their names without prior written
50 * permission of the OpenSSL Project.
52 * 6. Redistributions of any form whatsoever must retain the following
53 * acknowledgment:
54 * "This product includes software developed by the OpenSSL Project
55 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
57 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68 * OF THE POSSIBILITY OF SUCH DAMAGE.
69 * ====================================================================
71 * This product includes cryptographic software written by Eric Young
72 * (eay@cryptsoft.com). This product includes software written by Tim
73 * Hudson (tjh@cryptsoft.com).
77 #define OPENSSL_DES_LIBDES_COMPATIBILITY
78 #include <openssl/des.h>
79 #include <openssl/rand.h>
81 const char *_ossl_old_des_options(void)
83 return DES_options();
86 void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,
87 _ossl_old_des_cblock *output,
88 des_key_schedule ks1, des_key_schedule ks2,
89 des_key_schedule ks3, int enc)
91 DES_ecb3_encrypt((const_DES_cblock *)input, output,
92 (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
93 (DES_key_schedule *)ks3, enc);
96 DES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,
97 _ossl_old_des_cblock *output, long length,
98 des_key_schedule schedule,
99 _ossl_old_des_cblock *ivec)
101 return DES_cbc_cksum((unsigned char *)input, output, length,
102 (DES_key_schedule *)schedule, ivec);
105 void _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,
106 _ossl_old_des_cblock *output, long length,
107 des_key_schedule schedule,
108 _ossl_old_des_cblock *ivec, int enc)
110 DES_cbc_encrypt((unsigned char *)input, (unsigned char *)output,
111 length, (DES_key_schedule *)schedule, ivec, enc);
114 void _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,
115 _ossl_old_des_cblock *output, long length,
116 des_key_schedule schedule,
117 _ossl_old_des_cblock *ivec, int enc)
119 DES_ncbc_encrypt((unsigned char *)input, (unsigned char *)output,
120 length, (DES_key_schedule *)schedule, ivec, enc);
123 void _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,
124 _ossl_old_des_cblock *output, long length,
125 des_key_schedule schedule,
126 _ossl_old_des_cblock *ivec,
127 _ossl_old_des_cblock *inw,
128 _ossl_old_des_cblock *outw, int enc)
130 DES_xcbc_encrypt((unsigned char *)input, (unsigned char *)output,
131 length, (DES_key_schedule *)schedule, ivec, inw, outw,
132 enc);
135 void _ossl_old_des_cfb_encrypt(unsigned char *in, unsigned char *out,
136 int numbits, long length,
137 des_key_schedule schedule,
138 _ossl_old_des_cblock *ivec, int enc)
140 DES_cfb_encrypt(in, out, numbits, length,
141 (DES_key_schedule *)schedule, ivec, enc);
144 void _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,
145 _ossl_old_des_cblock *output,
146 des_key_schedule ks, int enc)
148 DES_ecb_encrypt(input, output, (DES_key_schedule *)ks, enc);
151 void _ossl_old_des_encrypt(DES_LONG *data, des_key_schedule ks, int enc)
153 DES_encrypt1(data, (DES_key_schedule *)ks, enc);
156 void _ossl_old_des_encrypt2(DES_LONG *data, des_key_schedule ks, int enc)
158 DES_encrypt2(data, (DES_key_schedule *)ks, enc);
161 void _ossl_old_des_encrypt3(DES_LONG *data, des_key_schedule ks1,
162 des_key_schedule ks2, des_key_schedule ks3)
164 DES_encrypt3(data, (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
165 (DES_key_schedule *)ks3);
168 void _ossl_old_des_decrypt3(DES_LONG *data, des_key_schedule ks1,
169 des_key_schedule ks2, des_key_schedule ks3)
171 DES_decrypt3(data, (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
172 (DES_key_schedule *)ks3);
175 void _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input,
176 _ossl_old_des_cblock *output, long length,
177 des_key_schedule ks1,
178 des_key_schedule ks2,
179 des_key_schedule ks3,
180 _ossl_old_des_cblock *ivec, int enc)
182 DES_ede3_cbc_encrypt((unsigned char *)input, (unsigned char *)output,
183 length, (DES_key_schedule *)ks1,
184 (DES_key_schedule *)ks2, (DES_key_schedule *)ks3,
185 ivec, enc);
188 void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
189 long length, des_key_schedule ks1,
190 des_key_schedule ks2,
191 des_key_schedule ks3,
192 _ossl_old_des_cblock *ivec, int *num,
193 int enc)
195 DES_ede3_cfb64_encrypt(in, out, length,
196 (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
197 (DES_key_schedule *)ks3, ivec, num, enc);
200 void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
201 long length, des_key_schedule ks1,
202 des_key_schedule ks2,
203 des_key_schedule ks3,
204 _ossl_old_des_cblock *ivec, int *num)
206 DES_ede3_ofb64_encrypt(in, out, length,
207 (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
208 (DES_key_schedule *)ks3, ivec, num);
211 #if 0 /* broken code, preserved just in case anyone
212 * specifically looks for this */
213 void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key),
214 _ossl_old_des_cblock (*in_white),
215 _ossl_old_des_cblock (*out_white))
217 DES_xwhite_in2out(des_key, in_white, out_white);
219 #endif
221 int _ossl_old_des_enc_read(int fd, char *buf, int len, des_key_schedule sched,
222 _ossl_old_des_cblock *iv)
224 return DES_enc_read(fd, buf, len, (DES_key_schedule *)sched, iv);
227 int _ossl_old_des_enc_write(int fd, char *buf, int len,
228 des_key_schedule sched, _ossl_old_des_cblock *iv)
230 return DES_enc_write(fd, buf, len, (DES_key_schedule *)sched, iv);
233 char *_ossl_old_des_fcrypt(const char *buf, const char *salt, char *ret)
235 return DES_fcrypt(buf, salt, ret);
238 char *_ossl_old_des_crypt(const char *buf, const char *salt)
240 return DES_crypt(buf, salt);
243 char *_ossl_old_crypt(const char *buf, const char *salt)
245 return DES_crypt(buf, salt);
248 void _ossl_old_des_ofb_encrypt(unsigned char *in, unsigned char *out,
249 int numbits, long length,
250 des_key_schedule schedule,
251 _ossl_old_des_cblock *ivec)
253 DES_ofb_encrypt(in, out, numbits, length, (DES_key_schedule *)schedule,
254 ivec);
257 void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,
258 _ossl_old_des_cblock *output, long length,
259 des_key_schedule schedule,
260 _ossl_old_des_cblock *ivec, int enc)
262 DES_pcbc_encrypt((unsigned char *)input, (unsigned char *)output,
263 length, (DES_key_schedule *)schedule, ivec, enc);
266 DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,
267 _ossl_old_des_cblock *output, long length,
268 int out_count, _ossl_old_des_cblock *seed)
270 return DES_quad_cksum((unsigned char *)input, output, length,
271 out_count, seed);
274 void _ossl_old_des_random_seed(_ossl_old_des_cblock key)
276 RAND_seed(key, sizeof(_ossl_old_des_cblock));
279 void _ossl_old_des_random_key(_ossl_old_des_cblock ret)
281 DES_random_key((DES_cblock *)ret);
284 int _ossl_old_des_read_password(_ossl_old_des_cblock *key, const char *prompt,
285 int verify)
287 return DES_read_password(key, prompt, verify);
290 int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1,
291 _ossl_old_des_cblock *key2,
292 const char *prompt, int verify)
294 return DES_read_2passwords(key1, key2, prompt, verify);
297 void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key)
299 DES_set_odd_parity(key);
302 int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key)
304 return DES_is_weak_key(key);
307 int _ossl_old_des_set_key(_ossl_old_des_cblock *key,
308 des_key_schedule schedule)
310 return DES_set_key(key, (DES_key_schedule *)schedule);
313 int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,
314 des_key_schedule schedule)
316 return DES_key_sched(key, (DES_key_schedule *)schedule);
319 void _ossl_old_des_string_to_key(char *str, _ossl_old_des_cblock *key)
321 DES_string_to_key(str, key);
324 void _ossl_old_des_string_to_2keys(char *str, _ossl_old_des_cblock *key1,
325 _ossl_old_des_cblock *key2)
327 DES_string_to_2keys(str, key1, key2);
330 void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out,
331 long length, des_key_schedule schedule,
332 _ossl_old_des_cblock *ivec, int *num,
333 int enc)
335 DES_cfb64_encrypt(in, out, length, (DES_key_schedule *)schedule,
336 ivec, num, enc);
339 void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out,
340 long length, des_key_schedule schedule,
341 _ossl_old_des_cblock *ivec, int *num)
343 DES_ofb64_encrypt(in, out, length, (DES_key_schedule *)schedule,
344 ivec, num);