UNPKG

pkcs-ts

Version:

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

90 lines 6.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_PublicRSAKeyAttributes = exports._decode_PublicRSAKeyAttributes = exports._extension_additions_list_spec_for_PublicRSAKeyAttributes = exports._root_component_type_list_2_spec_for_PublicRSAKeyAttributes = exports._root_component_type_list_1_spec_for_PublicRSAKeyAttributes = exports.PublicRSAKeyAttributes = exports._encode_RSAPublicKeyChoice = exports._decode_RSAPublicKeyChoice = 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; const tslib_1 = require("tslib"); const asn1_ts_1 = require("asn1-ts"); const $ = tslib_1.__importStar(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 RSAPublicKeyChoice_ta_1 = require("../PKCS-15/RSAPublicKeyChoice.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 RSAPublicKeyChoice_ta_2 = require("../PKCS-15/RSAPublicKeyChoice.ta"); Object.defineProperty(exports, "_decode_RSAPublicKeyChoice", { enumerable: true, get: function () { return RSAPublicKeyChoice_ta_2._decode_RSAPublicKeyChoice; } }); Object.defineProperty(exports, "_encode_RSAPublicKeyChoice", { enumerable: true, get: function () { return RSAPublicKeyChoice_ta_2._encode_RSAPublicKeyChoice; } }); class PublicRSAKeyAttributes { constructor(value, modulusLength, keyInfo, _unrecognizedExtensionsList = []) { this.value = value; this.modulusLength = modulusLength; this.keyInfo = keyInfo; this._unrecognizedExtensionsList = _unrecognizedExtensionsList; } static _from_object(_o) { return new PublicRSAKeyAttributes(_o.value, _o.modulusLength, _o.keyInfo, _o._unrecognizedExtensionsList); } } exports.PublicRSAKeyAttributes = PublicRSAKeyAttributes; exports._root_component_type_list_1_spec_for_PublicRSAKeyAttributes = [ 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), ]; exports._root_component_type_list_2_spec_for_PublicRSAKeyAttributes = []; exports._extension_additions_list_spec_for_PublicRSAKeyAttributes = []; let _cached_decoder_for_PublicRSAKeyAttributes = null; function _decode_PublicRSAKeyAttributes(el) { if (!_cached_decoder_for_PublicRSAKeyAttributes) { _cached_decoder_for_PublicRSAKeyAttributes = function (el) { let value; let modulusLength; let keyInfo; let _unrecognizedExtensionsList = []; const callbacks = { value: (_el) => { value = ObjectValue_ta_1._get_decoder_for_ObjectValue(RSAPublicKeyChoice_ta_1._decode_RSAPublicKeyChoice)(_el); }, modulusLength: (_el) => { modulusLength = $._decodeInteger(_el); }, keyInfo: (_el) => { keyInfo = KeyInfo_ta_1._get_decoder_for_KeyInfo($._decodeNull, PublicKeyOperations_ta_1._decode_PublicKeyOperations)(_el); }, }; $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_PublicRSAKeyAttributes, exports._extension_additions_list_spec_for_PublicRSAKeyAttributes, exports._root_component_type_list_2_spec_for_PublicRSAKeyAttributes, (ext) => { _unrecognizedExtensionsList.push(ext); }); return new PublicRSAKeyAttributes(value, modulusLength, keyInfo, _unrecognizedExtensionsList); }; } return _cached_decoder_for_PublicRSAKeyAttributes(el); } exports._decode_PublicRSAKeyAttributes = _decode_PublicRSAKeyAttributes; let _cached_encoder_for_PublicRSAKeyAttributes = null; function _encode_PublicRSAKeyAttributes(value, elGetter) { if (!_cached_encoder_for_PublicRSAKeyAttributes) { _cached_encoder_for_PublicRSAKeyAttributes = function (value, elGetter) { return $._encodeSequence([] .concat([ ObjectValue_ta_1._get_encoder_for_ObjectValue(RSAPublicKeyChoice_ta_1._encode_RSAPublicKeyChoice)(value.value, $.BER), $._encodeInteger(value.modulusLength, $.BER), 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_PublicRSAKeyAttributes(value, elGetter); } exports._encode_PublicRSAKeyAttributes = _encode_PublicRSAKeyAttributes; //# sourceMappingURL=PublicRSAKeyAttributes.ta.js.map