sl@0
|
1 |
/* crypto/des/des_old.c -*- mode:C; c-file-style: "eay" -*- */
|
sl@0
|
2 |
|
sl@0
|
3 |
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
sl@0
|
4 |
*
|
sl@0
|
5 |
* The function names in here are deprecated and are only present to
|
sl@0
|
6 |
* provide an interface compatible with libdes. OpenSSL now provides
|
sl@0
|
7 |
* functions where "des_" has been replaced with "DES_" in the names,
|
sl@0
|
8 |
* to make it possible to make incompatible changes that are needed
|
sl@0
|
9 |
* for C type security and other stuff.
|
sl@0
|
10 |
*
|
sl@0
|
11 |
* Please consider starting to use the DES_ functions rather than the
|
sl@0
|
12 |
* des_ ones. The des_ functions will dissapear completely before
|
sl@0
|
13 |
* OpenSSL 1.0!
|
sl@0
|
14 |
*
|
sl@0
|
15 |
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
|
sl@0
|
19 |
* project 2001.
|
sl@0
|
20 |
*/
|
sl@0
|
21 |
/* ====================================================================
|
sl@0
|
22 |
* Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
|
sl@0
|
23 |
*
|
sl@0
|
24 |
* Redistribution and use in source and binary forms, with or without
|
sl@0
|
25 |
* modification, are permitted provided that the following conditions
|
sl@0
|
26 |
* are met:
|
sl@0
|
27 |
*
|
sl@0
|
28 |
* 1. Redistributions of source code must retain the above copyright
|
sl@0
|
29 |
* notice, this list of conditions and the following disclaimer.
|
sl@0
|
30 |
*
|
sl@0
|
31 |
* 2. Redistributions in binary form must reproduce the above copyright
|
sl@0
|
32 |
* notice, this list of conditions and the following disclaimer in
|
sl@0
|
33 |
* the documentation and/or other materials provided with the
|
sl@0
|
34 |
* distribution.
|
sl@0
|
35 |
*
|
sl@0
|
36 |
* 3. All advertising materials mentioning features or use of this
|
sl@0
|
37 |
* software must display the following acknowledgment:
|
sl@0
|
38 |
* "This product includes software developed by the OpenSSL Project
|
sl@0
|
39 |
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
sl@0
|
40 |
*
|
sl@0
|
41 |
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
sl@0
|
42 |
* endorse or promote products derived from this software without
|
sl@0
|
43 |
* prior written permission. For written permission, please contact
|
sl@0
|
44 |
* openssl-core@openssl.org.
|
sl@0
|
45 |
*
|
sl@0
|
46 |
* 5. Products derived from this software may not be called "OpenSSL"
|
sl@0
|
47 |
* nor may "OpenSSL" appear in their names without prior written
|
sl@0
|
48 |
* permission of the OpenSSL Project.
|
sl@0
|
49 |
*
|
sl@0
|
50 |
* 6. Redistributions of any form whatsoever must retain the following
|
sl@0
|
51 |
* acknowledgment:
|
sl@0
|
52 |
* "This product includes software developed by the OpenSSL Project
|
sl@0
|
53 |
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
sl@0
|
54 |
*
|
sl@0
|
55 |
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
sl@0
|
56 |
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
sl@0
|
57 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
sl@0
|
58 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
sl@0
|
59 |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
sl@0
|
60 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
sl@0
|
61 |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
sl@0
|
62 |
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
sl@0
|
63 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
sl@0
|
64 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
sl@0
|
65 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
sl@0
|
66 |
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
sl@0
|
67 |
* ====================================================================
|
sl@0
|
68 |
*
|
sl@0
|
69 |
* This product includes cryptographic software written by Eric Young
|
sl@0
|
70 |
* (eay@cryptsoft.com). This product includes software written by Tim
|
sl@0
|
71 |
* Hudson (tjh@cryptsoft.com).
|
sl@0
|
72 |
*
|
sl@0
|
73 |
*/
|
sl@0
|
74 |
|
sl@0
|
75 |
#define OPENSSL_DES_LIBDES_COMPATIBILITY
|
sl@0
|
76 |
#include <openssl/des.h>
|
sl@0
|
77 |
#include <openssl/rand.h>
|
sl@0
|
78 |
|
sl@0
|
79 |
EXPORT_C const char *_ossl_old_des_options(void)
|
sl@0
|
80 |
{
|
sl@0
|
81 |
return DES_options();
|
sl@0
|
82 |
}
|
sl@0
|
83 |
EXPORT_C void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
|
sl@0
|
84 |
des_key_schedule ks1,des_key_schedule ks2,
|
sl@0
|
85 |
des_key_schedule ks3, int enc)
|
sl@0
|
86 |
{
|
sl@0
|
87 |
DES_ecb3_encrypt((const_DES_cblock *)input, output,
|
sl@0
|
88 |
(DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
|
sl@0
|
89 |
(DES_key_schedule *)ks3, enc);
|
sl@0
|
90 |
}
|
sl@0
|
91 |
EXPORT_C DES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
|
sl@0
|
92 |
long length,des_key_schedule schedule,_ossl_old_des_cblock *ivec)
|
sl@0
|
93 |
{
|
sl@0
|
94 |
return DES_cbc_cksum((unsigned char *)input, output, length,
|
sl@0
|
95 |
(DES_key_schedule *)schedule, ivec);
|
sl@0
|
96 |
}
|
sl@0
|
97 |
EXPORT_C void _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
|
sl@0
|
98 |
des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc)
|
sl@0
|
99 |
{
|
sl@0
|
100 |
DES_cbc_encrypt((unsigned char *)input, (unsigned char *)output,
|
sl@0
|
101 |
length, (DES_key_schedule *)schedule, ivec, enc);
|
sl@0
|
102 |
}
|
sl@0
|
103 |
EXPORT_C void _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
|
sl@0
|
104 |
des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc)
|
sl@0
|
105 |
{
|
sl@0
|
106 |
DES_ncbc_encrypt((unsigned char *)input, (unsigned char *)output,
|
sl@0
|
107 |
length, (DES_key_schedule *)schedule, ivec, enc);
|
sl@0
|
108 |
}
|
sl@0
|
109 |
EXPORT_C void _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
|
sl@0
|
110 |
des_key_schedule schedule,_ossl_old_des_cblock *ivec,
|
sl@0
|
111 |
_ossl_old_des_cblock *inw,_ossl_old_des_cblock *outw,int enc)
|
sl@0
|
112 |
{
|
sl@0
|
113 |
DES_xcbc_encrypt((unsigned char *)input, (unsigned char *)output,
|
sl@0
|
114 |
length, (DES_key_schedule *)schedule, ivec, inw, outw, enc);
|
sl@0
|
115 |
}
|
sl@0
|
116 |
EXPORT_C void _ossl_old_des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
|
sl@0
|
117 |
long length,des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc)
|
sl@0
|
118 |
{
|
sl@0
|
119 |
DES_cfb_encrypt(in, out, numbits, length,
|
sl@0
|
120 |
(DES_key_schedule *)schedule, ivec, enc);
|
sl@0
|
121 |
}
|
sl@0
|
122 |
EXPORT_C void _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
|
sl@0
|
123 |
des_key_schedule ks,int enc)
|
sl@0
|
124 |
{
|
sl@0
|
125 |
DES_ecb_encrypt(input, output, (DES_key_schedule *)ks, enc);
|
sl@0
|
126 |
}
|
sl@0
|
127 |
EXPORT_C void _ossl_old_des_encrypt(DES_LONG *data,des_key_schedule ks, int enc)
|
sl@0
|
128 |
{
|
sl@0
|
129 |
DES_encrypt1(data, (DES_key_schedule *)ks, enc);
|
sl@0
|
130 |
}
|
sl@0
|
131 |
EXPORT_C void _ossl_old_des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc)
|
sl@0
|
132 |
{
|
sl@0
|
133 |
DES_encrypt2(data, (DES_key_schedule *)ks, enc);
|
sl@0
|
134 |
}
|
sl@0
|
135 |
EXPORT_C void _ossl_old_des_encrypt3(DES_LONG *data, des_key_schedule ks1,
|
sl@0
|
136 |
des_key_schedule ks2, des_key_schedule ks3)
|
sl@0
|
137 |
{
|
sl@0
|
138 |
DES_encrypt3(data, (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
|
sl@0
|
139 |
(DES_key_schedule *)ks3);
|
sl@0
|
140 |
}
|
sl@0
|
141 |
EXPORT_C void _ossl_old_des_decrypt3(DES_LONG *data, des_key_schedule ks1,
|
sl@0
|
142 |
des_key_schedule ks2, des_key_schedule ks3)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
DES_decrypt3(data, (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
|
sl@0
|
145 |
(DES_key_schedule *)ks3);
|
sl@0
|
146 |
}
|
sl@0
|
147 |
EXPORT_C void _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input, _ossl_old_des_cblock *output,
|
sl@0
|
148 |
long length, des_key_schedule ks1, des_key_schedule ks2,
|
sl@0
|
149 |
des_key_schedule ks3, _ossl_old_des_cblock *ivec, int enc)
|
sl@0
|
150 |
{
|
sl@0
|
151 |
DES_ede3_cbc_encrypt((unsigned char *)input, (unsigned char *)output,
|
sl@0
|
152 |
length, (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
|
sl@0
|
153 |
(DES_key_schedule *)ks3, ivec, enc);
|
sl@0
|
154 |
}
|
sl@0
|
155 |
EXPORT_C void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
|
sl@0
|
156 |
long length, des_key_schedule ks1, des_key_schedule ks2,
|
sl@0
|
157 |
des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num, int enc)
|
sl@0
|
158 |
{
|
sl@0
|
159 |
DES_ede3_cfb64_encrypt(in, out, length,
|
sl@0
|
160 |
(DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
|
sl@0
|
161 |
(DES_key_schedule *)ks3, ivec, num, enc);
|
sl@0
|
162 |
}
|
sl@0
|
163 |
EXPORT_C void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
|
sl@0
|
164 |
long length, des_key_schedule ks1, des_key_schedule ks2,
|
sl@0
|
165 |
des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num)
|
sl@0
|
166 |
{
|
sl@0
|
167 |
DES_ede3_ofb64_encrypt(in, out, length,
|
sl@0
|
168 |
(DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
|
sl@0
|
169 |
(DES_key_schedule *)ks3, ivec, num);
|
sl@0
|
170 |
}
|
sl@0
|
171 |
|
sl@0
|
172 |
EXPORT_C void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white),
|
sl@0
|
173 |
_ossl_old_des_cblock (*out_white))
|
sl@0
|
174 |
{
|
sl@0
|
175 |
DES_xwhite_in2out(des_key, in_white, out_white);
|
sl@0
|
176 |
}
|
sl@0
|
177 |
|
sl@0
|
178 |
EXPORT_C int _ossl_old_des_enc_read(int fd,char *buf,int len,des_key_schedule sched,
|
sl@0
|
179 |
_ossl_old_des_cblock *iv)
|
sl@0
|
180 |
{
|
sl@0
|
181 |
return DES_enc_read(fd, buf, len, (DES_key_schedule *)sched, iv);
|
sl@0
|
182 |
}
|
sl@0
|
183 |
EXPORT_C int _ossl_old_des_enc_write(int fd,char *buf,int len,des_key_schedule sched,
|
sl@0
|
184 |
_ossl_old_des_cblock *iv)
|
sl@0
|
185 |
{
|
sl@0
|
186 |
return DES_enc_write(fd, buf, len, (DES_key_schedule *)sched, iv);
|
sl@0
|
187 |
}
|
sl@0
|
188 |
EXPORT_C char *_ossl_old_des_fcrypt(const char *buf,const char *salt, char *ret)
|
sl@0
|
189 |
{
|
sl@0
|
190 |
return DES_fcrypt(buf, salt, ret);
|
sl@0
|
191 |
}
|
sl@0
|
192 |
EXPORT_C char *_ossl_old_des_crypt(const char *buf,const char *salt)
|
sl@0
|
193 |
{
|
sl@0
|
194 |
return DES_crypt(buf, salt);
|
sl@0
|
195 |
}
|
sl@0
|
196 |
EXPORT_C char *_ossl_old_crypt(const char *buf,const char *salt)
|
sl@0
|
197 |
{
|
sl@0
|
198 |
return DES_crypt(buf, salt);
|
sl@0
|
199 |
}
|
sl@0
|
200 |
EXPORT_C void _ossl_old_des_ofb_encrypt(unsigned char *in,unsigned char *out,
|
sl@0
|
201 |
int numbits,long length,des_key_schedule schedule,_ossl_old_des_cblock *ivec)
|
sl@0
|
202 |
{
|
sl@0
|
203 |
DES_ofb_encrypt(in, out, numbits, length, (DES_key_schedule *)schedule,
|
sl@0
|
204 |
ivec);
|
sl@0
|
205 |
}
|
sl@0
|
206 |
EXPORT_C void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
|
sl@0
|
207 |
des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc)
|
sl@0
|
208 |
{
|
sl@0
|
209 |
DES_pcbc_encrypt((unsigned char *)input, (unsigned char *)output,
|
sl@0
|
210 |
length, (DES_key_schedule *)schedule, ivec, enc);
|
sl@0
|
211 |
}
|
sl@0
|
212 |
EXPORT_C DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
|
sl@0
|
213 |
long length,int out_count,_ossl_old_des_cblock *seed)
|
sl@0
|
214 |
{
|
sl@0
|
215 |
return DES_quad_cksum((unsigned char *)input, output, length,
|
sl@0
|
216 |
out_count, seed);
|
sl@0
|
217 |
}
|
sl@0
|
218 |
EXPORT_C void _ossl_old_des_random_seed(_ossl_old_des_cblock key)
|
sl@0
|
219 |
{
|
sl@0
|
220 |
RAND_seed(key, sizeof(_ossl_old_des_cblock));
|
sl@0
|
221 |
}
|
sl@0
|
222 |
EXPORT_C void _ossl_old_des_random_key(_ossl_old_des_cblock ret)
|
sl@0
|
223 |
{
|
sl@0
|
224 |
DES_random_key((DES_cblock *)ret);
|
sl@0
|
225 |
}
|
sl@0
|
226 |
EXPORT_C int _ossl_old_des_read_password(_ossl_old_des_cblock *key, const char *prompt,
|
sl@0
|
227 |
int verify)
|
sl@0
|
228 |
{
|
sl@0
|
229 |
return DES_read_password(key, prompt, verify);
|
sl@0
|
230 |
}
|
sl@0
|
231 |
EXPORT_C int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1, _ossl_old_des_cblock *key2,
|
sl@0
|
232 |
const char *prompt, int verify)
|
sl@0
|
233 |
{
|
sl@0
|
234 |
return DES_read_2passwords(key1, key2, prompt, verify);
|
sl@0
|
235 |
}
|
sl@0
|
236 |
EXPORT_C void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key)
|
sl@0
|
237 |
{
|
sl@0
|
238 |
DES_set_odd_parity(key);
|
sl@0
|
239 |
}
|
sl@0
|
240 |
EXPORT_C int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key)
|
sl@0
|
241 |
{
|
sl@0
|
242 |
return DES_is_weak_key(key);
|
sl@0
|
243 |
}
|
sl@0
|
244 |
EXPORT_C int _ossl_old_des_set_key(_ossl_old_des_cblock *key,des_key_schedule schedule)
|
sl@0
|
245 |
{
|
sl@0
|
246 |
return DES_set_key(key, (DES_key_schedule *)schedule);
|
sl@0
|
247 |
}
|
sl@0
|
248 |
EXPORT_C int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,des_key_schedule schedule)
|
sl@0
|
249 |
{
|
sl@0
|
250 |
return DES_key_sched(key, (DES_key_schedule *)schedule);
|
sl@0
|
251 |
}
|
sl@0
|
252 |
EXPORT_C void _ossl_old_des_string_to_key(char *str,_ossl_old_des_cblock *key)
|
sl@0
|
253 |
{
|
sl@0
|
254 |
DES_string_to_key(str, key);
|
sl@0
|
255 |
}
|
sl@0
|
256 |
EXPORT_C void _ossl_old_des_string_to_2keys(char *str,_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2)
|
sl@0
|
257 |
{
|
sl@0
|
258 |
DES_string_to_2keys(str, key1, key2);
|
sl@0
|
259 |
}
|
sl@0
|
260 |
EXPORT_C void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
|
sl@0
|
261 |
des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num, int enc)
|
sl@0
|
262 |
{
|
sl@0
|
263 |
DES_cfb64_encrypt(in, out, length, (DES_key_schedule *)schedule,
|
sl@0
|
264 |
ivec, num, enc);
|
sl@0
|
265 |
}
|
sl@0
|
266 |
EXPORT_C void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
|
sl@0
|
267 |
des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num)
|
sl@0
|
268 |
{
|
sl@0
|
269 |
DES_ofb64_encrypt(in, out, length, (DES_key_schedule *)schedule,
|
sl@0
|
270 |
ivec, num);
|
sl@0
|
271 |
}
|