objects, $object); } /** * Gets the object at index. * * @param $index 0 based index * @return ASN1Object object at index */ public function getObjectAt($index) { return $this->objects[$index]; } /** * Gets the number of objects stored inside this set. * * @return int the number of objects */ public function getObjectCount() { return count($this->objects); } /** * Gets all objects stored inside this set. * * @return array objects stored inside this set. */ public function getObjects() { return $this->objects; } /** * Encodes this ASN1Set and the objects contained within to DER. * * @return array DER encoding of this ASN1Set */ public function encodeDER() { $bytes = array(); foreach ($this->objects as $object) { $this->append($bytes, $object->encodeDER()); } $this->prepend($bytes, ASN1DER::encodeLength(count($bytes))); $this->prepend($bytes, ASN1DER::encodeType(ASN1_TAG_SET)); return $bytes; } /** * Decodes an ASN1Set from the given byte stream. * * @param $bytes V bytes from the encoding of ASN1Set TLV * @return void */ public function decodeDER($bytes) { while (count($bytes) > 0) { $object = ASN1DER::decodeType($bytes); $length = ASN1DER::decodeLength($bytes); $object->decodeDER($this->readBytes($bytes, $length)); array_push($this->objects, $object); } } } ?>