Issues (15)

src/structures/OCSPRequest.php (2 issues)

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
use \vakata\asn1\Encoder;
0 ignored issues
show
The type \vakata\asn1\Encoder 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...
7
8
class OCSPRequest extends Structure
9
{
10
    public static function generate(
11
        string $algorithm,
12
        string $issuerNameHash,
13
        string $issuerKeyHash,
14
        string $serialNumber
15
    ) {
16
        $alg = ASN1::TextToOID(strtolower($algorithm));
17
        if ($alg === strtolower($algorithm)) {
18
            $alg = ASN1::TextToOID('md5');
19
        }
20
        $src = [
21
            'tbsRequest' => [
22
                'requestList' => [
23
                    [
24
                        'reqCert' => [
25
                            'hashAlgorithm' => [
26
                                'algorithm' => $alg
27
                            ],
28
                            'issuerNameHash' => $issuerNameHash,
29
                            'issuerKeyHash' => $issuerKeyHash,
30
                            'serialNumber' => $serialNumber,
31
                        ]
32
                    ]
33
                ]
34
            ]
35
        ];
36
        return Encoder::encode($src, static::map());
37
    }
38
39
    public static function map()
40
    {
41
        return [
42
            'tag' => ASN1::TYPE_SEQUENCE,
43
            'children' => [
44
                'tbsRequest' => [
45
                    'tag' => ASN1::TYPE_SEQUENCE,
46
                    'children' => [
47
                        'version' => [
48
                            'tag' => ASN1::TYPE_INTEGER,
49
                            'name' => 0,
50
                            'implicit' => false,
51
                            'map' => [1=>'v1'],
52
                            'optional' => true
53
                        ],
54
                        'requestorName' => [
55
                            'tag' => ASN1::TYPE_GENERAL_STRING,
56
                            'optional' => true,
57
                            'name' => 1,
58
                            'implicit' => false,
59
                        ],
60
                        'requestList' => [
61
                            'tag' => ASN1::TYPE_SEQUENCE,
62
                            'repeat' => [
63
                                'tag' => ASN1::TYPE_SEQUENCE,
64
                                'children' => [
65
                                    'reqCert' => [
66
                                        'tag' => ASN1::TYPE_SEQUENCE,
67
                                        'children' => [
68
                                            'hashAlgorithm' => Common::AlgorithmIdentifier(),
69
                                            'issuerNameHash' => [
70
                                                'tag' => ASN1::TYPE_OCTET_STRING,
71
                                            ],
72
                                            'issuerKeyHash' => [
73
                                                'tag' => ASN1::TYPE_OCTET_STRING,
74
                                            ],
75
                                            'serialNumber' => [
76
                                                'tag' => ASN1::TYPE_INTEGER,
77
                                                'base' => 16
78
                                            ],
79
                                        ]
80
                                    ],
81
                                    'extensions' => Common::extensions() + [
82
                                        'name' => 0,
83
                                        'implicit' => false,
84
                                        'optional' => true
85
                                    ]
86
                                ]
87
                            ]
88
                        ],
89
                        'extensions' => Common::extensions() + ['name' => 2, 'implicit' => false, 'optional' => true ]
90
                    ]
91
                ],
92
                'signature' => [
93
                    'tag' => ASN1::TYPE_SEQUENCE,
94
                    'name' => 0,
95
                    'implicit' => false,
96
                    'optional' => true,
97
                    'children' => [
98
                        'signatureAlgorithm' => Common::AlgorithmIdentifier(),
99
                        'signature' => [
100
                            'tag' => ASN1::TYPE_BIT_STRING,
101
                        ],
102
                        'certs' => [
103
                            'tag' => ASN1::TYPE_ANY,
104
                            'name' => 0,
105
                            'implicit' => false,
106
                            'optional' => true
107
                        ]
108
                    ]
109
                ]
110
            ]
111
        ];
112
    }
113
}
114