# HG changeset patch # User Tobias Markmann # Date 1276098874 -7200 # Node ID d69e90ffbc091d7e540551d803db28409df6a342 # Parent 5e51f8a7179b676453e75a2326213ea2c0f35e99 mod_auth_internal_hashed: Convert hashpass to server_key/stored_key on SCRAM-SHA-1 login. diff -r 5e51f8a7179b -r d69e90ffbc09 plugins/mod_auth_internal_hashed.lua --- a/plugins/mod_auth_internal_hashed.lua Wed Jun 09 17:51:08 2010 +0200 +++ b/plugins/mod_auth_internal_hashed.lua Wed Jun 09 17:54:34 2010 +0200 @@ -140,6 +140,15 @@ 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);