1 /* crypto/des/des_old.h -*- mode:C; c-file-style: "eay" -*- */
3 /* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
5 * The function names in here are deprecated and are only present to
6 * provide an interface compatible with libdes. OpenSSL now provides
7 * functions where "des_" has been replaced with "DES_" in the names,
8 * to make it possible to make incompatible changes that are needed
9 * for C type security and other stuff.
11 * Please consider starting to use the DES_ functions rather than the
12 * des_ ones. The des_ functions will dissapear completely before
15 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
18 /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
21 /* ====================================================================
22 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
24 * Redistribution and use in source and binary forms, with or without
25 * modification, are permitted provided that the following conditions
28 * 1. Redistributions of source code must retain the above copyright
29 * notice, this list of conditions and the following disclaimer.
31 * 2. Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in
33 * the documentation and/or other materials provided with the
36 * 3. All advertising materials mentioning features or use of this
37 * software must display the following acknowledgment:
38 * "This product includes software developed by the OpenSSL Project
39 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42 * endorse or promote products derived from this software without
43 * prior written permission. For written permission, please contact
44 * openssl-core@openssl.org.
46 * 5. Products derived from this software may not be called "OpenSSL"
47 * nor may "OpenSSL" appear in their names without prior written
48 * permission of the OpenSSL Project.
50 * 6. Redistributions of any form whatsoever must retain the following
52 * "This product includes software developed by the OpenSSL Project
53 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66 * OF THE POSSIBILITY OF SUCH DAMAGE.
67 * ====================================================================
69 * This product includes cryptographic software written by Eric Young
70 * (eay@cryptsoft.com). This product includes software written by Tim
71 * Hudson (tjh@cryptsoft.com).
75 #ifndef HEADER_DES_OLD_H
76 #define HEADER_DES_OLD_H
79 #error DES is disabled.
82 #ifdef _KERBEROS_DES_H
83 #error <openssl/des_old.h> replaces <kerberos/des.h>.
86 #include <openssl/opensslconf.h> /* DES_LONG */
87 #include <openssl/e_os2.h> /* OPENSSL_EXTERN */
88 #include <openssl/symhacks.h>
90 #ifdef OPENSSL_BUILD_SHLIBCRYPTO
91 # undef OPENSSL_EXTERN
92 # define OPENSSL_EXTERN OPENSSL_EXPORT
99 typedef unsigned char des_cblock[8];
100 typedef struct des_ks_struct
104 /* make sure things are correct size on machines with
108 } des_key_schedule[16];
110 /* Map all function names to _ossl_old_des_* form, so we avoid all
111 clashes with libdes */
112 #define des_ecb3_encrypt(i,o,k1,k2,k3,e)\
113 _ossl_old_des_ecb3_encrypt((i),(o),(k1),(k2),(k3),(e))
114 #define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\
115 _ossl_old_des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(e))
116 #define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\
117 _ossl_old_des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(e))
118 #define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\
119 _ossl_old_des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n))
120 #define des_options()\
121 _ossl_old_des_options()
122 #define des_cbc_cksum(i,o,l,k,iv)\
123 _ossl_old_des_cbc_cksum((i),(o),(l),(k),(iv))
124 #define des_cbc_encrypt(i,o,l,k,iv,e)\
125 _ossl_old_des_cbc_encrypt((i),(o),(l),(k),(iv),(e))
126 #define des_ncbc_encrypt(i,o,l,k,iv,e)\
127 _ossl_old_des_ncbc_encrypt((i),(o),(l),(k),(iv),(e))
128 #define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\
129 _ossl_old_des_xcbc_encrypt((i),(o),(l),(k),(iv),(inw),(outw),(e))
130 #define des_cfb_encrypt(i,o,l,k,iv,e)\
131 _ossl_old_des_cfb_encrypt((i),(o),(l),(k),(iv),(e))
132 #define des_ecb_encrypt(i,o,k,e)\
133 _ossl_old_des_ecb_encrypt((i),(o),(k),(e))
134 #define des_encrypt(d,k,e)\
135 _ossl_old_des_encrypt((d),(k),(e))
136 #define des_encrypt2(d,k,e)\
137 _ossl_old_des_encrypt2((d),(k),(e))
138 #define des_encrypt3(d,k1,k2,k3)\
139 _ossl_old_des_encrypt3((d),(k1),(k2),(k3))
140 #define des_decrypt3(d,k1,k2,k3)\
141 _ossl_old_des_decrypt3((d),(k1),(k2),(k3))
142 #define des_xwhite_in2out(k,i,o)\
143 _ossl_old_des_xwhite_in2out((k),(i),(o))
144 #define des_enc_read(f,b,l,k,iv)\
145 _ossl_old_des_enc_read((f),(b),(l),(k),(iv))
146 #define des_enc_write(f,b,l,k,iv)\
147 _ossl_old_des_enc_write((f),(b),(l),(k),(iv))
148 #define des_fcrypt(b,s,r)\
149 _ossl_old_des_fcrypt((b),(s),(r))
150 #define des_crypt(b,s)\
151 _ossl_old_des_crypt((b),(s))
153 _ossl_old_crypt((b),(s))
154 #define des_ofb_encrypt(i,o,n,l,k,iv)\
155 _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv))
156 #define des_pcbc_encrypt(i,o,l,k,iv,e)\
157 _ossl_old_des_pcbc_encrypt((i),(o),(l),(k),(iv),(e))
158 #define des_quad_cksum(i,o,l,c,s)\
159 _ossl_old_des_quad_cksum((i),(o),(l),(c),(s))
160 #define des_random_seed(k)\
161 _ossl_old_des_random_seed((k))
162 #define des_random_key(r)\
163 _ossl_old_des_random_key((r))
164 #define des_read_password(k,p,v) \
165 _ossl_old_des_read_password((k),(p),(v))
166 #define des_read_2passwords(k1,k2,p,v) \
167 _ossl_old_des_read_2passwords((k1),(k2),(p),(v))
168 #define des_set_odd_parity(k)\
169 _ossl_old_des_set_odd_parity((k))
170 #define des_is_weak_key(k)\
171 _ossl_old_des_is_weak_key((k))
172 #define des_set_key(k,ks)\
173 _ossl_old_des_set_key((k),(ks))
174 #define des_key_sched(k,ks)\
175 _ossl_old_des_key_sched((k),(ks))
176 #define des_string_to_key(s,k)\
177 _ossl_old_des_string_to_key((s),(k))
178 #define des_string_to_2keys(s,k1,k2)\
179 _ossl_old_des_string_to_2keys((s),(k1),(k2))
180 #define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\
181 _ossl_old_des_cfb64_encrypt((i),(o),(l),(ks),(iv),(n),(e))
182 #define des_ofb64_encrypt(i,o,l,ks,iv,n)\
183 _ossl_old_des_ofb64_encrypt((i),(o),(l),(ks),(iv),(n))
186 #define des_ecb2_encrypt(i,o,k1,k2,e) \
187 des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
189 #define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
190 des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
192 #define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
193 des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
195 #define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
196 des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
198 #define des_check_key DES_check_key
199 #define des_rw_mode DES_rw_mode
201 const char *_ossl_old_des_options(void);
202 void _ossl_old_des_ecb3_encrypt(des_cblock *input,des_cblock *output,
203 des_key_schedule ks1,des_key_schedule ks2,
204 des_key_schedule ks3, int enc);
205 DES_LONG _ossl_old_des_cbc_cksum(des_cblock *input,des_cblock *output,
206 long length,des_key_schedule schedule,des_cblock *ivec);
207 void _ossl_old_des_cbc_encrypt(des_cblock *input,des_cblock *output,long length,
208 des_key_schedule schedule,des_cblock *ivec,int enc);
209 void _ossl_old_des_ncbc_encrypt(des_cblock *input,des_cblock *output,long length,
210 des_key_schedule schedule,des_cblock *ivec,int enc);
211 void _ossl_old_des_xcbc_encrypt(des_cblock *input,des_cblock *output,long length,
212 des_key_schedule schedule,des_cblock *ivec,
213 des_cblock *inw,des_cblock *outw,int enc);
214 void _ossl_old_des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
215 long length,des_key_schedule schedule,des_cblock *ivec,int enc);
216 void _ossl_old_des_ecb_encrypt(des_cblock *input,des_cblock *output,
217 des_key_schedule ks,int enc);
218 void _ossl_old_des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
219 void _ossl_old_des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
220 void _ossl_old_des_encrypt3(DES_LONG *data, des_key_schedule ks1,
221 des_key_schedule ks2, des_key_schedule ks3);
222 void _ossl_old_des_decrypt3(DES_LONG *data, des_key_schedule ks1,
223 des_key_schedule ks2, des_key_schedule ks3);
224 void _ossl_old_des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output,
225 long length, des_key_schedule ks1, des_key_schedule ks2,
226 des_key_schedule ks3, des_cblock *ivec, int enc);
227 void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
228 long length, des_key_schedule ks1, des_key_schedule ks2,
229 des_key_schedule ks3, des_cblock *ivec, int *num, int enc);
230 void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
231 long length, des_key_schedule ks1, des_key_schedule ks2,
232 des_key_schedule ks3, des_cblock *ivec, int *num);
234 void _ossl_old_des_xwhite_in2out(des_cblock (*des_key), des_cblock (*in_white),
235 des_cblock (*out_white));
237 int _ossl_old_des_enc_read(int fd,char *buf,int len,des_key_schedule sched,
239 int _ossl_old_des_enc_write(int fd,char *buf,int len,des_key_schedule sched,
241 char *_ossl_old_des_fcrypt(const char *buf,const char *salt, char *ret);
242 char *_ossl_old_des_crypt(const char *buf,const char *salt);
243 #if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT)
244 char *_ossl_old_crypt(const char *buf,const char *salt);
246 void _ossl_old_des_ofb_encrypt(unsigned char *in,unsigned char *out,
247 int numbits,long length,des_key_schedule schedule,des_cblock *ivec);
248 void _ossl_old_des_pcbc_encrypt(des_cblock *input,des_cblock *output,long length,
249 des_key_schedule schedule,des_cblock *ivec,int enc);
250 DES_LONG _ossl_old_des_quad_cksum(des_cblock *input,des_cblock *output,
251 long length,int out_count,des_cblock *seed);
252 void _ossl_old_des_random_seed(des_cblock key);
253 void _ossl_old_des_random_key(des_cblock ret);
254 int _ossl_old_des_read_password(des_cblock *key,const char *prompt,int verify);
255 int _ossl_old_des_read_2passwords(des_cblock *key1,des_cblock *key2,
256 const char *prompt,int verify);
257 void _ossl_old_des_set_odd_parity(des_cblock *key);
258 int _ossl_old_des_is_weak_key(des_cblock *key);
259 int _ossl_old_des_set_key(des_cblock *key,des_key_schedule schedule);
260 int _ossl_old_des_key_sched(des_cblock *key,des_key_schedule schedule);
261 void _ossl_old_des_string_to_key(char *str,des_cblock *key);
262 void _ossl_old_des_string_to_2keys(char *str,des_cblock *key1,des_cblock *key2);
263 void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
264 des_key_schedule schedule, des_cblock *ivec, int *num, int enc);
265 void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
266 des_key_schedule schedule, des_cblock *ivec, int *num);
268 /* The following definitions provide compatibility with the MIT Kerberos
269 * library. The des_key_schedule structure is not binary compatible. */
271 #define _KERBEROS_DES_H
273 #define KRBDES_ENCRYPT DES_ENCRYPT
274 #define KRBDES_DECRYPT DES_DECRYPT
277 # define ENCRYPT DES_ENCRYPT
278 # define DECRYPT DES_DECRYPT
282 # define C_Block des_cblock
283 # define Key_schedule des_key_schedule
284 # define KEY_SZ DES_KEY_SZ
285 # define string_to_key des_string_to_key
286 # define read_pw_string des_read_pw_string
287 # define random_key des_random_key
288 # define pcbc_encrypt des_pcbc_encrypt
289 # define set_key des_set_key
290 # define key_sched des_key_sched
291 # define ecb_encrypt des_ecb_encrypt
292 # define cbc_encrypt des_cbc_encrypt
293 # define ncbc_encrypt des_ncbc_encrypt
294 # define xcbc_encrypt des_xcbc_encrypt
295 # define cbc_cksum des_cbc_cksum
296 # define quad_cksum des_quad_cksum
297 # define check_parity des_check_key_parity
300 #define des_fixup_key_parity DES_fixup_key_parity
306 /* for DES_read_pw_string et al */
307 #include <openssl/ui_compat.h>