Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* crypt/Makefile (libcrypt-routines): Add sha256-crypt, sha256,
	sha512-crypt, and sha512.
	(tests): Add sha256test, sha256c-test, sha512test, and sha512c-test.
	(distribute): Add sha256.h and sha512.h.
	* crypt/crypt-entry.c (crypt): Recognize the new $5$ and $6$ prefixes
	and call the appropriate code.
	* crypt/sha256-crypt.c: New file.
	* crypt/sha256.c: New file.
	* crypt/sha256.h: New file.
	* crypt/sha256c-test.c: New file.
	* crypt/sha256test.c: New file.
	* crypt/sha512-crypt.c: New file.
	* crypt/sha512.c: New file.
	* crypt/sha512.h: New file.
	* crypt/sha512c-test.c: New file.
	* crypt/sha512test.c: New file.

	* sysdeps/unix/sysv/linux/sparc/sparc32/clone.S (__thread_start):
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/clone.S (__thread_start):
	Likewise.
  • Loading branch information
Ulrich Drepper committed Sep 19, 2007
1 parent 9425cb9 commit c3266dc
Show file tree
Hide file tree
Showing 12 changed files with 1,502 additions and 7 deletions.
25 changes: 23 additions & 2 deletions ChangeLog
@@ -1,3 +1,22 @@
2007-09-19 Ulrich Drepper <drepper@redhat.com>

* crypt/Makefile (libcrypt-routines): Add sha256-crypt, sha256,
sha512-crypt, and sha512.
(tests): Add sha256test, sha256c-test, sha512test, and sha512c-test.
(distribute): Add sha256.h and sha512.h.
* crypt/crypt-entry.c (crypt): Recognize the new $5$ and $6$ prefixes
and call the appropriate code.
* crypt/sha256-crypt.c: New file.
* crypt/sha256.c: New file.
* crypt/sha256.h: New file.
* crypt/sha256c-test.c: New file.
* crypt/sha256test.c: New file.
* crypt/sha512-crypt.c: New file.
* crypt/sha512.c: New file.
* crypt/sha512.h: New file.
* crypt/sha512c-test.c: New file.
* crypt/sha512test.c: New file.

2007-09-19 Jakub Jelinek <jakub@redhat.com>

* misc/bits/syslog.h (syslog): Remove extraneous argument from
Expand All @@ -11,8 +30,10 @@

* sysdeps/sparc/sparc32/elf/start.S: Remove cfi_* markup.
* sysdeps/sparc/sparc64/elf/start.S: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/clone.S (__thread_start): Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/clone.S (__thread_start): Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/clone.S (__thread_start):
Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/clone.S (__thread_start):
Likewise.

* sysdeps/generic/ldsodefs.h (DL_LOOKUP_GSCOPE_LOCK): New definition.
* elf/dl-runtime.c (_dl_fixup, _dl_profile_fixup): Or in
Expand Down
11 changes: 7 additions & 4 deletions crypt/Makefile
@@ -1,4 +1,4 @@
# Copyright (C) 1996, 2000, 2001 Free Software Foundation, Inc.
# Copyright (C) 1996, 2000, 2001, 2007 Free Software Foundation, Inc.
# This file is part of the GNU C Library.

# The GNU C Library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -26,12 +26,13 @@ headers := crypt.h
extra-libs := libcrypt
extra-libs-others := $(extra-libs)

libcrypt-routines := crypt-entry md5-crypt md5 crypt crypt_util
libcrypt-routines := crypt-entry md5-crypt md5 sha256-crypt sha256 \
sha512-crypt sha512 crypt crypt_util

tests := cert md5test md5c-test
tests := cert md5test md5c-test sha256test sha256c-test sha512test sha512c-test

distribute := ufc-crypt.h crypt-private.h ufc.c speeds.c README.ufc-crypt \
Banner md5.h
Banner md5.h sha256.h sha512.h

include ../Makeconfig

Expand All @@ -40,6 +41,8 @@ routines += $(libcrypt-routines)
endif

$(objpfx)md5test: $(objpfx)md5.o
$(objpfx)sha256test: $(objpfx)sha256.o
$(objpfx)sha512test: $(objpfx)sha512.o

include ../Rules

Expand Down
32 changes: 31 additions & 1 deletion crypt/crypt-entry.c
@@ -1,7 +1,7 @@
/*
* UFC-crypt: ultra fast crypt(3) implementation
*
* Copyright (C) 1991, 1992, 1993, 1996, 1997 Free Software Foundation, Inc.
* Copyright (C) 1991,1992,1993,1996,1997,2007 Free Software Foundation, Inc.
*
* The GNU C Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -55,13 +55,25 @@ void _ufc_clearmem (char *start, int cnt);
extern char *__md5_crypt_r (const char *key, const char *salt, char *buffer,
int buflen);
extern char *__md5_crypt (const char *key, const char *salt);
extern char *__sha256_crypt_r (const char *key, const char *salt,
char *buffer, int buflen);
extern char *__sha256_crypt (const char *key, const char *salt);
extern char *__sha512_crypt_r (const char *key, const char *salt,
char *buffer, int buflen);
extern char *__sha512_crypt (const char *key, const char *salt);
#endif

/* Define our magic string to mark salt for MD5 encryption
replacement. This is meant to be the same as for other MD5 based
encryption implementations. */
static const char md5_salt_prefix[] = "$1$";

/* Magic string for SHA256 encryption. */
static const char sha256_salt_prefix[] = "$5$";

/* Magic string for SHA512 encryption. */
static const char sha512_salt_prefix[] = "$6$";

/* For use by the old, non-reentrant routines (crypt/encrypt/setkey) */
extern struct crypt_data _ufc_foobar;

Expand All @@ -84,6 +96,16 @@ __crypt_r (key, salt, data)
if (strncmp (md5_salt_prefix, salt, sizeof (md5_salt_prefix) - 1) == 0)
return __md5_crypt_r (key, salt, (char *) data,
sizeof (struct crypt_data));

/* Try to find out whether we have to use SHA256 encryption replacement. */
if (strncmp (sha256_salt_prefix, salt, sizeof (sha256_salt_prefix) - 1) == 0)
return __sha256_crypt_r (key, salt, (char *) data,
sizeof (struct crypt_data));

/* Try to find out whether we have to use SHA512 encryption replacement. */
if (strncmp (sha512_salt_prefix, salt, sizeof (sha512_salt_prefix) - 1) == 0)
return __sha512_crypt_r (key, salt, (char *) data,
sizeof (struct crypt_data));
#endif

/*
Expand Down Expand Up @@ -126,6 +148,14 @@ crypt (key, salt)
/* Try to find out whether we have to use MD5 encryption replacement. */
if (strncmp (md5_salt_prefix, salt, sizeof (md5_salt_prefix) - 1) == 0)
return __md5_crypt (key, salt);

/* Try to find out whether we have to use SHA256 encryption replacement. */
if (strncmp (sha256_salt_prefix, salt, sizeof (sha256_salt_prefix) - 1) == 0)
return __sha256_crypt (key, salt);

/* Try to find out whether we have to use SHA512 encryption replacement. */
if (strncmp (sha512_salt_prefix, salt, sizeof (sha512_salt_prefix) - 1) == 0)
return __sha512_crypt (key, salt);
#endif

return __crypt_r (key, salt, &_ufc_foobar);
Expand Down

0 comments on commit c3266dc

Please sign in to comment.