UNPKG

@wildboar/pki-stub

Version:
153 lines (152 loc) 5.07 kB
/* eslint-disable */ import { ASN1TagClass as _TagClass, } from "@wildboar/asn1"; import * as $ from "@wildboar/asn1/functional"; /** * @summary AlgorithmWithInvoke * @description * * ### ASN.1 Definition: * * ```asn1 * AlgorithmWithInvoke{ALGORITHM:SupportedAlgorithms} ::= SEQUENCE { * algorithm ALGORITHM.&id({SupportedAlgorithms}), * parameters [0] ALGORITHM.&Type({SupportedAlgorithms}{@algorithm}) OPTIONAL, * dynamParms [1] ALGORITHM.&DynParms({SupportedAlgorithms}{@algorithm}) OPTIONAL, * ... } * ``` * */ export class AlgorithmWithInvoke { algorithm; parameters; dynamParms; _unrecognizedExtensionsList; constructor( /** * @summary `algorithm`. * @public * @readonly */ algorithm, /** * @summary `parameters`. * @public * @readonly */ parameters, /** * @summary `dynamParms`. * @public * @readonly */ dynamParms, /** * @summary Extensions that are not recognized. * @public * @readonly */ _unrecognizedExtensionsList = []) { this.algorithm = algorithm; this.parameters = parameters; this.dynamParms = dynamParms; this._unrecognizedExtensionsList = _unrecognizedExtensionsList; } /** * @summary Restructures an object into a AlgorithmWithInvoke * @description * * This takes an `object` and converts it to a `AlgorithmWithInvoke`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `AlgorithmWithInvoke`. * @returns {AlgorithmWithInvoke} */ static _from_object(_o) { return new AlgorithmWithInvoke(_o.algorithm, _o.parameters, _o.dynamParms, _o._unrecognizedExtensionsList); } } /** * @summary The Leading Root Component Types of AlgorithmWithInvoke * @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 */ export const _root_component_type_list_1_spec_for_AlgorithmWithInvoke = [ new $.ComponentSpec("algorithm", false, $.hasTag(_TagClass.universal, 6)), new $.ComponentSpec("parameters", true, $.hasTag(_TagClass.context, 0)), new $.ComponentSpec("dynamParms", true, $.hasTag(_TagClass.context, 1)), ]; /** * @summary The Trailing Root Component Types of AlgorithmWithInvoke * @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 */ export const _root_component_type_list_2_spec_for_AlgorithmWithInvoke = []; /** * @summary The Extension Addition Component Types of AlgorithmWithInvoke * @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 */ export const _extension_additions_list_spec_for_AlgorithmWithInvoke = []; /** * @summary Decodes an ASN.1 element into a(n) AlgorithmWithInvoke * @function * @param {_Element} el The element being decoded. * @returns {AlgorithmWithInvoke} The decoded data structure. */ export function _decode_AlgorithmWithInvoke(el) { let algorithm; let parameters; let dynamParms; let _unrecognizedExtensionsList = []; const callbacks = { algorithm: (_el) => { algorithm = $._decodeObjectIdentifier(_el); }, parameters: (_el) => { parameters = $._decode_explicit(() => $._decodeAny)(_el); }, dynamParms: (_el) => { dynamParms = $._decode_explicit(() => $._decodeAny)(_el); }, }; $._parse_sequence(el, callbacks, _root_component_type_list_1_spec_for_AlgorithmWithInvoke, _extension_additions_list_spec_for_AlgorithmWithInvoke, _root_component_type_list_2_spec_for_AlgorithmWithInvoke, (ext) => { _unrecognizedExtensionsList.push(ext); }); return new AlgorithmWithInvoke(algorithm, parameters, dynamParms, _unrecognizedExtensionsList); } /** * @summary Encodes a(n) AlgorithmWithInvoke into an ASN.1 Element. * @function * @param value The element being encoded. * @param elGetter A function that can be used to get new ASN.1 elements. * @returns {_Element} The AlgorithmWithInvoke, encoded as an ASN.1 Element. */ export function _encode_AlgorithmWithInvoke(value, _elGetter) { const components = [ /* REQUIRED */ $._encodeObjectIdentifier(value.algorithm, $.BER), ]; if (value.parameters) { const c = $._encode_explicit(_TagClass.context, 0, () => $._encodeAny, $.BER)(value.parameters, $.BER); components.push(c); } if (value.dynamParms) { const c = $._encode_explicit(_TagClass.context, 1, () => $._encodeAny, $.BER)(value.dynamParms, $.BER); components.push(c); } if (value._unrecognizedExtensionsList?.length) { components.push(...value._unrecognizedExtensionsList); } return $._encodeSequence(components, $.BER); } /* eslint-enable */