]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/des_crypt.3
fanotify_init.2, fanotify.7: Document FAN_REPORT_TID
[thirdparty/man-pages.git] / man3 / des_crypt.3
CommitLineData
fea681da
MK
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.
2297bf0e 5.\"
fea681da
MK
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.\"
ffe8c23b
MK
10.\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
11.\" can be distributed under GPL.
12.\" %%%LICENSE_END
13.\"
fe0fefbf 14.TH DES_CRYPT 3 2015-03-02 "" "Linux Programmer's Manual"
fea681da 15.SH NAME
c13182ef 16des_crypt, ecb_crypt, cbc_crypt, des_setparity, DES_FAILED \- fast
35478399 17DES encryption
fea681da
MK
18.SH SYNOPSIS
19.nf
20.\" Sun version
21.\" .B #include <des_crypt.h>
22.B #include <rpc/des_crypt.h>
dd3568a1 23.PP
fea681da
MK
24.BI "int ecb_crypt(char *" key ", char *" data ", unsigned " datalen ,
25.BI " unsigned " mode );
dd3568a1 26.PP
fea681da
MK
27.BI "int cbc_crypt(char *" key ", char *" data ", unsigned " datalen ,
28.BI " unsigned " mode ", char *" ivec );
dd3568a1 29.PP
fea681da 30.BI "void des_setparity(char *" key );
dd3568a1 31.PP
fea681da
MK
32.BI "int DES_FAILED(int " status );
33.fi
34.SH DESCRIPTION
e1d6264d 35.BR ecb_crypt ()
fea681da 36and
e1d6264d 37.BR cbc_crypt ()
fea681da 38implement the
d2d293ba
MK
39NBS
40DES
fea681da
MK
41(Data Encryption Standard).
42These routines are faster and more general purpose than
43.BR crypt (3).
44They also are able to utilize
d2d293ba 45DES
fea681da 46hardware if it is available.
e1d6264d 47.BR ecb_crypt ()
fea681da 48encrypts in
d2d293ba 49ECB
fea681da
MK
50(Electronic Code Book)
51mode, which encrypts blocks of data independently.
e1d6264d 52.BR cbc_crypt ()
fea681da 53encrypts in
d2d293ba 54CBC
fea681da
MK
55(Cipher Block Chaining)
56mode, which chains together
57successive blocks.
d2d293ba 58CBC
fea681da 59mode protects against insertions, deletions and
c13182ef
MK
60substitutions of blocks.
61Also, regularities in the clear text will
fea681da 62not appear in the cipher text.
dd3568a1 63.PP
c13182ef 64Here is how to use these routines.
c4bb193f 65The first argument,
fea681da
MK
66.IR key ,
67is the 8-byte encryption key with parity.
68To set the key's parity, which for
d2d293ba 69DES
fea681da 70is in the low bit of each byte, use
e511ffb6 71.BR des_setparity ().
c4bb193f 72The second argument,
fea681da 73.IR data ,
c13182ef
MK
74contains the data to be encrypted or decrypted.
75The
c4bb193f 76third argument,
fea681da
MK
77.IR datalen ,
78is the length in bytes of
79.IR data ,
c13182ef 80which must be a multiple of 8.
c4bb193f 81The fourth argument,
fea681da 82.IR mode ,
cebca1bd 83is formed by ORing together some things.
84c517a4 84For the encryption direction OR in either
d2d293ba 85.BR DES_ENCRYPT
fea681da 86or
c5a3b127 87.BR DES_DECRYPT .
fea681da 88For software versus hardware
84c517a4 89encryption, OR in either
d2d293ba 90.BR DES_HW
fea681da 91or
c5a3b127 92.BR DES_SW .
fea681da 93If
d2d293ba 94.BR DES_HW
fea681da
MK
95is specified, and there is no hardware, then the encryption is performed
96in software and the routine returns
c5a3b127 97.BR DESERR_NOHWDEVICE .
fea681da 98For
e511ffb6 99.BR cbc_crypt (),
c4bb193f 100the argument
fea681da 101.I ivec
61f4934a 102is the 8-byte initialization
c13182ef
MK
103vector for the chaining.
104It is updated to the next initialization
fea681da 105vector upon return.
8af1ba10 106.SH RETURN VALUE
fea681da
MK
107.PD 0
108.TP 20
d2d293ba 109.BR DESERR_NONE
fea681da
MK
110No error.
111.TP
d2d293ba 112.BR DESERR_NOHWDEVICE
fea681da
MK
113Encryption succeeded, but done in software instead of the requested hardware.
114.TP
d2d293ba 115.BR DESERR_HWERROR
fea681da
MK
116An error occurred in the hardware or driver.
117.TP
d2d293ba 118.BR DESERR_BADPARAM
c4bb193f 119Bad argument to routine.
fea681da 120.PD
dd3568a1 121.PP
fea681da
MK
122Given a result status
123.IR stat ,
124the macro
d2d293ba 125.\" .BR DES_FAILED\c
fea681da
MK
126.\" .BR ( stat )
127.BI DES_FAILED( stat )
128is false only for the first two statuses.
fea681da
MK
129.\" So far the Sun page
130.\" Some additions - aeb
a759cc87 131.SH VERSIONS
fa47e1fb 132These functions are present in
fea681da 133glibc 2.1 and later.
4cdc879a
MK
134.SH VERSIONS
135Because they employ the DES block cipher,
136which is no longer considered secure,
137.BR ecb_crypt (),
138.BR ecb_crypt (),
139.BR crypt_r (),
140and
141.BR des_setparity ()
142were removed in glibc 2.28.
143Applications should switch to a modern cryptography library, such as
144.BR libgcrypt .
adb7cd33 145.SH ATTRIBUTES
8907b78e
MK
146For an explanation of the terms used in this section, see
147.BR attributes (7).
148.TS
149allbox;
09c4d4dd 150lbw25 lb lb
8907b78e
MK
151l l l.
152Interface Attribute Value
153T{
adb7cd33 154.BR ecb_crypt (),
09c4d4dd 155.BR cbc_crypt (),
adb7cd33 156.BR des_setparity ()
8907b78e
MK
157T} Thread safety MT-Safe
158.TE
47297adb 159.SH CONFORMING TO
c13182ef 1604.3BSD.
a9a07374 161Not in POSIX.1.
47297adb 162.SH SEE ALSO
e37e3282 163.BR des (1),
ac5e6a36 164.BR crypt (3),
e37e3282 165.BR xcrypt (3)