UNPKG

@wildboar/pkcs

Version:
253 lines 12.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_RSASSA_PSS_params = exports._decode_RSASSA_PSS_params = exports._extension_additions_list_spec_for_RSASSA_PSS_params = exports._root_component_type_list_2_spec_for_RSASSA_PSS_params = exports._root_component_type_list_1_spec_for_RSASSA_PSS_params = exports.RSASSA_PSS_params = exports._encode_TrailerField = exports._decode_TrailerField = exports.TrailerField_trailerFieldBC = exports.trailerFieldBC = exports.sha1 = exports.mgf1SHA1 = exports._encode_MaskGenAlgorithm = exports._decode_MaskGenAlgorithm = exports._encode_HashAlgorithm = exports._decode_HashAlgorithm = void 0; /* eslint-disable */ const asn1_ts_1 = require("asn1-ts"); const $ = require("asn1-ts/dist/node/functional"); const HashAlgorithm_ta_1 = require("../PKCS-1/HashAlgorithm.ta"); const MaskGenAlgorithm_ta_1 = require("../PKCS-1/MaskGenAlgorithm.ta"); const mgf1SHA1_va_1 = require("../PKCS-1/mgf1SHA1.va"); const sha1_va_1 = require("../PKCS-1/sha1.va"); const TrailerField_ta_1 = require("../PKCS-1/TrailerField.ta"); var HashAlgorithm_ta_2 = require("../PKCS-1/HashAlgorithm.ta"); Object.defineProperty(exports, "_decode_HashAlgorithm", { enumerable: true, get: function () { return HashAlgorithm_ta_2._decode_HashAlgorithm; } }); Object.defineProperty(exports, "_encode_HashAlgorithm", { enumerable: true, get: function () { return HashAlgorithm_ta_2._encode_HashAlgorithm; } }); var MaskGenAlgorithm_ta_2 = require("../PKCS-1/MaskGenAlgorithm.ta"); Object.defineProperty(exports, "_decode_MaskGenAlgorithm", { enumerable: true, get: function () { return MaskGenAlgorithm_ta_2._decode_MaskGenAlgorithm; } }); Object.defineProperty(exports, "_encode_MaskGenAlgorithm", { enumerable: true, get: function () { return MaskGenAlgorithm_ta_2._encode_MaskGenAlgorithm; } }); var mgf1SHA1_va_2 = require("../PKCS-1/mgf1SHA1.va"); Object.defineProperty(exports, "mgf1SHA1", { enumerable: true, get: function () { return mgf1SHA1_va_2.mgf1SHA1; } }); var sha1_va_2 = require("../PKCS-1/sha1.va"); Object.defineProperty(exports, "sha1", { enumerable: true, get: function () { return sha1_va_2.sha1; } }); var TrailerField_ta_2 = require("../PKCS-1/TrailerField.ta"); Object.defineProperty(exports, "trailerFieldBC", { enumerable: true, get: function () { return TrailerField_ta_2.trailerFieldBC; } }); /* IMPORTED_SHORT_NAMED_INTEGER */ Object.defineProperty(exports, "TrailerField_trailerFieldBC", { enumerable: true, get: function () { return TrailerField_ta_2.TrailerField_trailerFieldBC; } }); /* IMPORTED_LONG_NAMED_INTEGER */ Object.defineProperty(exports, "_decode_TrailerField", { enumerable: true, get: function () { return TrailerField_ta_2._decode_TrailerField; } }); Object.defineProperty(exports, "_encode_TrailerField", { enumerable: true, get: function () { return TrailerField_ta_2._encode_TrailerField; } }); /* START_OF_SYMBOL_DEFINITION RSASSA_PSS_params */ /** * @summary RSASSA_PSS_params * @description * * ### ASN.1 Definition: * * ```asn1 * RSASSA-PSS-params ::= SEQUENCE { * hashAlgorithm [0] HashAlgorithm DEFAULT sha1, * maskGenAlgorithm [1] MaskGenAlgorithm DEFAULT mgf1SHA1, * saltLength [2] INTEGER DEFAULT 20, * trailerField [3] TrailerField DEFAULT trailerFieldBC * } * ``` * * @class */ class RSASSA_PSS_params { constructor( /** * @summary `hashAlgorithm`. * @public * @readonly */ hashAlgorithm, /** * @summary `maskGenAlgorithm`. * @public * @readonly */ maskGenAlgorithm, /** * @summary `saltLength`. * @public * @readonly */ saltLength, /** * @summary `trailerField`. * @public * @readonly */ trailerField) { this.hashAlgorithm = hashAlgorithm; this.maskGenAlgorithm = maskGenAlgorithm; this.saltLength = saltLength; this.trailerField = trailerField; } /** * @summary Restructures an object into a RSASSA_PSS_params * @description * * This takes an `object` and converts it to a `RSASSA_PSS_params`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `RSASSA_PSS_params`. * @returns {RSASSA_PSS_params} */ static _from_object(_o) { return new RSASSA_PSS_params(_o.hashAlgorithm, _o.maskGenAlgorithm, _o.saltLength, _o.trailerField); } /** * @summary Getter that returns the default value for `hashAlgorithm`. * @public * @static * @method */ static get _default_value_for_hashAlgorithm() { return sha1_va_1.sha1; } /** * @summary Getter that returns the default value for `maskGenAlgorithm`. * @public * @static * @method */ static get _default_value_for_maskGenAlgorithm() { return mgf1SHA1_va_1.mgf1SHA1; } /** * @summary Getter that returns the default value for `saltLength`. * @public * @static * @method */ static get _default_value_for_saltLength() { return 20; } /** * @summary Getter that returns the default value for `trailerField`. * @public * @static * @method */ static get _default_value_for_trailerField() { return TrailerField_ta_1.trailerFieldBC; } } exports.RSASSA_PSS_params = RSASSA_PSS_params; /* END_OF_SYMBOL_DEFINITION RSASSA_PSS_params */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_RSASSA_PSS_params */ /** * @summary The Leading Root Component Types of RSASSA_PSS_params * @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_RSASSA_PSS_params = [ new $.ComponentSpec("hashAlgorithm", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), new $.ComponentSpec("maskGenAlgorithm", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined), new $.ComponentSpec("saltLength", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 2), undefined, undefined), new $.ComponentSpec("trailerField", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 3), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_RSASSA_PSS_params */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_RSASSA_PSS_params */ /** * @summary The Trailing Root Component Types of RSASSA_PSS_params * @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_RSASSA_PSS_params = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_RSASSA_PSS_params */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_RSASSA_PSS_params */ /** * @summary The Extension Addition Component Types of RSASSA_PSS_params * @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_RSASSA_PSS_params = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_RSASSA_PSS_params */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_RSASSA_PSS_params */ let _cached_decoder_for_RSASSA_PSS_params = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_RSASSA_PSS_params */ /* START_OF_SYMBOL_DEFINITION _decode_RSASSA_PSS_params */ /** * @summary Decodes an ASN.1 element into a(n) RSASSA_PSS_params * @function * @param {_Element} el The element being decoded. * @returns {RSASSA_PSS_params} The decoded data structure. */ function _decode_RSASSA_PSS_params(el) { if (!_cached_decoder_for_RSASSA_PSS_params) { _cached_decoder_for_RSASSA_PSS_params = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let hashAlgorithm = RSASSA_PSS_params._default_value_for_hashAlgorithm; let maskGenAlgorithm = RSASSA_PSS_params._default_value_for_maskGenAlgorithm; let saltLength = RSASSA_PSS_params._default_value_for_saltLength; let trailerField = RSASSA_PSS_params._default_value_for_trailerField; /* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */ /* START_OF_CALLBACKS_MAP */ const callbacks = { hashAlgorithm: (_el) => { hashAlgorithm = $._decode_explicit(() => HashAlgorithm_ta_1._decode_HashAlgorithm)(_el); }, maskGenAlgorithm: (_el) => { maskGenAlgorithm = $._decode_explicit(() => MaskGenAlgorithm_ta_1._decode_MaskGenAlgorithm)(_el); }, saltLength: (_el) => { saltLength = $._decode_explicit(() => $._decodeInteger)(_el); }, trailerField: (_el) => { trailerField = $._decode_explicit(() => TrailerField_ta_1._decode_TrailerField)(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_RSASSA_PSS_params, exports._extension_additions_list_spec_for_RSASSA_PSS_params, exports._root_component_type_list_2_spec_for_RSASSA_PSS_params, undefined); return new RSASSA_PSS_params( /* SEQUENCE_CONSTRUCTOR_CALL */ hashAlgorithm, maskGenAlgorithm, saltLength, trailerField); }; } return _cached_decoder_for_RSASSA_PSS_params(el); } exports._decode_RSASSA_PSS_params = _decode_RSASSA_PSS_params; /* END_OF_SYMBOL_DEFINITION _decode_RSASSA_PSS_params */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_RSASSA_PSS_params */ let _cached_encoder_for_RSASSA_PSS_params = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_RSASSA_PSS_params */ /* START_OF_SYMBOL_DEFINITION _encode_RSASSA_PSS_params */ /** * @summary Encodes a(n) RSASSA_PSS_params 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 RSASSA_PSS_params, encoded as an ASN.1 Element. */ function _encode_RSASSA_PSS_params(value, elGetter) { if (!_cached_encoder_for_RSASSA_PSS_params) { _cached_encoder_for_RSASSA_PSS_params = function (value, elGetter) { return $._encodeSequence([] .concat([ /* IF_DEFAULT */ value.hashAlgorithm === undefined || $.deepEq(value.hashAlgorithm, RSASSA_PSS_params._default_value_for_hashAlgorithm) ? undefined : $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 0, () => HashAlgorithm_ta_1._encode_HashAlgorithm, $.BER)(value.hashAlgorithm, $.BER), /* IF_DEFAULT */ value.maskGenAlgorithm === undefined || $.deepEq(value.maskGenAlgorithm, RSASSA_PSS_params._default_value_for_maskGenAlgorithm) ? undefined : $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 1, () => MaskGenAlgorithm_ta_1._encode_MaskGenAlgorithm, $.BER)(value.maskGenAlgorithm, $.BER), /* IF_DEFAULT */ value.saltLength === undefined || $.deepEq(value.saltLength, RSASSA_PSS_params._default_value_for_saltLength) ? undefined : $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 2, () => $._encodeInteger, $.BER)(value.saltLength, $.BER), /* IF_DEFAULT */ value.trailerField === undefined || $.deepEq(value.trailerField, RSASSA_PSS_params._default_value_for_trailerField) ? undefined : $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 3, () => TrailerField_ta_1._encode_TrailerField, $.BER)(value.trailerField, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_RSASSA_PSS_params(value, elGetter); } exports._encode_RSASSA_PSS_params = _encode_RSASSA_PSS_params; /* END_OF_SYMBOL_DEFINITION _encode_RSASSA_PSS_params */ /* eslint-enable */ //# sourceMappingURL=RSASSA-PSS-params.ta.js.map