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