UNPKG

@wildboar/pkcs

Version:
173 lines 6.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_DHParameter = exports._decode_DHParameter = exports._extension_additions_list_spec_for_DHParameter = exports._root_component_type_list_2_spec_for_DHParameter = exports._root_component_type_list_1_spec_for_DHParameter = exports.DHParameter = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); /* START_OF_SYMBOL_DEFINITION DHParameter */ /** * @summary DHParameter * @description * * ### ASN.1 Definition: * * ```asn1 * DHParameter ::= SEQUENCE { * prime INTEGER, -- p * base INTEGER, -- g * privateValueLength INTEGER OPTIONAL * } * ``` * * @class */ class DHParameter { constructor( /** * @summary `prime`. * @public * @readonly */ prime, /** * @summary `base`. * @public * @readonly */ base, /** * @summary `privateValueLength`. * @public * @readonly */ privateValueLength) { this.prime = prime; this.base = base; this.privateValueLength = privateValueLength; } /** * @summary Restructures an object into a DHParameter * @description * * This takes an `object` and converts it to a `DHParameter`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `DHParameter`. * @returns {DHParameter} */ static _from_object(_o) { return new DHParameter(_o.prime, _o.base, _o.privateValueLength); } } exports.DHParameter = DHParameter; /* END_OF_SYMBOL_DEFINITION DHParameter */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_DHParameter */ /** * @summary The Leading Root Component Types of DHParameter * @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_DHParameter = [ new $.ComponentSpec("prime", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("base", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("privateValueLength", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_DHParameter */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_DHParameter */ /** * @summary The Trailing Root Component Types of DHParameter * @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_DHParameter = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_DHParameter */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_DHParameter */ /** * @summary The Extension Addition Component Types of DHParameter * @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_DHParameter = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_DHParameter */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_DHParameter */ let _cached_decoder_for_DHParameter = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_DHParameter */ /* START_OF_SYMBOL_DEFINITION _decode_DHParameter */ /** * @summary Decodes an ASN.1 element into a(n) DHParameter * @function * @param {_Element} el The element being decoded. * @returns {DHParameter} The decoded data structure. */ function _decode_DHParameter(el) { if (!_cached_decoder_for_DHParameter) { _cached_decoder_for_DHParameter = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let prime; let base; let privateValueLength; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { prime: (_el) => { prime = $._decodeBigInt(_el); }, base: (_el) => { base = $._decodeBigInt(_el); }, privateValueLength: (_el) => { privateValueLength = $._decodeInteger(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_DHParameter, exports._extension_additions_list_spec_for_DHParameter, exports._root_component_type_list_2_spec_for_DHParameter, undefined); return new DHParameter( /* SEQUENCE_CONSTRUCTOR_CALL */ prime, base, privateValueLength); }; } return _cached_decoder_for_DHParameter(el); } exports._decode_DHParameter = _decode_DHParameter; /* END_OF_SYMBOL_DEFINITION _decode_DHParameter */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_DHParameter */ let _cached_encoder_for_DHParameter = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_DHParameter */ /* START_OF_SYMBOL_DEFINITION _encode_DHParameter */ /** * @summary Encodes a(n) DHParameter 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 DHParameter, encoded as an ASN.1 Element. */ function _encode_DHParameter(value, elGetter) { if (!_cached_encoder_for_DHParameter) { _cached_encoder_for_DHParameter = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ $._encodeBigInt(value.prime, $.BER), /* REQUIRED */ $._encodeBigInt(value.base, $.BER), /* IF_ABSENT */ value.privateValueLength === undefined ? undefined : $._encodeInteger(value.privateValueLength, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_DHParameter(value, elGetter); } exports._encode_DHParameter = _encode_DHParameter; /* END_OF_SYMBOL_DEFINITION _encode_DHParameter */ /* eslint-enable */ //# sourceMappingURL=DHParameter.ta.js.map