UNPKG

@wildboar/pkcs

Version:
257 lines 13.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_SignerInfo = exports._decode_SignerInfo = exports._extension_additions_list_spec_for_SignerInfo = exports._root_component_type_list_2_spec_for_SignerInfo = exports._root_component_type_list_1_spec_for_SignerInfo = exports.SignerInfo = exports._encode_Version = exports._decode_Version = exports._encode_SignerIdentifier = exports._decode_SignerIdentifier = exports._encode_EncryptedDigest = exports._decode_EncryptedDigest = exports._encode_DigestEncryptionAlgorithmIdentifier = exports._decode_DigestEncryptionAlgorithmIdentifier = exports._encode_DigestAlgorithmIdentifier = exports._decode_DigestAlgorithmIdentifier = exports._encode_Attributes = exports._decode_Attributes = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const Attributes_ta_1 = require("../PKCS7/Attributes.ta"); const DigestAlgorithmIdentifier_ta_1 = require("../PKCS7/DigestAlgorithmIdentifier.ta"); const DigestEncryptionAlgorithmIdentifier_ta_1 = require("../PKCS7/DigestEncryptionAlgorithmIdentifier.ta"); const EncryptedDigest_ta_1 = require("../PKCS7/EncryptedDigest.ta"); const SignerIdentifier_ta_1 = require("../PKCS7/SignerIdentifier.ta"); const Version_ta_1 = require("../PKCS7/Version.ta"); var Attributes_ta_2 = require("../PKCS7/Attributes.ta"); Object.defineProperty(exports, "_decode_Attributes", { enumerable: true, get: function () { return Attributes_ta_2._decode_Attributes; } }); Object.defineProperty(exports, "_encode_Attributes", { enumerable: true, get: function () { return Attributes_ta_2._encode_Attributes; } }); var DigestAlgorithmIdentifier_ta_2 = require("../PKCS7/DigestAlgorithmIdentifier.ta"); Object.defineProperty(exports, "_decode_DigestAlgorithmIdentifier", { enumerable: true, get: function () { return DigestAlgorithmIdentifier_ta_2._decode_DigestAlgorithmIdentifier; } }); Object.defineProperty(exports, "_encode_DigestAlgorithmIdentifier", { enumerable: true, get: function () { return DigestAlgorithmIdentifier_ta_2._encode_DigestAlgorithmIdentifier; } }); var DigestEncryptionAlgorithmIdentifier_ta_2 = require("../PKCS7/DigestEncryptionAlgorithmIdentifier.ta"); Object.defineProperty(exports, "_decode_DigestEncryptionAlgorithmIdentifier", { enumerable: true, get: function () { return DigestEncryptionAlgorithmIdentifier_ta_2._decode_DigestEncryptionAlgorithmIdentifier; } }); Object.defineProperty(exports, "_encode_DigestEncryptionAlgorithmIdentifier", { enumerable: true, get: function () { return DigestEncryptionAlgorithmIdentifier_ta_2._encode_DigestEncryptionAlgorithmIdentifier; } }); var EncryptedDigest_ta_2 = require("../PKCS7/EncryptedDigest.ta"); Object.defineProperty(exports, "_decode_EncryptedDigest", { enumerable: true, get: function () { return EncryptedDigest_ta_2._decode_EncryptedDigest; } }); Object.defineProperty(exports, "_encode_EncryptedDigest", { enumerable: true, get: function () { return EncryptedDigest_ta_2._encode_EncryptedDigest; } }); var SignerIdentifier_ta_2 = require("../PKCS7/SignerIdentifier.ta"); Object.defineProperty(exports, "_decode_SignerIdentifier", { enumerable: true, get: function () { return SignerIdentifier_ta_2._decode_SignerIdentifier; } }); Object.defineProperty(exports, "_encode_SignerIdentifier", { enumerable: true, get: function () { return SignerIdentifier_ta_2._encode_SignerIdentifier; } }); 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 SignerInfo */ /** * @summary SignerInfo * @description * * ### ASN.1 Definition: * * ```asn1 * SignerInfo ::= SEQUENCE { * version Version, * signerIdentifier SignerIdentifier, * digestAlgorithm DigestAlgorithmIdentifier, * authenticatedAttributes [0] Attributes OPTIONAL, * digestEncryptionAlgorithm DigestEncryptionAlgorithmIdentifier, * encryptedDigest EncryptedDigest, * unauthenticatedAttributes [1] Attributes OPTIONAL * } * ``` * * @class */ class SignerInfo { constructor( /** * @summary `version`. * @public * @readonly */ version, /** * @summary `signerIdentifier`. * @public * @readonly */ signerIdentifier, /** * @summary `digestAlgorithm`. * @public * @readonly */ digestAlgorithm, /** * @summary `authenticatedAttributes`. * @public * @readonly */ authenticatedAttributes, /** * @summary `digestEncryptionAlgorithm`. * @public * @readonly */ digestEncryptionAlgorithm, /** * @summary `encryptedDigest`. * @public * @readonly */ encryptedDigest, /** * @summary `unauthenticatedAttributes`. * @public * @readonly */ unauthenticatedAttributes) { this.version = version; this.signerIdentifier = signerIdentifier; this.digestAlgorithm = digestAlgorithm; this.authenticatedAttributes = authenticatedAttributes; this.digestEncryptionAlgorithm = digestEncryptionAlgorithm; this.encryptedDigest = encryptedDigest; this.unauthenticatedAttributes = unauthenticatedAttributes; } /** * @summary Restructures an object into a SignerInfo * @description * * This takes an `object` and converts it to a `SignerInfo`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `SignerInfo`. * @returns {SignerInfo} */ static _from_object(_o) { return new SignerInfo(_o.version, _o.signerIdentifier, _o.digestAlgorithm, _o.authenticatedAttributes, _o.digestEncryptionAlgorithm, _o.encryptedDigest, _o.unauthenticatedAttributes); } } exports.SignerInfo = SignerInfo; /* END_OF_SYMBOL_DEFINITION SignerInfo */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_SignerInfo */ /** * @summary The Leading Root Component Types of SignerInfo * @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_SignerInfo = [ new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("signerIdentifier", false, $.hasAnyTag, undefined, undefined), new $.ComponentSpec("digestAlgorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("authenticatedAttributes", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), new $.ComponentSpec("digestEncryptionAlgorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("encryptedDigest", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined), new $.ComponentSpec("unauthenticatedAttributes", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_SignerInfo */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_SignerInfo */ /** * @summary The Trailing Root Component Types of SignerInfo * @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_SignerInfo = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_SignerInfo */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_SignerInfo */ /** * @summary The Extension Addition Component Types of SignerInfo * @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_SignerInfo = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_SignerInfo */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_SignerInfo */ let _cached_decoder_for_SignerInfo = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_SignerInfo */ /* START_OF_SYMBOL_DEFINITION _decode_SignerInfo */ /** * @summary Decodes an ASN.1 element into a(n) SignerInfo * @function * @param {_Element} el The element being decoded. * @returns {SignerInfo} The decoded data structure. */ function _decode_SignerInfo(el) { if (!_cached_decoder_for_SignerInfo) { _cached_decoder_for_SignerInfo = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let version; let signerIdentifier; let digestAlgorithm; let authenticatedAttributes; let digestEncryptionAlgorithm; let encryptedDigest; let unauthenticatedAttributes; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { version: (_el) => { version = Version_ta_1._decode_Version(_el); }, signerIdentifier: (_el) => { signerIdentifier = SignerIdentifier_ta_1._decode_SignerIdentifier(_el); }, digestAlgorithm: (_el) => { digestAlgorithm = DigestAlgorithmIdentifier_ta_1._decode_DigestAlgorithmIdentifier(_el); }, authenticatedAttributes: (_el) => { authenticatedAttributes = $._decode_implicit(() => Attributes_ta_1._decode_Attributes)(_el); }, digestEncryptionAlgorithm: (_el) => { digestEncryptionAlgorithm = DigestEncryptionAlgorithmIdentifier_ta_1._decode_DigestEncryptionAlgorithmIdentifier(_el); }, encryptedDigest: (_el) => { encryptedDigest = EncryptedDigest_ta_1._decode_EncryptedDigest(_el); }, unauthenticatedAttributes: (_el) => { unauthenticatedAttributes = $._decode_implicit(() => Attributes_ta_1._decode_Attributes)(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_SignerInfo, exports._extension_additions_list_spec_for_SignerInfo, exports._root_component_type_list_2_spec_for_SignerInfo, undefined); return new SignerInfo( /* SEQUENCE_CONSTRUCTOR_CALL */ version, signerIdentifier, digestAlgorithm, authenticatedAttributes, digestEncryptionAlgorithm, encryptedDigest, unauthenticatedAttributes); }; } return _cached_decoder_for_SignerInfo(el); } exports._decode_SignerInfo = _decode_SignerInfo; /* END_OF_SYMBOL_DEFINITION _decode_SignerInfo */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_SignerInfo */ let _cached_encoder_for_SignerInfo = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_SignerInfo */ /* START_OF_SYMBOL_DEFINITION _encode_SignerInfo */ /** * @summary Encodes a(n) SignerInfo 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 SignerInfo, encoded as an ASN.1 Element. */ function _encode_SignerInfo(value, elGetter) { if (!_cached_encoder_for_SignerInfo) { _cached_encoder_for_SignerInfo = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ Version_ta_1._encode_Version(value.version, $.BER), /* REQUIRED */ SignerIdentifier_ta_1._encode_SignerIdentifier(value.signerIdentifier, $.BER), /* REQUIRED */ DigestAlgorithmIdentifier_ta_1._encode_DigestAlgorithmIdentifier(value.digestAlgorithm, $.BER), /* IF_ABSENT */ value.authenticatedAttributes === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => Attributes_ta_1._encode_Attributes, $.BER)(value.authenticatedAttributes, $.BER), /* REQUIRED */ DigestEncryptionAlgorithmIdentifier_ta_1._encode_DigestEncryptionAlgorithmIdentifier(value.digestEncryptionAlgorithm, $.BER), /* REQUIRED */ EncryptedDigest_ta_1._encode_EncryptedDigest(value.encryptedDigest, $.BER), /* IF_ABSENT */ value.unauthenticatedAttributes === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 1, () => Attributes_ta_1._encode_Attributes, $.BER)(value.unauthenticatedAttributes, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_SignerInfo(value, elGetter); } exports._encode_SignerInfo = _encode_SignerInfo; /* END_OF_SYMBOL_DEFINITION _encode_SignerInfo */ /* eslint-enable */ //# sourceMappingURL=SignerInfo.ta.js.map