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) ->