import * as asn1js from "asn1js"; import * as pvutils from "pvutils"; import { Certificate } from "./Certificate"; import { AttributeCertificateV2 } from "./AttributeCertificateV2"; import * as Schema from "./Schema"; import { id_CertBag_AttributeCertificate, id_CertBag_SDSICertificate, id_CertBag_X509Certificate } from "./ObjectIdentifiers"; import { AsnError } from "./errors"; import { PkiObject, PkiObjectParameters } from "./PkiObject"; import { EMPTY_STRING } from "./constants";
//#region Get internal properties from parsed schema this.certId = asn1.result.certId.valueBlock.toString(); this.certValue = asn1.result.certValue as asn1js.OctetString;
const certValueHex = this.certValue.valueBlock.valueHexView; switch (this.certId) { case id_CertBag_X509Certificate: // x509Certificate
{ try { this.parsedValue = Certificate.fromBER(certValueHex as BufferSource);
} catch// In some realizations the same OID used for attribute certificates
{
AttributeCertificateV2.fromBER(certValueHex as BufferSource);
}
} break; case id_CertBag_AttributeCertificate: // attributeCertificate - (!!!) THIS OID IS SUBJECT FOR CHANGE IN FUTURE (!!!)
{ this.parsedValue = AttributeCertificateV2.fromBER(certValueHex as BufferSource);
} break; case id_CertBag_SDSICertificate: // sdsiCertificate default: thrownew Error(`Incorrect CERT_ID value in CertBag: ${this.certId}`);
} //#endregion
}
public toSchema(): asn1js.Sequence { //#region Construct and return new ASN.1 schema for this object if (PARSED_VALUE in this) { if ("acinfo" in this.parsedValue) {// attributeCertificate this.certId = id_CertBag_AttributeCertificate;
} else {// x509Certificate this.certId = id_CertBag_X509Certificate;
}
this.certValue = new asn1js.OctetString({ valueHex: this.parsedValue.toSchema().toBER(false) });
}
return (new asn1js.Sequence({
value: [ new asn1js.ObjectIdentifier({ value: this.certId }), new asn1js.Constructed({
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0// [0]
},
value: [(("toSchema" in this.certValue) ? this.certValue.toSchema() : this.certValue)]
})
]
})); //#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.