Skip to content

Commit c6668ea

Browse files
committed
Ensure OpenSSL or Sodium are available before cypher operation
1 parent 1106d8a commit c6668ea

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Signature/Blake2b.php

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Jose\Component\Core\JWK;
99
use Jose\Component\Signature\Algorithm\MacAlgorithm;
1010
use ParagonIE\ConstantTime\Base64UrlSafe;
11+
use RuntimeException;
12+
use function extension_loaded;
1113
use function in_array;
1214
use function is_string;
1315

@@ -18,6 +20,13 @@ final class Blake2b implements MacAlgorithm
1820
{
1921
private const MINIMUM_KEY_LENGTH = 32;
2022

23+
public function __construct()
24+
{
25+
if (! extension_loaded('sodium')) {
26+
throw new RuntimeException('Please install the Sodium extension');
27+
}
28+
}
29+
2130
public function allowedKeyTypes(): array
2231
{
2332
return ['oct'];

0 commit comments

Comments
 (0)