diff options
author | Tobias Markmann <tm@ayena.de> | 2010-06-08 15:02:53 +0200 |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2010-06-08 15:02:53 +0200 |
commit | 9cbe1a37424c67bdaf451c78ba1fe298bac9ac2b (patch) | |
tree | 0e081c422438324547aec997627010d3049acb86 /plugins | |
parent | 392a5dc56c0fccbfe1a01d2cbafd95a405162b70 (diff) | |
download | prosody-9cbe1a37424c67bdaf451c78ba1fe298bac9ac2b.tar.gz prosody-9cbe1a37424c67bdaf451c78ba1fe298bac9ac2b.zip |
mod_auth_internal_hashed: Coverting salted password to stored_key and server_key.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_auth_internal_hashed.lua | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/plugins/mod_auth_internal_hashed.lua b/plugins/mod_auth_internal_hashed.lua index c1e56ab6..4e554584 100644 --- a/plugins/mod_auth_internal_hashed.lua +++ b/plugins/mod_auth_internal_hashed.lua @@ -22,6 +22,10 @@ local new_sasl = require "util.sasl".new; local nodeprep = require "util.encodings".stringprep.nodeprep; local hosts = hosts; +-- TODO: remove these two lines in near future +local hmac_sha1 = require "util.hmac".sha1; +local sha1 = require "util.hashes".sha1; + local prosody = _G.prosody; local is_cyrus = usermanager.is_cyrus; @@ -53,9 +57,20 @@ function new_hashpass_provider(host) return nil, "Auth failed. Stored salt and iteration count information is not complete."; end - if credentials.saltedPasswordSHA1 + local valid, stored_key, server_key + + if credentials.hexpass then + -- convert hexpass to stored_key and server_key + -- TODO: remove this in near future + valid = true; + local salted_password = credentials.hexpass:gsub("..", function(x) return string.char(tonumber(x, 16)); end); + + stored_key = sha1(hmac_sha1(salted_password, "Client Key")) + server_key = hmac_sha1(salted_password, "Server Key"); + else + valid, stored_key, server_key = getAuthenticationDatabaseSHA1(password, credentials.salt, credentials.iteration_count); + end - local valid, stored_key, server_key = getAuthenticationDatabaseSHA1(password, credentials.salt, credentials.iteration_count); local stored_key_hex = stored_key:gsub(".", function (c) return ("%02x"):format(c:byte()); end); local server_key_hex = server_key:gsub(".", function (c) return ("%02x"):format(c:byte()); end); |