summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorschwarze <>2014-12-02 07:39:58 +0000
committerschwarze <>2014-12-02 07:39:58 +0000
commit8068f015c2050105c1ab16d99b7b03bc027c72d3 (patch)
treea5629da1ec9f12207deaf89ec56235572cc9deb6 /src
parent31c8510c76a513029853bca574d8394c55f6eff5 (diff)
downloadopenbsd-8068f015c2050105c1ab16d99b7b03bc027c72d3.tar.gz
openbsd-8068f015c2050105c1ab16d99b7b03bc027c72d3.tar.bz2
openbsd-8068f015c2050105c1ab16d99b7b03bc027c72d3.zip
macro cleanup; kaspars at bankovskis dot net
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/crypt/crypt.385
-rw-r--r--src/lib/libc/crypt/crypt_checkpass.319
2 files changed, 55 insertions, 49 deletions
diff --git a/src/lib/libc/crypt/crypt.3 b/src/lib/libc/crypt/crypt.3
index 0271e46cbb..9a73c7a515 100644
--- a/src/lib/libc/crypt/crypt.3
+++ b/src/lib/libc/crypt/crypt.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: crypt.3,v 1.42 2014/11/25 03:36:34 tedu Exp $ 1.\" $OpenBSD: crypt.3,v 1.43 2014/12/02 07:39:58 schwarze Exp $
2.\" 2.\"
3.\" FreeSec: libcrypt 3.\" FreeSec: libcrypt
4.\" 4.\"
@@ -31,7 +31,7 @@
31.\" 31.\"
32.\" Manual page, using -mandoc macros 32.\" Manual page, using -mandoc macros
33.\" 33.\"
34.Dd $Mdocdate: November 25 2014 $ 34.Dd $Mdocdate: December 2 2014 $
35.Dt CRYPT 3 35.Dt CRYPT 3
36.Os 36.Os
37.Sh NAME 37.Sh NAME
@@ -71,21 +71,27 @@ and
71The 71The
72.Fn crypt 72.Fn crypt
73function performs password hashing based on the 73function performs password hashing based on the
74.Tn NBS 74NBS Data Encryption Standard (DES).
75Data Encryption Standard (DES).
76Additional code has been added to deter key search attempts and to use 75Additional code has been added to deter key search attempts and to use
77stronger hashing algorithms. 76stronger hashing algorithms.
78.Pp 77.Pp
79The first argument to 78The first argument to
80.Fn crypt 79.Fn crypt
81is a 80is a NUL-terminated
82.Dv NUL Ns -terminated 81string
83string, typically a user's typed password. 82.Fa key ,
84The second is in one of three forms: 83typically a user's typed password.
84The second,
85.Fa setting ,
86is in one of three forms:
85if it begins with an underscore 87if it begins with an underscore
86.Pq Ql _ 88.Pq Ql _
87then an extended format is used 89then an extended format is used
88in interpreting both the key and the setting, as outlined below. 90in interpreting both the
91.Fa key
92and the
93.Fa setting ,
94as outlined below.
89If it begins 95If it begins
90with a string character 96with a string character
91.Pq Ql $ 97.Pq Ql $
@@ -95,7 +101,7 @@ At the moment
95chooses Blowfish hashing; see below for more information. 101chooses Blowfish hashing; see below for more information.
96.Ss Extended crypt 102.Ss Extended crypt
97The 103The
98.Ar key 104.Fa key
99is divided into groups of 8 characters (the last group is null-padded) 105is divided into groups of 8 characters (the last group is null-padded)
100and the low-order 7 bits of each character (56 bits per group) are 106and the low-order 7 bits of each character (56 bits per group) are
101used to form the DES key as follows: 107used to form the DES key as follows:
@@ -103,7 +109,9 @@ the first group of 56 bits becomes the initial DES key.
103For each additional group, the XOR of the encryption of the current DES 109For each additional group, the XOR of the encryption of the current DES
104key with itself and the group bits becomes the next DES key. 110key with itself and the group bits becomes the next DES key.
105.Pp 111.Pp
106The setting is a 9-character array consisting of an underscore followed 112The
113.Fa setting
114is a 9-character array consisting of an underscore followed
107by 4 bytes of iteration count and 4 bytes of salt. 115by 4 bytes of iteration count and 4 bytes of salt.
108These are encoded as printable characters, 6 bits per character, 116These are encoded as printable characters, 6 bits per character,
109least significant character first. 117least significant character first.
@@ -113,15 +121,12 @@ This allows 24 bits for both
113.Fa count 121.Fa count
114and 122and
115.Fa salt . 123.Fa salt .
116.Ss "Blowfish" crypt 124.Ss Blowfish crypt
117The 125The Blowfish version of crypt has 128 bits of
118.Tn Blowfish
119version of crypt has 128 bits of
120.Fa salt 126.Fa salt
121in order to make building dictionaries of common passwords space consuming. 127in order to make building dictionaries of common passwords space consuming.
122The initial state of the 128The initial state of the
123.Tn Blowfish 129Blowfish cipher is expanded using the
124cipher is expanded using the
125.Fa salt 130.Fa salt
126and the 131and the
127.Fa password 132.Fa password
@@ -132,9 +137,7 @@ The final Blowfish password entry is created by encrypting the string
132.Pp 137.Pp
133.Dq OrpheanBeholderScryDoubt 138.Dq OrpheanBeholderScryDoubt
134.Pp 139.Pp
135with the 140with the Blowfish state 64 times.
136.Tn Blowfish
137state 64 times.
138.Pp 141.Pp
139The version number, the logarithm of the number of rounds and 142The version number, the logarithm of the number of rounds and
140the concatenation of salt and hashed password are separated by the 143the concatenation of salt and hashed password are separated by the
@@ -150,13 +153,15 @@ A valid Blowfish password looks like this:
150The whole Blowfish password string is passed as 153The whole Blowfish password string is passed as
151.Fa setting 154.Fa setting
152for interpretation. 155for interpretation.
153.Ss "Traditional" crypt 156.Ss Traditional crypt
154The first 8 bytes of the key are null-padded, and the low-order 7 bits of 157The first 8 bytes of the
155each character is used to form the 56-bit 158.Fa key
156.Tn DES 159are null-padded, and the low-order 7 bits of
157key. 160each character is used to form the 56-bit DES key.
158.Pp 161.Pp
159The setting is a 2-character array of the ASCII-encoded salt. 162The
163.Fa setting
164is a 2-character array of the ASCII-encoded salt.
160Thus only 12 bits of 165Thus only 12 bits of
161.Fa salt 166.Fa salt
162are used. 167are used.
@@ -165,29 +170,24 @@ is set to 25.
165.Ss DES Algorithm 170.Ss DES Algorithm
166The 171The
167.Fa salt 172.Fa salt
168introduces disorder in the 173introduces disorder in the DES
169.Tn DES
170algorithm in one of 16777216 or 4096 possible ways 174algorithm in one of 16777216 or 4096 possible ways
171(i.e., with 24 or 12 bits: if bit 175(i.e., with 24 or 12 bits: if bit
172.Em i 176.Em i
173of the 177of the
174.Ar salt 178.Fa salt
175is set, then bits 179is set, then bits
176.Em i 180.Em i
177and 181and
178.Em i+24 182.Em i+24
179are swapped in the 183are swapped in the DES E-box output).
180.Tn DES
181E-box output).
182.Pp 184.Pp
183The DES key is used to encrypt a 64-bit constant using 185The DES key is used to encrypt a 64-bit constant using
184.Ar count 186.Fa count
185iterations of 187iterations of DES.
186.Tn DES . 188The value returned is a NUL-terminated
187The value returned is a
188.Dv NUL Ns -terminated
189string, 20 or 13 bytes (plus NUL) in length, consisting of the 189string, 20 or 13 bytes (plus NUL) in length, consisting of the
190.Ar setting 190.Fa setting
191followed by the encoded 64-bit encryption. 191followed by the encoded 64-bit encryption.
192.Pp 192.Pp
193The functions 193The functions
@@ -197,8 +197,7 @@ The functions
197and 197and
198.Fn des_cipher 198.Fn des_cipher
199provide access to the 199provide access to the
200.Tn DES 200DES algorithm itself.
201algorithm itself.
202.Fn setkey 201.Fn setkey
203is passed a 64-byte array of binary values (numeric 0 or 1). 202is passed a 64-byte array of binary values (numeric 0 or 1).
204A 56-bit key is extracted from this array by dividing the 203A 56-bit key is extracted from this array by dividing the
@@ -237,16 +236,14 @@ using
237.Xr abs 3 236.Xr abs 3
238of 237of
239.Fa count 238.Fa count
240iterations of 239iterations of DES
241.Tn DES
242and stores the 64-bit result in the 8 characters at 240and stores the 64-bit result in the 8 characters at
243.Fa out 241.Fa out
244(which may be the same as 242(which may be the same as
245.Fa in ) . 243.Fa in ) .
246The 244The
247.Fa salt 245.Fa salt
248specifies perturbations to the 246specifies perturbations to the DES
249.Tn DES
250E-box output as described above. 247E-box output as described above.
251.Pp 248.Pp
252The 249The
diff --git a/src/lib/libc/crypt/crypt_checkpass.3 b/src/lib/libc/crypt/crypt_checkpass.3
index fd60523502..09f2d02796 100644
--- a/src/lib/libc/crypt/crypt_checkpass.3
+++ b/src/lib/libc/crypt/crypt_checkpass.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: crypt_checkpass.3,v 1.4 2014/11/21 12:52:54 jmc Exp $ 1.\" $OpenBSD: crypt_checkpass.3,v 1.5 2014/12/02 07:39:58 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: November 21 2014 $ 17.Dd $Mdocdate: December 2 2014 $
18.Dt CRYPT_CHECKPASS 3 18.Dt CRYPT_CHECKPASS 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -31,10 +31,19 @@
31The 31The
32.Fn crypt_checkpass 32.Fn crypt_checkpass
33function is provided to simplify checking a user's password. 33function is provided to simplify checking a user's password.
34If both the hash and the password are the empty string, authentication 34If both the
35.Fa hash
36and the
37.Fa password
38are the empty string, authentication
35is a success. 39is a success.
36Otherwise, the password is hashed and compared to the provided hash. 40Otherwise, the
37If the hash is 41.Fa password
42is hashed and compared to the provided
43.Fa hash .
44If the
45.Fa hash
46is
38.Dv NULL , 47.Dv NULL ,
39authentication will always fail, but a default 48authentication will always fail, but a default
40amount of work is performed to simulate the hashing operation. 49amount of work is performed to simulate the hashing operation.