Skip to content

hidasw/PhpASN1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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);

About

Php Parse and create ASN.1 without depedencies or other libraries

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages