Lines Matching refs:length

232         $length = strlen($bytes);
233 $bytes = ($length < 128) ? chr($length) . $bytes : $this->encodeLongDefiniteLength($length) . $bytes;
321 * @param null|int $length
328 protected function decodeBytes(bool $isRoot = false, $tagType = null, $length = null, $isConstructed = null, $class = null): AbstractType
342 # It's possible we only got part of the VLQ for the high tag, as there is no way to know its ending length.
353 $length = ord($this->binary[$this->pos++]);
354 if ($length === 128) {
355 throw new EncoderException('Indefinite length encoding is not currently supported.');
357 if ($length > 128) {
358 $length = $this->decodeLongDefiniteLength($length);
362 if (($this->maxLen - $this->pos) < $length) {
364 'The expected byte length was %s, but received %s.',
365 $length,
376 $type = new IncompleteType(substr($this->binary, $this->pos, $length), $tagNumber, $class, $isConstructed);
377 $this->pos += $length;
387 if ($length !== 1 || $isConstructed) {
393 if ($length !== 0 || $isConstructed) {
402 $type = EncodedType\IntegerType::withTag($tagNumber, $class, $this->decodeInteger($length));
408 $type = EncodedType\EnumeratedType::withTag($tagNumber, $class, $this->decodeInteger($length));
414 $type = RealType::withTag($tagNumber, $class, $this->decodeReal($length));
417 $type = EncodedType\BitStringType::withTag($tagNumber, $class, $isConstructed, $this->decodeBitString($length));
423 $type = OidType::withTag($tagNumber, $class, $this->decodeOid($length));
429 $type = RelativeOidType::withTag($tagNumber, $class, $this->decodeRelativeOid($length));
432 $type = EncodedType\GeneralizedTimeType::withTag($tagNumber, $class, $isConstructed, ...$this->decodeGeneralizedTime($length));
435 $type = EncodedType\UtcTimeType::withTag($tagNumber, $class, $isConstructed, ...$this->decodeUtcTime($length));
438 $type = EncodedType\OctetStringType::withTag($tagNumber, $class, $isConstructed, substr($this->binary, $this->pos, $length));
439 $this->pos += $length;
442 $type = EncodedType\GeneralStringType::withTag($tagNumber, $class, $isConstructed, substr($this->binary, $this->pos, $length));
443 $this->pos += $length;
446 $type = EncodedType\VisibleStringType::withTag($tagNumber, $class, $isConstructed, substr($this->binary, $this->pos, $length));
447 $this->pos += $length;
450 $type = EncodedType\BmpStringType::withTag($tagNumber, $class, $isConstructed, substr($this->binary, $this->pos, $length));
451 $this->pos += $length;
454 $type = EncodedType\CharacterStringType::withTag($tagNumber, $class, $isConstructed, substr($this->binary, $this->pos, $length));
455 $this->pos += $length;
458 $type = EncodedType\UniversalStringType::withTag($tagNumber, $class, $isConstructed, substr($this->binary, $this->pos, $length));
459 $this->pos += $length;
462 $type = EncodedType\GraphicStringType::withTag($tagNumber, $class, $isConstructed, substr($this->binary, $this->pos, $length));
463 $this->pos += $length;
466 $type = EncodedType\VideotexStringType::withTag($tagNumber, $class, $isConstructed, substr($this->binary, $this->pos, $length));
467 $this->pos += $length;
470 $type = EncodedType\TeletexStringType::withTag($tagNumber, $class, $isConstructed, substr($this->binary, $this->pos, $length));
471 $this->pos += $length;
474 $type = EncodedType\PrintableStringType::withTag($tagNumber, $class, $isConstructed, substr($this->binary, $this->pos, $length));
475 $this->pos += $length;
478 $type = EncodedType\NumericStringType::withTag($tagNumber, $class, $isConstructed, substr($this->binary, $this->pos, $length));
479 $this->pos += $length;
482 $type = EncodedType\IA5StringType::withTag($tagNumber, $class, $isConstructed, substr($this->binary, $this->pos, $length));
483 $this->pos += $length;
486 $type = EncodedType\Utf8StringType::withTag($tagNumber, $class, $isConstructed, substr($this->binary, $this->pos, $length));
487 $this->pos += $length;
493 $type = EncodedType\SequenceType::withTag($tagNumber, $class, $this->decodeConstructedType($length));
499 $type = EncodedType\SetType::withTag($tagNumber, $class, $this->decodeConstructedType($length));
509 * @param int $length
514 protected function decodeLongDefiniteLength(int $length): int
516 # The length of the length bytes is in the first 7 bits. So remove the MSB to get the value.
517 $lengthOfLength = $length & ~0x80;
521 throw new EncoderException('The decoded length cannot be equal to 127 bytes.');
524 throw new PartialPduException('Not enough data to decode the length.');
529 $length = 0;
531 $length = $length * 256 + ord($this->binary[$this->pos]);
534 return $length;
538 * Given what should be VLQ bytes represent an int, get the int and the length of bytes.
581 * Get the bytes that represent variable length quantity.
650 $length = strlen($bytes);
651 if ($length >= 127) {
652 throw new EncoderException('The encoded length cannot be greater than or equal to 127 bytes');
655 return chr(0x80 | $length) . $bytes;
665 $length = strlen($data);
667 if ($length % 8) {
668 $unused = 8 - ($length % 8);
669 $data = str_pad($data, $length + $unused, $this->options['bitstring_padding']);
670 $length = strlen($data);
674 for ($i = 0; $i < $length / 8; $i++) {
707 $length = count($oids);
708 if ($length < 2) {
730 for ($i = 2; $i < $length; $i++) {
892 * @param int $length
896 protected function decodeGeneralizedTime($length): array
898 return $this->decodeTime('YmdH', GeneralizedTimeType::TIME_REGEX, GeneralizedTimeType::REGEX_MAP, $length);
902 * @param int $length
906 protected function decodeUtcTime($length): array
908 return $this->decodeTime('ymdH', UtcTimeType::TIME_REGEX, UtcTimeType::REGEX_MAP, $length);
915 * @param int $length
919 protected function decodeTime(string $format, string $regex, array $matchMap, $length): array
921 $bytes = substr($this->binary, $this->pos, $length);
922 $this->pos += $length;
974 * @param int $length
978 protected function decodeOid($length): string
980 if ($length === 0) {
981 throw new EncoderException('Zero length not permitted for an OID type.');
998 $oidLength = $length - ($this->pos - $startedAt);
1005 * @param int $length
1009 protected function decodeRelativeOid($length): string
1011 if ($length === 0) {
1012 throw new EncoderException('Zero length not permitted for an OID type.');
1015 $endAt = $this->pos + $length;
1033 * @param int $length
1037 protected function decodeBitString($length): string
1048 if ($unused > 0 && $length < 1) {
1052 $length
1055 $length--;
1057 return $this->binaryToBitString($length, $unused);
1061 * @param int $length
1065 protected function binaryToBitString(int $length, int $unused): string
1068 $endAt = $this->pos + $length;
1083 * @param int $length
1087 protected function decodeInteger($length)
1089 if ($length === 0) {
1090 throw new EncoderException('Zero length not permitted for an integer type.');
1092 $bytes = substr($this->binary, $this->pos, $length);
1093 $this->pos += $length;
1098 for ($i = 0; $i < $length; $i++) {
1134 * @param int $length
1138 protected function decodeReal($length): float
1140 if ($length === 0) {
1197 * @param int $length
1202 protected function decodeConstructedType($length)
1205 $endAt = $this->pos + $length;