Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34030 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60815 invoked by uid 1010); 14 Dec 2007 04:35:36 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 60799 invoked from network); 14 Dec 2007 04:35:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Dec 2007 04:35:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=solar@openwall.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=solar@openwall.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain openwall.com designates 195.42.179.200 as permitted sender) X-PHP-List-Original-Sender: solar@openwall.com X-Host-Fingerprint: 195.42.179.200 mother.openwall.net Received: from [195.42.179.200] ([195.42.179.200:4384] helo=mother.openwall.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8C/8A-18955-51802674 for ; Thu, 13 Dec 2007 23:35:35 -0500 Received: (qmail 13501 invoked from network); 14 Dec 2007 04:35:31 -0000 Received: from localhost (HELO pvt.openwall.com) (127.0.0.1) by localhost with SMTP; 14 Dec 2007 04:35:31 -0000 Received: by pvt.openwall.com (Postfix, from userid 503) id 6AF2D2FD0E; Fri, 14 Dec 2007 07:32:06 +0300 (MSK) Date: Fri, 14 Dec 2007 07:32:06 +0300 To: internals@lists.php.net Message-ID: <20071214043206.GA13908@openwall.com> References: <20071209010552.GA12561@openwall.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20071209010552.GA12561@openwall.com> User-Agent: Mutt/1.4.2.3i Subject: Re: faster & public domain MD5 implementation From: solar@openwall.com (Solar Designer) A few days ago, I wrote: > Attached is a quick patch for PHP 5.2.5 that replaces RSA's copyrighted > implementation of MD5 with my public domain one: > > http://cvsweb.openwall.com/cgi/cvsweb.cgi/Owl/packages/popa3d/popa3d/md5/ > > This also results in faster and slightly smaller code (both source and > binary). On a Pentium 3 that I've tested this on, the speedup is 12% > for the portable hashes as implemented in phpass: > > http://www.openwall.com/phpass/ The code from phpass is now being used by phpBB3 (3.0.0 release) and WordPress (development). It is being considered for Drupal 7. Wouldn't it be nice for PHP to be more efficient when running those popular apps, and at the same time have cleaner and smaller code? Of course, it'd be great if PHP would also integrate the CRYPT_BLOWFISH code from Suhosin, but that can be discussed separately (if it needs a discussion). > Given that most CPU time is spent on various overhead of the PHP > interpreter rather than on MD5 hashing itself (and gprof confirms this), > the 12% speedup seen on the PHP script as a whole means that the speedup > for the MD5 implementation alone is much higher than that. The speedup > should be similar on other little-endian CPUs (other x86 CPUs, x86-64, > Alpha), but smaller on big-endian. A correction: actually, Alpha falls into the same category with big-endian CPUs here (a smaller speedup - but nevertheless a speedup) because it lacks hardware support for unaligned accesses. I must have been too tired when I wrote the above. I am not quoting the rest of my posting, although I'd appreciate comments on the suggestions I had made there. Thanks, Alexander