CSteipp has uploaded a new change for review.
https://gerrit.wikimedia.org/r/110646
Change subject: Add Whirlpool using the password api
......................................................................
Add Whirlpool using the password api
Demonstration of adding Whirlpool as a hashing option, using the api
from change I0a9c972931a0eff0cfb2619cef3ddffd03710285.
Adds a Whirlpool-based hash, and a type "E", which is the current
default type B, wrapped in the whirlpool-based hash.
Bug: 28419
Change-Id: Ieaae596bc3921ecf5880457f7d4011a01c5fdf15
---
M includes/AutoLoader.php
M includes/DefaultSettings.php
A includes/password/WhirlpoolPassword.php
3 files changed, 74 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/46/110646/1
diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php
index bdd114e..a640e86 100644
--- a/includes/AutoLoader.php
+++ b/includes/AutoLoader.php
@@ -834,6 +834,7 @@
'ParameterizedPassword' =>
'includes/password/ParameterizedPassword.php',
'Password' => 'includes/password/Password.php',
'Pbkdf2Password' => 'includes/password/Pbkdf2Password.php',
+ 'WhirlpoolPassword' => 'includes/password/WhirlpoolPassword.php',
'PepperedPassword' => 'includes/password/PepperedPassword.php',
# includes/profiler
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 8378ec4..6fe37f9 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -3980,6 +3980,13 @@
'bcrypt',
),
),
+ 'E' => array(
+ 'class' => 'LayeredParameterizedPassword',
+ 'types' => array(
+ 'B',
+ 'whirlpool',
+ ),
+ ),
'bcrypt' => array(
'class' => 'BcryptPassword',
'cost' => 5,
@@ -3990,6 +3997,10 @@
'cost' => '10000',
'length' => '224',
),
+ 'whirlpool' => array(
+ 'class' => 'WhirlpoolPassword',
+ 'cost' => 8,
+ ),
);
/**
diff --git a/includes/password/WhirlpoolPassword.php
b/includes/password/WhirlpoolPassword.php
new file mode 100644
index 0000000..a14a0dd
--- /dev/null
+++ b/includes/password/WhirlpoolPassword.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Implements the WhirlpoolPassword class for the MediaWiki software.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
+/**
+ * A Whirlpool-based password hashing. Implements the Whirlpool bits from Tim's
+ * algorithm described in
http://www.mail-archive.com/[email protected]/msg08830.html
+ *
+ * @since 1.23
+ */
+class WhirlpoolPassword extends ParameterizedPassword {
+ function getDefaultParams() {
+ return array(
+ 'complexity' => $this->config['cost'],
+ );
+ }
+
+ function getDelimiter() {
+ return ':';
+ }
+
+ function parseHash( $hash ) {
+ parent::parseHash( $hash );
+ $this->params['complexity'] = (int)$this->params['complexity'];
+ }
+
+ function crypt( $password ) {
+ // args[0] is the salt
+ if ( count( $this->args ) == 0 ) {
+ $this->args[] = MWCryptRand::generateHex( 8 );
+ }
+ $iter = pow( 2, $this->params['complexity'] );
+ $h = $password;
+ for ( $i = 0; $i < $iter; $i++ ) {
+ $h = hash( 'whirlpool', str_repeat( $h .
$this->args[0], 100 ), true );
+ $h = substr( $h, 7, 32 );
+ }
+ $this->hash = bin2hex( $h );
+ }
+
+ function isHashContextFree() {
+ return true;
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/110646
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieaae596bc3921ecf5880457f7d4011a01c5fdf15
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: CSteipp <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits