File crypt_blowfish-1.0-suse.diff of Package glibc.import5554

Index: crypt/Makefile
===================================================================
--- crypt/Makefile.orig
+++ crypt/Makefile
@@ -27,7 +27,7 @@ extra-libs := libcrypt
 extra-libs-others := $(extra-libs)
 
 libcrypt-routines := crypt-entry md5-crypt sha256-crypt sha512-crypt crypt \
-		     crypt_util
+		     crypt_util crypt_blowfish
 
 tests := cert md5c-test sha256c-test sha512c-test
 
Index: crypt/crypt-entry.c
===================================================================
--- crypt/crypt-entry.c.orig
+++ crypt/crypt-entry.c
@@ -61,6 +61,8 @@ extern char *__sha256_crypt (const char
 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);
+extern char *_crypt_blowfish_rn (const char *key, const char *setting,
+				 char *output, int size);
 #endif
 
 /* Define our magic string to mark salt for MD5 encryption
@@ -74,6 +76,9 @@ static const char sha256_salt_prefix[] =
 /* Magic string for SHA512 encryption.  */
 static const char sha512_salt_prefix[] = "$6$";
 
+/* Magic string for Blowfish encryption.  */
+static const char blowfish_salt_prefix[] = "$2a$";
+
 /* For use by the old, non-reentrant routines (crypt/encrypt/setkey)  */
 extern struct crypt_data _ufc_foobar;
 
@@ -106,6 +111,14 @@ __crypt_r (key, salt, data)
   if (strncmp (sha512_salt_prefix, salt, sizeof (sha512_salt_prefix) - 1) == 0)
     return __sha512_crypt_r (key, salt, (char *) data,
 			     sizeof (struct crypt_data));
+
+  /* Try to find out whether we have to use Blowfish encryption replacement.  */
+  if (salt[0] == '$'
+  && salt[1] == '2'
+  && (salt[2] == 'a' || salt[2] == 'x' || salt[2] == 'y')
+  && salt[3] == '$')
+    return _crypt_blowfish_rn (key, salt, (char *) data,
+			     sizeof (struct crypt_data));
 #endif
 
   /*
openSUSE Build Service is sponsored by