UNPKG

@wildboar/pkcs

Version:
179 lines 9.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_ExtendedCertificate = exports._decode_ExtendedCertificate = exports._extension_additions_list_spec_for_ExtendedCertificate = exports._root_component_type_list_2_spec_for_ExtendedCertificate = exports._root_component_type_list_1_spec_for_ExtendedCertificate = exports.ExtendedCertificate = exports._encode_SignatureAlgorithmIdentifier = exports._decode_SignatureAlgorithmIdentifier = exports._encode_Signature = exports._decode_Signature = exports._encode_ExtendedCertificateInfo = exports._decode_ExtendedCertificateInfo = exports.ExtendedCertificateInfo = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const ExtendedCertificateInfo_ta_1 = require("../CryptographicMessageSyntax/ExtendedCertificateInfo.ta"); const Signature_ta_1 = require("../CryptographicMessageSyntax/Signature.ta"); const SignatureAlgorithmIdentifier_ta_1 = require("../CryptographicMessageSyntax/SignatureAlgorithmIdentifier.ta"); var ExtendedCertificateInfo_ta_2 = require("../CryptographicMessageSyntax/ExtendedCertificateInfo.ta"); Object.defineProperty(exports, "ExtendedCertificateInfo", { enumerable: true, get: function () { return ExtendedCertificateInfo_ta_2.ExtendedCertificateInfo; } }); Object.defineProperty(exports, "_decode_ExtendedCertificateInfo", { enumerable: true, get: function () { return ExtendedCertificateInfo_ta_2._decode_ExtendedCertificateInfo; } }); Object.defineProperty(exports, "_encode_ExtendedCertificateInfo", { enumerable: true, get: function () { return ExtendedCertificateInfo_ta_2._encode_ExtendedCertificateInfo; } }); var Signature_ta_2 = require("../CryptographicMessageSyntax/Signature.ta"); Object.defineProperty(exports, "_decode_Signature", { enumerable: true, get: function () { return Signature_ta_2._decode_Signature; } }); Object.defineProperty(exports, "_encode_Signature", { enumerable: true, get: function () { return Signature_ta_2._encode_Signature; } }); var SignatureAlgorithmIdentifier_ta_2 = require("../CryptographicMessageSyntax/SignatureAlgorithmIdentifier.ta"); Object.defineProperty(exports, "_decode_SignatureAlgorithmIdentifier", { enumerable: true, get: function () { return SignatureAlgorithmIdentifier_ta_2._decode_SignatureAlgorithmIdentifier; } }); Object.defineProperty(exports, "_encode_SignatureAlgorithmIdentifier", { enumerable: true, get: function () { return SignatureAlgorithmIdentifier_ta_2._encode_SignatureAlgorithmIdentifier; } }); /* START_OF_SYMBOL_DEFINITION ExtendedCertificate */ /** * @summary ExtendedCertificate * @description * * ### ASN.1 Definition: * * ```asn1 * ExtendedCertificate ::= SEQUENCE { * extendedCertificateInfo ExtendedCertificateInfo, * signatureAlgorithm SignatureAlgorithmIdentifier, * signature Signature * } * ``` * * @class */ class ExtendedCertificate { constructor( /** * @summary `extendedCertificateInfo`. * @public * @readonly */ extendedCertificateInfo, /** * @summary `signatureAlgorithm`. * @public * @readonly */ signatureAlgorithm, /** * @summary `signature`. * @public * @readonly */ signature) { this.extendedCertificateInfo = extendedCertificateInfo; this.signatureAlgorithm = signatureAlgorithm; this.signature = signature; } /** * @summary Restructures an object into a ExtendedCertificate * @description * * This takes an `object` and converts it to a `ExtendedCertificate`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `ExtendedCertificate`. * @returns {ExtendedCertificate} */ static _from_object(_o) { return new ExtendedCertificate(_o.extendedCertificateInfo, _o.signatureAlgorithm, _o.signature); } } exports.ExtendedCertificate = ExtendedCertificate; /* END_OF_SYMBOL_DEFINITION ExtendedCertificate */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_ExtendedCertificate */ /** * @summary The Leading Root Component Types of ExtendedCertificate * @description * * This is an array of `ComponentSpec`s that define how to decode the leading root component type list of a SET or SEQUENCE. * * @constant */ exports._root_component_type_list_1_spec_for_ExtendedCertificate = [ new $.ComponentSpec("extendedCertificateInfo", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("signatureAlgorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("signature", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 3), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_ExtendedCertificate */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_ExtendedCertificate */ /** * @summary The Trailing Root Component Types of ExtendedCertificate * @description * * This is an array of `ComponentSpec`s that define how to decode the trailing root component type list of a SET or SEQUENCE. * * @constant */ exports._root_component_type_list_2_spec_for_ExtendedCertificate = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_ExtendedCertificate */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_ExtendedCertificate */ /** * @summary The Extension Addition Component Types of ExtendedCertificate * @description * * This is an array of `ComponentSpec`s that define how to decode the extension addition component type list of a SET or SEQUENCE. * * @constant */ exports._extension_additions_list_spec_for_ExtendedCertificate = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_ExtendedCertificate */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_ExtendedCertificate */ let _cached_decoder_for_ExtendedCertificate = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_ExtendedCertificate */ /* START_OF_SYMBOL_DEFINITION _decode_ExtendedCertificate */ /** * @summary Decodes an ASN.1 element into a(n) ExtendedCertificate * @function * @param {_Element} el The element being decoded. * @returns {ExtendedCertificate} The decoded data structure. */ function _decode_ExtendedCertificate(el) { if (!_cached_decoder_for_ExtendedCertificate) { _cached_decoder_for_ExtendedCertificate = function (el) { const sequence = el.sequence; if (sequence.length < 3) { throw new asn1_ts_1.ASN1ConstructionError("ExtendedCertificate contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "extendedCertificateInfo"; sequence[1].name = "signatureAlgorithm"; sequence[2].name = "signature"; let extendedCertificateInfo; let signatureAlgorithm; let signature; extendedCertificateInfo = ExtendedCertificateInfo_ta_1._decode_ExtendedCertificateInfo(sequence[0]); signatureAlgorithm = SignatureAlgorithmIdentifier_ta_1._decode_SignatureAlgorithmIdentifier(sequence[1]); signature = Signature_ta_1._decode_Signature(sequence[2]); return new ExtendedCertificate(extendedCertificateInfo, signatureAlgorithm, signature); }; } return _cached_decoder_for_ExtendedCertificate(el); } exports._decode_ExtendedCertificate = _decode_ExtendedCertificate; /* END_OF_SYMBOL_DEFINITION _decode_ExtendedCertificate */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_ExtendedCertificate */ let _cached_encoder_for_ExtendedCertificate = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_ExtendedCertificate */ /* START_OF_SYMBOL_DEFINITION _encode_ExtendedCertificate */ /** * @summary Encodes a(n) ExtendedCertificate into an ASN.1 Element. * @function * @param {value} el The element being decoded. * @param elGetter A function that can be used to get new ASN.1 elements. * @returns {_Element} The ExtendedCertificate, encoded as an ASN.1 Element. */ function _encode_ExtendedCertificate(value, elGetter) { if (!_cached_encoder_for_ExtendedCertificate) { _cached_encoder_for_ExtendedCertificate = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ ExtendedCertificateInfo_ta_1._encode_ExtendedCertificateInfo(value.extendedCertificateInfo, $.BER), /* REQUIRED */ SignatureAlgorithmIdentifier_ta_1._encode_SignatureAlgorithmIdentifier(value.signatureAlgorithm, $.BER), /* REQUIRED */ Signature_ta_1._encode_Signature(value.signature, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_ExtendedCertificate(value, elGetter); } exports._encode_ExtendedCertificate = _encode_ExtendedCertificate; /* END_OF_SYMBOL_DEFINITION _encode_ExtendedCertificate */ /* eslint-enable */ //# sourceMappingURL=ExtendedCertificate.ta.js.map