2 * @(#)des_crypt.h 2.1 88/08/11 4.0 RPCSRC; from 1.4 88/02/08 (C) 1986 SMI
5 * des_crypt.h, des library routine interface
6 * Copyright (C) 1986, Sun Microsystems, Inc.
9 * SPDX-License-Identifier: BSD-3-Clause
11 * Copyright (c) 2009, Sun Microsystems, Inc.
12 * All rights reserved.
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are met:
16 * - Redistributions of source code must retain the above copyright notice,
17 * this list of conditions and the following disclaimer.
18 * - Redistributions in binary form must reproduce the above copyright notice,
19 * this list of conditions and the following disclaimer in the documentation
20 * and/or other materials provided with the distribution.
21 * - Neither the name of Sun Microsystems, Inc. nor the names of its
22 * contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
38 * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
42 * des_crypt.h, des library routine interface
45 #ifndef _DES_DES_CRYPT_H
46 #define _DES_DES_CRYPT_H
48 #include <sys/cdefs.h>
51 #define DES_MAXDATA 8192 /* max bytes encrypted in one call */
52 #define DES_DIRMASK (1 << 0)
53 #define DES_ENCRYPT (0*DES_DIRMASK) /* Encrypt */
54 #define DES_DECRYPT (1*DES_DIRMASK) /* Decrypt */
57 #define DES_DEVMASK (1 << 1)
58 #define DES_HW (0*DES_DEVMASK) /* Use hardware device */
59 #define DES_SW (1*DES_DEVMASK) /* Use software device */
62 #define DESERR_NONE 0 /* succeeded */
63 #define DESERR_NOHWDEVICE 1 /* succeeded, but hw device not available */
64 #define DESERR_HWERROR 2 /* failed, hardware/driver error */
65 #define DESERR_BADPARAM 3 /* failed, bad parameter to call */
67 #define DES_FAILED(err) \
68 ((err) > DESERR_NOHWDEVICE)
74 * Encrypt (or decrypt) len bytes of a buffer buf.
75 * The length must be a multiple of eight.
76 * The key should have odd parity in the low bit of each byte.
77 * ivec is the input vector, and is updated to the new one (cbc only).
78 * The mode is created by oring together the appropriate parameters.
79 * DESERR_NOHWDEVICE is returned if DES_HW was specified but
80 * there was no hardware to do it on (the data will still be
81 * encrypted though, in software).
86 * Cipher Block Chaining mode
89 int cbc_crypt( char *, char *, unsigned int, unsigned int, char *);
93 * Electronic Code Book mode
96 int ecb_crypt( char *, char *, unsigned int, unsigned int );
100 * Set des parity for a key.
101 * DES parity is odd and in the low bit of each byte
104 void des_setparity( char *);
107 #endif /* _DES_DES_CRYPT_H */