UNPKG

@wildboar/pkcs

Version:
228 lines 11.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_RSAES_OAEP_params = exports._decode_RSAES_OAEP_params = exports._extension_additions_list_spec_for_RSAES_OAEP_params = exports._root_component_type_list_2_spec_for_RSAES_OAEP_params = exports._root_component_type_list_1_spec_for_RSAES_OAEP_params = exports.RSAES_OAEP_params = exports.sha1 = exports.pSpecifiedEmpty = exports._encode_PSourceAlgorithm = exports._decode_PSourceAlgorithm = 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 PSourceAlgorithm_ta_1 = require("../PKCS-1/PSourceAlgorithm.ta"); const pSpecifiedEmpty_va_1 = require("../PKCS-1/pSpecifiedEmpty.va"); const sha1_va_1 = require("../PKCS-1/sha1.va"); 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 PSourceAlgorithm_ta_2 = require("../PKCS-1/PSourceAlgorithm.ta"); Object.defineProperty(exports, "_decode_PSourceAlgorithm", { enumerable: true, get: function () { return PSourceAlgorithm_ta_2._decode_PSourceAlgorithm; } }); Object.defineProperty(exports, "_encode_PSourceAlgorithm", { enumerable: true, get: function () { return PSourceAlgorithm_ta_2._encode_PSourceAlgorithm; } }); var pSpecifiedEmpty_va_2 = require("../PKCS-1/pSpecifiedEmpty.va"); Object.defineProperty(exports, "pSpecifiedEmpty", { enumerable: true, get: function () { return pSpecifiedEmpty_va_2.pSpecifiedEmpty; } }); var sha1_va_2 = require("../PKCS-1/sha1.va"); Object.defineProperty(exports, "sha1", { enumerable: true, get: function () { return sha1_va_2.sha1; } }); /* START_OF_SYMBOL_DEFINITION RSAES_OAEP_params */ /** * @summary RSAES_OAEP_params * @description * * ### ASN.1 Definition: * * ```asn1 * RSAES-OAEP-params ::= SEQUENCE { * hashAlgorithm [0] HashAlgorithm DEFAULT sha1, * maskGenAlgorithm [1] MaskGenAlgorithm DEFAULT mgf1SHA1, * pSourceAlgorithm [2] PSourceAlgorithm DEFAULT pSpecifiedEmpty * } * ``` * * @class */ class RSAES_OAEP_params { constructor( /** * @summary `hashAlgorithm`. * @public * @readonly */ hashAlgorithm, /** * @summary `maskGenAlgorithm`. * @public * @readonly */ maskGenAlgorithm, /** * @summary `pSourceAlgorithm`. * @public * @readonly */ pSourceAlgorithm) { this.hashAlgorithm = hashAlgorithm; this.maskGenAlgorithm = maskGenAlgorithm; this.pSourceAlgorithm = pSourceAlgorithm; } /** * @summary Restructures an object into a RSAES_OAEP_params * @description * * This takes an `object` and converts it to a `RSAES_OAEP_params`. * * @public * @static * @method * @param {Object} _o An object having all of the keys and values of a `RSAES_OAEP_params`. * @returns {RSAES_OAEP_params} */ static _from_object(_o) { return new RSAES_OAEP_params(_o.hashAlgorithm, _o.maskGenAlgorithm, _o.pSourceAlgorithm); } /** * @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 `pSourceAlgorithm`. * @public * @static * @method */ static get _default_value_for_pSourceAlgorithm() { return pSpecifiedEmpty_va_1.pSpecifiedEmpty; } } exports.RSAES_OAEP_params = RSAES_OAEP_params; /* END_OF_SYMBOL_DEFINITION RSAES_OAEP_params */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_RSAES_OAEP_params */ /** * @summary The Leading Root Component Types of RSAES_OAEP_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_RSAES_OAEP_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("pSourceAlgorithm", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 2), undefined, undefined), ]; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_RSAES_OAEP_params */ /* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_RSAES_OAEP_params */ /** * @summary The Trailing Root Component Types of RSAES_OAEP_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_RSAES_OAEP_params = []; /* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_RSAES_OAEP_params */ /* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_RSAES_OAEP_params */ /** * @summary The Extension Addition Component Types of RSAES_OAEP_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_RSAES_OAEP_params = []; /* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_RSAES_OAEP_params */ /* START_OF_SYMBOL_DEFINITION _cached_decoder_for_RSAES_OAEP_params */ let _cached_decoder_for_RSAES_OAEP_params = null; /* END_OF_SYMBOL_DEFINITION _cached_decoder_for_RSAES_OAEP_params */ /* START_OF_SYMBOL_DEFINITION _decode_RSAES_OAEP_params */ /** * @summary Decodes an ASN.1 element into a(n) RSAES_OAEP_params * @function * @param {_Element} el The element being decoded. * @returns {RSAES_OAEP_params} The decoded data structure. */ function _decode_RSAES_OAEP_params(el) { if (!_cached_decoder_for_RSAES_OAEP_params) { _cached_decoder_for_RSAES_OAEP_params = function (el) { /* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */ let hashAlgorithm = RSAES_OAEP_params._default_value_for_hashAlgorithm; let maskGenAlgorithm = RSAES_OAEP_params._default_value_for_maskGenAlgorithm; let pSourceAlgorithm = RSAES_OAEP_params._default_value_for_pSourceAlgorithm; /* 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); }, pSourceAlgorithm: (_el) => { pSourceAlgorithm = $._decode_explicit(() => PSourceAlgorithm_ta_1._decode_PSourceAlgorithm)(_el); }, }; /* END_OF_CALLBACKS_MAP */ $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_RSAES_OAEP_params, exports._extension_additions_list_spec_for_RSAES_OAEP_params, exports._root_component_type_list_2_spec_for_RSAES_OAEP_params, undefined); return new RSAES_OAEP_params( /* SEQUENCE_CONSTRUCTOR_CALL */ hashAlgorithm, maskGenAlgorithm, pSourceAlgorithm); }; } return _cached_decoder_for_RSAES_OAEP_params(el); } exports._decode_RSAES_OAEP_params = _decode_RSAES_OAEP_params; /* END_OF_SYMBOL_DEFINITION _decode_RSAES_OAEP_params */ /* START_OF_SYMBOL_DEFINITION _cached_encoder_for_RSAES_OAEP_params */ let _cached_encoder_for_RSAES_OAEP_params = null; /* END_OF_SYMBOL_DEFINITION _cached_encoder_for_RSAES_OAEP_params */ /* START_OF_SYMBOL_DEFINITION _encode_RSAES_OAEP_params */ /** * @summary Encodes a(n) RSAES_OAEP_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 RSAES_OAEP_params, encoded as an ASN.1 Element. */ function _encode_RSAES_OAEP_params(value, elGetter) { if (!_cached_encoder_for_RSAES_OAEP_params) { _cached_encoder_for_RSAES_OAEP_params = function (value, elGetter) { return $._encodeSequence([] .concat([ /* IF_DEFAULT */ value.hashAlgorithm === undefined || $.deepEq(value.hashAlgorithm, RSAES_OAEP_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, RSAES_OAEP_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.pSourceAlgorithm === undefined || $.deepEq(value.pSourceAlgorithm, RSAES_OAEP_params._default_value_for_pSourceAlgorithm) ? undefined : $._encode_explicit(asn1_ts_1.ASN1TagClass.context, 2, () => PSourceAlgorithm_ta_1._encode_PSourceAlgorithm, $.BER)(value.pSourceAlgorithm, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_RSAES_OAEP_params(value, elGetter); } exports._encode_RSAES_OAEP_params = _encode_RSAES_OAEP_params; /* END_OF_SYMBOL_DEFINITION _encode_RSAES_OAEP_params */ /* eslint-enable */ //# sourceMappingURL=RSAES-OAEP-params.ta.js.map