UNPKG

@wildboar/pkcs

Version:
206 lines 11.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_KEKRecipientInfo = exports._decode_KEKRecipientInfo = exports._extension_additions_list_spec_for_KEKRecipientInfo = exports._root_component_type_list_2_spec_for_KEKRecipientInfo = exports._root_component_type_list_1_spec_for_KEKRecipientInfo = exports.KEKRecipientInfo = exports._encode_KeyEncryptionAlgorithmIdentifier = exports._decode_KeyEncryptionAlgorithmIdentifier = exports._encode_KEKIdentifier = exports._decode_KEKIdentifier = exports.KEKIdentifier = exports._encode_EncryptedKey = exports._decode_EncryptedKey = 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 EncryptedKey_ta_1 = require("../CryptographicMessageSyntax/EncryptedKey.ta"); const KEKIdentifier_ta_1 = require("../CryptographicMessageSyntax/KEKIdentifier.ta"); const KeyEncryptionAlgorithmIdentifier_ta_1 = require("../CryptographicMessageSyntax/KeyEncryptionAlgorithmIdentifier.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 EncryptedKey_ta_2 = require("../CryptographicMessageSyntax/EncryptedKey.ta"); Object.defineProperty(exports, "_decode_EncryptedKey", { enumerable: true, get: function () { return EncryptedKey_ta_2._decode_EncryptedKey; } }); Object.defineProperty(exports, "_encode_EncryptedKey", { enumerable: true, get: function () { return EncryptedKey_ta_2._encode_EncryptedKey; } }); var KEKIdentifier_ta_2 = require("../CryptographicMessageSyntax/KEKIdentifier.ta"); Object.defineProperty(exports, "KEKIdentifier", { enumerable: true, get: function () { return KEKIdentifier_ta_2.KEKIdentifier; } }); Object.defineProperty(exports, "_decode_KEKIdentifier", { enumerable: true, get: function () { return KEKIdentifier_ta_2._decode_KEKIdentifier; } }); Object.defineProperty(exports, "_encode_KEKIdentifier", { enumerable: true, get: function () { return KEKIdentifier_ta_2._encode_KEKIdentifier; } }); var KeyEncryptionAlgorithmIdentifier_ta_2 = require("../CryptographicMessageSyntax/KeyEncryptionAlgorithmIdentifier.ta"); Object.defineProperty(exports, "_decode_KeyEncryptionAlgorithmIdentifier", { enumerable: true, get: function () { return KeyEncryptionAlgorithmIdentifier_ta_2._decode_KeyEncryptionAlgorithmIdentifier; } }); Object.defineProperty(exports, "_encode_KeyEncryptionAlgorithmIdentifier", { enumerable: true, get: function () { return KeyEncryptionAlgorithmIdentifier_ta_2._encode_KeyEncryptionAlgorithmIdentifier; } }); /* START_OF_SYMBOL_DEFINITION KEKRecipientInfo */ /** * @summary KEKRecipientInfo * @description * * ### ASN.1 Definition: * * ```asn1 * KEKRecipientInfo ::= SEQUENCE { * version CMSVersion, -- always set to 4 * kekid KEKIdentifier, * keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier, * encryptedKey EncryptedKey * } * ``` * * @class */ class KEKRecipientInfo { constructor( /** * @summary `version`. * @public * @readonly */ version, /** * @summary `kekid`. * @public * @readonly */ kekid, /** * @summary `keyEncryptionAlgorithm`. * @public * @readonly */ keyEncryptionAlgorithm, /** * @summary `encryptedKey`. * @public * @readonly */ encryptedKey) { this.version = version; this.kekid = kekid; this.keyEncryptionAlgorithm = keyEncryptionAlgorithm; this.encryptedKey = encryptedKey; } /** * @summary Restructures an object into a KEKRecipientInfo * @description * * This takes an `object` and converts it to a `KEKRecipientInfo`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `KEKRecipientInfo`. * @returns {KEKRecipientInfo} */ static _from_object(_o) { return new KEKRecipientInfo(_o.version, _o.kekid, _o.keyEncryptionAlgorithm, _o.encryptedKey); } } exports.KEKRecipientInfo = KEKRecipientInfo; /* END_OF_SYMBOL_DEFINITION KEKRecipientInfo */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_KEKRecipientInfo */ /** * @summary The Leading Root Component Types of KEKRecipientInfo * @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_KEKRecipientInfo = [ new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("kekid", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("keyEncryptionAlgorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("encryptedKey", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_KEKRecipientInfo */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_KEKRecipientInfo */ /** * @summary The Trailing Root Component Types of KEKRecipientInfo * @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_KEKRecipientInfo = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_KEKRecipientInfo */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_KEKRecipientInfo */ /** * @summary The Extension Addition Component Types of KEKRecipientInfo * @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_KEKRecipientInfo = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_KEKRecipientInfo */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_KEKRecipientInfo */ let _cached_decoder_for_KEKRecipientInfo = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_KEKRecipientInfo */ /* START_OF_SYMBOL_DEFINITION _decode_KEKRecipientInfo */ /** * @summary Decodes an ASN.1 element into a(n) KEKRecipientInfo * @function * @param {_Element} el The element being decoded. * @returns {KEKRecipientInfo} The decoded data structure. */ function _decode_KEKRecipientInfo(el) { if (!_cached_decoder_for_KEKRecipientInfo) { _cached_decoder_for_KEKRecipientInfo = function (el) { const sequence = el.sequence; if (sequence.length < 4) { throw new asn1_ts_1.ASN1ConstructionError("KEKRecipientInfo contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "version"; sequence[1].name = "kekid"; sequence[2].name = "keyEncryptionAlgorithm"; sequence[3].name = "encryptedKey"; let version; let kekid; let keyEncryptionAlgorithm; let encryptedKey; version = CMSVersion_ta_1._decode_CMSVersion(sequence[0]); kekid = KEKIdentifier_ta_1._decode_KEKIdentifier(sequence[1]); keyEncryptionAlgorithm = KeyEncryptionAlgorithmIdentifier_ta_1._decode_KeyEncryptionAlgorithmIdentifier(sequence[2]); encryptedKey = EncryptedKey_ta_1._decode_EncryptedKey(sequence[3]); return new KEKRecipientInfo(version, kekid, keyEncryptionAlgorithm, encryptedKey); }; } return _cached_decoder_for_KEKRecipientInfo(el); } exports._decode_KEKRecipientInfo = _decode_KEKRecipientInfo; /* END_OF_SYMBOL_DEFINITION _decode_KEKRecipientInfo */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_KEKRecipientInfo */ let _cached_encoder_for_KEKRecipientInfo = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_KEKRecipientInfo */ /* START_OF_SYMBOL_DEFINITION _encode_KEKRecipientInfo */ /** * @summary Encodes a(n) KEKRecipientInfo 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 KEKRecipientInfo, encoded as an ASN.1 Element. */ function _encode_KEKRecipientInfo(value, elGetter) { if (!_cached_encoder_for_KEKRecipientInfo) { _cached_encoder_for_KEKRecipientInfo = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ CMSVersion_ta_1._encode_CMSVersion(value.version, $.BER), /* REQUIRED */ KEKIdentifier_ta_1._encode_KEKIdentifier(value.kekid, $.BER), /* REQUIRED */ KeyEncryptionAlgorithmIdentifier_ta_1._encode_KeyEncryptionAlgorithmIdentifier(value.keyEncryptionAlgorithm, $.BER), /* REQUIRED */ EncryptedKey_ta_1._encode_EncryptedKey(value.encryptedKey, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_KEKRecipientInfo(value, elGetter); } exports._encode_KEKRecipientInfo = _encode_KEKRecipientInfo; /* END_OF_SYMBOL_DEFINITION _encode_KEKRecipientInfo */ /* eslint-enable */ //# sourceMappingURL=KEKRecipientInfo.ta.js.map