25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Merge branch '2.1.x' of git+ssh://gitorious.process-one.net/ejabberd/mainline into 2.1.x

This commit is contained in:
Evgeniy Khramtsov 2011-09-05 16:53:10 +10:00
commit ab2a298ebf

View File

@ -53,29 +53,29 @@ client_signature(StoredKey, AuthMessage) ->
crypto:sha_mac(StoredKey, AuthMessage). crypto:sha_mac(StoredKey, AuthMessage).
client_key(ClientProof, ClientSignature) -> client_key(ClientProof, ClientSignature) ->
binary:list_to_bin(lists:zipwith(fun(X, Y) -> list_to_binary(lists:zipwith(fun(X, Y) ->
X bxor Y X bxor Y
end, end,
binary:bin_to_list(ClientProof), binary_to_list(ClientProof),
binary:bin_to_list(ClientSignature))). binary_to_list(ClientSignature))).
server_signature(ServerKey, AuthMessage) -> server_signature(ServerKey, AuthMessage) ->
crypto:sha_mac(ServerKey, AuthMessage). crypto:sha_mac(ServerKey, AuthMessage).
hi(Password, Salt, IterationCount) -> hi(Password, Salt, IterationCount) ->
U1 = crypto:sha_mac(Password, string:concat(binary:bin_to_list(Salt), [0,0,0,1])), U1 = crypto:sha_mac(Password, string:concat(binary_to_list(Salt), [0,0,0,1])),
binary:list_to_bin(lists:zipwith(fun(X, Y) -> list_to_binary(lists:zipwith(fun(X, Y) ->
X bxor Y X bxor Y
end, end,
binary:bin_to_list(U1), binary_to_list(U1),
binary:bin_to_list(hi_round(Password, U1, IterationCount-1)))). binary_to_list(hi_round(Password, U1, IterationCount-1)))).
hi_round(Password, UPrev, 1) -> hi_round(Password, UPrev, 1) ->
crypto:sha_mac(Password, UPrev); crypto:sha_mac(Password, UPrev);
hi_round(Password, UPrev, IterationCount) -> hi_round(Password, UPrev, IterationCount) ->
U = crypto:sha_mac(Password, UPrev), U = crypto:sha_mac(Password, UPrev),
binary:list_to_bin(lists:zipwith(fun(X, Y) -> list_to_binary(lists:zipwith(fun(X, Y) ->
X bxor Y X bxor Y
end, end,
binary:bin_to_list(U), binary_to_list(U),
binary:bin_to_list(hi_round(Password, U, IterationCount-1)))). binary_to_list(hi_round(Password, U, IterationCount-1)))).