00001 /* $Id$ */ 00002 x/* $OpenBSD: rpc_des.h,v 1.3 1998/02/10 06:25:33 deraadt Exp $ */ 00003 00004 /* crypto/des/rpc_des.h */ 00005 /* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au) 00006 * All rights reserved. 00007 * 00008 * This package is an SSL implementation written 00009 * by Eric Young (eay@mincom.oz.au). 00010 * The implementation was written so as to conform with Netscapes SSL. 00011 * 00012 * This library is free for commercial and non-commercial use as long as 00013 * the following conditions are aheared to. The following conditions 00014 * apply to all code found in this distribution, be it the RC4, RSA, 00015 * lhash, DES, etc., code; not just the SSL code. The SSL documentation 00016 * included with this distribution is covered by the same copyright terms 00017 * except that the holder is Tim Hudson (tjh@mincom.oz.au). 00018 * 00019 * Copyright remains Eric Young's, and as such any Copyright notices in 00020 * the code are not to be removed. 00021 * If this package is used in a product, Eric Young should be given attribution 00022 * as the author of the parts of the library used. 00023 * This can be in the form of a textual message at program startup or 00024 * in documentation (online or textual) provided with the package. 00025 * 00026 * Redistribution and use in source and binary forms, with or without 00027 * modification, are permitted provided that the following conditions 00028 * are met: 00029 * 1. Redistributions of source code must retain the copyright 00030 * notice, this list of conditions and the following disclaimer. 00031 * 2. Redistributions in binary form must reproduce the above copyright 00032 * notice, this list of conditions and the following disclaimer in the 00033 * documentation and/or other materials provided with the distribution. 00034 * 3. All advertising materials mentioning features or use of this software 00035 * must display the following acknowledgement: 00036 * "This product includes cryptographic software written by 00037 * Eric Young (eay@mincom.oz.au)" 00038 * The word 'cryptographic' can be left out if the rouines from the library 00039 * being used are not cryptographic related :-). 00040 * 4. If you include any Windows specific code (or a derivative thereof) from 00041 * the apps directory (application code) you must include an acknowledgement: 00042 * "This product includes software written by Tim Hudson (tjh@mincom.oz.au)" 00043 * 00044 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 00045 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00046 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00047 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 00048 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00049 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00050 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00051 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00052 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00053 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00054 * SUCH DAMAGE. 00055 * 00056 * The licence and distribution terms for any publically available version or 00057 * derivative of this code cannot be changed. i.e. this code cannot simply be 00058 * copied and put under another distribution licence 00059 * [including the GNU Public Licence.] 00060 */ 00061 00062 /* @(#)des.h 2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI */ 00063 /* 00064 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 00065 * unrestricted use provided that this legend is included on all tape 00066 * media and as a part of the software program in whole or part. Users 00067 * may copy or modify Sun RPC without charge, but are not authorized 00068 * to license or distribute it to anyone else except as part of a product or 00069 * program developed by the user. 00070 * 00071 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 00072 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 00073 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 00074 * 00075 * Sun RPC is provided with no support and without any obligation on the 00076 * part of Sun Microsystems, Inc. to assist in its use, correction, 00077 * modification or enhancement. 00078 * 00079 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 00080 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 00081 * OR ANY PART THEREOF. 00082 * 00083 * In no event will Sun Microsystems, Inc. be liable for any lost revenue 00084 * or profits or other special, indirect and consequential damages, even if 00085 * Sun has been advised of the possibility of such damages. 00086 * 00087 * Sun Microsystems, Inc. 00088 * 2550 Garcia Avenue 00089 * Mountain View, California 94043 00090 */ 00091 /* 00092 * Generic DES driver interface 00093 * Keep this file hardware independent! 00094 * Copyright (c) 1986 by Sun Microsystems, Inc. 00095 */ 00096 00097 #define DES_MAXLEN 65536 /* maximum # of bytes to encrypt */ 00098 #define DES_QUICKLEN 16 /* maximum # of bytes to encrypt quickly */ 00099 00100 #ifdef HEADER_DES_H 00101 #undef ENCRYPT 00102 #undef DECRYPT 00103 #endif 00104 00105 enum desdir { ENCRYPT, DECRYPT }; 00106 enum desmode { CBC, ECB }; 00107 00108 /* 00109 * parameters to ioctl call 00110 */ 00111 struct desparams { 00112 unsigned char des_key[8]; /* key (with low bit parity) */ 00113 enum desdir des_dir; /* direction */ 00114 enum desmode des_mode; /* mode */ 00115 unsigned char des_ivec[8]; /* input vector */ 00116 unsigned int des_len; /* number of bytes to crypt */ 00117 union { 00118 unsigned char UDES_data[DES_QUICKLEN]; 00119 unsigned char *UDES_buf; 00120 } UDES; 00121 # define des_data UDES.UDES_data /* direct data here if quick */ 00122 # define des_buf UDES.UDES_buf /* otherwise, pointer to data */ 00123 }; 00124 00125 /* 00126 * Encrypt an arbitrary sized buffer 00127 */ 00128 #define DESIOCBLOCK _IOWR(d, 6, struct desparams) 00129 00130 /* 00131 * Encrypt of small amount of data, quickly 00132 */ 00133 #define DESIOCQUICK _IOWR(d, 7, struct desparams) 00134