]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/des_crypt.3
ffix
[thirdparty/man-pages.git] / 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 .TH DES_CRYPT 3 "6 October 1987"
11 .SH NAME
12 des_crypt, ecb_crypt, cbc_crypt, des_setparity, DES_FAILED \- fast
13 DES encryption
14 .SH SYNOPSIS
15 .nf
16 .\" Sun version
17 .\" .B #include <des_crypt.h>
18 .B #include <rpc/des_crypt.h>
19 .LP
20 .BI "int ecb_crypt(char *" key ", char *" data ", unsigned " datalen ,
21 .BI " unsigned " mode );
22 .LP
23 .BI "int cbc_crypt(char *" key ", char *" data ", unsigned " datalen ,
24 .BI " unsigned " mode ", char *" ivec );
25 .LP
26 .BI "void des_setparity(char *" key );
27 .LP
28 .BI "int DES_FAILED(int " status );
29 .fi
30 .SH DESCRIPTION
31 .BR ecb_crypt ()
32 and
33 .BR cbc_crypt ()
34 implement the
35 .SM NBS
36 .SM DES
37 (Data Encryption Standard).
38 These routines are faster and more general purpose than
39 .BR crypt (3).
40 They also are able to utilize
41 .SM DES
42 hardware if it is available.
43 .BR ecb_crypt ()
44 encrypts in
45 .SM ECB
46 (Electronic Code Book)
47 mode, which encrypts blocks of data independently.
48 .BR cbc_crypt ()
49 encrypts in
50 .SM CBC
51 (Cipher Block Chaining)
52 mode, which chains together
53 successive blocks.
54 .SM CBC
55 mode protects against insertions, deletions and
56 substitutions of blocks. Also, regularities in the clear text will
57 not appear in the cipher text.
58 .LP
59 Here is how to use these routines. The first parameter,
60 .IR key ,
61 is the 8-byte encryption key with parity.
62 To set the key's parity, which for
63 .SM DES
64 is in the low bit of each byte, use
65 .BR des_setparity ().
66 The second parameter,
67 .IR data ,
68 contains the data to be encrypted or decrypted. The
69 third parameter,
70 .IR datalen ,
71 is the length in bytes of
72 .IR data ,
73 which must be a multiple of 8. The fourth parameter,
74 .IR mode ,
75 is formed by
76 .SM OR\s0'ing
77 together some things. For the encryption direction 'or' in either
78 .SM DES_ENCRYPT
79 or
80 .SM DES_DECRYPT\s0.
81 For software versus hardware
82 encryption, 'or' in either
83 .SM DES_HW
84 or
85 .SM DES_SW\s0.
86 If
87 .SM DES_HW
88 is specified, and there is no hardware, then the encryption is performed
89 in software and the routine returns
90 .SM DESERR_NOHWDEVICE\s0.
91 For
92 .BR cbc_crypt (),
93 the parameter
94 .I ivec
95 is the 8-byte initialization
96 vector for the chaining. It is updated to the next initialization
97 vector upon return.
98 .SH "SEE ALSO"
99 .BR des (1),
100 .BR crypt (3)
101 .\" added, aeb
102 and
103 .BR xcrypt (3)
104 .SH DIAGNOSTICS
105 .PD 0
106 .TP 20
107 .SM DESERR_NONE
108 No error.
109 .TP
110 .SM DESERR_NOHWDEVICE
111 Encryption succeeded, but done in software instead of the requested hardware.
112 .TP
113 .SM DESERR_HWERROR
114 An error occurred in the hardware or driver.
115 .TP
116 .SM DESERR_BADPARAM
117 Bad parameter to routine.
118 .PD
119 .LP
120 Given a result status
121 .IR stat ,
122 the macro
123 .\" .SM DES_FAILED\c
124 .\" .BR ( stat )
125 .BI DES_FAILED( stat )
126 is false only for the first two statuses.
127 .\" So far the Sun page
128 .\" Some additions - aeb
129 .SH AVAILABILITY
130 These routines are present in libc 4.6.27 and later, and in
131 glibc 2.1 and later.
132 .SH "CONFORMING TO"
133 4.3BSD. Not in POSIX.1-2001.
134