remove redundant definitions that are also in des.h
[openssl.git] / crypto / des / des_old.h
1 /* crypto/des/des_old.h -*- mode:C; c-file-style: "eay" -*- */
2
3 /* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
4  *
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.
10  *
11  * Please consider starting to use the DES_ functions rather than the
12  * des_ ones.  The des_ functions will dissapear completely before
13  * OpenSSL 1.0!
14  *
15  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
16  */
17
18 /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
19  * project 2001.
20  */
21 /* ====================================================================
22  * Copyright (c) 1998-2001 The OpenSSL Project.  All rights reserved.
23  *
24  * Redistribution and use in source and binary forms, with or without
25  * modification, are permitted provided that the following conditions
26  * are met:
27  *
28  * 1. Redistributions of source code must retain the above copyright
29  *    notice, this list of conditions and the following disclaimer. 
30  *
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
34  *    distribution.
35  *
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/)"
40  *
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.
45  *
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.
49  *
50  * 6. Redistributions of any form whatsoever must retain the following
51  *    acknowledgment:
52  *    "This product includes software developed by the OpenSSL Project
53  *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54  *
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  * ====================================================================
68  *
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).
72  *
73  */
74
75 #ifndef HEADER_DES_COMP_H
76 #define HEADER_DES_COMP_H
77
78 #ifdef OPENSSL_NO_DES
79 #error DES is disabled.
80 #endif
81
82 #ifdef _KERBEROS_DES_H
83 #error <openssl/des_old.h> replaces <kerberos/des.h>.
84 #endif
85
86 #include <openssl/opensslconf.h> /* DES_LONG */
87 #include <openssl/e_os2.h>      /* OPENSSL_EXTERN */
88 #include <openssl/des.h>
89 #include <openssl/symhacks.h>
90
91 #ifdef OPENSSL_BUILD_SHLIBCRYPTO
92 # undef OPENSSL_EXTERN
93 # define OPENSSL_EXTERN OPENSSL_EXPORT
94 #endif
95
96 #ifdef  __cplusplus
97 extern "C" {
98 #endif
99
100 typedef unsigned char des_cblock[8];
101 typedef struct des_ks_struct
102         {
103         union   {
104                 des_cblock _;
105                 /* make sure things are correct size on machines with
106                  * 8 byte longs */
107                 DES_LONG pad[2];
108                 } ks;
109         } des_key_schedule[16];
110
111 #define des_ecb2_encrypt(i,o,k1,k2,e) \
112         des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
113
114 #define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
115         des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
116
117 #define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
118         des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
119
120 #define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
121         des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
122
123 #define des_check_key DES_check_key
124 #define des_rw_mode DES_rw_mode
125
126 const char *des_options(void);
127 void des_ecb3_encrypt(des_cblock *input,des_cblock *output,
128         des_key_schedule ks1,des_key_schedule ks2,
129         des_key_schedule ks3, int enc);
130 DES_LONG des_cbc_cksum(des_cblock *input,des_cblock *output,
131         long length,des_key_schedule schedule,des_cblock *ivec);
132 void des_cbc_encrypt(des_cblock *input,des_cblock *output,long length,
133         des_key_schedule schedule,des_cblock *ivec,int enc);
134 void des_ncbc_encrypt(des_cblock *input,des_cblock *output,long length,
135         des_key_schedule schedule,des_cblock *ivec,int enc);
136 void des_xcbc_encrypt(des_cblock *input,des_cblock *output,long length,
137         des_key_schedule schedule,des_cblock *ivec,
138         des_cblock *inw,des_cblock *outw,int enc);
139 void des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
140         long length,des_key_schedule schedule,des_cblock *ivec,int enc);
141 void des_ecb_encrypt(des_cblock *input,des_cblock *output,
142         des_key_schedule ks,int enc);
143 void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
144 void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
145 void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
146         des_key_schedule ks2, des_key_schedule ks3);
147 void des_decrypt3(DES_LONG *data, des_key_schedule ks1,
148         des_key_schedule ks2, des_key_schedule ks3);
149 void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output, 
150         long length, des_key_schedule ks1, des_key_schedule ks2, 
151         des_key_schedule ks3, des_cblock *ivec, int enc);
152 void des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
153         long length, des_key_schedule ks1, des_key_schedule ks2,
154         des_key_schedule ks3, des_cblock *ivec, int *num, int enc);
155 void des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
156         long length, des_key_schedule ks1, des_key_schedule ks2,
157         des_key_schedule ks3, des_cblock *ivec, int *num);
158
159 void des_xwhite_in2out(des_cblock (*des_key), des_cblock (*in_white),
160         des_cblock (*out_white));
161
162 int des_enc_read(int fd,char *buf,int len,des_key_schedule sched,
163         des_cblock *iv);
164 int des_enc_write(int fd,char *buf,int len,des_key_schedule sched,
165         des_cblock *iv);
166 char *des_fcrypt(const char *buf,const char *salt, char *ret);
167 char *des_crypt(const char *buf,const char *salt);
168 #if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT)
169 char *crypt(const char *buf,const char *salt);
170 #endif
171 void des_ofb_encrypt(unsigned char *in,unsigned char *out,
172         int numbits,long length,des_key_schedule schedule,des_cblock *ivec);
173 void des_pcbc_encrypt(des_cblock *input,des_cblock *output,long length,
174         des_key_schedule schedule,des_cblock *ivec,int enc);
175 DES_LONG des_quad_cksum(des_cblock *input,des_cblock *output,
176         long length,int out_count,des_cblock *seed);
177 void des_random_seed(des_cblock key);
178 void des_random_key(des_cblock ret);
179 void des_set_odd_parity(des_cblock *key);
180 int des_is_weak_key(des_cblock *key);
181 int des_set_key(des_cblock *key,des_key_schedule schedule);
182 int des_key_sched(des_cblock *key,des_key_schedule schedule);
183 void des_string_to_key(char *str,des_cblock *key);
184 void des_string_to_2keys(char *str,des_cblock *key1,des_cblock *key2);
185 void des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
186         des_key_schedule schedule, des_cblock *ivec, int *num, int enc);
187 void des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
188         des_key_schedule schedule, des_cblock *ivec, int *num);
189
190 /* The following definitions provide compatibility with the MIT Kerberos
191  * library. The des_key_schedule structure is not binary compatible. */
192
193 #define _KERBEROS_DES_H
194
195 #define KRBDES_ENCRYPT DES_ENCRYPT
196 #define KRBDES_DECRYPT DES_DECRYPT
197
198 #ifdef KERBEROS
199 #  define ENCRYPT DES_ENCRYPT
200 #  define DECRYPT DES_DECRYPT
201 #endif
202
203 #ifndef NCOMPAT
204 #  define C_Block des_cblock
205 #  define Key_schedule des_key_schedule
206 #  define KEY_SZ DES_KEY_SZ
207 #  define string_to_key des_string_to_key
208 #  define read_pw_string des_read_pw_string
209 #  define random_key des_random_key
210 #  define pcbc_encrypt des_pcbc_encrypt
211 #  define set_key des_set_key
212 #  define key_sched des_key_sched
213 #  define ecb_encrypt des_ecb_encrypt
214 #  define cbc_encrypt des_cbc_encrypt
215 #  define ncbc_encrypt des_ncbc_encrypt
216 #  define xcbc_encrypt des_xcbc_encrypt
217 #  define cbc_cksum des_cbc_cksum
218 #  define quad_cksum des_quad_cksum
219 #  define check_parity des_check_key_parity
220 #endif
221
222 #define des_fixup_key_parity DES_fixup_key_parity
223
224 #ifdef  __cplusplus
225 }
226 #endif
227
228 #endif