OSDN Git Service

LDP: Update original to LDP v3.68
[linuxjm/LDP_man-pages.git] / original / man3 / des_crypt.3
1 .\" @(#)des_crypt.3     2.1 88/08/11 4.0 RPCSRC; from 1.16 88/03/02 SMI;
2 .\"
3 .\" Taken from libc4 sources, which say:
4 .\" Copyright (C) 1993 Eric Young - can be distributed under GPL.
5 .\"
6 .\" However, the above header line suggests that this file in fact is
7 .\" Copyright Sun Microsystems, Inc (and is provided for unrestricted use,
8 .\" see other Sun RPC sources).
9 .\"
10 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
11 .\" can be distributed under GPL.
12 .\" %%%LICENSE_END
13 .\"
14 .TH DES_CRYPT 3  2013-09-18 "" "Linux Programmer's Manual"
15 .SH NAME
16 des_crypt, ecb_crypt, cbc_crypt, des_setparity, DES_FAILED \- fast
17 DES encryption
18 .SH SYNOPSIS
19 .nf
20 .\" Sun version
21 .\" .B #include <des_crypt.h>
22 .B #include <rpc/des_crypt.h>
23 .LP
24 .BI "int ecb_crypt(char *" key ", char *" data ", unsigned " datalen ,
25 .BI "              unsigned " mode );
26 .LP
27 .BI "int cbc_crypt(char *" key ", char *" data ", unsigned " datalen ,
28 .BI "              unsigned " mode ", char *" ivec );
29 .LP
30 .BI "void des_setparity(char *" key );
31 .LP
32 .BI "int DES_FAILED(int " status );
33 .fi
34 .SH DESCRIPTION
35 .BR ecb_crypt ()
36 and
37 .BR cbc_crypt ()
38 implement the
39 NBS
40 DES
41 (Data Encryption Standard).
42 These routines are faster and more general purpose than
43 .BR crypt (3).
44 They also are able to utilize
45 DES
46 hardware if it is available.
47 .BR ecb_crypt ()
48 encrypts in
49 ECB
50 (Electronic Code Book)
51 mode, which encrypts blocks of data independently.
52 .BR cbc_crypt ()
53 encrypts in
54 CBC
55 (Cipher Block Chaining)
56 mode, which chains together
57 successive blocks.
58 CBC
59 mode protects against insertions, deletions and
60 substitutions of blocks.
61 Also, regularities in the clear text will
62 not appear in the cipher text.
63 .LP
64 Here is how to use these routines.
65 The first argument,
66 .IR key ,
67 is the 8-byte encryption key with parity.
68 To set the key's parity, which for
69 DES
70 is in the low bit of each byte, use
71 .BR des_setparity ().
72 The second argument,
73 .IR data ,
74 contains the data to be encrypted or decrypted.
75 The
76 third argument,
77 .IR datalen ,
78 is the length in bytes of
79 .IR data ,
80 which must be a multiple of 8.
81 The fourth argument,
82 .IR mode ,
83 is formed by ORing together some things.
84 For the encryption direction OR in either
85 .BR DES_ENCRYPT
86 or
87 .BR DES_DECRYPT .
88 For software versus hardware
89 encryption, OR in either
90 .BR DES_HW
91 or
92 .BR DES_SW .
93 If
94 .BR DES_HW
95 is specified, and there is no hardware, then the encryption is performed
96 in software and the routine returns
97 .BR DESERR_NOHWDEVICE .
98 For
99 .BR cbc_crypt (),
100 the argument
101 .I ivec
102 is the 8-byte initialization
103 vector for the chaining.
104 It is updated to the next initialization
105 vector upon return.
106 .SH RETURN VALUE
107 .PD 0
108 .TP 20
109 .BR DESERR_NONE
110 No error.
111 .TP
112 .BR DESERR_NOHWDEVICE
113 Encryption succeeded, but done in software instead of the requested hardware.
114 .TP
115 .BR DESERR_HWERROR
116 An error occurred in the hardware or driver.
117 .TP
118 .BR DESERR_BADPARAM
119 Bad argument to routine.
120 .PD
121 .LP
122 Given a result status
123 .IR stat ,
124 the macro
125 .\" .BR DES_FAILED\c
126 .\" .BR ( stat )
127 .BI DES_FAILED( stat )
128 is false only for the first two statuses.
129 .\" So far the Sun page
130 .\" Some additions - aeb
131 .SH VERSIONS
132 These routines are present in libc 4.6.27 and later, and in
133 glibc 2.1 and later.
134 .SH ATTRIBUTES
135 .SS Multithreading (see pthreads(7))
136 The
137 .BR ecb_crypt (),
138 .BR cbc_crypt (),
139 and
140 .BR des_setparity ()
141 functions are thread-safe.
142 .SH CONFORMING TO
143 4.3BSD.
144 Not in POSIX.1-2001.
145 .SH SEE ALSO
146 .BR des (1),
147 .BR crypt (3),
148 .BR xcrypt (3)
149 .SH COLOPHON
150 This page is part of release 3.68 of the Linux
151 .I man-pages
152 project.
153 A description of the project,
154 information about reporting bugs,
155 and the latest version of this page,
156 can be found at
157 \%http://www.kernel.org/doc/man\-pages/.