xref: /freebsd/include/rpc/des.h (revision f7e2700f42901072d25967401d2d2716cdf48b78)
1f7e2700fSBill Paul /*  @(#)des.h	2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI  */
2f7e2700fSBill Paul /*
3f7e2700fSBill Paul  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
4f7e2700fSBill Paul  * unrestricted use provided that this legend is included on all tape
5f7e2700fSBill Paul  * media and as a part of the software program in whole or part.  Users
6f7e2700fSBill Paul  * may copy or modify Sun RPC without charge, but are not authorized
7f7e2700fSBill Paul  * to license or distribute it to anyone else except as part of a product or
8f7e2700fSBill Paul  * program developed by the user.
9f7e2700fSBill Paul  *
10f7e2700fSBill Paul  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
11f7e2700fSBill Paul  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
12f7e2700fSBill Paul  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
13f7e2700fSBill Paul  *
14f7e2700fSBill Paul  * Sun RPC is provided with no support and without any obligation on the
15f7e2700fSBill Paul  * part of Sun Microsystems, Inc. to assist in its use, correction,
16f7e2700fSBill Paul  * modification or enhancement.
17f7e2700fSBill Paul  *
18f7e2700fSBill Paul  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
19f7e2700fSBill Paul  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
20f7e2700fSBill Paul  * OR ANY PART THEREOF.
21f7e2700fSBill Paul  *
22f7e2700fSBill Paul  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
23f7e2700fSBill Paul  * or profits or other special, indirect and consequential damages, even if
24f7e2700fSBill Paul  * Sun has been advised of the possibility of such damages.
25f7e2700fSBill Paul  *
26f7e2700fSBill Paul  * Sun Microsystems, Inc.
27f7e2700fSBill Paul  * 2550 Garcia Avenue
28f7e2700fSBill Paul  * Mountain View, California  94043
29f7e2700fSBill Paul  */
30f7e2700fSBill Paul /*
31f7e2700fSBill Paul  * Generic DES driver interface
32f7e2700fSBill Paul  * Keep this file hardware independent!
33f7e2700fSBill Paul  * Copyright (c) 1986 by Sun Microsystems, Inc.
34f7e2700fSBill Paul  */
35f7e2700fSBill Paul 
36f7e2700fSBill Paul #define DES_MAXLEN 	65536	/* maximum # of bytes to encrypt  */
37f7e2700fSBill Paul #define DES_QUICKLEN	16	/* maximum # of bytes to encrypt quickly */
38f7e2700fSBill Paul 
39f7e2700fSBill Paul enum desdir { ENCRYPT, DECRYPT };
40f7e2700fSBill Paul enum desmode { CBC, ECB };
41f7e2700fSBill Paul 
42f7e2700fSBill Paul /*
43f7e2700fSBill Paul  * parameters to ioctl call
44f7e2700fSBill Paul  */
45f7e2700fSBill Paul struct desparams {
46f7e2700fSBill Paul 	u_char des_key[8];	/* key (with low bit parity) */
47f7e2700fSBill Paul 	enum desdir des_dir;	/* direction */
48f7e2700fSBill Paul 	enum desmode des_mode;	/* mode */
49f7e2700fSBill Paul 	u_char des_ivec[8];	/* input vector */
50f7e2700fSBill Paul 	unsigned des_len;	/* number of bytes to crypt */
51f7e2700fSBill Paul 	union {
52f7e2700fSBill Paul 		u_char UDES_data[DES_QUICKLEN];
53f7e2700fSBill Paul 		u_char *UDES_buf;
54f7e2700fSBill Paul 	} UDES;
55f7e2700fSBill Paul #	define des_data UDES.UDES_data	/* direct data here if quick */
56f7e2700fSBill Paul #	define des_buf	UDES.UDES_buf	/* otherwise, pointer to data */
57f7e2700fSBill Paul };
58f7e2700fSBill Paul 
59f7e2700fSBill Paul /*
60f7e2700fSBill Paul  * Encrypt an arbitrary sized buffer
61f7e2700fSBill Paul  */
62f7e2700fSBill Paul #define	DESIOCBLOCK	_IOWR(d, 6, struct desparams)
63f7e2700fSBill Paul 
64f7e2700fSBill Paul /*
65f7e2700fSBill Paul  * Encrypt of small amount of data, quickly
66f7e2700fSBill Paul  */
67f7e2700fSBill Paul #define DESIOCQUICK	_IOWR(d, 7, struct desparams)
68f7e2700fSBill Paul 
69f7e2700fSBill Paul /*
70f7e2700fSBill Paul  * Software DES.
71f7e2700fSBill Paul  */
72f7e2700fSBill Paul extern int _des_crypt __P(( char *, int, struct desparams * ));
73