1<?php 2/* 3 * Copyright 2008-2010 GuardTime AS 4 * 5 * This file is part of the GuardTime PHP SDK. 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20/** 21 * @package asn1 22 * @subpackage tsp 23 */ 24 25/** 26 * TSP TimeStampReq implementation. 27 * 28 * <pre> 29 * TimeStampReq ::= SEQUENCE { 30 * version INTEGER { v1(1) }, 31 * messageImprint MessageImprint, 32 * reqPolicy TSAPolicyId OPTIONAL, 33 * nonce INTEGER OPTIONAL, 34 * certReq BOOLEAN DEFAULT FALSE, 35 * extensions [0] IMPLICIT Extensions OPTIONAL 36 * } 37 * </pre> 38 * 39 * @see TSPMessageImprint 40 * 41 * @package asn1 42 * @subpackage tsp 43 * 44 * @link http://tools.ietf.org/html/rfc3161#section-2.4.1 RFC 3161: Time-Stamp Protocol 45 */ 46class TSPTimeStampReq implements ASN1DEREncodable { 47 48 const VERSION = 1; 49 50 private $version; 51 private $messageImprint; 52 53 /** 54 * Constructs a new instance of TSPTimeStampReq. 55 */ 56 public function __construct() { 57 $this->version = self::VERSION; 58 } 59 60 /** 61 * Encodes this TSPTimestampReq using DER. 62 * 63 * @return array byte array that contains the DER encoding of this TSPTimestampReq 64 */ 65 public function encodeDER() { 66 67 $sequence = new ASN1Sequence(); 68 69 $sequence->add(new ASN1Integer($this->version)); 70 $sequence->add($this->messageImprint); 71 72 return $sequence->encodeDER(); 73 } 74 75 /** 76 * Gets the version. 77 * 78 * @return int version 79 */ 80 public function getVersion() { 81 return $this->version; 82 } 83 84 /** 85 * Sets the message imprint. 86 * 87 * @throws GTException 88 * @param TSPMessageImprint $messageImprint the message imprint 89 * @return void 90 */ 91 public function setMessageImprint($messageImprint) { 92 93 if (!$messageImprint instanceof TSPMessageImprint) { 94 throw new GTException("messageImprint must be an instance of TSPMessageImprint"); 95 } 96 97 $this->messageImprint = $messageImprint; 98 99 } 100 101 /** 102 * Gets the message imprint. 103 * 104 * @return TSPMessageImprint the message imprint 105 */ 106 public function getMessageImprint() { 107 return $this->messageImprint; 108 } 109 110} 111 112?> 113