<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[51008] trunk/src/wp-includes/class-phpass.php: External Libraries: Update the phpass library to version `0.5`.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/51008">51008</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/51008","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>desrosj</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2021-05-25 18:46:39 +0000 (Tue, 25 May 2021)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>External Libraries: Update the phpass library to version `0.5`.
This updates the phpass library from version `0.3` to the latest version of `0.5`. This is a minor update that includes some adjustments to be more friendly with newer versions of PHP.
The changes made in <a href="https://core.trac.wordpress.org/changeset/30466">[30466]</a> have also been applied to the new version of the library. This should now be the only WordPress specific modification do this library.
Props ayeshrajans, dd32, otto42, desrosj.
Fixes <a href="https://core.trac.wordpress.org/ticket/51549">#51549</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclassphpassphp">trunk/src/wp-includes/class-phpass.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclassphpassphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-phpass.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-phpass.php 2021-05-25 17:42:58 UTC (rev 51007)
+++ trunk/src/wp-includes/class-phpass.php 2021-05-25 18:46:39 UTC (rev 51008)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3,16 +3,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Portable PHP password hashing framework.
</span><span class="cx" style="display: block; padding: 0 10px"> * @package phpass
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @version 0.3 / WordPress
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @version 0.5 / WordPress
</ins><span class="cx" style="display: block; padding: 0 10px"> * @link https://www.openwall.com/phpass/
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> #
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+# Portable PHP password hashing framework.
+#
+# Version 0.5 / WordPress.
+#
</ins><span class="cx" style="display: block; padding: 0 10px"> # Written by Solar Designer <solar at openwall.com> in 2004-2006 and placed in
</span><span class="cx" style="display: block; padding: 0 10px"> # the public domain. Revised in subsequent years, still public domain.
</span><span class="cx" style="display: block; padding: 0 10px"> #
</span><span class="cx" style="display: block; padding: 0 10px"> # There's absolutely no warranty.
</span><span class="cx" style="display: block; padding: 0 10px"> #
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+# The homepage URL for this framework is:
+#
+# http://www.openwall.com/phpass/
+#
</ins><span class="cx" style="display: block; padding: 0 10px"> # Please be sure to update the Version line if you edit this file in any way.
</span><span class="cx" style="display: block; padding: 0 10px"> # It is suggested that you leave the main version number intact, but indicate
</span><span class="cx" style="display: block; padding: 0 10px"> # your project name (after the slash) and add your own revision information.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -29,7 +37,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Portable PHP password hashing framework.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @package phpass
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @version 0.3 / WordPress
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @version 0.5 / WordPress
</ins><span class="cx" style="display: block; padding: 0 10px"> * @link https://www.openwall.com/phpass/
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -39,10 +47,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> var $portable_hashes;
</span><span class="cx" style="display: block; padding: 0 10px"> var $random_state;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * PHP5 constructor.
- */
- function __construct( $iteration_count_log2, $portable_hashes )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function __construct($iteration_count_log2, $portable_hashes)
</ins><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -52,20 +57,20 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->portable_hashes = $portable_hashes;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->random_state = microtime() . uniqid(rand(), TRUE); // removed getmypid() for compatibility reasons
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->random_state = microtime();
+ if (function_exists('getmypid'))
+ $this->random_state .= getmypid();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * PHP4 constructor.
- */
- public function PasswordHash( $iteration_count_log2, $portable_hashes ) {
- self::__construct( $iteration_count_log2, $portable_hashes );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function PasswordHash($iteration_count_log2, $portable_hashes)
+ {
+ self::__construct($iteration_count_log2, $portable_hashes);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function get_random_bytes($count)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> $output = '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( @is_readable('/dev/urandom') &&
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (@is_readable('/dev/urandom') &&
</ins><span class="cx" style="display: block; padding: 0 10px"> ($fh = @fopen('/dev/urandom', 'rb'))) {
</span><span class="cx" style="display: block; padding: 0 10px"> $output = fread($fh, $count);
</span><span class="cx" style="display: block; padding: 0 10px"> fclose($fh);
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -76,8 +81,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> for ($i = 0; $i < $count; $i += 16) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->random_state =
</span><span class="cx" style="display: block; padding: 0 10px"> md5(microtime() . $this->random_state);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $output .=
- pack('H*', md5($this->random_state));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $output .= md5($this->random_state, TRUE);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $output = substr($output, 0, $count);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -121,12 +125,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function crypt_private($password, $setting)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> $output = '*0';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (substr($setting, 0, 2) == $output)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (substr($setting, 0, 2) === $output)
</ins><span class="cx" style="display: block; padding: 0 10px"> $output = '*1';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $id = substr($setting, 0, 3);
</span><span class="cx" style="display: block; padding: 0 10px"> # We use "$P$", phpBB3 uses "$H$" for the same thing
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($id != '$P$' && $id != '$H$')
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($id !== '$P$' && $id !== '$H$')
</ins><span class="cx" style="display: block; padding: 0 10px"> return $output;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $count_log2 = strpos($this->itoa64, $setting[3]);
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -136,26 +140,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $count = 1 << $count_log2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $salt = substr($setting, 4, 8);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (strlen($salt) != 8)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (strlen($salt) !== 8)
</ins><span class="cx" style="display: block; padding: 0 10px"> return $output;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- # We're kind of forced to use MD5 here since it's the only
- # cryptographic primitive available in all versions of PHP
- # currently in use. To implement our own low-level crypto
- # in PHP would result in much worse performance and
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ # We were kind of forced to use MD5 here since it's the only
+ # cryptographic primitive that was available in all versions
+ # of PHP in use. To implement our own low-level crypto in PHP
+ # would have resulted in much worse performance and
</ins><span class="cx" style="display: block; padding: 0 10px"> # consequently in lower iteration counts and hashes that are
</span><span class="cx" style="display: block; padding: 0 10px"> # quicker to crack (by non-PHP code).
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (PHP_VERSION >= '5') {
- $hash = md5($salt . $password, TRUE);
- do {
- $hash = md5($hash . $password, TRUE);
- } while (--$count);
- } else {
- $hash = pack('H*', md5($salt . $password));
- do {
- $hash = pack('H*', md5($hash . $password));
- } while (--$count);
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $hash = md5($salt . $password, TRUE);
+ do {
+ $hash = md5($hash . $password, TRUE);
+ } while (--$count);
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $output = substr($setting, 0, 12);
</span><span class="cx" style="display: block; padding: 0 10px"> $output .= $this->encode64($hash, 16);
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -163,24 +160,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $output;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function gensalt_extended($input)
- {
- $count_log2 = min($this->iteration_count_log2 + 8, 24);
- # This should be odd to not reveal weak DES keys, and the
- # maximum valid value is (2**24 - 1) which is odd anyway.
- $count = (1 << $count_log2) - 1;
-
- $output = '_';
- $output .= $this->itoa64[$count & 0x3f];
- $output .= $this->itoa64[($count >> 6) & 0x3f];
- $output .= $this->itoa64[($count >> 12) & 0x3f];
- $output .= $this->itoa64[($count >> 18) & 0x3f];
-
- $output .= $this->encode64($input, 3);
-
- return $output;
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> function gensalt_blowfish($input)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> # This one needs to use a different order of characters and a
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -230,29 +209,20 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $random = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (CRYPT_BLOWFISH === 1 && !$this->portable_hashes) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $random = $this->get_random_bytes(16);
</span><span class="cx" style="display: block; padding: 0 10px"> $hash =
</span><span class="cx" style="display: block; padding: 0 10px"> crypt($password, $this->gensalt_blowfish($random));
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (strlen($hash) == 60)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (strlen($hash) === 60)
</ins><span class="cx" style="display: block; padding: 0 10px"> return $hash;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) {
- if (strlen($random) < 3)
- $random = $this->get_random_bytes(3);
- $hash =
- crypt($password, $this->gensalt_extended($random));
- if (strlen($hash) == 20)
- return $hash;
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> if (strlen($random) < 6)
</span><span class="cx" style="display: block; padding: 0 10px"> $random = $this->get_random_bytes(6);
</span><span class="cx" style="display: block; padding: 0 10px"> $hash =
</span><span class="cx" style="display: block; padding: 0 10px"> $this->crypt_private($password,
</span><span class="cx" style="display: block; padding: 0 10px"> $this->gensalt_private($random));
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (strlen($hash) == 34)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (strlen($hash) === 34)
</ins><span class="cx" style="display: block; padding: 0 10px"> return $hash;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> # Returning '*' on error is safe here, but would _not_ be safe
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -268,9 +238,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $hash = $this->crypt_private($password, $stored_hash);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($hash[0] == '*')
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($hash[0] === '*')
</ins><span class="cx" style="display: block; padding: 0 10px"> $hash = crypt($password, $stored_hash);
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ # This is not constant-time. In order to keep the code simple,
+ # for timing safety we currently rely on the salts being
+ # unpredictable, which they are at least in the non-fallback
+ # cases (that is, when we use /dev/urandom and bcrypt).
</ins><span class="cx" style="display: block; padding: 0 10px"> return $hash === $stored_hash;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-}
</del><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre>
</div>
</div>
</body>
</html>