[ 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 param: Element|string $encoded return: ?array |
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. param: string $encoded param: int $start param: int $encoded_pos return: array|bool |
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. param: array $decoded param: array $mapping param: array $special return: array|bool|Element|string|null |
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. param: string $string return: int |
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. param: Element|string|array $source param: array $mapping param: array $special return: string |
encode_der($source, array $mapping, $idx = null, array $special = []) X-Ref |
ASN.1 Encode (Helper function) param: Element|string|array|null $source param: array $mapping param: int $idx param: array $special return: string |
decodeOID($content) X-Ref |
BER-decode the OID Called by _decode_ber() param: string $content return: string |
encodeOID($source) X-Ref |
DER-encode the OID Called by _encode_der() param: string $source return: string |
decodeTime($content, $tag) X-Ref |
BER-decode the time Called by _decode_ber() and in the case of implicit tags asn1map(). param: string $content param: int $tag return: \DateTime|false |
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. param: string $in param: int $from param: int $to return: string |
extractBER($str) X-Ref |
Extract raw BER from Base64 encoding param: string $str return: string |
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. param: int $length return: string |
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' param: string $name return: string |