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 #define des_ecb2_encrypt(i,o,k1,k2,e) \
111 des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
113 #define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
114 des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
116 #define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
117 des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
119 #define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
120 des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
122 #define des_check_key DES_check_key
123 #define des_rw_mode DES_rw_mode
125 const char *des_options(void);
126 void des_ecb3_encrypt(des_cblock *input,des_cblock *output,
127 des_key_schedule ks1,des_key_schedule ks2,
128 des_key_schedule ks3, int enc);
129 DES_LONG des_cbc_cksum(des_cblock *input,des_cblock *output,
130 long length,des_key_schedule schedule,des_cblock *ivec);
131 void des_cbc_encrypt(des_cblock *input,des_cblock *output,long length,
132 des_key_schedule schedule,des_cblock *ivec,int enc);
133 void des_ncbc_encrypt(des_cblock *input,des_cblock *output,long length,
134 des_key_schedule schedule,des_cblock *ivec,int enc);
135 void des_xcbc_encrypt(des_cblock *input,des_cblock *output,long length,
136 des_key_schedule schedule,des_cblock *ivec,
137 des_cblock *inw,des_cblock *outw,int enc);
138 void des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
139 long length,des_key_schedule schedule,des_cblock *ivec,int enc);
140 void des_ecb_encrypt(des_cblock *input,des_cblock *output,
141 des_key_schedule ks,int enc);
142 void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
143 void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
144 void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
145 des_key_schedule ks2, des_key_schedule ks3);
146 void des_decrypt3(DES_LONG *data, des_key_schedule ks1,
147 des_key_schedule ks2, des_key_schedule ks3);
148 void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output,
149 long length, des_key_schedule ks1, des_key_schedule ks2,
150 des_key_schedule ks3, des_cblock *ivec, int enc);
151 void des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
152 long length, des_key_schedule ks1, des_key_schedule ks2,
153 des_key_schedule ks3, des_cblock *ivec, int *num, int enc);
154 void des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
155 long length, des_key_schedule ks1, des_key_schedule ks2,
156 des_key_schedule ks3, des_cblock *ivec, int *num);
158 void des_xwhite_in2out(des_cblock (*des_key), des_cblock (*in_white),
159 des_cblock (*out_white));
161 int des_enc_read(int fd,char *buf,int len,des_key_schedule sched,
163 int des_enc_write(int fd,char *buf,int len,des_key_schedule sched,
165 char *des_fcrypt(const char *buf,const char *salt, char *ret);
166 char *des_crypt(const char *buf,const char *salt);
167 #if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT)
168 char *crypt(const char *buf,const char *salt);
170 void des_ofb_encrypt(unsigned char *in,unsigned char *out,
171 int numbits,long length,des_key_schedule schedule,des_cblock *ivec);
172 void des_pcbc_encrypt(des_cblock *input,des_cblock *output,long length,
173 des_key_schedule schedule,des_cblock *ivec,int enc);
174 DES_LONG des_quad_cksum(des_cblock *input,des_cblock *output,
175 long length,int out_count,des_cblock *seed);
176 void des_random_seed(des_cblock key);
177 void des_random_key(des_cblock ret);
178 void des_set_odd_parity(des_cblock *key);
179 int des_is_weak_key(des_cblock *key);
180 int des_set_key(des_cblock *key,des_key_schedule schedule);
181 int des_key_sched(des_cblock *key,des_key_schedule schedule);
182 void des_string_to_key(char *str,des_cblock *key);
183 void des_string_to_2keys(char *str,des_cblock *key1,des_cblock *key2);
184 void des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
185 des_key_schedule schedule, des_cblock *ivec, int *num, int enc);
186 void des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
187 des_key_schedule schedule, des_cblock *ivec, int *num);
189 /* The following definitions provide compatibility with the MIT Kerberos
190 * library. The des_key_schedule structure is not binary compatible. */
192 #define _KERBEROS_DES_H
194 #define KRBDES_ENCRYPT DES_ENCRYPT
195 #define KRBDES_DECRYPT DES_DECRYPT
198 # define ENCRYPT DES_ENCRYPT
199 # define DECRYPT DES_DECRYPT
203 # define C_Block des_cblock
204 # define Key_schedule des_key_schedule
205 # define KEY_SZ DES_KEY_SZ
206 # define string_to_key des_string_to_key
207 # define read_pw_string des_read_pw_string
208 # define random_key des_random_key
209 # define pcbc_encrypt des_pcbc_encrypt
210 # define set_key des_set_key
211 # define key_sched des_key_sched
212 # define ecb_encrypt des_ecb_encrypt
213 # define cbc_encrypt des_cbc_encrypt
214 # define ncbc_encrypt des_ncbc_encrypt
215 # define xcbc_encrypt des_xcbc_encrypt
216 # define cbc_cksum des_cbc_cksum
217 # define quad_cksum des_quad_cksum
218 # define check_parity des_check_key_parity
221 #define des_fixup_key_parity DES_fixup_key_parity