()
| 1792 | } |
| 1793 | |
| 1794 | _negotiateARDAuth() { |
| 1795 | |
| 1796 | if (this._rfbCredentials.username === undefined || |
| 1797 | this._rfbCredentials.password === undefined) { |
| 1798 | this.dispatchEvent(new CustomEvent( |
| 1799 | "credentialsrequired", |
| 1800 | { detail: { types: ["username", "password"] } })); |
| 1801 | return false; |
| 1802 | } |
| 1803 | |
| 1804 | if (this._rfbCredentials.ardPublicKey != undefined && |
| 1805 | this._rfbCredentials.ardCredentials != undefined) { |
| 1806 | // if the async web crypto is done return the results |
| 1807 | this._sock.sQpushBytes(this._rfbCredentials.ardCredentials); |
| 1808 | this._sock.sQpushBytes(this._rfbCredentials.ardPublicKey); |
| 1809 | this._sock.flush(); |
| 1810 | this._rfbCredentials.ardCredentials = null; |
| 1811 | this._rfbCredentials.ardPublicKey = null; |
| 1812 | this._rfbInitState = "SecurityResult"; |
| 1813 | return true; |
| 1814 | } |
| 1815 | |
| 1816 | if (this._sock.rQwait("read ard", 4)) { return false; } |
| 1817 | |
| 1818 | let generator = this._sock.rQshiftBytes(2); // DH base generator value |
| 1819 | |
| 1820 | let keyLength = this._sock.rQshift16(); |
| 1821 | |
| 1822 | if (this._sock.rQwait("read ard keylength", keyLength*2, 4)) { return false; } |
| 1823 | |
| 1824 | // read the server values |
| 1825 | let prime = this._sock.rQshiftBytes(keyLength); // predetermined prime modulus |
| 1826 | let serverPublicKey = this._sock.rQshiftBytes(keyLength); // other party's public key |
| 1827 | |
| 1828 | let clientKey = legacyCrypto.generateKey( |
| 1829 | { name: "DH", g: generator, p: prime }, false, ["deriveBits"]); |
| 1830 | this._negotiateARDAuthAsync(keyLength, serverPublicKey, clientKey); |
| 1831 | |
| 1832 | return false; |
| 1833 | } |
| 1834 | |
| 1835 | async _negotiateARDAuthAsync(keyLength, serverPublicKey, clientKey) { |
| 1836 | const clientPublicKey = legacyCrypto.exportKey("raw", clientKey.publicKey); |
no test coverage detected