UNPKG

@wildboar/pkcs

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