1 /* 2 * @(#)des_crypt.h 2.1 88/08/11 4.0 RPCSRC; from 1.4 88/02/08 (C) 1986 SMI 3 * $FreeBSD$ 4 * 5 * des_crypt.h, des library routine interface 6 * Copyright (C) 1986, Sun Microsystems, Inc. 7 */ 8 /* 9 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 10 * unrestricted use provided that this legend is included on all tape 11 * media and as a part of the software program in whole or part. Users 12 * may copy or modify Sun RPC without charge, but are not authorized 13 * to license or distribute it to anyone else except as part of a product or 14 * program developed by the user. 15 * 16 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 17 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 18 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 19 * 20 * Sun RPC is provided with no support and without any obligation on the 21 * part of Sun Microsystems, Inc. to assist in its use, correction, 22 * modification or enhancement. 23 * 24 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 25 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 26 * OR ANY PART THEREOF. 27 * 28 * In no event will Sun Microsystems, Inc. be liable for any lost revenue 29 * or profits or other special, indirect and consequential damages, even if 30 * Sun has been advised of the possibility of such damages. 31 * 32 * Sun Microsystems, Inc. 33 * 2550 Garcia Avenue 34 * Mountain View, California 94043 35 */ 36 37 #include <sys/cdefs.h> 38 #include <rpc/rpc.h> 39 40 #define DES_MAXDATA 8192 /* max bytes encrypted in one call */ 41 #define DES_DIRMASK (1 << 0) 42 #define DES_ENCRYPT (0*DES_DIRMASK) /* Encrypt */ 43 #define DES_DECRYPT (1*DES_DIRMASK) /* Decrypt */ 44 45 46 #define DES_DEVMASK (1 << 1) 47 #define DES_HW (0*DES_DEVMASK) /* Use hardware device */ 48 #define DES_SW (1*DES_DEVMASK) /* Use software device */ 49 50 51 #define DESERR_NONE 0 /* succeeded */ 52 #define DESERR_NOHWDEVICE 1 /* succeeded, but hw device not available */ 53 #define DESERR_HWERROR 2 /* failed, hardware/driver error */ 54 #define DESERR_BADPARAM 3 /* failed, bad parameter to call */ 55 56 #define DES_FAILED(err) \ 57 ((err) > DESERR_NOHWDEVICE) 58 59 /* 60 * cbc_crypt() 61 * ecb_crypt() 62 * 63 * Encrypt (or decrypt) len bytes of a buffer buf. 64 * The length must be a multiple of eight. 65 * The key should have odd parity in the low bit of each byte. 66 * ivec is the input vector, and is updated to the new one (cbc only). 67 * The mode is created by oring together the appropriate parameters. 68 * DESERR_NOHWDEVICE is returned if DES_HW was specified but 69 * there was no hardware to do it on (the data will still be 70 * encrypted though, in software). 71 */ 72 73 74 /* 75 * Cipher Block Chaining mode 76 */ 77 __BEGIN_DECLS 78 #ifdef __STDC__ 79 int cbc_crypt __P(( char *, char *, unsigned int, unsigned int, char *)); 80 #else 81 cbc_crypt(/* key, buf, len, mode, ivec */); /* 82 char *key; 83 char *buf; 84 unsigned len; 85 unsigned mode; 86 char *ivec; 87 */ 88 #endif 89 90 /* 91 * Electronic Code Book mode 92 */ 93 #ifdef __STDC__ 94 int ecb_crypt __P(( char *, char *, unsigned int, unsigned int )); 95 #else 96 ecb_crypt(/* key, buf, len, mode */); /* 97 char *key; 98 char *buf; 99 unsigned len; 100 unsigned mode; 101 */ 102 #endif 103 __END_DECLS 104 105 #ifndef _KERNEL 106 /* 107 * Set des parity for a key. 108 * DES parity is odd and in the low bit of each byte 109 */ 110 __BEGIN_DECLS 111 #ifdef __STDC__ 112 void des_setparity __P(( char *)); 113 #else 114 void 115 des_setparity(/* key */); /* 116 char *key; 117 */ 118 #endif 119 __END_DECLS 120 #endif 121