@novnc/novnc 1.3.0-gd8b3ec9 → 1.3.0-ge6fce71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core/rfb.js CHANGED
@@ -62,6 +62,7 @@ const securityTypeTight = 16;
62
62
  const securityTypeVeNCrypt = 19;
63
63
  const securityTypeXVP = 22;
64
64
  const securityTypeARD = 30;
65
+ const securityTypeMSLogonII = 113;
65
66
 
66
67
  // Special Tight security types
67
68
  const securityTypeUnixLogon = 129;
@@ -1392,6 +1393,7 @@ export default class RFB extends EventTargetMixin {
1392
1393
  securityTypeVeNCrypt,
1393
1394
  securityTypeXVP,
1394
1395
  securityTypeARD,
1396
+ securityTypeMSLogonII,
1395
1397
  securityTypePlain,
1396
1398
  ];
1397
1399
 
@@ -1903,6 +1905,62 @@ export default class RFB extends EventTargetMixin {
1903
1905
  return false;
1904
1906
  }
1905
1907
 
1908
+ _negotiateMSLogonIIAuth() {
1909
+ if (this._sock.rQwait("mslogonii dh param", 24)) { return false; }
1910
+
1911
+ if (this._rfbCredentials.username === undefined ||
1912
+ this._rfbCredentials.password === undefined) {
1913
+ this.dispatchEvent(new CustomEvent(
1914
+ "credentialsrequired",
1915
+ { detail: { types: ["username", "password"] } }));
1916
+ return false;
1917
+ }
1918
+
1919
+ const g = this._sock.rQshiftBytes(8);
1920
+ const p = this._sock.rQshiftBytes(8);
1921
+ const A = this._sock.rQshiftBytes(8);
1922
+ const b = window.crypto.getRandomValues(new Uint8Array(8));
1923
+ const B = new Uint8Array(this._modPow(g, b, p));
1924
+ const secret = new Uint8Array(this._modPow(A, b, p));
1925
+
1926
+ const des = new DES(secret);
1927
+ const username = encodeUTF8(this._rfbCredentials.username).substring(0, 255);
1928
+ const password = encodeUTF8(this._rfbCredentials.password).substring(0, 63);
1929
+ const usernameBytes = new Uint8Array(256);
1930
+ const passwordBytes = new Uint8Array(64);
1931
+ window.crypto.getRandomValues(usernameBytes);
1932
+ window.crypto.getRandomValues(passwordBytes);
1933
+ for (let i = 0; i < username.length; i++) {
1934
+ usernameBytes[i] = username.charCodeAt(i);
1935
+ }
1936
+ usernameBytes[username.length] = 0;
1937
+ for (let i = 0; i < password.length; i++) {
1938
+ passwordBytes[i] = password.charCodeAt(i);
1939
+ }
1940
+ passwordBytes[password.length] = 0;
1941
+ let x = new Uint8Array(secret);
1942
+ for (let i = 0; i < 32; i++) {
1943
+ for (let j = 0; j < 8; j++) {
1944
+ x[j] ^= usernameBytes[i * 8 + j];
1945
+ }
1946
+ x = des.enc8(x);
1947
+ usernameBytes.set(x, i * 8);
1948
+ }
1949
+ x = new Uint8Array(secret);
1950
+ for (let i = 0; i < 8; i++) {
1951
+ for (let j = 0; j < 8; j++) {
1952
+ x[j] ^= passwordBytes[i * 8 + j];
1953
+ }
1954
+ x = des.enc8(x);
1955
+ passwordBytes.set(x, i * 8);
1956
+ }
1957
+ this._sock.send(B);
1958
+ this._sock.send(usernameBytes);
1959
+ this._sock.send(passwordBytes);
1960
+ this._rfbInitState = "SecurityResult";
1961
+ return true;
1962
+ }
1963
+
1906
1964
  _negotiateAuthentication() {
1907
1965
  switch (this._rfbAuthScheme) {
1908
1966
  case securityTypeNone:
@@ -1933,6 +1991,9 @@ export default class RFB extends EventTargetMixin {
1933
1991
  case securityTypeRA2ne:
1934
1992
  return this._negotiateRA2neAuth();
1935
1993
 
1994
+ case securityTypeMSLogonII:
1995
+ return this._negotiateMSLogonIIAuth();
1996
+
1936
1997
  default:
1937
1998
  return this._fail("Unsupported auth scheme (scheme: " +
1938
1999
  this._rfbAuthScheme + ")");