Skip to content
PKIjsPKIjsPKIjsv4.0.1

TimeStampResp

Represents the TimeStampResp structure described in RFC3161

The following example demonstrates how to create and sign Time-Stamp Response

// Generate random serial number
const serialNumber = pkijs.getRandomValues(new Uint8Array(10)).buffer;
// Create specific TST info structure to sign
const 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 TSTInfo
const 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 Info
const cmsContent = new pkijs.ContentInfo({
contentType: pkijs.ContentInfo.SIGNED_DATA,
content: cmsSigned.toSchema(true)
});
// Finally create completed TSP response structure
const tspResp = new pkijs.TimeStampResp({
status: new pkijs.PKIStatusInfo({ status: pkijs.PKIStatus.granted }),
timeStampToken: new pkijs.ContentInfo({ schema: cmsContent.toSchema() })
});
const tspRespRaw = tspResp.toSchema().toBER();

new TimeStampResp(parameters?): TimeStampResp

Initializes a new instance of the TimeStampResp class

TimeStampRespParameters = {}

Initialization parameters

TimeStampResp

PkiObject.constructor

status: PKIStatusInfo

Time-Stamp status

ITimeStampResp.status


optional timeStampToken?: ContentInfo

Time-Stamp token

ITimeStampResp.timeStampToken


static CLASS_NAME: string = "TimeStampResp"

Name of the class

PkiObject.CLASS_NAME

get className(): string

string

PkiObject.className

fromSchema(schema): void

Converts parsed ASN.1 object into current class

any

ASN.1 schema

void

PkiObject.fromSchema


sign(privateKey, hashAlgorithm?, crypto?): Promise<void>

Sign current TSP Response

CryptoKey

Private key for “subjectPublicKeyInfo” structure

string

Hashing algorithm. Default SHA-1

ICryptoEngine = ...

Crypto engine

Promise<void>


toJSON(): TimeStampRespJson

Converts the class to JSON object

TimeStampRespJson

JSON object

PkiObject.toJSON


toSchema(): Sequence

Converts current object to ASN.1 object and sets correct values

Sequence

ASN.1 object

PkiObject.toSchema


toString(encoding?): string

"hex" | "base64" | "base64url" = "hex"

string

PkiObject.toString


verify(verificationParameters?, crypto?): Promise<boolean>

Verify current TSP Response

TimeStampRespVerifyParams = ...

Input parameters for verification

ICryptoEngine = ...

Crypto engine

Promise<boolean>


static blockName(): string

Returns block name

string

Returns string block name

PkiObject.blockName


static compareWithDefault(memberName, memberValue): boolean

Compare values with default values for all class members

string

String name for a class member

any

Value to compare with default value

boolean


static defaultValues(memberName): PKIStatusInfo

Returns default values for all class members

"status"

String name for a class member

PKIStatusInfo

Default value

PkiObject.defaultValues

static defaultValues(memberName): ContentInfo

Returns default values for all class members

"timeStampToken"

String name for a class member

ContentInfo

Default value

PkiObject.defaultValues


static fromBER<T>(this, raw): T

Creates PKI object from the raw data

T extends PkiObject

PkiObjectConstructor<T>

BufferSource

ASN.1 encoded raw data

T

Initialized and filled current class object

PkiObject.fromBER


static schema(parameters?): any

Returns value of pre-defined ASN.1 schema for current class

SchemaParameters<{ status?: PKIStatusInfoSchema; timeStampToken?: ContentInfoSchema; }> = {}

Input parameters for the schema

any

ASN.1 schema object

PkiObject.schema