1 /* crypto/des/des_old.c -*- mode:C; c-file-style: "eay" -*- */
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
16 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
20 * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project
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
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
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
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)
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,
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,
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,
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 int _ossl_old_des_enc_read(int fd, char *buf, int len, des_key_schedule sched,
212 _ossl_old_des_cblock *iv)
214 return DES_enc_read(fd, buf, len, (DES_key_schedule *)sched, iv);
217 int _ossl_old_des_enc_write(int fd, char *buf, int len,
218 des_key_schedule sched, _ossl_old_des_cblock *iv)
220 return DES_enc_write(fd, buf, len, (DES_key_schedule *)sched, iv);
223 char *_ossl_old_des_fcrypt(const char *buf, const char *salt, char *ret)
225 return DES_fcrypt(buf, salt, ret);
228 char *_ossl_old_des_crypt(const char *buf, const char *salt)
230 return DES_crypt(buf, salt);
233 char *_ossl_old_crypt(const char *buf, const char *salt)
235 return DES_crypt(buf, salt);
238 void _ossl_old_des_ofb_encrypt(unsigned char *in, unsigned char *out,
239 int numbits, long length,
240 des_key_schedule schedule,
241 _ossl_old_des_cblock *ivec)
243 DES_ofb_encrypt(in, out, numbits, length, (DES_key_schedule *)schedule,
247 void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,
248 _ossl_old_des_cblock *output, long length,
249 des_key_schedule schedule,
250 _ossl_old_des_cblock *ivec, int enc)
252 DES_pcbc_encrypt((unsigned char *)input, (unsigned char *)output,
253 length, (DES_key_schedule *)schedule, ivec, enc);
256 DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,
257 _ossl_old_des_cblock *output, long length,
258 int out_count, _ossl_old_des_cblock *seed)
260 return DES_quad_cksum((unsigned char *)input, output, length,
264 void _ossl_old_des_random_seed(_ossl_old_des_cblock key)
266 RAND_seed(key, sizeof(_ossl_old_des_cblock));
269 void _ossl_old_des_random_key(_ossl_old_des_cblock ret)
271 DES_random_key((DES_cblock *)ret);
274 int _ossl_old_des_read_password(_ossl_old_des_cblock *key, const char *prompt,
277 return DES_read_password(key, prompt, verify);
280 int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1,
281 _ossl_old_des_cblock *key2,
282 const char *prompt, int verify)
284 return DES_read_2passwords(key1, key2, prompt, verify);
287 void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key)
289 DES_set_odd_parity(key);
292 int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key)
294 return DES_is_weak_key(key);
297 int _ossl_old_des_set_key(_ossl_old_des_cblock *key,
298 des_key_schedule schedule)
300 return DES_set_key(key, (DES_key_schedule *)schedule);
303 int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,
304 des_key_schedule schedule)
306 return DES_key_sched(key, (DES_key_schedule *)schedule);
309 void _ossl_old_des_string_to_key(char *str, _ossl_old_des_cblock *key)
311 DES_string_to_key(str, key);
314 void _ossl_old_des_string_to_2keys(char *str, _ossl_old_des_cblock *key1,
315 _ossl_old_des_cblock *key2)
317 DES_string_to_2keys(str, key1, key2);
320 void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out,
321 long length, des_key_schedule schedule,
322 _ossl_old_des_cblock *ivec, int *num,
325 DES_cfb64_encrypt(in, out, length, (DES_key_schedule *)schedule,
329 void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out,
330 long length, des_key_schedule schedule,
331 _ossl_old_des_cblock *ivec, int *num)
333 DES_ofb64_encrypt(in, out, length, (DES_key_schedule *)schedule,