Constants

CLASS_UNIVERSAL

CLASS_UNIVERSAL

CLASS_APPLICATION

CLASS_APPLICATION

CLASS_CONTEXT_SPECIFIC

CLASS_CONTEXT_SPECIFIC

CLASS_PRIVATE

CLASS_PRIVATE

TYPE_BOOLEAN

TYPE_BOOLEAN

TYPE_INTEGER

TYPE_INTEGER

TYPE_BIT_STRING

TYPE_BIT_STRING

TYPE_OCTET_STRING

TYPE_OCTET_STRING

TYPE_NULL

TYPE_NULL

TYPE_OBJECT_IDENTIFIER

TYPE_OBJECT_IDENTIFIER

TYPE_REAL

TYPE_REAL

TYPE_ENUMERATED

TYPE_ENUMERATED

TYPE_UTF8_STRING

TYPE_UTF8_STRING

TYPE_SEQUENCE

TYPE_SEQUENCE

TYPE_SET

TYPE_SET

TYPE_NUMERIC_STRING

TYPE_NUMERIC_STRING

TYPE_PRINTABLE_STRING

TYPE_PRINTABLE_STRING

TYPE_TELETEX_STRING

TYPE_TELETEX_STRING

TYPE_VIDEOTEX_STRING

TYPE_VIDEOTEX_STRING

TYPE_IA5_STRING

TYPE_IA5_STRING

TYPE_UTC_TIME

TYPE_UTC_TIME

TYPE_GENERALIZED_TIME

TYPE_GENERALIZED_TIME

TYPE_GRAPHIC_STRING

TYPE_GRAPHIC_STRING

TYPE_VISIBLE_STRING

TYPE_VISIBLE_STRING

TYPE_GENERAL_STRING

TYPE_GENERAL_STRING

TYPE_UNIVERSAL_STRING

TYPE_UNIVERSAL_STRING

TYPE_BMP_STRING

TYPE_BMP_STRING

TYPE_CHOICE

TYPE_CHOICE

TYPE_ANY

TYPE_ANY

Properties

$oids

$oids : array

ASN.1 object identifier

Type

array

$format

$format : string

Default date format

Type

string

$encoded

$encoded : array

Default date format

Type

array

$filters

$filters : array

Filters

If the mapping type is self::TYPE_ANY what do we actually encode it as?

Type

array

$ANYmap

$ANYmap : array

Type mapping table for the ANY type.

Structured or unknown types are mapped to a \phpseclib\File\ASN1\Element. Unambiguous types get the direct mapping (int/real/bool). Others are mapped as a choice, with an extra indexing level.

Type

array

$stringTypeSize

$stringTypeSize : array

String type to character size mapping table.

Non-convertable types are absent from this table. size == 0 indicates variable length encoding.

Type

array

Methods

decodeBER()

decodeBER(string  $encoded) : array

Parse BER-encoding

Serves a similar purpose to openssl's asn1parse

Parameters

string $encoded

Returns

array

_decode_ber()

_decode_ber(string  $encoded, integer  $start, integer  $encoded_pos) : array

Parse BER-encoding (Helper function)

Sometimes we want to get the BER encoding of a particular tag. $start lets us do that without having to reencode. $encoded is passed by reference for the recursive calls done for self::TYPE_BIT_STRING and self::TYPE_OCTET_STRING. In those cases, the indefinite length is used.

Parameters

string $encoded
integer $start
integer $encoded_pos

Returns

array

asn1map()

asn1map(array  $decoded, array  $mapping, array  $special = array()) : array

ASN.1 Map

Provides an ASN.1 semantic mapping ($mapping) from a parsed BER-encoding to a human readable format.

"Special" mappings may be applied on a per tag-name basis via $special.

Parameters

array $decoded
array $mapping
array $special

Returns

array

encodeDER()

encodeDER(string  $source, string  $mapping,   $special = array()) : string

ASN.1 Encode

DER-encodes an ASN.1 semantic mapping ($mapping). Some libraries would probably call this function an ASN.1 compiler.

"Special" mappings can be applied via $special.

Parameters

string $source
string $mapping
$special

Returns

string

_encode_der()

_encode_der(string  $source, string  $mapping, integer  $idx = null,   $special = array()) : string

ASN.1 Encode (Helper function)

Parameters

string $source
string $mapping
integer $idx
$special

Returns

string

_encodeLength()

_encodeLength(integer  $length) : string

DER-encode the length

DER supports lengths up to (28)127, however, we'll only support lengths up to (28)4. See X.690 paragraph 8.1.3 for more information.

Parameters

integer $length

Returns

string

_decodeOID()

_decodeOID(string  $content) : string

BER-decode the OID

Called by _decode_ber()

Parameters

string $content

Returns

string

_encodeOID()

_encodeOID(  $source) : string

DER-encode the OID

Called by _encode_der()

Parameters

$source

Returns

string

_decodeTime()

_decodeTime(string  $content, integer  $tag) : string

BER-decode the time

Called by _decode_ber() and in the case of implicit tags asn1map().

Parameters

string $content
integer $tag

Returns

string

setTimeFormat()

setTimeFormat(string  $format) 

Set the time format

Sets the time / date format for asn1map().

Parameters

string $format

loadOIDs()

loadOIDs(array  $oids) 

Load OIDs

Load the relevant OIDs for a particular ASN.1 semantic mapping.

Parameters

array $oids

loadFilters()

loadFilters(array  $filters) 

Load filters

See \phpseclib\File\X509, etc, for an example.

Parameters

array $filters

_string_shift()

_string_shift(string  $string, integer  $index = 1) : string

String Shift

Inspired by array_shift

Parameters

string $string
integer $index

Returns

string

convert()

convert(string  $in, integer  $from = self::TYPE_UTF8_STRING, integer  $to = self::TYPE_UTF8_STRING) : string

String type conversion

This is a lazy conversion, dealing only with character size. No real conversion table is used.

Parameters

string $in
integer $from
integer $to

Returns

string