aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Lemenkov <lemenkov@gmail.com>2017-02-13 18:35:57 +0300
committerPeter Lemenkov <lemenkov@gmail.com>2017-02-13 18:42:50 +0300
commite7733ce7d97376bf41d0c683ce3888838a7ea985 (patch)
treeb5151424a014b0697a0f7663d54fc22e588faf09 /src
parentCheck result of gen_mod:start/2 callback (#1534) (diff)
Use crypto:hash/2 function
Use crypto:hash/2 function instead of ones from p1_sha. This function exists since commit erlang/otp@208f9ad3828313f6c659a501d53f5534ec1bdf2e and also implemented as NIF, so I believe it's safe to use it. Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/ejabberd_websocket.erl2
-rw-r--r--src/mod_admin_extra.erl2
-rw-r--r--src/mod_caps.erl10
-rw-r--r--src/scram.erl2
4 files changed, 8 insertions, 8 deletions
diff --git a/src/ejabberd_websocket.erl b/src/ejabberd_websocket.erl
index d87bf9bb1..61d314089 100644
--- a/src/ejabberd_websocket.erl
+++ b/src/ejabberd_websocket.erl
@@ -153,7 +153,7 @@ handshake(#ws{headers = Headers} = State) ->
[<<"Sec-Websocket-Protocol:">>, V, <<"\r\n">>]
end,
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">>,
<<"Upgrade: websocket\r\n">>,
<<"Connection: Upgrade\r\n">>,
diff --git a/src/mod_admin_extra.erl b/src/mod_admin_extra.erl
index 472e9fbe3..9139f1e47 100644
--- a/src/mod_admin_extra.erl
+++ b/src/mod_admin_extra.erl
@@ -734,7 +734,7 @@ get_md5(AccountPass) ->
|| X <- binary_to_list(erlang:md5(AccountPass))]).
get_sha(AccountPass) ->
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) ->
DB_Type = gen_mod:db_type(Host, mod_last),
diff --git a/src/mod_caps.erl b/src/mod_caps.erl
index 391a3ba74..d8438ebe0 100644
--- a/src/mod_caps.erl
+++ b/src/mod_caps.erl
@@ -409,11 +409,11 @@ make_disco_hash(DiscoInfo, Algo) ->
concat_features(DiscoInfo), concat_info(DiscoInfo)]),
jlib:encode_base64(case Algo of
md5 -> erlang:md5(Concat);
- sha -> p1_sha:sha1(Concat);
- sha224 -> p1_sha:sha224(Concat);
- sha256 -> p1_sha:sha256(Concat);
- sha384 -> p1_sha:sha384(Concat);
- sha512 -> p1_sha:sha512(Concat)
+ sha -> crypto:hash(sha, Concat);
+ sha224 -> crypto:hash(sha224, Concat);
+ sha256 -> crypto:hash(sha256, Concat);
+ sha384 -> crypto:hash(sha384, Concat);
+ sha512 -> crypto:hash(sha512, Concat)
end).
-spec check_hash(caps(), disco_info()) -> boolean().
diff --git a/src/scram.erl b/src/scram.erl
index ee7960475..f2875e4ab 100644
--- a/src/scram.erl
+++ b/src/scram.erl
@@ -45,7 +45,7 @@ client_key(SaltedPassword) ->
-spec stored_key(binary()) -> binary().
-stored_key(ClientKey) -> p1_sha:sha1(ClientKey).
+stored_key(ClientKey) -> crypto:hash(sha, ClientKey).
-spec server_key(binary()) -> binary().