]> granicus.if.org Git - ejabberd/commitdiff
Do not use functions from crypto module wherever possible
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Tue, 5 Nov 2013 10:05:12 +0000 (20:05 +1000)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Tue, 5 Nov 2013 10:07:38 +0000 (20:07 +1000)
src/cyrsasl_digest.erl
src/ejabberd_http_poll.erl
src/ejabberd_web_admin.erl
src/mod_caps.erl
src/scram.erl
test/suite.erl

index 3f7133943fc4d7a2dd5a20c1a0e44d31b2813afa..b837a2e258404e39b965ae8fcb6347c968c2d0d7 100644 (file)
@@ -237,7 +237,7 @@ response(KeyVals, User, Passwd, Nonce, AuthzId,
     DigestURI = proplists_get_bin_value(<<"digest-uri">>, KeyVals, <<>>),
     NC = proplists_get_bin_value(<<"nc">>, KeyVals, <<>>),
     QOP = proplists_get_bin_value(<<"qop">>, KeyVals, <<>>),
-    MD5Hash = crypto:md5(<<User/binary, ":", Realm/binary, ":",
+    MD5Hash = erlang:md5(<<User/binary, ":", Realm/binary, ":",
                            Passwd/binary>>),
     A1 = case AuthzId of
           <<"">> ->
@@ -253,7 +253,7 @@ response(KeyVals, User, Passwd, Nonce, AuthzId,
               <<A2Prefix/binary, ":", DigestURI/binary,
                 ":00000000000000000000000000000000">>
         end,
-    T = <<(hex((crypto:md5(A1))))/binary, ":", Nonce/binary,
+    T = <<(hex((erlang:md5(A1))))/binary, ":", Nonce/binary,
          ":", NC/binary, ":", CNonce/binary, ":", QOP/binary,
-         ":", (hex((crypto:md5(A2))))/binary>>,
-    hex((crypto:md5(T))).
+         ":", (hex((erlang:md5(A2))))/binary>>,
+    hex((erlang:md5(T))).
index 480d04ec2508f4098ff3752459380da7cf3c1587..a00e690e271d9fd69f4b8b797facee24590ad164 100644 (file)
@@ -284,7 +284,7 @@ handle_sync_event({http_put, Key, NewKey, Packet},
     Allow = case StateData#state.key of
              <<"">> -> true;
              OldKey ->
-                 NextKey = jlib:encode_base64((crypto:sha(Key))),
+                 NextKey = jlib:encode_base64((p1_sha:sha1(Key))),
                  if OldKey == NextKey -> true;
                     true -> false
                  end
index 02f653f585ec1700f076380a18503449909822ca..5744a08665e363560eb5d653f89f9e1cd49a2ebc 100644 (file)
@@ -2447,7 +2447,7 @@ get_port_data(PortIP, Opts) ->
                                  io_lib:format("~.16b", [N])
                          end,
                          binary_to_list(
-                           crypto:md5(
+                           erlang:md5(
                              [SPort, IPS, atom_to_list(NetProt)])))),
     {Port, SPort, IPT, IPS, SSPort, NetProt, OptsClean}.
 
index 513eaa45078b49e6875e1d18fcc9f98ca2e7bd4d..ac115d64627d1f19f0fb86c941eaf972f81d1872 100644 (file)
@@ -467,8 +467,8 @@ make_disco_hash(DiscoEls, Algo) ->
     Concat = list_to_binary([concat_identities(DiscoEls),
                              concat_features(DiscoEls), concat_info(DiscoEls)]),
     jlib:encode_base64(case Algo of
-                           md5 -> crypto:md5(Concat);
-                           sha1 -> crypto:sha(Concat);
+                           md5 -> erlang:md5(Concat);
+                           sha1 -> p1_sha:sha1(Concat);
                            sha224 -> p1_sha:sha224(Concat);
                            sha256 -> p1_sha:sha256(Concat);
                            sha384 -> p1_sha:sha384(Concat);
index 94b3324fdefb486c497cda43a752e3e72a34068b..407f69d2f6d71071cef48025ed9607eecf89f99f 100644 (file)
@@ -46,7 +46,7 @@ client_key(SaltedPassword) ->
 
 -spec stored_key(binary()) -> binary().
 
-stored_key(ClientKey) -> crypto:sha(ClientKey).
+stored_key(ClientKey) -> p1_sha:sha1(ClientKey).
 
 -spec server_key(binary()) -> binary().
 
index 8104df75e3cca6087c118902c8d4390d01472260..c35592c80aa0091c652d5c690f74d5ddb1ca1f1a 100644 (file)
@@ -254,11 +254,11 @@ response(User, Passwd, Nonce, AuthzId, Realm, CNonce,
         DigestURI, NC, QOP, A2Prefix) ->
     A1 = case AuthzId of
           <<"">> ->
-              <<((crypto:md5(<<User/binary, ":", Realm/binary, ":",
+              <<((erlang:md5(<<User/binary, ":", Realm/binary, ":",
                                Passwd/binary>>)))/binary,
                 ":", Nonce/binary, ":", CNonce/binary>>;
           _ ->
-              <<((crypto:md5(<<User/binary, ":", Realm/binary, ":",
+              <<((erlang:md5(<<User/binary, ":", Realm/binary, ":",
                                Passwd/binary>>)))/binary,
                 ":", Nonce/binary, ":", CNonce/binary, ":",
                 AuthzId/binary>>
@@ -270,10 +270,10 @@ response(User, Passwd, Nonce, AuthzId, Realm, CNonce,
               <<A2Prefix/binary, ":", DigestURI/binary,
                 ":00000000000000000000000000000000">>
         end,
-    T = <<(hex((crypto:md5(A1))))/binary, ":", Nonce/binary,
+    T = <<(hex((erlang:md5(A1))))/binary, ":", Nonce/binary,
          ":", NC/binary, ":", CNonce/binary, ":", QOP/binary,
-         ":", (hex((crypto:md5(A2))))/binary>>,
-    hex((crypto:md5(T))).
+         ":", (hex((erlang:md5(A2))))/binary>>,
+    hex((erlang:md5(T))).
 
 my_jid(Config) ->
     jlib:make_jid(?config(user, Config),