UNPKG

@wildboar/pkcs

Version:
223 lines 9.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_AlgorithmInfo = exports._decode_AlgorithmInfo = exports._extension_additions_list_spec_for_AlgorithmInfo = exports._root_component_type_list_2_spec_for_AlgorithmInfo = exports._root_component_type_list_1_spec_for_AlgorithmInfo = exports.AlgorithmInfo = exports._encode_Reference = exports._decode_Reference = exports.AlgorithmSet = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const Reference_ta_1 = require("../PKCS-15/Reference.ta"); var AlgorithmSet_osa_1 = require("../PKCS-15/AlgorithmSet.osa"); Object.defineProperty(exports, "AlgorithmSet", { enumerable: true, get: function () { return AlgorithmSet_osa_1.AlgorithmSet; } }); var Reference_ta_2 = require("../PKCS-15/Reference.ta"); Object.defineProperty(exports, "_decode_Reference", { enumerable: true, get: function () { return Reference_ta_2._decode_Reference; } }); Object.defineProperty(exports, "_encode_Reference", { enumerable: true, get: function () { return Reference_ta_2._encode_Reference; } }); /* START_OF_SYMBOL_DEFINITION AlgorithmInfo */ /** * @summary AlgorithmInfo * @description * * ### ASN.1 Definition: * * ```asn1 * AlgorithmInfo ::= SEQUENCE { * reference Reference, * algorithm PKCS15-ALGORITHM.&id({AlgorithmSet}), * parameters PKCS15-ALGORITHM.&Parameters({AlgorithmSet}{@algorithm}), * supportedOperations PKCS15-ALGORITHM.&Operations({AlgorithmSet}{@algorithm}), * algId PKCS15-ALGORITHM.&objectIdentifier({AlgorithmSet}{@algorithm}) OPTIONAL, * algRef Reference OPTIONAL * } * ``` * * @class */ class AlgorithmInfo { constructor( /** * @summary `reference`. * @public * @readonly */ reference, /** * @summary `algorithm`. * @public * @readonly */ algorithm, /** * @summary `parameters`. * @public * @readonly */ parameters, /** * @summary `supportedOperations`. * @public * @readonly */ supportedOperations, /** * @summary `algId`. * @public * @readonly */ algId, /** * @summary `algRef`. * @public * @readonly */ algRef) { this.reference = reference; this.algorithm = algorithm; this.parameters = parameters; this.supportedOperations = supportedOperations; this.algId = algId; this.algRef = algRef; } /** * @summary Restructures an object into a AlgorithmInfo * @description * * This takes an `object` and converts it to a `AlgorithmInfo`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `AlgorithmInfo`. * @returns {AlgorithmInfo} */ static _from_object(_o) { return new AlgorithmInfo(_o.reference, _o.algorithm, _o.parameters, _o.supportedOperations, _o.algId, _o.algRef); } } exports.AlgorithmInfo = AlgorithmInfo; /* END_OF_SYMBOL_DEFINITION AlgorithmInfo */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_AlgorithmInfo */ /** * @summary The Leading Root Component Types of AlgorithmInfo * @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_AlgorithmInfo = [ new $.ComponentSpec("reference", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("algorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("parameters", false, $.hasAnyTag, undefined, undefined), new $.ComponentSpec("supportedOperations", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 3), undefined, undefined), new $.ComponentSpec("algId", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined), new $.ComponentSpec("algRef", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_AlgorithmInfo */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_AlgorithmInfo */ /** * @summary The Trailing Root Component Types of AlgorithmInfo * @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_AlgorithmInfo = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_AlgorithmInfo */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_AlgorithmInfo */ /** * @summary The Extension Addition Component Types of AlgorithmInfo * @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_AlgorithmInfo = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_AlgorithmInfo */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_AlgorithmInfo */ let _cached_decoder_for_AlgorithmInfo = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_AlgorithmInfo */ /* START_OF_SYMBOL_DEFINITION _decode_AlgorithmInfo */ /** * @summary Decodes an ASN.1 element into a(n) AlgorithmInfo * @function * @param {_Element} el The element being decoded. * @returns {AlgorithmInfo} The decoded data structure. */ function _decode_AlgorithmInfo(el) { if (!_cached_decoder_for_AlgorithmInfo) { _cached_decoder_for_AlgorithmInfo = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let reference; let algorithm; let parameters; let supportedOperations; let algId; let algRef; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { reference: (_el) => { reference = Reference_ta_1._decode_Reference(_el); }, algorithm: (_el) => { algorithm = $._decodeInteger(_el); }, parameters: (_el) => { parameters = $._decodeAny(_el); }, supportedOperations: (_el) => { supportedOperations = $._decodeAny(_el); }, algId: (_el) => { algId = $._decodeObjectIdentifier(_el); }, algRef: (_el) => { algRef = Reference_ta_1._decode_Reference(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_AlgorithmInfo, exports._extension_additions_list_spec_for_AlgorithmInfo, exports._root_component_type_list_2_spec_for_AlgorithmInfo, undefined); return new AlgorithmInfo( /* SEQUENCE_CONSTRUCTOR_CALL */ reference, algorithm, parameters, supportedOperations, algId, algRef); }; } return _cached_decoder_for_AlgorithmInfo(el); } exports._decode_AlgorithmInfo = _decode_AlgorithmInfo; /* END_OF_SYMBOL_DEFINITION _decode_AlgorithmInfo */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_AlgorithmInfo */ let _cached_encoder_for_AlgorithmInfo = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_AlgorithmInfo */ /* START_OF_SYMBOL_DEFINITION _encode_AlgorithmInfo */ /** * @summary Encodes a(n) AlgorithmInfo 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 AlgorithmInfo, encoded as an ASN.1 Element. */ function _encode_AlgorithmInfo(value, elGetter) { if (!_cached_encoder_for_AlgorithmInfo) { _cached_encoder_for_AlgorithmInfo = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ Reference_ta_1._encode_Reference(value.reference, $.BER), /* REQUIRED */ $._encodeInteger(value.algorithm, $.BER), /* REQUIRED */ $._encodeAny(value.parameters, $.BER), /* REQUIRED */ $._encodeAny(value.supportedOperations, $.BER), /* IF_ABSENT */ value.algId === undefined ? undefined : $._encodeObjectIdentifier(value.algId, $.BER), /* IF_ABSENT */ value.algRef === undefined ? undefined : Reference_ta_1._encode_Reference(value.algRef, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_AlgorithmInfo(value, elGetter); } exports._encode_AlgorithmInfo = _encode_AlgorithmInfo; /* END_OF_SYMBOL_DEFINITION _encode_AlgorithmInfo */ /* eslint-enable */ //# sourceMappingURL=AlgorithmInfo.ta.js.map