util/sasl.lua

changeset 603
423fd24fff54
parent 602
a977227aa9e6
child 615
4ae3e81513f3
equal deleted inserted replaced
602:a977227aa9e6 603:423fd24fff54
203 local password_encoding, Y = self.password_handler(response["username"], response["realm"], "DIGEST-MD5", decoder) 203 local password_encoding, Y = self.password_handler(response["username"], response["realm"], "DIGEST-MD5", decoder)
204 if Y == nil then return "failure", "not-authorized" 204 if Y == nil then return "failure", "not-authorized"
205 elseif Y == false then return "failure", "account-disabled" end 205 elseif Y == false then return "failure", "account-disabled" end
206 206
207 local A1 = Y..":"..response["nonce"]..":"..response["cnonce"]--:authzid 207 local A1 = Y..":"..response["nonce"]..":"..response["cnonce"]--:authzid
208 local A2 = "AUTHENTICATE:"..protocol.."/"..idna_ascii(domain) 208 local A2 = "AUTHENTICATE:"..protocol.."/"..domain;
209 209
210 local HA1 = md5(A1, true) 210 local HA1 = md5(A1, true)
211 local HA2 = md5(A2, true) 211 local HA2 = md5(A2, true)
212 212
213 local KD = HA1..":"..response["nonce"]..":"..response["nc"]..":"..response["cnonce"]..":"..response["qop"]..":"..HA2 213 local KD = HA1..":"..response["nonce"]..":"..response["nc"]..":"..response["cnonce"]..":"..response["qop"]..":"..HA2
214 local response_value = md5(KD, true) 214 local response_value = md5(KD, true)
215 215
216 if response_value == response["response"] then 216 if response_value == response["response"] then
217 -- calculate rspauth 217 -- calculate rspauth
218 A2 = ":"..protocol.."/"..idna_ascii(domain) 218 A2 = ":"..protocol.."/"..domain;
219 219
220 HA1 = md5(A1, true) 220 HA1 = md5(A1, true)
221 HA2 = md5(A2, true) 221 HA2 = md5(A2, true)
222 222
223 KD = HA1..":"..response["nonce"]..":"..response["nc"]..":"..response["cnonce"]..":"..response["qop"]..":"..HA2 223 KD = HA1..":"..response["nonce"]..":"..response["nc"]..":"..response["cnonce"]..":"..response["qop"]..":"..HA2

mercurial