Issues (15)

src/structures/OCSPResponse.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace vakata\asn1\structures;
4
5
use \vakata\asn1\ASN1;
0 ignored issues
show
The type \vakata\asn1\ASN1 was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
/**
8
 * A class for OCSP parsing
9
 */
10
class OCSPResponse extends Structure
11
{
12
    public function subject()
13
    {
14
        $map = static::map();
15
        $map['children']['responseBytes']['children']['response']['map']['children']['tbsResponseData']['tag'] =
16
            ASN1::TYPE_ANY_DER;
17
        $temp = \vakata\asn1\Decoder::fromString($this->getReader()->chunk(0))->map($map);
18
        return $temp['responseBytes']['response']['tbsResponseData'];
19
    }
20
21
    public static function map()
22
    {
23
        return [
24
            'tag' => ASN1::TYPE_SEQUENCE,
25
            'children' => [
26
                'responseStatus' => [
27
                    'tag' => ASN1::TYPE_ENUMERATED,
28
                    'map' => [
29
                        'successful',
30
                        'malformedRequest',
31
                        'internalError',
32
                        'tryLater',
33
                        '',
34
                        'sigRequired',
35
                        'unauthorized'
36
                    ]
37
                ],
38
                'responseBytes' => [
39
                    'name' => 0,
40
                    'implicit' => false,
41
                    'optional' => true,
42
                    'tag' => ASN1::TYPE_SEQUENCE,
43
                    'children' => [
44
                        'responseType' => [
45
                            'tag' => ASN1::TYPE_OBJECT_IDENTIFIER
46
                        ],
47
                        'response' => [
48
                            'tag' => ASN1::TYPE_OCTET_STRING,
49
                            'der' => true,
50
                            'map' => [
51
                                'tag' => ASN1::TYPE_SEQUENCE,
52
                                'children' => [
53
                                    'tbsResponseData' => [
54
                                        'tag' => ASN1::TYPE_SEQUENCE,
55
                                        'children' => [
56
                                            'version' => [
57
                                                'tag' => ASN1::TYPE_INTEGER,
58
                                                'name' => 0,
59
                                                'implicit' => false,
60
                                                'map' => [1=>'v1'],
61
                                                'optional' => true
62
                                            ],
63
                                            'responderID' => [
64
                                                'tag' => ASN1::TYPE_CHOICE,
65
                                                'children' => [
66
                                                    'byName' => [
67
                                                        'name' => 1,
68
                                                        'tag' => ASN1::TYPE_OCTET_STRING,
69
                                                    ],
70
                                                    'byKey' => [
71
                                                        'name' => 2,
72
                                                        'tag' => ASN1::TYPE_OCTET_STRING,
73
                                                    ]
74
                                                ]
75
                                            ],
76
                                            'producedAt' => [
77
                                                'tag' => ASN1::TYPE_GENERALIZED_TIME
78
                                            ],
79
                                            'responses' => [
80
                                                'tag' => ASN1::TYPE_SEQUENCE,
81
                                                'repeat' => [
82
                                                    'tag' => ASN1::TYPE_SEQUENCE,
83
                                                    'children' => [
84
                                                        'certID' => [
85
                                                            'tag' => ASN1::TYPE_SEQUENCE,
86
                                                            'children' => [
87
                                                                'hashAlgorithm' => Common::AlgorithmIdentifier(),
88
                                                                'issuerNameHash' => [
89
                                                                    'tag' => ASN1::TYPE_OCTET_STRING,
90
                                                                ],
91
                                                                'issuerKeyHash' => [
92
                                                                    'tag' => ASN1::TYPE_OCTET_STRING,
93
                                                                ],
94
                                                                'serialNumber' => [
95
                                                                    'tag' => ASN1::TYPE_INTEGER,
96
                                                                    'base' => 16
97
                                                                ]
98
                                                            ]
99
                                                        ],
100
                                                        'certStatus' => [
101
                                                            'tag' => ASN1::TYPE_CHOICE,
102
                                                            'children' => [
103
                                                                'good'    => [
104
                                                                    'name' => 0,
105
                                                                    'tag' => 0,
106
                                                                    'value' => 'good'
107
                                                                ],
108
                                                                'revoked' => [
109
                                                                    'name' => 1,
110
                                                                    'tag' => 1,
111
                                                                    'value' => 'revoked'
112
                                                                ],
113
                                                                'unknown' => [
114
                                                                    'name' => 2,
115
                                                                    'tag' => 2,
116
                                                                    'value' => 'unknown'
117
                                                                ],
118
                                                            ]
119
                                                        ],
120
                                                        'thisUpdate' => [ 'tag' => ASN1::TYPE_GENERALIZED_TIME ],
121
                                                        'nextUpdate' => [
122
                                                            'tag' => ASN1::TYPE_GENERALIZED_TIME,
123
                                                            'name' => 0,
124
                                                            'implicit' => false,
125
                                                            'optional' => true
126
                                                        ],
127
                                                        'extensions' => Common::extensions() + [
128
                                                            'name' => 1,
129
                                                            'implicit' => false
130
                                                        ]
131
                                                    ]
132
                                                ]
133
                                            ],
134
                                            'extensions' => Common::extensions() + [ 'name' => 1, 'implicit' => false ]
135
                                        ]
136
                                    ],
137
                                    'signatureAlgorithm' => Common::AlgorithmIdentifier(),
138
                                    'signature' => [
139
                                        'tag' => ASN1::TYPE_BIT_STRING,
140
                                    ],
141
                                    'certs' => [
142
                                        'tag' => ASN1::TYPE_SEQUENCE,
143
                                        'name' => 0,
144
                                        'implicit' => false,
145
                                        'optional' => true,
146
                                        'repeat' => [
147
                                            'tag' => ASN1::TYPE_ANY_DER,
148
                                        ]
149
                                    ]
150
                                ]
151
                            ]
152
                        ]
153
                    ]
154
                ]
155
            ]
156
        ];
157
    }
158
}
159