00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 #ifndef HEADER_DES_H
00092 #define HEADER_DES_H
00093
00094 #include <openssl/e_os2.h>
00095
00096 #ifdef OPENSSL_NO_DES
00097 #error DES is disabled.
00098 #endif
00099
00100 #ifndef HEADER_NEW_DES_H
00101 #error You must include des.h, not des_old.h directly.
00102 #endif
00103
00104 #ifdef _KERBEROS_DES_H
00105 #error <openssl/des_old.h> replaces <kerberos/des.h>.
00106 #endif
00107
00108 #include <openssl/symhacks.h>
00109
00110 #ifdef OPENSSL_BUILD_SHLIBCRYPTO
00111 # undef OPENSSL_EXTERN
00112 # define OPENSSL_EXTERN OPENSSL_EXPORT
00113 #endif
00114
00115 #ifdef __cplusplus
00116 extern "C" {
00117 #endif
00118
00119 #ifdef _
00120 #undef _
00121 #endif
00122
00123 typedef unsigned char _ossl_old_des_cblock[8];
00124 typedef struct _ossl_old_des_ks_struct
00125 {
00126 union {
00127 _ossl_old_des_cblock _;
00128
00129
00130 DES_LONG pad[2];
00131 } ks;
00132 } _ossl_old_des_key_schedule[16];
00133
00134 #ifndef OPENSSL_DES_LIBDES_COMPATIBILITY
00135 #define des_cblock DES_cblock
00136 #define const_des_cblock const_DES_cblock
00137 #define des_key_schedule DES_key_schedule
00138 #define des_ecb3_encrypt(i,o,k1,k2,k3,e)\
00139 DES_ecb3_encrypt((i),(o),&(k1),&(k2),&(k3),(e))
00140 #define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\
00141 DES_ede3_cbc_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(e))
00142 #define des_ede3_cbcm_encrypt(i,o,l,k1,k2,k3,iv1,iv2,e)\
00143 DES_ede3_cbcm_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv1),(iv2),(e))
00144 #define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\
00145 DES_ede3_cfb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n),(e))
00146 #define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\
00147 DES_ede3_ofb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n))
00148 #define des_options()\
00149 DES_options()
00150 #define des_cbc_cksum(i,o,l,k,iv)\
00151 DES_cbc_cksum((i),(o),(l),&(k),(iv))
00152 #define des_cbc_encrypt(i,o,l,k,iv,e)\
00153 DES_cbc_encrypt((i),(o),(l),&(k),(iv),(e))
00154 #define des_ncbc_encrypt(i,o,l,k,iv,e)\
00155 DES_ncbc_encrypt((i),(o),(l),&(k),(iv),(e))
00156 #define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\
00157 DES_xcbc_encrypt((i),(o),(l),&(k),(iv),(inw),(outw),(e))
00158 #define des_cfb_encrypt(i,o,n,l,k,iv,e)\
00159 DES_cfb_encrypt((i),(o),(n),(l),&(k),(iv),(e))
00160 #define des_ecb_encrypt(i,o,k,e)\
00161 DES_ecb_encrypt((i),(o),&(k),(e))
00162 #define des_encrypt1(d,k,e)\
00163 DES_encrypt1((d),&(k),(e))
00164 #define des_encrypt2(d,k,e)\
00165 DES_encrypt2((d),&(k),(e))
00166 #define des_encrypt3(d,k1,k2,k3)\
00167 DES_encrypt3((d),&(k1),&(k2),&(k3))
00168 #define des_decrypt3(d,k1,k2,k3)\
00169 DES_decrypt3((d),&(k1),&(k2),&(k3))
00170 #define des_xwhite_in2out(k,i,o)\
00171 DES_xwhite_in2out((k),(i),(o))
00172 #define des_enc_read(f,b,l,k,iv)\
00173 DES_enc_read((f),(b),(l),&(k),(iv))
00174 #define des_enc_write(f,b,l,k,iv)\
00175 DES_enc_write((f),(b),(l),&(k),(iv))
00176 #define des_fcrypt(b,s,r)\
00177 DES_fcrypt((b),(s),(r))
00178 #if 0
00179 #define des_crypt(b,s)\
00180 DES_crypt((b),(s))
00181 #if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__)
00182 #define crypt(b,s)\
00183 DES_crypt((b),(s))
00184 #endif
00185 #endif
00186 #define des_ofb_encrypt(i,o,n,l,k,iv)\
00187 DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv))
00188 #define des_pcbc_encrypt(i,o,l,k,iv,e)\
00189 DES_pcbc_encrypt((i),(o),(l),&(k),(iv),(e))
00190 #define des_quad_cksum(i,o,l,c,s)\
00191 DES_quad_cksum((i),(o),(l),(c),(s))
00192 #define des_random_seed(k)\
00193 _ossl_096_des_random_seed((k))
00194 #define des_random_key(r)\
00195 DES_random_key((r))
00196 #define des_read_password(k,p,v) \
00197 DES_read_password((k),(p),(v))
00198 #define des_read_2passwords(k1,k2,p,v) \
00199 DES_read_2passwords((k1),(k2),(p),(v))
00200 #define des_set_odd_parity(k)\
00201 DES_set_odd_parity((k))
00202 #define des_check_key_parity(k)\
00203 DES_check_key_parity((k))
00204 #define des_is_weak_key(k)\
00205 DES_is_weak_key((k))
00206 #define des_set_key(k,ks)\
00207 DES_set_key((k),&(ks))
00208 #define des_key_sched(k,ks)\
00209 DES_key_sched((k),&(ks))
00210 #define des_set_key_checked(k,ks)\
00211 DES_set_key_checked((k),&(ks))
00212 #define des_set_key_unchecked(k,ks)\
00213 DES_set_key_unchecked((k),&(ks))
00214 #define des_string_to_key(s,k)\
00215 DES_string_to_key((s),(k))
00216 #define des_string_to_2keys(s,k1,k2)\
00217 DES_string_to_2keys((s),(k1),(k2))
00218 #define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\
00219 DES_cfb64_encrypt((i),(o),(l),&(ks),(iv),(n),(e))
00220 #define des_ofb64_encrypt(i,o,l,ks,iv,n)\
00221 DES_ofb64_encrypt((i),(o),(l),&(ks),(iv),(n))
00222
00223
00224 #define des_ecb2_encrypt(i,o,k1,k2,e) \
00225 des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
00226
00227 #define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
00228 des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
00229
00230 #define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
00231 des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
00232
00233 #define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
00234 des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
00235
00236 #define des_check_key DES_check_key
00237 #define des_rw_mode DES_rw_mode
00238 #else
00239
00240
00241 #define des_cblock _ossl_old_des_cblock
00242 #define des_key_schedule _ossl_old_des_key_schedule
00243 #define des_ecb3_encrypt(i,o,k1,k2,k3,e)\
00244 _ossl_old_des_ecb3_encrypt((i),(o),(k1),(k2),(k3),(e))
00245 #define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\
00246 _ossl_old_des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(e))
00247 #define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\
00248 _ossl_old_des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n),(e))
00249 #define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\
00250 _ossl_old_des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n))
00251 #define des_options()\
00252 _ossl_old_des_options()
00253 #define des_cbc_cksum(i,o,l,k,iv)\
00254 _ossl_old_des_cbc_cksum((i),(o),(l),(k),(iv))
00255 #define des_cbc_encrypt(i,o,l,k,iv,e)\
00256 _ossl_old_des_cbc_encrypt((i),(o),(l),(k),(iv),(e))
00257 #define des_ncbc_encrypt(i,o,l,k,iv,e)\
00258 _ossl_old_des_ncbc_encrypt((i),(o),(l),(k),(iv),(e))
00259 #define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\
00260 _ossl_old_des_xcbc_encrypt((i),(o),(l),(k),(iv),(inw),(outw),(e))
00261 #define des_cfb_encrypt(i,o,n,l,k,iv,e)\
00262 _ossl_old_des_cfb_encrypt((i),(o),(n),(l),(k),(iv),(e))
00263 #define des_ecb_encrypt(i,o,k,e)\
00264 _ossl_old_des_ecb_encrypt((i),(o),(k),(e))
00265 #define des_encrypt(d,k,e)\
00266 _ossl_old_des_encrypt((d),(k),(e))
00267 #define des_encrypt2(d,k,e)\
00268 _ossl_old_des_encrypt2((d),(k),(e))
00269 #define des_encrypt3(d,k1,k2,k3)\
00270 _ossl_old_des_encrypt3((d),(k1),(k2),(k3))
00271 #define des_decrypt3(d,k1,k2,k3)\
00272 _ossl_old_des_decrypt3((d),(k1),(k2),(k3))
00273 #define des_xwhite_in2out(k,i,o)\
00274 _ossl_old_des_xwhite_in2out((k),(i),(o))
00275 #define des_enc_read(f,b,l,k,iv)\
00276 _ossl_old_des_enc_read((f),(b),(l),(k),(iv))
00277 #define des_enc_write(f,b,l,k,iv)\
00278 _ossl_old_des_enc_write((f),(b),(l),(k),(iv))
00279 #define des_fcrypt(b,s,r)\
00280 _ossl_old_des_fcrypt((b),(s),(r))
00281 #define des_crypt(b,s)\
00282 _ossl_old_des_crypt((b),(s))
00283 #if 0
00284 #define crypt(b,s)\
00285 _ossl_old_crypt((b),(s))
00286 #endif
00287 #define des_ofb_encrypt(i,o,n,l,k,iv)\
00288 _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv))
00289 #define des_pcbc_encrypt(i,o,l,k,iv,e)\
00290 _ossl_old_des_pcbc_encrypt((i),(o),(l),(k),(iv),(e))
00291 #define des_quad_cksum(i,o,l,c,s)\
00292 _ossl_old_des_quad_cksum((i),(o),(l),(c),(s))
00293 #define des_random_seed(k)\
00294 _ossl_old_des_random_seed((k))
00295 #define des_random_key(r)\
00296 _ossl_old_des_random_key((r))
00297 #define des_read_password(k,p,v) \
00298 _ossl_old_des_read_password((k),(p),(v))
00299 #define des_read_2passwords(k1,k2,p,v) \
00300 _ossl_old_des_read_2passwords((k1),(k2),(p),(v))
00301 #define des_set_odd_parity(k)\
00302 _ossl_old_des_set_odd_parity((k))
00303 #define des_is_weak_key(k)\
00304 _ossl_old_des_is_weak_key((k))
00305 #define des_set_key(k,ks)\
00306 _ossl_old_des_set_key((k),(ks))
00307 #define des_key_sched(k,ks)\
00308 _ossl_old_des_key_sched((k),(ks))
00309 #define des_string_to_key(s,k)\
00310 _ossl_old_des_string_to_key((s),(k))
00311 #define des_string_to_2keys(s,k1,k2)\
00312 _ossl_old_des_string_to_2keys((s),(k1),(k2))
00313 #define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\
00314 _ossl_old_des_cfb64_encrypt((i),(o),(l),(ks),(iv),(n),(e))
00315 #define des_ofb64_encrypt(i,o,l,ks,iv,n)\
00316 _ossl_old_des_ofb64_encrypt((i),(o),(l),(ks),(iv),(n))
00317
00318
00319 #define des_ecb2_encrypt(i,o,k1,k2,e) \
00320 des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
00321
00322 #define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
00323 des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
00324
00325 #define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
00326 des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
00327
00328 #define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
00329 des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
00330
00331 #define des_check_key DES_check_key
00332 #define des_rw_mode DES_rw_mode
00333 #endif
00334
00335 const char *_ossl_old_des_options(void);
00336 void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
00337 _ossl_old_des_key_schedule ks1,_ossl_old_des_key_schedule ks2,
00338 _ossl_old_des_key_schedule ks3, int enc);
00339 DES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
00340 long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec);
00341 void _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
00342 _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
00343 void _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
00344 _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
00345 void _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
00346 _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,
00347 _ossl_old_des_cblock *inw,_ossl_old_des_cblock *outw,int enc);
00348 void _ossl_old_des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
00349 long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
00350 void _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
00351 _ossl_old_des_key_schedule ks,int enc);
00352 void _ossl_old_des_encrypt(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc);
00353 void _ossl_old_des_encrypt2(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc);
00354 void _ossl_old_des_encrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,
00355 _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3);
00356 void _ossl_old_des_decrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,
00357 _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3);
00358 void _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input, _ossl_old_des_cblock *output,
00359 long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2,
00360 _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int enc);
00361 void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
00362 long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2,
00363 _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num, int enc);
00364 void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
00365 long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2,
00366 _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num);
00367
00368 void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white),
00369 _ossl_old_des_cblock (*out_white));
00370
00371 int _ossl_old_des_enc_read(int fd,char *buf,int len,_ossl_old_des_key_schedule sched,
00372 _ossl_old_des_cblock *iv);
00373 int _ossl_old_des_enc_write(int fd,char *buf,int len,_ossl_old_des_key_schedule sched,
00374 _ossl_old_des_cblock *iv);
00375 char *_ossl_old_des_fcrypt(const char *buf,const char *salt, char *ret);
00376 char *_ossl_old_des_crypt(const char *buf,const char *salt);
00377 #if !defined(PERL5) && !defined(NeXT)
00378 char *_ossl_old_crypt(const char *buf,const char *salt);
00379 #endif
00380 void _ossl_old_des_ofb_encrypt(unsigned char *in,unsigned char *out,
00381 int numbits,long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec);
00382 void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
00383 _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
00384 DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
00385 long length,int out_count,_ossl_old_des_cblock *seed);
00386 void _ossl_old_des_random_seed(_ossl_old_des_cblock key);
00387 void _ossl_old_des_random_key(_ossl_old_des_cblock ret);
00388 int _ossl_old_des_read_password(_ossl_old_des_cblock *key,const char *prompt,int verify);
00389 int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2,
00390 const char *prompt,int verify);
00391 void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key);
00392 int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key);
00393 int _ossl_old_des_set_key(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule);
00394 int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule);
00395 void _ossl_old_des_string_to_key(char *str,_ossl_old_des_cblock *key);
00396 void _ossl_old_des_string_to_2keys(char *str,_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2);
00397 void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
00398 _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num, int enc);
00399 void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
00400 _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num);
00401
00402 void _ossl_096_des_random_seed(des_cblock *key);
00403
00404
00405
00406
00407 #define _KERBEROS_DES_H
00408
00409 #define KRBDES_ENCRYPT DES_ENCRYPT
00410 #define KRBDES_DECRYPT DES_DECRYPT
00411
00412 #ifdef KERBEROS
00413 # define ENCRYPT DES_ENCRYPT
00414 # define DECRYPT DES_DECRYPT
00415 #endif
00416
00417 #ifndef NCOMPAT
00418 # define C_Block des_cblock
00419 # define Key_schedule des_key_schedule
00420 # define KEY_SZ DES_KEY_SZ
00421 # define string_to_key des_string_to_key
00422 # define read_pw_string des_read_pw_string
00423 # define random_key des_random_key
00424 # define pcbc_encrypt des_pcbc_encrypt
00425 # define set_key des_set_key
00426 # define key_sched des_key_sched
00427 # define ecb_encrypt des_ecb_encrypt
00428 # define cbc_encrypt des_cbc_encrypt
00429 # define ncbc_encrypt des_ncbc_encrypt
00430 # define xcbc_encrypt des_xcbc_encrypt
00431 # define cbc_cksum des_cbc_cksum
00432 # define quad_cksum des_quad_cksum
00433 # define check_parity des_check_key_parity
00434 #endif
00435
00436 #define des_fixup_key_parity DES_fixup_key_parity
00437
00438 #ifdef __cplusplus
00439 }
00440 #endif
00441
00442
00443 #include <openssl/ui_compat.h>
00444
00445 #endif