UNPKG

pkcs-ts

Version:

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

60 lines 2.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_PBEParameter = exports._decode_PBEParameter = exports._extension_additions_list_spec_for_PBEParameter = exports._root_component_type_list_2_spec_for_PBEParameter = exports._root_component_type_list_1_spec_for_PBEParameter = exports.PBEParameter = void 0; const tslib_1 = require("tslib"); const asn1_ts_1 = require("asn1-ts"); const $ = tslib_1.__importStar(require("asn1-ts/dist/node/functional")); class PBEParameter { constructor(salt, iterationCount) { this.salt = salt; this.iterationCount = iterationCount; } static _from_object(_o) { return new PBEParameter(_o.salt, _o.iterationCount); } } exports.PBEParameter = PBEParameter; exports._root_component_type_list_1_spec_for_PBEParameter = [ new $.ComponentSpec("salt", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined), new $.ComponentSpec("iterationCount", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined), ]; exports._root_component_type_list_2_spec_for_PBEParameter = []; exports._extension_additions_list_spec_for_PBEParameter = []; let _cached_decoder_for_PBEParameter = null; function _decode_PBEParameter(el) { if (!_cached_decoder_for_PBEParameter) { _cached_decoder_for_PBEParameter = function (el) { const sequence = el.sequence; if (sequence.length < 2) { throw new asn1_ts_1.ASN1ConstructionError("PBEParameter contained only " + sequence.length.toString() + " elements."); } sequence[0].name = "salt"; sequence[1].name = "iterationCount"; let salt; let iterationCount; salt = $._decodeOctetString(sequence[0]); iterationCount = $._decodeInteger(sequence[1]); return new PBEParameter(salt, iterationCount); }; } return _cached_decoder_for_PBEParameter(el); } exports._decode_PBEParameter = _decode_PBEParameter; let _cached_encoder_for_PBEParameter = null; function _encode_PBEParameter(value, elGetter) { if (!_cached_encoder_for_PBEParameter) { _cached_encoder_for_PBEParameter = function (value, elGetter) { return $._encodeSequence([] .concat([ $._encodeOctetString(value.salt, $.BER), $._encodeInteger(value.iterationCount, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_PBEParameter(value, elGetter); } exports._encode_PBEParameter = _encode_PBEParameter; //# sourceMappingURL=PBEParameter.ta.js.map