UNPKG

@wildboar/pkcs

Version:
196 lines 10.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_EncryptedData = exports._decode_EncryptedData = exports._extension_additions_list_spec_for_EncryptedData = exports._root_component_type_list_2_spec_for_EncryptedData = exports._root_component_type_list_1_spec_for_EncryptedData = exports.EncryptedData = exports._encode_UnprotectedAttributes = exports._decode_UnprotectedAttributes = exports._encode_EncryptedContentInfo = exports._decode_EncryptedContentInfo = exports.EncryptedContentInfo = exports._encode_CMSVersion = exports._decode_CMSVersion = exports.v4 = exports.v3 = exports.v2 = exports.v1 = exports.v0 = exports.CMSVersion_v4 = exports.CMSVersion_v3 = exports.CMSVersion_v2 = exports.CMSVersion_v1 = exports.CMSVersion_v0 = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const CMSVersion_ta_1 = require("../CryptographicMessageSyntax/CMSVersion.ta"); const EncryptedContentInfo_ta_1 = require("../CryptographicMessageSyntax/EncryptedContentInfo.ta"); const UnprotectedAttributes_ta_1 = require("../CryptographicMessageSyntax/UnprotectedAttributes.ta"); var CMSVersion_ta_2 = require("../CryptographicMessageSyntax/CMSVersion.ta"); Object.defineProperty(exports, "CMSVersion_v0", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v0; } }); /* IMPORTED_LONG_NAMED_INTEGER */ Object.defineProperty(exports, "CMSVersion_v1", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v1; } }); /* IMPORTED_LONG_NAMED_INTEGER */ Object.defineProperty(exports, "CMSVersion_v2", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v2; } }); /* IMPORTED_LONG_NAMED_INTEGER */ Object.defineProperty(exports, "CMSVersion_v3", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v3; } }); /* IMPORTED_LONG_NAMED_INTEGER */ Object.defineProperty(exports, "CMSVersion_v4", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v4; } }); /* IMPORTED_LONG_NAMED_INTEGER */ Object.defineProperty(exports, "v0", { enumerable: true, get: function () { return CMSVersion_ta_2.v0; } }); /* IMPORTED_SHORT_NAMED_INTEGER */ Object.defineProperty(exports, "v1", { enumerable: true, get: function () { return CMSVersion_ta_2.v1; } }); /* IMPORTED_SHORT_NAMED_INTEGER */ Object.defineProperty(exports, "v2", { enumerable: true, get: function () { return CMSVersion_ta_2.v2; } }); /* IMPORTED_SHORT_NAMED_INTEGER */ Object.defineProperty(exports, "v3", { enumerable: true, get: function () { return CMSVersion_ta_2.v3; } }); /* IMPORTED_SHORT_NAMED_INTEGER */ Object.defineProperty(exports, "v4", { enumerable: true, get: function () { return CMSVersion_ta_2.v4; } }); /* IMPORTED_SHORT_NAMED_INTEGER */ Object.defineProperty(exports, "_decode_CMSVersion", { enumerable: true, get: function () { return CMSVersion_ta_2._decode_CMSVersion; } }); Object.defineProperty(exports, "_encode_CMSVersion", { enumerable: true, get: function () { return CMSVersion_ta_2._encode_CMSVersion; } }); var EncryptedContentInfo_ta_2 = require("../CryptographicMessageSyntax/EncryptedContentInfo.ta"); Object.defineProperty(exports, "EncryptedContentInfo", { enumerable: true, get: function () { return EncryptedContentInfo_ta_2.EncryptedContentInfo; } }); Object.defineProperty(exports, "_decode_EncryptedContentInfo", { enumerable: true, get: function () { return EncryptedContentInfo_ta_2._decode_EncryptedContentInfo; } }); Object.defineProperty(exports, "_encode_EncryptedContentInfo", { enumerable: true, get: function () { return EncryptedContentInfo_ta_2._encode_EncryptedContentInfo; } }); var UnprotectedAttributes_ta_2 = require("../CryptographicMessageSyntax/UnprotectedAttributes.ta"); Object.defineProperty(exports, "_decode_UnprotectedAttributes", { enumerable: true, get: function () { return UnprotectedAttributes_ta_2._decode_UnprotectedAttributes; } }); Object.defineProperty(exports, "_encode_UnprotectedAttributes", { enumerable: true, get: function () { return UnprotectedAttributes_ta_2._encode_UnprotectedAttributes; } }); /* START_OF_SYMBOL_DEFINITION EncryptedData */ /** * @summary EncryptedData * @description * * ### ASN.1 Definition: * * ```asn1 * EncryptedData ::= SEQUENCE { * version CMSVersion, * encryptedContentInfo EncryptedContentInfo, * unprotectedAttrs [1] IMPLICIT UnprotectedAttributes OPTIONAL * } * ``` * * @class */ class EncryptedData { constructor( /** * @summary `version`. * @public * @readonly */ version, /** * @summary `encryptedContentInfo`. * @public * @readonly */ encryptedContentInfo, /** * @summary `unprotectedAttrs`. * @public * @readonly */ unprotectedAttrs) { this.version = version; this.encryptedContentInfo = encryptedContentInfo; this.unprotectedAttrs = unprotectedAttrs; } /** * @summary Restructures an object into a EncryptedData * @description * * This takes an `object` and converts it to a `EncryptedData`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `EncryptedData`. * @returns {EncryptedData} */ static _from_object(_o) { return new EncryptedData(_o.version, _o.encryptedContentInfo, _o.unprotectedAttrs); } } exports.EncryptedData = EncryptedData; /* END_OF_SYMBOL_DEFINITION EncryptedData */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_EncryptedData */ /** * @summary The Leading Root Component Types of EncryptedData * @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_EncryptedData = [ new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("encryptedContentInfo", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("unprotectedAttrs", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_EncryptedData */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_EncryptedData */ /** * @summary The Trailing Root Component Types of EncryptedData * @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_EncryptedData = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_EncryptedData */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_EncryptedData */ /** * @summary The Extension Addition Component Types of EncryptedData * @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_EncryptedData = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_EncryptedData */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_EncryptedData */ let _cached_decoder_for_EncryptedData = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_EncryptedData */ /* START_OF_SYMBOL_DEFINITION _decode_EncryptedData */ /** * @summary Decodes an ASN.1 element into a(n) EncryptedData * @function * @param {_Element} el The element being decoded. * @returns {EncryptedData} The decoded data structure. */ function _decode_EncryptedData(el) { if (!_cached_decoder_for_EncryptedData) { _cached_decoder_for_EncryptedData = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let version; let encryptedContentInfo; let unprotectedAttrs; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { version: (_el) => { version = CMSVersion_ta_1._decode_CMSVersion(_el); }, encryptedContentInfo: (_el) => { encryptedContentInfo = EncryptedContentInfo_ta_1._decode_EncryptedContentInfo(_el); }, unprotectedAttrs: (_el) => { unprotectedAttrs = $._decode_implicit(() => UnprotectedAttributes_ta_1._decode_UnprotectedAttributes)(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_EncryptedData, exports._extension_additions_list_spec_for_EncryptedData, exports._root_component_type_list_2_spec_for_EncryptedData, undefined); return new EncryptedData( /* SEQUENCE_CONSTRUCTOR_CALL */ version, encryptedContentInfo, unprotectedAttrs); }; } return _cached_decoder_for_EncryptedData(el); } exports._decode_EncryptedData = _decode_EncryptedData; /* END_OF_SYMBOL_DEFINITION _decode_EncryptedData */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_EncryptedData */ let _cached_encoder_for_EncryptedData = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_EncryptedData */ /* START_OF_SYMBOL_DEFINITION _encode_EncryptedData */ /** * @summary Encodes a(n) EncryptedData 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 EncryptedData, encoded as an ASN.1 Element. */ function _encode_EncryptedData(value, elGetter) { if (!_cached_encoder_for_EncryptedData) { _cached_encoder_for_EncryptedData = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ CMSVersion_ta_1._encode_CMSVersion(value.version, $.BER), /* REQUIRED */ EncryptedContentInfo_ta_1._encode_EncryptedContentInfo(value.encryptedContentInfo, $.BER), /* IF_ABSENT */ value.unprotectedAttrs === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 1, () => UnprotectedAttributes_ta_1._encode_UnprotectedAttributes, $.BER)(value.unprotectedAttrs, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_EncryptedData(value, elGetter); } exports._encode_EncryptedData = _encode_EncryptedData; /* END_OF_SYMBOL_DEFINITION _encode_EncryptedData */ /* eslint-enable */ //# sourceMappingURL=EncryptedData.ta.js.map