summaryrefslogtreecommitdiff
path: root/src/lib/libc/crypt
diff options
context:
space:
mode:
authoraaron <>2000-04-18 02:31:34 +0000
committeraaron <>2000-04-18 02:31:34 +0000
commit59ca3f5f8991ab72904434fb49ef0999d64ae2e8 (patch)
tree1dd6f422d13137d3acf29ca8d4d3e3b69d122d98 /src/lib/libc/crypt
parent6c6b1d3d1d43480c21468b276a64c1fb7d82c152 (diff)
downloadopenbsd-59ca3f5f8991ab72904434fb49ef0999d64ae2e8.tar.gz
openbsd-59ca3f5f8991ab72904434fb49ef0999d64ae2e8.tar.bz2
openbsd-59ca3f5f8991ab72904434fb49ef0999d64ae2e8.zip
Repairs.
Diffstat (limited to 'src/lib/libc/crypt')
-rw-r--r--src/lib/libc/crypt/arc4random.310
-rw-r--r--src/lib/libc/crypt/blowfish.35
-rw-r--r--src/lib/libc/crypt/crypt.3105
3 files changed, 69 insertions, 51 deletions
diff --git a/src/lib/libc/crypt/arc4random.3 b/src/lib/libc/crypt/arc4random.3
index f4116a1e82..2bf63eca72 100644
--- a/src/lib/libc/crypt/arc4random.3
+++ b/src/lib/libc/crypt/arc4random.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: arc4random.3,v 1.13 2000/04/15 02:15:22 aaron Exp $ 1.\" $OpenBSD: arc4random.3,v 1.14 2000/04/18 02:31:34 aaron Exp $
2.\" 2.\"
3.\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> 3.\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
4.\" All rights reserved. 4.\" All rights reserved.
@@ -50,8 +50,8 @@
50The 50The
51.Fn arc4random 51.Fn arc4random
52function uses the key stream generator employed by the 52function uses the key stream generator employed by the
53arc4 cipher, which uses 8*8 8 bit S-Boxes. The S-Boxes 53arc4 cipher, which uses 8*8 8 bit S-Boxes.
54can be in about (2**1700) states. 54The S-Boxes can be in about (2**1700) states.
55.Pp 55.Pp
56The 56The
57.Fn arc4random_stir 57.Fn arc4random_stir
@@ -74,8 +74,8 @@ automatically initializes itself.
74.Sh HISTORY 74.Sh HISTORY
75An algorithm call 75An algorithm call
76.Pa RC4 76.Pa RC4
77was designed by RSA Data Security, Inc. It was considered a trade secret, 77was designed by RSA Data Security, Inc.
78but not trademarked. 78It was considered a trade secret, but not trademarked.
79A clone of this was posted anonymously to the USENET and was confirmed to 79A clone of this was posted anonymously to the USENET and was confirmed to
80be equivalent by several sources who had access to the original cipher. 80be equivalent by several sources who had access to the original cipher.
81Because of the trade secret situation, RSA Data Security, Inc. can do 81Because of the trade secret situation, RSA Data Security, Inc. can do
diff --git a/src/lib/libc/crypt/blowfish.3 b/src/lib/libc/crypt/blowfish.3
index b5fdae92b1..6d8c5db88d 100644
--- a/src/lib/libc/crypt/blowfish.3
+++ b/src/lib/libc/crypt/blowfish.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: blowfish.3,v 1.8 2000/04/15 02:15:22 aaron Exp $ 1.\" $OpenBSD: blowfish.3,v 1.9 2000/04/18 02:31:34 aaron Exp $
2.\" 2.\"
3.\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> 3.\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
4.\" All rights reserved. 4.\" All rights reserved.
@@ -63,7 +63,8 @@ The block size is 64 bit and the key size is maximal 448 bit.
63The 63The
64.Fn blf_key 64.Fn blf_key
65function initializes the 4 8bit S-boxes and the 18 Subkeys with 65function initializes the 4 8bit S-boxes and the 18 Subkeys with
66the hexadecimal digits of Pi. The key is used for further randomization. 66the hexadecimal digits of Pi.
67The key is used for further randomization.
67The first argument to 68The first argument to
68.Fn blf_enc 69.Fn blf_enc
69is the initialized state derived from 70is the initialized state derived from
diff --git a/src/lib/libc/crypt/crypt.3 b/src/lib/libc/crypt/crypt.3
index daa9c4d844..36058c7567 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.15 2000/04/15 02:15:22 aaron Exp $ 1.\" $OpenBSD: crypt.3,v 1.16 2000/04/18 02:31:34 aaron Exp $
2.\" 2.\"
3.\" FreeSec: libcrypt 3.\" FreeSec: libcrypt
4.\" 4.\"
@@ -56,24 +56,32 @@
56.Sh DESCRIPTION 56.Sh DESCRIPTION
57The 57The
58.Fn crypt 58.Fn crypt
59function performs password encryption, based on the 59function performs password encryption based on the
60.Tn NBS 60.Tn NBS
61Data Encryption Standard (DES). 61Data Encryption Standard (DES).
62Additional code has been added to deter key search attempts and to use 62Additional code has been added to deter key search attempts and to use
63stronger hashing algorithms. 63stronger hashing algorithms.
64.Pp
64The first argument to 65The first argument to
65.Fn crypt 66.Fn crypt
66is a 67is a
67.Dv null Ns -terminated 68.Dv null Ns -terminated
68string, typically a user's typed password. 69string, typically a user's typed password.
69The second is in one of three forms: 70The second is in one of three forms:
70if it begins with an underscore (``_'') then an extended format is used 71if it begins with an underscore
71in interpreting both the key and the setting, as outlined below. If it begins 72.Pq Ql _
72with an string character (``$'') and a number then a different algorithm 73then an extended format is used
73is used depending on the number. At the moment a ``$1'' chooses MD5 hashing 74in interpreting both the key and the setting, as outlined below.
74and a ``$2'' chooses Blowfish hashing, see below for more information. 75If it begins
75.Ss Extended crypt: 76with a string character
76.Pp 77.Pq Ql $
78and a number then a different algorithm is used depending on the number.
79At the moment a
80.Ql $1
81chooses MD5 hashing and a
82.Ql $2
83chooses Blowfish hashing; see below for more information.
84.Ss Extended crypt
77The 85The
78.Ar key 86.Ar key
79is divided into groups of 8 characters (the last group is null-padded) 87is divided into groups of 8 characters (the last group is null-padded)
@@ -87,61 +95,68 @@ The setting is a 9-character array consisting of an underscore followed
87by 4 bytes of iteration count and 4 bytes of salt. 95by 4 bytes of iteration count and 4 bytes of salt.
88These are encoded as printable characters, 6 bits per character, 96These are encoded as printable characters, 6 bits per character,
89least significant character first. 97least significant character first.
90The values 0 to 63 are encoded as ``./0-9A-Za-z''. 98The values 0 to 63 are encoded as
99.Dq \&./0-9A-Za-z .
91This allows 24 bits for both 100This allows 24 bits for both
92.Fa count 101.Fa count
93and 102and
94.Fa salt . 103.Fa salt .
95.Ss "MD5" crypt: 104.Ss "MD5" crypt
96.Pp
97For 105For
98.Tn MD5 106.Tn MD5
99crypt the version number, 107crypt the version number,
100.Fa salt 108.Fa salt
101and the hashed password are separated 109and the hashed password are separated by the
102by the ``$'' character. The maximum length of a password is limited by 110.Ql $
111character.
112The maximum length of a password is limited by
103the length counter of the MD5 context, which is about 113the length counter of the MD5 context, which is about
1042**64. A valid MD5 password entry looks like this: 1142**64.
115A valid MD5 password entry looks like this:
105.Pp 116.Pp
106``$1$caeiHQwX$hsKqOjrFRRN6K32OWkCBf1''. 117.Dq $1$caeiHQwX$hsKqOjrFRRN6K32OWkCBf1 .
107.Pp 118.Pp
108The whole MD5 password string is passed as 119The whole MD5 password string is passed as
109.Fa setting 120.Fa setting
110for interpretation. 121for interpretation.
111.Ss "Blowfish" crypt: 122.Ss "Blowfish" crypt
112.Pp
113The 123The
114.Tn Blowfish 124.Tn Blowfish
115version of crypt has 128 bits of 125version of crypt has 128 bits of
116.Fa salt 126.Fa salt
117in order to make building 127in order to make building dictionaries of common passwords space consuming.
118dictionaries of common passwords space consuming. The initial state 128The initial state of the
119of the
120.Tn Blowfish 129.Tn Blowfish
121cipher is expanded using the 130cipher is expanded using the
122.Fa salt 131.Fa salt
123and the 132and the
124.Fa password 133.Fa password
125repeating the process a variable number of rounds, which is encoded in 134repeating the process a variable number of rounds, which is encoded in
126the password string. The maximum password length is 72. The final Blowfish 135the password string.
127password entry is created by encrypting 136The maximum password length is 72.
128the string ``OrpheanBeholderScryDoubt'' with the 137The final Blowfish password entry is created by encrypting the string
138.Pp
139.Dq OrpheanBeholderScryDoubt
140.Pp
141with the
129.Tn Blowfish 142.Tn Blowfish
130state 64 times. 143state 64 times.
131.Pp 144.Pp
132The version number, the logarithm of the number of rounds and 145The version number, the logarithm of the number of rounds and
133the concatenation of salt and 146the concatenation of salt and hashed password are separated by the
134hashed password are separated by the ``$'' character. An encoded ``8'' 147.Ql $
148character.
149An encoded
150.Sq 8
135would specify 256 rounds. 151would specify 256 rounds.
136A valid Blowfish password looks like this: 152A valid Blowfish password looks like this:
137.Pp 153.Pp
138``$2a$12$eIAq8PR8sIUnJ1HaohxX2O9x9Qlm2vK97LJ5dsXdmB.eXF42qjchC''. 154.Dq $2a$12$eIAq8PR8sIUnJ1HaohxX2O9x9Qlm2vK97LJ5dsXdmB.eXF42qjchC .
139.Pp 155.Pp
140The whole Blowfish password string is passed as 156The whole Blowfish password string is passed as
141.Fa setting 157.Fa setting
142for interpretation. 158for interpretation.
143.Ss "Traditional" crypt: 159.Ss "Traditional" crypt
144.Pp
145The first 8 bytes of the key are null-padded, and the low-order 7 bits of 160The first 8 bytes of the key are null-padded, and the low-order 7 bits of
146each character is used to form the 56-bit 161each character is used to form the 56-bit
147.Tn DES 162.Tn DES
@@ -153,8 +168,7 @@ Thus only 12 bits of
153are used. 168are used.
154.Fa count 169.Fa count
155is set to 25. 170is set to 25.
156.Ss DES Algorithm: 171.Ss DES Algorithm
157.Pp
158The 172The
159.Fa salt 173.Fa salt
160introduces disorder in the 174introduces disorder in the
@@ -182,10 +196,10 @@ string, 20 or 13 bytes (plus null) in length, consisting of the
182.Ar setting 196.Ar setting
183followed by the encoded 64-bit encryption. 197followed by the encoded 64-bit encryption.
184.Pp 198.Pp
185The functions, 199The functions
186.Fn encrypt , 200.Fn encrypt ,
187.Fn setkey , 201.Fn setkey ,
188.Fn des_setkey 202.Fn des_setkey ,
189and 203and
190.Fn des_cipher 204.Fn des_cipher
191provide access to the 205provide access to the
@@ -243,7 +257,9 @@ E-box output as described above.
243.Pp 257.Pp
244The function 258The function
245.Fn crypt 259.Fn crypt
246returns a pointer to the encrypted value on success, and NULL on failure. 260returns a pointer to the encrypted value on success, and
261.Dv NULL
262on failure.
247The functions 263The functions
248.Fn setkey , 264.Fn setkey ,
249.Fn encrypt , 265.Fn encrypt ,
@@ -254,7 +270,7 @@ return 0 on success and 1 on failure.
254.Pp 270.Pp
255The 271The
256.Fn crypt , 272.Fn crypt ,
257.Fn setkey 273.Fn setkey ,
258and 274and
259.Fn des_setkey 275.Fn des_setkey
260functions all manipulate the same key space. 276functions all manipulate the same key space.
@@ -265,12 +281,8 @@ functions all manipulate the same key space.
265.Xr getpass 3 , 281.Xr getpass 3 ,
266.Xr md5 3 , 282.Xr md5 3 ,
267.Xr passwd 5 283.Xr passwd 5
268.Sh BUGS 284.Sh AUTHOR
269The 285David Burren <davidb@werj.com.au>
270.Fn crypt
271function returns a pointer to static data, and subsequent calls to
272.Fn crypt
273will modify the same object.
274.Sh HISTORY 286.Sh HISTORY
275A rotor-based 287A rotor-based
276.Fn crypt 288.Fn crypt
@@ -289,9 +301,14 @@ Programs linked against the
289interface may be exported from the U.S.A. only if they use 301interface may be exported from the U.S.A. only if they use
290.Fn crypt 302.Fn crypt
291solely for authentication purposes and avoid use of 303solely for authentication purposes and avoid use of
292the other programmer interfaces listed above. Special care has been taken 304the other programmer interfaces listed above.
305Special care has been taken
293in the library so that programs which only use the 306in the library so that programs which only use the
294.Fn crypt 307.Fn crypt
295interface do not pull in the other components. 308interface do not pull in the other components.
296.Sh AUTHOR 309.Sh BUGS
297David Burren <davidb@werj.com.au> 310The
311.Fn crypt
312function returns a pointer to static data, and subsequent calls to
313.Fn crypt
314will modify the same object.