UNPKG

@wildboar/pkcs

Version:
203 lines 10.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_PrivateRSAKeyAttributes = exports._decode_PrivateRSAKeyAttributes = exports._extension_additions_list_spec_for_PrivateRSAKeyAttributes = exports._root_component_type_list_2_spec_for_PrivateRSAKeyAttributes = exports._root_component_type_list_1_spec_for_PrivateRSAKeyAttributes = exports.PrivateRSAKeyAttributes = exports._encode_RSAPrivateKeyObject = exports._decode_RSAPrivateKeyObject = exports.RSAPrivateKeyObject = exports._encode_PublicKeyOperations = exports._decode_PublicKeyOperations = exports._get_encoder_for_ObjectValue = exports._get_decoder_for_ObjectValue = exports._get_encoder_for_KeyInfo = exports._get_decoder_for_KeyInfo = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const KeyInfo_ta_1 = require("../PKCS-15/KeyInfo.ta"); const ObjectValue_ta_1 = require("../PKCS-15/ObjectValue.ta"); const PublicKeyOperations_ta_1 = require("../PKCS-15/PublicKeyOperations.ta"); const RSAPrivateKeyObject_ta_1 = require("../PKCS-15/RSAPrivateKeyObject.ta"); var KeyInfo_ta_2 = require("../PKCS-15/KeyInfo.ta"); Object.defineProperty(exports, "_get_decoder_for_KeyInfo", { enumerable: true, get: function () { return KeyInfo_ta_2._get_decoder_for_KeyInfo; } }); Object.defineProperty(exports, "_get_encoder_for_KeyInfo", { enumerable: true, get: function () { return KeyInfo_ta_2._get_encoder_for_KeyInfo; } }); var ObjectValue_ta_2 = require("../PKCS-15/ObjectValue.ta"); Object.defineProperty(exports, "_get_decoder_for_ObjectValue", { enumerable: true, get: function () { return ObjectValue_ta_2._get_decoder_for_ObjectValue; } }); Object.defineProperty(exports, "_get_encoder_for_ObjectValue", { enumerable: true, get: function () { return ObjectValue_ta_2._get_encoder_for_ObjectValue; } }); var PublicKeyOperations_ta_2 = require("../PKCS-15/PublicKeyOperations.ta"); Object.defineProperty(exports, "_decode_PublicKeyOperations", { enumerable: true, get: function () { return PublicKeyOperations_ta_2._decode_PublicKeyOperations; } }); Object.defineProperty(exports, "_encode_PublicKeyOperations", { enumerable: true, get: function () { return PublicKeyOperations_ta_2._encode_PublicKeyOperations; } }); var RSAPrivateKeyObject_ta_2 = require("../PKCS-15/RSAPrivateKeyObject.ta"); Object.defineProperty(exports, "RSAPrivateKeyObject", { enumerable: true, get: function () { return RSAPrivateKeyObject_ta_2.RSAPrivateKeyObject; } }); Object.defineProperty(exports, "_decode_RSAPrivateKeyObject", { enumerable: true, get: function () { return RSAPrivateKeyObject_ta_2._decode_RSAPrivateKeyObject; } }); Object.defineProperty(exports, "_encode_RSAPrivateKeyObject", { enumerable: true, get: function () { return RSAPrivateKeyObject_ta_2._encode_RSAPrivateKeyObject; } }); /* START_OF_SYMBOL_DEFINITION PrivateRSAKeyAttributes */ /** * @summary PrivateRSAKeyAttributes * @description * * ### ASN.1 Definition: * * ```asn1 * PrivateRSAKeyAttributes ::= SEQUENCE { * value ObjectValue {RSAPrivateKeyObject}, * modulusLength INTEGER, -- modulus length in bits, e.g. 1024 * keyInfo KeyInfo {NULL, PublicKeyOperations} OPTIONAL, * ... -- For future extensions * } * ``` * * @class */ class PrivateRSAKeyAttributes { constructor( /** * @summary `value`. * @public * @readonly */ value, /** * @summary `modulusLength`. * @public * @readonly */ modulusLength, /** * @summary `keyInfo`. * @public * @readonly */ keyInfo, /** * @summary Extensions that are not recognized. * @public * @readonly */ _unrecognizedExtensionsList = []) { this.value = value; this.modulusLength = modulusLength; this.keyInfo = keyInfo; this._unrecognizedExtensionsList = _unrecognizedExtensionsList; } /** * @summary Restructures an object into a PrivateRSAKeyAttributes * @description * * This takes an `object` and converts it to a `PrivateRSAKeyAttributes`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `PrivateRSAKeyAttributes`. * @returns {PrivateRSAKeyAttributes} */ static _from_object(_o) { return new PrivateRSAKeyAttributes(_o.value, _o.modulusLength, _o.keyInfo, _o._unrecognizedExtensionsList); } } exports.PrivateRSAKeyAttributes = PrivateRSAKeyAttributes; /* END_OF_SYMBOL_DEFINITION PrivateRSAKeyAttributes */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PrivateRSAKeyAttributes */ /** * @summary The Leading Root Component Types of PrivateRSAKeyAttributes * @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_PrivateRSAKeyAttributes = [ new $.ComponentSpec("value", false, $.hasAnyTag, undefined, undefined), new $.ComponentSpec("modulusLength", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), new $.ComponentSpec("keyInfo", true, $.hasAnyTag, undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PrivateRSAKeyAttributes */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PrivateRSAKeyAttributes */ /** * @summary The Trailing Root Component Types of PrivateRSAKeyAttributes * @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_PrivateRSAKeyAttributes = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PrivateRSAKeyAttributes */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PrivateRSAKeyAttributes */ /** * @summary The Extension Addition Component Types of PrivateRSAKeyAttributes * @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_PrivateRSAKeyAttributes = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PrivateRSAKeyAttributes */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_PrivateRSAKeyAttributes */ let _cached_decoder_for_PrivateRSAKeyAttributes = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_PrivateRSAKeyAttributes */ /* START_OF_SYMBOL_DEFINITION _decode_PrivateRSAKeyAttributes */ /** * @summary Decodes an ASN.1 element into a(n) PrivateRSAKeyAttributes * @function * @param {_Element} el The element being decoded. * @returns {PrivateRSAKeyAttributes} The decoded data structure. */ function _decode_PrivateRSAKeyAttributes(el) { if (!_cached_decoder_for_PrivateRSAKeyAttributes) { _cached_decoder_for_PrivateRSAKeyAttributes = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let value; let modulusLength; let keyInfo; let _unrecognizedExtensionsList = []; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { value: (_el) => { value = ObjectValue_ta_1._get_decoder_for_ObjectValue(RSAPrivateKeyObject_ta_1._decode_RSAPrivateKeyObject)(_el); }, modulusLength: (_el) => { modulusLength = $._decodeInteger(_el); }, keyInfo: (_el) => { keyInfo = KeyInfo_ta_1._get_decoder_for_KeyInfo($._decodeNull, PublicKeyOperations_ta_1._decode_PublicKeyOperations)(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_PrivateRSAKeyAttributes, exports._extension_additions_list_spec_for_PrivateRSAKeyAttributes, exports._root_component_type_list_2_spec_for_PrivateRSAKeyAttributes, (ext) => { _unrecognizedExtensionsList.push(ext); }); return new PrivateRSAKeyAttributes( /* SEQUENCE_CONSTRUCTOR_CALL */ value, modulusLength, keyInfo, _unrecognizedExtensionsList); }; } return _cached_decoder_for_PrivateRSAKeyAttributes(el); } exports._decode_PrivateRSAKeyAttributes = _decode_PrivateRSAKeyAttributes; /* END_OF_SYMBOL_DEFINITION _decode_PrivateRSAKeyAttributes */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_PrivateRSAKeyAttributes */ let _cached_encoder_for_PrivateRSAKeyAttributes = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_PrivateRSAKeyAttributes */ /* START_OF_SYMBOL_DEFINITION _encode_PrivateRSAKeyAttributes */ /** * @summary Encodes a(n) PrivateRSAKeyAttributes 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 PrivateRSAKeyAttributes, encoded as an ASN.1 Element. */ function _encode_PrivateRSAKeyAttributes(value, elGetter) { if (!_cached_encoder_for_PrivateRSAKeyAttributes) { _cached_encoder_for_PrivateRSAKeyAttributes = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ ObjectValue_ta_1._get_encoder_for_ObjectValue(RSAPrivateKeyObject_ta_1._encode_RSAPrivateKeyObject)(value.value, $.BER), /* REQUIRED */ $._encodeInteger(value.modulusLength, $.BER), /* IF_ABSENT */ value.keyInfo === undefined ? undefined : KeyInfo_ta_1._get_encoder_for_KeyInfo($._encodeNull, PublicKeyOperations_ta_1._encode_PublicKeyOperations)(value.keyInfo, $.BER), ], value._unrecognizedExtensionsList ? value._unrecognizedExtensionsList : []) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_PrivateRSAKeyAttributes(value, elGetter); } exports._encode_PrivateRSAKeyAttributes = _encode_PrivateRSAKeyAttributes; /* END_OF_SYMBOL_DEFINITION _encode_PrivateRSAKeyAttributes */ /* eslint-enable */ //# sourceMappingURL=PrivateRSAKeyAttributes.ta.js.map