* SignatureInfo ::= SEQUENCE { * signatureAlgorithm AlgorithmIdentifier, * signatureValue OCTET STRING * pkiReferences [0] IMPLICIT SET OF OCTET STRING OPTIONAL * } * * * @package asn1 * @subpackage gt */ class GTSignatureInfo implements ASN1DEREncodable { private $signatureAlgorithm; private $signatureValue; private $pkiReferences; /** * Construct a new instance of GTSignatureInfo. */ public function __construct() { } /** * Decodes the given ASN1Sequence as GTSignatureInfo. * * @throws GTException * @param ASN1Sequence $object GTSignatureInfo encoded as ASN1Sequence * @return void */ public function decode($object) { if (!$object instanceof ASN1Sequence) { throw new GTException("Expecting an ASN1Sequence"); } if ($object->getObjectCount() < 2 || $object->getObjectCount() > 3) { throw new GTException("Invalid sequence size: " . $object->getObjectCount()); } $algorithm = new X509AlgorithmIdentifier(); $algorithm->decode($object->getObjectAt(0)); $signatureValue = $object->getObjectAt(1); if (!$signatureValue instanceof ASN1OctetString) { throw new GTException("Expecting an ASN1OctetString"); } $this->signatureAlgorithm = $algorithm; $this->signatureValue = $signatureValue->getValue(); if ($object->getObjectCount() == 3) { throw new GTException("pkiRefernces not implemented"); } } /** * Encodes this GTSignatureInfo using DER. * * @return array byte array containing the DER encoding of this GTSignatureInfo */ public function encodeDER() { $sequence = new ASN1Sequence(); $sequence->add($this->signatureAlgorithm); $sequence->add(new ASN1OctetString($this->signatureValue)); return $sequence->encodeDER(); } /** * Gets the signature algorithm. * * @return X509AlgorithmIdentifier signature algorithm */ public function getSignatureAlgorithm() { return $this->signatureAlgorithm; } /** * Gets the signature value. * * @return array byte array containing the signature value bytes */ public function getSignatureValue() { return $this->signatureValue; } } ?>