Software /
code /
prosody
Comparison
plugins/mod_auth_internal_hashed.lua @ 3213:c85bba8bd41a
mod_auth_internal_hashed: Empty hashpass after conversion to stored_key/server_key and store new authentication database.
author | Tobias Markmann <tm@ayena.de> |
---|---|
date | Wed, 09 Jun 2010 17:58:20 +0200 |
parent | 3212:e416b9185c6b |
child | 3214:a69d8021b1db |
comparison
equal
deleted
inserted
replaced
3212:e416b9185c6b | 3213:c85bba8bd41a |
---|---|
64 if credentials.hashpass then | 64 if credentials.hashpass then |
65 valid = true; | 65 valid = true; |
66 local salted_password = credentials.hashpass:gsub("..", function(x) return string.char(tonumber(x, 16)); end); | 66 local salted_password = credentials.hashpass:gsub("..", function(x) return string.char(tonumber(x, 16)); end); |
67 credentials.stored_key = sha1(hmac_sha1(salted_password, "Client Key")):gsub(".", function (c) return ("%02x"):format(c:byte()); end); | 67 credentials.stored_key = sha1(hmac_sha1(salted_password, "Client Key")):gsub(".", function (c) return ("%02x"):format(c:byte()); end); |
68 credentials.server_key = hmac_sha1(salted_password, "Server Key"):gsub(".", function (c) return ("%02x"):format(c:byte()); end); | 68 credentials.server_key = hmac_sha1(salted_password, "Server Key"):gsub(".", function (c) return ("%02x"):format(c:byte()); end); |
69 credentials.hashpass = nil | |
70 datamanager.store(username, host, "accounts", credentials); | |
69 end | 71 end |
70 | 72 |
71 local valid, stored_key, server_key = getAuthenticationDatabaseSHA1(password, credentials.salt, credentials.iteration_count); | 73 local valid, stored_key, server_key = getAuthenticationDatabaseSHA1(password, credentials.salt, credentials.iteration_count); |
72 | 74 |
73 local stored_key_hex = stored_key:gsub(".", function (c) return ("%02x"):format(c:byte()); end); | 75 local stored_key_hex = stored_key:gsub(".", function (c) return ("%02x"):format(c:byte()); end); |
144 -- TODO: remove this in near future | 146 -- TODO: remove this in near future |
145 if credentials.hashpass then | 147 if credentials.hashpass then |
146 local salted_password = credentials.hashpass:gsub("..", function(x) return string.char(tonumber(x, 16)); end); | 148 local salted_password = credentials.hashpass:gsub("..", function(x) return string.char(tonumber(x, 16)); end); |
147 credentials.stored_key = sha1(hmac_sha1(salted_password, "Client Key")):gsub(".", function (c) return ("%02x"):format(c:byte()); end); | 149 credentials.stored_key = sha1(hmac_sha1(salted_password, "Client Key")):gsub(".", function (c) return ("%02x"):format(c:byte()); end); |
148 credentials.server_key = hmac_sha1(salted_password, "Server Key"):gsub(".", function (c) return ("%02x"):format(c:byte()); end); | 150 credentials.server_key = hmac_sha1(salted_password, "Server Key"):gsub(".", function (c) return ("%02x"):format(c:byte()); end); |
151 credentials.hashpass = nil | |
152 datamanager.store(username, host, "accounts", credentials); | |
149 end | 153 end |
150 | 154 |
151 local stored_key, server_key, iteration_count, salt = credentials.stored_key, credentials.server_key, credentials.iteration_count, credentials.salt; | 155 local stored_key, server_key, iteration_count, salt = credentials.stored_key, credentials.server_key, credentials.iteration_count, credentials.salt; |
152 stored_key = stored_key and stored_key:gsub("..", function(x) return string.char(tonumber(x, 16)); end); | 156 stored_key = stored_key and stored_key:gsub("..", function(x) return string.char(tonumber(x, 16)); end); |
153 server_key = server_key and server_key:gsub("..", function(x) return string.char(tonumber(x, 16)); end); | 157 server_key = server_key and server_key:gsub("..", function(x) return string.char(tonumber(x, 16)); end); |