/** * Return digest of the subjetcname field using algorithm $alg * * @param string $alg OID of the digest algorithm ('1.3.14.3.2.26' * i. e. SHA1 by default * * @retval string hexadecimal representation of the subjectname hash */ public function getSubjectNameHash($alg = '1.3.14.3.2.26') { $ser = \ASN1\ASN1::createSerializer(\ASN1\ASN1::createWriter()); $data = $ser->serialize($this->subject); return $this->_hashData($data, $alg); }
/** @name Signature Verification (Local implementation) * * Local implementation of signature verification related methods **@{ */ public function getSignedData() { $writer = \ASN1\ASN1::createWriter(); $ser = \ASN1\ASN1::createSerializer($writer); return $ser->serialize($this->_tlv->first()); }
/** * Create a new \\PKIX\\TSP\\Request from parameters provided in * $params. The request is minimal but compliant with RFC3161 and * can be used to query a TSP server. * * @param array $params contains configuration parameters for the * message: * - hashAlgorithm - string representation of hash algorithm OID * - hashedMessage - hex representation of the hashed message * * @retval \PKIX\TSP\Request new instance */ public function createFromParams(array $params) { /* TimeStampReq ::= SEQUENCE { version INTEGER { v1(1) }, messageImprint MessageImprint, --a hash algorithm OID and the hash value of the data to be --time-stamped reqPolicy TSAPolicyId OPTIONAL, nonce INTEGER OPTIONAL, certReq BOOLEAN DEFAULT FALSE, extensions [0] IMPLICIT Extensions OPTIONAL } MessageImprint ::= SEQUENCE { hashAlgorithm AlgorithmIdentifier, hashedMessage OCTET STRING } */ $hashAlg = new \ASN1\TLV((object) array('Class' => TLV_CLASS_UNIVERSAL, 'Type' => TLV_TYPE_CONSTRUCTED, 'Tag' => TLV_TAG_SEQUENCE)); $algorithm = \ASN1\TLV\OID::create(); $algorithm->set($params['hashAlgorithm']); $parameters = \ASN1\TLV\Null::create(); $parameters->set(null); $hashAlg->add($algorithm); $hashAlg->add($parameters); $hashedMessage = \ASN1\TLV\OctetString::create(); $hashedMessage->set($params['hashedMessage']); $messageImprint = new \ASN1\TLV((object) array('Class' => TLV_CLASS_UNIVERSAL, 'Type' => TLV_TYPE_CONSTRUCTED, 'Tag' => TLV_TAG_SEQUENCE)); $messageImprint->add($hashAlg); $messageImprint->add($hashedMessage); $version = \ASN1\TLV\Integer::create(); $version->set(static::TSP_Version); $tsReq = new \ASN1\TLV((object) array('Class' => TLV_CLASS_UNIVERSAL, 'Type' => TLV_TYPE_CONSTRUCTED, 'Tag' => TLV_TAG_SEQUENCE)); $tsReq->add($version); $tsReq->add($messageImprint); $writer = \ASN1\ASN1::createWriter(); $ser = \ASN1\ASN1::createSerializer($writer); $data = $ser->serialize($tsReq); return new static($data); }