Lines Matching refs:length

172      * size == 0 indicates variable length encoding.
215 * self::TYPE_OCTET_STRING. In those cases, the indefinite length is used.
261 $length = ord($encoded[$encoded_pos++]);
263 if ($length == 0x80) { // indefinite length
266 $length = strlen($encoded) - $encoded_pos;
267 } elseif ($length & 0x80) { // definite length, long form
268 // technically, the long form of the length can be represented by up to 126 octets (bytes), but we'll only
270 $length &= 0x7F;
271 $temp = substr($encoded, $encoded_pos, $length);
272 $encoded_pos += $length;
273 // tags of indefinte length don't really have a header length; this length includes the tag
274 $current += ['headerlength' => $length + 2];
275 $start += $length;
277 /** @var integer $length */
282 if ($length > (strlen($encoded) - $encoded_pos)) {
286 $content = substr($encoded, $encoded_pos, $length);
289 // at this point $length can be overwritten. it's only accurate for definite length things as is
310 'length' => $length + $start - $current['start']
315 $remainingLength = $length;
321 $length = $temp['length'];
323 if (substr($content, $content_pos + $length, 2) == "\0\0") {
324 $length += 2;
325 $start += $length;
329 $start += $length;
330 $remainingLength -= $length;
332 $content_pos += $length;
340 // the only time when $content['headerlength'] isn't defined is when the length is indefinite.
343 'length' => $start - $current['start']
378 $length -= (strlen($content) - $content_pos);
399 $length = 0;
401 $temp = self::decode_ber($content, $length + $start, $content_pos);
405 $content_pos += $temp['length'];
411 $length += $temp['length'];
414 $length += 2; // +2 for the EOC
433 // if indefinite length construction was used and we have an end-of-content string next
436 $length = $offset + 2; // +2 for the EOC
443 $content_pos += $temp['length'];
445 $offset += $temp['length'];
501 $start += $length;
503 // ie. length is the length of the full TLV encoding - it's not just the length of the value
504 return $current + ['length' => $start - $current['start']];
530 return new Element(substr(self::$encoded, $decoded['start'], $decoded['length']));
806 * DER-decode the length
816 $length = ord(Strings::shift($string));
817 if ($length & 0x80) { // definite length, long form
818 $length &= 0x7F;
819 $temp = Strings::shift($string, $length);
820 list(, $length) = unpack('N', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4));
822 return $length;
1473 * DER-encode the length
1478 * @param int $length
1481 public static function encodeLength($length)
1483 if ($length <= 0x7F) {
1484 return chr($length);
1487 $temp = ltrim(pack('N', $length), chr(0));