37 $this->objectInstance = $this->getMock(
'TYPO3\\CMS\\Saltedpasswords\\Salt\\BlowfishSalt', array(
'dummy'));
46 if (!CRYPT_BLOWFISH) {
47 $this->markTestSkipped(
'Blowfish is not supported on your platform.');
55 $hasCorrectBaseClass = get_class($this->objectInstance) ===
'TYPO3\\CMS\\Saltedpasswords\\Salt\\BlowfishSalt';
57 if (!$hasCorrectBaseClass && FALSE != get_parent_class($this->objectInstance)) {
58 $hasCorrectBaseClass = is_subclass_of($this->objectInstance,
'TYPO3\\CMS\\Saltedpasswords\\Salt\\BlowfishSalt');
60 $this->assertTrue($hasCorrectBaseClass);
67 $this->assertTrue($this->objectInstance->getSaltLength() > 0);
75 $this->assertNull($this->objectInstance->getHashedPassword($password));
84 $this->assertNotNull($this->objectInstance->getHashedPassword($password));
92 $password =
'password';
93 $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
94 $this->assertTrue($this->objectInstance->isValidSaltedPW($saltedHashPassword));
102 $password =
'password';
105 $salt = $this->objectInstance->base64Encode($randomBytes, $this->objectInstance->getSaltLength());
106 $this->assertTrue($this->objectInstance->isValidSalt($salt));
107 $saltedHashPassword = $this->objectInstance->getHashedPassword($password, $salt);
108 $this->assertTrue($this->objectInstance->isValidSaltedPW($saltedHashPassword));
116 $password =
'password';
117 $minHashCount = $this->objectInstance->getMinHashCount();
118 $this->objectInstance->setHashCount($minHashCount);
119 $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
120 $this->assertTrue($this->objectInstance->isValidSaltedPW($saltedHashPassword));
122 $this->objectInstance->setHashCount(NULL);
135 $password =
'aEjOtY';
136 $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
137 $this->assertTrue($this->objectInstance->checkPassword($password, $saltedHashPassword));
151 $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
152 $this->assertTrue($this->objectInstance->checkPassword($password, $saltedHashPassword));
165 $password =
' !"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~';
166 $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
167 $this->assertTrue($this->objectInstance->checkPassword($password, $saltedHashPassword));
181 for ($i = 160; $i <= 191; $i++) {
182 $password .= chr($i);
184 $password .= chr(215) . chr(247);
185 $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
186 $this->assertTrue($this->objectInstance->checkPassword($password, $saltedHashPassword));
200 for ($i = 192; $i <= 214; $i++) {
201 $password .= chr($i);
203 for ($i = 216; $i <= 246; $i++) {
204 $password .= chr($i);
206 for ($i = 248; $i <= 255; $i++) {
207 $password .= chr($i);
209 $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
210 $this->assertTrue($this->objectInstance->checkPassword($password, $saltedHashPassword));
218 $password =
'password';
219 $password1 = $password .
'INVALID';
220 $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
221 $this->assertFalse($this->objectInstance->checkPassword($password1, $saltedHashPassword));
231 $criticalPwLength = 0;
233 $saltedHashPasswordCurrent = $salt = $this->objectInstance->getHashedPassword($pad);
234 for ($i = 0; $i <= 128; $i += 8) {
235 $password = str_repeat($pad, max($i, 1));
236 $saltedHashPasswordPrevious = $saltedHashPasswordCurrent;
237 $saltedHashPasswordCurrent = $this->objectInstance->getHashedPassword($password, $salt);
238 if ($i > 0 && $saltedHashPasswordPrevious === $saltedHashPasswordCurrent) {
239 $criticalPwLength = $i;
243 $this->assertTrue($criticalPwLength == 0 || $criticalPwLength > 32,
'Duplicates of hashed passwords with plaintext password of length ' . $criticalPwLength .
'+.');
250 $minHashCount = $this->objectInstance->getMinHashCount();
251 $this->objectInstance->setMinHashCount($minHashCount - 1);
252 $this->assertTrue($this->objectInstance->getMinHashCount() < $minHashCount);
253 $this->objectInstance->setMinHashCount($minHashCount + 1);
254 $this->assertTrue($this->objectInstance->getMinHashCount() > $minHashCount);
261 $maxHashCount = $this->objectInstance->getMaxHashCount();
262 $this->objectInstance->setMaxHashCount($maxHashCount + 1);
263 $this->assertTrue($this->objectInstance->getMaxHashCount() > $maxHashCount);
264 $this->objectInstance->setMaxHashCount($maxHashCount - 1);
265 $this->assertTrue($this->objectInstance->getMaxHashCount() < $maxHashCount);
272 $hashCount = $this->objectInstance->getHashCount();
273 $this->objectInstance->setMaxHashCount($hashCount + 1);
274 $this->objectInstance->setHashCount($hashCount + 1);
275 $this->assertTrue($this->objectInstance->getHashCount() > $hashCount);
276 $this->objectInstance->setMinHashCount($hashCount - 1);
277 $this->objectInstance->setHashCount($hashCount - 1);
278 $this->assertTrue($this->objectInstance->getHashCount() < $hashCount);
280 $this->objectInstance->setHashCount(NULL);
288 $password =
'password';
289 $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
290 $this->assertFalse($this->objectInstance->isHashUpdateNeeded($saltedHashPassword));
297 $password =
'password';
298 $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
299 $increasedHashCount = $this->objectInstance->getHashCount() + 1;
300 $this->objectInstance->setMaxHashCount($increasedHashCount);
301 $this->objectInstance->setHashCount($increasedHashCount);
302 $this->assertTrue($this->objectInstance->isHashUpdateNeeded($saltedHashPassword));
304 $this->objectInstance->setHashCount(NULL);
312 $password =
'password';
313 $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
314 $decreasedHashCount = $this->objectInstance->getHashCount() - 1;
315 $this->objectInstance->setMinHashCount($decreasedHashCount);
316 $this->objectInstance->setHashCount($decreasedHashCount);
317 $this->assertFalse($this->objectInstance->isHashUpdateNeeded($saltedHashPassword));
319 $this->objectInstance->setHashCount(NULL);
nonEmptyPasswordResultsInNonNullSaltedPassword()
authenticationWithNonValidPassword()
emptyPasswordResultsInNullSaltedPassword()
authenticationWithValidNumericCharClassPassword()
static generateRandomBytes($bytesToReturn)
updateNecessityForValidSaltedPassword()
createdSaltedHashOfProperStructureForCustomSaltWithoutSetting()
authenticationWithValidLatin1UmlautCharClassPassword()
skipTestIfBlowfishIsNotAvailable()
authenticationWithValidLatin1SpecialCharClassPassword()
updateNecessityForDecreasedHashcount()
authenticationWithValidAlphaCharClassPassword()
updateNecessityForIncreasedHashcount()
createdSaltedHashOfProperStructure()
passwordVariationsResultInDifferentHashes()
createdSaltedHashOfProperStructureForMinimumHashCount()
authenticationWithValidAsciiSpecialCharClassPassword()