Software /
code /
prosody
Comparison
util/sasl.lua @ 1518:9707dfa80980
util.sasl: Convert spaces to tabs
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 10 Jul 2009 02:26:43 +0100 |
parent | 1485:fbefd16d2955 |
child | 1585:edc066730d11 |
child | 1720:c34409a5fdee |
comparison
equal
deleted
inserted
replaced
1517:22be7637a64d | 1518:9707dfa80980 |
---|---|
31 module "sasl" | 31 module "sasl" |
32 | 32 |
33 local function new_plain(realm, password_handler) | 33 local function new_plain(realm, password_handler) |
34 local object = { mechanism = "PLAIN", realm = realm, password_handler = password_handler} | 34 local object = { mechanism = "PLAIN", realm = realm, password_handler = password_handler} |
35 function object.feed(self, message) | 35 function object.feed(self, message) |
36 | 36 |
37 if message == "" or message == nil then return "failure", "malformed-request" end | 37 if message == "" or message == nil then return "failure", "malformed-request" end |
38 local response = message | 38 local response = message |
39 local authorization = s_match(response, "([^&%z]+)") | 39 local authorization = s_match(response, "([^&%z]+)") |
40 local authentication = s_match(response, "%z([^&%z]+)%z") | 40 local authentication = s_match(response, "%z([^&%z]+)%z") |
41 local password = s_match(response, "%z[^&%z]+%z([^&%z]+)") | 41 local password = s_match(response, "%z[^&%z]+%z([^&%z]+)") |
227 -- calculate rspauth | 227 -- calculate rspauth |
228 A2 = ":"..protocol.."/"..domain; | 228 A2 = ":"..protocol.."/"..domain; |
229 | 229 |
230 HA1 = md5(A1, true); | 230 HA1 = md5(A1, true); |
231 HA2 = md5(A2, true); | 231 HA2 = md5(A2, true); |
232 | 232 |
233 KD = HA1..":"..response["nonce"]..":"..response["nc"]..":"..response["cnonce"]..":"..response["qop"]..":"..HA2 | 233 KD = HA1..":"..response["nonce"]..":"..response["nc"]..":"..response["cnonce"]..":"..response["qop"]..":"..HA2 |
234 local rspauth = md5(KD, true); | 234 local rspauth = md5(KD, true); |
235 self.authenticated = true; | 235 self.authenticated = true; |
236 return "challenge", serialize({rspauth = rspauth}); | 236 return "challenge", serialize({rspauth = rspauth}); |
237 else | 237 else |