Software / code / prosody
Comparison
plugins/mod_auth_internal_hashed.lua @ 3211:d69e90ffbc09
mod_auth_internal_hashed: Convert hashpass to server_key/stored_key on SCRAM-SHA-1 login.
| author | Tobias Markmann <tm@ayena.de> |
|---|---|
| date | Wed, 09 Jun 2010 17:54:34 +0200 |
| parent | 3210:5e51f8a7179b |
| child | 3212:e416b9185c6b |
comparison
equal
deleted
inserted
replaced
| 3210:5e51f8a7179b | 3211:d69e90ffbc09 |
|---|---|
| 138 local credentials = datamanager.load(username, host, "accounts") or {}; | 138 local credentials = datamanager.load(username, host, "accounts") or {}; |
| 139 if credentials.password then | 139 if credentials.password then |
| 140 usermanager.set_password(username, credentials.password); | 140 usermanager.set_password(username, credentials.password); |
| 141 credentials = datamanager.load(username, host, "accounts") or {}; | 141 credentials = datamanager.load(username, host, "accounts") or {}; |
| 142 end | 142 end |
| 143 | |
| 144 -- convert hexpass to stored_key and server_key | |
| 145 -- TODO: remove this in near future | |
| 146 if credentials.hashpass then | |
| 147 local salted_password = credentials.hashpass:gsub("..", function(x) return string.char(tonumber(x, 16)); end); | |
| 148 credentials.stored_key = sha1(hmac_sha1(salted_password, "Client Key")):gsub(".", function (c) return ("%02x"):format(c:byte()); end); | |
| 149 credentials.server_key = hmac_sha1(salted_password, "Server Key"):gsub(".", function (c) return ("%02x"):format(c:byte()); end); | |
| 150 end | |
| 151 | |
| 143 local stored_key, server_key, iteration_count, salt = credentials.stored_key, credentials.server_key, credentials.iteration_count, credentials.salt; | 152 local stored_key, server_key, iteration_count, salt = credentials.stored_key, credentials.server_key, credentials.iteration_count, credentials.salt; |
| 144 stored_key = stored_key and stored_key:gsub("..", function(x) return string.char(tonumber(x, 16)); end); | 153 stored_key = stored_key and stored_key:gsub("..", function(x) return string.char(tonumber(x, 16)); end); |
| 145 server_key = server_key and server_key:gsub("..", function(x) return string.char(tonumber(x, 16)); end); | 154 server_key = server_key and server_key:gsub("..", function(x) return string.char(tonumber(x, 16)); end); |
| 146 return stored_key, server_key, iteration_count, salt, true; | 155 return stored_key, server_key, iteration_count, salt, true; |
| 147 end | 156 end |