11558Srgrimes/*  @(#)des.h	2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI  */
21558Srgrimes/* $FreeBSD$ */
31558Srgrimes/*-
41558Srgrimes * Copyright (c) 2009, Sun Microsystems, Inc.
51558Srgrimes * All rights reserved.
61558Srgrimes *
71558Srgrimes * Redistribution and use in source and binary forms, with or without
81558Srgrimes * modification, are permitted provided that the following conditions are met:
91558Srgrimes * - Redistributions of source code must retain the above copyright notice,
101558Srgrimes *   this list of conditions and the following disclaimer.
111558Srgrimes * - Redistributions in binary form must reproduce the above copyright notice,
121558Srgrimes *   this list of conditions and the following disclaimer in the documentation
131558Srgrimes *   and/or other materials provided with the distribution.
141558Srgrimes * - Neither the name of Sun Microsystems, Inc. nor the names of its
151558Srgrimes *   contributors may be used to endorse or promote products derived
161558Srgrimes *   from this software without specific prior written permission.
171558Srgrimes *
181558Srgrimes * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
191558Srgrimes * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
201558Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
211558Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
221558Srgrimes * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
231558Srgrimes * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
241558Srgrimes * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
251558Srgrimes * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
261558Srgrimes * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
271558Srgrimes * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
281558Srgrimes * POSSIBILITY OF SUCH DAMAGE.
291558Srgrimes */
301558Srgrimes/*
311558Srgrimes * Generic DES driver interface
321558Srgrimes * Keep this file hardware independent!
33114589Sobrien * Copyright (c) 1986 by Sun Microsystems, Inc.
341558Srgrimes */
3523247Swollman
361558Srgrimes#define DES_MAXLEN 	65536	/* maximum # of bytes to encrypt  */
371558Srgrimes#define DES_QUICKLEN	16	/* maximum # of bytes to encrypt quickly */
381558Srgrimes
391558Srgrimesenum desdir { ENCRYPT, DECRYPT };
401558Srgrimesenum desmode { CBC, ECB };
411558Srgrimes
42114589Sobrien/*
4337671Scharnier * parameters to ioctl call
44114589Sobrien */
45114589Sobrienstruct desparams {
461558Srgrimes	u_char des_key[8];	/* key (with low bit parity) */
471558Srgrimes	enum desdir des_dir;	/* direction */
481558Srgrimes	enum desmode des_mode;	/* mode */
491558Srgrimes	u_char des_ivec[8];	/* input vector */
5037671Scharnier	unsigned des_len;	/* number of bytes to crypt */
511558Srgrimes	union {
521558Srgrimes		u_char UDES_data[DES_QUICKLEN];
531558Srgrimes		u_char *UDES_buf;
541558Srgrimes	} UDES;
551558Srgrimes#	define des_data UDES.UDES_data	/* direct data here if quick */
561558Srgrimes#	define des_buf	UDES.UDES_buf	/* otherwise, pointer to data */
571558Srgrimes};
581558Srgrimes
591558Srgrimes#ifdef notdef
601558Srgrimes
611558Srgrimes/*
621558Srgrimes * These ioctls are only implemented in SunOS. Maybe someday
631558Srgrimes * if somebody writes a driver for DES hardware that works
641558Srgrimes * with FreeBSD, we can being that back.
6523247Swollman */
66109733Smaxim
67109731Smaxim/*
68109733Smaxim * Encrypt an arbitrary sized buffer
69109733Smaxim */
7023247Swollman#define	DESIOCBLOCK	_IOWR('d', 6, struct desparams)
71109733Smaxim
72109733Smaxim/*
73109733Smaxim * Encrypt of small amount of data, quickly
74109733Smaxim */
75109733Smaxim#define DESIOCQUICK	_IOWR('d', 7, struct desparams)
76109733Smaxim
77109733Smaxim#endif
78109733Smaxim
79171135Sgnn/*
80109733Smaxim * Software DES.
81109733Smaxim */
8223247Swollmanextern int _des_crypt( char *, int, struct desparams * );
8323247Swollman