UNPKG

pkcs-ts

Version:

PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More

89 lines 7.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_KeyEncryptionKeyRecipientInfo = exports._decode_KeyEncryptionKeyRecipientInfo = exports._extension_additions_list_spec_for_KeyEncryptionKeyRecipientInfo = exports._root_component_type_list_2_spec_for_KeyEncryptionKeyRecipientInfo = exports._root_component_type_list_1_spec_for_KeyEncryptionKeyRecipientInfo = exports.KeyEncryptionKeyRecipientInfo = exports._encode_Version = exports._decode_Version = exports._encode_KeyEncryptionKeyIdentifier = exports._decode_KeyEncryptionKeyIdentifier = exports.KeyEncryptionKeyIdentifier = exports._encode_KeyEncryptionAlgorithmIdentifier = exports._decode_KeyEncryptionAlgorithmIdentifier = exports._encode_EncryptedKey = exports._decode_EncryptedKey = void 0; const tslib_1 = require("tslib"); const asn1_ts_1 = require("asn1-ts"); const $ = tslib_1.__importStar(require("asn1-ts/dist/node/functional")); const EncryptedKey_ta_1 = require("../PKCS7/EncryptedKey.ta"); const KeyEncryptionAlgorithmIdentifier_ta_1 = require("../PKCS7/KeyEncryptionAlgorithmIdentifier.ta"); const KeyEncryptionKeyIdentifier_ta_1 = require("../PKCS7/KeyEncryptionKeyIdentifier.ta"); const Version_ta_1 = require("../PKCS7/Version.ta"); var EncryptedKey_ta_2 = require("../PKCS7/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 KeyEncryptionAlgorithmIdentifier_ta_2 = require("../PKCS7/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; } }); var KeyEncryptionKeyIdentifier_ta_2 = require("../PKCS7/KeyEncryptionKeyIdentifier.ta"); Object.defineProperty(exports, "KeyEncryptionKeyIdentifier", { enumerable: true, get: function () { return KeyEncryptionKeyIdentifier_ta_2.KeyEncryptionKeyIdentifier; } }); Object.defineProperty(exports, "_decode_KeyEncryptionKeyIdentifier", { enumerable: true, get: function () { return KeyEncryptionKeyIdentifier_ta_2._decode_KeyEncryptionKeyIdentifier; } }); Object.defineProperty(exports, "_encode_KeyEncryptionKeyIdentifier", { enumerable: true, get: function () { return KeyEncryptionKeyIdentifier_ta_2._encode_KeyEncryptionKeyIdentifier; } }); 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; } }); class KeyEncryptionKeyRecipientInfo { constructor(version, keyEncryptionKeyIdentifier, keyEncryptionAlgorithm, encryptedKey) { this.version = version; this.keyEncryptionKeyIdentifier = keyEncryptionKeyIdentifier; this.keyEncryptionAlgorithm = keyEncryptionAlgorithm; this.encryptedKey = encryptedKey; } static _from_object(_o) { return new KeyEncryptionKeyRecipientInfo(_o.version, _o.keyEncryptionKeyIdentifier, _o.keyEncryptionAlgorithm, _o.encryptedKey); } } exports.KeyEncryptionKeyRecipientInfo = KeyEncryptionKeyRecipientInfo; exports._root_component_type_list_1_spec_for_KeyEncryptionKeyRecipientInfo = [ new $.ComponentSpec("version", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("keyEncryptionKeyIdentifier", 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), ]; exports._root_component_type_list_2_spec_for_KeyEncryptionKeyRecipientInfo = []; exports._extension_additions_list_spec_for_KeyEncryptionKeyRecipientInfo = []; let _cached_decoder_for_KeyEncryptionKeyRecipientInfo = null; function _decode_KeyEncryptionKeyRecipientInfo(el) { if (!_cached_decoder_for_KeyEncryptionKeyRecipientInfo) { _cached_decoder_for_KeyEncryptionKeyRecipientInfo = function (el) { const sequence = el.sequence; if (sequence.length < 4) { throw new asn1_ts_1.ASN1ConstructionError("KeyEncryptionKeyRecipientInfo contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "version"; sequence[1].name = "keyEncryptionKeyIdentifier"; sequence[2].name = "keyEncryptionAlgorithm"; sequence[3].name = "encryptedKey"; let version; let keyEncryptionKeyIdentifier; let keyEncryptionAlgorithm; let encryptedKey; version = Version_ta_1._decode_Version(sequence[0]); keyEncryptionKeyIdentifier = KeyEncryptionKeyIdentifier_ta_1._decode_KeyEncryptionKeyIdentifier(sequence[1]); keyEncryptionAlgorithm = KeyEncryptionAlgorithmIdentifier_ta_1._decode_KeyEncryptionAlgorithmIdentifier(sequence[2]); encryptedKey = EncryptedKey_ta_1._decode_EncryptedKey(sequence[3]); return new KeyEncryptionKeyRecipientInfo(version, keyEncryptionKeyIdentifier, keyEncryptionAlgorithm, encryptedKey); }; } return _cached_decoder_for_KeyEncryptionKeyRecipientInfo(el); } exports._decode_KeyEncryptionKeyRecipientInfo = _decode_KeyEncryptionKeyRecipientInfo; let _cached_encoder_for_KeyEncryptionKeyRecipientInfo = null; function _encode_KeyEncryptionKeyRecipientInfo(value, elGetter) { if (!_cached_encoder_for_KeyEncryptionKeyRecipientInfo) { _cached_encoder_for_KeyEncryptionKeyRecipientInfo = function (value, elGetter) { return $._encodeSequence([] .concat([ Version_ta_1._encode_Version(value.version, $.BER), KeyEncryptionKeyIdentifier_ta_1._encode_KeyEncryptionKeyIdentifier(value.keyEncryptionKeyIdentifier, $.BER), KeyEncryptionAlgorithmIdentifier_ta_1._encode_KeyEncryptionAlgorithmIdentifier(value.keyEncryptionAlgorithm, $.BER), EncryptedKey_ta_1._encode_EncryptedKey(value.encryptedKey, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_KeyEncryptionKeyRecipientInfo(value, elGetter); } exports._encode_KeyEncryptionKeyRecipientInfo = _encode_KeyEncryptionKeyRecipientInfo; //# sourceMappingURL=KeyEncryptionKeyRecipientInfo.ta.js.map