()
| 2080 | } |
| 2081 | |
| 2082 | _negotiateTightAuth() { |
| 2083 | if (!this._rfbTightVNC) { // first pass, do the tunnel negotiation |
| 2084 | if (this._sock.rQwait("num tunnels", 4)) { return false; } |
| 2085 | const numTunnels = this._sock.rQshift32(); |
| 2086 | if (numTunnels > 0 && this._sock.rQwait("tunnel capabilities", 16 * numTunnels, 4)) { return false; } |
| 2087 | |
| 2088 | this._rfbTightVNC = true; |
| 2089 | |
| 2090 | if (numTunnels > 0) { |
| 2091 | this._negotiateTightTunnels(numTunnels); |
| 2092 | return false; // wait until we receive the sub auth to continue |
| 2093 | } |
| 2094 | } |
| 2095 | |
| 2096 | // second pass, do the sub-auth negotiation |
| 2097 | if (this._sock.rQwait("sub auth count", 4)) { return false; } |
| 2098 | const subAuthCount = this._sock.rQshift32(); |
| 2099 | if (subAuthCount === 0) { // empty sub-auth list received means 'no auth' subtype selected |
| 2100 | this._rfbInitState = 'SecurityResult'; |
| 2101 | return true; |
| 2102 | } |
| 2103 | |
| 2104 | if (this._sock.rQwait("sub auth capabilities", 16 * subAuthCount, 4)) { return false; } |
| 2105 | |
| 2106 | const clientSupportedTypes = { |
| 2107 | 'STDVNOAUTH__': 1, |
| 2108 | 'STDVVNCAUTH_': 2, |
| 2109 | 'TGHTULGNAUTH': 129 |
| 2110 | }; |
| 2111 | |
| 2112 | const serverSupportedTypes = []; |
| 2113 | |
| 2114 | for (let i = 0; i < subAuthCount; i++) { |
| 2115 | this._sock.rQshift32(); // capNum |
| 2116 | const capabilities = this._sock.rQshiftStr(12); |
| 2117 | serverSupportedTypes.push(capabilities); |
| 2118 | } |
| 2119 | |
| 2120 | Log.Debug("Server Tight authentication types: " + serverSupportedTypes); |
| 2121 | |
| 2122 | for (let authType in clientSupportedTypes) { |
| 2123 | if (serverSupportedTypes.indexOf(authType) != -1) { |
| 2124 | this._sock.sQpush32(clientSupportedTypes[authType]); |
| 2125 | this._sock.flush(); |
| 2126 | Log.Debug("Selected authentication type: " + authType); |
| 2127 | |
| 2128 | switch (authType) { |
| 2129 | case 'STDVNOAUTH__': // no auth |
| 2130 | this._rfbInitState = 'SecurityResult'; |
| 2131 | return true; |
| 2132 | case 'STDVVNCAUTH_': |
| 2133 | this._rfbAuthScheme = securityTypeVNCAuth; |
| 2134 | return true; |
| 2135 | case 'TGHTULGNAUTH': |
| 2136 | this._rfbAuthScheme = securityTypeUnixLogon; |
| 2137 | return true; |
| 2138 | default: |
| 2139 | return this._fail("Unsupported tiny auth scheme " + |
no test coverage detected