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