[ Index ] |
PHP Cross Reference of DokuWiki |
[Source view] [Print] [Project Stats]
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: | 1513 lines (61 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
decodeBER($encoded) X-Ref |
Parse BER-encoding Serves a similar purpose to openssl's asn1parse return: ?array param: Element|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|bool param: string $encoded param: int $start param: int $encoded_pos |
asn1map(array $decoded, $mapping, $special = []) 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|bool|Element|string|null param: array $decoded param: array $mapping param: array $special |
decodeLength(&$string) X-Ref |
DER-decode 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: int param: string $string |
encodeDER($source, $mapping, $special = []) 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: Element|string|array $source param: array $mapping param: array $special |
encode_der($source, array $mapping, $idx = null, array $special = []) X-Ref |
ASN.1 Encode (Helper function) return: string param: Element|string|array|null $source param: array $mapping param: int $idx param: array $special |
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 $source |
decodeTime($content, $tag) X-Ref |
BER-decode the time Called by _decode_ber() and in the case of implicit tags asn1map(). return: \DateTime|false 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(array $oids) X-Ref |
Load OIDs Load the relevant OIDs for a particular ASN.1 semantic mapping. Previously loaded OIDs are retained. param: array $oids |
setFilters(array $filters) X-Ref |
Set filters See \phpseclib3\File\X509, etc, for an example. Previously loaded filters are not retained. param: array $filters |
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 |
extractBER($str) X-Ref |
Extract raw BER from Base64 encoding return: string param: string $str |
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 |
getOID($name) X-Ref |
Returns the OID corresponding to a name What's returned in the associative array returned by loadX509() (or load*()) is either a name or an OID if no OID to name mapping is available. The problem with this is that what may be an unmapped OID in one version of phpseclib may not be unmapped in the next version, so apps that are looking at this OID may not be able to work from version to version. This method will return the OID if a name is passed to it and if no mapping is avialable it'll assume that what's being passed to it already is an OID and return that instead. A few examples. getOID('2.16.840.1.101.3.4.2.1') == '2.16.840.1.101.3.4.2.1' getOID('id-sha256') == '2.16.840.1.101.3.4.2.1' getOID('zzz') == 'zzz' return: string param: string $name |