UNPKG

pkcs-ts

Version:

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

68 lines 4.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_EncryptedPrivateKeyInfo = exports._decode_EncryptedPrivateKeyInfo = exports._extension_additions_list_spec_for_EncryptedPrivateKeyInfo = exports._root_component_type_list_2_spec_for_EncryptedPrivateKeyInfo = exports._root_component_type_list_1_spec_for_EncryptedPrivateKeyInfo = exports.EncryptedPrivateKeyInfo = exports._encode_EncryptionAlgorithmIdentifier = exports._decode_EncryptionAlgorithmIdentifier = exports._encode_EncryptedData = exports._decode_EncryptedData = 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 EncryptedData_ta_1 = require("../AsymmetricKeyPackageModuleV1/EncryptedData.ta"); const EncryptionAlgorithmIdentifier_ta_1 = require("../AsymmetricKeyPackageModuleV1/EncryptionAlgorithmIdentifier.ta"); var EncryptedData_ta_2 = require("../AsymmetricKeyPackageModuleV1/EncryptedData.ta"); Object.defineProperty(exports, "_decode_EncryptedData", { enumerable: true, get: function () { return EncryptedData_ta_2._decode_EncryptedData; } }); Object.defineProperty(exports, "_encode_EncryptedData", { enumerable: true, get: function () { return EncryptedData_ta_2._encode_EncryptedData; } }); var EncryptionAlgorithmIdentifier_ta_2 = require("../AsymmetricKeyPackageModuleV1/EncryptionAlgorithmIdentifier.ta"); Object.defineProperty(exports, "_decode_EncryptionAlgorithmIdentifier", { enumerable: true, get: function () { return EncryptionAlgorithmIdentifier_ta_2._decode_EncryptionAlgorithmIdentifier; } }); Object.defineProperty(exports, "_encode_EncryptionAlgorithmIdentifier", { enumerable: true, get: function () { return EncryptionAlgorithmIdentifier_ta_2._encode_EncryptionAlgorithmIdentifier; } }); class EncryptedPrivateKeyInfo { constructor(encryptionAlgorithm, encryptedData) { this.encryptionAlgorithm = encryptionAlgorithm; this.encryptedData = encryptedData; } static _from_object(_o) { return new EncryptedPrivateKeyInfo(_o.encryptionAlgorithm, _o.encryptedData); } } exports.EncryptedPrivateKeyInfo = EncryptedPrivateKeyInfo; exports._root_component_type_list_1_spec_for_EncryptedPrivateKeyInfo = [ new $.ComponentSpec("encryptionAlgorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("encryptedData", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined), ]; exports._root_component_type_list_2_spec_for_EncryptedPrivateKeyInfo = []; exports._extension_additions_list_spec_for_EncryptedPrivateKeyInfo = []; let _cached_decoder_for_EncryptedPrivateKeyInfo = null; function _decode_EncryptedPrivateKeyInfo(el) { if (!_cached_decoder_for_EncryptedPrivateKeyInfo) { _cached_decoder_for_EncryptedPrivateKeyInfo = function (el) { const sequence = el.sequence; if (sequence.length < 2) { throw new asn1_ts_1.ASN1ConstructionError("EncryptedPrivateKeyInfo contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "encryptionAlgorithm"; sequence[1].name = "encryptedData"; let encryptionAlgorithm; let encryptedData; encryptionAlgorithm = EncryptionAlgorithmIdentifier_ta_1._decode_EncryptionAlgorithmIdentifier(sequence[0]); encryptedData = EncryptedData_ta_1._decode_EncryptedData(sequence[1]); return new EncryptedPrivateKeyInfo(encryptionAlgorithm, encryptedData); }; } return _cached_decoder_for_EncryptedPrivateKeyInfo(el); } exports._decode_EncryptedPrivateKeyInfo = _decode_EncryptedPrivateKeyInfo; let _cached_encoder_for_EncryptedPrivateKeyInfo = null; function _encode_EncryptedPrivateKeyInfo(value, elGetter) { if (!_cached_encoder_for_EncryptedPrivateKeyInfo) { _cached_encoder_for_EncryptedPrivateKeyInfo = function (value, elGetter) { return $._encodeSequence([] .concat([ EncryptionAlgorithmIdentifier_ta_1._encode_EncryptionAlgorithmIdentifier(value.encryptionAlgorithm, $.BER), EncryptedData_ta_1._encode_EncryptedData(value.encryptedData, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_EncryptedPrivateKeyInfo(value, elGetter); } exports._encode_EncryptedPrivateKeyInfo = _encode_EncryptedPrivateKeyInfo; //# sourceMappingURL=EncryptedPrivateKeyInfo.ta.js.map