Skip to content

Commit 7a81928

Browse files
Merge MC-36790 into cia-2.3.7
2 parents 43aa07f + c74b946 commit 7a81928

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/internal/Magento/Framework/Encryption/Encryptor.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,14 @@ public function getHash($password, $salt = false, $version = self::HASH_VERSION_
219219
}
220220

221221
if ($isArgon) {
222+
//phpcs:disable PHPCompatibility.Constants.NewConstants
222223
$seedBytes = SODIUM_CRYPTO_SIGN_SEEDBYTES;
223224
$opsLimit = SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE;
224225
$memLimit = SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE;
225226
if ($version === self::HASH_VERSION_ARGON2ID13_AGNOSTIC) {
226227
$version = implode('_', [self::HASH_VERSION_ARGON2ID13_AGNOSTIC, $seedBytes, $opsLimit, $memLimit]);
227228
}
229+
//phpcs:enable PHPCompatibility.Constants.NewConstants
228230

229231
$hash = $this->getArgonHash($password, $seedBytes, $opsLimit, $memLimit, $salt);
230232
} else {
@@ -302,13 +304,15 @@ public function isValidHash($password, $hash)
302304
$hashSalt
303305
);
304306
} elseif ((int)$hashVersion === self::HASH_VERSION_ARGON2ID13) {
307+
//phpcs:disable PHPCompatibility.Constants.NewConstants
305308
$recreated = $this->getArgonHash(
306309
$recreated,
307310
SODIUM_CRYPTO_SIGN_SEEDBYTES,
308311
SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE,
309312
SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE,
310313
$hashSalt
311314
);
315+
//phpcs:enable PHPCompatibility.Constants.NewConstants
312316
} else {
313317
$recreated = $this->generateSimpleHash($hashSalt . $recreated, (int)$hashVersion);
314318
}
@@ -586,6 +590,7 @@ private function getArgonHash(
586590
int $memLimit,
587591
string $salt
588592
): string {
593+
//phpcs:disable PHPCompatibility.Constants.NewConstants
589594
if (strlen($salt) < SODIUM_CRYPTO_PWHASH_SALTBYTES) {
590595
$salt = str_pad($salt, SODIUM_CRYPTO_PWHASH_SALTBYTES, $salt);
591596
} elseif (strlen($salt) > SODIUM_CRYPTO_PWHASH_SALTBYTES) {
@@ -602,5 +607,6 @@ private function getArgonHash(
602607
SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13
603608
)
604609
);
610+
//phpcs:enable PHPCompatibility.Constants.NewConstants
605611
}
606612
}

lib/internal/Magento/Framework/Encryption/Test/Unit/EncryptorTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public function testGetHashSpecifiedSalt(): void
9696
*/
9797
public function testGetHashRandomSaltDefaultLength(): void
9898
{
99+
//phpcs:disable PHPCompatibility.Constants.NewConstants
99100
$salt = 'random-salt';
100101
$salt = str_pad(
101102
$salt,
@@ -116,6 +117,7 @@ public function testGetHashRandomSaltDefaultLength(): void
116117
->willReturn($salt);
117118
$actual = $this->encryptor->getHash('password', true, $version);
118119
$this->assertEquals($expected, $actual);
120+
//phpcs:enable PHPCompatibility.Constants.NewConstants
119121
}
120122

121123
/**

0 commit comments

Comments
 (0)