Permalink
Browse files

Update crypt_blowfish to 1.2 (no security fixes)

  • Loading branch information...
1 parent 4aefe29 commit 8a17a3cca8db46973844a98b01424ae59aea5787 @rg3 committed May 26, 2013
View
@@ -1,13 +1,24 @@
#
-# Written by Solar Designer and placed in the public domain.
+# Written and revised by Solar Designer <solar at openwall.com> in 2000-2011.
+# No copyright is claimed, and the software is hereby placed in the public
+# domain. In case this attempt to disclaim copyright and place the software
+# in the public domain is deemed null and void, then the software is
+# Copyright (c) 2000-2011 Solar Designer and it is hereby released to the
+# general public under the following terms:
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted.
+#
+# There's ABSOLUTELY NO WARRANTY, express or implied.
+#
# See crypt_blowfish.c for more information.
#
CC = gcc
AS = $(CC)
LD = $(CC)
RM = rm -f
-CFLAGS = -Wall -O2 -fomit-frame-pointer -funroll-loops
+CFLAGS = -W -Wall -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wundef -Wpointer-arith -O2 -fomit-frame-pointer -funroll-loops
ASFLAGS = -c
LDFLAGS = -s
@@ -38,7 +49,7 @@ check: crypt_test
crypt_test: $(TEST_OBJS)
$(LD) $(LDFLAGS) $(TEST_OBJS) -o $@
-crypt_test.o: wrapper.c
+crypt_test.o: wrapper.c ow-crypt.h crypt_blowfish.h crypt_gensalt.h
$(CC) -c $(CFLAGS) wrapper.c -DTEST -o $@
check_threads: crypt_test_threads
@@ -47,14 +58,18 @@ check_threads: crypt_test_threads
crypt_test_threads: $(TEST_THREADS_OBJS)
$(LD) $(LDFLAGS) $(TEST_THREADS_OBJS) -lpthread -o $@
-crypt_test_threads.o: wrapper.c
+crypt_test_threads.o: wrapper.c ow-crypt.h crypt_blowfish.h crypt_gensalt.h
$(CC) -c $(CFLAGS) wrapper.c -DTEST -DTEST_THREADS=4 -o $@
man: $(EXTRA_MANS)
$(EXTRA_MANS):
echo '.so man3/crypt.3' > $@
+crypt_blowfish.o: crypt_blowfish.h
+crypt_gensalt.o: crypt_gensalt.h
+wrapper.o: crypt.h ow-crypt.h crypt_blowfish.h crypt_gensalt.h
+
.c.o:
$(CC) -c $(CFLAGS) $*.c
@@ -10,6 +10,11 @@ PA-RISC 7100LC, 80 MHz 8.5 c/s 16.3 c/s (+92%)
(*) built with -fomit-frame-pointer -funroll-loops, which I don't
think happens for libcrypt.
+Starting with version 1.1 released in June 2011, default builds of
+crypt_blowfish invoke a quick self-test on every hash computation.
+This has roughly a 4.8% performance impact at "$2a$05", but only a 0.6%
+impact at a more typical setting of "$2a$08".
+
The large speedup for the original Pentium is due to the assembly
code and the weird optimizations this processor requires.
@@ -22,4 +27,4 @@ additional 15% speedup on the Pentium Pro family of processors (which
includes Pentium III) with a separate version of the assembly code and
run-time CPU detection.
-$Owl: Owl/packages/glibc/crypt_blowfish/PERFORMANCE,v 1.5 2005/11/16 13:09:47 solar Exp $
+$Owl: Owl/packages/glibc/crypt_blowfish/PERFORMANCE,v 1.6 2011/06/21 12:09:20 solar Exp $
View
@@ -1,9 +1,12 @@
-This is an implementation of a password hashing algorithm, provided
-via the crypt(3) and a reentrant interface. It is compatible with
-OpenBSD bcrypt.c (version 2a) by Niels Provos and David Mazieres.
+This is an implementation of a password hashing method, provided via the
+crypt(3) and a reentrant interface. It is mostly compatible with
+OpenBSD's bcrypt.c (prefix "$2a$") by Niels Provos and David Mazieres.
+(Please refer to the included crypt(3) man page for information on
+compatibility issues.)
-I've placed this code in the public domain. Please, see the comment
-in crypt_blowfish.c for more information.
+I've placed this code in the public domain, with fallback to a
+permissive license. Please see the comment in crypt_blowfish.c for
+more information.
You can use the provided routines in your own packages, or link them
into a C library. I've provided hooks for linking into GNU libc, but
@@ -30,6 +33,21 @@ will produce no code in this case).
2. Building the routines into GNU C library.
+For versions 2.13 and 2.14 (and likely other nearby ones), extract the
+library sources as usual. Apply the patch for glibc 2.14 provided in
+this package. Enter crypt/ and rename crypt.h to gnu-crypt.h within
+that directory. Copy the C sources, header, and assembly (x86.S) files
+from this package in there as well (but be sure you don't overwrite the
+Makefile). Configure, build, and install the library as usual.
+
+For versions 2.2 to 2.3.6 (and likely also for some newer ones),
+extract the library sources and maybe its optional add-ons as usual.
+Apply the patch for glibc 2.3.6 provided in this package. Enter
+crypt/ and rename crypt.h to gnu-crypt.h within that directory. Copy
+the C sources, header, and assembly (x86.S) files from this package in
+there as well (but be sure you don't overwrite the Makefile).
+Configure, build, and install the library as usual.
+
For versions 2.1 to 2.1.3, extract the library sources and the crypt
and linuxthreads add-ons as usual. Apply the patch for glibc 2.1.3
provided in this package. Enter crypt/sysdeps/unix/, and rename
@@ -38,14 +56,6 @@ and assembly (x86.S) files from this package in there as well (but be
sure you don't overwrite the Makefile). Configure, build, and install
the library as usual.
-For versions 2.2 to 2.3.6 (and likely also for some newer ones),
-extract the library sources and the linuxthreads add-on as usual.
-Apply the patch for glibc 2.3.2 provided in this package. Enter
-crypt/ and rename crypt.h to gnu-crypt.h within that directory. Copy
-the C sources, header, and assembly (x86.S) files from this package in
-there as well (but be sure you don't overwrite the Makefile).
-Configure, build, and install the library as usual.
-
Programs that want to use the provided interfaces will need to include
crypt.h (but not ow-crypt.h directly). By default, prototypes for the
new routines aren't defined (but the extra functionality of crypt(3)
@@ -55,4 +65,4 @@ routines as well.
--
Solar Designer <solar at openwall.com>
-$Owl: Owl/packages/glibc/crypt_blowfish/README,v 1.6 2006/01/02 19:04:19 solar Exp $
+$Owl: Owl/packages/glibc/crypt_blowfish/README,v 1.9 2011/07/16 21:48:45 solar Exp $
View
@@ -1,9 +1,19 @@
-.\" Written by Solar Designer and placed in the public domain.
+.\" Written and revised by Solar Designer <solar at openwall.com> in 2000-2011.
+.\" No copyright is claimed, and this man page is hereby placed in the public
+.\" domain. In case this attempt to disclaim copyright and place the man page
+.\" in the public domain is deemed null and void, then the man page is
+.\" Copyright (c) 2000-2011 Solar Designer and it is hereby released to the
+.\" general public under the following terms:
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted.
+.\"
+.\" There's ABSOLUTELY NO WARRANTY, express or implied.
.\"
.\" This manual page in its current form is intended for use on systems
.\" based on the GNU C Library with crypt_blowfish patched into libcrypt.
.\"
-.TH CRYPT 3 "22 February 2005" "Openwall Project" "Library functions"
+.TH CRYPT 3 "July 16, 2011" "Openwall Project" "Library functions"
.ad l
.\" No macros in NAME to keep makewhatis happy.
.SH NAME
@@ -404,7 +414,7 @@ and the BSDI-style DES-based hashing offer a variable iteration count,
may scale to even faster hardware, doesn't allow for certain optimizations
specific to password cracking only, doesn't have the effective key size
limitation, and uses 8-bit characters in passwords.
-.hash "$2a$" "\e$2a\e$[0-9]{2}\e$[./A-Za-z0-9]{53}" 72 8 "" 184 128 "2**4 to 2**99 (current implementations are limited to 2**31 iterations)"
+.hash "$2y$" "\e$2[axy]\e$[0-9]{2}\e$[./A-Za-z0-9]{53}" 72 8 "" 184 128 "2**4 to 2**99 (current implementations are limited to 2**31 iterations)"
.PP
With
.BR bcrypt ,
@@ -413,6 +423,29 @@ the
passed to
.crypt_gensalt and
is the base-2 logarithm of the actual iteration count.
+.PP
+.B bcrypt
+hashes used the "$2a$" prefix since 1997.
+However, in 2011 an implementation bug was discovered in crypt_blowfish
+(versions up to 1.0.4 inclusive) affecting handling of password characters with
+the 8th bit set.
+Besides fixing the bug,
+to provide for upgrade strategies for existing systems, two new prefixes were
+introduced: "$2x$", which fully re-introduces the bug, and "$2y$", which
+guarantees correct handling of both 7- and 8-bit characters (same as OpenBSD's
+"$2a$").
+Unfortunately, the behavior of "$2a$" on password characters with the 8th bit
+set has to be considered system-specific.
+When generating new password hashes, the "$2y$" prefix should be used.
+(If such hashes ever need to be migrated to a system that does not yet support
+this new prefix, the prefix in migrated copies of the already-generated hashes
+may be changed to "$2a$".)
+.PP
+.crypt_gensalt and
+support the "$2y$" and "$2a$" prefixes (the latter for legacy programs or
+configurations), but not "$2x$" (which must not be used for new hashes).
+.crypt and
+support all three of these prefixes.
.SH PORTABILITY NOTES
Programs using any of these functions on a glibc 2.x system must be
linked against
View
@@ -1,5 +1,16 @@
/*
- * Written by Solar Designer and placed in the public domain.
+ * Written by Solar Designer <solar at openwall.com> in 2000-2002.
+ * No copyright is claimed, and the software is hereby placed in the public
+ * domain. In case this attempt to disclaim copyright and place the software
+ * in the public domain is deemed null and void, then the software is
+ * Copyright (c) 2000-2002 Solar Designer and it is hereby released to the
+ * general public under the following terms:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted.
+ *
+ * There's ABSOLUTELY NO WARRANTY, express or implied.
+ *
* See crypt_blowfish.c for more information.
*/
Oops, something went wrong.

0 comments on commit 8a17a3c

Please sign in to comment.