import * as asn1js from "asn1js"; import * as pvtsutils from "pvtsutils"; import * as pvutils from "pvutils"; import { GeneralName, GeneralNameJson, GeneralNameSchema } from "./GeneralName"; import { Request, RequestJson, RequestSchema } from "./Request"; import { Extension, ExtensionJson } from "./Extension"; import { Extensions, ExtensionsSchema } from "./Extensions"; import * as Schema from "./Schema"; import { AsnError } from "./errors"; import { PkiObject, PkiObjectParameters } from "./PkiObject"; import { EMPTY_BUFFER } from "./constants";
public tbsView!: Uint8Array; /** *@deprecatedSinceversion3.0.0
*/ public get tbs(): ArrayBuffer {
return pvtsutils.BufferSourceConverter.toArrayBuffer(this.tbsView);
}
/** *@deprecatedSinceversion3.0.0
*/ public set tbs(value: ArrayBuffer) { this.tbsView = new Uint8Array(value);
} public version?: number; public requestorName?: GeneralName; public requestList!: Request[]; public requestExtensions?: Extension[];
public fromSchema(schema: Schema.SchemaType): void { // Clear input data first
pvutils.clearProps(schema, CLEAR_PROPS);
// Check the schema is valid const asn1 = asn1js.compareSchema(schema,
schema,
TBSRequest.schema()
);
AsnError.assertSchema(asn1, this.className);
// Get internal properties from parsed schema this.tbsView = asn1.result.TBSRequest.valueBeforeDecodeView;
if (TBS_REQUEST_VERSION in asn1.result) this.version = asn1.result[TBS_REQUEST_VERSION].valueBlock.valueDec; if (TBS_REQUEST_REQUESTOR_NAME in asn1.result) this.requestorName = new GeneralName({ schema: asn1.result[TBS_REQUEST_REQUESTOR_NAME] });
this.requestList = Array.from(asn1.result[TBS_REQUEST_REQUESTS], element => new Request({ schema: element }));
if (TBS_REQUEST_REQUEST_EXTENSIONS in asn1.result) this.requestExtensions = Array.from(asn1.result[TBS_REQUEST_REQUEST_EXTENSIONS].valueBlock.value, element => new Extension({ schema: element }));
}
/** *Convertcurrentobjecttoasn1jsobjectandsetcorrectvalues *@paramencodeFlagIfparamequaltofalsethencreateTBSschemaviadecodingstoredvalue.InothecasecreateTBSschemaviaassemblingfromTBSparts. *@returnsasn1jsobject
*/ public toSchema(encodeFlag = false): asn1js.Sequence { //#region Decode stored TBS value
let tbsSchema;
if (encodeFlag === false) { if (this.tbsView.byteLength === 0) // No stored TBS part
return TBSRequest.schema();
const asn1 = asn1js.fromBER(this.tbsView);
AsnError.assert(asn1, "TBS Request"); if (!(asn1.result instanceof asn1js.Sequence)) { thrownew Error("ASN.1 result should be SEQUENCE");
}
tbsSchema = asn1.result;
} //#endregion //#region Create TBS schema via assembling from TBS parts else { const outputArray = [];
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.