import * as asn1js from "asn1js"; import * as pvutils from "pvutils"; import { ResponseBytes, ResponseBytesJson, ResponseBytesSchema } from "./ResponseBytes"; import { BasicOCSPResponse } from "./BasicOCSPResponse"; import * as Schema from "./Schema"; import { Certificate } from "./Certificate"; import { id_PKIX_OCSP_Basic } from "./ObjectIdentifiers"; import { AsnError } from "./errors"; import { PkiObject, PkiObjectParameters } from "./PkiObject"; import * as common from "./common";
public fromSchema(schema: Schema.SchemaType): void { // Clear input data first
pvutils.clearProps(schema, [
RESPONSE_STATUS,
RESPONSE_BYTES
]);
// Check the schema is valid const asn1 = asn1js.compareSchema(schema,
schema,
OCSPResponse.schema()
);
AsnError.assertSchema(asn1, this.className);
// Get internal properties from parsed schema this.responseStatus = asn1.result.responseStatus; if (RESPONSE_BYTES in asn1.result) this.responseBytes = new ResponseBytes({ schema: asn1.result.responseBytes });
}
public toSchema(): asn1js.Sequence { //#region Create array for output sequence const outputArray = [];
/** *MakeasignatureforcurrentOCSPResponse *@paramprivateKeyPrivatekeyfor"subjectPublicKeyInfo"structure *@paramhashAlgorithmHashingalgorithm.DefaultSHA-1
*/ public async sign(privateKey: CryptoKey, hashAlgorithm?: string, crypto = common.getCrypto(true)) { //#region Check that ResponseData has type BasicOCSPResponse and sign it if (this.responseBytes && this.responseBytes.responseType === id_PKIX_OCSP_Basic) { const basicResponse = BasicOCSPResponse.fromBER(this.responseBytes.response.valueBlock.valueHexView as BufferSource);
/** *VerifycurrentOCSPResponse *@paramissuerCertificateInordertodecreasesizeofrespissuercertcouldbeomitted.Insuchcaseyouneedmanuallyprovideit. *@paramcryptoCryptoengine
*/ public async verify(issuerCertificate: Certificate | null = null, crypto = common.getCrypto(true)): Promise<boolean> { //#region Check that ResponseBytes exists in the object if ((RESPONSE_BYTES in this) === false) thrownew Error("Empty ResponseBytes field"); //#endregion
//#region Check that ResponseData has type BasicOCSPResponse and verify it if (this.responseBytes && this.responseBytes.responseType === id_PKIX_OCSP_Basic) { const basicResponse = BasicOCSPResponse.fromBER(this.responseBytes.response.valueBlock.valueHexView as BufferSource);
if (issuerCertificate !== null) { if (!basicResponse.certs) {
basicResponse.certs = [];
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.