[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * This file is part of the PHPASN1 library. 4 * 5 * Copyright © Friedrich Große <[email protected]> 6 * 7 * For the full copyright and license information, please view the LICENSE 8 * file that was distributed with this source code. 9 */ 10 11 namespace FG\X509\CSR; 12 13 use FG\ASN1\ASNObject; 14 use FG\X509\CertificateExtensions; 15 use FG\ASN1\OID; 16 use FG\ASN1\Parsable; 17 use FG\ASN1\Construct; 18 use FG\ASN1\Identifier; 19 use FG\ASN1\Universal\Set; 20 use FG\ASN1\Universal\Sequence; 21 use FG\ASN1\Universal\ObjectIdentifier; 22 23 class Attributes extends Construct implements Parsable 24 { 25 public function getType() 26 { 27 return 0xA0; 28 } 29 30 public function addAttribute($objectIdentifier, Set $attribute) 31 { 32 if (is_string($objectIdentifier)) { 33 $objectIdentifier = new ObjectIdentifier($objectIdentifier); 34 } 35 $attributeSequence = new Sequence($objectIdentifier, $attribute); 36 $attributeSequence->getNumberOfLengthOctets(); // length and number of length octets is calculated 37 $this->addChild($attributeSequence); 38 } 39 40 public static function fromBinary(&$binaryData, &$offsetIndex = 0) 41 { 42 self::parseIdentifier($binaryData[$offsetIndex], 0xA0, $offsetIndex++); 43 $contentLength = self::parseContentLength($binaryData, $offsetIndex); 44 $octetsToRead = $contentLength; 45 46 $parsedObject = new self(); 47 while ($octetsToRead > 0) { 48 $initialOffset = $offsetIndex; // used to calculate how much bits have been read 49 self::parseIdentifier($binaryData[$offsetIndex], Identifier::SEQUENCE, $offsetIndex++); 50 self::parseContentLength($binaryData, $offsetIndex); 51 52 $objectIdentifier = ObjectIdentifier::fromBinary($binaryData, $offsetIndex); 53 $oidString = $objectIdentifier->getContent(); 54 if ($oidString == OID::PKCS9_EXTENSION_REQUEST) { 55 $attribute = CertificateExtensions::fromBinary($binaryData, $offsetIndex); 56 } else { 57 $attribute = ASNObject::fromBinary($binaryData, $offsetIndex); 58 } 59 60 $parsedObject->addAttribute($objectIdentifier, $attribute); 61 $octetsToRead -= ($offsetIndex - $initialOffset); 62 } 63 64 $parsedObject->setContentLength($contentLength); 65 66 return $parsedObject; 67 } 68 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |