get('kty')) { return; } if (!$jwk->has('crv')) { $bag->add(Message::high('Invalid key. The components "crv" is missing.')); return; } if ('P-521' !== $jwk->get('crv')) { return; } $x = Base64Url::decode($jwk->get('x')); $xLength = 8 * mb_strlen($x, '8bit'); $y = Base64Url::decode($jwk->get('y')); $yLength = 8 * mb_strlen($y, '8bit'); if ($yLength !== $xLength || 528 !== $yLength) { $bag->add(Message::high('Invalid key. The components "x" and "y" size shall be 528 bits.')); } $xBI = BigInteger::fromBase(bin2hex($x), 16); $yBI = BigInteger::fromBase(bin2hex($y), 16); $curve = NistCurve::curve521(); if (!$curve->contains($xBI, $yBI)) { $bag->add(Message::high('Invalid key. The point is not on the curve.')); } } }