xref: /reactos/dll/3rdparty/libtirpc/tirpc/rpc/des.h (revision c2c66aff)
1*c2c66affSColin Finck /*  @(#)des.h	2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI  */
2*c2c66affSColin Finck /* $FreeBSD: src/include/rpc/des.h,v 1.4 2002/03/23 17:24:55 imp Exp $ */
3*c2c66affSColin Finck /*
4*c2c66affSColin Finck  * Copyright (c) 2009, Sun Microsystems, Inc.
5*c2c66affSColin Finck  * All rights reserved.
6*c2c66affSColin Finck  *
7*c2c66affSColin Finck  * Redistribution and use in source and binary forms, with or without
8*c2c66affSColin Finck  * modification, are permitted provided that the following conditions are met:
9*c2c66affSColin Finck  * - Redistributions of source code must retain the above copyright notice,
10*c2c66affSColin Finck  *   this list of conditions and the following disclaimer.
11*c2c66affSColin Finck  * - Redistributions in binary form must reproduce the above copyright notice,
12*c2c66affSColin Finck  *   this list of conditions and the following disclaimer in the documentation
13*c2c66affSColin Finck  *   and/or other materials provided with the distribution.
14*c2c66affSColin Finck  * - Neither the name of Sun Microsystems, Inc. nor the names of its
15*c2c66affSColin Finck  *   contributors may be used to endorse or promote products derived
16*c2c66affSColin Finck  *   from this software without specific prior written permission.
17*c2c66affSColin Finck  *
18*c2c66affSColin Finck  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19*c2c66affSColin Finck  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20*c2c66affSColin Finck  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21*c2c66affSColin Finck  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22*c2c66affSColin Finck  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23*c2c66affSColin Finck  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24*c2c66affSColin Finck  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25*c2c66affSColin Finck  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26*c2c66affSColin Finck  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27*c2c66affSColin Finck  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28*c2c66affSColin Finck  * POSSIBILITY OF SUCH DAMAGE.
29*c2c66affSColin Finck  */
30*c2c66affSColin Finck /*
31*c2c66affSColin Finck  * Generic DES driver interface
32*c2c66affSColin Finck  * Keep this file hardware independent!
33*c2c66affSColin Finck  * Copyright (c) 1986 by Sun Microsystems, Inc.
34*c2c66affSColin Finck  */
35*c2c66affSColin Finck 
36*c2c66affSColin Finck #define DES_MAXLEN 	65536	/* maximum # of bytes to encrypt  */
37*c2c66affSColin Finck #define DES_QUICKLEN	16	/* maximum # of bytes to encrypt quickly */
38*c2c66affSColin Finck 
39*c2c66affSColin Finck enum desdir { ENCRYPT, DECRYPT };
40*c2c66affSColin Finck enum desmode { CBC, ECB };
41*c2c66affSColin Finck 
42*c2c66affSColin Finck /*
43*c2c66affSColin Finck  * parameters to ioctl call
44*c2c66affSColin Finck  */
45*c2c66affSColin Finck struct desparams {
46*c2c66affSColin Finck 	u_char des_key[8];	/* key (with low bit parity) */
47*c2c66affSColin Finck 	enum desdir des_dir;	/* direction */
48*c2c66affSColin Finck 	enum desmode des_mode;	/* mode */
49*c2c66affSColin Finck 	u_char des_ivec[8];	/* input vector */
50*c2c66affSColin Finck 	unsigned des_len;	/* number of bytes to crypt */
51*c2c66affSColin Finck 	union {
52*c2c66affSColin Finck 		u_char UDES_data[DES_QUICKLEN];
53*c2c66affSColin Finck 		u_char *UDES_buf;
54*c2c66affSColin Finck 	} UDES;
55*c2c66affSColin Finck #	define des_data UDES.UDES_data	/* direct data here if quick */
56*c2c66affSColin Finck #	define des_buf	UDES.UDES_buf	/* otherwise, pointer to data */
57*c2c66affSColin Finck };
58*c2c66affSColin Finck 
59*c2c66affSColin Finck #ifdef notdef
60*c2c66affSColin Finck 
61*c2c66affSColin Finck /*
62*c2c66affSColin Finck  * These ioctls are only implemented in SunOS. Maybe someday
63*c2c66affSColin Finck  * if somebody writes a driver for DES hardware that works
64*c2c66affSColin Finck  * with FreeBSD, we can being that back.
65*c2c66affSColin Finck  */
66*c2c66affSColin Finck 
67*c2c66affSColin Finck /*
68*c2c66affSColin Finck  * Encrypt an arbitrary sized buffer
69*c2c66affSColin Finck  */
70*c2c66affSColin Finck #define	DESIOCBLOCK	_IOWR('d', 6, struct desparams)
71*c2c66affSColin Finck 
72*c2c66affSColin Finck /*
73*c2c66affSColin Finck  * Encrypt of small amount of data, quickly
74*c2c66affSColin Finck  */
75*c2c66affSColin Finck #define DESIOCQUICK	_IOWR('d', 7, struct desparams)
76*c2c66affSColin Finck 
77*c2c66affSColin Finck #endif
78*c2c66affSColin Finck 
79*c2c66affSColin Finck /*
80*c2c66affSColin Finck  * Software DES.
81*c2c66affSColin Finck  */
82*c2c66affSColin Finck extern int _des_crypt( char *, int, struct desparams * );
83