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