sl@0: /* crypto/des/des_old.c -*- mode:C; c-file-style: "eay" -*- */ sl@0: sl@0: /* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING sl@0: * sl@0: * The function names in here are deprecated and are only present to sl@0: * provide an interface compatible with libdes. OpenSSL now provides sl@0: * functions where "des_" has been replaced with "DES_" in the names, sl@0: * to make it possible to make incompatible changes that are needed sl@0: * for C type security and other stuff. sl@0: * sl@0: * Please consider starting to use the DES_ functions rather than the sl@0: * des_ ones. The des_ functions will dissapear completely before sl@0: * OpenSSL 1.0! sl@0: * sl@0: * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING sl@0: */ sl@0: sl@0: /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL sl@0: * project 2001. sl@0: */ sl@0: /* ==================================================================== sl@0: * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. sl@0: * sl@0: * Redistribution and use in source and binary forms, with or without sl@0: * modification, are permitted provided that the following conditions sl@0: * are met: sl@0: * sl@0: * 1. Redistributions of source code must retain the above copyright sl@0: * notice, this list of conditions and the following disclaimer. sl@0: * sl@0: * 2. Redistributions in binary form must reproduce the above copyright sl@0: * notice, this list of conditions and the following disclaimer in sl@0: * the documentation and/or other materials provided with the sl@0: * distribution. sl@0: * sl@0: * 3. All advertising materials mentioning features or use of this sl@0: * software must display the following acknowledgment: sl@0: * "This product includes software developed by the OpenSSL Project sl@0: * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" sl@0: * sl@0: * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to sl@0: * endorse or promote products derived from this software without sl@0: * prior written permission. For written permission, please contact sl@0: * openssl-core@openssl.org. sl@0: * sl@0: * 5. Products derived from this software may not be called "OpenSSL" sl@0: * nor may "OpenSSL" appear in their names without prior written sl@0: * permission of the OpenSSL Project. sl@0: * sl@0: * 6. Redistributions of any form whatsoever must retain the following sl@0: * acknowledgment: sl@0: * "This product includes software developed by the OpenSSL Project sl@0: * for use in the OpenSSL Toolkit (http://www.openssl.org/)" sl@0: * sl@0: * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY sl@0: * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE sl@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR sl@0: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR sl@0: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, sl@0: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT sl@0: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; sl@0: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) sl@0: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, sl@0: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) sl@0: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED sl@0: * OF THE POSSIBILITY OF SUCH DAMAGE. sl@0: * ==================================================================== sl@0: * sl@0: * This product includes cryptographic software written by Eric Young sl@0: * (eay@cryptsoft.com). This product includes software written by Tim sl@0: * Hudson (tjh@cryptsoft.com). sl@0: * sl@0: */ sl@0: sl@0: #define OPENSSL_DES_LIBDES_COMPATIBILITY sl@0: #include sl@0: #include sl@0: sl@0: EXPORT_C const char *_ossl_old_des_options(void) sl@0: { sl@0: return DES_options(); sl@0: } sl@0: EXPORT_C void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, sl@0: des_key_schedule ks1,des_key_schedule ks2, sl@0: des_key_schedule ks3, int enc) sl@0: { sl@0: DES_ecb3_encrypt((const_DES_cblock *)input, output, sl@0: (DES_key_schedule *)ks1, (DES_key_schedule *)ks2, sl@0: (DES_key_schedule *)ks3, enc); sl@0: } sl@0: EXPORT_C DES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, sl@0: long length,des_key_schedule schedule,_ossl_old_des_cblock *ivec) sl@0: { sl@0: return DES_cbc_cksum((unsigned char *)input, output, length, sl@0: (DES_key_schedule *)schedule, ivec); sl@0: } sl@0: EXPORT_C void _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, sl@0: des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc) sl@0: { sl@0: DES_cbc_encrypt((unsigned char *)input, (unsigned char *)output, sl@0: length, (DES_key_schedule *)schedule, ivec, enc); sl@0: } sl@0: EXPORT_C void _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, sl@0: des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc) sl@0: { sl@0: DES_ncbc_encrypt((unsigned char *)input, (unsigned char *)output, sl@0: length, (DES_key_schedule *)schedule, ivec, enc); sl@0: } sl@0: EXPORT_C void _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, sl@0: des_key_schedule schedule,_ossl_old_des_cblock *ivec, sl@0: _ossl_old_des_cblock *inw,_ossl_old_des_cblock *outw,int enc) sl@0: { sl@0: DES_xcbc_encrypt((unsigned char *)input, (unsigned char *)output, sl@0: length, (DES_key_schedule *)schedule, ivec, inw, outw, enc); sl@0: } sl@0: EXPORT_C void _ossl_old_des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits, sl@0: long length,des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc) sl@0: { sl@0: DES_cfb_encrypt(in, out, numbits, length, sl@0: (DES_key_schedule *)schedule, ivec, enc); sl@0: } sl@0: EXPORT_C void _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, sl@0: des_key_schedule ks,int enc) sl@0: { sl@0: DES_ecb_encrypt(input, output, (DES_key_schedule *)ks, enc); sl@0: } sl@0: EXPORT_C void _ossl_old_des_encrypt(DES_LONG *data,des_key_schedule ks, int enc) sl@0: { sl@0: DES_encrypt1(data, (DES_key_schedule *)ks, enc); sl@0: } sl@0: EXPORT_C void _ossl_old_des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc) sl@0: { sl@0: DES_encrypt2(data, (DES_key_schedule *)ks, enc); sl@0: } sl@0: EXPORT_C void _ossl_old_des_encrypt3(DES_LONG *data, des_key_schedule ks1, sl@0: des_key_schedule ks2, des_key_schedule ks3) sl@0: { sl@0: DES_encrypt3(data, (DES_key_schedule *)ks1, (DES_key_schedule *)ks2, sl@0: (DES_key_schedule *)ks3); sl@0: } sl@0: EXPORT_C void _ossl_old_des_decrypt3(DES_LONG *data, des_key_schedule ks1, sl@0: des_key_schedule ks2, des_key_schedule ks3) sl@0: { sl@0: DES_decrypt3(data, (DES_key_schedule *)ks1, (DES_key_schedule *)ks2, sl@0: (DES_key_schedule *)ks3); sl@0: } sl@0: EXPORT_C void _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input, _ossl_old_des_cblock *output, sl@0: long length, des_key_schedule ks1, des_key_schedule ks2, sl@0: des_key_schedule ks3, _ossl_old_des_cblock *ivec, int enc) sl@0: { sl@0: DES_ede3_cbc_encrypt((unsigned char *)input, (unsigned char *)output, sl@0: length, (DES_key_schedule *)ks1, (DES_key_schedule *)ks2, sl@0: (DES_key_schedule *)ks3, ivec, enc); sl@0: } sl@0: EXPORT_C void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out, sl@0: long length, des_key_schedule ks1, des_key_schedule ks2, sl@0: des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num, int enc) sl@0: { sl@0: DES_ede3_cfb64_encrypt(in, out, length, sl@0: (DES_key_schedule *)ks1, (DES_key_schedule *)ks2, sl@0: (DES_key_schedule *)ks3, ivec, num, enc); sl@0: } sl@0: EXPORT_C void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out, sl@0: long length, des_key_schedule ks1, des_key_schedule ks2, sl@0: des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num) sl@0: { sl@0: DES_ede3_ofb64_encrypt(in, out, length, sl@0: (DES_key_schedule *)ks1, (DES_key_schedule *)ks2, sl@0: (DES_key_schedule *)ks3, ivec, num); sl@0: } sl@0: sl@0: EXPORT_C void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white), sl@0: _ossl_old_des_cblock (*out_white)) sl@0: { sl@0: DES_xwhite_in2out(des_key, in_white, out_white); sl@0: } sl@0: sl@0: EXPORT_C int _ossl_old_des_enc_read(int fd,char *buf,int len,des_key_schedule sched, sl@0: _ossl_old_des_cblock *iv) sl@0: { sl@0: return DES_enc_read(fd, buf, len, (DES_key_schedule *)sched, iv); sl@0: } sl@0: EXPORT_C int _ossl_old_des_enc_write(int fd,char *buf,int len,des_key_schedule sched, sl@0: _ossl_old_des_cblock *iv) sl@0: { sl@0: return DES_enc_write(fd, buf, len, (DES_key_schedule *)sched, iv); sl@0: } sl@0: EXPORT_C char *_ossl_old_des_fcrypt(const char *buf,const char *salt, char *ret) sl@0: { sl@0: return DES_fcrypt(buf, salt, ret); sl@0: } sl@0: EXPORT_C char *_ossl_old_des_crypt(const char *buf,const char *salt) sl@0: { sl@0: return DES_crypt(buf, salt); sl@0: } sl@0: EXPORT_C char *_ossl_old_crypt(const char *buf,const char *salt) sl@0: { sl@0: return DES_crypt(buf, salt); sl@0: } sl@0: EXPORT_C void _ossl_old_des_ofb_encrypt(unsigned char *in,unsigned char *out, sl@0: int numbits,long length,des_key_schedule schedule,_ossl_old_des_cblock *ivec) sl@0: { sl@0: DES_ofb_encrypt(in, out, numbits, length, (DES_key_schedule *)schedule, sl@0: ivec); sl@0: } sl@0: EXPORT_C void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, sl@0: des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc) sl@0: { sl@0: DES_pcbc_encrypt((unsigned char *)input, (unsigned char *)output, sl@0: length, (DES_key_schedule *)schedule, ivec, enc); sl@0: } sl@0: EXPORT_C DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, sl@0: long length,int out_count,_ossl_old_des_cblock *seed) sl@0: { sl@0: return DES_quad_cksum((unsigned char *)input, output, length, sl@0: out_count, seed); sl@0: } sl@0: EXPORT_C void _ossl_old_des_random_seed(_ossl_old_des_cblock key) sl@0: { sl@0: RAND_seed(key, sizeof(_ossl_old_des_cblock)); sl@0: } sl@0: EXPORT_C void _ossl_old_des_random_key(_ossl_old_des_cblock ret) sl@0: { sl@0: DES_random_key((DES_cblock *)ret); sl@0: } sl@0: EXPORT_C int _ossl_old_des_read_password(_ossl_old_des_cblock *key, const char *prompt, sl@0: int verify) sl@0: { sl@0: return DES_read_password(key, prompt, verify); sl@0: } sl@0: EXPORT_C int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1, _ossl_old_des_cblock *key2, sl@0: const char *prompt, int verify) sl@0: { sl@0: return DES_read_2passwords(key1, key2, prompt, verify); sl@0: } sl@0: EXPORT_C void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key) sl@0: { sl@0: DES_set_odd_parity(key); sl@0: } sl@0: EXPORT_C int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key) sl@0: { sl@0: return DES_is_weak_key(key); sl@0: } sl@0: EXPORT_C int _ossl_old_des_set_key(_ossl_old_des_cblock *key,des_key_schedule schedule) sl@0: { sl@0: return DES_set_key(key, (DES_key_schedule *)schedule); sl@0: } sl@0: EXPORT_C int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,des_key_schedule schedule) sl@0: { sl@0: return DES_key_sched(key, (DES_key_schedule *)schedule); sl@0: } sl@0: EXPORT_C void _ossl_old_des_string_to_key(char *str,_ossl_old_des_cblock *key) sl@0: { sl@0: DES_string_to_key(str, key); sl@0: } sl@0: EXPORT_C void _ossl_old_des_string_to_2keys(char *str,_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2) sl@0: { sl@0: DES_string_to_2keys(str, key1, key2); sl@0: } sl@0: EXPORT_C void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, sl@0: des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num, int enc) sl@0: { sl@0: DES_cfb64_encrypt(in, out, length, (DES_key_schedule *)schedule, sl@0: ivec, num, enc); sl@0: } sl@0: EXPORT_C void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, sl@0: des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num) sl@0: { sl@0: DES_ofb64_encrypt(in, out, length, (DES_key_schedule *)schedule, sl@0: ivec, num); sl@0: }