Lines Matching refs:self

107      * If the mapping type is self::TYPE_ANY what do we actually encode it as?
110 * @see self::encode_der()
120 * @see self::encode_der()
130 * @see self::decodeDER()
144 self::TYPE_BOOLEAN => true,
145 self::TYPE_INTEGER => true,
146 self::TYPE_BIT_STRING => 'bitString',
147 self::TYPE_OCTET_STRING => 'octetString',
148 self::TYPE_NULL => 'null',
149 self::TYPE_OBJECT_IDENTIFIER => 'objectIdentifier',
150 self::TYPE_REAL => true,
151 self::TYPE_ENUMERATED => 'enumerated',
152 self::TYPE_UTF8_STRING => 'utf8String',
153 self::TYPE_NUMERIC_STRING => 'numericString',
154 self::TYPE_PRINTABLE_STRING => 'printableString',
155 self::TYPE_TELETEX_STRING => 'teletexString',
156 self::TYPE_VIDEOTEX_STRING => 'videotexString',
157 self::TYPE_IA5_STRING => 'ia5String',
158 self::TYPE_UTC_TIME => 'utcTime',
159 self::TYPE_GENERALIZED_TIME => 'generalTime',
160 self::TYPE_GRAPHIC_STRING => 'graphicString',
161 self::TYPE_VISIBLE_STRING => 'visibleString',
162 self::TYPE_GENERAL_STRING => 'generalString',
163 self::TYPE_UNIVERSAL_STRING => 'universalString',
164 //self::TYPE_CHARACTER_STRING => 'characterString',
165 self::TYPE_BMP_STRING => 'bmpString'
177 self::TYPE_UTF8_STRING => 0,
178 self::TYPE_BMP_STRING => 2,
179 self::TYPE_UNIVERSAL_STRING => 4,
180 self::TYPE_PRINTABLE_STRING => 1,
181 self::TYPE_TELETEX_STRING => 1,
182 self::TYPE_IA5_STRING => 1,
183 self::TYPE_VISIBLE_STRING => 1,
200 self::$encoded = $encoded;
202 $decoded = self::decode_ber($encoded);
214 * $encoded is passed by reference for the recursive calls done for self::TYPE_BIT_STRING and
215 * self::TYPE_OCTET_STRING. In those cases, the indefinite length is used.
302 case self::CLASS_APPLICATION:
303 case self::CLASS_PRIVATE:
304 case self::CLASS_CONTEXT_SPECIFIC:
317 $temp = self::decode_ber($content, $start, $content_pos);
351 case self::TYPE_BOOLEAN:
358 case self::TYPE_INTEGER:
359 case self::TYPE_ENUMERATED:
365 case self::TYPE_REAL: // not currently supported
367 case self::TYPE_BIT_STRING:
374 $temp = self::decode_ber($content, $start, $content_pos);
382 if ($temp[$i]['type'] != self::TYPE_BIT_STRING) {
388 if ($temp[$last]['type'] != self::TYPE_BIT_STRING) {
394 case self::TYPE_OCTET_STRING:
401 $temp = self::decode_ber($content, $length + $start, $content_pos);
407 if ($temp['type'] != self::TYPE_OCTET_STRING) {
418 case self::TYPE_NULL:
424 case self::TYPE_SEQUENCE:
425 case self::TYPE_SET:
439 $temp = self::decode_ber($content, $start + $offset, $content_pos);
448 case self::TYPE_OBJECT_IDENTIFIER:
452 $current['content'] = self::decodeOID(substr($content, $content_pos));
464 case self::TYPE_NUMERIC_STRING:
466 case self::TYPE_PRINTABLE_STRING:
469 case self::TYPE_TELETEX_STRING:
472 case self::TYPE_VIDEOTEX_STRING:
474 case self::TYPE_VISIBLE_STRING:
476 case self::TYPE_IA5_STRING:
478 case self::TYPE_GRAPHIC_STRING:
480 case self::TYPE_GENERAL_STRING:
482 case self::TYPE_UTF8_STRING:
484 case self::TYPE_BMP_STRING:
490 case self::TYPE_UTC_TIME:
491 case self::TYPE_GENERALIZED_TIME:
495 $current['content'] = self::decodeTime(substr($content, $content_pos), $tag);
526 case $mapping['type'] == self::TYPE_ANY:
528 // !isset(self::ANY_MAP[$intype]) produces a fatal error on PHP 5.6
529 if (isset($decoded['constant']) || !array_key_exists($intype, self::ANY_MAP) || (ord(self::$encoded[$decoded['start']]) & 0x20)) {
530 return new Element(substr(self::$encoded, $decoded['start'], $decoded['length']));
532 $inmap = self::ANY_MAP[$intype];
534 return [$inmap => self::asn1map($decoded, ['type' => $intype] + $mapping, $special)];
537 case $mapping['type'] == self::TYPE_CHOICE:
542 $value = self::asn1map($decoded, $option, $special);
544 case !isset($option['constant']) && $option['type'] == self::TYPE_CHOICE:
545 $v = self::asn1map($decoded, $option, $special);
566 case $decoded['type'] < 18: // self::TYPE_NUMERIC_STRING == 18
567 case $decoded['type'] > 30: // self::TYPE_BMP_STRING == 30
579 case self::TYPE_SEQUENCE:
586 if (($map[] = self::asn1map($content, $child, $special)) === null) {
602 if ($child['type'] != self::TYPE_CHOICE) {
604 $childClass = $tempClass = self::CLASS_UNIVERSAL;
613 $childClass = self::CLASS_CONTEXT_SPECIFIC;
622 $maymatch = !isset($child['constant']) && array_search($child['type'], [$temp['type'], self::TYPE_ANY, self::TYPE_CHOICE]) !== false;
629 $candidate = self::asn1map($temp, $child, $special);
651 case self::TYPE_SET:
658 if (($map[] = self::asn1map($content, $child, $special)) === null) {
668 $tempClass = self::CLASS_UNIVERSAL;
678 if ($child['type'] != self::TYPE_CHOICE) {
679 $childClass = self::CLASS_UNIVERSAL;
685 $childClass = self::CLASS_CONTEXT_SPECIFIC;
694 $maymatch = !isset($child['constant']) && array_search($child['type'], [$temp['type'], self::TYPE_ANY, self::TYPE_CHOICE]) !== false;
700 $candidate = self::asn1map($temp, $child, $special);
727 case self::TYPE_OBJECT_IDENTIFIER:
728 return isset(self::$oids[$decoded['content']]) ? self::$oids[$decoded['content']] : $decoded['content'];
729 case self::TYPE_UTC_TIME:
730 case self::TYPE_GENERALIZED_TIME:
739 $decoded['content'] = self::decodeTime($decoded['content'], $decoded['type']);
741 return $decoded['content'] ? $decoded['content']->format(self::$format) : false;
742 case self::TYPE_BIT_STRING:
772 case self::TYPE_OCTET_STRING:
774 case self::TYPE_NULL:
776 case self::TYPE_BOOLEAN:
777 case self::TYPE_NUMERIC_STRING:
778 case self::TYPE_PRINTABLE_STRING:
779 case self::TYPE_TELETEX_STRING:
780 case self::TYPE_VIDEOTEX_STRING:
781 case self::TYPE_IA5_STRING:
782 case self::TYPE_GRAPHIC_STRING:
783 case self::TYPE_VISIBLE_STRING:
784 case self::TYPE_GENERAL_STRING:
785 case self::TYPE_UNIVERSAL_STRING:
786 case self::TYPE_UTF8_STRING:
787 case self::TYPE_BMP_STRING:
789 case self::TYPE_INTEGER:
790 case self::TYPE_ENUMERATED:
840 self::$location = [];
841 return self::encode_der($source, $mapping, null, $special);
868 self::$location[] = $idx;
874 case self::TYPE_SET: // Children order is not important, thus process in sequence.
875 case self::TYPE_SEQUENCE:
884 $temp = self::encode_der($content, $child, null, $special);
895 if ($mapping['type'] == self::TYPE_SET) {
911 $temp = self::encode_der($source[$key], $child, $key, $special);
933 if (isset($child['explicit']) || $child['type'] == self::TYPE_CHOICE) {
934 $subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | 0x20 | $child['constant']);
935 $temp = $subtag . self::encodeLength(strlen($temp)) . $temp;
937 $subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | (ord($temp[0]) & 0x20) | $child['constant']);
944 case self::TYPE_CHOICE:
952 $temp = self::encode_der($source[$key], $child, $key, $special);
967 if (isset($child['explicit']) || $child['type'] == self::TYPE_CHOICE) {
968 $subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | 0x20 | $child['constant']);
969 $temp = $subtag . self::encodeLength(strlen($temp)) . $temp;
971 $subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | (ord($temp[0]) & 0x20) | $child['constant']);
978 array_pop(self::$location);
986 case self::TYPE_INTEGER:
987 case self::TYPE_ENUMERATED:
1005 case self::TYPE_UTC_TIME:
1006 case self::TYPE_GENERALIZED_TIME:
1007 $format = $mapping['type'] == self::TYPE_UTC_TIME ? 'y' : 'Y';
1015 case self::TYPE_BIT_STRING:
1048 case self::TYPE_OCTET_STRING:
1055 case self::TYPE_OBJECT_IDENTIFIER:
1056 $value = self::encodeOID($source);
1058 case self::TYPE_ANY:
1059 $loc = self::$location;
1061 array_pop(self::$location);
1066 return self::encode_der(null, ['type' => self::TYPE_NULL] + $mapping, null, $special);
1069 return self::encode_der($source, ['type' => self::TYPE_INTEGER] + $mapping, null, $special);
1071 return self::encode_der($source, ['type' => self::TYPE_REAL] + $mapping, null, $special);
1073 return self::encode_der($source, ['type' => self::TYPE_BOOLEAN] + $mapping, null, $special);
1076 $outtype = array_search($typename, self::ANY_MAP, true);
1078 return self::encode_der($source[$typename], ['type' => $outtype] + $mapping, null, $special);
1082 $filters = self::$filters;
1093 return self::encode_der($source, $filters + $mapping, null, $special);
1094 case self::TYPE_NULL:
1097 case self::TYPE_NUMERIC_STRING:
1098 case self::TYPE_TELETEX_STRING:
1099 case self::TYPE_PRINTABLE_STRING:
1100 case self::TYPE_UNIVERSAL_STRING:
1101 case self::TYPE_UTF8_STRING:
1102 case self::TYPE_BMP_STRING:
1103 case self::TYPE_IA5_STRING:
1104 case self::TYPE_VISIBLE_STRING:
1105 case self::TYPE_VIDEOTEX_STRING:
1106 case self::TYPE_GRAPHIC_STRING:
1107 case self::TYPE_GENERAL_STRING:
1110 case self::TYPE_BOOLEAN:
1114 throw new \RuntimeException('Mapping provides no type definition for ' . implode('/', self::$location));
1118 array_pop(self::$location);
1122 if (isset($mapping['explicit']) || $mapping['type'] == self::TYPE_CHOICE) {
1123 $value = chr($tag) . self::encodeLength(strlen($value)) . $value;
1130 return chr($tag) . self::encodeLength(strlen($value)) . $value;
1208 $oid = isset(self::$reverseOIDs[$source]) ? self::$reverseOIDs[$source] : false;
1268 if ($tag == self::TYPE_UTC_TIME) {
1303 self::$format = $format;
1316 self::$reverseOIDs += $oids;
1317 self::$oids = array_flip(self::$reverseOIDs);
1330 self::$filters = $filters;
1344 public static function convert($in, $from = self::TYPE_UTF8_STRING, $to = self::TYPE_UTF8_STRING)
1346 // isset(self::STRING_TYPE_SIZE[$from] returns a fatal error on PHP 5.6
1347 if (!array_key_exists($from, self::STRING_TYPE_SIZE) || !array_key_exists($to, self::STRING_TYPE_SIZE)) {
1350 $insize = self::STRING_TYPE_SIZE[$from];
1351 $outsize = self::STRING_TYPE_SIZE[$to];
1511 return isset(self::$reverseOIDs[$name]) ? self::$reverseOIDs[$name] : $name;