Imported Upstream version 0.2.5
[platform/upstream/libtirpc.git] / man / des_crypt.3t
1 .\" @(#)des_crypt.3     2.1 88/08/11 4.0 RPCSRC; from 1.16 88/03/02 SMI;
2 .\"
3 .Dd October 6, 1987
4 .Dt DES_CRYPT 3
5 .Os
6 .Sh NAME
7 .Nm des_crypt , ecb_crypt , cbc_crypt , des_setparity
8 .Nd "fast DES encryption"
9 .Sh SYNOPSIS
10 .In rpc/des_crypt.h
11 .Ft int
12 .Fn ecb_crypt "char *key" "char *data" "unsigned datalen" "unsigned mode"
13 .Ft int
14 .Fn cbc_crypt "char *key" "char *data" "unsigned datalen" "unsigned mode" "char *ivec"
15 .Ft void
16 .Fn des_setparity "char *key"
17 .Sh DESCRIPTION
18 The
19 .Fn ecb_crypt
20 and
21 .Fn cbc_crypt
22 functions
23 implement the
24 .Tn NBS
25 .Tn DES
26 (Data Encryption Standard).
27 These routines are faster and more general purpose than
28 .Xr crypt 3 .
29 They also are able to utilize
30 .Tn DES
31 hardware if it is available.
32 The
33 .Fn ecb_crypt
34 function
35 encrypts in
36 .Tn ECB
37 (Electronic Code Book)
38 mode, which encrypts blocks of data independently.
39 The
40 .Fn cbc_crypt
41 function
42 encrypts in
43 .Tn CBC
44 (Cipher Block Chaining)
45 mode, which chains together
46 successive blocks.
47 .Tn CBC
48 mode protects against insertions, deletions and
49 substitutions of blocks.
50 Also, regularities in the clear text will
51 not appear in the cipher text.
52 .Pp
53 Here is how to use these routines.
54 The first argument,
55 .Fa key ,
56 is the 8-byte encryption key with parity.
57 To set the key's parity, which for
58 .Tn DES
59 is in the low bit of each byte, use
60 .Fn des_setparity .
61 The second argument,
62 .Fa data ,
63 contains the data to be encrypted or decrypted.
64 The
65 third argument,
66 .Fa datalen ,
67 is the length in bytes of
68 .Fa data ,
69 which must be a multiple of 8.
70 The fourth argument,
71 .Fa mode ,
72 is formed by
73 .Em OR Ns 'ing
74 together some things.
75 For the encryption direction
76 .Em OR
77 in either
78 .Dv DES_ENCRYPT
79 or
80 .Dv DES_DECRYPT .
81 For software versus hardware
82 encryption,
83 .Em OR
84 in either
85 .Dv DES_HW
86 or
87 .Dv DES_SW .
88 If
89 .Dv DES_HW
90 is specified, and there is no hardware, then the encryption is performed
91 in software and the routine returns
92 .Er DESERR_NOHWDEVICE .
93 For
94 .Fn cbc_crypt ,
95 the
96 .Fa ivec
97 argument
98 is the 8-byte initialization
99 vector for the chaining.
100 It is updated to the next initialization
101 vector upon return.
102 .Sh ERRORS
103 .Bl -tag -width [DESERR_NOHWDEVICE] -compact
104 .It Bq Er DESERR_NONE
105 No error.
106 .It Bq Er DESERR_NOHWDEVICE
107 Encryption succeeded, but done in software instead of the requested hardware.
108 .It Bq Er DESERR_HWERR
109 An error occurred in the hardware or driver.
110 .It Bq Er DESERR_BADPARAM
111 Bad argument to routine.
112 .El
113 .Pp
114 Given a result status
115 .Va stat ,
116 the macro
117 .Fn DES_FAILED stat
118 is false only for the first two statuses.
119 .Sh AVAILABILITY
120 The
121 .Fn ecb_crypt ,
122 .Fn cbc_crypt ,
123 and
124 .Fn des_setparity
125 functions are part of libtirpc.
126 .Sh SEE ALSO
127 .\" .Xr des 1 ,
128 .Xr crypt 3
129 .Sh RESTRICTIONS
130 These routines are not available in RPCSRC 4.0.
131 This information is provided to describe the
132 .Tn DES
133 interface expected by
134 Secure RPC.