UNPKG

@wildboar/pkcs

Version:
166 lines 6.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_OtherPrimeInfo = exports._decode_OtherPrimeInfo = exports._extension_additions_list_spec_for_OtherPrimeInfo = exports._root_component_type_list_2_spec_for_OtherPrimeInfo = exports._root_component_type_list_1_spec_for_OtherPrimeInfo = exports.OtherPrimeInfo = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); /* START_OF_SYMBOL_DEFINITION OtherPrimeInfo */ /** * @summary OtherPrimeInfo * @description * * ### ASN.1 Definition: * * ```asn1 * OtherPrimeInfo ::= SEQUENCE { * prime INTEGER, -- ri * exponent INTEGER, -- di * coefficient INTEGER -- ti * } * ``` * * @class */ class OtherPrimeInfo { constructor( /** * @summary `prime`. * @public * @readonly */ prime, /** * @summary `exponent`. * @public * @readonly */ exponent, /** * @summary `coefficient`. * @public * @readonly */ coefficient) { this.prime = prime; this.exponent = exponent; this.coefficient = coefficient; } /** * @summary Restructures an object into a OtherPrimeInfo * @description * * This takes an `object` and converts it to a `OtherPrimeInfo`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `OtherPrimeInfo`. * @returns {OtherPrimeInfo} */ static _from_object(_o) { return new OtherPrimeInfo(_o.prime, _o.exponent, _o.coefficient); } } exports.OtherPrimeInfo = OtherPrimeInfo; /* END_OF_SYMBOL_DEFINITION OtherPrimeInfo */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_OtherPrimeInfo */ /** * @summary The Leading Root Component Types of OtherPrimeInfo * @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_OtherPrimeInfo = [ new $.ComponentSpec("prime", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("exponent", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("coefficient", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_OtherPrimeInfo */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_OtherPrimeInfo */ /** * @summary The Trailing Root Component Types of OtherPrimeInfo * @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_OtherPrimeInfo = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_OtherPrimeInfo */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_OtherPrimeInfo */ /** * @summary The Extension Addition Component Types of OtherPrimeInfo * @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_OtherPrimeInfo = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_OtherPrimeInfo */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_OtherPrimeInfo */ let _cached_decoder_for_OtherPrimeInfo = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_OtherPrimeInfo */ /* START_OF_SYMBOL_DEFINITION _decode_OtherPrimeInfo */ /** * @summary Decodes an ASN.1 element into a(n) OtherPrimeInfo * @function * @param {_Element} el The element being decoded. * @returns {OtherPrimeInfo} The decoded data structure. */ function _decode_OtherPrimeInfo(el) { if (!_cached_decoder_for_OtherPrimeInfo) { _cached_decoder_for_OtherPrimeInfo = function (el) { const sequence = el.sequence; if (sequence.length < 3) { throw new asn1_ts_1.ASN1ConstructionError("OtherPrimeInfo contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "prime"; sequence[1].name = "exponent"; sequence[2].name = "coefficient"; let prime; let exponent; let coefficient; prime = $._decodeBigInt(sequence[0]); exponent = $._decodeBigInt(sequence[1]); coefficient = $._decodeBigInt(sequence[2]); return new OtherPrimeInfo(prime, exponent, coefficient); }; } return _cached_decoder_for_OtherPrimeInfo(el); } exports._decode_OtherPrimeInfo = _decode_OtherPrimeInfo; /* END_OF_SYMBOL_DEFINITION _decode_OtherPrimeInfo */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_OtherPrimeInfo */ let _cached_encoder_for_OtherPrimeInfo = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_OtherPrimeInfo */ /* START_OF_SYMBOL_DEFINITION _encode_OtherPrimeInfo */ /** * @summary Encodes a(n) OtherPrimeInfo 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 OtherPrimeInfo, encoded as an ASN.1 Element. */ function _encode_OtherPrimeInfo(value, elGetter) { if (!_cached_encoder_for_OtherPrimeInfo) { _cached_encoder_for_OtherPrimeInfo = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ $._encodeBigInt(value.prime, $.BER), /* REQUIRED */ $._encodeBigInt(value.exponent, $.BER), /* REQUIRED */ $._encodeBigInt(value.coefficient, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_OtherPrimeInfo(value, elGetter); } exports._encode_OtherPrimeInfo = _encode_OtherPrimeInfo; /* END_OF_SYMBOL_DEFINITION _encode_OtherPrimeInfo */ /* eslint-enable */ //# sourceMappingURL=OtherPrimeInfo.ta.js.map