setValue($value); } } /** * Encodes the contents of this ASN1String. * * @return array DER encoding for this string */ public function encodeDER() { $bytes = GTUtil::toByteArray($this->value); $this->prepend($bytes, ASN1DER::encodeLength(count($bytes))); $this->prepend($bytes, ASN1DER::encodeType($this->getType())); return $bytes; } /** * Decodes an ASN1String from the given byte stream. * * @param $bytes V bytes of this ASN1String TLV * @return void */ public function decodeDER($bytes) { $this->setValue(GTUtil::fromByteArray($bytes)); } /** * Sets the value of this ASN1String. * * @param string $value * @return void */ protected function setValue($value) { $this->value = $value; } /** * Gets the value of this ASN1String. * * @return string */ public function getValue() { return $this->value; } /** * Gets the actual ASN.1 type to use for encoding/decoding this ASN1String. * @abstract * @return int */ protected abstract function getType(); } ?>