UNPKG

@wildboar/pkcs

Version:
269 lines 15.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_UnsignedAttributes = exports._decode_UnsignedAttributes = exports._encode_SignerIdentifier = exports._decode_SignerIdentifier = exports._encode_SignedAttributes = exports._decode_SignedAttributes = exports._encode_SignatureValue = exports._decode_SignatureValue = exports._encode_SignatureAlgorithmIdentifier = exports._decode_SignatureAlgorithmIdentifier = exports._encode_DigestAlgorithmIdentifier = exports._decode_DigestAlgorithmIdentifier = 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 DigestAlgorithmIdentifier_ta_1 = require("../CryptographicMessageSyntax/DigestAlgorithmIdentifier.ta"); const SignatureAlgorithmIdentifier_ta_1 = require("../CryptographicMessageSyntax/SignatureAlgorithmIdentifier.ta"); const SignatureValue_ta_1 = require("../CryptographicMessageSyntax/SignatureValue.ta"); const SignedAttributes_ta_1 = require("../CryptographicMessageSyntax/SignedAttributes.ta"); const SignerIdentifier_ta_1 = require("../CryptographicMessageSyntax/SignerIdentifier.ta"); const UnsignedAttributes_ta_1 = require("../CryptographicMessageSyntax/UnsignedAttributes.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 DigestAlgorithmIdentifier_ta_2 = require("../CryptographicMessageSyntax/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 SignatureAlgorithmIdentifier_ta_2 = require("../CryptographicMessageSyntax/SignatureAlgorithmIdentifier.ta"); Object.defineProperty(exports, "_decode_SignatureAlgorithmIdentifier", { enumerable: true, get: function () { return SignatureAlgorithmIdentifier_ta_2._decode_SignatureAlgorithmIdentifier; } }); Object.defineProperty(exports, "_encode_SignatureAlgorithmIdentifier", { enumerable: true, get: function () { return SignatureAlgorithmIdentifier_ta_2._encode_SignatureAlgorithmIdentifier; } }); var SignatureValue_ta_2 = require("../CryptographicMessageSyntax/SignatureValue.ta"); Object.defineProperty(exports, "_decode_SignatureValue", { enumerable: true, get: function () { return SignatureValue_ta_2._decode_SignatureValue; } }); Object.defineProperty(exports, "_encode_SignatureValue", { enumerable: true, get: function () { return SignatureValue_ta_2._encode_SignatureValue; } }); var SignedAttributes_ta_2 = require("../CryptographicMessageSyntax/SignedAttributes.ta"); Object.defineProperty(exports, "_decode_SignedAttributes", { enumerable: true, get: function () { return SignedAttributes_ta_2._decode_SignedAttributes; } }); Object.defineProperty(exports, "_encode_SignedAttributes", { enumerable: true, get: function () { return SignedAttributes_ta_2._encode_SignedAttributes; } }); var SignerIdentifier_ta_2 = require("../CryptographicMessageSyntax/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 UnsignedAttributes_ta_2 = require("../CryptographicMessageSyntax/UnsignedAttributes.ta"); Object.defineProperty(exports, "_decode_UnsignedAttributes", { enumerable: true, get: function () { return UnsignedAttributes_ta_2._decode_UnsignedAttributes; } }); Object.defineProperty(exports, "_encode_UnsignedAttributes", { enumerable: true, get: function () { return UnsignedAttributes_ta_2._encode_UnsignedAttributes; } }); /* START_OF_SYMBOL_DEFINITION SignerInfo */ /** * @summary SignerInfo * @description * * ### ASN.1 Definition: * * ```asn1 * SignerInfo ::= SEQUENCE { * version CMSVersion, * sid SignerIdentifier, * digestAlgorithm DigestAlgorithmIdentifier, * signedAttrs [0] IMPLICIT SignedAttributes OPTIONAL, * signatureAlgorithm SignatureAlgorithmIdentifier, * signature SignatureValue, * unsignedAttrs [1] IMPLICIT UnsignedAttributes OPTIONAL * } * ``` * * @class */ class SignerInfo { constructor( /** * @summary `version`. * @public * @readonly */ version, /** * @summary `sid`. * @public * @readonly */ sid, /** * @summary `digestAlgorithm`. * @public * @readonly */ digestAlgorithm, /** * @summary `signedAttrs`. * @public * @readonly */ signedAttrs, /** * @summary `signatureAlgorithm`. * @public * @readonly */ signatureAlgorithm, /** * @summary `signature`. * @public * @readonly */ signature, /** * @summary `unsignedAttrs`. * @public * @readonly */ unsignedAttrs) { this.version = version; this.sid = sid; this.digestAlgorithm = digestAlgorithm; this.signedAttrs = signedAttrs; this.signatureAlgorithm = signatureAlgorithm; this.signature = signature; this.unsignedAttrs = unsignedAttrs; } /** * @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.sid, _o.digestAlgorithm, _o.signedAttrs, _o.signatureAlgorithm, _o.signature, _o.unsignedAttrs); } } 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("sid", false, $.hasAnyTag, undefined, undefined), new $.ComponentSpec("digestAlgorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("signedAttrs", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), new $.ComponentSpec("signatureAlgorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("signature", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined), new $.ComponentSpec("unsignedAttrs", 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 sid; let digestAlgorithm; let signedAttrs; let signatureAlgorithm; let signature; let unsignedAttrs; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { version: (_el) => { version = CMSVersion_ta_1._decode_CMSVersion(_el); }, sid: (_el) => { sid = SignerIdentifier_ta_1._decode_SignerIdentifier(_el); }, digestAlgorithm: (_el) => { digestAlgorithm = DigestAlgorithmIdentifier_ta_1._decode_DigestAlgorithmIdentifier(_el); }, signedAttrs: (_el) => { signedAttrs = $._decode_implicit(() => SignedAttributes_ta_1._decode_SignedAttributes)(_el); }, signatureAlgorithm: (_el) => { signatureAlgorithm = SignatureAlgorithmIdentifier_ta_1._decode_SignatureAlgorithmIdentifier(_el); }, signature: (_el) => { signature = SignatureValue_ta_1._decode_SignatureValue(_el); }, unsignedAttrs: (_el) => { unsignedAttrs = $._decode_implicit(() => UnsignedAttributes_ta_1._decode_UnsignedAttributes)(_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, sid, digestAlgorithm, signedAttrs, signatureAlgorithm, signature, unsignedAttrs); }; } 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 */ CMSVersion_ta_1._encode_CMSVersion(value.version, $.BER), /* REQUIRED */ SignerIdentifier_ta_1._encode_SignerIdentifier(value.sid, $.BER), /* REQUIRED */ DigestAlgorithmIdentifier_ta_1._encode_DigestAlgorithmIdentifier(value.digestAlgorithm, $.BER), /* IF_ABSENT */ value.signedAttrs === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => SignedAttributes_ta_1._encode_SignedAttributes, $.BER)(value.signedAttrs, $.BER), /* REQUIRED */ SignatureAlgorithmIdentifier_ta_1._encode_SignatureAlgorithmIdentifier(value.signatureAlgorithm, $.BER), /* REQUIRED */ SignatureValue_ta_1._encode_SignatureValue(value.signature, $.BER), /* IF_ABSENT */ value.unsignedAttrs === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 1, () => UnsignedAttributes_ta_1._encode_UnsignedAttributes, $.BER)(value.unsignedAttrs, $.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