* PublishedData ::= SEQUENCE { * publicationIdentifier INTEGER, * publicationImprint DataImprint * } * * *
 * DataImprint ::= OCTET STRING
 * 
* * @package asn1 * @subpackage gt */ class GTPublishedData implements ASN1DEREncodable { private $publicationIdentifier; private $publicationImprint; /** * Constructs a new instance of GTPublishedData. */ public function __construct() { } /** * Decodes the given ASN1Sequence as GTPublishedData. * * @throws GTException * @param ASN1Sequence $object GTPublishedData encoded as ASN1Sequence * @return void */ public function decode($object) { if (!$object instanceof ASN1Sequence) { throw new GTException("Expecting an ASN1Sequence"); } $size = $object->getObjectCount(); if ($size != 2) { throw new GTException("Invalid sequence size: {$size}"); } $publicationIdentifier = $object->getObjectAt(0); if (!$publicationIdentifier instanceof ASN1Integer) { throw new GTException("Expecting an ASN1Integer for GTPublishedData.publicationIdentifier"); } $publicationImprint = $object->getObjectAt(1); if (!$publicationImprint instanceof ASN1OctetString) { throw new GTException("Expecting an ASN1Integer for GTPublishedData.publicationImprint"); } $this->publicationIdentifier = $publicationIdentifier->getValue(); $this->publicationImprint = $publicationImprint->getValue(); GTDataHash::getInstance($this->publicationImprint); } /** * Encodes this GTPublishedData using DER. * * @return array byte array containing the DER encoding of this GTPublishedData */ public function encodeDER() { $sequence = new ASN1Sequence(); $sequence->add(new ASN1Integer(new GTBigInteger($this->publicationIdentifier))); $sequence->add(new ASN1OctetString($this->publicationImprint)); return $sequence->encodeDER(); } /** * Gets the encoded publication. * * @return string encoded publication. */ public function getEncodedPublication() { $int = new GTBigInteger($this->publicationIdentifier); $bytes = $int->toBytes(); // pad to 64 bit while (count($bytes) % 8 != 0) { array_unshift($bytes, 0); } foreach ($this->publicationImprint as $byte) { array_push($bytes, $byte); } $bytes = GTUtil::addCrc32($bytes); return GTBase32::encodeWithDashes($bytes); } /** * Gets the publication identifier. * * @return string publication identifier */ public function getPublicationIdentifier() { return $this->publicationIdentifier; } /** * Gets the publication imprint. * * @return array byte array containing the publication imprint bytes */ public function getPublicationImprint() { return $this->publicationImprint; } } ?>