Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
66.67% |
2 / 3 |
CRAP | |
90.00% |
18 / 20 |
| Pkcs7UnverifiedParser | |
0.00% |
0 / 1 |
|
66.67% |
2 / 3 |
3.01 | |
90.00% |
18 / 20 |
| __construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| readUnverified | |
100.00% |
1 / 1 |
1 | |
100.00% |
17 / 17 |
|||
| readUsingOnlyTrustedCerts | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| 1 | <?php |
| 2 | |
| 3 | namespace Proton\IosReceiptParser\ASN1; |
| 4 | |
| 5 | use phpseclib3\File\ASN1; |
| 6 | |
| 7 | class Pkcs7UnverifiedParser implements Pkcs7Reader |
| 8 | { |
| 9 | private $decoder; |
| 10 | |
| 11 | public function __construct() |
| 12 | { |
| 13 | $this->decoder = new SimpleDecoder(); |
| 14 | } |
| 15 | |
| 16 | public function readUnverified(string $ber): string |
| 17 | { |
| 18 | $data = $this->decoder->decode($ber, [ |
| 19 | 'type' => ASN1::TYPE_SEQUENCE, |
| 20 | 'children' => [ |
| 21 | '_id' => ['type' => ASN1::TYPE_ANY], |
| 22 | 'data' => [ |
| 23 | 'type' => ASN1::TYPE_SEQUENCE, |
| 24 | 'constant' => 0, |
| 25 | 'explicit' => true, |
| 26 | 'children' => [ |
| 27 | '_ver' => ['type' => ASN1::TYPE_ANY], |
| 28 | '_sigAlg' => ['type' => ASN1::TYPE_ANY], |
| 29 | 'data' => [ |
| 30 | 'type' => ASN1::TYPE_SEQUENCE, |
| 31 | 'children' => [ |
| 32 | '_id' => ['type' => ASN1::TYPE_ANY], |
| 33 | 'data' => [ |
| 34 | 'type' => ASN1::TYPE_OCTET_STRING, |
| 35 | 'constant' => 0, |
| 36 | 'explicit' => true, |
| 37 | ], |
| 38 | ], |
| 39 | ], |
| 40 | '_certs' => [ |
| 41 | 'type' => ASN1::TYPE_ANY, |
| 42 | 'constant' => 0, |
| 43 | 'implicit' => true, |
| 44 | 'optional' => true, |
| 45 | ], |
| 46 | '_crls' => [ |
| 47 | 'type' => ASN1::TYPE_ANY, |
| 48 | 'constant' => 0, |
| 49 | 'implicit' => true, |
| 50 | 'optional' => true, |
| 51 | ], |
| 52 | '_sig' => ['type' => ASN1::TYPE_ANY], |
| 53 | ], |
| 54 | ], |
| 55 | ], |
| 56 | ]); |
| 57 | |
| 58 | return $data['data']['data']['data']; |
| 59 | } |
| 60 | |
| 61 | public function readUsingOnlyTrustedCerts(string $ber, string ...$certificates): string |
| 62 | { |
| 63 | throw new \Exception('Cannot provide proper pkcs7 verification'); |
| 64 | } |
| 65 | } |