clix: Support SCRAM hashes stored as hex in config

Wed, 03 Aug 2022 03:02:12 +0200

author
Kim Alvefur <zash@zash.se>
date
Wed, 03 Aug 2022 03:02:12 +0200
changeset 166
b0c586241224
parent 165
e4391832be1e
child 167
57bb6e03d239

clix: Support SCRAM hashes stored as hex in config

clix.lua file | annotate | diff | comparison | revisions
--- a/clix.lua	Wed Aug 03 03:01:26 2022 +0200
+++ b/clix.lua	Wed Aug 03 03:02:12 2022 +0200
@@ -111,12 +111,22 @@
 	conn.connect_host = account.address;
 	conn.connect_port = account.port;
 
-	if not account.password and opts.interactive then
+	if not account.password and not (account.clientkey and account.serverkey) and opts.interactive then
 		account.password = read_password()
 	end
+
+	local clientkey, serverkey = account.clientkey, account.serverkey;
+	if clientkey and serverkey then
+		local hex = require "util.hex";
+		clientkey = hex.from(clientkey);
+		serverkey = hex.from(serverkey);
+	elseif clientkey or serverkey then
+		conn:warn("Only one of 'clientkey' and 'serverkey' available, both reqired for SCRAM")
+		clientkey, serverkey = nil, nil;
+	end
 	
 	-- Connect!
-	conn:connect_client(account.jid, account.password);
+	conn:connect_client(account.jid, account.password, clientkey, serverkey);
 	
 	-- COMPAT: Tigase discards stanzas sent at the same time as </stream:stream>
 	local _real_close = conn.close;

mercurial