diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libc/crypt/Makefile.inc | 4 | ||||
| -rw-r--r-- | src/lib/libc/crypt/crypt.3 | 86 |
2 files changed, 3 insertions, 87 deletions
diff --git a/src/lib/libc/crypt/Makefile.inc b/src/lib/libc/crypt/Makefile.inc index 2a06f73acc..bdca0bbf66 100644 --- a/src/lib/libc/crypt/Makefile.inc +++ b/src/lib/libc/crypt/Makefile.inc | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # $OpenBSD: Makefile.inc,v 1.25 2014/12/08 20:36:18 tedu Exp $ | 1 | # $OpenBSD: Makefile.inc,v 1.26 2014/12/08 20:46:04 tedu Exp $ |
| 2 | 2 | ||
| 3 | .PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/crypt ${LIBCSRCDIR}/crypt | 3 | .PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/crypt ${LIBCSRCDIR}/crypt |
| 4 | 4 | ||
| @@ -6,8 +6,6 @@ SRCS+= crypt.c cryptutil.c arc4random.c arc4random_uniform.c \ | |||
| 6 | blowfish.c bcrypt.c | 6 | blowfish.c bcrypt.c |
| 7 | 7 | ||
| 8 | MAN+= crypt.3 crypt_checkpass.3 blowfish.3 arc4random.3 | 8 | MAN+= crypt.3 crypt_checkpass.3 blowfish.3 arc4random.3 |
| 9 | MLINKS+=crypt.3 setkey.3 crypt.3 encrypt.3 | ||
| 10 | MLINKS+=crypt.3 des_setkey.3 crypt.3 des_cipher.3 | ||
| 11 | MLINKS+=crypt.3 bcrypt_gensalt.3 crypt.3 bcrypt.3 | 9 | MLINKS+=crypt.3 bcrypt_gensalt.3 crypt.3 bcrypt.3 |
| 12 | MLINKS+=crypt_checkpass.3 crypt_newhash.3 | 10 | MLINKS+=crypt_checkpass.3 crypt_newhash.3 |
| 13 | MLINKS+=blowfish.3 blf_key.3 blowfish.3 blf_enc.3 | 11 | MLINKS+=blowfish.3 blf_key.3 blowfish.3 blf_enc.3 |
diff --git a/src/lib/libc/crypt/crypt.3 b/src/lib/libc/crypt/crypt.3 index 9a73c7a515..f6373c5125 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.43 2014/12/02 07:39:58 schwarze Exp $ | 1 | .\" $OpenBSD: crypt.3,v 1.44 2014/12/08 20:46:04 tedu Exp $ |
| 2 | .\" | 2 | .\" |
| 3 | .\" FreeSec: libcrypt | 3 | .\" FreeSec: libcrypt |
| 4 | .\" | 4 | .\" |
| @@ -31,32 +31,20 @@ | |||
| 31 | .\" | 31 | .\" |
| 32 | .\" Manual page, using -mandoc macros | 32 | .\" Manual page, using -mandoc macros |
| 33 | .\" | 33 | .\" |
| 34 | .Dd $Mdocdate: December 2 2014 $ | 34 | .Dd $Mdocdate: December 8 2014 $ |
| 35 | .Dt CRYPT 3 | 35 | .Dt CRYPT 3 |
| 36 | .Os | 36 | .Os |
| 37 | .Sh NAME | 37 | .Sh NAME |
| 38 | .Nm crypt , | 38 | .Nm crypt , |
| 39 | .Nm setkey , | ||
| 40 | .Nm encrypt , | ||
| 41 | .Nm des_setkey , | ||
| 42 | .Nm des_cipher , | ||
| 43 | .Nm bcrypt_gensalt , | 39 | .Nm bcrypt_gensalt , |
| 44 | .Nm bcrypt | 40 | .Nm bcrypt |
| 45 | .Nd password hashing | 41 | .Nd password hashing |
| 46 | .Sh SYNOPSIS | 42 | .Sh SYNOPSIS |
| 47 | .In stdlib.h | 43 | .In stdlib.h |
| 48 | .Ft int | ||
| 49 | .Fn setkey "const char *key" | ||
| 50 | .Pp | 44 | .Pp |
| 51 | .In unistd.h | 45 | .In unistd.h |
| 52 | .Ft char * | 46 | .Ft char * |
| 53 | .Fn crypt "const char *key" "const char *setting" | 47 | .Fn crypt "const char *key" "const char *setting" |
| 54 | .Ft int | ||
| 55 | .Fn encrypt "char *block" "int flag" | ||
| 56 | .Ft int | ||
| 57 | .Fn des_setkey "const char *key" | ||
| 58 | .Ft int | ||
| 59 | .Fn des_cipher "const char *in" "char *out" "int32_t salt" "int count" | ||
| 60 | .In pwd.h | 48 | .In pwd.h |
| 61 | .Ft char * | 49 | .Ft char * |
| 62 | .Fn bcrypt_gensalt "u_int8_t log_rounds" | 50 | .Fn bcrypt_gensalt "u_int8_t log_rounds" |
| @@ -189,82 +177,12 @@ The value returned is a NUL-terminated | |||
| 189 | string, 20 or 13 bytes (plus NUL) in length, consisting of the | 177 | string, 20 or 13 bytes (plus NUL) in length, consisting of the |
| 190 | .Fa setting | 178 | .Fa setting |
| 191 | followed by the encoded 64-bit encryption. | 179 | followed by the encoded 64-bit encryption. |
| 192 | .Pp | ||
| 193 | The functions | ||
| 194 | .Fn encrypt , | ||
| 195 | .Fn setkey , | ||
| 196 | .Fn des_setkey , | ||
| 197 | and | ||
| 198 | .Fn des_cipher | ||
| 199 | provide access to the | ||
| 200 | DES algorithm itself. | ||
| 201 | .Fn setkey | ||
| 202 | is passed a 64-byte array of binary values (numeric 0 or 1). | ||
| 203 | A 56-bit key is extracted from this array by dividing the | ||
| 204 | array into groups of 8, and ignoring the last bit in each group. | ||
| 205 | That bit is reserved for a byte parity check by DES, but is ignored | ||
| 206 | by these functions. | ||
| 207 | .Pp | ||
| 208 | The | ||
| 209 | .Fa block | ||
| 210 | argument to | ||
| 211 | .Fn encrypt | ||
| 212 | is also a 64-byte array of binary values. | ||
| 213 | If the value of | ||
| 214 | .Fa flag | ||
| 215 | is 0, | ||
| 216 | .Fa block | ||
| 217 | is encrypted otherwise it is decrypted. | ||
| 218 | The result is returned in the original array | ||
| 219 | .Fa block | ||
| 220 | after using the key specified by | ||
| 221 | .Fn setkey | ||
| 222 | to process it. | ||
| 223 | .Pp | ||
| 224 | The argument to | ||
| 225 | .Fn des_setkey | ||
| 226 | is a character array of length 8. | ||
| 227 | The least significant bit (the parity bit) in each character is ignored, | ||
| 228 | and the remaining bits are concatenated to form a 56-bit key. | ||
| 229 | The function | ||
| 230 | .Fn des_cipher | ||
| 231 | encrypts (or decrypts if | ||
| 232 | .Fa count | ||
| 233 | is negative) the 64-bits stored in the 8 characters at | ||
| 234 | .Fa in | ||
| 235 | using | ||
| 236 | .Xr abs 3 | ||
| 237 | of | ||
| 238 | .Fa count | ||
| 239 | iterations of DES | ||
| 240 | and stores the 64-bit result in the 8 characters at | ||
| 241 | .Fa out | ||
| 242 | (which may be the same as | ||
| 243 | .Fa in ) . | ||
| 244 | The | ||
| 245 | .Fa salt | ||
| 246 | specifies perturbations to the DES | ||
| 247 | E-box output as described above. | ||
| 248 | .Pp | ||
| 249 | The | ||
| 250 | .Fn crypt , | ||
| 251 | .Fn setkey , | ||
| 252 | and | ||
| 253 | .Fn des_setkey | ||
| 254 | functions all manipulate the same key space. | ||
| 255 | .Sh RETURN VALUES | 180 | .Sh RETURN VALUES |
| 256 | The function | 181 | The function |
| 257 | .Fn crypt | 182 | .Fn crypt |
| 258 | returns a pointer to the encrypted value on success, and | 183 | returns a pointer to the encrypted value on success, and |
| 259 | .Dv NULL | 184 | .Dv NULL |
| 260 | on failure. | 185 | on failure. |
| 261 | The functions | ||
| 262 | .Fn setkey , | ||
| 263 | .Fn encrypt , | ||
| 264 | .Fn des_setkey , | ||
| 265 | and | ||
| 266 | .Fn des_cipher | ||
| 267 | return 0 on success and 1 on failure. | ||
| 268 | .Sh SEE ALSO | 186 | .Sh SEE ALSO |
| 269 | .Xr encrypt 1 , | 187 | .Xr encrypt 1 , |
| 270 | .Xr login 1 , | 188 | .Xr login 1 , |
