UNPKG

@wildboar/pkcs

Version:
158 lines 6.85 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_PBMAC1_params = exports._decode_PBMAC1_params = exports._extension_additions_list_spec_for_PBMAC1_params = exports._root_component_type_list_2_spec_for_PBMAC1_params = exports._root_component_type_list_1_spec_for_PBMAC1_params = exports.PBMAC1_params = exports._encode_AlgorithmIdentifier = exports._decode_AlgorithmIdentifier = exports.AlgorithmIdentifier = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const AlgorithmIdentifier_ta_1 = require("../PKCS5v2-1/AlgorithmIdentifier.ta"); var AlgorithmIdentifier_ta_2 = require("../PKCS5v2-1/AlgorithmIdentifier.ta"); Object.defineProperty(exports, "AlgorithmIdentifier", { enumerable: true, get: function () { return AlgorithmIdentifier_ta_2.AlgorithmIdentifier; } }); Object.defineProperty(exports, "_decode_AlgorithmIdentifier", { enumerable: true, get: function () { return AlgorithmIdentifier_ta_2._decode_AlgorithmIdentifier; } }); Object.defineProperty(exports, "_encode_AlgorithmIdentifier", { enumerable: true, get: function () { return AlgorithmIdentifier_ta_2._encode_AlgorithmIdentifier; } }); /* START_OF_SYMBOL_DEFINITION PBMAC1_params */ /** * @summary PBMAC1_params * @description * * ### ASN.1 Definition: * * ```asn1 * PBMAC1-params ::= SEQUENCE { * keyDerivationFunc AlgorithmIdentifier {{PBMAC1-KDFs}}, * messageAuthScheme AlgorithmIdentifier {{PBMAC1-MACs}} * } * ``` * * @class */ class PBMAC1_params { constructor( /** * @summary `keyDerivationFunc`. * @public * @readonly */ keyDerivationFunc, /** * @summary `messageAuthScheme`. * @public * @readonly */ messageAuthScheme) { this.keyDerivationFunc = keyDerivationFunc; this.messageAuthScheme = messageAuthScheme; } /** * @summary Restructures an object into a PBMAC1_params * @description * * This takes an `object` and converts it to a `PBMAC1_params`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `PBMAC1_params`. * @returns {PBMAC1_params} */ static _from_object(_o) { return new PBMAC1_params(_o.keyDerivationFunc, _o.messageAuthScheme); } } exports.PBMAC1_params = PBMAC1_params; /* END_OF_SYMBOL_DEFINITION PBMAC1_params */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PBMAC1_params */ /** * @summary The Leading Root Component Types of PBMAC1_params * @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_PBMAC1_params = [ new $.ComponentSpec("keyDerivationFunc", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("messageAuthScheme", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PBMAC1_params */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PBMAC1_params */ /** * @summary The Trailing Root Component Types of PBMAC1_params * @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_PBMAC1_params = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PBMAC1_params */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PBMAC1_params */ /** * @summary The Extension Addition Component Types of PBMAC1_params * @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_PBMAC1_params = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PBMAC1_params */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_PBMAC1_params */ let _cached_decoder_for_PBMAC1_params = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_PBMAC1_params */ /* START_OF_SYMBOL_DEFINITION _decode_PBMAC1_params */ /** * @summary Decodes an ASN.1 element into a(n) PBMAC1_params * @function * @param {_Element} el The element being decoded. * @returns {PBMAC1_params} The decoded data structure. */ function _decode_PBMAC1_params(el) { if (!_cached_decoder_for_PBMAC1_params) { _cached_decoder_for_PBMAC1_params = function (el) { const sequence = el.sequence; if (sequence.length < 2) { throw new asn1_ts_1.ASN1ConstructionError("PBMAC1-params contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "keyDerivationFunc"; sequence[1].name = "messageAuthScheme"; let keyDerivationFunc; let messageAuthScheme; keyDerivationFunc = AlgorithmIdentifier_ta_1._decode_AlgorithmIdentifier(sequence[0]); messageAuthScheme = AlgorithmIdentifier_ta_1._decode_AlgorithmIdentifier(sequence[1]); return new PBMAC1_params(keyDerivationFunc, messageAuthScheme); }; } return _cached_decoder_for_PBMAC1_params(el); } exports._decode_PBMAC1_params = _decode_PBMAC1_params; /* END_OF_SYMBOL_DEFINITION _decode_PBMAC1_params */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_PBMAC1_params */ let _cached_encoder_for_PBMAC1_params = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_PBMAC1_params */ /* START_OF_SYMBOL_DEFINITION _encode_PBMAC1_params */ /** * @summary Encodes a(n) PBMAC1_params 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 PBMAC1_params, encoded as an ASN.1 Element. */ function _encode_PBMAC1_params(value, elGetter) { if (!_cached_encoder_for_PBMAC1_params) { _cached_encoder_for_PBMAC1_params = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier(value.keyDerivationFunc, $.BER), /* REQUIRED */ AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier(value.messageAuthScheme, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_PBMAC1_params(value, elGetter); } exports._encode_PBMAC1_params = _encode_PBMAC1_params; /* END_OF_SYMBOL_DEFINITION _encode_PBMAC1_params */ /* eslint-enable */ //# sourceMappingURL=PBMAC1-params.ta.js.map