__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
declare(strict_types=1);
namespace Webauthn;
use CBOR\ByteStringObject;
use CBOR\MapItem;
use CBOR\MapObject;
use CBOR\NegativeIntegerObject;
use CBOR\UnsignedIntegerObject;
use Cose\Algorithms;
use Cose\Key\Ec2Key;
class U2FPublicKey
{
public static function isU2FKey(string $publicKey): bool
{
return $publicKey[0] === "\x04" && mb_strlen($publicKey, '8bit') === 65;
}
public static function convertToCoseKey(string $publicKey): string
{
return MapObject::create([
MapItem::create(
UnsignedIntegerObject::create(Ec2Key::TYPE),
UnsignedIntegerObject::create(Ec2Key::TYPE_EC2)
),
MapItem::create(
UnsignedIntegerObject::create(Ec2Key::ALG),
NegativeIntegerObject::create(Algorithms::COSE_ALGORITHM_ES256)
),
MapItem::create(
NegativeIntegerObject::create(Ec2Key::DATA_CURVE),
UnsignedIntegerObject::create(Ec2Key::CURVE_P256)
),
MapItem::create(
NegativeIntegerObject::create(Ec2Key::DATA_X),
ByteStringObject::create(mb_substr($publicKey, 1, 32, '8bit'))
),
MapItem::create(
NegativeIntegerObject::create(Ec2Key::DATA_Y),
ByteStringObject::create(mb_substr($publicKey, 33, null, '8bit'))
),
])->__toString();
}
}