aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-11-27 23:36:49 +0000
committerMatthew Wild <mwild1@gmail.com>2008-11-27 23:36:49 +0000
commitefd0ef64bb4cbf51ecbd51280b4cf42d7f6e6ed8 (patch)
treefbb36c13b7526cb3f7d79d364e8b338c4fc81b34 /util
parentf588a0f5b0dd4c6b6d2c81a517594b50b45fc15b (diff)
parent631e249397fd7cd2a2c5a7cb4c1feba664a41b2e (diff)
downloadprosody-efd0ef64bb4cbf51ecbd51280b4cf42d7f6e6ed8.tar.gz
prosody-efd0ef64bb4cbf51ecbd51280b4cf42d7f6e6ed8.zip
Merge from waqas
Diffstat (limited to 'util')
-rw-r--r--util/dependencies.lua8
-rw-r--r--util/hashes.lua30
-rw-r--r--util/sasl.lua14
3 files changed, 7 insertions, 45 deletions
diff --git a/util/dependencies.lua b/util/dependencies.lua
index 3213a356..682afd15 100644
--- a/util/dependencies.lua
+++ b/util/dependencies.lua
@@ -43,12 +43,4 @@ if not ssl then
end
-local md5 = softreq "md5";
-
-if not md5 then
- missingdep("MD5", { ["luarocks"] = "luarocks install md5"; ["Source"] = "http://luaforge.net/frs/?group_id=155" });
- fatal = true;
-end
-
-
if fatal then os.exit(1); end
diff --git a/util/hashes.lua b/util/hashes.lua
deleted file mode 100644
index 2fd0fbd8..00000000
--- a/util/hashes.lua
+++ /dev/null
@@ -1,30 +0,0 @@
-
-local softreq = function (...) local ok, lib = pcall(require, ...); if ok then return lib; else return nil; end end
-local error = error;
-
-module "hashes"
-
-local md5 = softreq("md5");
-if md5 then
- if md5.digest then
- local md5_digest = md5.digest;
- local sha1_digest = sha1.digest;
- function _M.md5(input)
- return md5_digest(input);
- end
- function _M.sha1(input)
- return sha1_digest(input);
- end
- elseif md5.sumhexa then
- local md5_sumhexa = md5.sumhexa;
- function _M.md5(input)
- return md5_sumhexa(input);
- end
- else
- error("md5 library found, but unrecognised... no hash functions will be available", 0);
- end
-else
- error("No md5 library found. Install md5 using luarocks, for example", 0);
-end
-
-return _M;
diff --git a/util/sasl.lua b/util/sasl.lua
index 7cabd8b3..001f40fb 100644
--- a/util/sasl.lua
+++ b/util/sasl.lua
@@ -1,5 +1,5 @@
-local md5 = require "md5"
+local md5 = require "util.hashes".md5;
local log = require "util.logger".init("sasl");
local tostring = tostring;
local st = require "util.stanza";
@@ -132,21 +132,21 @@ local function new_digest_md5(realm, password_handler)
local A1 = Y..":"..response["nonce"]..":"..response["cnonce"]--:authzid
local A2 = "AUTHENTICATE:"..protocol.."/"..domain
- local HA1 = md5.sumhexa(A1)
- local HA2 = md5.sumhexa(A2)
+ local HA1 = md5(A1, true)
+ local HA2 = md5(A2, true)
local KD = HA1..":"..response["nonce"]..":"..response["nc"]..":"..response["cnonce"]..":"..response["qop"]..":"..HA2
- local response_value = md5.sumhexa(KD)
+ local response_value = md5(KD, true)
if response_value == response["response"] then
-- calculate rspauth
A2 = ":"..protocol.."/"..domain
- HA1 = md5.sumhexa(A1)
- HA2 = md5.sumhexa(A2)
+ HA1 = md5(A1, true)
+ HA2 = md5(A2, true)
KD = HA1..":"..response["nonce"]..":"..response["nc"]..":"..response["cnonce"]..":"..response["qop"]..":"..HA2
- local rspauth = md5.sumhexa(KD)
+ local rspauth = md5(KD, true)
self.authenticated = true
return "challenge", serialize({rspauth = rspauth})
else