UNPKG

@wildboar/pkcs

Version:
158 lines 7.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_SubjectPublicKeyInfo = exports._decode_SubjectPublicKeyInfo = exports._extension_additions_list_spec_for_SubjectPublicKeyInfo = exports._root_component_type_list_2_spec_for_SubjectPublicKeyInfo = exports._root_component_type_list_1_spec_for_SubjectPublicKeyInfo = exports.SubjectPublicKeyInfo = exports._encode_AlgorithmIdentifier = exports._decode_AlgorithmIdentifier = exports.AlgorithmIdentifier = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const AlgorithmIdentifier_ta_1 = require("../PKCS-10/AlgorithmIdentifier.ta"); var AlgorithmIdentifier_ta_2 = require("../PKCS-10/AlgorithmIdentifier.ta"); Object.defineProperty(exports, "AlgorithmIdentifier", { enumerable: true, get: function () { return AlgorithmIdentifier_ta_2.AlgorithmIdentifier; } }); Object.defineProperty(exports, "_decode_AlgorithmIdentifier", { enumerable: true, get: function () { return AlgorithmIdentifier_ta_2._decode_AlgorithmIdentifier; } }); Object.defineProperty(exports, "_encode_AlgorithmIdentifier", { enumerable: true, get: function () { return AlgorithmIdentifier_ta_2._encode_AlgorithmIdentifier; } }); /* START_OF_SYMBOL_DEFINITION SubjectPublicKeyInfo */ /** * @summary SubjectPublicKeyInfo * @description * * ### ASN.1 Definition: * * ```asn1 * SubjectPublicKeyInfo {ALGORITHM: IOSet} ::= SEQUENCE { * algorithm AlgorithmIdentifier {{IOSet}}, * subjectPublicKey BIT STRING * } * ``` * * @class */ class SubjectPublicKeyInfo { constructor( /** * @summary `algorithm`. * @public * @readonly */ algorithm, /** * @summary `subjectPublicKey`. * @public * @readonly */ subjectPublicKey) { this.algorithm = algorithm; this.subjectPublicKey = subjectPublicKey; } /** * @summary Restructures an object into a SubjectPublicKeyInfo * @description * * This takes an `object` and converts it to a `SubjectPublicKeyInfo`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `SubjectPublicKeyInfo`. * @returns {SubjectPublicKeyInfo} */ static _from_object(_o) { return new SubjectPublicKeyInfo(_o.algorithm, _o.subjectPublicKey); } } exports.SubjectPublicKeyInfo = SubjectPublicKeyInfo; /* END_OF_SYMBOL_DEFINITION SubjectPublicKeyInfo */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_SubjectPublicKeyInfo */ /** * @summary The Leading Root Component Types of SubjectPublicKeyInfo * @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_SubjectPublicKeyInfo = [ new $.ComponentSpec("algorithm", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined), new $.ComponentSpec("subjectPublicKey", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 3), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_SubjectPublicKeyInfo */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_SubjectPublicKeyInfo */ /** * @summary The Trailing Root Component Types of SubjectPublicKeyInfo * @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_SubjectPublicKeyInfo = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_SubjectPublicKeyInfo */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_SubjectPublicKeyInfo */ /** * @summary The Extension Addition Component Types of SubjectPublicKeyInfo * @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_SubjectPublicKeyInfo = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_SubjectPublicKeyInfo */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_SubjectPublicKeyInfo */ let _cached_decoder_for_SubjectPublicKeyInfo = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_SubjectPublicKeyInfo */ /* START_OF_SYMBOL_DEFINITION _decode_SubjectPublicKeyInfo */ /** * @summary Decodes an ASN.1 element into a(n) SubjectPublicKeyInfo * @function * @param {_Element} el The element being decoded. * @returns {SubjectPublicKeyInfo} The decoded data structure. */ function _decode_SubjectPublicKeyInfo(el) { if (!_cached_decoder_for_SubjectPublicKeyInfo) { _cached_decoder_for_SubjectPublicKeyInfo = function (el) { const sequence = el.sequence; if (sequence.length < 2) { throw new asn1_ts_1.ASN1ConstructionError("SubjectPublicKeyInfo contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "algorithm"; sequence[1].name = "subjectPublicKey"; let algorithm; let subjectPublicKey; algorithm = AlgorithmIdentifier_ta_1._decode_AlgorithmIdentifier(sequence[0]); subjectPublicKey = $._decodeBitString(sequence[1]); return new SubjectPublicKeyInfo(algorithm, subjectPublicKey); }; } return _cached_decoder_for_SubjectPublicKeyInfo(el); } exports._decode_SubjectPublicKeyInfo = _decode_SubjectPublicKeyInfo; /* END_OF_SYMBOL_DEFINITION _decode_SubjectPublicKeyInfo */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_SubjectPublicKeyInfo */ let _cached_encoder_for_SubjectPublicKeyInfo = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_SubjectPublicKeyInfo */ /* START_OF_SYMBOL_DEFINITION _encode_SubjectPublicKeyInfo */ /** * @summary Encodes a(n) SubjectPublicKeyInfo 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 SubjectPublicKeyInfo, encoded as an ASN.1 Element. */ function _encode_SubjectPublicKeyInfo(value, elGetter) { if (!_cached_encoder_for_SubjectPublicKeyInfo) { _cached_encoder_for_SubjectPublicKeyInfo = function (value, elGetter) { return $._encodeSequence([] .concat([ /* REQUIRED */ AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier(value.algorithm, $.BER), /* REQUIRED */ $._encodeBitString(value.subjectPublicKey, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_SubjectPublicKeyInfo(value, elGetter); } exports._encode_SubjectPublicKeyInfo = _encode_SubjectPublicKeyInfo; /* END_OF_SYMBOL_DEFINITION _encode_SubjectPublicKeyInfo */ /* eslint-enable */ //# sourceMappingURL=SubjectPublicKeyInfo.ta.js.map