126209Swpaul/*  @(#)des.h	2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI  */
283265Speter/* $FreeBSD$ */
3261057Smav/*-
4261057Smav * Copyright (c) 2009, Sun Microsystems, Inc.
5261057Smav * All rights reserved.
6261057Smav *
7261057Smav * Redistribution and use in source and binary forms, with or without
8261057Smav * modification, are permitted provided that the following conditions are met:
9261057Smav * - Redistributions of source code must retain the above copyright notice,
10261057Smav *   this list of conditions and the following disclaimer.
11261057Smav * - Redistributions in binary form must reproduce the above copyright notice,
12261057Smav *   this list of conditions and the following disclaimer in the documentation
13261057Smav *   and/or other materials provided with the distribution.
14261057Smav * - Neither the name of Sun Microsystems, Inc. nor the names of its
15261057Smav *   contributors may be used to endorse or promote products derived
16261057Smav *   from this software without specific prior written permission.
17261057Smav *
18261057Smav * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19261057Smav * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20261057Smav * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21261057Smav * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22261057Smav * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23261057Smav * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24261057Smav * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25261057Smav * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26261057Smav * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27261057Smav * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28261057Smav * POSSIBILITY OF SUCH DAMAGE.
2926209Swpaul */
3026209Swpaul/*
3126209Swpaul * Generic DES driver interface
3226209Swpaul * Keep this file hardware independent!
3326209Swpaul * Copyright (c) 1986 by Sun Microsystems, Inc.
3426209Swpaul */
3526209Swpaul
3626209Swpaul#define DES_MAXLEN 	65536	/* maximum # of bytes to encrypt  */
3726209Swpaul#define DES_QUICKLEN	16	/* maximum # of bytes to encrypt quickly */
3826209Swpaul
3926209Swpaulenum desdir { ENCRYPT, DECRYPT };
4026209Swpaulenum desmode { CBC, ECB };
4126209Swpaul
4226209Swpaul/*
4326209Swpaul * parameters to ioctl call
4426209Swpaul */
4526209Swpaulstruct desparams {
4626209Swpaul	u_char des_key[8];	/* key (with low bit parity) */
4726209Swpaul	enum desdir des_dir;	/* direction */
4826209Swpaul	enum desmode des_mode;	/* mode */
4926209Swpaul	u_char des_ivec[8];	/* input vector */
5026209Swpaul	unsigned des_len;	/* number of bytes to crypt */
5126209Swpaul	union {
5226209Swpaul		u_char UDES_data[DES_QUICKLEN];
5326209Swpaul		u_char *UDES_buf;
5426209Swpaul	} UDES;
5526209Swpaul#	define des_data UDES.UDES_data	/* direct data here if quick */
5626209Swpaul#	define des_buf	UDES.UDES_buf	/* otherwise, pointer to data */
5726209Swpaul};
5826209Swpaul
5939661Swpaul#ifdef notdef
6039661Swpaul
6126209Swpaul/*
6239661Swpaul * These ioctls are only implemented in SunOS. Maybe someday
6339661Swpaul * if somebody writes a driver for DES hardware that works
6439661Swpaul * with FreeBSD, we can being that back.
6539661Swpaul */
6639661Swpaul
6739661Swpaul/*
6826209Swpaul * Encrypt an arbitrary sized buffer
6926209Swpaul */
7083265Speter#define	DESIOCBLOCK	_IOWR('d', 6, struct desparams)
7126209Swpaul
7226209Swpaul/*
7326209Swpaul * Encrypt of small amount of data, quickly
7426209Swpaul */
7583265Speter#define DESIOCQUICK	_IOWR('d', 7, struct desparams)
7626209Swpaul
7739661Swpaul#endif
7839661Swpaul
7926209Swpaul/*
8026209Swpaul * Software DES.
8126209Swpaul */
8293032Simpextern int _des_crypt( char *, int, struct desparams * );
83