| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace SpomkyLabs\Pki\X509\Certificate\Extension; |
| 6 |
|
| 7 |
use SpomkyLabs\Pki\ASN1\Element; |
| 8 |
use SpomkyLabs\Pki\ASN1\Type\Primitive\OctetString; |
| 9 |
use SpomkyLabs\Pki\ASN1\Type\UnspecifiedType; |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
final class SubjectKeyIdentifierExtension extends Extension |
| 17 |
{ |
| 18 |
private function __construct( |
| 19 |
bool $critical, |
| 20 |
private readonly string $keyIdentifier |
| 21 |
) { |
| 22 |
parent::__construct(self::OID_SUBJECT_KEY_IDENTIFIER, $critical); |
| 23 |
} |
| 24 |
|
| 25 |
public static function create(bool $critical, string $keyIdentifier): self |
| 26 |
{ |
| 27 |
return new self($critical, $keyIdentifier); |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public function keyIdentifier(): string |
| 34 |
{ |
| 35 |
return $this->keyIdentifier; |
| 36 |
} |
| 37 |
|
| 38 |
protected static function fromDER(string $data, bool $critical): static |
| 39 |
{ |
| 40 |
return self::create($critical, UnspecifiedType::fromDER($data)->asOctetString()->string()); |
| 41 |
} |
| 42 |
|
| 43 |
protected function valueASN1(): Element |
| 44 |
{ |
| 45 |
return OctetString::create($this->keyIdentifier); |
| 46 |
} |
| 47 |
} |