@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
215 lines • 9.39 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_PBKDF2_params = exports._decode_PBKDF2_params = exports._extension_additions_list_spec_for_PBKDF2_params = exports._root_component_type_list_2_spec_for_PBKDF2_params = exports._root_component_type_list_1_spec_for_PBKDF2_params = exports.PBKDF2_params = exports._encode_PBKDF2_params_salt = exports._decode_PBKDF2_params_salt = exports._encode_AlgorithmIdentifier = exports._decode_AlgorithmIdentifier = exports.AlgorithmIdentifier = exports.algid_hmacWithSHA1 = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const algid_hmacWithSHA1_va_1 = require("../PKCS5v2-1/algid-hmacWithSHA1.va");
const AlgorithmIdentifier_ta_1 = require("../PKCS5v2-1/AlgorithmIdentifier.ta");
const PBKDF2_params_salt_ta_1 = require("../PKCS5v2-1/PBKDF2-params-salt.ta");
var algid_hmacWithSHA1_va_2 = require("../PKCS5v2-1/algid-hmacWithSHA1.va");
Object.defineProperty(exports, "algid_hmacWithSHA1", { enumerable: true, get: function () { return algid_hmacWithSHA1_va_2.algid_hmacWithSHA1; } });
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; } });
var PBKDF2_params_salt_ta_2 = require("../PKCS5v2-1/PBKDF2-params-salt.ta");
Object.defineProperty(exports, "_decode_PBKDF2_params_salt", { enumerable: true, get: function () { return PBKDF2_params_salt_ta_2._decode_PBKDF2_params_salt; } });
Object.defineProperty(exports, "_encode_PBKDF2_params_salt", { enumerable: true, get: function () { return PBKDF2_params_salt_ta_2._encode_PBKDF2_params_salt; } });
/* START_OF_SYMBOL_DEFINITION PBKDF2_params */
/**
* @summary PBKDF2_params
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* PBKDF2-params ::= SEQUENCE {
* salt CHOICE {
* specified OCTET STRING,
* otherSource AlgorithmIdentifier {{PBKDF2-SaltSources}}
* },
* iterationCount INTEGER (1..MAX),
* keyLength INTEGER (1..MAX) OPTIONAL,
* prf AlgorithmIdentifier {{PBKDF2-PRFs}} DEFAULT
* algid-hmacWithSHA1
* }
* ```
*
* @class
*/
class PBKDF2_params {
constructor(
/**
* @summary `salt`.
* @public
* @readonly
*/
salt,
/**
* @summary `iterationCount`.
* @public
* @readonly
*/
iterationCount,
/**
* @summary `keyLength`.
* @public
* @readonly
*/
keyLength,
/**
* @summary `prf`.
* @public
* @readonly
*/
prf) {
this.salt = salt;
this.iterationCount = iterationCount;
this.keyLength = keyLength;
this.prf = prf;
}
/**
* @summary Restructures an object into a PBKDF2_params
* @description
*
* This takes an `object` and converts it to a `PBKDF2_params`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `PBKDF2_params`.
* @returns {PBKDF2_params}
*/
static _from_object(_o) {
return new PBKDF2_params(_o.salt, _o.iterationCount, _o.keyLength, _o.prf);
}
/**
* @summary Getter that returns the default value for `prf`.
* @public
* @static
* @method
*/
static get _default_value_for_prf() {
return algid_hmacWithSHA1_va_1.algid_hmacWithSHA1;
}
}
exports.PBKDF2_params = PBKDF2_params;
/* END_OF_SYMBOL_DEFINITION PBKDF2_params */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PBKDF2_params */
/**
* @summary The Leading Root Component Types of PBKDF2_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_PBKDF2_params = [
new $.ComponentSpec("salt", false, $.hasAnyTag, undefined, undefined),
new $.ComponentSpec("iterationCount", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("keyLength", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("prf", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PBKDF2_params */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PBKDF2_params */
/**
* @summary The Trailing Root Component Types of PBKDF2_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_PBKDF2_params = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PBKDF2_params */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PBKDF2_params */
/**
* @summary The Extension Addition Component Types of PBKDF2_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_PBKDF2_params = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PBKDF2_params */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_PBKDF2_params */
let _cached_decoder_for_PBKDF2_params = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_PBKDF2_params */
/* START_OF_SYMBOL_DEFINITION _decode_PBKDF2_params */
/**
* @summary Decodes an ASN.1 element into a(n) PBKDF2_params
* @function
* @param {_Element} el The element being decoded.
* @returns {PBKDF2_params} The decoded data structure.
*/
function _decode_PBKDF2_params(el) {
if (!_cached_decoder_for_PBKDF2_params) {
_cached_decoder_for_PBKDF2_params = function (el) {
/* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */
let salt;
let iterationCount;
let keyLength;
let prf = PBKDF2_params._default_value_for_prf;
/* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */
/* START_OF_CALLBACKS_MAP */
const callbacks = {
salt: (_el) => {
salt = PBKDF2_params_salt_ta_1._decode_PBKDF2_params_salt(_el);
},
iterationCount: (_el) => {
iterationCount = $._decodeInteger(_el);
},
keyLength: (_el) => {
keyLength = $._decodeInteger(_el);
},
prf: (_el) => {
prf = AlgorithmIdentifier_ta_1._decode_AlgorithmIdentifier(_el);
},
};
/* END_OF_CALLBACKS_MAP */
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_PBKDF2_params, exports._extension_additions_list_spec_for_PBKDF2_params, exports._root_component_type_list_2_spec_for_PBKDF2_params, undefined);
return new PBKDF2_params(
/* SEQUENCE_CONSTRUCTOR_CALL */ salt, iterationCount, keyLength, prf);
};
}
return _cached_decoder_for_PBKDF2_params(el);
}
exports._decode_PBKDF2_params = _decode_PBKDF2_params;
/* END_OF_SYMBOL_DEFINITION _decode_PBKDF2_params */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_PBKDF2_params */
let _cached_encoder_for_PBKDF2_params = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_PBKDF2_params */
/* START_OF_SYMBOL_DEFINITION _encode_PBKDF2_params */
/**
* @summary Encodes a(n) PBKDF2_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 PBKDF2_params, encoded as an ASN.1 Element.
*/
function _encode_PBKDF2_params(value, elGetter) {
if (!_cached_encoder_for_PBKDF2_params) {
_cached_encoder_for_PBKDF2_params = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ PBKDF2_params_salt_ta_1._encode_PBKDF2_params_salt(value.salt, $.BER),
/* REQUIRED */ $._encodeInteger(value.iterationCount, $.BER),
/* IF_ABSENT */ value.keyLength === undefined
? undefined
: $._encodeInteger(value.keyLength, $.BER),
/* IF_DEFAULT */ value.prf === undefined ||
$.deepEq(value.prf, PBKDF2_params._default_value_for_prf)
? undefined
: AlgorithmIdentifier_ta_1._encode_AlgorithmIdentifier(value.prf, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_PBKDF2_params(value, elGetter);
}
exports._encode_PBKDF2_params = _encode_PBKDF2_params;
/* END_OF_SYMBOL_DEFINITION _encode_PBKDF2_params */
/* eslint-enable */
//# sourceMappingURL=PBKDF2-params.ta.js.map