MCPcopy
hub / github.com/novnc/noVNC / _negotiateARDAuthAsync

Method _negotiateARDAuthAsync

core/rfb.js:1835–1862  ·  view source on GitHub ↗
(keyLength, serverPublicKey, clientKey)

Source from the content-addressed store, hash-verified

1833 }
1834
1835 async _negotiateARDAuthAsync(keyLength, serverPublicKey, clientKey) {
1836 const clientPublicKey = legacyCrypto.exportKey("raw", clientKey.publicKey);
1837 const sharedKey = legacyCrypto.deriveBits(
1838 { name: "DH", public: serverPublicKey }, clientKey.privateKey, keyLength * 8);
1839
1840 const username = encodeUTF8(this._rfbCredentials.username).substring(0, 63);
1841 const password = encodeUTF8(this._rfbCredentials.password).substring(0, 63);
1842
1843 const credentials = window.crypto.getRandomValues(new Uint8Array(128));
1844 for (let i = 0; i < username.length; i++) {
1845 credentials[i] = username.charCodeAt(i);
1846 }
1847 credentials[username.length] = 0;
1848 for (let i = 0; i < password.length; i++) {
1849 credentials[64 + i] = password.charCodeAt(i);
1850 }
1851 credentials[64 + password.length] = 0;
1852
1853 const key = await legacyCrypto.digest("MD5", sharedKey);
1854 const cipher = await legacyCrypto.importKey(
1855 "raw", key, { name: "AES-ECB" }, false, ["encrypt"]);
1856 const encrypted = await legacyCrypto.encrypt({ name: "AES-ECB" }, cipher, credentials);
1857
1858 this._rfbCredentials.ardCredentials = encrypted;
1859 this._rfbCredentials.ardPublicKey = clientPublicKey;
1860
1861 this._resumeAuthentication();
1862 }
1863
1864 _negotiateTightUnixAuth() {
1865 if (this._rfbCredentials.username === undefined ||

Callers 1

_negotiateARDAuthMethod · 0.95

Calls 7

_resumeAuthenticationMethod · 0.95
encodeUTF8Function · 0.90
digestMethod · 0.80
exportKeyMethod · 0.45
deriveBitsMethod · 0.45
importKeyMethod · 0.45
encryptMethod · 0.45

Tested by

no test coverage detected