Skip to content

Commit 608633c

Browse files
author
tedu
committed
split crypt_checkpass off into a new file
1 parent 4b9a7a1 commit 608633c

File tree

3 files changed

+73
-36
lines changed

3 files changed

+73
-36
lines changed

lib/libc/crypt/Makefile.inc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
#$OpenBSD: Makefile.inc,v 1.23 2014/11/18 22:17:50 jmc Exp $
1+
#$OpenBSD: Makefile.inc,v 1.24 2014/11/20 19:18:25 tedu Exp $
22

33
.PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/crypt ${LIBCSRCDIR}/crypt
44

55
SRCS+= crypt.c crypt2.c cryptutil.c arc4random.c arc4random_uniform.c \
66
blowfish.c bcrypt.c
77

8-
MAN+= crypt.3 blowfish.3 arc4random.3
9-
MLINKS+=crypt.3 setkey.3 crypt.3 crypt_checkpass.3
10-
MLINKS+=crypt.3 crypt_newhash.3 crypt.3 encrypt.3
8+
MAN+= crypt.3 crypt_checkpass.3 blowfish.3 arc4random.3
9+
MLINKS+=crypt.3 setkey.3 crypt.3 encrypt.3
1110
MLINKS+=crypt.3 des_setkey.3 crypt.3 des_cipher.3
1211
MLINKS+=crypt.3 bcrypt_gensalt.3 crypt.3 bcrypt.3
12+
MLINKS+=crypt_checkpass.3 crypt_newhash.3
1313
MLINKS+=blowfish.3 blf_key.3 blowfish.3 blf_enc.3
1414
MLINKS+=blowfish.3 blf_dec.3 blowfish.3 blf_ecb_encrypt.3
1515
MLINKS+=blowfish.3 blf_ecb_decrypt.3 blowfish.3 blf_cbc_encrypt.3

lib/libc/crypt/crypt.3

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.\" $OpenBSD: crypt.3,v 1.40 2014/11/18 22:17:50 jmc Exp $
1+
.\" $OpenBSD: crypt.3,v 1.41 2014/11/20 19:18:25 tedu Exp $
22
.\"
33
.\" FreeSec: libcrypt
44
.\"
@@ -31,13 +31,11 @@
3131
.\"
3232
.\" Manual page, using -mandoc macros
3333
.\"
34-
.Dd $Mdocdate: November 18 2014 $
34+
.Dd $Mdocdate: November 20 2014 $
3535
.Dt CRYPT 3
3636
.Os
3737
.Sh NAME
3838
.Nm crypt ,
39-
.Nm crypt_checkpass ,
40-
.Nm crypt_newhash ,
4139
.Nm setkey ,
4240
.Nm encrypt ,
4341
.Nm des_setkey ,
@@ -54,10 +52,6 @@
5452
.Ft char *
5553
.Fn crypt "const char *key" "const char *setting"
5654
.Ft int
57-
.Fn crypt_checkpass "const char *password" "const char *hash"
58-
.Ft int
59-
.Fn crypt_newhash "const char *password" "login_cap_t *lc" "char *hash" "size_t hashsize"
60-
.Ft int
6155
.Fn encrypt "char *block" "int flag"
6256
.Ft int
6357
.Fn des_setkey "const char *key"
@@ -69,6 +63,11 @@
6963
.Ft char *
7064
.Fn bcrypt "const char *key" "const char *salt"
7165
.Sh DESCRIPTION
66+
These functions are deprecated in favor of
67+
.Xr crypt_checkpass 3
68+
and
69+
.Xr crypt_newhash 3 .
70+
.Pp
7271
The
7372
.Fn crypt
7473
function performs password hashing based on the
@@ -94,30 +93,6 @@ and a number then a different algorithm is used depending on the number.
9493
At the moment
9594
.Ql $2
9695
chooses Blowfish hashing; see below for more information.
97-
.Pp
98-
The
99-
.Fn crypt_checkpass
100-
function is provided to simplify checking a user's password.
101-
If both the hash and the password are the empty string, authentication
102-
is a success.
103-
Otherwise, the password is hashed and compared to the provided hash.
104-
If the hash is NULL, authentication will always fail, but a default
105-
amount of work is performed to simulate the hashing operation.
106-
A successful match will return 0.
107-
A failure will return \-1 and set errno.
108-
.Pp
109-
The
110-
.Fn crypt_newhash
111-
function is provided to simplify the creation of new password hashes.
112-
The provided
113-
.Fa password
114-
is randomly salted and hashed and stored in
115-
.Fa hash .
116-
The login class argument
117-
.Fa lc
118-
is used to identify the preferred hashing algorithm and parameters.
119-
Refer to
120-
.Xr login.conf 5 .
12196
.Ss Extended crypt
12297
The
12398
.Ar key
@@ -298,6 +273,7 @@ return 0 on success and 1 on failure.
298273
.Xr login 1 ,
299274
.Xr passwd 1 ,
300275
.Xr blowfish 3 ,
276+
.Xr crypt_checkpass 3 ,
301277
.Xr getpass 3 ,
302278
.Xr md5 3 ,
303279
.Xr passwd 5

lib/libc/crypt/crypt_checkpass.3

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
.\" $OpenBSD: crypt_checkpass.3,v 1.1 2014/11/20 19:18:25 tedu Exp $
2+
.\"
3+
.\" Copyright (c) Ted Unangst <tedu@openbsd.org>
4+
.\"
5+
.\" Permission to use, copy, modify, and distribute this software for any
6+
.\" purpose with or without fee is hereby granted, provided that the above
7+
.\" copyright notice and this permission notice appear in all copies.
8+
.\"
9+
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10+
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11+
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12+
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13+
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14+
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15+
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16+
.\"
17+
.Dd $Mdocdate: November 20 2014 $
18+
.Dt CRYPT_CHECKPASS 3
19+
.Os
20+
.Sh NAME
21+
.Nm crypt_checkpass ,
22+
.Nm crypt_newhash
23+
.Nd password hashing
24+
.Sh SYNOPSIS
25+
.In unistd.h
26+
.Ft int
27+
.Fn crypt_checkpass "const char *password" "const char *hash"
28+
.In login_cap.h
29+
.Ft int
30+
.Fn crypt_newhash "const char *password" "login_cap_t *lc" "char *hash" "size_t hashsize"
31+
.Sh DESCRIPTION
32+
The
33+
.Fn crypt_checkpass
34+
function is provided to simplify checking a user's password.
35+
If both the hash and the password are the empty string, authentication
36+
is a success.
37+
Otherwise, the password is hashed and compared to the provided hash.
38+
If the hash is NULL, authentication will always fail, but a default
39+
amount of work is performed to simulate the hashing operation.
40+
A successful match will return 0.
41+
A failure will return \-1 and set errno.
42+
.Pp
43+
The
44+
.Fn crypt_newhash
45+
function is provided to simplify the creation of new password hashes.
46+
The provided
47+
.Fa password
48+
is randomly salted and hashed and stored in
49+
.Fa hash .
50+
The login class argument
51+
.Fa lc
52+
is used to identify the preferred hashing algorithm and parameters.
53+
Refer to
54+
.Xr login.conf 5 .
55+
.Sh RETURN VALUES
56+
These functions
57+
return 0 on success and -1 on failure.
58+
.Sh SEE ALSO
59+
.Xr crypt 3 ,
60+
.Xr login.conf 5 ,
61+
.Xr passwd 5

0 commit comments

Comments
 (0)