()
| 1949 | } |
| 1950 | |
| 1951 | _negotiateARDAuth() { |
| 1952 | |
| 1953 | if (this._rfbCredentials.username === undefined || |
| 1954 | this._rfbCredentials.password === undefined) { |
| 1955 | this.dispatchEvent(new CustomEvent( |
| 1956 | "credentialsrequired", |
| 1957 | { detail: { types: ["username", "password"] } })); |
| 1958 | return false; |
| 1959 | } |
| 1960 | |
| 1961 | if (this._rfbCredentials.ardPublicKey != undefined && |
| 1962 | this._rfbCredentials.ardCredentials != undefined) { |
| 1963 | // if the async web crypto is done return the results |
| 1964 | this._sock.sQpushBytes(this._rfbCredentials.ardCredentials); |
| 1965 | this._sock.sQpushBytes(this._rfbCredentials.ardPublicKey); |
| 1966 | this._sock.flush(); |
| 1967 | this._rfbCredentials.ardCredentials = null; |
| 1968 | this._rfbCredentials.ardPublicKey = null; |
| 1969 | this._rfbInitState = "SecurityResult"; |
| 1970 | return true; |
| 1971 | } |
| 1972 | |
| 1973 | if (this._sock.rQwait("read ard", 4)) { return false; } |
| 1974 | |
| 1975 | let generator = this._sock.rQshiftBytes(2); // DH base generator value |
| 1976 | |
| 1977 | let keyLength = this._sock.rQshift16(); |
| 1978 | |
| 1979 | if (this._sock.rQwait("read ard keylength", keyLength*2, 4)) { return false; } |
| 1980 | |
| 1981 | // read the server values |
| 1982 | let prime = this._sock.rQshiftBytes(keyLength); // predetermined prime modulus |
| 1983 | let serverPublicKey = this._sock.rQshiftBytes(keyLength); // other party's public key |
| 1984 | |
| 1985 | let clientKey = legacyCrypto.generateKey( |
| 1986 | { name: "DH", g: generator, p: prime }, false, ["deriveBits"]); |
| 1987 | this._negotiateARDAuthAsync(keyLength, serverPublicKey, clientKey); |
| 1988 | |
| 1989 | return false; |
| 1990 | } |
| 1991 | |
| 1992 | async _negotiateARDAuthAsync(keyLength, serverPublicKey, clientKey) { |
| 1993 | const clientPublicKey = legacyCrypto.exportKey("raw", clientKey.publicKey); |
no test coverage detected