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