Debian Codegraph @

lib/3rdParty/composer/spomky-labs/pki-framework/src/X509/Certificate/Extension/SubjectKeyIdentifierExtension.php

raw symbols SCIP
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 * Implements 'Subject Key Identifier' certificate extension.
13 *
14 * @see https://tools.ietf.org/html/rfc5280#section-4.2.1.2
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 * Get key identifier.
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 }