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