get('kty')) { return; } if (!$jwk->has('crv')) { $bag->add(Message::high('Invalid key. The components "crv" is missing.')); return; } if ('P-256' !== $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 || 256 !== $yLength) { $bag->add(Message::high('Invalid key. The components "x" and "y" size shall be 256 bits.')); } $xBI = BigInteger::fromBase(bin2hex($x), 16); $yBI = BigInteger::fromBase(bin2hex($y), 16); $curve = NistCurve::curve256(); if (!$curve->contains($xBI, $yBI)) { $bag->add(Message::high('Invalid key. The point is not on the curve.')); } } }