UNPKG

pkcs-ts

Version:

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

99 lines 7.88 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; const tslib_1 = require("tslib"); const asn1_ts_1 = require("asn1-ts"); const $ = tslib_1.__importStar(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; } }); Object.defineProperty(exports, "CMSVersion_v1", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v1; } }); Object.defineProperty(exports, "CMSVersion_v2", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v2; } }); Object.defineProperty(exports, "CMSVersion_v3", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v3; } }); Object.defineProperty(exports, "CMSVersion_v4", { enumerable: true, get: function () { return CMSVersion_ta_2.CMSVersion_v4; } }); Object.defineProperty(exports, "v0", { enumerable: true, get: function () { return CMSVersion_ta_2.v0; } }); Object.defineProperty(exports, "v1", { enumerable: true, get: function () { return CMSVersion_ta_2.v1; } }); Object.defineProperty(exports, "v2", { enumerable: true, get: function () { return CMSVersion_ta_2.v2; } }); Object.defineProperty(exports, "v3", { enumerable: true, get: function () { return CMSVersion_ta_2.v3; } }); Object.defineProperty(exports, "v4", { enumerable: true, get: function () { return CMSVersion_ta_2.v4; } }); 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; } }); class KEKRecipientInfo { constructor(version, kekid, keyEncryptionAlgorithm, encryptedKey) { this.version = version; this.kekid = kekid; this.keyEncryptionAlgorithm = keyEncryptionAlgorithm; this.encryptedKey = encryptedKey; } static _from_object(_o) { return new KEKRecipientInfo(_o.version, _o.kekid, _o.keyEncryptionAlgorithm, _o.encryptedKey); } } exports.KEKRecipientInfo = KEKRecipientInfo; 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), ]; exports._root_component_type_list_2_spec_for_KEKRecipientInfo = []; exports._extension_additions_list_spec_for_KEKRecipientInfo = []; let _cached_decoder_for_KEKRecipientInfo = null; 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; let _cached_encoder_for_KEKRecipientInfo = null; function _encode_KEKRecipientInfo(value, elGetter) { if (!_cached_encoder_for_KEKRecipientInfo) { _cached_encoder_for_KEKRecipientInfo = function (value, elGetter) { return $._encodeSequence([] .concat([ CMSVersion_ta_1._encode_CMSVersion(value.version, $.BER), KEKIdentifier_ta_1._encode_KEKIdentifier(value.kekid, $.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_KEKRecipientInfo(value, elGetter); } exports._encode_KEKRecipientInfo = _encode_KEKRecipientInfo; //# sourceMappingURL=KEKRecipientInfo.ta.js.map