Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 9 Feb 2012 12:10:24 +0400
From: Solar Designer <solar@...nwall.com>
To: john-dev@...ts.openwall.com
Subject: Re: Drupal 7

On Thu, Feb 09, 2012 at 11:47:44AM +0400, Solar Designer wrote:
> On Thu, Feb 09, 2012 at 03:15:46AM +0100, magnum wrote:
> > On 01/16/2012 12:12 AM, Solar Designer wrote:
> > > Here's one more: Drupal 7 uses a revision of phpass with MD5 replaced
> > > with SHA-512 and hashes cut at 258 bits (yes, 258 - that's a multiple of 6).
> > > These hash encodings use the $S$ prefix.  Perhaps we should support them.
> > 
> > I just committed this format. Painfully slow but supports OMP.
...
> Benchmarking: Drupal 7 $S$ (SHA-512 x 16385) [64/64]... (8xOMP) DONE
> Raw:    738 c/s real, 92.0 c/s virtual

Here's a very minor optimization:

Benchmarking: Drupal 7 $S$ (SHA-512 x 16385) [64/64]... (8xOMP) DONE
Raw:    745 c/s real, 93.7 c/s virtual

Patch attached.

Alexander

--- drupal7_fmt.c.orig	2012-02-09 11:28:48 +0400
+++ drupal7_fmt.c	2012-02-09 12:05:48 +0400
@@ -150,25 +150,26 @@
 #endif
 	{
 		SHA512_CTX ctx;
-		unsigned Lcount;
+		unsigned char tmp[REAL_BINARY_SIZE + PLAINTEXT_LENGTH];
 		int len = EncKeyLen[index];
+		unsigned Lcount = loopCnt - 1;
 
 		SHA512_Init( &ctx );
 		SHA512_Update( &ctx, cursalt, 8 );
 		SHA512_Update( &ctx, EncKey[index], len );
-		SHA512_Final( (unsigned char *) crypt_key[index], &ctx);
-
-		memcpy(&crypt_key[index][REAL_BINARY_SIZE],
-		       ((char*)EncKey[index]), len);
-		Lcount = loopCnt;
+		memcpy(&tmp[REAL_BINARY_SIZE], (char *)EncKey[index], len);
+		SHA512_Final( tmp, &ctx);
 
 		len += REAL_BINARY_SIZE;
 
 		do {
 			SHA512_Init( &ctx );
-			SHA512_Update( &ctx, crypt_key[index], len);
-			SHA512_Final( (unsigned char *) crypt_key[index], &ctx);
+			SHA512_Update( &ctx, tmp, len);
+			SHA512_Final( tmp, &ctx);
 		} while (--Lcount);
+		SHA512_Init( &ctx );
+		SHA512_Update( &ctx, tmp, len);
+		SHA512_Final( (unsigned char *) crypt_key[index], &ctx);
 	}
 }
 

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ