pkcs-ts
Version:
PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More
65 lines • 3.82 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;
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("../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; } });
class PBES2_params {
constructor(keyDerivationFunc, encryptionScheme) {
this.keyDerivationFunc = keyDerivationFunc;
this.encryptionScheme = encryptionScheme;
}
static _from_object(_o) {
return new PBES2_params(_o.keyDerivationFunc, _o.encryptionScheme);
}
}
exports.PBES2_params = PBES2_params;
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),
];
exports._root_component_type_list_2_spec_for_PBES2_params = [];
exports._extension_additions_list_spec_for_PBES2_params = [];
let _cached_decoder_for_PBES2_params = null;
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;
let _cached_encoder_for_PBES2_params = null;
function _encode_PBES2_params(value, elGetter) {
if (!_cached_encoder_for_PBES2_params) {
_cached_encoder_for_PBES2_params = function (value, elGetter) {
return $._encodeSequence([]
.concat([
AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier(value.keyDerivationFunc, $.BER),
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;
//# sourceMappingURL=PBES2-params.ta.js.map