CVS commit: src/lib/libcrypt

2020-03-25 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Mar 25 22:09:48 UTC 2020

Modified Files:
src/lib/libcrypt: pw_gensalt.3

Log Message:
Remove trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libcrypt/pw_gensalt.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/pw_gensalt.3
diff -u src/lib/libcrypt/pw_gensalt.3:1.6 src/lib/libcrypt/pw_gensalt.3:1.7
--- src/lib/libcrypt/pw_gensalt.3:1.6	Wed Mar 25 21:26:12 2020
+++ src/lib/libcrypt/pw_gensalt.3	Wed Mar 25 22:09:48 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: pw_gensalt.3,v 1.6 2020/03/25 21:26:12 christos Exp $
+.\"	$NetBSD: pw_gensalt.3,v 1.7 2020/03/25 22:09:48 wiz Exp $
 .\"
 .\" Copyright (c) 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -56,7 +56,7 @@ using the hash function specified in
 with the function-specific
 .Ar option .
 .Pp
-The new salt types follow the 
+The new salt types follow the
 .Dq Modular Crypt Format
 (MCF) standard and are of the form:
 .Bd -literal -offset indent
@@ -65,7 +65,7 @@ The new salt types follow the 
 .Pp
 The characters allowed in the password salt are alphanumeric and
 include a forward slash and a period (are in the regular expression
-format 
+format
 .Li [A-Za-z0-9/.] ) .
 .Pp
 The following types are available:
@@ -165,8 +165,8 @@ The
 function was written in 1997 by
 .An Niels Provos Aq Mt pro...@physnet.uni-hamburg.de .
 .Pp
-The 
+The
 .Lk https://passlib.readthedocs.io/en/stable/modular_crypt_format.html "Modular Crypt Format (MCF)" .
 .Pp
-The 
+The
 .Lk https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md "Password Hashing Competition (PHC) format" .



CVS commit: src/lib/libcrypt

2020-03-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 25 21:26:12 UTC 2020

Modified Files:
src/lib/libcrypt: pw_gensalt.3

Log Message:
new paragraph


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libcrypt/pw_gensalt.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/pw_gensalt.3
diff -u src/lib/libcrypt/pw_gensalt.3:1.5 src/lib/libcrypt/pw_gensalt.3:1.6
--- src/lib/libcrypt/pw_gensalt.3:1.5	Wed Mar 25 17:24:08 2020
+++ src/lib/libcrypt/pw_gensalt.3	Wed Mar 25 17:26:12 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: pw_gensalt.3,v 1.5 2020/03/25 21:24:08 christos Exp $
+.\"	$NetBSD: pw_gensalt.3,v 1.6 2020/03/25 21:26:12 christos Exp $
 .\"
 .\" Copyright (c) 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -167,5 +167,6 @@ function was written in 1997 by
 .Pp
 The 
 .Lk https://passlib.readthedocs.io/en/stable/modular_crypt_format.html "Modular Crypt Format (MCF)" .
+.Pp
 The 
 .Lk https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md "Password Hashing Competition (PHC) format" .



CVS commit: src/lib/libcrypt

2020-03-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 25 21:24:08 UTC 2020

Modified Files:
src/lib/libcrypt: pw_gensalt.3

Log Message:
more info


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libcrypt/pw_gensalt.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/pw_gensalt.3
diff -u src/lib/libcrypt/pw_gensalt.3:1.4 src/lib/libcrypt/pw_gensalt.3:1.5
--- src/lib/libcrypt/pw_gensalt.3:1.4	Wed Mar 25 17:02:26 2020
+++ src/lib/libcrypt/pw_gensalt.3	Wed Mar 25 17:24:08 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: pw_gensalt.3,v 1.4 2020/03/25 21:02:26 christos Exp $
+.\"	$NetBSD: pw_gensalt.3,v 1.5 2020/03/25 21:24:08 christos Exp $
 .\"
 .\" Copyright (c) 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -56,13 +56,20 @@ using the hash function specified in
 with the function-specific
 .Ar option .
 .Pp
-The new salt types follow the MCF standard and are of the form:
+The new salt types follow the 
+.Dq Modular Crypt Format
+(MCF) standard and are of the form:
+.Bd -literal -offset indent
 .Li $[$=(,=)*][$[$]]
+.Ed
+.Pp
 The characters allowed in the password salt are alphanumeric and
-include a forward slash and a period.
+include a forward slash and a period (are in the regular expression
+format 
+.Li [A-Za-z0-9/.] ) .
 .Pp
 The following types are available:
-.Bl -tag -width blowfish -compact
+.Bl -tag -width blowfish -offset indent
 .It old
 The original Unix implementation.
 This is of the form
@@ -117,7 +124,7 @@ A salt generated using the
 .Sq blowfish
 algorithm.
 The minimum salt size is
-.Dv 31
+.Dv 30
 and the number of rounds needs to be specified in
 .Ar option .
 This is of the form:
@@ -157,3 +164,8 @@ The
 .Fn pw_gensalt
 function was written in 1997 by
 .An Niels Provos Aq Mt pro...@physnet.uni-hamburg.de .
+.Pp
+The 
+.Lk https://passlib.readthedocs.io/en/stable/modular_crypt_format.html "Modular Crypt Format (MCF)" .
+The 
+.Lk https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md "Password Hashing Competition (PHC) format" .



CVS commit: src/lib/libcrypt

2020-03-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 25 21:02:26 UTC 2020

Modified Files:
src/lib/libcrypt: bcrypt.c pw_gensalt.3

Log Message:
Revert putting a $ as the final character for blowfish. It is not required by
MCF and we want to be compatible.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/libcrypt/bcrypt.c
cvs rdiff -u -r1.3 -r1.4 src/lib/libcrypt/pw_gensalt.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/bcrypt.c
diff -u src/lib/libcrypt/bcrypt.c:1.20 src/lib/libcrypt/bcrypt.c:1.21
--- src/lib/libcrypt/bcrypt.c:1.20	Wed Mar 25 14:36:29 2020
+++ src/lib/libcrypt/bcrypt.c	Wed Mar 25 17:02:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcrypt.c,v 1.20 2020/03/25 18:36:29 christos Exp $	*/
+/*	$NetBSD: bcrypt.c,v 1.21 2020/03/25 21:02:26 christos Exp $	*/
 /*	$OpenBSD: bcrypt.c,v 1.16 2002/02/19 19:39:36 millert Exp $	*/
 
 /*
@@ -46,7 +46,7 @@
  *
  */
 #include 
-__RCSID("$NetBSD: bcrypt.c,v 1.20 2020/03/25 18:36:29 christos Exp $");
+__RCSID("$NetBSD: bcrypt.c,v 1.21 2020/03/25 21:02:26 christos Exp $");
 
 #include 
 #include 
@@ -66,12 +66,12 @@ __RCSID("$NetBSD: bcrypt.c,v 1.20 2020/0
 
 #define BCRYPT_VERSION '2'
 #define BCRYPT_MAXSALT 16	/* Precomputation is just so nice */
-#define BCRYPT_MAXSALTLEN 	(7 + (BCRYPT_MAXSALT * 4 + 2) / 3 + 2)
+#define BCRYPT_MAXSALTLEN 	(7 + (BCRYPT_MAXSALT * 4 + 2) / 3 + 1)
 #define BCRYPT_BLOCKS 6		/* Ciphertext blocks */
 #define BCRYPT_MINROUNDS 16	/* we have log2(rounds) in salt */
 
 static void encode_salt(char *, u_int8_t *, u_int16_t, u_int8_t);
-static u_int8_t *encode_base64(u_int8_t *, u_int8_t *, u_int16_t);
+static void encode_base64(u_int8_t *, u_int8_t *, u_int16_t);
 static void decode_base64(u_int8_t *, u_int16_t, const u_int8_t *);
 
 char *__bcrypt(const char *, const char *);	/* XXX */
@@ -146,9 +146,7 @@ encode_salt(char *salt, u_int8_t *csalt,
 
 	snprintf(salt + 4, 4, "%2.2u$", logr);
 
-	csalt = encode_base64((u_int8_t *) salt + 7, csalt, clen);
-	*csalt++ = '$';
-	*csalt = '\0';
+	encode_base64((u_int8_t *) salt + 7, csalt, clen);
 }
 
 int
@@ -320,7 +318,7 @@ __bcrypt(const char *key, const char *sa
 	return encrypted;
 }
 
-static u_int8_t *
+static void
 encode_base64(u_int8_t *buffer, u_int8_t *data, u_int16_t len)
 {
 	u_int8_t *bp = buffer;
@@ -348,7 +346,6 @@ encode_base64(u_int8_t *buffer, u_int8_t
 		*bp++ = Base64Code[c2 & 0x3f];
 	}
 	*bp = '\0';
-	return bp;
 }
 #if 0
 void

Index: src/lib/libcrypt/pw_gensalt.3
diff -u src/lib/libcrypt/pw_gensalt.3:1.3 src/lib/libcrypt/pw_gensalt.3:1.4
--- src/lib/libcrypt/pw_gensalt.3:1.3	Wed Mar 25 14:53:50 2020
+++ src/lib/libcrypt/pw_gensalt.3	Wed Mar 25 17:02:26 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: pw_gensalt.3,v 1.3 2020/03/25 18:53:50 wiz Exp $
+.\"	$NetBSD: pw_gensalt.3,v 1.4 2020/03/25 21:02:26 christos Exp $
 .\"
 .\" Copyright (c) 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -121,7 +121,7 @@ The minimum salt size is
 and the number of rounds needs to be specified in
 .Ar option .
 This is of the form:
-.Li $2a$nrounds$??$ .
+.Li $2a$nrounds$?? .
 The
 .Li 2
 in the salt string indicates the current blowfish version.



CVS commit: src/lib/libcrypt

2020-03-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 25 18:37:09 UTC 2020

Modified Files:
src/lib/libcrypt: pw_gensalt.3

Log Message:
- bump blowfish size, explain version
- add passwd xref


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libcrypt/pw_gensalt.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/pw_gensalt.3
diff -u src/lib/libcrypt/pw_gensalt.3:1.1 src/lib/libcrypt/pw_gensalt.3:1.2
--- src/lib/libcrypt/pw_gensalt.3:1.1	Wed Mar 25 13:11:06 2020
+++ src/lib/libcrypt/pw_gensalt.3	Wed Mar 25 14:37:08 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: pw_gensalt.3,v 1.1 2020/03/25 17:11:06 christos Exp $
+.\"	$NetBSD: pw_gensalt.3,v 1.2 2020/03/25 18:37:08 christos Exp $
 .\"
 .\" Copyright (c) 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -116,11 +116,14 @@ A salt generated using the
 .Sq blowfish
 algorithm.
 The minimum salt size is
-.Dv 30
+.Dv 31
 and the number of rounds needs to be specified in
 .Ar option .
 This is of the form:
 .Li $2a$nrounds$??$ .
+The
+.Li 2
+in the salt string indicates the current blowfish version.
 .\" .It argon2
 .\" .It argon2id
 .\" .It argon2i
@@ -146,6 +149,7 @@ was not large enough to fit the salt for
 .Ar type.
 .El
 .Sh SEE ALSO
+.Xr passwd 1 ,
 .Xr pwhash 1
 .Sh HISTORY
 The



CVS commit: src/lib/libcrypt

2020-03-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 25 18:36:29 UTC 2020

Modified Files:
src/lib/libcrypt: bcrypt.c

Log Message:
Add missing trailing $ for blowfish


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/lib/libcrypt/bcrypt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/bcrypt.c
diff -u src/lib/libcrypt/bcrypt.c:1.19 src/lib/libcrypt/bcrypt.c:1.20
--- src/lib/libcrypt/bcrypt.c:1.19	Wed Aug 28 13:47:07 2013
+++ src/lib/libcrypt/bcrypt.c	Wed Mar 25 14:36:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcrypt.c,v 1.19 2013/08/28 17:47:07 riastradh Exp $	*/
+/*	$NetBSD: bcrypt.c,v 1.20 2020/03/25 18:36:29 christos Exp $	*/
 /*	$OpenBSD: bcrypt.c,v 1.16 2002/02/19 19:39:36 millert Exp $	*/
 
 /*
@@ -46,7 +46,7 @@
  *
  */
 #include 
-__RCSID("$NetBSD: bcrypt.c,v 1.19 2013/08/28 17:47:07 riastradh Exp $");
+__RCSID("$NetBSD: bcrypt.c,v 1.20 2020/03/25 18:36:29 christos Exp $");
 
 #include 
 #include 
@@ -66,12 +66,12 @@ __RCSID("$NetBSD: bcrypt.c,v 1.19 2013/0
 
 #define BCRYPT_VERSION '2'
 #define BCRYPT_MAXSALT 16	/* Precomputation is just so nice */
-#define BCRYPT_MAXSALTLEN 	(7 + (BCRYPT_MAXSALT * 4 + 2) / 3 + 1)
+#define BCRYPT_MAXSALTLEN 	(7 + (BCRYPT_MAXSALT * 4 + 2) / 3 + 2)
 #define BCRYPT_BLOCKS 6		/* Ciphertext blocks */
 #define BCRYPT_MINROUNDS 16	/* we have log2(rounds) in salt */
 
 static void encode_salt(char *, u_int8_t *, u_int16_t, u_int8_t);
-static void encode_base64(u_int8_t *, u_int8_t *, u_int16_t);
+static u_int8_t *encode_base64(u_int8_t *, u_int8_t *, u_int16_t);
 static void decode_base64(u_int8_t *, u_int16_t, const u_int8_t *);
 
 char *__bcrypt(const char *, const char *);	/* XXX */
@@ -146,7 +146,9 @@ encode_salt(char *salt, u_int8_t *csalt,
 
 	snprintf(salt + 4, 4, "%2.2u$", logr);
 
-	encode_base64((u_int8_t *) salt + 7, csalt, clen);
+	csalt = encode_base64((u_int8_t *) salt + 7, csalt, clen);
+	*csalt++ = '$';
+	*csalt = '\0';
 }
 
 int
@@ -318,7 +320,7 @@ __bcrypt(const char *key, const char *sa
 	return encrypted;
 }
 
-static void
+static u_int8_t *
 encode_base64(u_int8_t *buffer, u_int8_t *data, u_int16_t len)
 {
 	u_int8_t *bp = buffer;
@@ -346,6 +348,7 @@ encode_base64(u_int8_t *buffer, u_int8_t
 		*bp++ = Base64Code[c2 & 0x3f];
 	}
 	*bp = '\0';
+	return bp;
 }
 #if 0
 void



CVS commit: src/lib/libcrypt

2020-03-25 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Mar 25 18:53:50 UTC 2020

Modified Files:
src/lib/libcrypt: pw_gensalt.3

Log Message:
Fix typos. Use more markup. New sentence, new line.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libcrypt/pw_gensalt.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/pw_gensalt.3
diff -u src/lib/libcrypt/pw_gensalt.3:1.2 src/lib/libcrypt/pw_gensalt.3:1.3
--- src/lib/libcrypt/pw_gensalt.3:1.2	Wed Mar 25 18:37:08 2020
+++ src/lib/libcrypt/pw_gensalt.3	Wed Mar 25 18:53:50 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: pw_gensalt.3,v 1.2 2020/03/25 18:37:08 christos Exp $
+.\"	$NetBSD: pw_gensalt.3,v 1.3 2020/03/25 18:53:50 wiz Exp $
 .\"
 .\" Copyright (c) 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -32,7 +32,7 @@
 .Dt PW_GENSALT 3
 .Os
 .Sh NAME
-.Nm pw_gensalt 
+.Nm pw_gensalt
 .Nd passwd salt generation function
 .Sh LIBRARY
 .Lb libcrypt
@@ -42,32 +42,33 @@
 .Fn pw_gensalt "char *salt" "size_t saltlen" "const char *type" "const char *option"
 .Sh DESCRIPTION
 The
-.Fn pw_gensalt 
+.Fn pw_gensalt
 function generates a
 .Dq salt
 to be added to a password hashing function to guarantee uniqueness and
-slow down dictionary and brute force attacks. The function places a
-random array of
-.Ar saltlen bytes in
+slow down dictionary and brute force attacks.
+The function places a random array of
+.Ar saltlen
+bytes in
 .Ar salt
 using the hash function specified in
 .Ar type
 with the function-specific
 .Ar option .
-.Ph
+.Pp
 The new salt types follow the MCF standard and are of the form:
 .Li $[$=(,=)*][$[$]]
 The characters allowed in the password salt are alphanumeric and
 include a forward slash and a period.
 .Pp
-.The following types are available:
-.Bl -tag -width blowfish compact
-.It old 
+The following types are available:
+.Bl -tag -width blowfish -compact
+.It old
 The original Unix implementation.
-This is of the form 
+This is of the form
 .Li _Gl/. ,
 where
-.Li ?
+.Li \&?
 denotes a random alphanumeric character.
 The minimum salt size is
 .Dv 3 .
@@ -90,7 +91,7 @@ An alias for
 A salt generated using the
 .Xr md5 1
 algorithm.
-This is of the form 
+This is of the form
 .Li $1$$ .
 The minimum salt size is
 .Dv 13 .
@@ -98,14 +99,14 @@ The minimum salt size is
 A salt generated using the
 .Xr sha1 1
 algorithm.
-This is of the form 
+This is of the form
 .Li $sha1$nrounds$$ ,
 where
 .Ar nrounds
 is the number of rounds to be used.
 The number of rounds can be specified in
 .Ar option ,
-and defaults to random if 
+and defaults to random if
 .Dv NULL .
 The minimum salt size is
 .Dv 8
@@ -146,7 +147,7 @@ is not specified or has an illegal value
 The
 .Ar saltlen
 was not large enough to fit the salt for the specified
-.Ar type.
+.Ar type .
 .El
 .Sh SEE ALSO
 .Xr passwd 1 ,
@@ -154,4 +155,5 @@ was not large enough to fit the salt for
 .Sh HISTORY
 The
 .Fn pw_gensalt
-function was written in 1997 Niels Provos .
+function was written in 1997 by
+.An Niels Provos Aq Mt pro...@physnet.uni-hamburg.de .



CVS commit: src/lib/libcrypt

2020-03-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 25 17:11:06 UTC 2020

Modified Files:
src/lib/libcrypt: Makefile
Added Files:
src/lib/libcrypt: pw_gensalt.3

Log Message:
PR/55095: David A. Holland: pw_gensalt(3) undocumented


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libcrypt/Makefile
cvs rdiff -u -r0 -r1.1 src/lib/libcrypt/pw_gensalt.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/Makefile
diff -u src/lib/libcrypt/Makefile:1.26 src/lib/libcrypt/Makefile:1.27
--- src/lib/libcrypt/Makefile:1.26	Sun Oct 20 22:36:48 2019
+++ src/lib/libcrypt/Makefile	Wed Mar 25 13:11:06 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.26 2019/10/21 02:36:48 jhigh Exp $
+#	$NetBSD: Makefile,v 1.27 2020/03/25 17:11:06 christos Exp $
 
 .include 
 
@@ -21,7 +21,7 @@ LDADD+=		-largon2 
 
 WARNS?=	5
 
-MAN=	crypt.3
+MAN=	crypt.3 pw_gensalt.3
 MLINKS= crypt.3 encrypt.3 crypt.3 setkey.3
 
 

Added files:

Index: src/lib/libcrypt/pw_gensalt.3
diff -u /dev/null src/lib/libcrypt/pw_gensalt.3:1.1
--- /dev/null	Wed Mar 25 13:11:06 2020
+++ src/lib/libcrypt/pw_gensalt.3	Wed Mar 25 13:11:06 2020
@@ -0,0 +1,153 @@
+.\"	$NetBSD: pw_gensalt.3,v 1.1 2020/03/25 17:11:06 christos Exp $
+.\"
+.\" Copyright (c) 2020 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Christos Zoulas.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice, this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.\"
+.Dd March 25, 2020
+.Dt PW_GENSALT 3
+.Os
+.Sh NAME
+.Nm pw_gensalt 
+.Nd passwd salt generation function
+.Sh LIBRARY
+.Lb libcrypt
+.Sh SYNOPSIS
+.In pwd.h
+.Ft int
+.Fn pw_gensalt "char *salt" "size_t saltlen" "const char *type" "const char *option"
+.Sh DESCRIPTION
+The
+.Fn pw_gensalt 
+function generates a
+.Dq salt
+to be added to a password hashing function to guarantee uniqueness and
+slow down dictionary and brute force attacks. The function places a
+random array of
+.Ar saltlen bytes in
+.Ar salt
+using the hash function specified in
+.Ar type
+with the function-specific
+.Ar option .
+.Ph
+The new salt types follow the MCF standard and are of the form:
+.Li $[$=(,=)*][$[$]]
+The characters allowed in the password salt are alphanumeric and
+include a forward slash and a period.
+.Pp
+.The following types are available:
+.Bl -tag -width blowfish compact
+.It old 
+The original Unix implementation.
+This is of the form 
+.Li _Gl/. ,
+where
+.Li ?
+denotes a random alphanumeric character.
+The minimum salt size is
+.Dv 3 .
+.It new
+The Seventh Edition Unix 12 bit salt.
+This has the same form as the
+.Sq old .
+The minimum salt size is
+.Dv 10 .
+The number of rounds can be specified in
+.Ar option
+and is enforced to be between
+.Dv 7250
+and
+.Dv 16777215 .
+.It newsalt
+An alias for
+.Sq new .
+.It md5
+A salt generated using the
+.Xr md5 1
+algorithm.
+This is of the form 
+.Li $1$$ .
+The minimum salt size is
+.Dv 13 .
+.It sha1
+A salt generated using the
+.Xr sha1 1
+algorithm.
+This is of the form 
+.Li $sha1$nrounds$$ ,
+where
+.Ar nrounds
+is the number of rounds to be used.
+The number of rounds can be specified in
+.Ar option ,
+and defaults to random if 
+.Dv NULL .
+The minimum salt size is
+.Dv 8
+and the maximum is
+.Dv 64 .
+.It blowfish
+A salt generated using the
+.Sq blowfish
+algorithm.
+The minimum salt size is
+.Dv 30
+and the number of rounds needs to be specified in
+.Ar option .
+This is of the form:
+.Li $2a$nrounds$??$ .
+.\" .It argon2
+.\" .It argon2id
+.\" .It argon2i
+.\" .It argon2
+.El
+.Sh R

CVS commit: src/lib/libcrypt

2020-02-22 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Feb 22 10:29:17 UTC 2020

Modified Files:
src/lib/libcrypt: crypt.c

Log Message:
Avoid undefined behavior in left shift

crypt.c:772:11, left shift of 1363235140 by 1 places cannot be represented
in type 'int32_t' (aka 'int')


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/lib/libcrypt/crypt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/crypt.c
diff -u src/lib/libcrypt/crypt.c:1.37 src/lib/libcrypt/crypt.c:1.38
--- src/lib/libcrypt/crypt.c:1.37	Sat Feb 22 10:22:32 2020
+++ src/lib/libcrypt/crypt.c	Sat Feb 22 10:29:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypt.c,v 1.37 2020/02/22 10:22:32 kamil Exp $	*/
+/*	$NetBSD: crypt.c,v 1.38 2020/02/22 10:29:17 kamil Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)crypt.c	8.1.1.1 (Berkeley) 8/18/93";
 #else
-__RCSID("$NetBSD: crypt.c,v 1.37 2020/02/22 10:22:32 kamil Exp $");
+__RCSID("$NetBSD: crypt.c,v 1.38 2020/02/22 10:29:17 kamil Exp $");
 #endif
 #endif /* not lint */
 
@@ -769,9 +769,9 @@ des_cipher(const char *in, char *out, lo
 	LOADREG(R,R0,R1,L,L0,L1);
 	L0 &= 0xL;
 	L1 &= 0xL;
-	L0 = (L0 << 1) | L1;	/* L0 is the even-numbered input bits */
+	L0 = ((uint32_t)L0 << 1) | L1;	/* L0 is the even-numbered input bits */
 	R0 &= 0xL;
-	R1 = (R1 >> 1) & 0xL;
+	R1 = ((uint32_t)R1 >> 1) & 0xL;
 	L1 = R0 | R1;		/* L1 is the odd-numbered input bits */
 	STORE(L,L0,L1,B);
 	PERM3264(L,L0,L1,B.b,  (C_block *)IE3264);	/* even bits */



CVS commit: src/lib/libcrypt

2020-02-22 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Feb 22 10:22:32 UTC 2020

Modified Files:
src/lib/libcrypt: crypt.c

Log Message:
Avoid undefined behavior in bit shift operations

crypt.c:839:40, left shift of negative value -1197182952
crypt.c:840:40, left shift of negative value -264997776


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/lib/libcrypt/crypt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/crypt.c
diff -u src/lib/libcrypt/crypt.c:1.36 src/lib/libcrypt/crypt.c:1.37
--- src/lib/libcrypt/crypt.c:1.36	Mon Oct 21 02:36:48 2019
+++ src/lib/libcrypt/crypt.c	Sat Feb 22 10:22:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypt.c,v 1.36 2019/10/21 02:36:48 jhigh Exp $	*/
+/*	$NetBSD: crypt.c,v 1.37 2020/02/22 10:22:32 kamil Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)crypt.c	8.1.1.1 (Berkeley) 8/18/93";
 #else
-__RCSID("$NetBSD: crypt.c,v 1.36 2019/10/21 02:36:48 jhigh Exp $");
+__RCSID("$NetBSD: crypt.c,v 1.37 2020/02/22 10:22:32 kamil Exp $");
 #endif
 #endif /* not lint */
 
@@ -836,8 +836,8 @@ des_cipher(const char *in, char *out, lo
 	}
 
 	/* store the encrypted (or decrypted) result */
-	L0 = ((L0 >> 3) & 0x0f0f0f0fL) | ((L1 << 1) & 0xf0f0f0f0L);
-	L1 = ((R0 >> 3) & 0x0f0f0f0fL) | ((R1 << 1) & 0xf0f0f0f0L);
+	L0 = (((uint32_t)L0 >> 3) & 0x0f0f0f0fL) | (((uint32_t)L1 << 1) & 0xf0f0f0f0L);
+	L1 = (((uint32_t)R0 >> 3) & 0x0f0f0f0fL) | (((uint32_t)R1 << 1) & 0xf0f0f0f0L);
 	STORE(L,L0,L1,B);
 	PERM6464(L,L0,L1,B.b, (C_block *)CF6464);
 #if defined(MUST_ALIGN)



CVS commit: src/lib/libcrypt

2013-08-10 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Aug 10 18:42:29 UTC 2013

Modified Files:
src/lib/libcrypt: Makefile crypt-sha1.c

Log Message:
Silence -Wpointer-sign on crypt-sha1.c.
This requires casts, which is not entirely desirable; however, this way
at least no *more* pointer sign issues can creep in.

Output object files are unchanged on amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libcrypt/Makefile
cvs rdiff -u -r1.6 -r1.7 src/lib/libcrypt/crypt-sha1.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/Makefile
diff -u src/lib/libcrypt/Makefile:1.24 src/lib/libcrypt/Makefile:1.25
--- src/lib/libcrypt/Makefile:1.24	Fri Aug 10 04:30:47 2012
+++ src/lib/libcrypt/Makefile	Sat Aug 10 18:42:29 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.24 2012/08/10 04:30:47 joerg Exp $
+#	$NetBSD: Makefile,v 1.25 2013/08/10 18:42:29 dholland Exp $
 
 USE_SHLIBDIR=	yes
 
@@ -24,5 +24,3 @@ LDSTATIC?= -static
 .else
 .include 
 .endif
-
-COPTS.crypt-sha1.c+=	-Wno-pointer-sign

Index: src/lib/libcrypt/crypt-sha1.c
diff -u src/lib/libcrypt/crypt-sha1.c:1.6 src/lib/libcrypt/crypt-sha1.c:1.7
--- src/lib/libcrypt/crypt-sha1.c:1.6	Mon Jun 24 04:21:20 2013
+++ src/lib/libcrypt/crypt-sha1.c	Sat Aug 10 18:42:29 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: crypt-sha1.c,v 1.6 2013/06/24 04:21:20 riastradh Exp $ */
+/* $NetBSD: crypt-sha1.c,v 1.7 2013/08/10 18:42:29 dholland Exp $ */
 
 /*
  * Copyright (c) 2004, Juniper Networks, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: crypt-sha1.c,v 1.6 2013/06/24 04:21:20 riastradh Exp $");
+__RCSID("$NetBSD: crypt-sha1.c,v 1.7 2013/08/10 18:42:29 dholland Exp $");
 #endif /* not lint */
 
 #include 
@@ -130,6 +130,8 @@ __crypt_sha1 (const char *pw, const char
 int dl;
 unsigned int iterations;
 unsigned int i;
+/* XXX silence -Wpointer-sign (would be nice to fix this some other way) */
+const unsigned char *pwu = (const unsigned char *)pw;
 
 /*
  * Salt format is
@@ -166,9 +168,9 @@ __crypt_sha1 (const char *pw, const char
 /*
  * Then hmac using  as key, and repeat...
  */
-__hmac_sha1(passwd, dl, pw, pl, hmac_buf);
+__hmac_sha1((unsigned char *)passwd, dl, pwu, pl, hmac_buf);
 for (i = 1; i < iterations; i++) {
-	__hmac_sha1(hmac_buf, SHA1_SIZE, pw, pl, hmac_buf);
+	__hmac_sha1(hmac_buf, SHA1_SIZE, pwu, pl, hmac_buf);
 }
 /* Now output... */
 pl = snprintf(passwd, sizeof(passwd), "%s%u$%.*s$",



CVS commit: src/lib/libcrypt

2012-08-09 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Aug 10 04:30:47 UTC 2012

Modified Files:
src/lib/libcrypt: Makefile

Log Message:
crypt-sha1.c flags apply to all compilers in the tree, drop conditional.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libcrypt/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/Makefile
diff -u src/lib/libcrypt/Makefile:1.23 src/lib/libcrypt/Makefile:1.24
--- src/lib/libcrypt/Makefile:1.23	Wed Mar 21 05:37:42 2012
+++ src/lib/libcrypt/Makefile	Fri Aug 10 04:30:47 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.23 2012/03/21 05:37:42 matt Exp $
+#	$NetBSD: Makefile,v 1.24 2012/08/10 04:30:47 joerg Exp $
 
 USE_SHLIBDIR=	yes
 
@@ -25,6 +25,4 @@ LDSTATIC?= -static
 .include 
 .endif
 
-.if defined(HAVE_GCC) || defined(HAVE_PCC)
 COPTS.crypt-sha1.c+=	-Wno-pointer-sign
-.endif



CVS commit: src/lib/libcrypt

2012-03-01 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Mar  1 21:31:10 UTC 2012

Modified Files:
src/lib/libcrypt: crypt.3

Log Message:
Fix punctuation markup.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/libcrypt/crypt.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/crypt.3
diff -u src/lib/libcrypt/crypt.3:1.25 src/lib/libcrypt/crypt.3:1.26
--- src/lib/libcrypt/crypt.3:1.25	Mon Jan  2 18:06:37 2012
+++ src/lib/libcrypt/crypt.3	Thu Mar  1 21:31:10 2012
@@ -1,4 +1,4 @@
-.\"	$NetBSD: crypt.3,v 1.25 2012/01/02 18:06:37 wiz Exp $
+.\"	$NetBSD: crypt.3,v 1.26 2012/03/01 21:31:10 wiz Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -403,5 +403,5 @@ Before
 returned either
 .Dv NULL
 or
-.Dv :
+.Dv \&:
 on error.



CVS commit: src/lib/libcrypt

2012-01-02 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Jan  2 18:06:37 UTC 2012

Modified Files:
src/lib/libcrypt: crypt.3

Log Message:
Remove trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libcrypt/crypt.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/crypt.3
diff -u src/lib/libcrypt/crypt.3:1.24 src/lib/libcrypt/crypt.3:1.25
--- src/lib/libcrypt/crypt.3:1.24	Sun Jan  1 23:42:03 2012
+++ src/lib/libcrypt/crypt.3	Mon Jan  2 18:06:37 2012
@@ -1,4 +1,4 @@
-.\"	$NetBSD: crypt.3,v 1.24 2012/01/01 23:42:03 christos Exp $
+.\"	$NetBSD: crypt.3,v 1.25 2012/01/02 18:06:37 wiz Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -244,7 +244,7 @@ for interpretation.
 .Ss "Blowfish" crypt
 The
 .Tn Blowfish
-version of 
+version of
 .Fn crypt
 has 128 bits of
 .Fa salt



CVS commit: src/lib/libcrypt

2012-01-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan  1 23:42:03 UTC 2012

Modified Files:
src/lib/libcrypt: crypt.3

Log Message:
a typo and missing markup


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libcrypt/crypt.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/crypt.3
diff -u src/lib/libcrypt/crypt.3:1.23 src/lib/libcrypt/crypt.3:1.24
--- src/lib/libcrypt/crypt.3:1.23	Sun Jan  1 18:18:51 2012
+++ src/lib/libcrypt/crypt.3	Sun Jan  1 18:42:03 2012
@@ -1,4 +1,4 @@
-.\"	$NetBSD: crypt.3,v 1.23 2012/01/01 23:18:51 christos Exp $
+.\"	$NetBSD: crypt.3,v 1.24 2012/01/01 23:42:03 christos Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -244,7 +244,9 @@ for interpretation.
 .Ss "Blowfish" crypt
 The
 .Tn Blowfish
-version of crypt has 128 bits of
+version of 
+.Fn crypt
+has 128 bits of
 .Fa salt
 in order to make building dictionaries of common passwords space consuming.
 The initial state of the
@@ -307,7 +309,9 @@ Unfortunately, most existing application
 .Dv NULL
 returns from
 .Fn crypt .
-The description below corresponds to this implementation of crypt only.
+The description below corresponds to this implementation of
+.Fn crypt
+only.
 The behavior may change to match standards, other implementations or existing
 applications.
 .Pp
@@ -315,11 +319,12 @@ applications.
 may only fail (and return) when passed an invalid or unsupported
 .Fa setting ,
 in which case it returns a pointer to a magic string that is shorter than 13
-haracters and is guaranteed to differ from
+characters and is guaranteed to differ from
 .Fa setting .
-This behavior is safe for older applications which assume that crypt can't
-fail, when both setting new passwords and authenticating against existing
-password hashes.
+This behavior is safe for older applications which assume that
+.Fn crypt
+can't fail, when both setting new passwords and authenticating against
+existing password hashes.
 .Pp
 The functions
 .Fn setkey ,



CVS commit: src/lib/libcrypt

2012-01-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan  1 23:18:51 UTC 2012

Modified Files:
src/lib/libcrypt: crypt.3

Log Message:
Improve returns description from Solar Designer.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/lib/libcrypt/crypt.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/crypt.3
diff -u src/lib/libcrypt/crypt.3:1.22 src/lib/libcrypt/crypt.3:1.23
--- src/lib/libcrypt/crypt.3:1.22	Wed Dec 28 17:41:34 2011
+++ src/lib/libcrypt/crypt.3	Sun Jan  1 18:18:51 2012
@@ -1,4 +1,4 @@
-.\"	$NetBSD: crypt.3,v 1.22 2011/12/28 22:41:34 wiz Exp $
+.\"	$NetBSD: crypt.3,v 1.23 2012/01/01 23:18:51 christos Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)crypt.3	8.2 (Berkeley) 12/11/93
 .\"
-.Dd December 28, 2011
+.Dd January 1, 2012
 .Dt CRYPT 3
 .Os
 .Sh NAME
@@ -281,14 +281,46 @@ for interpretation.
 .Sh RETURN VALUES
 The function
 .Fn crypt
-returns a pointer to the encrypted value on success and
-.Dv *0
-on failure, or
-.Dv *1
-if the
-.Ar setting
-argument was already
-.Dv *0 .
+returns a pointer to the encrypted value on success.
+.Pp
+The behavior of
+.Fn crypt
+on errors isn't well standardized.
+Some implementations simply can't fail (unless the process dies, in which
+case they obviously can't return), others return
+.Dv NULL
+or a fixed string.
+Most implementations don't set
+.Va errno ,
+but some do.
+.St -susv2
+specifies
+only returning
+.Dv NULL
+and setting
+.Va errno
+as a valid behavior, and defines
+only one possible error
+.Er ( ENOSYS ,
+.Dq "The functionality is not supported on this implementation." )
+Unfortunately, most existing applications aren't prepared to handle
+.Dv NULL
+returns from
+.Fn crypt .
+The description below corresponds to this implementation of crypt only.
+The behavior may change to match standards, other implementations or existing
+applications.
+.Pp
+.Fn crypt
+may only fail (and return) when passed an invalid or unsupported
+.Fa setting ,
+in which case it returns a pointer to a magic string that is shorter than 13
+haracters and is guaranteed to differ from
+.Fa setting .
+This behavior is safe for older applications which assume that crypt can't
+fail, when both setting new passwords and authenticating against existing
+password hashes.
+.Pp
 The functions
 .Fn setkey ,
 .Fn encrypt ,



CVS commit: src/lib/libcrypt

2011-12-28 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Dec 28 22:41:34 UTC 2011

Modified Files:
src/lib/libcrypt: crypt.3

Log Message:
Remove trailing whitespace. Avoid xr to itself.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libcrypt/crypt.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/crypt.3
diff -u src/lib/libcrypt/crypt.3:1.21 src/lib/libcrypt/crypt.3:1.22
--- src/lib/libcrypt/crypt.3:1.21	Wed Dec 28 22:15:23 2011
+++ src/lib/libcrypt/crypt.3	Wed Dec 28 22:41:34 2011
@@ -1,4 +1,4 @@
-.\"	$NetBSD: crypt.3,v 1.21 2011/12/28 22:15:23 christos Exp $
+.\"	$NetBSD: crypt.3,v 1.22 2011/12/28 22:41:34 wiz Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -137,7 +137,7 @@ of the
 followed by the encoded 64-bit encryption.
 .Pp
 For compatibility with historical versions of
-.Xr crypt 3 ,
+.Fn crypt ,
 the
 .Ar setting
 may consist of 2 bytes of salt, encoded as above, in which case an
@@ -281,7 +281,7 @@ for interpretation.
 .Sh RETURN VALUES
 The function
 .Fn crypt
-returns a pointer to the encrypted value on success and 
+returns a pointer to the encrypted value on success and
 .Dv *0
 on failure, or
 .Dv *1



CVS commit: src/lib/libcrypt

2011-12-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 28 22:15:23 UTC 2011

Modified Files:
src/lib/libcrypt: crypt.3

Log Message:
reflect current reality about return values.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/libcrypt/crypt.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/crypt.3
diff -u src/lib/libcrypt/crypt.3:1.20 src/lib/libcrypt/crypt.3:1.21
--- src/lib/libcrypt/crypt.3:1.20	Sun Sep  4 23:37:15 2005
+++ src/lib/libcrypt/crypt.3	Wed Dec 28 17:15:23 2011
@@ -1,4 +1,4 @@
-.\"	$NetBSD: crypt.3,v 1.20 2005/09/05 03:37:15 hubertf Exp $
+.\"	$NetBSD: crypt.3,v 1.21 2011/12/28 22:15:23 christos Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)crypt.3	8.2 (Berkeley) 12/11/93
 .\"
-.Dd September 4, 2005
+.Dd December 28, 2011
 .Dt CRYPT 3
 .Os
 .Sh NAME
@@ -43,8 +43,8 @@
 .Lb libcrypt
 .Sh SYNOPSIS
 .In unistd.h
-.Ft char
-.Fn *crypt "const char *key" "const char *setting"
+.Ft "char *"
+.Fn crypt "const char *key" "const char *setting"
 .Ft int
 .Fn encrypt "char *block" "int flag"
 .Ft int
@@ -281,7 +281,14 @@ for interpretation.
 .Sh RETURN VALUES
 The function
 .Fn crypt
-returns a pointer to the encrypted value on success and NULL on failure.
+returns a pointer to the encrypted value on success and 
+.Dv *0
+on failure, or
+.Dv *1
+if the
+.Ar setting
+argument was already
+.Dv *0 .
 The functions
 .Fn setkey ,
 .Fn encrypt ,
@@ -352,3 +359,12 @@ a pointer to that object.
 Subsequent calls to
 .Fn crypt
 will modify the same object.
+.Pp
+Before
+.Nx 6
+.Fn crypt
+returned either
+.Dv NULL
+or
+.Dv :
+on error.



CVS commit: src/lib/libcrypt

2011-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 28 03:13:09 UTC 2011

Modified Files:
src/lib/libcrypt: crypt.c

Log Message:
make __crypt static


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/lib/libcrypt/crypt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/crypt.c
diff -u src/lib/libcrypt/crypt.c:1.32 src/lib/libcrypt/crypt.c:1.33
--- src/lib/libcrypt/crypt.c:1.32	Tue Dec 27 18:34:13 2011
+++ src/lib/libcrypt/crypt.c	Tue Dec 27 22:13:09 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypt.c,v 1.32 2011/12/27 23:34:13 christos Exp $	*/
+/*	$NetBSD: crypt.c,v 1.33 2011/12/28 03:13:09 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)crypt.c	8.1.1.1 (Berkeley) 8/18/93";
 #else
-__RCSID("$NetBSD: crypt.c,v 1.32 2011/12/27 23:34:13 christos Exp $");
+__RCSID("$NetBSD: crypt.c,v 1.33 2011/12/28 03:13:09 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -501,8 +501,7 @@ ascii_is_unsafe(char ch)
  * Return a pointer to static data consisting of the "setting"
  * followed by an encryption produced by the "key" and "setting".
  */
-char *__crypt(const char *, const char *);
-char *
+static char *
 __crypt(const char *key, const char *setting)
 {
 	char *encp;



CVS commit: src/lib/libcrypt

2011-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 28 03:12:38 UTC 2011

Modified Files:
src/lib/libcrypt: bcrypt.c

Log Message:
clamp length to 72 (73) characters.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/lib/libcrypt/bcrypt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/bcrypt.c
diff -u src/lib/libcrypt/bcrypt.c:1.14 src/lib/libcrypt/bcrypt.c:1.15
--- src/lib/libcrypt/bcrypt.c:1.14	Tue Dec 27 18:33:41 2011
+++ src/lib/libcrypt/bcrypt.c	Tue Dec 27 22:12:38 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcrypt.c,v 1.14 2011/12/27 23:33:41 christos Exp $	*/
+/*	$NetBSD: bcrypt.c,v 1.15 2011/12/28 03:12:38 christos Exp $	*/
 /*	$OpenBSD: bcrypt.c,v 1.16 2002/02/19 19:39:36 millert Exp $	*/
 
 /*
@@ -46,7 +46,7 @@
  *
  */
 #include 
-__RCSID("$NetBSD: bcrypt.c,v 1.14 2011/12/27 23:33:41 christos Exp $");
+__RCSID("$NetBSD: bcrypt.c,v 1.15 2011/12/28 03:12:38 christos Exp $");
 
 #include 
 #include 
@@ -269,9 +269,11 @@ __bcrypt(key, salt)
 	decode_base64(csalt, BCRYPT_MAXSALT, (const u_int8_t *)salt);
 	salt_len = BCRYPT_MAXSALT;
 	len = strlen(key);
-	if (len > 253)
-		return NULL;
-	key_len = (uint8_t)len + (minor >= 'a' ? 1 : 0);
+	if (len > 72)
+		key_len = 72;
+	else
+		key_len = (uint8_t)len;
+	key_len += minor >= 'a' ? 1 : 0;
 
 	/* Setting up S-Boxes and Subkeys */
 	Blowfish_initstate(&state);



CVS commit: src/lib/libcrypt

2011-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 27 23:34:13 UTC 2011

Modified Files:
src/lib/libcrypt: crypt.c

Log Message:
wrap crypt() to a function that returns *0 and *1 on error.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/libcrypt/crypt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/crypt.c
diff -u src/lib/libcrypt/crypt.c:1.31 src/lib/libcrypt/crypt.c:1.32
--- src/lib/libcrypt/crypt.c:1.31	Mon Dec 26 20:20:45 2011
+++ src/lib/libcrypt/crypt.c	Tue Dec 27 18:34:13 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypt.c,v 1.31 2011/12/27 01:20:45 christos Exp $	*/
+/*	$NetBSD: crypt.c,v 1.32 2011/12/27 23:34:13 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)crypt.c	8.1.1.1 (Berkeley) 8/18/93";
 #else
-__RCSID("$NetBSD: crypt.c,v 1.31 2011/12/27 01:20:45 christos Exp $");
+__RCSID("$NetBSD: crypt.c,v 1.32 2011/12/27 23:34:13 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -486,7 +486,7 @@ ascii_to_bin(char ch)
 
 	return retval & 0x3f;
 }
-#include 
+
 /*
  * When we choose to "support" invalid salts, nevertheless disallow those
  * containing characters that would violate the passwd file format.
@@ -501,8 +501,9 @@ ascii_is_unsafe(char ch)
  * Return a pointer to static data consisting of the "setting"
  * followed by an encryption produced by the "key" and "setting".
  */
+char *__crypt(const char *, const char *);
 char *
-crypt(const char *key, const char *setting)
+__crypt(const char *key, const char *setting)
 {
 	char *encp;
 	int32_t i;
@@ -613,6 +614,15 @@ crypt(const char *key, const char *setti
 	return (cryptresult);
 }
 
+char *
+crypt(const char *key, const char *salt)
+{
+	char *res = __crypt(key, salt);
+	if (res)
+		return res;
+	/* How do I handle errors ? Return "*0" or "*1" */
+	return __UNCONST(salt[0] == '*' && salt[1] == '0' ? "*1" : "*0");
+}
 
 /*
  * The Key Schedule, filled in by des_setkey() or setkey().



CVS commit: src/lib/libcrypt

2011-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 27 23:33:41 UTC 2011

Modified Files:
src/lib/libcrypt: bcrypt.c

Log Message:
- go back to returning NULL, we are going to wrap crypt instead.
- limit length of key to 253 to prevent truncation.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libcrypt/bcrypt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/bcrypt.c
diff -u src/lib/libcrypt/bcrypt.c:1.13 src/lib/libcrypt/bcrypt.c:1.14
--- src/lib/libcrypt/bcrypt.c:1.13	Tue Dec 27 17:01:26 2011
+++ src/lib/libcrypt/bcrypt.c	Tue Dec 27 18:33:41 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcrypt.c,v 1.13 2011/12/27 22:01:26 christos Exp $	*/
+/*	$NetBSD: bcrypt.c,v 1.14 2011/12/27 23:33:41 christos Exp $	*/
 /*	$OpenBSD: bcrypt.c,v 1.16 2002/02/19 19:39:36 millert Exp $	*/
 
 /*
@@ -46,7 +46,7 @@
  *
  */
 #include 
-__RCSID("$NetBSD: bcrypt.c,v 1.13 2011/12/27 22:01:26 christos Exp $");
+__RCSID("$NetBSD: bcrypt.c,v 1.14 2011/12/27 23:33:41 christos Exp $");
 
 #include 
 #include 
@@ -222,13 +222,13 @@ __bcrypt(key, salt)
 	u_int8_t csalt[BCRYPT_MAXSALT];
 	u_int32_t cdata[BCRYPT_BLOCKS];
 	int n;
+	size_t len;
 
 	/* Discard "$" identifier */
 	salt++;
 
-	if (*salt > BCRYPT_VERSION) {
-		goto out;
-	}
+	if (*salt > BCRYPT_VERSION)
+		return NULL;
 
 	/* Check for minor versions */
 	if (salt[1] != '$') {
@@ -239,7 +239,7 @@ __bcrypt(key, salt)
 			salt++;
 			break;
 		default:
-			goto out;
+			return NULL;
 		}
 	} else
 		 minor = 0;
@@ -249,26 +249,29 @@ __bcrypt(key, salt)
 
 	if (salt[2] != '$')
 		/* Out of sync with passwd entry */
-		goto out;
+		return NULL;
 
 	/* Computer power doesn't increase linear, 2^x should be fine */
 	n = atoi(salt);
 	if (n > 31 || n < 0)
-		goto out;
+		return NULL;
 	logr = (u_int8_t)n;
 	if ((rounds = (u_int32_t) 1 << logr) < BCRYPT_MINROUNDS)
-		goto out;
+		return NULL;
 
 	/* Discard num rounds + "$" identifier */
 	salt += 3;
 
 	if (strlen(salt) * 3 / 4 < BCRYPT_MAXSALT)
-		goto out;
+		return NULL;
 
 	/* We dont want the base64 salt but the raw data */
 	decode_base64(csalt, BCRYPT_MAXSALT, (const u_int8_t *)salt);
 	salt_len = BCRYPT_MAXSALT;
-	key_len = strlen(key) + (minor >= 'a' ? 1 : 0);
+	len = strlen(key);
+	if (len > 253)
+		return NULL;
+	key_len = (uint8_t)len + (minor >= 'a' ? 1 : 0);
 
 	/* Setting up S-Boxes and Subkeys */
 	Blowfish_initstate(&state);
@@ -313,9 +316,6 @@ __bcrypt(key, salt)
 	4 * BCRYPT_BLOCKS - 1);
 	memset(&state, 0, sizeof(state));
 	return encrypted;
-out:
-	/* How do I handle errors ? Return "*0" or "*1" */
-	return __UNCONST(salt[0] == '*' && salt[1] == '0' ? "*1" : "*0");
 }
 
 static void



CVS commit: src/lib/libcrypt

2011-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 27 22:01:26 UTC 2011

Modified Files:
src/lib/libcrypt: bcrypt.c

Log Message:
we want to check against "*0" not "*\0"


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libcrypt/bcrypt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/bcrypt.c
diff -u src/lib/libcrypt/bcrypt.c:1.12 src/lib/libcrypt/bcrypt.c:1.13
--- src/lib/libcrypt/bcrypt.c:1.12	Tue Dec 27 14:36:10 2011
+++ src/lib/libcrypt/bcrypt.c	Tue Dec 27 17:01:26 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcrypt.c,v 1.12 2011/12/27 19:36:10 christos Exp $	*/
+/*	$NetBSD: bcrypt.c,v 1.13 2011/12/27 22:01:26 christos Exp $	*/
 /*	$OpenBSD: bcrypt.c,v 1.16 2002/02/19 19:39:36 millert Exp $	*/
 
 /*
@@ -46,7 +46,7 @@
  *
  */
 #include 
-__RCSID("$NetBSD: bcrypt.c,v 1.12 2011/12/27 19:36:10 christos Exp $");
+__RCSID("$NetBSD: bcrypt.c,v 1.13 2011/12/27 22:01:26 christos Exp $");
 
 #include 
 #include 
@@ -315,7 +315,7 @@ __bcrypt(key, salt)
 	return encrypted;
 out:
 	/* How do I handle errors ? Return "*0" or "*1" */
-	return __UNCONST(salt[0] == '*' && salt[1] == '\0' ? "*1" : "*0");
+	return __UNCONST(salt[0] == '*' && salt[1] == '0' ? "*1" : "*0");
 }
 
 static void



CVS commit: src/lib/libcrypt

2011-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 27 19:36:10 UTC 2011

Modified Files:
src/lib/libcrypt: bcrypt.c

Log Message:
Instead of returning ":" on error, return "*0" or "*1" which will always result
in logged password entries, even if the calling program decides to blindly
use them. Discussed in: http://www.openwall.com/lists/oss-security/2011/11/15/3


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libcrypt/bcrypt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/bcrypt.c
diff -u src/lib/libcrypt/bcrypt.c:1.11 src/lib/libcrypt/bcrypt.c:1.12
--- src/lib/libcrypt/bcrypt.c:1.11	Mon Dec 26 16:51:53 2011
+++ src/lib/libcrypt/bcrypt.c	Tue Dec 27 14:36:10 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcrypt.c,v 1.11 2011/12/26 21:51:53 christos Exp $	*/
+/*	$NetBSD: bcrypt.c,v 1.12 2011/12/27 19:36:10 christos Exp $	*/
 /*	$OpenBSD: bcrypt.c,v 1.16 2002/02/19 19:39:36 millert Exp $	*/
 
 /*
@@ -46,7 +46,7 @@
  *
  */
 #include 
-__RCSID("$NetBSD: bcrypt.c,v 1.11 2011/12/26 21:51:53 christos Exp $");
+__RCSID("$NetBSD: bcrypt.c,v 1.12 2011/12/27 19:36:10 christos Exp $");
 
 #include 
 #include 
@@ -77,7 +77,6 @@ static void decode_base64(u_int8_t *, u_
 char *__bcrypt(const char *, const char *);	/* XXX */
 
 static charencrypted[_PASSWORD_LEN];
-static charerror[] = ":1";
 
 static const u_int8_t Base64Code[] =
 "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
@@ -228,21 +227,20 @@ __bcrypt(key, salt)
 	salt++;
 
 	if (*salt > BCRYPT_VERSION) {
-		/* How do I handle errors ? Return ':' */
-		return error;
+		goto out;
 	}
 
 	/* Check for minor versions */
 	if (salt[1] != '$') {
-		 switch (salt[1]) {
-		 case 'a':
-			 /* 'ab' should not yield the same as 'abab' */
-			 minor = salt[1];
-			 salt++;
-			 break;
-		 default:
-			 return error;
-		 }
+		switch (salt[1]) {
+		case 'a':
+			/* 'ab' should not yield the same as 'abab' */
+			minor = salt[1];
+			salt++;
+			break;
+		default:
+			goto out;
+		}
 	} else
 		 minor = 0;
 
@@ -251,21 +249,21 @@ __bcrypt(key, salt)
 
 	if (salt[2] != '$')
 		/* Out of sync with passwd entry */
-		return error;
+		goto out;
 
 	/* Computer power doesn't increase linear, 2^x should be fine */
 	n = atoi(salt);
 	if (n > 31 || n < 0)
-		return error;
+		goto out;
 	logr = (u_int8_t)n;
 	if ((rounds = (u_int32_t) 1 << logr) < BCRYPT_MINROUNDS)
-		return error;
+		goto out;
 
 	/* Discard num rounds + "$" identifier */
 	salt += 3;
 
 	if (strlen(salt) * 3 / 4 < BCRYPT_MAXSALT)
-		return error;
+		goto out;
 
 	/* We dont want the base64 salt but the raw data */
 	decode_base64(csalt, BCRYPT_MAXSALT, (const u_int8_t *)salt);
@@ -315,6 +313,9 @@ __bcrypt(key, salt)
 	4 * BCRYPT_BLOCKS - 1);
 	memset(&state, 0, sizeof(state));
 	return encrypted;
+out:
+	/* How do I handle errors ? Return "*0" or "*1" */
+	return __UNCONST(salt[0] == '*' && salt[1] == '\0' ? "*1" : "*0");
 }
 
 static void



CVS commit: src/lib/libcrypt

2011-12-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 27 01:20:45 UTC 2011

Modified Files:
src/lib/libcrypt: crypt.c

Log Message:
perform the check for all salts > 2.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/lib/libcrypt/crypt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/crypt.c
diff -u src/lib/libcrypt/crypt.c:1.30 src/lib/libcrypt/crypt.c:1.31
--- src/lib/libcrypt/crypt.c:1.30	Mon Dec 26 17:58:45 2011
+++ src/lib/libcrypt/crypt.c	Mon Dec 26 20:20:45 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypt.c,v 1.30 2011/12/26 22:58:45 christos Exp $	*/
+/*	$NetBSD: crypt.c,v 1.31 2011/12/27 01:20:45 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)crypt.c	8.1.1.1 (Berkeley) 8/18/93";
 #else
-__RCSID("$NetBSD: crypt.c,v 1.30 2011/12/26 22:58:45 christos Exp $");
+__RCSID("$NetBSD: crypt.c,v 1.31 2011/12/27 01:20:45 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -578,7 +578,7 @@ crypt(const char *key, const char *setti
 	salt = 0;
 	for (i = salt_size; --i >= 0; ) {
 		int value = ascii_to_bin(setting[i]);
-		if (salt_size == 4 && itoa64[value] != setting[i])
+		if (salt_size > 2 && itoa64[value] != setting[i])
 			return NULL;
 		encp[i] = setting[i];
 		salt = (salt << 6) | value;



CVS commit: src/lib/libcrypt

2011-12-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 26 22:58:45 UTC 2011

Modified Files:
src/lib/libcrypt: crypt.c

Log Message:
Provide a safer salting method that does not turn invalid salts to '.'.
Be more sensitive to bad salts and counts. From:
http://cvsweb.openwall.com/cgi/cvsweb.cgi/Owl/packages/glibc/crypt_freesec.c
>From Solar Designer


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libcrypt/crypt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/crypt.c
diff -u src/lib/libcrypt/crypt.c:1.29 src/lib/libcrypt/crypt.c:1.30
--- src/lib/libcrypt/crypt.c:1.29	Mon Dec 26 11:03:42 2011
+++ src/lib/libcrypt/crypt.c	Mon Dec 26 17:58:45 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypt.c,v 1.29 2011/12/26 16:03:42 christos Exp $	*/
+/*	$NetBSD: crypt.c,v 1.30 2011/12/26 22:58:45 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)crypt.c	8.1.1.1 (Berkeley) 8/18/93";
 #else
-__RCSID("$NetBSD: crypt.c,v 1.29 2011/12/26 16:03:42 christos Exp $");
+__RCSID("$NetBSD: crypt.c,v 1.30 2011/12/26 22:58:45 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -445,8 +445,6 @@ static const unsigned char itoa64[] =		/
 /* =  Tables that are initialized at run time   */
 
 
-static unsigned char a64toi[128];	/* ascii-64 => 0..63 */
-
 /* Initial key schedule permutation */
 static C_block	PC1ROT[64/CHUNKBITS][1<= 'a')
+		retval = sch - ('a' - 38);
+	else if (sch >= 'A') 
+		retval = sch - ('A' - 12);
+	else
+		retval = sch - '.';
+
+	return retval & 0x3f;
+}
+#include 
+/*
+ * When we choose to "support" invalid salts, nevertheless disallow those
+ * containing characters that would violate the passwd file format.
+ */
+static inline int
+ascii_is_unsafe(char ch)
+{
+	return !ch || ch == '\n' || ch == ':';
+}
 
 /*
  * Return a pointer to static data consisting of the "setting"
@@ -502,7 +529,7 @@ crypt(const char *key, const char *setti
 			key++;
 		keyblock.b[i] = t;
 	}
-	if (des_setkey((char *)keyblock.b))	/* also initializes "a64toi" */
+	if (des_setkey((char *)keyblock.b))
 		return (NULL);
 
 	encp = &cryptresult[0];
@@ -529,12 +556,14 @@ crypt(const char *key, const char *setti
 		/* get iteration count */
 		num_iter = 0;
 		for (i = 4; --i >= 0; ) {
-			if ((t = (unsigned char)setting[i]) == '\0')
-t = '.';
-			encp[i] = t;
-			num_iter = (num_iter << 6) |
-			a64toi[t & (sizeof(a64toi) - 1)];
+			int value = ascii_to_bin(setting[i]);
+			if (itoa64[value] != setting[i])
+return NULL;
+			encp[i] = setting[i];
+			num_iter = (num_iter << 6) | value;
 		}
+		if (num_iter == 0)
+			return NULL;
 		setting += 4;
 		encp += 4;
 		salt_size = 4;
@@ -542,14 +571,17 @@ crypt(const char *key, const char *setti
 	default:
 		num_iter = 25;
 		salt_size = 2;
+		if (ascii_is_unsafe(setting[0]) || ascii_is_unsafe(setting[1]))
+			return NULL;
 	}
 
 	salt = 0;
 	for (i = salt_size; --i >= 0; ) {
-		if ((t = (unsigned char)setting[i]) == '\0')
-			t = '.';
-		encp[i] = t;
-		salt = (salt<<6) | a64toi[t & (sizeof(a64toi) - 1)];
+		int value = ascii_to_bin(setting[i]);
+		if (salt_size == 4 && itoa64[value] != setting[i])
+			return NULL;
+		encp[i] = setting[i];
+		salt = (salt << 6) | value;
 	}
 	encp += salt_size;
 	if (des_cipher((char *)(void *)&constdatablock,
@@ -752,12 +784,6 @@ init_des(void)
 	static unsigned char perm[64], tmp32[32];	/* "static" for speed */
 
 	/*
-	 * table that converts chars "./0-9A-Za-z"to integers 0-63.
-	 */
-	for (i = 0; i < 64; i++)
-		a64toi[itoa64[i]] = i;
-
-	/*
 	 * PC1ROT - bit reverse, then PC1, then Rotate, then PC2.
 	 */
 	for (i = 0; i < 64; i++)



CVS commit: src/lib/libcrypt

2011-12-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 26 21:51:53 UTC 2011

Modified Files:
src/lib/libcrypt: bcrypt.c

Log Message:
Return ":1" on error instead of ":", so that sloppy password creation programs
don't end up confusing libc or the other way around. From Solar Designer


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libcrypt/bcrypt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/bcrypt.c
diff -u src/lib/libcrypt/bcrypt.c:1.10 src/lib/libcrypt/bcrypt.c:1.11
--- src/lib/libcrypt/bcrypt.c:1.10	Mon May 16 06:45:56 2011
+++ src/lib/libcrypt/bcrypt.c	Mon Dec 26 16:51:53 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcrypt.c,v 1.10 2011/05/16 10:45:56 drochner Exp $	*/
+/*	$NetBSD: bcrypt.c,v 1.11 2011/12/26 21:51:53 christos Exp $	*/
 /*	$OpenBSD: bcrypt.c,v 1.16 2002/02/19 19:39:36 millert Exp $	*/
 
 /*
@@ -46,7 +46,7 @@
  *
  */
 #include 
-__RCSID("$NetBSD: bcrypt.c,v 1.10 2011/05/16 10:45:56 drochner Exp $");
+__RCSID("$NetBSD: bcrypt.c,v 1.11 2011/12/26 21:51:53 christos Exp $");
 
 #include 
 #include 
@@ -77,7 +77,7 @@ static void decode_base64(u_int8_t *, u_
 char *__bcrypt(const char *, const char *);	/* XXX */
 
 static charencrypted[_PASSWORD_LEN];
-static charerror[] = ":";
+static charerror[] = ":1";
 
 static const u_int8_t Base64Code[] =
 "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";



CVS commit: src/lib/libcrypt

2011-12-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 26 16:03:42 UTC 2011

Modified Files:
src/lib/libcrypt: crypt.c

Log Message:
avoid accessing array over its bound, from Solar Designer


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/libcrypt/crypt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/crypt.c
diff -u src/lib/libcrypt/crypt.c:1.28 src/lib/libcrypt/crypt.c:1.29
--- src/lib/libcrypt/crypt.c:1.28	Thu Apr 30 20:28:17 2009
+++ src/lib/libcrypt/crypt.c	Mon Dec 26 11:03:42 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypt.c,v 1.28 2009/05/01 00:28:17 perry Exp $	*/
+/*	$NetBSD: crypt.c,v 1.29 2011/12/26 16:03:42 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)crypt.c	8.1.1.1 (Berkeley) 8/18/93";
 #else
-__RCSID("$NetBSD: crypt.c,v 1.28 2009/05/01 00:28:17 perry Exp $");
+__RCSID("$NetBSD: crypt.c,v 1.29 2011/12/26 16:03:42 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -532,7 +532,8 @@ crypt(const char *key, const char *setti
 			if ((t = (unsigned char)setting[i]) == '\0')
 t = '.';
 			encp[i] = t;
-			num_iter = (num_iter<<6) | a64toi[t];
+			num_iter = (num_iter << 6) |
+			a64toi[t & (sizeof(a64toi) - 1)];
 		}
 		setting += 4;
 		encp += 4;
@@ -548,7 +549,7 @@ crypt(const char *key, const char *setti
 		if ((t = (unsigned char)setting[i]) == '\0')
 			t = '.';
 		encp[i] = t;
-		salt = (salt<<6) | a64toi[t];
+		salt = (salt<<6) | a64toi[t & (sizeof(a64toi) - 1)];
 	}
 	encp += salt_size;
 	if (des_cipher((char *)(void *)&constdatablock,



CVS commit: src/lib/libcrypt

2011-11-29 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Tue Nov 29 17:27:10 UTC 2011

Modified Files:
src/lib/libcrypt: md5crypt.c

Log Message:
remove the option to build this against openssl - this hasn't been used
in the NetBSD build
since the libc version of MD5Final zeroes out the context, replace
the bzero introduced in the previous commit by comments telling that


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libcrypt/md5crypt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/md5crypt.c
diff -u src/lib/libcrypt/md5crypt.c:1.10 src/lib/libcrypt/md5crypt.c:1.11
--- src/lib/libcrypt/md5crypt.c:1.10	Tue Nov 29 13:18:52 2011
+++ src/lib/libcrypt/md5crypt.c	Tue Nov 29 17:27:10 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: md5crypt.c,v 1.10 2011/11/29 13:18:52 drochner Exp $	*/
+/*	$NetBSD: md5crypt.c,v 1.11 2011/11/29 17:27:10 drochner Exp $	*/
 
 /*
  * 
@@ -15,38 +15,22 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: md5crypt.c,v 1.10 2011/11/29 13:18:52 drochner Exp $");
+__RCSID("$NetBSD: md5crypt.c,v 1.11 2011/11/29 17:27:10 drochner Exp $");
 #endif /* not lint */
 
-/*
- * NOTE: We are also built for inclusion in libcrypto; when built for that
- * environment, use the libcrypto versions of the MD5 routines, so save
- * having to pull two versions into the same program.
- */
-
 #include 
 #include 
 #include 
-#ifdef libcrypto
-#include 
-#else
 #include 
-#endif
 
 #include "crypt.h"
 
 #define MD5_MAGIC	"$1$"
 #define MD5_MAGIC_LEN	3
 
-#ifdef libcrypto
-#define	INIT(x)			MD5_Init((x))
-#define	UPDATE(x, b, l)		MD5_Update((x), (b), (l))
-#define	FINAL(v, x)		MD5_Final((v), (x))
-#else
 #define	INIT(x)			MD5Init((x))
 #define	UPDATE(x, b, l)		MD5Update((x), (b), (l))
 #define	FINAL(v, x)		MD5Final((v), (x))
-#endif
 
 
 /*
@@ -117,8 +101,7 @@ __md5crypt(const char *pw, const char *s
 
 	FINAL(final, &ctx);
 
-	/* Don't leave anything around in vm they could use. */
-	memset(&ctx, 0, sizeof(ctx));
+	/* memset(&ctx, 0, sizeof(ctx)); done by MD5Final() */
 
 	/*
 	 * And now, just to make sure things don't run too fast. On a 60 MHz
@@ -147,8 +130,7 @@ __md5crypt(const char *pw, const char *s
 		FINAL(final, &ctx1);
 	}
 
-	/* Don't leave anything around in vm they could use. */
-	memset(&ctx1, 0, sizeof(ctx1));
+	/* memset(&ctx1, 0, sizeof(ctx1)); done by MD5Final() */
 
 	p = passwd + sl + MD5_MAGIC_LEN + 1;
 



CVS commit: src/lib/libcrypt

2011-11-29 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Tue Nov 29 13:18:52 UTC 2011

Modified Files:
src/lib/libcrypt: md5crypt.c

Log Message:
zero out hash context after use, to avoid traces in RAM
(hint from "Solar Designer")


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libcrypt/md5crypt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/md5crypt.c
diff -u src/lib/libcrypt/md5crypt.c:1.9 src/lib/libcrypt/md5crypt.c:1.10
--- src/lib/libcrypt/md5crypt.c:1.9	Wed Jan 17 23:24:22 2007
+++ src/lib/libcrypt/md5crypt.c	Tue Nov 29 13:18:52 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: md5crypt.c,v 1.9 2007/01/17 23:24:22 hubertf Exp $	*/
+/*	$NetBSD: md5crypt.c,v 1.10 2011/11/29 13:18:52 drochner Exp $	*/
 
 /*
  * 
@@ -15,7 +15,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: md5crypt.c,v 1.9 2007/01/17 23:24:22 hubertf Exp $");
+__RCSID("$NetBSD: md5crypt.c,v 1.10 2011/11/29 13:18:52 drochner Exp $");
 #endif /* not lint */
 
 /*
@@ -117,6 +117,9 @@ __md5crypt(const char *pw, const char *s
 
 	FINAL(final, &ctx);
 
+	/* Don't leave anything around in vm they could use. */
+	memset(&ctx, 0, sizeof(ctx));
+
 	/*
 	 * And now, just to make sure things don't run too fast. On a 60 MHz
 	 * Pentium this takes 34 msec, so you would need 30 seconds to build
@@ -144,6 +147,9 @@ __md5crypt(const char *pw, const char *s
 		FINAL(final, &ctx1);
 	}
 
+	/* Don't leave anything around in vm they could use. */
+	memset(&ctx1, 0, sizeof(ctx1));
+
 	p = passwd + sl + MD5_MAGIC_LEN + 1;
 
 	l = (final[ 0]<<16) | (final[ 6]<<8) | final[12]; __crypt_to64(p,l,4); p += 4;



CVS commit: src/lib/libcrypt

2011-05-16 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Mon May 16 10:45:56 UTC 2011

Modified Files:
src/lib/libcrypt: bcrypt.c

Log Message:
-fix maximum length of salt (missing prefix, rounding error)
-clip number of rounds at 31 -- this is log2 of the real number,
 and anything larger would break exponentation
-catch possible atoi() error where log2(rounds) is parsed in the
 salt prefix
-zero crypto state on exit
from Open/FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libcrypt/bcrypt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/bcrypt.c
diff -u src/lib/libcrypt/bcrypt.c:1.9 src/lib/libcrypt/bcrypt.c:1.10
--- src/lib/libcrypt/bcrypt.c:1.9	Fri Oct 27 19:39:11 2006
+++ src/lib/libcrypt/bcrypt.c	Mon May 16 10:45:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcrypt.c,v 1.9 2006/10/27 19:39:11 drochner Exp $	*/
+/*	$NetBSD: bcrypt.c,v 1.10 2011/05/16 10:45:56 drochner Exp $	*/
 /*	$OpenBSD: bcrypt.c,v 1.16 2002/02/19 19:39:36 millert Exp $	*/
 
 /*
@@ -46,7 +46,7 @@
  *
  */
 #include 
-__RCSID("$NetBSD: bcrypt.c,v 1.9 2006/10/27 19:39:11 drochner Exp $");
+__RCSID("$NetBSD: bcrypt.c,v 1.10 2011/05/16 10:45:56 drochner Exp $");
 
 #include 
 #include 
@@ -66,7 +66,7 @@
 
 #define BCRYPT_VERSION '2'
 #define BCRYPT_MAXSALT 16	/* Precomputation is just so nice */
-#define BCRYPT_MAXSALTLEN 	(BCRYPT_MAXSALT * 4 / 3 + 1)
+#define BCRYPT_MAXSALTLEN 	(7 + (BCRYPT_MAXSALT * 4 + 2) / 3 + 1)
 #define BCRYPT_BLOCKS 6		/* Ciphertext blocks */
 #define BCRYPT_MINROUNDS 16	/* we have log2(rounds) in salt */
 
@@ -175,13 +175,10 @@
 	if (errno == ERANGE && nrounds == ULONG_MAX)
 		return -1;
 
-	if (nrounds > 255) {
-		errno = EINVAL;
-		return -1;
-	}
-
 	if (nrounds < 4)
 		nrounds = 4;
+	else if (nrounds > 31)
+		nrounds = 31;
 
 	for (i = 0; i < BCRYPT_MAXSALT; i++) {
 		if (i % 4 == 0)
@@ -225,6 +222,7 @@
 	u_int8_t ciphertext[4 * BCRYPT_BLOCKS] = "OrpheanBeholderScryDoubt";
 	u_int8_t csalt[BCRYPT_MAXSALT];
 	u_int32_t cdata[BCRYPT_BLOCKS];
+	int n;
 
 	/* Discard "$" identifier */
 	salt++;
@@ -256,7 +254,11 @@
 		return error;
 
 	/* Computer power doesn't increase linear, 2^x should be fine */
-	if ((rounds = (u_int32_t) 1 << (logr = atoi(salt))) < BCRYPT_MINROUNDS)
+	n = atoi(salt);
+	if (n > 31 || n < 0)
+		return error;
+	logr = (u_int8_t)n;
+	if ((rounds = (u_int32_t) 1 << logr) < BCRYPT_MINROUNDS)
 		return error;
 
 	/* Discard num rounds + "$" identifier */
@@ -311,6 +313,7 @@
 	encode_base64((u_int8_t *) encrypted + i + 3, csalt, BCRYPT_MAXSALT);
 	encode_base64((u_int8_t *) encrypted + strlen(encrypted), ciphertext,
 	4 * BCRYPT_BLOCKS - 1);
+	memset(&state, 0, sizeof(state));
 	return encrypted;
 }
 



CVS commit: src/lib/libcrypt

2011-05-16 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Mon May 16 10:39:12 UTC 2011

Modified Files:
src/lib/libcrypt: hmac.c

Log Message:
fix ipad/opad buffer length (was one too much), just for sanity


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libcrypt/hmac.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/hmac.c
diff -u src/lib/libcrypt/hmac.c:1.2 src/lib/libcrypt/hmac.c:1.3
--- src/lib/libcrypt/hmac.c:1.2	Sun Jan 18 12:15:27 2009
+++ src/lib/libcrypt/hmac.c	Mon May 16 10:39:12 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: hmac.c,v 1.2 2009/01/18 12:15:27 lukem Exp $ */
+/* $NetBSD: hmac.c,v 1.3 2011/05/16 10:39:12 drochner Exp $ */
 
 /*
  * Copyright (c) 2004, Juniper Networks, Inc.
@@ -42,7 +42,7 @@
  */
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: hmac.c,v 1.2 2009/01/18 12:15:27 lukem Exp $");
+__RCSID("$NetBSD: hmac.c,v 1.3 2011/05/16 10:39:12 drochner Exp $");
 #endif /* not lint */
 
 #include 
@@ -70,9 +70,9 @@
 {
 HASH_CTX context;
 /* Inner padding key XOR'd with ipad */
-unsigned char k_ipad[HMAC_BLOCKSZ + 1];
+unsigned char k_ipad[HMAC_BLOCKSZ];
 /* Outer padding key XOR'd with opad */
-unsigned char k_opad[HMAC_BLOCKSZ + 1];
+unsigned char k_opad[HMAC_BLOCKSZ];
 /* HASH(key) if needed */
 unsigned char tk[HASH_LENGTH];	
 size_t i;



CVS commit: src/lib/libcrypt

2011-05-09 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Mon May  9 19:15:29 UTC 2011

Modified Files:
src/lib/libcrypt: crypt-sha1.c

Log Message:
rearrange variable usage to kill __UNCONST
reviewed by sjg


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libcrypt/crypt-sha1.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/crypt-sha1.c
diff -u src/lib/libcrypt/crypt-sha1.c:1.3 src/lib/libcrypt/crypt-sha1.c:1.4
--- src/lib/libcrypt/crypt-sha1.c:1.3	Fri Oct 27 18:22:56 2006
+++ src/lib/libcrypt/crypt-sha1.c	Mon May  9 19:15:28 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: crypt-sha1.c,v 1.3 2006/10/27 18:22:56 drochner Exp $ */
+/* $NetBSD: crypt-sha1.c,v 1.4 2011/05/09 19:15:28 drochner Exp $ */
 
 /*
  * Copyright (c) 2004, Juniper Networks, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: crypt-sha1.c,v 1.3 2006/10/27 18:22:56 drochner Exp $");
+__RCSID("$NetBSD: crypt-sha1.c,v 1.4 2011/05/09 19:15:28 drochner Exp $");
 #endif /* not lint */
 
 #include 
@@ -122,7 +122,7 @@
 static unsigned char hmac_buf[SHA1_SIZE];
 static char passwd[(2 * sizeof(SHA1_MAGIC)) +
 		   CRYPT_SHA1_SALT_LENGTH + SHA1_SIZE];
-char *sp;
+const char *sp;
 char *ep;
 unsigned long ul;
 int sl;
@@ -136,26 +136,25 @@
  * $$$salt[$]
  * If it does not start with $ we use our default iterations.
  */
-sp = __UNCONST(salt);
 
 /* If it starts with the magic string, then skip that */
-if (!strncmp(sp, magic, strlen(magic))) {
-	sp += strlen(magic);
+if (!strncmp(salt, magic, strlen(magic))) {
+	salt += strlen(magic);
 	/* and get the iteration count */
-	iterations = strtoul(sp, &ep, 10);
+	iterations = strtoul(salt, &ep, 10);
 	if (*ep != '$')
 	return NULL;		/* invalid input */
-	sp = ep + 1;			/* skip over the '$' */
+	salt = ep + 1;			/* skip over the '$' */
 } else {
 	iterations = __crypt_sha1_iterations(0);
 }
 
 /* It stops at the next '$', max CRYPT_SHA1_ITERATIONS chars */
-for (ep = sp; *ep && *ep != '$' && ep < (sp + CRYPT_SHA1_ITERATIONS); ep++)
+for (sp = salt; *sp && *sp != '$' && sp < (salt + CRYPT_SHA1_ITERATIONS); sp++)
 	continue;
 
 /* Get the length of the actual salt */
-sl = ep - sp;
+sl = sp - salt;
 pl = strlen(pw);
 
 /*
@@ -163,18 +162,17 @@
  * Prime the pump with 
  */
 dl = snprintf(passwd, sizeof (passwd), "%.*s%s%u", 
-		  sl, sp, magic, iterations);
+		  sl, salt, magic, iterations);
 /*
  * Then hmac using  as key, and repeat...
  */
-ep = __UNCONST(pw);			/* keep gcc happy */
-__hmac_sha1(passwd, dl, ep, pl, hmac_buf);
+__hmac_sha1(passwd, dl, pw, pl, hmac_buf);
 for (i = 1; i < iterations; i++) {
-	__hmac_sha1(hmac_buf, SHA1_SIZE, ep, pl, hmac_buf);
+	__hmac_sha1(hmac_buf, SHA1_SIZE, pw, pl, hmac_buf);
 }
 /* Now output... */
 pl = snprintf(passwd, sizeof(passwd), "%s%u$%.*s$",
-		  magic, iterations, sl, sp);
+		  magic, iterations, sl, salt);
 ep = passwd + pl;
 
 /* Every 3 bytes of hash gives 24 bits which is 4 base64 chars */



CVS commit: src/lib/libcrypt

2009-04-30 Thread Perry E. Metzger
Module Name:src
Committed By:   perry
Date:   Fri May  1 00:28:17 UTC 2009

Modified Files:
src/lib/libcrypt: crypt.c

Log Message:
ANSI function prototypes


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libcrypt/crypt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/crypt.c
diff -u src/lib/libcrypt/crypt.c:1.27 src/lib/libcrypt/crypt.c:1.28
--- src/lib/libcrypt/crypt.c:1.27	Fri May  1 00:20:08 2009
+++ src/lib/libcrypt/crypt.c	Fri May  1 00:28:17 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypt.c,v 1.27 2009/05/01 00:20:08 perry Exp $	*/
+/*	$NetBSD: crypt.c,v 1.28 2009/05/01 00:28:17 perry Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)crypt.c	8.1.1.1 (Berkeley) 8/18/93";
 #else
-__RCSID("$NetBSD: crypt.c,v 1.27 2009/05/01 00:20:08 perry Exp $");
+__RCSID("$NetBSD: crypt.c,v 1.28 2009/05/01 00:28:17 perry Exp $");
 #endif
 #endif /* not lint */
 
@@ -300,11 +300,7 @@
 
 #ifndef LARGEDATA
 STATIC
-permute(cp, out, p, chars_in)
-	const unsigned char *cp;
-	C_block *out;
-	C_block *p;
-	int chars_in;
+permute(const unsigned char *cp, C_block *out, C_block *p, int chars_in)
 {
 	DCL_BLOCK(D,D0,D1);
 	C_block *tp;
@@ -479,9 +475,7 @@
  * followed by an encryption produced by the "key" and "setting".
  */
 char *
-crypt(key, setting)
-	const char *key;
-	const char *setting;
+crypt(const char *key, const char *setting)
 {
 	char *encp;
 	int32_t i;
@@ -597,8 +591,7 @@
  * Set up the key schedule from the key.
  */
 int
-des_setkey(key)
-	const char *key;
+des_setkey(const char *key)
 {
 	DCL_BLOCK(K, K0, K1);
 	C_block *help, *ptabp;
@@ -632,11 +625,7 @@
  * compiler and machine architecture.
  */
 int
-des_cipher(in, out, salt, num_iter)
-	const char *in;
-	char *out;
-	long salt;
-	int num_iter;
+des_cipher(const char *in, char *out, long salt, int num_iter)
 {
 	/* variables that we want in registers, most important first */
 #if defined(pdp11)
@@ -754,7 +743,7 @@
  * done at compile time, if the compiler were capable of that sort of thing.
  */
 STATIC
-init_des()
+init_des(void)
 {
 	int i, j;
 	int32_t k;
@@ -898,10 +887,8 @@
  * "perm" must be all-zeroes on entry to this routine.
  */
 STATIC
-init_perm(perm, p, chars_in, chars_out)
-	C_block perm[64/CHUNKBITS][1<
 
 int
-main (int argc, char *argv[])
+main(int argc, char *argv[])
 {
 if (argc < 2)
 	errx(1, "Usage: %s password [salt]\n", argv[0]);



CVS commit: src/lib/libcrypt

2009-04-30 Thread Perry E. Metzger
Module Name:src
Committed By:   perry
Date:   Fri May  1 00:20:08 UTC 2009

Modified Files:
src/lib/libcrypt: crypt.c

Log Message:
de-__P


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libcrypt/crypt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libcrypt/crypt.c
diff -u src/lib/libcrypt/crypt.c:1.26 src/lib/libcrypt/crypt.c:1.27
--- src/lib/libcrypt/crypt.c:1.26	Wed Jan 17 23:24:22 2007
+++ src/lib/libcrypt/crypt.c	Fri May  1 00:20:08 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypt.c,v 1.26 2007/01/17 23:24:22 hubertf Exp $	*/
+/*	$NetBSD: crypt.c,v 1.27 2009/05/01 00:20:08 perry Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)crypt.c	8.1.1.1 (Berkeley) 8/18/93";
 #else
-__RCSID("$NetBSD: crypt.c,v 1.26 2007/01/17 23:24:22 hubertf Exp $");
+__RCSID("$NetBSD: crypt.c,v 1.27 2009/05/01 00:20:08 perry Exp $");
 #endif
 #endif /* not lint */
 
@@ -287,14 +287,14 @@
 	{ C_block tblk; permute(cpp,&tblk,p,4); LOAD (d,d0,d1,tblk); }
 #endif /* LARGEDATA */
 
-STATIC	init_des __P((void));
-STATIC	init_perm __P((C_block [64/CHUNKBITS][1<