25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

Do not use functions from crypto module wherever possible

This commit is contained in:
Evgeniy Khramtsov 2013-11-05 20:05:12 +10:00
parent b7c7d2747b
commit a87b475361
6 changed files with 14 additions and 14 deletions

View File

@ -237,7 +237,7 @@ response(KeyVals, User, Passwd, Nonce, AuthzId,
DigestURI = proplists_get_bin_value(<<"digest-uri">>, KeyVals, <<>>), DigestURI = proplists_get_bin_value(<<"digest-uri">>, KeyVals, <<>>),
NC = proplists_get_bin_value(<<"nc">>, KeyVals, <<>>), NC = proplists_get_bin_value(<<"nc">>, KeyVals, <<>>),
QOP = proplists_get_bin_value(<<"qop">>, KeyVals, <<>>), QOP = proplists_get_bin_value(<<"qop">>, KeyVals, <<>>),
MD5Hash = crypto:md5(<<User/binary, ":", Realm/binary, ":", MD5Hash = erlang:md5(<<User/binary, ":", Realm/binary, ":",
Passwd/binary>>), Passwd/binary>>),
A1 = case AuthzId of A1 = case AuthzId of
<<"">> -> <<"">> ->
@ -253,7 +253,7 @@ response(KeyVals, User, Passwd, Nonce, AuthzId,
<<A2Prefix/binary, ":", DigestURI/binary, <<A2Prefix/binary, ":", DigestURI/binary,
":00000000000000000000000000000000">> ":00000000000000000000000000000000">>
end, end,
T = <<(hex((crypto:md5(A1))))/binary, ":", Nonce/binary, T = <<(hex((erlang:md5(A1))))/binary, ":", Nonce/binary,
":", NC/binary, ":", CNonce/binary, ":", QOP/binary, ":", NC/binary, ":", CNonce/binary, ":", QOP/binary,
":", (hex((crypto:md5(A2))))/binary>>, ":", (hex((erlang:md5(A2))))/binary>>,
hex((crypto:md5(T))). hex((erlang:md5(T))).

View File

@ -284,7 +284,7 @@ handle_sync_event({http_put, Key, NewKey, Packet},
Allow = case StateData#state.key of Allow = case StateData#state.key of
<<"">> -> true; <<"">> -> true;
OldKey -> OldKey ->
NextKey = jlib:encode_base64((crypto:sha(Key))), NextKey = jlib:encode_base64((p1_sha:sha1(Key))),
if OldKey == NextKey -> true; if OldKey == NextKey -> true;
true -> false true -> false
end end

View File

@ -2447,7 +2447,7 @@ get_port_data(PortIP, Opts) ->
io_lib:format("~.16b", [N]) io_lib:format("~.16b", [N])
end, end,
binary_to_list( binary_to_list(
crypto:md5( erlang:md5(
[SPort, IPS, atom_to_list(NetProt)])))), [SPort, IPS, atom_to_list(NetProt)])))),
{Port, SPort, IPT, IPS, SSPort, NetProt, OptsClean}. {Port, SPort, IPT, IPS, SSPort, NetProt, OptsClean}.

View File

@ -467,8 +467,8 @@ make_disco_hash(DiscoEls, Algo) ->
Concat = list_to_binary([concat_identities(DiscoEls), Concat = list_to_binary([concat_identities(DiscoEls),
concat_features(DiscoEls), concat_info(DiscoEls)]), concat_features(DiscoEls), concat_info(DiscoEls)]),
jlib:encode_base64(case Algo of jlib:encode_base64(case Algo of
md5 -> crypto:md5(Concat); md5 -> erlang:md5(Concat);
sha1 -> crypto:sha(Concat); sha1 -> p1_sha:sha1(Concat);
sha224 -> p1_sha:sha224(Concat); sha224 -> p1_sha:sha224(Concat);
sha256 -> p1_sha:sha256(Concat); sha256 -> p1_sha:sha256(Concat);
sha384 -> p1_sha:sha384(Concat); sha384 -> p1_sha:sha384(Concat);

View File

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

View File

@ -254,11 +254,11 @@ response(User, Passwd, Nonce, AuthzId, Realm, CNonce,
DigestURI, NC, QOP, A2Prefix) -> DigestURI, NC, QOP, A2Prefix) ->
A1 = case AuthzId of A1 = case AuthzId of
<<"">> -> <<"">> ->
<<((crypto:md5(<<User/binary, ":", Realm/binary, ":", <<((erlang:md5(<<User/binary, ":", Realm/binary, ":",
Passwd/binary>>)))/binary, Passwd/binary>>)))/binary,
":", Nonce/binary, ":", CNonce/binary>>; ":", Nonce/binary, ":", CNonce/binary>>;
_ -> _ ->
<<((crypto:md5(<<User/binary, ":", Realm/binary, ":", <<((erlang:md5(<<User/binary, ":", Realm/binary, ":",
Passwd/binary>>)))/binary, Passwd/binary>>)))/binary,
":", Nonce/binary, ":", CNonce/binary, ":", ":", Nonce/binary, ":", CNonce/binary, ":",
AuthzId/binary>> AuthzId/binary>>
@ -270,10 +270,10 @@ response(User, Passwd, Nonce, AuthzId, Realm, CNonce,
<<A2Prefix/binary, ":", DigestURI/binary, <<A2Prefix/binary, ":", DigestURI/binary,
":00000000000000000000000000000000">> ":00000000000000000000000000000000">>
end, end,
T = <<(hex((crypto:md5(A1))))/binary, ":", Nonce/binary, T = <<(hex((erlang:md5(A1))))/binary, ":", Nonce/binary,
":", NC/binary, ":", CNonce/binary, ":", QOP/binary, ":", NC/binary, ":", CNonce/binary, ":", QOP/binary,
":", (hex((crypto:md5(A2))))/binary>>, ":", (hex((erlang:md5(A2))))/binary>>,
hex((crypto:md5(T))). hex((erlang:md5(T))).
my_jid(Config) -> my_jid(Config) ->
jlib:make_jid(?config(user, Config), jlib:make_jid(?config(user, Config),