Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TimeStampResp

Represents the TimeStampResp structure described in RFC3161

example

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();

Hierarchy

Implements

Index

Constructors

Properties

Time-Stamp status

timeStampToken?: ContentInfo

Time-Stamp token

CLASS_NAME: string = "TimeStampResp"

Name of the class

Accessors

  • get className(): string

Methods

  • fromSchema(schema: any): void
  • sign(privateKey: CryptoKey, hashAlgorithm?: string, crypto?: ICryptoEngine): Promise<void>
  • Sign current TSP Response

    Parameters

    • privateKey: CryptoKey

      Private key for "subjectPublicKeyInfo" structure

    • Optional hashAlgorithm: string

      Hashing algorithm. Default SHA-1

    • crypto: ICryptoEngine = ...

      Crypto engine

    Returns Promise<void>

  • toSchema(): Sequence
  • toString(encoding?: "base64" | "base64url" | "hex"): string
  • blockName(): string
  • compareWithDefault(memberName: string, memberValue: any): boolean
  • Compare values with default values for all class members

    Parameters

    • memberName: string

      String name for a class member

    • memberValue: any

      Value to compare with default value

    Returns boolean

  • fromBER<T>(this: PkiObjectConstructor<T>, raw: BufferSource): T
  • Creates PKI object from the raw data

    Type Parameters

    Parameters

    • this: PkiObjectConstructor<T>
    • raw: BufferSource

      ASN.1 encoded raw data

    Returns T

    Initialized and filled current class object

Generated using TypeDoc