Deleted Added
sdiff udiff text old ( 50476 ) new ( 57686 )
full compact
1.\" @(#)des_crypt.3 2.1 88/08/11 4.0 RPCSRC; from 1.16 88/03/02 SMI;
2.\" $FreeBSD: head/lib/libc/rpc/des_crypt.3 50476 1999-08-28 00:22:10Z peter $
3.\"
4.TH DES_CRYPT 3 "6 October 1987"
5.SH NAME
6des_crypt, ecb_crypt, cbc_crypt, des_setparity \- fast DES encryption
7.SH SYNOPSIS
8.nf
9.B #include <des_crypt.h>
10.LP
11.B int ecb_crypt(key, data, datalen, mode)
12.B char *key;
13.B char *data;
14.B unsigned datalen;
15.B unsigned mode;
16.LP
17.B int cbc_crypt(key, data, datalen, mode, ivec)
18.B char *key;
19.B char *data;
20.B unsigned datalen;
21.B unsigned mode;
22.B char *ivec;
23.LP
24.B void des_setparity(key)
25.B char *key;
26.fi
27.SH DESCRIPTION
28.IX encryption cbc_crypt "" \fLcbc_crypt\fP
29.IX "des encryption" cbc_crypt "DES encryption" \fLcbc_crypt\fP
30.IX encryption des_setparity "" \fLdes_setparity\fP
31.IX "des encryption" des_setparity "DES encryption" \fLdes_setparity\fP
32.B ecb_crypt(\|)
33and
34.B cbc_crypt(\|)
35implement the
36.SM NBS
37.SM DES
38(Data Encryption Standard).
39These routines are faster and more general purpose than
40.BR crypt (3).
41They also are able to utilize
42.SM DES
43hardware if it is available.
44.B ecb_crypt(\|)
45encrypts in
46.SM ECB
47(Electronic Code Book)
48mode, which encrypts blocks of data independently.
49.B cbc_crypt(\|)
50encrypts in
51.SM CBC
52(Cipher Block Chaining)
53mode, which chains together
54successive blocks.
55.SM CBC
56mode protects against insertions, deletions and
57substitutions of blocks. Also, regularities in the clear text will
58not appear in the cipher text.
59.LP
60Here is how to use these routines. The first parameter,
61.IR key ,
62is the 8-byte encryption key with parity.
63To set the key's parity, which for
64.SM DES
65is in the low bit of each byte, use
66.IR des_setparity .
67The second parameter,
68.IR data ,
69contains the data to be encrypted or decrypted. The
70third parameter,
71.IR datalen ,
72is the length in bytes of
73.IR data ,
74which must be a multiple of 8. The fourth parameter,
75.IR mode ,
76is formed by
77.SM OR\s0'ing
78together some things. For the encryption direction 'or' in either
79.SM DES_ENCRYPT
80or
81.SM DES_DECRYPT\s0.
82For software versus hardware
83encryption, 'or' in either
84.SM DES_HW
85or
86.SM DES_SW\s0.
87If
88.SM DES_HW
89is specified, and there is no hardware, then the encryption is performed
90in software and the routine returns
91.SM DESERR_NOHWDEVICE\s0.
92For
93.IR cbc_crypt ,
94the parameter
95.I ivec
96is the the 8-byte initialization
97vector for the chaining. It is updated to the next initialization
98vector upon return.
99.LP
100.SH "SEE ALSO"
101.BR des (1),
102.BR crypt (3)
103.SH DIAGNOSTICS
104.PD 0
105.TP 20
106.SM DESERR_NONE
107No error.
108.TP
109.SM DESERR_NOHWDEVICE
110Encryption succeeded, but done in software instead of the requested hardware.
111.TP
112.SM DESERR_HWERR
113An error occurred in the hardware or driver.
114.TP
115.SM DESERR_BADPARAM
116Bad parameter to routine.
117.PD
118.LP
119Given a result status
120.IR stat ,
121the macro
122.SM DES_FAILED\c
123.BR ( stat )
124is false only for the first two statuses.
125.SH RESTRICTIONS
126These routines are not available in RPCSRC 4.0.
127This information is provided to describe the DES interface expected by
128Secure RPC.