UNPKG

@wildboar/pkcs

Version:
153 lines 5.66 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_PBEParameter = exports._decode_PBEParameter = exports._extension_additions_list_spec_for_PBEParameter = exports._root_component_type_list_2_spec_for_PBEParameter = exports._root_component_type_list_1_spec_for_PBEParameter = exports.PBEParameter = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); /* START_OF_SYMBOL_DEFINITION PBEParameter */ /** * @summary PBEParameter * @description * * ### ASN.1 Definition: * * ```asn1 * PBEParameter ::= SEQUENCE { * salt OCTET STRING (SIZE(8)), * iterationCount INTEGER * } * ``` * * @class */ class PBEParameter { constructor( /** * @summary `salt`. * @public * @readonly */ salt, /** * @summary `iterationCount`. * @public * @readonly */ iterationCount) { this.salt = salt; this.iterationCount = iterationCount; } /** * @summary Restructures an object into a PBEParameter * @description * * This takes an `object` and converts it to a `PBEParameter`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `PBEParameter`. * @returns {PBEParameter} */ static _from_object(_o) { return new PBEParameter(_o.salt, _o.iterationCount); } } exports.PBEParameter = PBEParameter; /* END_OF_SYMBOL_DEFINITION PBEParameter */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PBEParameter */ /** * @summary The Leading Root Component Types of PBEParameter * @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_PBEParameter = [ new $.ComponentSpec("salt", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined), new $.ComponentSpec("iterationCount", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PBEParameter */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PBEParameter */ /** * @summary The Trailing Root Component Types of PBEParameter * @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_PBEParameter = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PBEParameter */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PBEParameter */ /** * @summary The Extension Addition Component Types of PBEParameter * @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_PBEParameter = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PBEParameter */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_PBEParameter */ let _cached_decoder_for_PBEParameter = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_PBEParameter */ /* START_OF_SYMBOL_DEFINITION _decode_PBEParameter */ /** * @summary Decodes an ASN.1 element into a(n) PBEParameter * @function * @param {_Element} el The element being decoded. * @returns {PBEParameter} The decoded data structure. */ function _decode_PBEParameter(el) { if (!_cached_decoder_for_PBEParameter) { _cached_decoder_for_PBEParameter = function (el) { const sequence = el.sequence; if (sequence.length < 2) { throw new asn1_ts_1.ASN1ConstructionError("PBEParameter contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "salt"; sequence[1].name = "iterationCount"; let salt; let iterationCount; salt = $._decodeOctetString(sequence[0]); iterationCount = $._decodeInteger(sequence[1]); return new PBEParameter(salt, iterationCount); }; } return _cached_decoder_for_PBEParameter(el); } exports._decode_PBEParameter = _decode_PBEParameter; /* END_OF_SYMBOL_DEFINITION _decode_PBEParameter */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_PBEParameter */ let _cached_encoder_for_PBEParameter = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_PBEParameter */ /* START_OF_SYMBOL_DEFINITION _encode_PBEParameter */ /** * @summary Encodes a(n) PBEParameter 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 PBEParameter, encoded as an ASN.1 Element. */ function _encode_PBEParameter(value, elGetter) { if (!_cached_encoder_for_PBEParameter) { _cached_encoder_for_PBEParameter = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ $._encodeOctetString(value.salt, $.BER), /* REQUIRED */ $._encodeInteger(value.iterationCount, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_PBEParameter(value, elGetter); } exports._encode_PBEParameter = _encode_PBEParameter; /* END_OF_SYMBOL_DEFINITION _encode_PBEParameter */ /* eslint-enable */ //# sourceMappingURL=PBEParameter.ta.js.map