Am ASN1 encoder / decoder.
Via Composer
$ composer require vakata/asn1
The main part of the library are the Decoder
and Encoder
classes.
// first create an instance (there is a fromFile static method as well)
$decoded = \vakata\asn1\Decoder::fromString("...ASN1 data here ...");
// you can then inspect the parsed raw data
$decoded->structure(); // more info
$decoded->values(); // just values
// or map the data to an existing map
$decoded->map($mapArray);
// the encoder on the otherhand needs some data and a map
\vakata\asn1\Encoder::encode($dataArray, $mapArray);
There are helper classes in the structures
namespace - these help with working with common known structures. All the structures have fromString
and fromFile
static constructor methods, and a toArray
method.
// Timestamp example:
\vakata\asn1\structures\TimestampRequest::fromString($tsq)->toArray();
\vakata\asn1\structures\TimestampResponse::fromFile('/path/to/timestamp/response')->toArray();
\vakata\asn1\structures\TimestampRequest::generateFromFile('/path/to/file/to/timestamp');
// You can also work with Certificate, CRL, OCSPRequest, OCSPResponse, P7S
Read more in the API docs
$ composer test
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.