1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Faster RSA signatures.

This commit is contained in:
Ylian Saint-Hilaire 2018-01-09 20:13:41 -08:00
parent 348065fec3
commit c53d51175a
16 changed files with 419 additions and 60 deletions

View file

@ -28,6 +28,7 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
obj.connectioncount = 0;
obj.rotation = 0;
obj.protocol = 2; // KVM
obj.debugmode = 0;
obj.sessionid = 0;
obj.username;
@ -169,13 +170,15 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
if (str.length < 4) return;
var cmdmsg = null, X = 0, Y = 0, command = ReadShort(str, 0), cmdsize = ReadShort(str, 2);
if (command >= 18) { console.error("Invalid KVM command " + command + " of size " + cmdsize); obj.parent.Stop(); return; }
if (cmdsize > str.length) return;
if (cmdsize > str.length) { console.error("KVM invalid command size", cmdsize, str.length); return; }
//meshOnDebug("KVM Command: " + command + " Len:" + cmdsize);
if (obj.debugmode == 1) { console.log("KVM Command: " + command + " Len:" + cmdsize); }
if (command == 3 || command == 4 || command == 7) {
cmdmsg = str.substring(4, cmdsize);
X = ((cmdmsg.charCodeAt(0) & 0xFF) << 8) + (cmdmsg.charCodeAt(1) & 0xFF);
Y = ((cmdmsg.charCodeAt(2) & 0xFF) << 8) + (cmdmsg.charCodeAt(3) & 0xFF);
//if (obj.debugmode == 1) { console.log("X=" + X + " Y=" + Y); }
}
switch (command) {

View file

@ -20,6 +20,7 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
obj.webrtc = null;
obj.webchannel = null;
obj.onStateChanged = null;
obj.debugmode = 0;
// Private method
//obj.debug = function (msg) { console.log(msg); }
@ -41,6 +42,7 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
}
obj.xxOnSocketConnected = function () {
if (obj.debugmode == 1) { console.log('onSocketConnected'); }
//obj.debug("Agent Redir Socket Connected");
obj.xxStateChange(2);
}
@ -63,6 +65,7 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
}
obj.xxOnMessage = function (e) {
if (obj.debugmode == 1) { console.log('Recv', e.data); }
if (obj.State < 3) {
if (e.data == 'c') {
obj.socket.send(obj.protocol);
@ -156,10 +159,18 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
//obj.debug("Agent Redir Send(" + x.length + "): " + rstr2hex(x));
if (obj.socket != null && obj.socket.readyState == WebSocket.OPEN) {
if (typeof x == 'string') {
var b = new Uint8Array(x.length);
for (var i = 0; i < x.length; ++i) { b[i] = x.charCodeAt(i); }
obj.socket.send(b.buffer);
if (obj.debugmode == 1) {
var b = new Uint8Array(x.length), c = [];
for (var i = 0; i < x.length; ++i) { b[i] = x.charCodeAt(i); c.push(x.charCodeAt(i)); }
obj.socket.send(b.buffer);
console.log('Send', c);
} else {
var b = new Uint8Array(x.length);
for (var i = 0; i < x.length; ++i) { b[i] = x.charCodeAt(i); }
obj.socket.send(b.buffer);
}
} else {
if (obj.debugmode == 1) { console.log('Send', x); }
obj.socket.send(x);
}
}
@ -167,7 +178,8 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
obj.xxOnSocketClosed = function () {
//obj.debug("Agent Redir Socket Closed");
obj.Stop();
if (obj.debugmode == 1) { console.log('onSocketClosed'); }
obj.Stop(1);
}
obj.xxStateChange = function(newstate) {
@ -177,7 +189,8 @@ var CreateAgentRedirect = function (meshserver, module, serverPublicNamePort) {
if (obj.onStateChanged != null) obj.onStateChanged(obj, obj.State);
}
obj.Stop = function () {
obj.Stop = function (x) {
if (obj.debugmode == 1) { console.log('stop', x); }
//obj.debug("Agent Redir Socket Stopped");
obj.xxStateChange(0);
obj.connectstate = -1;

View file

@ -22,6 +22,7 @@ var CreateAmtRedirect = function (module) {
// ###END###{!Mode-Firmware}
obj.connectstate = 0;
obj.protocol = module.protocol; // 1 = SOL, 2 = KVM, 3 = IDER
obj.debugmode = 0;
obj.amtaccumulator = "";
obj.amtsequence = 1;
@ -48,6 +49,7 @@ var CreateAmtRedirect = function (module) {
obj.xxOnSocketConnected = function () {
//obj.Debug("Redir Socket Connected");
if (obj.debugmode == 1) { console.log('onSocketConnected'); }
obj.xxStateChange(2);
if (obj.protocol == 1) obj.xxSend(obj.RedirectStartSol); // TODO: Put these strings in higher level module to tighten code
if (obj.protocol == 2) obj.xxSend(obj.RedirectStartKvm); // Don't need these is the feature is not compiled-in.
@ -55,6 +57,7 @@ var CreateAmtRedirect = function (module) {
}
obj.xxOnMessage = function (e) {
if (obj.debugmode == 1) { console.log('Recv', e.data); }
obj.inDataCount++;
if (typeof e.data == 'object') {
var f = new FileReader();
@ -113,7 +116,7 @@ var CreateAmtRedirect = function (module) {
cmdsize = (13 + oemlen);
break;
default:
obj.Stop();
obj.Stop(1);
break;
}
break;
@ -141,7 +144,7 @@ var CreateAmtRedirect = function (module) {
// Basic Auth (Probably a good idea to not support this unless this is an old version of Intel AMT)
obj.xxSend(String.fromCharCode(0x13, 0x00, 0x00, 0x00, 0x01) + IntToStrX(obj.user.length + obj.pass.length + 2) + String.fromCharCode(obj.user.length) + obj.user + String.fromCharCode(obj.pass.length) + obj.pass);
}
else obj.Stop();
else obj.Stop(2);
}
else if ((authType == 3 || authType == 4) && status == 1) {
var curptr = 0;
@ -197,7 +200,7 @@ var CreateAmtRedirect = function (module) {
obj.connectstate = 1;
obj.xxStateChange(3);
}
} else obj.Stop();
} else obj.Stop(3);
break;
case 0x21: // Response to settings (33)
if (obj.amtaccumulator.length < 23) break;
@ -232,7 +235,7 @@ var CreateAmtRedirect = function (module) {
break;
default:
console.log("Unknown Intel AMT command: " + obj.amtaccumulator.charCodeAt(0) + " acclen=" + obj.amtaccumulator.length);
obj.Stop();
obj.Stop(4);
return;
}
if (cmdsize == 0) return;
@ -243,6 +246,7 @@ var CreateAmtRedirect = function (module) {
obj.xxSend = function (x) {
//obj.Debug("Redir Send(" + x.length + "): " + rstr2hex(x));
if (obj.socket != null && obj.socket.readyState == WebSocket.OPEN) {
if (obj.debugmode == 1) { console.log('Send', x); }
var b = new Uint8Array(x.length);
for (var i = 0; i < x.length; ++i) { b[i] = x.charCodeAt(i); }
obj.socket.send(b.buffer);
@ -267,6 +271,7 @@ var CreateAmtRedirect = function (module) {
}
obj.xxOnSocketClosed = function () {
if (obj.debugmode == 1) { console.log('onSocketClosed'); }
//obj.Debug("Redir Socket Closed");
if ((obj.inDataCount == 0) && (obj.tlsv1only == 0)) {
obj.tlsv1only = 1;
@ -275,7 +280,7 @@ var CreateAmtRedirect = function (module) {
obj.socket.onmessage = obj.xxOnMessage;
obj.socket.onclose = obj.xxOnSocketClosed;
} else {
obj.Stop();
obj.Stop(5);
}
}
@ -286,7 +291,8 @@ var CreateAmtRedirect = function (module) {
if (obj.onStateChanged != null) obj.onStateChanged(obj, obj.State);
}
obj.Stop = function () {
obj.Stop = function (x) {
if (obj.debugmode == 1) { console.log('onSocketStop', x); }
//obj.Debug("Redir Socket Stopped");
obj.xxStateChange(0);
obj.connectstate = -1;