UNPKG

@wildboar/pkcs

Version:
171 lines 7.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_DigestInfoWithDefault = exports._decode_DigestInfoWithDefault = exports._extension_additions_list_spec_for_DigestInfoWithDefault = exports._root_component_type_list_2_spec_for_DigestInfoWithDefault = exports._root_component_type_list_1_spec_for_DigestInfoWithDefault = exports.DigestInfoWithDefault = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const AlgorithmIdentifier_ta_1 = require("@wildboar/x500/src/lib/modules/AuthenticationFramework/AlgorithmIdentifier.ta"); const alg_id_sha1_va_1 = require("../PKCS-15/alg-id-sha1.va"); /* START_OF_SYMBOL_DEFINITION DigestInfoWithDefault */ /** * @summary DigestInfoWithDefault * @description * * ### ASN.1 Definition: * * ```asn1 * DigestInfoWithDefault ::= SEQUENCE { * digestAlg AlgorithmIdentifier {{DigestAlgorithms}} DEFAULT alg-id-sha1, * digest OCTET STRING (SIZE(8..128)) * } * ``` * * @class */ class DigestInfoWithDefault { constructor( /** * @summary `digestAlg`. * @public * @readonly */ digestAlg, /** * @summary `digest`. * @public * @readonly */ digest) { this.digestAlg = digestAlg; this.digest = digest; } /** * @summary Restructures an object into a DigestInfoWithDefault * @description * * This takes an `object` and converts it to a `DigestInfoWithDefault`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `DigestInfoWithDefault`. * @returns {DigestInfoWithDefault} */ static _from_object(_o) { return new DigestInfoWithDefault(_o.digestAlg, _o.digest); } /** * @summary Getter that returns the default value for `digestAlg`. * @public * @static * @method */ static get _default_value_for_digestAlg() { return alg_id_sha1_va_1.alg_id_sha1; } } exports.DigestInfoWithDefault = DigestInfoWithDefault; /* END_OF_SYMBOL_DEFINITION DigestInfoWithDefault */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_DigestInfoWithDefault */ /** * @summary The Leading Root Component Types of DigestInfoWithDefault * @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_DigestInfoWithDefault = [ new $.ComponentSpec("digestAlg", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("digest", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_DigestInfoWithDefault */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_DigestInfoWithDefault */ /** * @summary The Trailing Root Component Types of DigestInfoWithDefault * @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_DigestInfoWithDefault = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_DigestInfoWithDefault */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_DigestInfoWithDefault */ /** * @summary The Extension Addition Component Types of DigestInfoWithDefault * @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_DigestInfoWithDefault = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_DigestInfoWithDefault */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_DigestInfoWithDefault */ let _cached_decoder_for_DigestInfoWithDefault = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_DigestInfoWithDefault */ /* START_OF_SYMBOL_DEFINITION _decode_DigestInfoWithDefault */ /** * @summary Decodes an ASN.1 element into a(n) DigestInfoWithDefault * @function * @param {_Element} el The element being decoded. * @returns {DigestInfoWithDefault} The decoded data structure. */ function _decode_DigestInfoWithDefault(el) { if (!_cached_decoder_for_DigestInfoWithDefault) { _cached_decoder_for_DigestInfoWithDefault = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let digestAlg = DigestInfoWithDefault._default_value_for_digestAlg; let digest; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { digestAlg: (_el) => { digestAlg = AlgorithmIdentifier_ta_1._decode_AlgorithmIdentifier(_el); }, digest: (_el) => { digest = $._decodeOctetString(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_DigestInfoWithDefault, exports._extension_additions_list_spec_for_DigestInfoWithDefault, exports._root_component_type_list_2_spec_for_DigestInfoWithDefault, undefined); return new DigestInfoWithDefault( /* SEQUENCE_CONSTRUCTOR_CALL */ digestAlg, digest); }; } return _cached_decoder_for_DigestInfoWithDefault(el); } exports._decode_DigestInfoWithDefault = _decode_DigestInfoWithDefault; /* END_OF_SYMBOL_DEFINITION _decode_DigestInfoWithDefault */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_DigestInfoWithDefault */ let _cached_encoder_for_DigestInfoWithDefault = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_DigestInfoWithDefault */ /* START_OF_SYMBOL_DEFINITION _encode_DigestInfoWithDefault */ /** * @summary Encodes a(n) DigestInfoWithDefault 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 DigestInfoWithDefault, encoded as an ASN.1 Element. */ function _encode_DigestInfoWithDefault(value, elGetter) { if (!_cached_encoder_for_DigestInfoWithDefault) { _cached_encoder_for_DigestInfoWithDefault = function (value, elGetter) { return $._encodeSequence([] .concat([ /* IF_DEFAULT */ value.digestAlg === undefined || $.deepEq(value.digestAlg, DigestInfoWithDefault._default_value_for_digestAlg) ? undefined : AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier(value.digestAlg, $.BER), /* REQUIRED */ $._encodeOctetString(value.digest, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_DigestInfoWithDefault(value, elGetter); } exports._encode_DigestInfoWithDefault = _encode_DigestInfoWithDefault; /* END_OF_SYMBOL_DEFINITION _encode_DigestInfoWithDefault */ /* eslint-enable */ //# sourceMappingURL=DigestInfoWithDefault.ta.js.map