Skip to content

Commit a586ad4

Browse files
Handle argon failures robustly (#33856)
1 parent 9c61823 commit a586ad4

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Illuminate/Hashing/ArgonHasher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ public function __construct(array $options = [])
6060
*/
6161
public function make($value, array $options = [])
6262
{
63-
$hash = password_hash($value, $this->algorithm(), [
63+
$hash = @password_hash($value, $this->algorithm(), [
6464
'memory_cost' => $this->memory($options),
6565
'time_cost' => $this->time($options),
6666
'threads' => $this->threads($options),
6767
]);
6868

69-
if ($hash === false) {
69+
if (! is_string($hash)) {
7070
throw new RuntimeException('Argon2 hashing not supported.');
7171
}
7272

tests/Hashing/HasherTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public function testBasicArgon2idHashing()
5151
$this->assertSame('argon2id', password_get_info($value)['algoName']);
5252
}
5353

54+
/**
55+
* @depends testBasicBcryptHashing
56+
*/
5457
public function testBasicBcryptVerification()
5558
{
5659
$this->expectException(RuntimeException::class);
@@ -64,6 +67,9 @@ public function testBasicBcryptVerification()
6467
(new BcryptHasher(['verify' => true]))->check('password', $argonHashed);
6568
}
6669

70+
/**
71+
* @depends testBasicArgon2iHashing
72+
*/
6773
public function testBasicArgon2iVerification()
6874
{
6975
$this->expectException(RuntimeException::class);
@@ -73,6 +79,9 @@ public function testBasicArgon2iVerification()
7379
(new ArgonHasher(['verify' => true]))->check('password', $bcryptHashed);
7480
}
7581

82+
/**
83+
* @depends testBasicArgon2idHashing
84+
*/
7685
public function testBasicArgon2idVerification()
7786
{
7887
$this->expectException(RuntimeException::class);

0 commit comments

Comments
 (0)