2 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH ECB_CRYPT 3EXT "Mar 3, 2008"
8 ecb_crypt, cbc_crypt, des_setparity, DES_FAILED \- fast DES encryption
12 #include <rpc/des_crypt.h>
14 \fBint\fR \fBecb_crypt\fR(\fBchar *\fR\fIkey\fR, \fBchar *\fR\fIdata\fR, \fBunsigned\fR \fIdatalen\fR,
15 \fBunsigned\fR \fImode\fR);
20 \fBint\fR \fBcbc_crypt\fR(\fBchar *\fR\fIkey\fR, \fBchar *\fR\fIdata\fR, \fBunsigned\fR \fIdatalen\fR,
21 \fBunsigned\fR \fImode\fR, \fBchar *\fR\fIivec\fR);
26 \fBvoid\fR \fBdes_setparity\fR(\fBchar *\fR\fIkey\fR);
31 \fBint\fR \fBDES_FAILED\fR(\fBint\fR \fIstat\fR);
37 \fBecb_crypt()\fR and \fBcbc_crypt()\fR implement the \fBNBS\fR \fBDES\fR (Data
38 Encryption Standard). These routines are faster and more general purpose than
39 \fBcrypt\fR(3C). They also are able to utilize \fBDES\fR hardware if it is
40 available. \fBecb_crypt()\fR encrypts in \fBECB\fR (Electronic Code Book) mode,
41 which encrypts blocks of data independently. \fBcbc_crypt()\fR encrypts in
42 \fBCBC\fR (Cipher Block Chaining) mode, which chains together successive
43 blocks. \fBCBC\fR mode protects against insertions, deletions, and
44 substitutions of blocks. Also, regularities in the clear text will not appear
48 The first parameter, \fIkey\fR, is the 8-byte encryption key with parity. To
49 set the key's parity, which for \fBDES\fR is in the low bit of each byte, use
50 \fBdes_setparity()\fR. The second parameter, \fIdata\fR, contains the data to
51 be encrypted or decrypted. The third parameter, \fIdatalen\fR, is the length in
52 bytes of \fIdata\fR, which must be a multiple of 8. The fourth parameter,
53 \fImode\fR, is formed by \fBOR'ing\fR together the \fBDES_ENCRYPT\fR or
54 \fBDES_DECRYPT\fR to specify the encryption direction and \fBDES_HW\fR or
55 \fBDES_SW\fR to specify software or hardware encryption. If \fBDES_HW\fR is
56 specified, and there is no hardware, then the encryption is performed in
57 software and the routine returns \fBDESERR_NOHWDEVICE.\fR
60 For \fBcbc_crypt()\fR, the parameter \fIivec\fR is the 8-byte initialization
61 vector for the chaining. It is updated to the next initialization vector upon
66 Given a result status \fIstat\fR, the macro \fBDES_FAILED\fR is false only for
67 the first two statuses.
71 \fB\fBDESERR_NONE\fR\fR
80 \fB\fBDESERR_NOHWDEVICE\fR\fR
83 Encryption succeeded, but done in software instead of the requested hardware.
89 \fB\fBDESERR_HWERROR\fR\fR
92 An error occurred in the hardware or driver.
98 \fB\fBDESERR_BADPARAM\fR\fR
101 Bad parameter to routine.
107 See \fBattributes\fR(5) for descriptions of the following attributes:
115 ATTRIBUTE TYPE ATTRIBUTE VALUE
123 \fBcrypt\fR(3C), \fBattributes\fR(5)
127 When compiling multi-thread applications, the \fB_REENTRANT\fR flag must be
128 defined on the compile line. This flag should only be used in multi-thread