8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libbc / inc / include / des / des_crypt.h
blob521da663e1875ef3c1ab7932f65a25f286052228
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 2000 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 * Portions of this source code were derived from Berkeley 4.3 BSD
32 * under license from the Regents of the University of California.
35 #pragma ident "%Z%%M% %I% %E% SMI"
38 * des_crypt.h, des library routine interface
41 #define DES_MAXDATA 8192 /* max bytes encrypted in one call */
42 #define DES_DIRMASK (1 << 0)
43 #define DES_ENCRYPT (0*DES_DIRMASK) /* Encrypt */
44 #define DES_DECRYPT (1*DES_DIRMASK) /* Decrypt */
47 #define DES_DEVMASK (1 << 1)
48 #define DES_HW (0*DES_DEVMASK) /* Use hardware device */
49 #define DES_SW (1*DES_DEVMASK) /* Use software device */
52 #define DESERR_NONE 0 /* succeeded */
53 #define DESERR_NOHWDEVICE 1 /* succeeded, but hw device not available */
54 #define DESERR_HWERROR 2 /* failed, hardware/driver error */
55 #define DESERR_BADPARAM 3 /* failed, bad parameter to call */
57 #define DES_FAILED(err) \
58 ((err) > DESERR_NOHWDEVICE)
61 * cbc_crypt()
62 * ecb_crypt()
64 * Encrypt (or decrypt) len bytes of a buffer buf.
65 * The length must be a multiple of eight.
66 * The key should have odd parity in the low bit of each byte.
67 * ivec is the input vector, and is updated to the new one (cbc only).
68 * The mode is created by oring together the appropriate parameters.
69 * DESERR_NOHWDEVICE is returned if DES_HW was specified but
70 * there was no hardware to do it on (the data will still be
71 * encrypted though, in software).
76 * Cipher Block Chaining mode
78 int
79 cbc_crypt(/* key, buf, len, mode, ivec */); /*
80 char *key;
81 char *buf;
82 unsigned len;
83 unsigned mode;
84 char *ivec;
89 * Electronic Code Book mode
91 int
92 ecb_crypt(/* key, buf, len, mode */); /*
93 char *key;
94 char *buf;
95 unsigned len;
96 unsigned mode;
100 #ifndef KERNEL
102 * Set des parity for a key.
103 * DES parity is odd and in the low bit of each byte
105 void
106 des_setparity(/* key */); /*
107 char *key;
109 #endif