Skip to content

Commit de64e1e

Browse files
committed
#370 don't convert xored strings to hex
1 parent 4af417c commit de64e1e

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

html5/js/Client.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2815,6 +2815,7 @@ class XpraClient {
28152815
const client = this;
28162816

28172817
function call_do_process_challenge(password) {
2818+
Utilities.clog("call_do_process_challenge(", password, ")");
28182819
if (!client || !client.protocol) {
28192820
return;
28202821
}
@@ -2878,16 +2879,29 @@ class XpraClient {
28782879
this.clog("using", salt_digest);
28792880
Utilities.gendigest(salt_digest, client_salt, server_salt)
28802881
.then(salt => {
2881-
this.clog(salt_digest, ":", Utilities.convertToHex(salt));
28822882
const hex_salt = Utilities.convertToHex(salt);
2883+
this.clog(salt_digest, ":", hex_salt);
2884+
if (challenge_digest == "xor") {
2885+
// shortcut: no need for async API, do not convert the result to hex
2886+
const xored = Utilities.xor(password, hex_salt);
2887+
this.do_send_hello(xored, client_salt);
2888+
return;
2889+
}
2890+
28832891
Utilities.gendigest(challenge_digest, password, hex_salt)
28842892
.then(challenge_response => {
28852893
const hex_challenge = Utilities.convertToHex(challenge_response);
28862894
this.do_send_hello(hex_challenge, client_salt)
28872895
})
2888-
.catch(err => this.disconnect("failed to generate challenge response: " + err));
2896+
.catch(err => {
2897+
this.cerror("challenge digest error", err);
2898+
this.disconnect("failed to generate challenge response " + err);
2899+
});
28892900
})
2890-
.catch(err => this.disconnect("failed to generate salt: " + err));
2901+
.catch(err => {
2902+
this.cerror("salt digest error", err);
2903+
this.disconnect("failed to generate challenge response " + err);
2904+
});
28912905
}
28922906

28932907
_send_ping() {

html5/js/Utilities.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ const Utilities = {
9595
return new Uint8Array(value);
9696
},
9797

98+
xor(str1, str2) {
99+
const trimmed_str2 = str2.slice(0, str1.length);
100+
return Utilities.xorString(str1, trimmed_str2);
101+
},
102+
98103
gendigest(digest, password, salt) {
104+
Utilities.clog("gendigest(", digest, ", ", password, ", ", salt, ")");
99105
if (digest == "xor") {
100106
const trimmed_salt = salt.slice(0, password.length);
101107
// Utilities.debug("xoring with trimmed salt:", Utilities.convertToHex(trimmed_salt));
@@ -121,6 +127,8 @@ const Utilities = {
121127
}
122128

123129
const promise = new Promise(function(resolve, reject) {
130+
Utilities.clog("crypto.subtle=", crypto.subtle);
131+
Utilities.clog("crypto.subtle.importKey=", crypto.subtle.importKey);
124132
crypto.subtle.importKey("raw", Utilities.u8(password), {
125133
name: "HMAC",
126134
hash: hash

0 commit comments

Comments
 (0)