get('kty') !== 'oct') { return; } if (! $jwk->has('alg') || $jwk->get('alg') !== $this->getAlgorithmName()) { 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 < $this->getMinimumKeySize()) { $bag->add( Message::high(sprintf( 'HS512 algorithm requires at least %d bits key length.', $this->getMinimumKeySize() )) ); } } abstract protected function getAlgorithmName(): string; abstract protected function getMinimumKeySize(): int; }