diff options
author | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2010-06-22 03:10:41 +1000 |
---|---|---|
committer | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2010-06-22 03:10:41 +1000 |
commit | f66f049ef342cb9b42666288d390c03e1f18e676 (patch) | |
tree | 3600d8a207259fe4e798fb24ce6d96ce6e9c3303 /src | |
parent | Added md2/1 support (diff) |
Added support for all hash functions required by XEP-0115
Diffstat (limited to 'src')
-rw-r--r-- | src/mod_caps.erl | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/mod_caps.erl b/src/mod_caps.erl index dc20a9ae3..7fb011ef9 100644 --- a/src/mod_caps.erl +++ b/src/mod_caps.erl @@ -277,10 +277,20 @@ feature_response(#iq{type = result, Host, From, Caps, [SubNode | SubNodes]) -> BinaryNode = node_to_binary(Caps#caps.node, SubNode), IsValid = case Caps#caps.hash of - "sha-1" -> - Caps#caps.version == make_disco_hash(Els, sha1); + "md2" -> + Caps#caps.version == make_disco_hash(Els, md2); "md5" -> Caps#caps.version == make_disco_hash(Els, md5); + "sha-1" -> + Caps#caps.version == make_disco_hash(Els, sha1); + "sha-224" -> + Caps#caps.version == make_disco_hash(Els, sha224); + "sha-256" -> + Caps#caps.version == make_disco_hash(Els, sha256); + "sha-384" -> + Caps#caps.version == make_disco_hash(Els, sha384); + "sha-512" -> + Caps#caps.version == make_disco_hash(Els, sha512); _ -> true end, @@ -339,15 +349,25 @@ make_my_disco_hash(Host) -> "" end. -make_disco_hash(DiscoEls, Algo) when Algo == sha1; Algo == md5 -> +make_disco_hash(DiscoEls, Algo) -> Concat = [concat_identities(DiscoEls), concat_features(DiscoEls), concat_info(DiscoEls)], base64:encode_to_string( - if Algo == sha1 -> - crypto:sha(Concat); + if Algo == md2 -> + sha:md2(Concat); Algo == md5 -> - crypto:md5(Concat) + crypto:md5(Concat); + Algo == sha1 -> + crypto:sha(Concat); + Algo == sha224 -> + sha:sha224(Concat); + Algo == sha256 -> + sha:sha256(Concat); + Algo == sha384 -> + sha:sha384(Concat); + Algo == sha512 -> + sha:sha512(Concat) end). concat_features(Els) -> |