diff options
| author | cvs2svn <admin@example.com> | 2014-04-13 15:49:51 +0000 |
|---|---|---|
| committer | cvs2svn <admin@example.com> | 2014-04-13 15:49:51 +0000 |
| commit | 9ef0d5fb5b0acfd35d73a5557198f46525ab1667 (patch) | |
| tree | 61e7e25839f716a30db270f15cddf0be6903781f /src/lib/libc/crypt/crypt.3 | |
| parent | ff237038a541d51619efa5b36fb251c8dc1e9637 (diff) | |
| download | openbsd-butholakala.tar.gz openbsd-butholakala.tar.bz2 openbsd-butholakala.zip | |
This commit was manufactured by cvs2git to create tag 'butholakala'.butholakala
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libc/crypt/crypt.3 | 318 |
1 files changed, 0 insertions, 318 deletions
diff --git a/src/lib/libc/crypt/crypt.3 b/src/lib/libc/crypt/crypt.3 deleted file mode 100644 index f4a78781da..0000000000 --- a/src/lib/libc/crypt/crypt.3 +++ /dev/null | |||
| @@ -1,318 +0,0 @@ | |||
| 1 | .\" $OpenBSD: crypt.3,v 1.34 2014/03/19 02:34:45 tedu Exp $ | ||
| 2 | .\" | ||
| 3 | .\" FreeSec: libcrypt | ||
| 4 | .\" | ||
| 5 | .\" Copyright (c) 1994 David Burren | ||
| 6 | .\" All rights reserved. | ||
| 7 | .\" | ||
| 8 | .\" Redistribution and use in source and binary forms, with or without | ||
| 9 | .\" modification, are permitted provided that the following conditions | ||
| 10 | .\" are met: | ||
| 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. | ||
| 19 | .\" | ||
| 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 | ||
| 30 | .\" SUCH DAMAGE. | ||
| 31 | .\" | ||
| 32 | .\" Manual page, using -mandoc macros | ||
| 33 | .\" | ||
| 34 | .Dd $Mdocdate: March 19 2014 $ | ||
| 35 | .Dt CRYPT 3 | ||
| 36 | .Os | ||
| 37 | .Sh NAME | ||
| 38 | .Nm crypt , | ||
| 39 | .Nm setkey , | ||
| 40 | .Nm encrypt , | ||
| 41 | .Nm des_setkey , | ||
| 42 | .Nm des_cipher , | ||
| 43 | .Nm bcrypt_gensalt , | ||
| 44 | .Nm bcrypt , | ||
| 45 | .Nm md5crypt | ||
| 46 | .Nd password hashing | ||
| 47 | .Sh SYNOPSIS | ||
| 48 | .In stdlib.h | ||
| 49 | .Ft int | ||
| 50 | .Fn setkey "const char *key" | ||
| 51 | .Pp | ||
| 52 | .In unistd.h | ||
| 53 | .Ft char * | ||
| 54 | .Fn crypt "const char *key" "const char *setting" | ||
| 55 | .Ft int | ||
| 56 | .Fn encrypt "char *block" "int flag" | ||
| 57 | .Ft int | ||
| 58 | .Fn des_setkey "const char *key" | ||
| 59 | .Ft int | ||
| 60 | .Fn des_cipher "const char *in" "char *out" "int32_t salt" "int count" | ||
| 61 | .In pwd.h | ||
| 62 | .Ft char * | ||
| 63 | .Fn bcrypt_gensalt "u_int8_t log_rounds" | ||
| 64 | .Ft char * | ||
| 65 | .Fn bcrypt "const char *key" "const char *salt" | ||
| 66 | .Ft char * | ||
| 67 | .Fn md5crypt "const char *key" "const char *salt" | ||
| 68 | .Sh DESCRIPTION | ||
| 69 | The | ||
| 70 | .Fn crypt | ||
| 71 | function performs password hashing based on the | ||
| 72 | .Tn NBS | ||
| 73 | Data Encryption Standard (DES). | ||
| 74 | Additional code has been added to deter key search attempts and to use | ||
| 75 | stronger hashing algorithms. | ||
| 76 | .Pp | ||
| 77 | The first argument to | ||
| 78 | .Fn crypt | ||
| 79 | is a | ||
| 80 | .Dv NUL Ns -terminated | ||
| 81 | string, typically a user's typed password. | ||
| 82 | The second is in one of three forms: | ||
| 83 | if it begins with an underscore | ||
| 84 | .Pq Ql _ | ||
| 85 | then an extended format is used | ||
| 86 | in interpreting both the key and the setting, as outlined below. | ||
| 87 | If it begins | ||
| 88 | with a string character | ||
| 89 | .Pq Ql $ | ||
| 90 | and a number then a different algorithm is used depending on the number. | ||
| 91 | At the moment a | ||
| 92 | .Ql $1 | ||
| 93 | chooses MD5 hashing and a | ||
| 94 | .Ql $2 | ||
| 95 | chooses Blowfish hashing; see below for more information. | ||
| 96 | .Ss Extended crypt | ||
| 97 | The | ||
| 98 | .Ar key | ||
| 99 | is divided into groups of 8 characters (the last group is null-padded) | ||
| 100 | and the low-order 7 bits of each character (56 bits per group) are | ||
| 101 | used to form the DES key as follows: | ||
| 102 | the first group of 56 bits becomes the initial DES key. | ||
| 103 | For each additional group, the XOR of the encryption of the current DES | ||
| 104 | key with itself and the group bits becomes the next DES key. | ||
| 105 | .Pp | ||
| 106 | The setting is a 9-character array consisting of an underscore followed | ||
| 107 | by 4 bytes of iteration count and 4 bytes of salt. | ||
| 108 | These are encoded as printable characters, 6 bits per character, | ||
| 109 | least significant character first. | ||
| 110 | The values 0 to 63 are encoded as | ||
| 111 | .Dq \&./0-9A-Za-z . | ||
| 112 | This allows 24 bits for both | ||
| 113 | .Fa count | ||
| 114 | and | ||
| 115 | .Fa salt . | ||
| 116 | .Ss "MD5" crypt | ||
| 117 | For | ||
| 118 | .Tn MD5 | ||
| 119 | crypt the version number, | ||
| 120 | .Fa salt | ||
| 121 | and the hashed password are separated by the | ||
| 122 | .Ql $ | ||
| 123 | character. | ||
| 124 | The maximum length of a password is limited by | ||
| 125 | the length counter of the MD5 context, which is about | ||
| 126 | 2**64. | ||
| 127 | A valid MD5 password entry looks like this: | ||
| 128 | .Pp | ||
| 129 | .Dq $1$caeiHQwX$hsKqOjrFRRN6K32OWkCBf1 . | ||
| 130 | .Pp | ||
| 131 | The whole MD5 password string is passed as | ||
| 132 | .Fa setting | ||
| 133 | for interpretation. | ||
| 134 | .Ss "Blowfish" crypt | ||
| 135 | The | ||
| 136 | .Tn Blowfish | ||
| 137 | version of crypt has 128 bits of | ||
| 138 | .Fa salt | ||
| 139 | in order to make building dictionaries of common passwords space consuming. | ||
| 140 | The initial state of the | ||
| 141 | .Tn Blowfish | ||
| 142 | cipher is expanded using the | ||
| 143 | .Fa salt | ||
| 144 | and the | ||
| 145 | .Fa password | ||
| 146 | repeating the process a variable number of rounds, which is encoded in | ||
| 147 | the password string. | ||
| 148 | The maximum password length is 72. | ||
| 149 | The final Blowfish password entry is created by encrypting the string | ||
| 150 | .Pp | ||
| 151 | .Dq OrpheanBeholderScryDoubt | ||
| 152 | .Pp | ||
| 153 | with the | ||
| 154 | .Tn Blowfish | ||
| 155 | state 64 times. | ||
| 156 | .Pp | ||
| 157 | The version number, the logarithm of the number of rounds and | ||
| 158 | the concatenation of salt and hashed password are separated by the | ||
| 159 | .Ql $ | ||
| 160 | character. | ||
| 161 | An encoded | ||
| 162 | .Sq 8 | ||
| 163 | would specify 256 rounds. | ||
| 164 | A valid Blowfish password looks like this: | ||
| 165 | .Pp | ||
| 166 | .Dq $2a$12$eIAq8PR8sIUnJ1HaohxX2O9x9Qlm2vK97LJ5dsXdmB.eXF42qjchC . | ||
| 167 | .Pp | ||
| 168 | The whole Blowfish password string is passed as | ||
| 169 | .Fa setting | ||
| 170 | for interpretation. | ||
| 171 | .Ss "Traditional" crypt | ||
| 172 | The first 8 bytes of the key are null-padded, and the low-order 7 bits of | ||
| 173 | each character is used to form the 56-bit | ||
| 174 | .Tn DES | ||
| 175 | key. | ||
| 176 | .Pp | ||
| 177 | The setting is a 2-character array of the ASCII-encoded salt. | ||
| 178 | Thus only 12 bits of | ||
| 179 | .Fa salt | ||
| 180 | are used. | ||
| 181 | .Fa count | ||
| 182 | is set to 25. | ||
| 183 | .Ss DES Algorithm | ||
| 184 | The | ||
| 185 | .Fa salt | ||
| 186 | introduces disorder in the | ||
| 187 | .Tn DES | ||
| 188 | algorithm in one of 16777216 or 4096 possible ways | ||
| 189 | (i.e., with 24 or 12 bits: if bit | ||
| 190 | .Em i | ||
| 191 | of the | ||
| 192 | .Ar salt | ||
| 193 | is set, then bits | ||
| 194 | .Em i | ||
| 195 | and | ||
| 196 | .Em i+24 | ||
| 197 | are swapped in the | ||
| 198 | .Tn DES | ||
| 199 | E-box output). | ||
| 200 | .Pp | ||
| 201 | The DES key is used to encrypt a 64-bit constant using | ||
| 202 | .Ar count | ||
| 203 | iterations of | ||
| 204 | .Tn DES . | ||
| 205 | The value returned is a | ||
| 206 | .Dv NUL Ns -terminated | ||
| 207 | string, 20 or 13 bytes (plus NUL) in length, consisting of the | ||
| 208 | .Ar setting | ||
| 209 | followed by the encoded 64-bit encryption. | ||
| 210 | .Pp | ||
| 211 | The functions | ||
| 212 | .Fn encrypt , | ||
| 213 | .Fn setkey , | ||
| 214 | .Fn des_setkey , | ||
| 215 | and | ||
| 216 | .Fn des_cipher | ||
| 217 | provide access to the | ||
| 218 | .Tn DES | ||
| 219 | algorithm itself. | ||
| 220 | .Fn setkey | ||
| 221 | is passed a 64-byte array of binary values (numeric 0 or 1). | ||
| 222 | A 56-bit key is extracted from this array by dividing the | ||
| 223 | array into groups of 8, and ignoring the last bit in each group. | ||
| 224 | That bit is reserved for a byte parity check by DES, but is ignored | ||
| 225 | by these functions. | ||
| 226 | .Pp | ||
| 227 | The | ||
| 228 | .Fa block | ||
| 229 | argument to | ||
| 230 | .Fn encrypt | ||
| 231 | is also a 64-byte array of binary values. | ||
| 232 | If the value of | ||
| 233 | .Fa flag | ||
| 234 | is 0, | ||
| 235 | .Fa block | ||
| 236 | is encrypted otherwise it is decrypted. | ||
| 237 | The result is returned in the original array | ||
| 238 | .Fa block | ||
| 239 | after using the key specified by | ||
| 240 | .Fn setkey | ||
| 241 | to process it. | ||
| 242 | .Pp | ||
| 243 | The argument to | ||
| 244 | .Fn des_setkey | ||
| 245 | is a character array of length 8. | ||
| 246 | The least significant bit (the parity bit) in each character is ignored, | ||
| 247 | and the remaining bits are concatenated to form a 56-bit key. | ||
| 248 | The function | ||
| 249 | .Fn des_cipher | ||
| 250 | encrypts (or decrypts if | ||
| 251 | .Fa count | ||
| 252 | is negative) the 64-bits stored in the 8 characters at | ||
| 253 | .Fa in | ||
| 254 | using | ||
| 255 | .Xr abs 3 | ||
| 256 | of | ||
| 257 | .Fa count | ||
| 258 | iterations of | ||
| 259 | .Tn DES | ||
| 260 | and stores the 64-bit result in the 8 characters at | ||
| 261 | .Fa out | ||
| 262 | (which may be the same as | ||
| 263 | .Fa in ) . | ||
| 264 | The | ||
| 265 | .Fa salt | ||
| 266 | specifies perturbations to the | ||
| 267 | .Tn DES | ||
| 268 | E-box output as described above. | ||
| 269 | .Pp | ||
| 270 | The | ||
| 271 | .Fn crypt , | ||
| 272 | .Fn setkey , | ||
| 273 | and | ||
| 274 | .Fn des_setkey | ||
| 275 | functions all manipulate the same key space. | ||
| 276 | .Sh RETURN VALUES | ||
| 277 | The function | ||
| 278 | .Fn crypt | ||
| 279 | returns a pointer to the encrypted value on success, and | ||
| 280 | .Dv NULL | ||
| 281 | on failure. | ||
| 282 | The functions | ||
| 283 | .Fn setkey , | ||
| 284 | .Fn encrypt , | ||
| 285 | .Fn des_setkey , | ||
| 286 | and | ||
| 287 | .Fn des_cipher | ||
| 288 | return 0 on success and 1 on failure. | ||
| 289 | .Sh SEE ALSO | ||
| 290 | .Xr encrypt 1 , | ||
| 291 | .Xr login 1 , | ||
| 292 | .Xr passwd 1 , | ||
| 293 | .Xr blowfish 3 , | ||
| 294 | .Xr getpass 3 , | ||
| 295 | .Xr md5 3 , | ||
| 296 | .Xr passwd 5 | ||
| 297 | .Sh HISTORY | ||
| 298 | A rotor-based | ||
| 299 | .Fn crypt | ||
| 300 | function appeared in | ||
| 301 | .At v3 . | ||
| 302 | The current style | ||
| 303 | .Fn crypt | ||
| 304 | first appeared in | ||
| 305 | .At v7 . | ||
| 306 | .Sh AUTHORS | ||
| 307 | .An David Burren Aq Mt davidb@werj.com.au | ||
| 308 | wrote the original DES functions. | ||
| 309 | .Sh BUGS | ||
| 310 | The | ||
| 311 | .Fn crypt | ||
| 312 | function returns a pointer to static data, and subsequent calls to | ||
| 313 | .Fn crypt | ||
| 314 | will modify the same object. | ||
| 315 | .Pp | ||
| 316 | With DES hashing, passwords containing the byte 0x80 use less key entropy | ||
| 317 | than other passwords. | ||
| 318 | This is an implementation bug, not a bug in the DES cipher. | ||
