* SignerIdentifier ::= CHOICE { * issuerAndSerialNumber IssuerAndSerialNumber, * subjectKeyIdentifier [0] SubjectKeyIdentifier * } * * *
 * SubjectKeyIdentifier ::= OCTET STRING
 * 
* * @package asn1 * @subpackage cms * * @link http://tools.ietf.org/html/rfc3852#section-5.3 RFC 3852: Cryptographic Message Syntax */ class CMSSignerIdentifier implements ASN1DEREncodable { private $issuerAndSerialNumber; private $subjectKeyIdentifier; /** * Constructs a new instance of CMSSignerIdentifier. */ public function __construct() { } /** * Decodes the given ASN1Sequence as CMSSignerIdentifier. * * @throws GTException * @param ASN1Sequence $object CMSSignerIdentifier encoded as ASN1Sequence * @return void */ public function decode($object) { if ($object instanceof ASN1Sequence) { $issuerAndSerialNumber = new CMSIssuerAndSerialNumber(); $issuerAndSerialNumber->decode($object); $this->issuerAndSerialNumber = $issuerAndSerialNumber; } else if ($object instanceof ASN1Tag) { if ($object->getTagValue() != 0) { throw new GTException("Unexpected TAG value: " . $object->getTagValue()); } $subjectKeyIdentifier = $object->getObjectAs(ASN1_TAG_OCTET_STRING); $this->subjectKeyIdentifier = $subjectKeyIdentifier->getValue(); } else { throw new GTException("Unexpected ASN1 type: " . get_class($object)); } } /** * Encodes the given CMSSignerIdentifier using DER. * * @throws GTException * @return array byte array that contains the DER encoding of this CMSSignerIdentifier */ public function encodeDER() { if (!is_null($this->issuerAndSerialNumber)) { return $this->issuerAndSerialNumber->encodeDER(); } else if (!is_null($this->subjectKeyIdentifier)) { $tag = new ASN1Tag(); $tag->setExplicit(false); $tag->setTagValue(0); $tag->setTagClass(ASN1_TAG_CONTEXT); $tag->setTagType(ASN1_TAG_CONSTRUCTED); $tag->setObject(new ASN1OctetString($this->subjectKeyIdentifier)); return $tag->encodeDER(); } else { throw new GTException("Unable to encode CMSSignerIdentifier, both issuerAndSerialNumber and subjectKeyIdentifier are null"); } } /** * Gets the issuer and serial number. * * @return CMSIssuerAndSerialNumber issuer and serial number */ public function getIssuerAndSerialNumber() { return $this->issuerAndSerialNumber; } /** * Sets the issuer and serial number. * * @param CMSIssuerAndSerialNumber $issuerAndSerialNumber issuer and serial number * @return void */ public function setIssuerAndSerialNumber($issuerAndSerialNumber) { $this->issuerAndSerialNumber = $issuerAndSerialNumber; } /** * Gets the subject key identifier. * * @return array byte array containing the subject key identifier */ public function getSubjectKeyIdentifier() { return $this->subjectKeyIdentifier; } /** * Sets the subject key identifier. * * @param array $subjectKeyIdentifier byte array containing the subject key identifier * @return void */ public function setSubjectKeyIdentifier($subjectKeyIdentifier) { $this->subjectKeyIdentifier = $subjectKeyIdentifier; } } ?>