Skip to content

vakata/asn1

Repository files navigation

asn1

Latest Version on Packagist Software License Build Status Scrutinizer Code Quality Code Coverage

Am ASN1 encoder / decoder.

Install

Via Composer

$ composer require vakata/asn1

Usage

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

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email github@vakata.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

ASN1 parser and builder

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages