UNPKG

pkcs-ts

Version:

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

61 lines 3.17 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; const tslib_1 = require("tslib"); const asn1_ts_1 = require("asn1-ts"); const $ = tslib_1.__importStar(require("asn1-ts/dist/node/functional")); const AlgorithmIdentifier_ta_1 = require("x500-ts/dist/node/modules/AuthenticationFramework/AlgorithmIdentifier.ta"); class OriginatorPublicKey { constructor(algorithm, publicKey) { this.algorithm = algorithm; this.publicKey = publicKey; } static _from_object(_o) { return new OriginatorPublicKey(_o.algorithm, _o.publicKey); } } exports.OriginatorPublicKey = OriginatorPublicKey; 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), ]; exports._root_component_type_list_2_spec_for_OriginatorPublicKey = []; exports._extension_additions_list_spec_for_OriginatorPublicKey = []; let _cached_decoder_for_OriginatorPublicKey = null; 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; let _cached_encoder_for_OriginatorPublicKey = null; function _encode_OriginatorPublicKey(value, elGetter) { if (!_cached_encoder_for_OriginatorPublicKey) { _cached_encoder_for_OriginatorPublicKey = function (value, elGetter) { return $._encodeSequence([] .concat([ AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier(value.algorithm, $.BER), $._encodeBitString(value.publicKey, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_OriginatorPublicKey(value, elGetter); } exports._encode_OriginatorPublicKey = _encode_OriginatorPublicKey; //# sourceMappingURL=OriginatorPublicKey.ta.js.map