25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-30 16:36:29 +01:00

Merge pull request #1539 from lemenkov/use_crypto_sha

RFE: Use crypto:hash/2 function
This commit is contained in:
Evgeny Khramtsov 2017-02-14 11:38:05 +04:00 committed by GitHub
commit a1e45ab56c
4 changed files with 8 additions and 8 deletions

View File

@ -153,7 +153,7 @@ handshake(#ws{headers = Headers} = State) ->
[<<"Sec-Websocket-Protocol:">>, V, <<"\r\n">>] [<<"Sec-Websocket-Protocol:">>, V, <<"\r\n">>]
end, end,
Hash = jlib:encode_base64( Hash = jlib:encode_base64(
p1_sha:sha1(<<Key/binary, "258EAFA5-E914-47DA-95CA-C5AB0DC85B11">>)), crypto:hash(sha, <<Key/binary, "258EAFA5-E914-47DA-95CA-C5AB0DC85B11">>)),
{State, [<<"HTTP/1.1 101 Switching Protocols\r\n">>, {State, [<<"HTTP/1.1 101 Switching Protocols\r\n">>,
<<"Upgrade: websocket\r\n">>, <<"Upgrade: websocket\r\n">>,
<<"Connection: Upgrade\r\n">>, <<"Connection: Upgrade\r\n">>,

View File

@ -734,7 +734,7 @@ get_md5(AccountPass) ->
|| X <- binary_to_list(erlang:md5(AccountPass))]). || X <- binary_to_list(erlang:md5(AccountPass))]).
get_sha(AccountPass) -> get_sha(AccountPass) ->
iolist_to_binary([io_lib:format("~2.16.0B", [X]) iolist_to_binary([io_lib:format("~2.16.0B", [X])
|| X <- binary_to_list(p1_sha:sha1(AccountPass))]). || X <- binary_to_list(crypto:hash(sha, AccountPass))]).
num_active_users(Host, Days) -> num_active_users(Host, Days) ->
DB_Type = gen_mod:db_type(Host, mod_last), DB_Type = gen_mod:db_type(Host, mod_last),

View File

@ -409,11 +409,11 @@ make_disco_hash(DiscoInfo, Algo) ->
concat_features(DiscoInfo), concat_info(DiscoInfo)]), concat_features(DiscoInfo), concat_info(DiscoInfo)]),
jlib:encode_base64(case Algo of jlib:encode_base64(case Algo of
md5 -> erlang:md5(Concat); md5 -> erlang:md5(Concat);
sha -> p1_sha:sha1(Concat); sha -> crypto:hash(sha, Concat);
sha224 -> p1_sha:sha224(Concat); sha224 -> crypto:hash(sha224, Concat);
sha256 -> p1_sha:sha256(Concat); sha256 -> crypto:hash(sha256, Concat);
sha384 -> p1_sha:sha384(Concat); sha384 -> crypto:hash(sha384, Concat);
sha512 -> p1_sha:sha512(Concat) sha512 -> crypto:hash(sha512, Concat)
end). end).
-spec check_hash(caps(), disco_info()) -> boolean(). -spec check_hash(caps(), disco_info()) -> boolean().

View File

@ -45,7 +45,7 @@ client_key(SaltedPassword) ->
-spec stored_key(binary()) -> binary(). -spec stored_key(binary()) -> binary().
stored_key(ClientKey) -> p1_sha:sha1(ClientKey). stored_key(ClientKey) -> crypto:hash(sha, ClientKey).
-spec server_key(binary()) -> binary(). -spec server_key(binary()) -> binary().