Comparison

core/s2smanager.lua @ 448:2623519b25b0

Switched from md5 to sha256 for dialback key generation
author Waqas Hussain <waqas20@gmail.com>
date Fri, 28 Nov 2008 01:13:34 +0500
parent 435:4087aa611de2
child 451:e9f269e5204e
comparison
equal deleted inserted replaced
447:c0dae734d3bf 448:2623519b25b0
19 19
20 local logger_init = require "util.logger".init; 20 local logger_init = require "util.logger".init;
21 21
22 local log = logger_init("s2smanager"); 22 local log = logger_init("s2smanager");
23 23
24 local md5_hash = require "util.hashes".md5; 24 local sha256_hash = require "util.hashes".sha256;
25 25
26 local dialback_secret = "This is very secret!!! Ha!"; 26 local dialback_secret = "This is very secret!!! Ha!";
27 27
28 local dns = require "net.dns"; 28 local dns = require "net.dns";
29 29
208 session.sends2s(format("<db:result from='%s' to='%s'>%s</db:result>", session.from_host, session.to_host, session.dialback_key)); 208 session.sends2s(format("<db:result from='%s' to='%s'>%s</db:result>", session.from_host, session.to_host, session.dialback_key));
209 session.log("info", "sent dialback key on outgoing s2s stream"); 209 session.log("info", "sent dialback key on outgoing s2s stream");
210 end 210 end
211 211
212 function generate_dialback(id, to, from) 212 function generate_dialback(id, to, from)
213 return md5_hash(id..to..from..dialback_secret); -- FIXME: See XEP-185 and XEP-220 213 return sha256_hash(id..to..from..dialback_secret, true);
214 end 214 end
215 215
216 function verify_dialback(id, to, from, key) 216 function verify_dialback(id, to, from, key)
217 return key == generate_dialback(id, to, from); 217 return key == generate_dialback(id, to, from);
218 end 218 end