UNPKG

pkcs-ts

Version:

PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More

117 lines 6.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_RSAPrivateKeyObject = exports._decode_RSAPrivateKeyObject = exports._extension_additions_list_spec_for_RSAPrivateKeyObject = exports._root_component_type_list_2_spec_for_RSAPrivateKeyObject = exports._root_component_type_list_1_spec_for_RSAPrivateKeyObject = exports.RSAPrivateKeyObject = void 0; const tslib_1 = require("tslib"); const asn1_ts_1 = require("asn1-ts"); const $ = tslib_1.__importStar(require("asn1-ts/dist/node/functional")); class RSAPrivateKeyObject { constructor(modulus, publicExponent, privateExponent, prime1, prime2, exponent1, exponent2, coefficient) { this.modulus = modulus; this.publicExponent = publicExponent; this.privateExponent = privateExponent; this.prime1 = prime1; this.prime2 = prime2; this.exponent1 = exponent1; this.exponent2 = exponent2; this.coefficient = coefficient; } static _from_object(_o) { return new RSAPrivateKeyObject(_o.modulus, _o.publicExponent, _o.privateExponent, _o.prime1, _o.prime2, _o.exponent1, _o.exponent2, _o.coefficient); } } exports.RSAPrivateKeyObject = RSAPrivateKeyObject; exports._root_component_type_list_1_spec_for_RSAPrivateKeyObject = [ new $.ComponentSpec("modulus", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), new $.ComponentSpec("publicExponent", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined), new $.ComponentSpec("privateExponent", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 2), undefined, undefined), new $.ComponentSpec("prime1", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 3), undefined, undefined), new $.ComponentSpec("prime2", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 4), undefined, undefined), new $.ComponentSpec("exponent1", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 5), undefined, undefined), new $.ComponentSpec("exponent2", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 6), undefined, undefined), new $.ComponentSpec("coefficient", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 7), undefined, undefined), ]; exports._root_component_type_list_2_spec_for_RSAPrivateKeyObject = []; exports._extension_additions_list_spec_for_RSAPrivateKeyObject = []; let _cached_decoder_for_RSAPrivateKeyObject = null; function _decode_RSAPrivateKeyObject(el) { if (!_cached_decoder_for_RSAPrivateKeyObject) { _cached_decoder_for_RSAPrivateKeyObject = function (el) { let modulus; let publicExponent; let privateExponent; let prime1; let prime2; let exponent1; let exponent2; let coefficient; const callbacks = { modulus: (_el) => { modulus = $._decode_implicit(() => $._decodeInteger)(_el); }, publicExponent: (_el) => { publicExponent = $._decode_implicit(() => $._decodeInteger)(_el); }, privateExponent: (_el) => { privateExponent = $._decode_implicit(() => $._decodeInteger)(_el); }, prime1: (_el) => { prime1 = $._decode_implicit(() => $._decodeInteger)(_el); }, prime2: (_el) => { prime2 = $._decode_implicit(() => $._decodeInteger)(_el); }, exponent1: (_el) => { exponent1 = $._decode_implicit(() => $._decodeInteger)(_el); }, exponent2: (_el) => { exponent2 = $._decode_implicit(() => $._decodeInteger)(_el); }, coefficient: (_el) => { coefficient = $._decode_implicit(() => $._decodeInteger)(_el); }, }; $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_RSAPrivateKeyObject, exports._extension_additions_list_spec_for_RSAPrivateKeyObject, exports._root_component_type_list_2_spec_for_RSAPrivateKeyObject, undefined); return new RSAPrivateKeyObject(modulus, publicExponent, privateExponent, prime1, prime2, exponent1, exponent2, coefficient); }; } return _cached_decoder_for_RSAPrivateKeyObject(el); } exports._decode_RSAPrivateKeyObject = _decode_RSAPrivateKeyObject; let _cached_encoder_for_RSAPrivateKeyObject = null; function _encode_RSAPrivateKeyObject(value, elGetter) { if (!_cached_encoder_for_RSAPrivateKeyObject) { _cached_encoder_for_RSAPrivateKeyObject = function (value, elGetter) { return $._encodeSequence([] .concat([ value.modulus === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => $._encodeInteger, $.BER)(value.modulus, $.BER), value.publicExponent === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 1, () => $._encodeInteger, $.BER)(value.publicExponent, $.BER), value.privateExponent === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 2, () => $._encodeInteger, $.BER)(value.privateExponent, $.BER), value.prime1 === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 3, () => $._encodeInteger, $.BER)(value.prime1, $.BER), value.prime2 === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 4, () => $._encodeInteger, $.BER)(value.prime2, $.BER), value.exponent1 === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 5, () => $._encodeInteger, $.BER)(value.exponent1, $.BER), value.exponent2 === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 6, () => $._encodeInteger, $.BER)(value.exponent2, $.BER), value.coefficient === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 7, () => $._encodeInteger, $.BER)(value.coefficient, $.BER), ]) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_RSAPrivateKeyObject(value, elGetter); } exports._encode_RSAPrivateKeyObject = _encode_RSAPrivateKeyObject; //# sourceMappingURL=RSAPrivateKeyObject.ta.js.map