UNPKG

@wildboar/pkcs

Version:
272 lines 15.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_SignedAndEnvelopedData = exports._decode_SignedAndEnvelopedData = exports._extension_additions_list_spec_for_SignedAndEnvelopedData = exports._root_component_type_list_2_spec_for_SignedAndEnvelopedData = exports._root_component_type_list_1_spec_for_SignedAndEnvelopedData = exports.SignedAndEnvelopedData = exports._encode_Version = exports._decode_Version = exports._encode_SignerInfo = exports._decode_SignerInfo = exports.SignerInfo = exports._encode_KeyTransportRecipientInfo = exports._decode_KeyTransportRecipientInfo = exports.KeyTransportRecipientInfo = exports._encode_EncryptedContentInfo = exports._decode_EncryptedContentInfo = exports.EncryptedContentInfo = exports._encode_DigestAlgorithmIdentifiers = exports._decode_DigestAlgorithmIdentifiers = exports._encode_CertificateSet = exports._decode_CertificateSet = exports._encode_CertificateRevocationLists = exports._decode_CertificateRevocationLists = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const CertificateRevocationLists_ta_1 = require("../PKCS7/CertificateRevocationLists.ta"); const CertificateSet_ta_1 = require("../PKCS7/CertificateSet.ta"); const DigestAlgorithmIdentifiers_ta_1 = require("../PKCS7/DigestAlgorithmIdentifiers.ta"); const EncryptedContentInfo_ta_1 = require("../PKCS7/EncryptedContentInfo.ta"); const KeyTransportRecipientInfo_ta_1 = require("../PKCS7/KeyTransportRecipientInfo.ta"); const SignerInfo_ta_1 = require("../PKCS7/SignerInfo.ta"); const Version_ta_1 = require("../PKCS7/Version.ta"); var CertificateRevocationLists_ta_2 = require("../PKCS7/CertificateRevocationLists.ta"); Object.defineProperty(exports, "_decode_CertificateRevocationLists", { enumerable: true, get: function () { return CertificateRevocationLists_ta_2._decode_CertificateRevocationLists; } }); Object.defineProperty(exports, "_encode_CertificateRevocationLists", { enumerable: true, get: function () { return CertificateRevocationLists_ta_2._encode_CertificateRevocationLists; } }); var CertificateSet_ta_2 = require("../PKCS7/CertificateSet.ta"); Object.defineProperty(exports, "_decode_CertificateSet", { enumerable: true, get: function () { return CertificateSet_ta_2._decode_CertificateSet; } }); Object.defineProperty(exports, "_encode_CertificateSet", { enumerable: true, get: function () { return CertificateSet_ta_2._encode_CertificateSet; } }); var DigestAlgorithmIdentifiers_ta_2 = require("../PKCS7/DigestAlgorithmIdentifiers.ta"); Object.defineProperty(exports, "_decode_DigestAlgorithmIdentifiers", { enumerable: true, get: function () { return DigestAlgorithmIdentifiers_ta_2._decode_DigestAlgorithmIdentifiers; } }); Object.defineProperty(exports, "_encode_DigestAlgorithmIdentifiers", { enumerable: true, get: function () { return DigestAlgorithmIdentifiers_ta_2._encode_DigestAlgorithmIdentifiers; } }); var EncryptedContentInfo_ta_2 = require("../PKCS7/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 KeyTransportRecipientInfo_ta_2 = require("../PKCS7/KeyTransportRecipientInfo.ta"); Object.defineProperty(exports, "KeyTransportRecipientInfo", { enumerable: true, get: function () { return KeyTransportRecipientInfo_ta_2.KeyTransportRecipientInfo; } }); Object.defineProperty(exports, "_decode_KeyTransportRecipientInfo", { enumerable: true, get: function () { return KeyTransportRecipientInfo_ta_2._decode_KeyTransportRecipientInfo; } }); Object.defineProperty(exports, "_encode_KeyTransportRecipientInfo", { enumerable: true, get: function () { return KeyTransportRecipientInfo_ta_2._encode_KeyTransportRecipientInfo; } }); var SignerInfo_ta_2 = require("../PKCS7/SignerInfo.ta"); Object.defineProperty(exports, "SignerInfo", { enumerable: true, get: function () { return SignerInfo_ta_2.SignerInfo; } }); Object.defineProperty(exports, "_decode_SignerInfo", { enumerable: true, get: function () { return SignerInfo_ta_2._decode_SignerInfo; } }); Object.defineProperty(exports, "_encode_SignerInfo", { enumerable: true, get: function () { return SignerInfo_ta_2._encode_SignerInfo; } }); var Version_ta_2 = require("../PKCS7/Version.ta"); Object.defineProperty(exports, "_decode_Version", { enumerable: true, get: function () { return Version_ta_2._decode_Version; } }); Object.defineProperty(exports, "_encode_Version", { enumerable: true, get: function () { return Version_ta_2._encode_Version; } }); /* START_OF_SYMBOL_DEFINITION SignedAndEnvelopedData */ /** * @summary SignedAndEnvelopedData * @description * * ### ASN.1 Definition: * * ```asn1 * SignedAndEnvelopedData ::= SEQUENCE { * version Version, * recipientInfos SET SIZE (1..MAX) OF KeyTransportRecipientInfo, * digestAlgorithms DigestAlgorithmIdentifiers, * encryptedContentInfo EncryptedContentInfo, * certificates [0] CertificateSet OPTIONAL, * crls [1] CertificateRevocationLists OPTIONAL, * signerInfos * SET SIZE (1..MAX) OF * SignerInfo * (WITH COMPONENTS { * ..., * signerIdentifier (WITH COMPONENTS { * issuerAndSerialNumber PRESENT * }), * authenticatedAttributes ABSENT, * unauthenticatedAttributes ABSENT * }) * } * ``` * * @class */ class SignedAndEnvelopedData { constructor( /** * @summary `version`. * @public * @readonly */ version, /** * @summary `recipientInfos`. * @public * @readonly */ recipientInfos, /** * @summary `digestAlgorithms`. * @public * @readonly */ digestAlgorithms, /** * @summary `encryptedContentInfo`. * @public * @readonly */ encryptedContentInfo, /** * @summary `certificates`. * @public * @readonly */ certificates, /** * @summary `crls`. * @public * @readonly */ crls, /** * @summary `signerInfos`. * @public * @readonly */ signerInfos) { this.version = version; this.recipientInfos = recipientInfos; this.digestAlgorithms = digestAlgorithms; this.encryptedContentInfo = encryptedContentInfo; this.certificates = certificates; this.crls = crls; this.signerInfos = signerInfos; } /** * @summary Restructures an object into a SignedAndEnvelopedData * @description * * This takes an `object` and converts it to a `SignedAndEnvelopedData`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `SignedAndEnvelopedData`. * @returns {SignedAndEnvelopedData} */ static _from_object(_o) { return new SignedAndEnvelopedData(_o.version, _o.recipientInfos, _o.digestAlgorithms, _o.encryptedContentInfo, _o.certificates, _o.crls, _o.signerInfos); } } exports.SignedAndEnvelopedData = SignedAndEnvelopedData; /* END_OF_SYMBOL_DEFINITION SignedAndEnvelopedData */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_SignedAndEnvelopedData */ /** * @summary The Leading Root Component Types of SignedAndEnvelopedData * @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_SignedAndEnvelopedData = [ new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("recipientInfos", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 17), undefined, undefined), new $.ComponentSpec("digestAlgorithms", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 17), undefined, undefined), new $.ComponentSpec("encryptedContentInfo", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("certificates", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), new $.ComponentSpec("crls", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined), new $.ComponentSpec("signerInfos", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 17), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_SignedAndEnvelopedData */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_SignedAndEnvelopedData */ /** * @summary The Trailing Root Component Types of SignedAndEnvelopedData * @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_SignedAndEnvelopedData = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_SignedAndEnvelopedData */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_SignedAndEnvelopedData */ /** * @summary The Extension Addition Component Types of SignedAndEnvelopedData * @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_SignedAndEnvelopedData = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_SignedAndEnvelopedData */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_SignedAndEnvelopedData */ let _cached_decoder_for_SignedAndEnvelopedData = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_SignedAndEnvelopedData */ /* START_OF_SYMBOL_DEFINITION _decode_SignedAndEnvelopedData */ /** * @summary Decodes an ASN.1 element into a(n) SignedAndEnvelopedData * @function * @param {_Element} el The element being decoded. * @returns {SignedAndEnvelopedData} The decoded data structure. */ function _decode_SignedAndEnvelopedData(el) { if (!_cached_decoder_for_SignedAndEnvelopedData) { _cached_decoder_for_SignedAndEnvelopedData = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let version; let recipientInfos; let digestAlgorithms; let encryptedContentInfo; let certificates; let crls; let signerInfos; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { version: (_el) => { version = Version_ta_1._decode_Version(_el); }, recipientInfos: (_el) => { recipientInfos = $._decodeSetOf(() => KeyTransportRecipientInfo_ta_1._decode_KeyTransportRecipientInfo)(_el); }, digestAlgorithms: (_el) => { digestAlgorithms = DigestAlgorithmIdentifiers_ta_1._decode_DigestAlgorithmIdentifiers(_el); }, encryptedContentInfo: (_el) => { encryptedContentInfo = EncryptedContentInfo_ta_1._decode_EncryptedContentInfo(_el); }, certificates: (_el) => { certificates = $._decode_implicit(() => CertificateSet_ta_1._decode_CertificateSet)(_el); }, crls: (_el) => { crls = $._decode_implicit(() => CertificateRevocationLists_ta_1._decode_CertificateRevocationLists)(_el); }, signerInfos: (_el) => { signerInfos = $._decodeSetOf(() => SignerInfo_ta_1._decode_SignerInfo)(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_SignedAndEnvelopedData, exports._extension_additions_list_spec_for_SignedAndEnvelopedData, exports._root_component_type_list_2_spec_for_SignedAndEnvelopedData, undefined); return new SignedAndEnvelopedData( /* SEQUENCE_CONSTRUCTOR_CALL */ version, recipientInfos, digestAlgorithms, encryptedContentInfo, certificates, crls, signerInfos); }; } return _cached_decoder_for_SignedAndEnvelopedData(el); } exports._decode_SignedAndEnvelopedData = _decode_SignedAndEnvelopedData; /* END_OF_SYMBOL_DEFINITION _decode_SignedAndEnvelopedData */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_SignedAndEnvelopedData */ let _cached_encoder_for_SignedAndEnvelopedData = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_SignedAndEnvelopedData */ /* START_OF_SYMBOL_DEFINITION _encode_SignedAndEnvelopedData */ /** * @summary Encodes a(n) SignedAndEnvelopedData 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 SignedAndEnvelopedData, encoded as an ASN.1 Element. */ function _encode_SignedAndEnvelopedData(value, elGetter) { if (!_cached_encoder_for_SignedAndEnvelopedData) { _cached_encoder_for_SignedAndEnvelopedData = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ Version_ta_1._encode_Version(value.version, $.BER), /* REQUIRED */ $._encodeSetOf(() => KeyTransportRecipientInfo_ta_1._encode_KeyTransportRecipientInfo, $.BER)(value.recipientInfos, $.BER), /* REQUIRED */ DigestAlgorithmIdentifiers_ta_1._encode_DigestAlgorithmIdentifiers(value.digestAlgorithms, $.BER), /* REQUIRED */ EncryptedContentInfo_ta_1._encode_EncryptedContentInfo(value.encryptedContentInfo, $.BER), /* IF_ABSENT */ value.certificates === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => CertificateSet_ta_1._encode_CertificateSet, $.BER)(value.certificates, $.BER), /* IF_ABSENT */ value.crls === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 1, () => CertificateRevocationLists_ta_1._encode_CertificateRevocationLists, $.BER)(value.crls, $.BER), /* REQUIRED */ $._encodeSetOf(() => SignerInfo_ta_1._encode_SignerInfo, $.BER)(value.signerInfos, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_SignedAndEnvelopedData(value, elGetter); } exports._encode_SignedAndEnvelopedData = _encode_SignedAndEnvelopedData; /* END_OF_SYMBOL_DEFINITION _encode_SignedAndEnvelopedData */ /* eslint-enable */ //# sourceMappingURL=SignedAndEnvelopedData.ta.js.map