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