TimeStampResp
Represents the TimeStampResp structure described in RFC3161
Example
Section titled “Example”The following example demonstrates how to create and sign Time-Stamp Response
// Generate random serial numberconst serialNumber = pkijs.getRandomValues(new Uint8Array(10)).buffer;
// Create specific TST info structure to signconst tstInfo = new pkijs.TSTInfo({ version: 1, policy: tspReq.reqPolicy, messageImprint: tspReq.messageImprint, serialNumber: new asn1js.Integer({ valueHex: serialNumber }), genTime: new Date(), ordering: true, accuracy: new pkijs.Accuracy({ seconds: 1, millis: 1, micros: 10 }), nonce: tspReq.nonce,});
// Create and sign CMS Signed Data with TSTInfoconst cmsSigned = new pkijs.SignedData({ version: 3, encapContentInfo: new pkijs.EncapsulatedContentInfo({ eContentType: "1.2.840.113549.1.9.16.1.4", // "tSTInfo" content type eContent: new asn1js.OctetString({ valueHex: tstInfo.toSchema().toBER() }), }), signerInfos: [ new pkijs.SignerInfo({ version: 1, sid: new pkijs.IssuerAndSerialNumber({ issuer: cert.issuer, serialNumber: cert.serialNumber }) }) ], certificates: [cert]});
await cmsSigned.sign(keys.privateKey, 0, "SHA-256");
// Create CMS Content Infoconst cmsContent = new pkijs.ContentInfo({ contentType: pkijs.ContentInfo.SIGNED_DATA, content: cmsSigned.toSchema(true)});
// Finally create completed TSP response structureconst tspResp = new pkijs.TimeStampResp({ status: new pkijs.PKIStatusInfo({ status: pkijs.PKIStatus.granted }), timeStampToken: new pkijs.ContentInfo({ schema: cmsContent.toSchema() })});
const tspRespRaw = tspResp.toSchema().toBER();Extends
Section titled “Extends”Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new TimeStampResp(
parameters?):TimeStampResp
Initializes a new instance of the TimeStampResp class
Parameters
Section titled “Parameters”parameters?
Section titled “parameters?”Initialization parameters
Returns
Section titled “Returns”TimeStampResp
Overrides
Section titled “Overrides”Properties
Section titled “Properties”status
Section titled “status”status:
PKIStatusInfo
Time-Stamp status
Implementation of
Section titled “Implementation of”timeStampToken?
Section titled “timeStampToken?”
optionaltimeStampToken?:ContentInfo
Time-Stamp token
Implementation of
Section titled “Implementation of”CLASS_NAME
Section titled “CLASS_NAME”
staticCLASS_NAME:string="TimeStampResp"
Name of the class
Overrides
Section titled “Overrides”Accessors
Section titled “Accessors”className
Section titled “className”Get Signature
Section titled “Get Signature”get className():
string
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”fromSchema()
Section titled “fromSchema()”fromSchema(
schema):void
Converts parsed ASN.1 object into current class
Parameters
Section titled “Parameters”schema
Section titled “schema”any
ASN.1 schema
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”sign()
Section titled “sign()”sign(
privateKey,hashAlgorithm?,crypto?):Promise<void>
Sign current TSP Response
Parameters
Section titled “Parameters”privateKey
Section titled “privateKey”CryptoKey
Private key for “subjectPublicKeyInfo” structure
hashAlgorithm?
Section titled “hashAlgorithm?”string
Hashing algorithm. Default SHA-1
crypto?
Section titled “crypto?”ICryptoEngine = ...
Crypto engine
Returns
Section titled “Returns”Promise<void>
toJSON()
Section titled “toJSON()”toJSON():
TimeStampRespJson
Converts the class to JSON object
Returns
Section titled “Returns”JSON object
Overrides
Section titled “Overrides”toSchema()
Section titled “toSchema()”toSchema():
Sequence
Converts current object to ASN.1 object and sets correct values
Returns
Section titled “Returns”Sequence
ASN.1 object
Overrides
Section titled “Overrides”toString()
Section titled “toString()”toString(
encoding?):string
Parameters
Section titled “Parameters”encoding?
Section titled “encoding?”"hex" | "base64" | "base64url" = "hex"
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”verify()
Section titled “verify()”verify(
verificationParameters?,crypto?):Promise<boolean>
Verify current TSP Response
Parameters
Section titled “Parameters”verificationParameters?
Section titled “verificationParameters?”TimeStampRespVerifyParams = ...
Input parameters for verification
crypto?
Section titled “crypto?”ICryptoEngine = ...
Crypto engine
Returns
Section titled “Returns”Promise<boolean>
blockName()
Section titled “blockName()”
staticblockName():string
Returns block name
Returns
Section titled “Returns”string
Returns string block name
Inherited from
Section titled “Inherited from”compareWithDefault()
Section titled “compareWithDefault()”
staticcompareWithDefault(memberName,memberValue):boolean
Compare values with default values for all class members
Parameters
Section titled “Parameters”memberName
Section titled “memberName”string
String name for a class member
memberValue
Section titled “memberValue”any
Value to compare with default value
Returns
Section titled “Returns”boolean
defaultValues()
Section titled “defaultValues()”Call Signature
Section titled “Call Signature”
staticdefaultValues(memberName):PKIStatusInfo
Returns default values for all class members
Parameters
Section titled “Parameters”memberName
Section titled “memberName”"status"
String name for a class member
Returns
Section titled “Returns”Default value
Overrides
Section titled “Overrides”Call Signature
Section titled “Call Signature”
staticdefaultValues(memberName):ContentInfo
Returns default values for all class members
Parameters
Section titled “Parameters”memberName
Section titled “memberName”"timeStampToken"
String name for a class member
Returns
Section titled “Returns”Default value
Overrides
Section titled “Overrides”PkiObject.defaultValues
fromBER()
Section titled “fromBER()”
staticfromBER<T>(this,raw):T
Creates PKI object from the raw data
Type Parameters
Section titled “Type Parameters”T extends PkiObject
Parameters
Section titled “Parameters”PkiObjectConstructor<T>
BufferSource
ASN.1 encoded raw data
Returns
Section titled “Returns”T
Initialized and filled current class object
Inherited from
Section titled “Inherited from”schema()
Section titled “schema()”
staticschema(parameters?):any
Returns value of pre-defined ASN.1 schema for current class
Parameters
Section titled “Parameters”parameters?
Section titled “parameters?”SchemaParameters<{ status?: PKIStatusInfoSchema; timeStampToken?: ContentInfoSchema; }> = {}
Input parameters for the schema
Returns
Section titled “Returns”any
ASN.1 schema object