MCPcopy Create free account
hub / github.com/apache/cloudstack / _negotiateARDAuthAsync

Method _negotiateARDAuthAsync

systemvm/agent/noVNC/core/rfb.js:1992–2019  ·  view source on GitHub ↗
(keyLength, serverPublicKey, clientKey)

Source from the content-addressed store, hash-verified

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 ||

Callers 1

_negotiateARDAuthMethod · 0.95

Calls 7

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

Tested by

no test coverage detected