1 .\" $OpenBSD: crypt.3,v 1.5 1996/12/10 09:06:09 deraadt Exp $
5 .\" Copyright (c) 1994 David Burren
6 .\" All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 4. Neither the name of the author nor the names of other contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" Manual page, using -mandoc macros
43 .Fd #include <unistd.h>
47 .Fa "const char *salt"
54 .Fd #include <stdlib.h>
62 function performs password encryption, based on the
64 Data Encryption Standard (DES).
65 Additional code has been added to deter key search attempts.
69 .Dv null Ns -terminated
70 string, typically a user's typed password.
71 The second is in one of two forms:
72 if it begins with an underscore (``_''), an extended format is used
73 in interpreting both the key and the salt value, as outlined below.
78 is divided into groups of 8 characters (the last group is null-padded)
79 and the low-order 7 bits of each each character (56 bits per group) are
80 used to form the DES key as follows:
81 the first group of 56 bits becomes the initial DES key.
82 For each additional group, the XOR of the encryption of the current DES
83 key with itself and the group bits becomes the next DES key.
87 is a 9-character array consisting of an underscore, followed
88 by 4 bytes of iteration count and 4 bytes of salt.
89 These are encoded as printable characters, 6 bits per character,
90 least significant character first.
91 The values 0 to 63 are encoded as ``./0-9A-Za-z''.
92 This allows 24 bits for both
96 .Ss "Traditional" crypt:
98 The first 8 bytes of the key are null-padded, and the low-order 7 bits of
99 each character is used to form the 56-bit
105 is a 2-character array of the ASCII-encoded salt.
106 Thus, only 12 bits of salt are used.
113 introduces disorder in the
115 algorithm in one of 16777216 or 4096 possible ways
116 (ie. with 24 or 12 bits: if bit
128 The DES key is used to encrypt a 64-bit constant, using
132 The value returned is a
133 .Dv null Ns -terminated
134 string, 20 or 13 bytes (plus null) in length, consisting of the
136 followed by the encoded 64-bit encryption.
142 provide access to the
146 is passed a 64-byte array of binary values (numeric 0 or 1).
147 A 56-bit key is extracted from this array by dividing the
148 array into groups of 8 and ignoring the last bit in each group.
149 That bit is reserved for a byte parity check by DES, but is ignored
156 is also a 64-byte array of binary values.
161 is encrypted; otherwise, it is decrypted.
162 The result is returned in the original array
164 after using the key specified by
170 returns a pointer to the encrypted value on success, and NULL on failure.
176 functions all manipulate the same key space.
184 .Fd #include <unistd.h>
195 returns 0 on success and 1 on failure.
200 .Fa "const char *key"
205 is necessary and sufficient for the
211 function returns a pointer to static data, and subsequent calls to
213 will modify the same object.
224 This library (FreeSec 1.0) was developed outside the United States of America
225 as an unencumbered replacement for the U.S.-only libcrypt encryption
227 Programs linked against the
229 interface may be exported from the U.S.A. only if they use
231 solely for authentication purposes and avoid use of
232 the other programmer interfaces listed above. Special care has been taken
233 in the library so that programs which only use the
235 interface do not pull in the other components.
237 David Burren <davidb@werj.com.au>