pkcs-ts
Version:
PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More
66 lines • 3.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_OtherPrimeInfo = exports._decode_OtherPrimeInfo = exports._extension_additions_list_spec_for_OtherPrimeInfo = exports._root_component_type_list_2_spec_for_OtherPrimeInfo = exports._root_component_type_list_1_spec_for_OtherPrimeInfo = exports.OtherPrimeInfo = 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 OtherPrimeInfo {
constructor(prime, exponent, coefficient) {
this.prime = prime;
this.exponent = exponent;
this.coefficient = coefficient;
}
static _from_object(_o) {
return new OtherPrimeInfo(_o.prime, _o.exponent, _o.coefficient);
}
}
exports.OtherPrimeInfo = OtherPrimeInfo;
exports._root_component_type_list_1_spec_for_OtherPrimeInfo = [
new $.ComponentSpec("prime", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("exponent", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("coefficient", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
];
exports._root_component_type_list_2_spec_for_OtherPrimeInfo = [];
exports._extension_additions_list_spec_for_OtherPrimeInfo = [];
let _cached_decoder_for_OtherPrimeInfo = null;
function _decode_OtherPrimeInfo(el) {
if (!_cached_decoder_for_OtherPrimeInfo) {
_cached_decoder_for_OtherPrimeInfo = function (el) {
const sequence = el.sequence;
if (sequence.length < 3) {
throw new asn1_ts_1.ASN1ConstructionError("OtherPrimeInfo contained only " +
sequence.length.toString() +
" elements.");
}
sequence[0].name = "prime";
sequence[1].name = "exponent";
sequence[2].name = "coefficient";
let prime;
let exponent;
let coefficient;
prime = $._decodeBigInt(sequence[0]);
exponent = $._decodeBigInt(sequence[1]);
coefficient = $._decodeBigInt(sequence[2]);
return new OtherPrimeInfo(prime, exponent, coefficient);
};
}
return _cached_decoder_for_OtherPrimeInfo(el);
}
exports._decode_OtherPrimeInfo = _decode_OtherPrimeInfo;
let _cached_encoder_for_OtherPrimeInfo = null;
function _encode_OtherPrimeInfo(value, elGetter) {
if (!_cached_encoder_for_OtherPrimeInfo) {
_cached_encoder_for_OtherPrimeInfo = function (value, elGetter) {
return $._encodeSequence([]
.concat([
$._encodeBigInt(value.prime, $.BER),
$._encodeBigInt(value.exponent, $.BER),
$._encodeBigInt(value.coefficient, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_OtherPrimeInfo(value, elGetter);
}
exports._encode_OtherPrimeInfo = _encode_OtherPrimeInfo;
//# sourceMappingURL=OtherPrimeInfo.ta.js.map