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