aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_auth_internal_hashed.lua
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2010-06-09 17:54:34 +0200
committerTobias Markmann <tm@ayena.de>2010-06-09 17:54:34 +0200
commit282c761001d958f0641e063026c0a3b242fd0df2 (patch)
tree4a47d1410ff9005329ef0626fa425f8f9f5bf5d9 /plugins/mod_auth_internal_hashed.lua
parentd543622be3cad382c9f2b4febf1e8cb7f47d21d8 (diff)
downloadprosody-282c761001d958f0641e063026c0a3b242fd0df2.tar.gz
prosody-282c761001d958f0641e063026c0a3b242fd0df2.zip
mod_auth_internal_hashed: Convert hashpass to server_key/stored_key on SCRAM-SHA-1 login.
Diffstat (limited to 'plugins/mod_auth_internal_hashed.lua')
-rw-r--r--plugins/mod_auth_internal_hashed.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/plugins/mod_auth_internal_hashed.lua b/plugins/mod_auth_internal_hashed.lua
index 59aef1ec..854138e8 100644
--- a/plugins/mod_auth_internal_hashed.lua
+++ b/plugins/mod_auth_internal_hashed.lua
@@ -140,6 +140,15 @@ function new_hashpass_provider(host)
usermanager.set_password(username, credentials.password);
credentials = datamanager.load(username, host, "accounts") or {};
end
+
+ -- convert hexpass to stored_key and server_key
+ -- TODO: remove this in near future
+ if credentials.hashpass then
+ local salted_password = credentials.hashpass:gsub("..", function(x) return string.char(tonumber(x, 16)); end);
+ credentials.stored_key = sha1(hmac_sha1(salted_password, "Client Key")):gsub(".", function (c) return ("%02x"):format(c:byte()); end);
+ credentials.server_key = hmac_sha1(salted_password, "Server Key"):gsub(".", function (c) return ("%02x"):format(c:byte()); end);
+ end
+
local stored_key, server_key, iteration_count, salt = credentials.stored_key, credentials.server_key, credentials.iteration_count, credentials.salt;
stored_key = stored_key and stored_key:gsub("..", function(x) return string.char(tonumber(x, 16)); end);
server_key = server_key and server_key:gsub("..", function(x) return string.char(tonumber(x, 16)); end);