(keyLength, serverPublicKey, clientKey)
| 1990 | } |
| 1991 | |
| 1992 | async _negotiateARDAuthAsync(keyLength, serverPublicKey, clientKey) { |
| 1993 | const clientPublicKey = legacyCrypto.exportKey("raw", clientKey.publicKey); |
| 1994 | const sharedKey = legacyCrypto.deriveBits( |
| 1995 | { name: "DH", public: serverPublicKey }, clientKey.privateKey, keyLength * 8); |
| 1996 | |
| 1997 | const username = encodeUTF8(this._rfbCredentials.username).substring(0, 63); |
| 1998 | const password = encodeUTF8(this._rfbCredentials.password).substring(0, 63); |
| 1999 | |
| 2000 | const credentials = window.crypto.getRandomValues(new Uint8Array(128)); |
| 2001 | for (let i = 0; i < username.length; i++) { |
| 2002 | credentials[i] = username.charCodeAt(i); |
| 2003 | } |
| 2004 | credentials[username.length] = 0; |
| 2005 | for (let i = 0; i < password.length; i++) { |
| 2006 | credentials[64 + i] = password.charCodeAt(i); |
| 2007 | } |
| 2008 | credentials[64 + password.length] = 0; |
| 2009 | |
| 2010 | const key = await legacyCrypto.digest("MD5", sharedKey); |
| 2011 | const cipher = await legacyCrypto.importKey( |
| 2012 | "raw", key, { name: "AES-ECB" }, false, ["encrypt"]); |
| 2013 | const encrypted = await legacyCrypto.encrypt({ name: "AES-ECB" }, cipher, credentials); |
| 2014 | |
| 2015 | this._rfbCredentials.ardCredentials = encrypted; |
| 2016 | this._rfbCredentials.ardPublicKey = clientPublicKey; |
| 2017 | |
| 2018 | this._resumeAuthentication(); |
| 2019 | } |
| 2020 | |
| 2021 | _negotiateTightUnixAuth() { |
| 2022 | if (this._rfbCredentials.username === undefined || |
no test coverage detected