Untitled diff

Created Diff never expires
12 removals
71 lines
19 additions
77 lines
// 21.08.2019
// 27.08.2019
// https://www.elec.moscow/js/forms/mgik/dit.bundle.js
// https://www.elec.moscow/js/forms/mgik/dit.bundle.js


key: "encrypt",
key: "encrypt",
value: function() {
value: function() {
var t = tr(regeneratorRuntime.mark(function t(e, r) {
var t = tr(regeneratorRuntime.mark(function t(e, r) {
var n, i, o, f, a, s, u, c;
var n, i, o, f, a, s, u, c;
return regeneratorRuntime.wrap(function(t) {
return regeneratorRuntime.wrap(function(t) {
for (;;) switch (t.prev = t.next) {
for (;;) switch (t.prev = t.next) {
case 0:
case 0:
if (e) {
if (e) {
t.next = 2;
t.next = 2;
break
break
}
}
throw new Error("Data must present!");
throw new Error("Data must present!");
case 2:
case 2:
if (r) {
if (r) {
t.next = 4;
t.next = 4;
break
break
}
}
throw new Error("Entropy must present!");
throw new Error("Entropy must present!");
case 4:
case 4:
if (n = new zo(e.toString()), i = new zo(r.toString()), !(n.compareTo(this.Q) >= 0)) {
if (n = new df(e.toString()), i = new df(r.toString()), !(n.compareTo(this.Q) >= 0)) {
t.next = 8;
t.next = 8;
break
break
}
}
throw new Error("Data to encrypt can not be bigger or equal that (P-1)/2!");
throw new Error("Data to encrypt can not be bigger or equal that (P-1)/2!");
case 8:
case 8:
if (!(i.compareTo(zo.ONE) <= 0)) {
if (!(i.compareTo(df.ONE) <= 0)) {
t.next = 10;
t.next = 10;
break
break
}
}
throw new Error("Entropy for Session Key must be Integer bigger than 1!");
throw new Error("Entropy for Session Key must be Integer bigger than 1!");
case 10:
case 10:
if (!(i.compareTo(this.moduleP) >= 0)) {
if (!(i.compareTo(this.moduleP) >= 0)) {
t.next = 12;
t.next = 12;
break
break
}
}
throw new Error("Entropy for Session Key can not be bigger or equal Basis Module P!");
throw new Error("Entropy for Session Key can not be bigger or equal Basis Module P!");
case 12:
case 12:
return t.next = 14, Zo(zo.ONE, this.moduleP.subtract(zo.ONE));
return t.next = 14, mf(df.ONE, this.moduleP.subtract(df.ONE));
case 14:
case 14:
return o = t.sent, f = o.xor(i), a = $o(f, this.moduleP.bitLength() - 1), s = this.publicKey.modPow(a, this.moduleP), u = this.generatorG.modPow(a, this.moduleP).toString(), c = s.multiply(n).remainder(this.moduleP).toString(), t.abrupt("return", {
return o = t.sent, f = o.xor(i), a = vf(f, this.moduleP.bitLength() - 1), s = n.modPow(new df("2"), this.moduleP), u = this.generatorG.modPow(a, this.moduleP).toString(), c = this.publicKey.modPow(a, this.moduleP).multiply(s).remainder(this.moduleP).toString(), t.abrupt("return", {
a: u,
a: u,
b: c
b: c
});
});
case 21:
case 21:
case "end":
case "end":
return t.stop()
return t.stop()
}
}
}, t, this)
}, t, this)
}));
}));
return function(e, r) {
return function(e, r) {
return t.apply(this, arguments)
return t.apply(this, arguments)
}
}
}()
}()
}, {
}, {
key: "decrypt",
key: "decrypt",
value: function() {
value: function() {
var t = tr(regeneratorRuntime.mark(function t(e) {
var t = tr(regeneratorRuntime.mark(function t(e) {
var r;
var r, n, i, o;
return regeneratorRuntime.wrap(function(t) {
return regeneratorRuntime.wrap(function(t) {
for (;;) switch (t.prev = t.next) {
for (;;) switch (t.prev = t.next) {
case 0:
case 0:
return r = this.getDecryptor(e), t.abrupt("return", new zo(e.b.toString()).multiply(r).remainder(this.moduleP).toString());
if (r = this.getDecryptor(e), n = new df(e.b.toString()).multiply(r).remainder(this.moduleP), 0 === n.modPow(this.moduleP.subtract(df.ONE).divide(new df("2")), this.moduleP).compareTo(df.ONE)) {
case 2:
t.next = 5;
break
}
throw new Error("Data is incorrect: encrypted value should be quadratic residue moduleP");
case 5:
return i = n.modPow(this.moduleP.add(df.ONE).divide(new df("4")), this.moduleP), o = this.moduleP.subtract(i), t.abrupt("return", o.compareTo(i) > 0 ? i.toString() : o.toString());
case 8:
case "end":
case "end":
return t.stop()
return t.stop()
}
}
}, t, this)
}, t, this)
}));
}));