@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
158 lines • 6.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_PBES2_params = exports._decode_PBES2_params = exports._extension_additions_list_spec_for_PBES2_params = exports._root_component_type_list_2_spec_for_PBES2_params = exports._root_component_type_list_1_spec_for_PBES2_params = exports.PBES2_params = exports._encode_AlgorithmIdentifier = exports._decode_AlgorithmIdentifier = exports.AlgorithmIdentifier = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const AlgorithmIdentifier_ta_1 = require("../PKCS5v2-1/AlgorithmIdentifier.ta");
var AlgorithmIdentifier_ta_2 = require("../PKCS5v2-1/AlgorithmIdentifier.ta");
Object.defineProperty(exports, "AlgorithmIdentifier", { enumerable: true, get: function () { return AlgorithmIdentifier_ta_2.AlgorithmIdentifier; } });
Object.defineProperty(exports, "_decode_AlgorithmIdentifier", { enumerable: true, get: function () { return AlgorithmIdentifier_ta_2._decode_AlgorithmIdentifier; } });
Object.defineProperty(exports, "_encode_AlgorithmIdentifier", { enumerable: true, get: function () { return AlgorithmIdentifier_ta_2._encode_AlgorithmIdentifier; } });
/* START_OF_SYMBOL_DEFINITION PBES2_params */
/**
* @summary PBES2_params
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* PBES2-params ::= SEQUENCE {
* keyDerivationFunc AlgorithmIdentifier {{PBES2-KDFs}},
* encryptionScheme AlgorithmIdentifier {{PBES2-Encs}}
* }
* ```
*
* @class
*/
class PBES2_params {
constructor(
/**
* @summary `keyDerivationFunc`.
* @public
* @readonly
*/
keyDerivationFunc,
/**
* @summary `encryptionScheme`.
* @public
* @readonly
*/
encryptionScheme) {
this.keyDerivationFunc = keyDerivationFunc;
this.encryptionScheme = encryptionScheme;
}
/**
* @summary Restructures an object into a PBES2_params
* @description
*
* This takes an `object` and converts it to a `PBES2_params`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `PBES2_params`.
* @returns {PBES2_params}
*/
static _from_object(_o) {
return new PBES2_params(_o.keyDerivationFunc, _o.encryptionScheme);
}
}
exports.PBES2_params = PBES2_params;
/* END_OF_SYMBOL_DEFINITION PBES2_params */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PBES2_params */
/**
* @summary The Leading Root Component Types of PBES2_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_PBES2_params = [
new $.ComponentSpec("keyDerivationFunc", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("encryptionScheme", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PBES2_params */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PBES2_params */
/**
* @summary The Trailing Root Component Types of PBES2_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_PBES2_params = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PBES2_params */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PBES2_params */
/**
* @summary The Extension Addition Component Types of PBES2_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_PBES2_params = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PBES2_params */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_PBES2_params */
let _cached_decoder_for_PBES2_params = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_PBES2_params */
/* START_OF_SYMBOL_DEFINITION _decode_PBES2_params */
/**
* @summary Decodes an ASN.1 element into a(n) PBES2_params
* @function
* @param {_Element} el The element being decoded.
* @returns {PBES2_params} The decoded data structure.
*/
function _decode_PBES2_params(el) {
if (!_cached_decoder_for_PBES2_params) {
_cached_decoder_for_PBES2_params = function (el) {
const sequence = el.sequence;
if (sequence.length < 2) {
throw new asn1_ts_1.ASN1ConstructionError("PBES2-params contained only " +
sequence.length.toString() +
" elements.");
}
sequence[0].name = "keyDerivationFunc";
sequence[1].name = "encryptionScheme";
let keyDerivationFunc;
let encryptionScheme;
keyDerivationFunc = AlgorithmIdentifier_ta_1._decode_AlgorithmIdentifier(sequence[0]);
encryptionScheme = AlgorithmIdentifier_ta_1._decode_AlgorithmIdentifier(sequence[1]);
return new PBES2_params(keyDerivationFunc, encryptionScheme);
};
}
return _cached_decoder_for_PBES2_params(el);
}
exports._decode_PBES2_params = _decode_PBES2_params;
/* END_OF_SYMBOL_DEFINITION _decode_PBES2_params */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_PBES2_params */
let _cached_encoder_for_PBES2_params = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_PBES2_params */
/* START_OF_SYMBOL_DEFINITION _encode_PBES2_params */
/**
* @summary Encodes a(n) PBES2_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 PBES2_params, encoded as an ASN.1 Element.
*/
function _encode_PBES2_params(value, elGetter) {
if (!_cached_encoder_for_PBES2_params) {
_cached_encoder_for_PBES2_params = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier(value.keyDerivationFunc, $.BER),
/* REQUIRED */ AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier(value.encryptionScheme, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_PBES2_params(value, elGetter);
}
exports._encode_PBES2_params = _encode_PBES2_params;
/* END_OF_SYMBOL_DEFINITION _encode_PBES2_params */
/* eslint-enable */
//# sourceMappingURL=PBES2-params.ta.js.map