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