Commit 8fe2daad authored by Christian Kuhn's avatar Christian Kuhn Committed by Georg Ringer
Browse files

[TASK] Merge EXT:saltedpasswords into EXT:core

Move all classes and other resources from EXT:saltedpasswords to
EXT:core.

Classes live in TYPO3\CMS\Core\Crypto\PasswordHashing. This namespace
will be clean in v10 when the classes that are currently only kept for
backwards compatibility are removed.

The documentation has been integrated into the "Core API" docs at
https://docs.typo3.org/typo3cms/CoreApiReference/stable/ApiOverview/PasswordHashing/

Resolves: #85833
Resolves: #85026
Releases: master
Change-Id: Ie6ac7fbf215fe61711f0acdd6dc5a318bce1ad35
Reviewed-on: https://review.typo3.org/57885


Reviewed-by: Stephan Großberndt's avatarStephan Großberndt <stephan.grossberndt@typo3.org>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
parent db6087cc
......@@ -95,7 +95,6 @@
"typo3/sysext/lowlevel/Migrations/Code/ClassAliasMap.php",
"typo3/sysext/recordlist/Migrations/Code/ClassAliasMap.php",
"typo3/sysext/reports/Migrations/Code/ClassAliasMap.php",
"typo3/sysext/saltedpasswords/Migrations/Code/ClassAliasMap.php",
"typo3/sysext/t3editor/Migrations/Code/ClassAliasMap.php",
"typo3/sysext/workspaces/Migrations/Code/ClassAliasMap.php"
]
......@@ -167,7 +166,6 @@
"typo3/cms-reports": "self.version",
"typo3/cms-rsaauth": "self.version",
"typo3/cms-rte-ckeditor": "self.version",
"typo3/cms-saltedpasswords": "self.version",
"typo3/cms-scheduler": "self.version",
"typo3/cms-seo": "self.version",
"typo3/cms-setup": "self.version",
......@@ -209,7 +207,6 @@
"TYPO3\\CMS\\Reports\\": "typo3/sysext/reports/Classes/",
"TYPO3\\CMS\\Rsaauth\\": "typo3/sysext/rsaauth/Classes/",
"TYPO3\\CMS\\RteCKEditor\\": "typo3/sysext/rte_ckeditor/Classes/",
"TYPO3\\CMS\\Saltedpasswords\\": "typo3/sysext/saltedpasswords/Classes/",
"TYPO3\\CMS\\Scheduler\\": "typo3/sysext/scheduler/Classes/",
"TYPO3\\CMS\\Seo\\": "typo3/sysext/seo/Classes/",
"TYPO3\\CMS\\Setup\\": "typo3/sysext/setup/Classes/",
......@@ -253,7 +250,6 @@
"TYPO3\\CMS\\Recordlist\\Tests\\": "typo3/sysext/recordlist/Tests/",
"TYPO3\\CMS\\Reports\\Tests\\": "typo3/sysext/reports/Tests/",
"TYPO3\\CMS\\Rsaauth\\Tests\\": "typo3/sysext/rsaauth/Tests/",
"TYPO3\\CMS\\Saltedpasswords\\Tests\\": "typo3/sysext/saltedpasswords/Tests/",
"TYPO3\\CMS\\Scheduler\\Tests\\": "typo3/sysext/scheduler/Tests/",
"TYPO3\\CMS\\Seo\\Tests\\": "typo3/sysext/seo/Tests/",
"TYPO3\\CMS\\Setup\\Tests\\": "typo3/sysext/setup/Tests/",
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "63588d48aa7557054c5c4a21e8acff6a",
"content-hash": "2d4286e7d7266515cb472a37beeeffe7",
"packages": [
{
"name": "cogpowered/finediff",
......
......@@ -14,14 +14,14 @@ namespace TYPO3\CMS\Core\Authentication;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Crypto\PasswordHashing\InvalidPasswordHashException;
use TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory;
use TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashInterface;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
use TYPO3\CMS\Core\TimeTracker\TimeTracker;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Saltedpasswords\Exception\InvalidSaltException;
use TYPO3\CMS\Saltedpasswords\Salt\SaltFactory;
use TYPO3\CMS\Saltedpasswords\Salt\SaltInterface;
/**
* Authentication services class
......@@ -118,20 +118,20 @@ class AuthenticationService extends AbstractAuthenticationService
$isReHashNeeded = false;
$isDomainLockMet = false;
$saltFactory = GeneralUtility::makeInstance(SaltFactory::class);
$saltFactory = GeneralUtility::makeInstance(PasswordHashFactory::class);
// Get a hashed password instance for the hash stored in db of this user
try {
$hashInstance = $saltFactory->get($passwordHashInDatabase, TYPO3_MODE);
} catch (InvalidSaltException $e) {
} catch (InvalidPasswordHashException $e) {
// This can be refactored if the 'else' part below is gone in v10: Log and return 100 here
$hashInstance = null;
}
// An instance of the currently configured salted password mechanism
// Don't catch InvalidSaltException here: Only install tool should handle those configuration failures
// Don't catch InvalidPasswordHashException here: Only install tool should handle those configuration failures
$defaultHashInstance = $saltFactory->getDefaultHashInstance(TYPO3_MODE);
if ($hashInstance instanceof SaltInterface) {
if ($hashInstance instanceof PasswordHashInterface) {
// We found a hash class that can handle this type of hash
$isSaltedPassword = true;
$isValidPassword = $hashInstance->checkPassword($submittedPassword, $passwordHashInDatabase);
......@@ -156,7 +156,7 @@ class AuthenticationService extends AbstractAuthenticationService
if (substr($user['password'], 0, 2) === 'M$') {
// If the stored db password starts with M$, it may be a md5 password that has been
// upgraded to a salted md5 using the old salted passwords scheduler task.
// See if a salt instance is returned if we cut off the M, so Md5Salt kicks in
// See if a salt instance is returned if we cut off the M, so Md5PasswordHash kicks in
try {
$hashInstance = $saltFactory->get(substr($passwordHashInDatabase, 1), TYPO3_MODE);
$isSaltedPassword = true;
......@@ -172,7 +172,7 @@ class AuthenticationService extends AbstractAuthenticationService
$isDomainLockMet = true;
}
}
} catch (InvalidSaltException $e) {
} catch (InvalidPasswordHashException $e) {
// Still no instance found: $isSaltedPasswords is NOT set to true, logging and return done below
}
}
......
......@@ -15,11 +15,11 @@ namespace TYPO3\CMS\Core\Authentication;
*/
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory;
use TYPO3\CMS\Core\Crypto\Random;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Saltedpasswords\Salt\SaltFactory;
/**
* TYPO3 backend user authentication on a CLI level
......@@ -148,7 +148,7 @@ class CommandLineUserAuthentication extends BackendUserAuthentication
{
$cryptoService = GeneralUtility::makeInstance(Random::class);
$password = $cryptoService->generateRandomBytes(20);
$hashInstance = GeneralUtility::makeInstance(SaltFactory::class)->getDefaultHashInstance('BE');
$hashInstance = GeneralUtility::makeInstance(PasswordHashFactory::class)->getDefaultHashInstance('BE');
return $hashInstance->getHashedPassword($password);
}
}
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Saltedpasswords\Salt;
namespace TYPO3\CMS\Core\Crypto\PasswordHashing;
/*
* This file is part of the TYPO3 CMS project.
......
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Saltedpasswords\Salt;
namespace TYPO3\CMS\Core\Crypto\PasswordHashing;
/*
* This file is part of the TYPO3 CMS project.
......@@ -15,8 +15,6 @@ namespace TYPO3\CMS\Saltedpasswords\Salt;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Saltedpasswords\Exception\InvalidSaltException;
/**
* This class implements the 'argon2i' flavour of the php password api.
*
......@@ -27,7 +25,7 @@ use TYPO3\CMS\Saltedpasswords\Exception\InvalidSaltException;
*
* @see PASSWORD_ARGON2I in https://secure.php.net/manual/en/password.constants.php
*/
class Argon2iSalt implements SaltInterface
class Argon2iPasswordHash implements PasswordHashInterface
{
/**
* Prefix for the password hash.
......@@ -53,6 +51,7 @@ class Argon2iSalt implements SaltInterface
* Constructor sets options if given
*
* @param array $options
* @throws \InvalidArgumentException
*/
public function __construct(array $options = [])
{
......@@ -127,7 +126,7 @@ class Argon2iSalt implements SaltInterface
if ($password !== '') {
$hashedPassword = password_hash($password, PASSWORD_ARGON2I, $this->options);
if (!is_string($hashedPassword) || empty($hashedPassword)) {
throw new InvalidSaltException('Cannot generate password, probably invalid options', 1526052118);
throw new InvalidPasswordHashException('Cannot generate password, probably invalid options', 1526052118);
}
}
return $hashedPassword;
......
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Saltedpasswords\Salt;
namespace TYPO3\CMS\Core\Crypto\PasswordHashing;
/*
* This file is part of the TYPO3 CMS project.
......@@ -15,8 +15,6 @@ namespace TYPO3\CMS\Saltedpasswords\Salt;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Saltedpasswords\Exception\InvalidSaltException;
/**
* This class implements the 'bcrypt' flavour of the php password api.
*
......@@ -28,7 +26,7 @@ use TYPO3\CMS\Saltedpasswords\Exception\InvalidSaltException;
*
* @see PASSWORD_BCRYPT in https://secure.php.net/manual/en/password.constants.php
*/
class BcryptSalt implements SaltInterface
class BcryptPasswordHash implements PasswordHashInterface
{
/**
* Prefix for the password hash
......@@ -51,6 +49,7 @@ class BcryptSalt implements SaltInterface
* Constructor sets options if given
*
* @param array $options
* @throws \InvalidArgumentException
*/
public function __construct(array $options = [])
{
......@@ -112,7 +111,7 @@ class BcryptSalt implements SaltInterface
$password = $this->processPlainPassword($password);
$hashedPassword = password_hash($password, PASSWORD_BCRYPT, $this->options);
if (!is_string($hashedPassword) || empty($hashedPassword)) {
throw new InvalidSaltException('Cannot generate password, probably invalid options', 1517174114);
throw new InvalidPasswordHashException('Cannot generate password, probably invalid options', 1517174114);
}
}
return $hashedPassword;
......
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Saltedpasswords\Salt;
namespace TYPO3\CMS\Core\Crypto\PasswordHashing;
/*
* This file is part of the TYPO3 CMS project.
......@@ -26,7 +26,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
* Warning: Blowfish salted hashing with PHP's crypt() is not available
* on every system.
*/
class BlowfishSalt implements SaltInterface
class BlowfishPasswordHash implements PasswordHashInterface
{
use PublicMethodDeprecationTrait;
......@@ -34,8 +34,8 @@ class BlowfishSalt implements SaltInterface
* @var array
*/
private $deprecatedPublicMethods = [
'isValidSalt' => 'Using BlowfishSalt::isValidSalt() is deprecated and will not be possible anymore in TYPO3 v10.',
'base64Encode' => 'Using BlowfishSalt::base64Encode() is deprecated and will not be possible anymore in TYPO3 v10.',
'isValidSalt' => 'Using BlowfishPasswordHash::isValidSalt() is deprecated and will not be possible anymore in TYPO3 v10.',
'base64Encode' => 'Using BlowfishPasswordHash::base64Encode() is deprecated and will not be possible anymore in TYPO3 v10.',
];
/**
......@@ -85,6 +85,7 @@ class BlowfishSalt implements SaltInterface
* Constructor sets options if given
*
* @param array $options
* @throws \InvalidArgumentException
*/
public function __construct(array $options = [])
{
......
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Saltedpasswords\Salt;
namespace TYPO3\CMS\Core\Crypto\PasswordHashing;
/*
* This file is part of the TYPO3 CMS project.
......@@ -21,7 +21,7 @@ namespace TYPO3\CMS\Saltedpasswords\Salt;
*
* @deprecated and will be removed in TYPO3 v10.0.
*/
interface ComposedSaltInterface extends SaltInterface
interface ComposedPasswordHashInterface extends PasswordHashInterface
{
/**
* Returns length of required salt.
......
<?php
namespace TYPO3\CMS\Saltedpasswords\Utility;
namespace TYPO3\CMS\Core\Crypto\PasswordHashing;
/*
* This file is part of the TYPO3 CMS project.
......@@ -62,10 +62,10 @@ class ExtensionManagerConfigurationUtility
$propertyName = $params['propertyName'];
$unknownVariablePleaseRenameMe = '\'' . substr(md5($propertyName), 0, 10) . '\'';
$pField = '';
$registeredMethods = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getRegisteredSaltedHashingMethods();
$registeredMethods = \TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory::getRegisteredSaltedHashingMethods();
foreach ($registeredMethods as $class => $reference) {
$classInstance = GeneralUtility::makeInstance($reference);
if ($classInstance instanceof \TYPO3\CMS\Saltedpasswords\Salt\SaltInterface && $classInstance->isAvailable()) {
if ($classInstance instanceof \TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashInterface && $classInstance->isAvailable()) {
$sel = $this->extConf[$disposal]['saltedPWHashingMethod'] == $class ? ' selected="selected" ' : '';
$label = 'ext.saltedpasswords.title.' . strtolower(end(explode('\\', $class)));
$pField .= '<option value="' . htmlspecialchars($class) . '"' . $sel . '>' . $GLOBALS['LANG']->getLL($label) . '</option>';
......
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Saltedpasswords\Exception;
namespace TYPO3\CMS\Core\Crypto\PasswordHashing;
/*
* This file is part of the TYPO3 CMS project.
......@@ -16,8 +16,8 @@ namespace TYPO3\CMS\Saltedpasswords\Exception;
*/
/**
* InvalidSaltException thrown if salting went wrong.
* InvalidPasswordHashException thrown if salting went wrong.
*/
class InvalidSaltException extends \Exception
class InvalidPasswordHashException extends \TYPO3\CMS\Core\Exception
{
}
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Saltedpasswords\Salt;
namespace TYPO3\CMS\Core\Crypto\PasswordHashing;
/*
* This file is part of the TYPO3 CMS project.
......@@ -26,7 +26,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
* MD5 salted hashing with PHP's crypt() should be available
* on most of the systems.
*/
class Md5Salt implements SaltInterface
class Md5PasswordHash implements PasswordHashInterface
{
use PublicMethodDeprecationTrait;
......@@ -34,8 +34,8 @@ class Md5Salt implements SaltInterface
* @var array
*/
private $deprecatedPublicMethods = [
'isValidSalt' => 'Using Md5Salt::isValidSalt() is deprecated and will not be possible anymore in TYPO3 v10.',
'base64Encode' => 'Using Md5Salt::base64Encode() is deprecated and will not be possible anymore in TYPO3 v10.',
'isValidSalt' => 'Using Md5PasswordHash::isValidSalt() is deprecated and will not be possible anymore in TYPO3 v10.',
'base64Encode' => 'Using Md5PasswordHash::base64Encode() is deprecated and will not be possible anymore in TYPO3 v10.',
];
/**
......
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Saltedpasswords\Salt;
namespace TYPO3\CMS\Core\Crypto\PasswordHashing;
/*
* This file is part of the TYPO3 CMS project.
......@@ -16,20 +16,18 @@ namespace TYPO3\CMS\Saltedpasswords\Salt;
*/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Saltedpasswords\Exception\InvalidSaltException;
use TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility;
/**
* Factory class to find and return hash instances of given hashed passwords
* and to find and return default hash instances to hash new passwords.
*/
class SaltFactory
class PasswordHashFactory
{
/**
* An instance of the salted hashing method.
* This member is set in the getSaltingInstance() function.
*
* @var SaltInterface
* @var PasswordHashInterface
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
protected static $instance;
......@@ -39,12 +37,12 @@ class SaltFactory
*
* @param string $hash Given hash to find instance for
* @param string $mode 'FE' for frontend users, 'BE' for backend users
* @return SaltInterface Object that can handle given hash
* @return PasswordHashInterface Object that can handle given hash
* @throws \LogicException
* @throws \InvalidArgumentException
* @throws InvalidSaltException If no class was found that handles given hash
* @throws InvalidPasswordHashException If no class was found that handles given hash
*/
public function get(string $hash, string $mode): SaltInterface
public function get(string $hash, string $mode): PasswordHashInterface
{
if ($mode !== 'FE' && $mode !== 'BE') {
throw new \InvalidArgumentException('Mode must be either \'FE\' or \'BE\', ' . $mode . ' given.', 1533948312);
......@@ -70,27 +68,27 @@ class SaltFactory
} else {
$hashInstance = GeneralUtility::makeInstance($className);
}
if (!$hashInstance instanceof SaltInterface) {
throw new \LogicException('Class ' . $className . ' does not implement SaltInterface', 1533818569);
if (!$hashInstance instanceof PasswordHashInterface) {
throw new \LogicException('Class ' . $className . ' does not implement PasswordHashInterface', 1533818569);
}
if ($hashInstance->isAvailable() && $hashInstance->isValidSaltedPW($hash)) {
return $hashInstance;
}
}
// Do not add the hash to the exception to prevent information disclosure
throw new InvalidSaltException('No implementation found that handles given hash.', 1533818591);
throw new InvalidPasswordHashException('No implementation found that handles given hash.', 1533818591);
}
/**
* Determine configured default hash method and return an instance of the class representing it.
*
* @param string $mode 'FE' for frontend users, 'BE' for backend users
* @return SaltInterface Class instance that is configured as default hash method
* @return PasswordHashInterface Class instance that is configured as default hash method
* @throws \InvalidArgumentException
* @throws \LogicException
* @throws InvalidSaltException If configuration is broken
* @throws InvalidPasswordHashException If configuration is broken
*/
public function getDefaultHashInstance(string $mode): SaltInterface
public function getDefaultHashInstance(string $mode): PasswordHashInterface
{
if ($mode !== 'FE' && $mode !== 'BE') {
throw new \InvalidArgumentException('Mode must be either \'FE\' or \'BE\', ' . $mode . ' given.', 1533820041);
......@@ -111,20 +109,20 @@ class SaltFactory
$availableHashClasses = static::getRegisteredSaltedHashingMethods();
if (!in_array($defaultHashClassName, $availableHashClasses, true)) {
throw new InvalidSaltException(
throw new InvalidPasswordHashException(
'Configured default hash method ' . $defaultHashClassName . ' is not registered',
1533820194
);
}
$hashInstance = GeneralUtility::makeInstance($defaultHashClassName, $defaultHashOptions);
if (!$hashInstance instanceof SaltInterface) {
if (!$hashInstance instanceof PasswordHashInterface) {
throw new \LogicException(
'Configured default hash method ' . $defaultHashClassName . ' is not an instance of SaltInterface',
'Configured default hash method ' . $defaultHashClassName . ' is not an instance of PasswordHashInterface',
1533820281
);
}
if (!$hashInstance->isAvailable()) {
throw new InvalidSaltException(
throw new InvalidPasswordHashException(
'Configured default hash method ' . $defaultHashClassName . ' is not available, missing php requirement?',
1533822084
);
......@@ -163,13 +161,13 @@ class SaltFactory
* Obtains a salting hashing method instance.
*
* This function will return an instance of a class that implements
* \TYPO3\CMS\Saltedpasswords\Salt\SaltInterface
* \TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashInterface
*
* Use parameter NULL to reset the factory!
*
* @param string|null $saltedHash Salted hashed password to determine the type of used method from or NULL to reset to the default type
* @param string $mode The TYPO3 mode (FE or BE) saltedpasswords shall be used for
* @return SaltInterface|null An instance of salting hash method class or null if given hash is not supported
* @return PasswordHashInterface|null An instance of salting hash method class or null if given hash is not supported
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public static function getSaltingInstance($saltedHash = '', $mode = TYPO3_MODE)
......@@ -221,7 +219,7 @@ class SaltFactory
$methodFound = false;
foreach ($registeredMethods as $method) {
$objectInstance = GeneralUtility::makeInstance($method);
if ($objectInstance instanceof SaltInterface && $objectInstance->isAvailable()) {
if ($objectInstance instanceof PasswordHashInterface && $objectInstance->isAvailable()) {
$methodFound = $objectInstance->isValidSaltedPW($saltedHash);
if ($methodFound) {
self::$instance = $objectInstance;
......@@ -235,8 +233,8 @@ class SaltFactory
/**
* Method sets a custom salting hashing method class.
*
* @param string $resource Object resource to use (e.g. \TYPO3\CMS\Saltedpasswords\Salt\BlowfishSalt::class)
* @return SaltInterface|null An instance of salting hashing method object or null
* @param string $resource Object resource to use (e.g. \TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash::class)
* @return PasswordHashInterface|null An instance of salting hashing method object or null
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10
*/
public static function setPreferredHashingMethod(string $resource)
......@@ -244,7 +242,7 @@ class SaltFactory
trigger_error('This method is obsolete and will be removed in TYPO3 v10.', E_USER_DEPRECATED);
self::$instance = null;
$objectInstance = GeneralUtility::makeInstance($resource);
if ($objectInstance instanceof SaltInterface) {
if ($objectInstance instanceof PasswordHashInterface) {
self::$instance = $objectInstance;
}
return self::$instance;
......
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Saltedpasswords\Salt;
namespace TYPO3\CMS\Core\Crypto\PasswordHashing;
/*
* This file is part of the TYPO3 CMS project.
......@@ -19,7 +19,7 @@ namespace TYPO3\CMS\Saltedpasswords\Salt;
* Interface with public methods needed to be implemented
* in a salting hashing class.
*/
interface SaltInterface
interface PasswordHashInterface
{
/**
* Method checks if a given plaintext password is correct by comparing it with
......
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Saltedpasswords\Salt;
namespace TYPO3\CMS\Core\Crypto\PasswordHashing;
/*
* This file is part of the TYPO3 CMS project.
......@@ -23,7 +23,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
* Class that implements PBKDF2 salted hashing based on PHP's
* hash_pbkdf2() function.
*/
class Pbkdf2Salt implements SaltInterface
class Pbkdf2PasswordHash implements PasswordHashInterface
{
use PublicMethodDeprecationTrait;
......@@ -31,9 +31,9 @@ class Pbkdf2Salt implements SaltInterface
* @var array
*/
private $deprecatedPublicMethods = [
'isValidSalt' => 'Using Pbkdf2Salt::isValidSalt() is deprecated and will not be possible anymore in TYPO3 v10.',
'base64Encode' => 'Using Pbkdf2Salt::base64Encode() is deprecated and will not be possible anymore in TYPO3 v10.',
'base64Decode' => 'Using Pbkdf2Salt::base64Decode() is deprecated and will not be possible anymore in TYPO3 v10.',
'isValidSalt' => 'Using Pbkdf2PasswordHash::isValidSalt() is deprecated and will not be possible anymore in TYPO3 v10.',
'base64Encode' => 'Using Pbkdf2PasswordHash::base64Encode() is deprecated and will not be possible anymore in TYPO3 v10.',
'base64Decode' => 'Using Pbkdf2PasswordHash::base64Decode() is deprecated and will not be possible anymore in TYPO3 v10.',
];
/**
......
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Saltedpasswords\Salt;
namespace TYPO3\CMS\Core\Crypto\PasswordHashing;
/*
* This file is part of the TYPO3 CMS project.
......@@ -30,7 +30,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
* @see http://drupal.org/node/29706/
* @see http://www.openwall.com/phpass/
*/
class PhpassSalt implements SaltInterface
class PhpassPasswordHash implements PasswordHashInterface
{
use PublicMethodDeprecationTrait;
......@@ -38,8 +38,8 @@ class PhpassSalt implements SaltInterface
* @var array
*/
private $deprecatedPublicMethods = [
'isValidSalt' => 'Using PhpassSalt::isValidSalt() is deprecated and will not be possible anymore in TYPO3 v10.',
'base64Encode' => 'Using PhpassSalt::base64Encode() is deprecated and will not be possible anymore in TYPO3 v10.',
'isValidSalt' => 'Using PhpassPasswordHash::isValidSalt() is deprecated and will not be possible anymore in TYPO3 v10.',
'base64Encode' => 'Using PhpassPasswordHash::base64Encode() is deprecated and will not be possible anymore in TYPO3 v10.',
];
/**
......
<?php
namespace TYPO3\CMS\Saltedpasswords;
namespace TYPO3\CMS\Core\Crypto\PasswordHashing;
/*
* This file is part of the TYPO3 CMS project.
......@@ -18,7 +18,6 @@ use TYPO3\CMS\Core\Authentication\AbstractAuthenticationService;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\TimeTracker\TimeTracker;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Saltedpasswords\Salt\SaltFactory;
/**
* Class implements salted-password hashes authentication service.
......@@ -53,7 +52,7 @@ class SaltedPasswordService extends AbstractAuthenticationService
* An instance of the salted hashing method.
* This member is set in the getSaltingInstance() function.
*
* @var \TYPO3\CMS\Saltedpasswords\Salt\SaltInterface
* @var \TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashInterface
*/
protected $objInstanceSaltedPW;
......@@ -82,7 +81,7 @@ class SaltedPasswordService extends AbstractAuthenticationService
*/
public function init()
{
$this->extConf = Utility\SaltedPasswordsUtility::returnExtConf();
$this->extConf = TYPO3\CMS\Core\Crypto\PasswordHashing\SaltedPasswordsUtility::returnExtConf();
parent::init();
return true;
}
......@@ -101,7 +100,7 @@ class SaltedPasswordService extends AbstractAuthenticationService
$password = $loginData['uident_text'];
// Determine method used for given salted hashed password
// This calls deprecated getSaltingInstance(). This is "ok" since this SaltedPasswordsService in itself is deprecated.
$this->objInstanceSaltedPW = SaltFactory::getSaltingInstance($user['password']);
$this->objInstanceSaltedPW = PasswordHashFactory::getSaltingInstance($user['password']);
// Existing record is in format of Salted Hash password
if (is_object($this->objInstanceSaltedPW)) {