Skip to content

Latest commit

 

History

History
58 lines (57 loc) · 1.21 KB

README.md

File metadata and controls

58 lines (57 loc) · 1.21 KB

Php ASN.1

Independent Asn.1 Parse & Create

Description

Php function to parse and create ASN.1 hex form.
base64 form need to decoded then convert to hex.
DER form need to convert to hex.

Usage

Parse as array:

Parse hex encoded and return as array:

include 'asn1.php;
// $hex is hex form such from bin2hex()
$return = asn1::parse($hex);

To specify max parsing depth:

$maxdepth = 9;
asn1::parse($hex, $maxdepth);

Create:

create sequence:

asn1::sequence($hexdata);

create set:

asn1::set($hexdata);

create various structure:

asn1::sequence(
              asn::sequence(
                            asn1::integer('2')
                            ).
              asn1::set(
                        asn1::bitstr('00')
                        )
              );

Supported tags

asn1::sequence($hex);
asn1::octet($hex);
asn1::object($hex);
asn1::bitstr($hex);
asn1::printablestr($str);
asn1::integer($int);
asn1::set($hex);
asn1::explicit($explicitNumber, $hex);
asn1::implicit($num="0");
asn1::utctime($time); // ymdHis
asn1::generalizedtime($time); // YmdHis
asn1::utf8str($str);
asn1::ia5str($str);
asn1::visiblestr($str);
asn1::t61str($str);