import * as asn1js from "asn1js"; import * as pvutils from "pvutils"; import { PkiObject, PkiObjectParameters } from "./PkiObject"; import * as Schema from "./Schema";
public fromSchema(schema: Schema.SchemaType) { //#region Check the schema is valid if (schema.constructor.blockName() !== asn1js.Integer.blockName()) { thrownew Error("Object's schema was not verified against input data for CAVersion");
} //#endregion
//#region Check length of the input value and correct it if needed
let value = schema.valueBlock.valueHex.slice(0); const valueView = new Uint8Array(value);
switch (true) { case (value.byteLength < 4):
{ const tempValue = new ArrayBuffer(4); const tempValueView = new Uint8Array(tempValue);
value = tempValue.slice(0);
} break; case (value.byteLength > 4):
{ const tempValue = new ArrayBuffer(4); const tempValueView = new Uint8Array(tempValue);
tempValueView.set(valueView.slice(0, 4));
value = tempValue.slice(0);
} break; default:
} //#endregion
//#region Get internal properties from parsed schema const keyIndexBuffer = value.slice(0, 2); const keyIndexView8 = new Uint8Array(keyIndexBuffer);
let temp = keyIndexView8[0];
keyIndexView8[0] = keyIndexView8[1];
keyIndexView8[1] = temp;
const keyIndexView16 = new Uint16Array(keyIndexBuffer);
public toSchema(): asn1js.Integer { //#region Create raw values const certificateIndexBuffer = new ArrayBuffer(2); const certificateIndexView = new Uint16Array(certificateIndexBuffer);
certificateIndexView[0] = this.certificateIndex;
const certificateIndexView8 = new Uint8Array(certificateIndexBuffer);
let temp = certificateIndexView8[0];
certificateIndexView8[0] = certificateIndexView8[1];
certificateIndexView8[1] = temp;
const keyIndexBuffer = new ArrayBuffer(2); const keyIndexView = new Uint16Array(keyIndexBuffer);
//#region Construct and return new ASN.1 schema for this object
return (new asn1js.Integer({
valueHex: pvutils.utilConcatBuf(keyIndexBuffer, certificateIndexBuffer)
})); //#endregion
}
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.