Software / code / prosody
Comparison
plugins/mod_dialback.lua @ 7104:352270bc0439 0.9.10
Merge
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 27 Jan 2016 00:06:30 +0100 |
| parent | 7103:5c6e78dc1864 |
| child | 7106:74798480b52e |
comparison
equal
deleted
inserted
replaced
| 7100:301d58705667 | 7104:352270bc0439 |
|---|---|
| 10 | 10 |
| 11 local log = module._log; | 11 local log = module._log; |
| 12 | 12 |
| 13 local st = require "util.stanza"; | 13 local st = require "util.stanza"; |
| 14 local sha256_hash = require "util.hashes".sha256; | 14 local sha256_hash = require "util.hashes".sha256; |
| 15 local sha256_hmac = require "util.hashes".hmac_sha256; | |
| 15 local nameprep = require "util.encodings".stringprep.nameprep; | 16 local nameprep = require "util.encodings".stringprep.nameprep; |
| 16 | 17 |
| 17 local xmlns_stream = "http://etherx.jabber.org/streams"; | 18 local xmlns_stream = "http://etherx.jabber.org/streams"; |
| 18 | 19 |
| 19 local dialback_requests = setmetatable({}, { __mode = 'v' }); | 20 local dialback_requests = setmetatable({}, { __mode = 'v' }); |
| 20 | 21 |
| 21 function generate_dialback(id, to, from) | 22 function generate_dialback(id, to, from) |
| 22 return sha256_hash(id..to..from..hosts[from].dialback_secret, true); | 23 return sha256_hmac(sha256_hash(hosts[from].dialback_secret), to .. ' ' .. from .. ' ' .. id, true); |
| 23 end | 24 end |
| 24 | 25 |
| 25 function initiate_dialback(session) | 26 function initiate_dialback(session) |
| 26 -- generate dialback key | 27 -- generate dialback key |
| 27 session.dialback_key = generate_dialback(session.streamid, session.to_host, session.from_host); | 28 session.dialback_key = generate_dialback(session.streamid, session.to_host, session.from_host); |