Jose\KeyConverter\ECKey::loadPublicPEM PHP Method

loadPublicPEM() private method

private loadPublicPEM ( array $children ) : array
$children array
return array
    private function loadPublicPEM(array $children)
    {
        Assertion::isInstanceOf($children[0], Sequence::class, 'Unsupported key type');
        $sub = $children[0]->getChildren();
        Assertion::isInstanceOf($sub[0], ObjectIdentifier::class, 'Unsupported key type');
        Assertion::eq('1.2.840.10045.2.1', $sub[0]->getContent(), 'Unsupported key type');
        Assertion::isInstanceOf($sub[1], ObjectIdentifier::class, 'Unsupported key type');
        Assertion::isInstanceOf($children[1], BitString::class, 'Unable to load the key');
        $bits = $children[1]->getContent();
        $bits_length = mb_strlen($bits, '8bit');
        Assertion::eq('04', mb_substr($bits, 0, 2, '8bit'), 'Unsupported key type');
        $this->values['kty'] = 'EC';
        $this->values['crv'] = $this->getCurve($sub[1]->getContent());
        $this->values['x'] = Base64Url::encode(hex2bin(mb_substr($bits, 2, ($bits_length - 2) / 2, '8bit')));
        $this->values['y'] = Base64Url::encode(hex2bin(mb_substr($bits, ($bits_length - 2) / 2 + 2, ($bits_length - 2) / 2, '8bit')));
    }