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