()
| 1826 | |
| 1827 | // VeNCrypt authentication, currently only supports version 0.2 and only Plain subtype |
| 1828 | _negotiateVeNCryptAuth() { |
| 1829 | |
| 1830 | // waiting for VeNCrypt version |
| 1831 | if (this._rfbVeNCryptState == 0) { |
| 1832 | if (this._sock.rQwait("vencrypt version", 2)) { return false; } |
| 1833 | |
| 1834 | const major = this._sock.rQshift8(); |
| 1835 | const minor = this._sock.rQshift8(); |
| 1836 | |
| 1837 | if (!(major == 0 && minor == 2)) { |
| 1838 | return this._fail("Unsupported VeNCrypt version " + major + "." + minor); |
| 1839 | } |
| 1840 | |
| 1841 | this._sock.sQpush8(0); |
| 1842 | this._sock.sQpush8(2); |
| 1843 | this._sock.flush(); |
| 1844 | this._rfbVeNCryptState = 1; |
| 1845 | } |
| 1846 | |
| 1847 | // waiting for ACK |
| 1848 | if (this._rfbVeNCryptState == 1) { |
| 1849 | if (this._sock.rQwait("vencrypt ack", 1)) { return false; } |
| 1850 | |
| 1851 | const res = this._sock.rQshift8(); |
| 1852 | |
| 1853 | if (res != 0) { |
| 1854 | return this._fail("VeNCrypt failure " + res); |
| 1855 | } |
| 1856 | |
| 1857 | this._rfbVeNCryptState = 2; |
| 1858 | } |
| 1859 | // must fall through here (i.e. no "else if"), beacause we may have already received |
| 1860 | // the subtypes length and won't be called again |
| 1861 | |
| 1862 | if (this._rfbVeNCryptState == 2) { // waiting for subtypes length |
| 1863 | if (this._sock.rQwait("vencrypt subtypes length", 1)) { return false; } |
| 1864 | |
| 1865 | const subtypesLength = this._sock.rQshift8(); |
| 1866 | if (subtypesLength < 1) { |
| 1867 | return this._fail("VeNCrypt subtypes empty"); |
| 1868 | } |
| 1869 | |
| 1870 | this._rfbVeNCryptSubtypesLength = subtypesLength; |
| 1871 | this._rfbVeNCryptState = 3; |
| 1872 | } |
| 1873 | |
| 1874 | // waiting for subtypes list |
| 1875 | if (this._rfbVeNCryptState == 3) { |
| 1876 | if (this._sock.rQwait("vencrypt subtypes", 4 * this._rfbVeNCryptSubtypesLength)) { return false; } |
| 1877 | |
| 1878 | const subtypes = []; |
| 1879 | for (let i = 0; i < this._rfbVeNCryptSubtypesLength; i++) { |
| 1880 | subtypes.push(this._sock.rQshift32()); |
| 1881 | } |
| 1882 | |
| 1883 | // Look for a matching security type in the order that the |
| 1884 | // server prefers |
| 1885 | this._rfbAuthScheme = -1; |
no test coverage detected