primo commit
This commit is contained in:
30
libraries/vendor/web-token/jwt-library/KeyManagement/Analyzer/OctAnalyzer.php
vendored
Normal file
30
libraries/vendor/web-token/jwt-library/KeyManagement/Analyzer/OctAnalyzer.php
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Jose\Component\KeyManagement\Analyzer;
|
||||
|
||||
use Jose\Component\Core\JWK;
|
||||
use Jose\Component\Core\Util\Base64UrlSafe;
|
||||
use function is_string;
|
||||
|
||||
final class OctAnalyzer implements KeyAnalyzer
|
||||
{
|
||||
public function analyze(JWK $jwk, MessageBag $bag): void
|
||||
{
|
||||
if ($jwk->get('kty') !== 'oct') {
|
||||
return;
|
||||
}
|
||||
$k = $jwk->get('k');
|
||||
if (! is_string($k)) {
|
||||
$bag->add(Message::high('The key is not valid'));
|
||||
|
||||
return;
|
||||
}
|
||||
$k = Base64UrlSafe::decodeNoPadding($k);
|
||||
$kLength = 8 * mb_strlen($k, '8bit');
|
||||
if ($kLength < 128) {
|
||||
$bag->add(Message::high('The key length is less than 128 bits.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user