UNPKG

@wildboar/pkcs

Version:
133 lines (132 loc) 4.38 kB
/* eslint-disable */ import { ASN1TagClass as _TagClass, } from "@wildboar/asn1"; import * as $ from "@wildboar/asn1/functional"; /** * @summary RC2_CBC_Parameter * @description * * ### ASN.1 Definition: * * ```asn1 * RC2-CBC-Parameter ::= SEQUENCE { * rc2ParameterVersion INTEGER OPTIONAL, * iv OCTET STRING (SIZE(8)) * } * ``` * */ export class RC2_CBC_Parameter { rc2ParameterVersion; iv; constructor( /** * @summary `rc2ParameterVersion`. * @public * @readonly */ rc2ParameterVersion, /** * @summary `iv`. * @public * @readonly */ iv) { this.rc2ParameterVersion = rc2ParameterVersion; this.iv = iv; } /** * @summary Restructures an object into a RC2_CBC_Parameter * @description * * This takes an `object` and converts it to a `RC2_CBC_Parameter`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `RC2_CBC_Parameter`. * @returns {RC2_CBC_Parameter} */ static _from_object(_o) { return new RC2_CBC_Parameter(_o.rc2ParameterVersion, _o.iv); } } /** * @summary The Leading Root Component Types of RC2_CBC_Parameter * @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_RC2_CBC_Parameter = [ new $.ComponentSpec("rc2ParameterVersion", true, $.hasTag(_TagClass.universal, 2)), new $.ComponentSpec("iv", false, $.hasTag(_TagClass.universal, 4)), ]; /** * @summary The Trailing Root Component Types of RC2_CBC_Parameter * @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_RC2_CBC_Parameter = []; /** * @summary The Extension Addition Component Types of RC2_CBC_Parameter * @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_RC2_CBC_Parameter = []; let _cached_decoder_for_RC2_CBC_Parameter = null; /** * @summary Decodes an ASN.1 element into a(n) RC2_CBC_Parameter * @function * @param {_Element} el The element being decoded. * @returns {RC2_CBC_Parameter} The decoded data structure. */ export function _decode_RC2_CBC_Parameter(el) { if (!_cached_decoder_for_RC2_CBC_Parameter) { _cached_decoder_for_RC2_CBC_Parameter = function (el) { let rc2ParameterVersion; let iv; const callbacks = { rc2ParameterVersion: (_el) => { rc2ParameterVersion = $._decodeInteger(_el); }, iv: (_el) => { iv = $._decodeOctetString(_el); }, }; $._parse_sequence(el, callbacks, _root_component_type_list_1_spec_for_RC2_CBC_Parameter, _extension_additions_list_spec_for_RC2_CBC_Parameter, _root_component_type_list_2_spec_for_RC2_CBC_Parameter, undefined); return new RC2_CBC_Parameter(rc2ParameterVersion, iv); }; } return _cached_decoder_for_RC2_CBC_Parameter(el); } let _cached_encoder_for_RC2_CBC_Parameter = null; /** * @summary Encodes a(n) RC2_CBC_Parameter 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 RC2_CBC_Parameter, encoded as an ASN.1 Element. */ export function _encode_RC2_CBC_Parameter(value, elGetter) { if (!_cached_encoder_for_RC2_CBC_Parameter) { _cached_encoder_for_RC2_CBC_Parameter = function (value) { return $._encodeSequence([] .concat([ /* IF_ABSENT */ value.rc2ParameterVersion === undefined ? undefined : $._encodeInteger(value.rc2ParameterVersion, $.BER), /* REQUIRED */ $._encodeOctetString(value.iv, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_RC2_CBC_Parameter(value, elGetter); } /* eslint-enable */