Curses library problems Medium * Steven W.
[unix-history] / usr.bin / bdes / bdes.1
CommitLineData
44a1bce2
AM
1.\" Copyright (c) 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Matt Bishop of Dartmouth College.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\" notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\" notice, this list of conditions and the following disclaimer in the
14.\" documentation and/or other materials provided with the distribution.
15.\" 3. All advertising materials mentioning features or use of this software
16.\" must display the following acknowledgement:
17.\" This product includes software developed by the University of
18.\" California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\" may be used to endorse or promote products derived from this software
21.\" without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.\" @(#)bdes.1 5.4 (Berkeley) 5/6/91
36.\"
37.TH BDES 1 "May 6, 1991"
38.SH NAME
39bdes \- encrypt/decrypt using the Data Encryption Standard
40.SH SYNOPSIS
41.nf
42.ft B
43bdes [ \-abdp ] [ \-F N ] [ \-f N ] [ \-k key ]
44.ti +5
45[ \-m N ] [ \-o N ] [ \-v vector ]
46.ft R
47.fi
48.SH DESCRIPTION
49.I Bdes
50implements all DES modes of operation described in FIPS PUB 81,
51including alternative cipher feedback mode and both authentication
52modes.
53.I Bdes
54reads from the standard input and writes to the standard output.
55By default, the input is encrypted using cipher block chaining mode.
56Using the same key for encryption and decryption preserves plaintext.
57.PP
58All modes but the electronic code book mode require an initialization
59vector; if none is supplied, the zero vector is used.
60If no
61.I key
62is specified on the command line, the user is prompted for one (see
63.IR getpass (3)
64for more details).
65.PP
66The options are as follows:
67.TP
68\-a
69The key and initialization vector strings are to be taken as ASCII,
70suppressing the special interpretation given to leading ``0X'', ``0x'',
71``0B'', and ``0b'' characters.
72This flag applies to
73.I both
74the key and initialization vector.
75.TP
76\-b
77Use electronic code book mode.
78.TP
79\-d
80Decrypt the input.
81.TP
82\-F
83Use
84.IR N -bit
85alternative cipher feedback mode.
86Currently
87.I N
88must be a multiple of 7 between 7 and 56 inclusive (this does not conform
89to the alternative CFB mode specification).
90.TP
91\-f
92Use
93.IR N -bit
94cipher feedback mode.
95Currently
96.I N
97must be a multiple of 8 between 8 and 64 inclusive (this does not conform
98to the standard CFB mode specification).
99.TP
100\-k
101Use
102.I key
103as the cryptographic key.
104.TP
105\-m
106Compute a message authentication code (MAC) of
107.I N
108bits on the input.
109The value of
110.I N
111must be between 1 and 64 inclusive; if
112.I N
113is not a multiple of 8, enough 0 bits will be added to pad the MAC length
114to the nearest multiple of 8.
115Only the MAC is output.
116MACs are only available in cipher block chaining mode or in cipher feedback
117mode.
118.TP
119\-o
120Use
121.IR N -bit
122output feedback mode.
123Currently
124.I N
125must be a multiple of 8 between 8 and 64 inclusive (this does not conform
126to the OFB mode specification).
127.TP
128\-p
129Disable the resetting of the parity bit.
130This flag forces the parity bit of the key to be used as typed, rather than
131making each character be of odd parity.
132It is used only if the key is given in ASCII.
133.TP
134\-v
135Set the initialization vector to
136.IR vector ;
137the vector is interpreted in the same way as the key.
138The vector is ignored in electronic codebook mode.
139.PP
140The key and initialization vector are taken as sequences of ASCII
141characters which are then mapped into their bit representations.
142If either begins with ``0X'' or ``0x'',
143that one is taken as a sequence of hexadecimal digits indicating the
144bit pattern;
145if either begins with ``0B'' or ``0b'',
146that one is taken as a sequence of binary digits indicating the bit pattern.
147In either case,
148only the leading 64 bits of the key or initialization vector
149are used,
150and if fewer than 64 bits are provided, enough 0 bits are appended
151to pad the key to 64 bits.
152.PP
153According to the DES standard, the low-order bit of each character in the
154key string is deleted.
155Since most ASCII representations set the high-order bit to 0, simply
156deleting the low-order bit effectively reduces the size of the key space
157from 2\u\s-356\s0\d to 2\u\s-348\s0\d keys.
158To prevent this, the high-order bit must be a function depending in part
159upon the low-order bit; so, the high-order bit is set to whatever value
160gives odd parity.
161This preserves the key space size.
162Note this resetting of the parity bit is
163.I not
164done if the key is given in binary or hex, and can be disabled for ASCII
165keys as well.
166.PP
167The DES is considered a very strong cryptosystem, and other than table lookup
168attacks, key search attacks, and Hellman's time-memory tradeoff (all of which
169are very expensive and time-consuming), no cryptanalytic methods for breaking
170the DES are known in the open literature.
171No doubt the choice of keys and key security are the most vulnerable aspect
172of
173.IR bdes .
174.SH IMPLEMENTATION NOTES
175For implementors wishing to write software compatible with this program,
176the following notes are provided.
177This software is believed to be compatible with the implementation of the
178data encryption standard distributed by Sun Microsystems, Inc.
179.PP
180In the ECB and CBC modes, plaintext is encrypted in units of 64 bits (8 bytes,
181also called a block).
182To ensure that the plaintext file is encrypted correctly,
183.I bdes
184will (internally) append from 1 to 8 bytes, the last byte containing an
185integer stating how many bytes of that final block are from the plaintext
186file, and encrypt the resulting block.
187Hence, when decrypting, the last block may contain from 0 to 7 characters
188present in the plaintext file, and the last byte tells how many.
189Note that if during decryption the last byte of the file does not contain an
190integer between 0 and 7, either the file has been corrupted or an incorrect
191key has been given.
192A similar mechanism is used for the OFB and CFB modes, except that those
193simply require the length of the input to be a multiple of the mode size,
194and the final byte contains an integer between 0 and one less than the number
195of bytes being used as the mode.
196(This was another reason that the mode size must be a multiple of 8 for those
197modes.)
198.PP
199Unlike Sun's implementation, unused bytes of that last block are not filled
200with random data, but instead contain what was in those byte positions in
201the preceding block.
202This is quicker and more portable, and does not weaken the encryption
203significantly.
204.PP
205If the key is entered in ASCII, the parity bits of the key characters are set
206so that each key character is of odd parity.
207Unlike Sun's implementation, it is possible to enter binary or hexadecimal
208keys on the command line, and if this is done, the parity bits are
209.I not
210reset.
211This allows testing using arbitrary bit patterns as keys.
212.PP
213The Sun implementation always uses an initialization vector of 0
214(that is, all zeroes).
215By default,
216.I bdes
217does too, but this may be changed from the command line.
218.SH SEE ALSO
219crypt(1), crypt(3), getpass(3)
220.sp
221.IR "Data Encryption Standard" ,
222Federal Information Processing Standard #46,
223National Bureau of Standards,
224U.S. Department of Commerce,
225Washington DC
226(Jan. 1977)
227.sp
228.IR "DES Modes of Operation" ,
229Federal Information Processing Standard #81,
230National Bureau of Standards,
231U.S. Department of Commerce
232Washington DC
233(Dec. 1980)
234.sp
235Dorothy Denning,
236.IR "Cryptography and Data Security" ,
237Addison-Wesley Publishing Co.,
238Reading, MA
239\(co1982.
240.sp
241Matt Bishop,
242.IR "Implementation Notes on bdes(1)"
243Technical Report PCS-TR-91-158,
244Department of Mathematics and Computer Science,
245Dartmouth College,
246Hanover, NH 03755
247(Apr. 1991).
248.SH DISCLAIMER
249.nf
250THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
251ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
252IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
253ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
254FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
255DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
256OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
257HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
258LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
259OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
260SUCH DAMAGE.
261.fi
262.SH BUGS
263There is a controversy raging over whether the DES will still be secure
264in a few years.
265The advent of special-purpose hardware could reduce the cost of any of the
266methods of attack named above so that they are no longer computationally
267infeasible.
268.PP
269As the key or key schedule is stored in memory, the encryption can be
270compromised if memory is readable.
271Additionally, programs which display programs' arguments may compromise the
272key and initialization vector, if they are specified on the command line.
273To avoid this
274.I bdes
275overwrites its arguments, however, the obvious race cannot currently be
276avoided.
277.PP
278Certain specific keys should be avoided because they introduce potential
279weaknesses; these keys, called the
280.I weak
281and
282.I semiweak
283keys, are (in hex notation, where p is either 0 or 1, and P is either
284e or f):
285.sp
286.nf
287.in +10n
288.ta \w'0x0p0p0p0p0p0p0p0p\0\0\0'u+5n
2890x0p0p0p0p0p0p0p0p 0x0p1P0p1P0p0P0p0P
2900x0pep0pep0pfp0pfp 0x0pfP0pfP0pfP0pfP
2910x1P0p1P0p0P0p0P0p 0x1P1P1P1P0P0P0P0P
2920x1Pep1Pep0Pfp0Pfp 0x1PfP1PfP0PfP0PfP
2930xep0pep0pfp0pfp0p 0xep1Pep1pfp0Pfp0P
2940xepepepepepepepep 0xepfPepfPfpfPfpfP
2950xfP0pfP0pfP0pfP0p 0xfP1PfP1PfP0PfP0P
2960xfPepfPepfPepfPep 0xfPfPfPfPfPfPfPfP
297.fi
298.in -10n
299.sp
300This is inherent in the DES algorithm (see Moore and Simmons,
301\*(LqCycle structure of the DES with weak and semi-weak keys,\*(Rq
302.I "Advances in Cryptology \- Crypto '86 Proceedings" ,
303Springer-Verlag New York, \(co1987, pp. 9-32.)