@novnc/novnc
Advanced tools
Comparing version 1.4.0-gcbbd9ab to 1.4.0-ge8ad466
@@ -161,6 +161,7 @@ import { encodeUTF8 } from './util/strings.js'; | ||
// verify server public key | ||
let approveKey = this._waitApproveKeyAsync(); | ||
this.dispatchEvent(new CustomEvent("serververification", { | ||
detail: { type: "RSA", publickey: serverPublickey } | ||
})); | ||
await this._waitApproveKeyAsync(); | ||
await approveKey; | ||
@@ -264,2 +265,3 @@ // 2: Send client public key | ||
subtype = subtype[0]; | ||
let waitCredentials = this._waitCredentialsAsync(subtype); | ||
if (subtype === 1) { | ||
@@ -281,3 +283,3 @@ if (this._getCredentials().username === undefined || | ||
} | ||
await this._waitCredentialsAsync(subtype); | ||
await waitCredentials; | ||
let username; | ||
@@ -284,0 +286,0 @@ if (subtype === 1) { |
134
lib/ra2.js
@@ -237,3 +237,3 @@ "use strict"; | ||
var _negotiateRA2neAuthAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() { | ||
var serverKeyLengthBuffer, serverKeyLength, serverKeyBytes, serverN, serverE, serverRSACipher, serverPublickey, clientKeyLength, clientKeyBytes, clientRSACipher, clientExportedRSAKey, clientN, clientE, clientPublicKey, clientRandom, clientEncryptedRandom, clientRandomMessage, serverEncryptedRandom, serverRandom, clientSessionKey, serverSessionKey, clientCipher, serverCipher, serverHash, clientHash, serverHashReceived, i, subtype, username, password, credentials, _i, _i2; | ||
var serverKeyLengthBuffer, serverKeyLength, serverKeyBytes, serverN, serverE, serverRSACipher, serverPublickey, approveKey, clientKeyLength, clientKeyBytes, clientRSACipher, clientExportedRSAKey, clientN, clientE, clientPublicKey, clientRandom, clientEncryptedRandom, clientRandomMessage, serverEncryptedRandom, serverRandom, clientSessionKey, serverSessionKey, clientCipher, serverCipher, serverHash, clientHash, serverHashReceived, i, subtype, waitCredentials, username, password, credentials, _i, _i2; | ||
return _regeneratorRuntime().wrap(function _callee4$(_context4) { | ||
@@ -282,2 +282,3 @@ while (1) switch (_context4.prev = _context4.next) { | ||
// verify server public key | ||
approveKey = this._waitApproveKeyAsync(); | ||
this.dispatchEvent(new CustomEvent("serververification", { | ||
@@ -289,9 +290,9 @@ detail: { | ||
})); | ||
_context4.next = 26; | ||
return this._waitApproveKeyAsync(); | ||
case 26: | ||
_context4.next = 27; | ||
return approveKey; | ||
case 27: | ||
// 2: Send client public key | ||
clientKeyLength = 2048; | ||
clientKeyBytes = Math.ceil(clientKeyLength / 8); | ||
_context4.next = 30; | ||
_context4.next = 31; | ||
return _crypto["default"].generateKey({ | ||
@@ -302,7 +303,7 @@ name: "RSA-PKCS1-v1_5", | ||
}, true, ["encrypt"]); | ||
case 30: | ||
case 31: | ||
clientRSACipher = _context4.sent.privateKey; | ||
_context4.next = 33; | ||
_context4.next = 34; | ||
return _crypto["default"].exportKey("raw", clientRSACipher); | ||
case 33: | ||
case 34: | ||
clientExportedRSAKey = _context4.sent; | ||
@@ -323,7 +324,7 @@ clientN = clientExportedRSAKey.n; | ||
window.crypto.getRandomValues(clientRandom); | ||
_context4.next = 48; | ||
_context4.next = 49; | ||
return _crypto["default"].encrypt({ | ||
name: "RSA-PKCS1-v1_5" | ||
}, serverRSACipher, clientRandom); | ||
case 48: | ||
case 49: | ||
clientEncryptedRandom = _context4.sent; | ||
@@ -337,24 +338,24 @@ clientRandomMessage = new Uint8Array(2 + serverKeyBytes); | ||
// 4: Receive server random | ||
_context4.next = 56; | ||
_context4.next = 57; | ||
return this._waitSockAsync(2); | ||
case 56: | ||
case 57: | ||
if (!(this._sock.rQshift16() !== clientKeyBytes)) { | ||
_context4.next = 58; | ||
_context4.next = 59; | ||
break; | ||
} | ||
throw new Error("RA2: wrong encrypted message length"); | ||
case 58: | ||
case 59: | ||
serverEncryptedRandom = this._sock.rQshiftBytes(clientKeyBytes); | ||
_context4.next = 61; | ||
_context4.next = 62; | ||
return _crypto["default"].decrypt({ | ||
name: "RSA-PKCS1-v1_5" | ||
}, clientRSACipher, serverEncryptedRandom); | ||
case 61: | ||
case 62: | ||
serverRandom = _context4.sent; | ||
if (!(serverRandom === null || serverRandom.length !== 16)) { | ||
_context4.next = 64; | ||
_context4.next = 65; | ||
break; | ||
} | ||
throw new Error("RA2: corrupted server encrypted random"); | ||
case 64: | ||
case 65: | ||
// 5: Compute session keys and set ciphers | ||
@@ -367,20 +368,20 @@ clientSessionKey = new Uint8Array(32); | ||
serverSessionKey.set(serverRandom, 16); | ||
_context4.next = 72; | ||
_context4.next = 73; | ||
return window.crypto.subtle.digest("SHA-1", clientSessionKey); | ||
case 72: | ||
case 73: | ||
clientSessionKey = _context4.sent; | ||
clientSessionKey = new Uint8Array(clientSessionKey).slice(0, 16); | ||
_context4.next = 76; | ||
_context4.next = 77; | ||
return window.crypto.subtle.digest("SHA-1", serverSessionKey); | ||
case 76: | ||
case 77: | ||
serverSessionKey = _context4.sent; | ||
serverSessionKey = new Uint8Array(serverSessionKey).slice(0, 16); | ||
clientCipher = new RA2Cipher(); | ||
_context4.next = 81; | ||
_context4.next = 82; | ||
return clientCipher.setKey(clientSessionKey); | ||
case 81: | ||
case 82: | ||
serverCipher = new RA2Cipher(); | ||
_context4.next = 84; | ||
_context4.next = 85; | ||
return serverCipher.setKey(serverSessionKey); | ||
case 84: | ||
case 85: | ||
// 6: Compute and exchange hashes | ||
@@ -393,9 +394,9 @@ serverHash = new Uint8Array(8 + serverKeyBytes * 2 + clientKeyBytes * 2); | ||
clientHash.set(serverPublickey, 4 + clientKeyBytes * 2); | ||
_context4.next = 92; | ||
_context4.next = 93; | ||
return window.crypto.subtle.digest("SHA-1", serverHash); | ||
case 92: | ||
case 93: | ||
serverHash = _context4.sent; | ||
_context4.next = 95; | ||
_context4.next = 96; | ||
return window.crypto.subtle.digest("SHA-1", clientHash); | ||
case 95: | ||
case 96: | ||
clientHash = _context4.sent; | ||
@@ -405,64 +406,65 @@ serverHash = new Uint8Array(serverHash); | ||
_context4.t0 = this._sock; | ||
_context4.next = 101; | ||
_context4.next = 102; | ||
return clientCipher.makeMessage(clientHash); | ||
case 101: | ||
case 102: | ||
_context4.t1 = _context4.sent; | ||
_context4.t0.send.call(_context4.t0, _context4.t1); | ||
_context4.next = 105; | ||
_context4.next = 106; | ||
return this._waitSockAsync(2 + 20 + 16); | ||
case 105: | ||
case 106: | ||
if (!(this._sock.rQshift16() !== 20)) { | ||
_context4.next = 107; | ||
_context4.next = 108; | ||
break; | ||
} | ||
throw new Error("RA2: wrong server hash"); | ||
case 107: | ||
_context4.next = 109; | ||
case 108: | ||
_context4.next = 110; | ||
return serverCipher.receiveMessage(20, this._sock.rQshiftBytes(20 + 16)); | ||
case 109: | ||
case 110: | ||
serverHashReceived = _context4.sent; | ||
if (!(serverHashReceived === null)) { | ||
_context4.next = 112; | ||
_context4.next = 113; | ||
break; | ||
} | ||
throw new Error("RA2: failed to authenticate the message"); | ||
case 112: | ||
case 113: | ||
i = 0; | ||
case 113: | ||
case 114: | ||
if (!(i < 20)) { | ||
_context4.next = 119; | ||
_context4.next = 120; | ||
break; | ||
} | ||
if (!(serverHashReceived[i] !== serverHash[i])) { | ||
_context4.next = 116; | ||
_context4.next = 117; | ||
break; | ||
} | ||
throw new Error("RA2: wrong server hash"); | ||
case 116: | ||
case 117: | ||
i++; | ||
_context4.next = 113; | ||
_context4.next = 114; | ||
break; | ||
case 119: | ||
_context4.next = 121; | ||
case 120: | ||
_context4.next = 122; | ||
return this._waitSockAsync(2 + 1 + 16); | ||
case 121: | ||
case 122: | ||
if (!(this._sock.rQshift16() !== 1)) { | ||
_context4.next = 123; | ||
_context4.next = 124; | ||
break; | ||
} | ||
throw new Error("RA2: wrong subtype"); | ||
case 123: | ||
_context4.next = 125; | ||
case 124: | ||
_context4.next = 126; | ||
return serverCipher.receiveMessage(1, this._sock.rQshiftBytes(1 + 16)); | ||
case 125: | ||
case 126: | ||
subtype = _context4.sent; | ||
if (!(subtype === null)) { | ||
_context4.next = 128; | ||
_context4.next = 129; | ||
break; | ||
} | ||
throw new Error("RA2: failed to authenticate the message"); | ||
case 128: | ||
case 129: | ||
subtype = subtype[0]; | ||
waitCredentials = this._waitCredentialsAsync(subtype); | ||
if (!(subtype === 1)) { | ||
_context4.next = 133; | ||
_context4.next = 135; | ||
break; | ||
@@ -477,7 +479,7 @@ } | ||
} | ||
_context4.next = 138; | ||
_context4.next = 140; | ||
break; | ||
case 133: | ||
case 135: | ||
if (!(subtype === 2)) { | ||
_context4.next = 137; | ||
_context4.next = 139; | ||
break; | ||
@@ -492,10 +494,10 @@ } | ||
} | ||
_context4.next = 138; | ||
_context4.next = 140; | ||
break; | ||
case 137: | ||
case 139: | ||
throw new Error("RA2: wrong subtype"); | ||
case 138: | ||
_context4.next = 140; | ||
return this._waitCredentialsAsync(subtype); | ||
case 140: | ||
_context4.next = 142; | ||
return waitCredentials; | ||
case 142: | ||
if (subtype === 1) { | ||
@@ -517,8 +519,8 @@ username = (0, _strings.encodeUTF8)(this._getCredentials().username).slice(0, 255); | ||
_context4.t2 = this._sock; | ||
_context4.next = 150; | ||
_context4.next = 152; | ||
return clientCipher.makeMessage(credentials); | ||
case 150: | ||
case 152: | ||
_context4.t3 = _context4.sent; | ||
_context4.t2.send.call(_context4.t2, _context4.t3); | ||
case 152: | ||
case 154: | ||
case "end": | ||
@@ -525,0 +527,0 @@ return _context4.stop(); |
{ | ||
"name": "@novnc/novnc", | ||
"version": "1.4.0-gcbbd9ab", | ||
"version": "1.4.0-ge8ad466", | ||
"description": "An HTML5 VNC client", | ||
@@ -5,0 +5,0 @@ "browser": "lib/rfb", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1348224
31426