Debian Codegraph @

upstream/debian-unstable/man3/des_crypt.3

raw
1 '\" t
2 .\" Copyright 1993, Eric Young
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: GPL-1.0-or-later
6 .\"
7 .TH des_crypt 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 des_crypt, ecb_crypt, cbc_crypt, des_setparity, DES_FAILED \- fast
10 DES encryption
11 .SH LIBRARY
12 Standard C library
13 .RI ( libc ,\~ \-lc )
14 .SH SYNOPSIS
15 .nf
16 .\" Sun version
17 .\" .B #include <des_crypt.h>
18 .B #include <rpc/des_crypt.h>
19 .P
20 .BR "[[deprecated]] int ecb_crypt(" "unsigned int datalen;"
21 .BI " char *" key ", char " data [ datalen ],
22 .BI " unsigned int " datalen ", unsigned int " mode );
23 .BR "[[deprecated]] int cbc_crypt(" "unsigned int datalen;"
24 .BI " char *" key ", char " data [ datalen ],
25 .BI " unsigned int " datalen ", unsigned int " mode ,
26 .BI " char *" ivec );
27 .P
28 .BI "[[deprecated]] void des_setparity(char *" key );
29 .P
30 .BI "[[deprecated]] int DES_FAILED(int " status );
31 .fi
32 .SH DESCRIPTION
33 .BR ecb_crypt ()
34 and
35 .BR cbc_crypt ()
36 implement the
37 NBS
38 DES
39 (Data Encryption Standard).
40 These routines are faster and more general purpose than
41 .BR crypt (3).
42 They also are able to utilize
43 DES
44 hardware if it is available.
45 .BR ecb_crypt ()
46 encrypts in
47 ECB
48 (Electronic Code Book)
49 mode, which encrypts blocks of data independently.
50 .BR cbc_crypt ()
51 encrypts in
52 CBC
53 (Cipher Block Chaining)
54 mode, which chains together
55 successive blocks.
56 CBC
57 mode protects against insertions, deletions, and
58 substitutions of blocks.
59 Also, regularities in the clear text will
60 not appear in the cipher text.
61 .P
62 Here is how to use these routines.
63 The first argument,
64 .IR key ,
65 is the 8-byte encryption key with parity.
66 To set the key's parity, which for
67 DES
68 is in the low bit of each byte, use
69 .BR des_setparity ().
70 The second argument,
71 .IR data ,
72 contains the data to be encrypted or decrypted.
73 The
74 third argument,
75 .IR datalen ,
76 is the length in bytes of
77 .IR data ,
78 which must be a multiple of 8.
79 The fourth argument,
80 .IR mode ,
81 is formed by ORing together some things.
82 For the encryption direction OR in either
83 .B DES_ENCRYPT
84 or
85 .BR DES_DECRYPT .
86 For software versus hardware
87 encryption, OR in either
88 .B DES_HW
89 or
90 .BR DES_SW .
91 If
92 .B DES_HW
93 is specified, and there is no hardware, then the encryption is performed
94 in software and the routine returns
95 .BR DESERR_NOHWDEVICE .
96 For
97 .BR cbc_crypt (),
98 the argument
99 .I ivec
100 is the 8-byte initialization
101 vector for the chaining.
102 It is updated to the next initialization
103 vector upon return.
104 .SH RETURN VALUE
105 .TP
106 .B DESERR_NONE
107 No error.
108 .TP
109 .B DESERR_NOHWDEVICE
110 Encryption succeeded, but done in software instead of the requested hardware.
111 .TP
112 .B DESERR_HWERROR
113 An error occurred in the hardware or driver.
114 .TP
115 .B DESERR_BADPARAM
116 Bad argument to routine.
117 .P
118 Given a result status
119 .IR stat ,
120 the macro
121 .\" .BR DES_FAILED\c
122 .\" .BR ( stat )
123 .BI DES_FAILED( stat )
124 is false only for the first two statuses.
125 .\" So far the Sun page
126 .\" Some additions - aeb
127 .SH ATTRIBUTES
128 For an explanation of the terms used in this section, see
129 .BR attributes (7).
130 .TS
131 allbox;
132 lbx lb lb
133 l l l.
134 Interface Attribute Value
135 T{
136 .na
137 .nh
138 .BR ecb_crypt (),
139 .BR cbc_crypt (),
140 .BR des_setparity ()
141 T} Thread safety MT-Safe
142 .TE
143 .SH STANDARDS
144 None.
145 .SH HISTORY
146 4.3BSD.
147 glibc 2.1.
148 Removed in glibc 2.28.
149 .P
150 Because they employ the DES block cipher,
151 which is no longer considered secure,
152 these functions were removed.
153 Applications should switch to a modern cryptography library, such as
154 .BR libgcrypt .
155 .SH SEE ALSO
156 .BR des (1),
157 .BR crypt (3),
158 .BR xcrypt (3)