[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/vendor/phpseclib/phpseclib/phpseclib/File/ -> ASN1.php (summary)

Pure-PHP ASN.1 Parser PHP version 5

Author: Jim Wigginton
Copyright: 2012 Jim Wigginton
License: http://www.opensource.org/licenses/mit-license.html MIT License
Link: http://phpseclib.sourceforge.net
File Size: 1414 lines (56 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

ASN1:: (14 methods):
  decodeBER()
  _decode_ber()
  asn1map()
  encodeDER()
  _encode_der()
  _encodeLength()
  _decodeOID()
  _encodeOID()
  _decodeTime()
  setTimeFormat()
  loadOIDs()
  loadFilters()
  _string_shift()
  convert()


Class: ASN1  - X-Ref

Pure-PHP ASN.1 Parser

decodeBER($encoded)   X-Ref
Parse BER-encoding

Serves a similar purpose to openssl's asn1parse

return: array
param: string $encoded

_decode_ber($encoded, $start = 0, $encoded_pos = 0)   X-Ref
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.

return: array
param: string $encoded
param: int $start
param: int $encoded_pos

asn1map($decoded, $mapping, $special = array()   X-Ref
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.

return: array
param: array $decoded
param: array $mapping
param: array $special

encodeDER($source, $mapping, $special = array()   X-Ref
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.

return: string
param: string $source
param: string $mapping
param: int $idx

_encode_der($source, $mapping, $idx = null, $special = array()   X-Ref
ASN.1 Encode (Helper function)

return: string
param: string $source
param: string $mapping
param: int $idx

_encodeLength($length)   X-Ref
DER-encode the length

DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4.  See
{@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information.

return: string
param: int $length

_decodeOID($content)   X-Ref
BER-decode the OID

Called by _decode_ber()

return: string
param: string $content

_encodeOID($source)   X-Ref
DER-encode the OID

Called by _encode_der()

return: string
param: string $content

_decodeTime($content, $tag)   X-Ref
BER-decode the time

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

return: string
param: string $content
param: int $tag

setTimeFormat($format)   X-Ref
Set the time format

Sets the time / date format for asn1map().

param: string $format

loadOIDs($oids)   X-Ref
Load OIDs

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

param: array $oids

loadFilters($filters)   X-Ref
Load filters

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

param: array $filters

_string_shift(&$string, $index = 1)   X-Ref
String Shift

Inspired by array_shift

return: string
param: string $string
param: int $index

convert($in, $from = self::TYPE_UTF8_STRING, $to = self::TYPE_UTF8_STRING)   X-Ref
String type conversion

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

return: string
param: string $in
param: int $from
param: int $to