@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
160 lines • 7.92 kB
JavaScript
;
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;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = 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; } });
/* START_OF_SYMBOL_DEFINITION EncryptedPrivateKeyInfo */
/**
* @summary EncryptedPrivateKeyInfo
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* EncryptedPrivateKeyInfo ::= SEQUENCE {
* encryptionAlgorithm EncryptionAlgorithmIdentifier,
* encryptedData EncryptedData }
* ```
*
* @class
*/
class EncryptedPrivateKeyInfo {
constructor(
/**
* @summary `encryptionAlgorithm`.
* @public
* @readonly
*/
encryptionAlgorithm,
/**
* @summary `encryptedData`.
* @public
* @readonly
*/
encryptedData) {
this.encryptionAlgorithm = encryptionAlgorithm;
this.encryptedData = encryptedData;
}
/**
* @summary Restructures an object into a EncryptedPrivateKeyInfo
* @description
*
* This takes an `object` and converts it to a `EncryptedPrivateKeyInfo`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `EncryptedPrivateKeyInfo`.
* @returns {EncryptedPrivateKeyInfo}
*/
static _from_object(_o) {
return new EncryptedPrivateKeyInfo(_o.encryptionAlgorithm, _o.encryptedData);
}
}
exports.EncryptedPrivateKeyInfo = EncryptedPrivateKeyInfo;
/* END_OF_SYMBOL_DEFINITION EncryptedPrivateKeyInfo */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_EncryptedPrivateKeyInfo */
/**
* @summary The Leading Root Component Types of EncryptedPrivateKeyInfo
* @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_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),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_EncryptedPrivateKeyInfo */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_EncryptedPrivateKeyInfo */
/**
* @summary The Trailing Root Component Types of EncryptedPrivateKeyInfo
* @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_EncryptedPrivateKeyInfo = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_EncryptedPrivateKeyInfo */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_EncryptedPrivateKeyInfo */
/**
* @summary The Extension Addition Component Types of EncryptedPrivateKeyInfo
* @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_EncryptedPrivateKeyInfo = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_EncryptedPrivateKeyInfo */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_EncryptedPrivateKeyInfo */
let _cached_decoder_for_EncryptedPrivateKeyInfo = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_EncryptedPrivateKeyInfo */
/* START_OF_SYMBOL_DEFINITION _decode_EncryptedPrivateKeyInfo */
/**
* @summary Decodes an ASN.1 element into a(n) EncryptedPrivateKeyInfo
* @function
* @param {_Element} el The element being decoded.
* @returns {EncryptedPrivateKeyInfo} The decoded data structure.
*/
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;
/* END_OF_SYMBOL_DEFINITION _decode_EncryptedPrivateKeyInfo */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_EncryptedPrivateKeyInfo */
let _cached_encoder_for_EncryptedPrivateKeyInfo = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_EncryptedPrivateKeyInfo */
/* START_OF_SYMBOL_DEFINITION _encode_EncryptedPrivateKeyInfo */
/**
* @summary Encodes a(n) EncryptedPrivateKeyInfo 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 EncryptedPrivateKeyInfo, encoded as an ASN.1 Element.
*/
function _encode_EncryptedPrivateKeyInfo(value, elGetter) {
if (!_cached_encoder_for_EncryptedPrivateKeyInfo) {
_cached_encoder_for_EncryptedPrivateKeyInfo = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ EncryptionAlgorithmIdentifier_ta_1._encode_EncryptionAlgorithmIdentifier(value.encryptionAlgorithm, $.BER),
/* REQUIRED */ EncryptedData_ta_1._encode_EncryptedData(value.encryptedData, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_EncryptedPrivateKeyInfo(value, elGetter);
}
exports._encode_EncryptedPrivateKeyInfo = _encode_EncryptedPrivateKeyInfo;
/* END_OF_SYMBOL_DEFINITION _encode_EncryptedPrivateKeyInfo */
/* eslint-enable */
//# sourceMappingURL=EncryptedPrivateKeyInfo.ta.js.map