aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/scram.erl17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/scram.erl b/src/scram.erl
index c8c85e8d5..3069be466 100644
--- a/src/scram.erl
+++ b/src/scram.erl
@@ -41,7 +41,7 @@ salted_password(Password, Salt, IterationCount) ->
-spec client_key(binary()) -> binary().
client_key(SaltedPassword) ->
- crypto:sha_mac(SaltedPassword, <<"Client Key">>).
+ sha_mac(SaltedPassword, <<"Client Key">>).
-spec stored_key(binary()) -> binary().
@@ -50,12 +50,12 @@ stored_key(ClientKey) -> p1_sha:sha1(ClientKey).
-spec server_key(binary()) -> binary().
server_key(SaltedPassword) ->
- crypto:sha_mac(SaltedPassword, <<"Server Key">>).
+ sha_mac(SaltedPassword, <<"Server Key">>).
-spec client_signature(binary(), binary()) -> binary().
client_signature(StoredKey, AuthMessage) ->
- crypto:sha_mac(StoredKey, AuthMessage).
+ sha_mac(StoredKey, AuthMessage).
-spec client_key(binary(), binary()) -> binary().
@@ -67,20 +67,23 @@ client_key(ClientProof, ClientSignature) ->
-spec server_signature(binary(), binary()) -> binary().
server_signature(ServerKey, AuthMessage) ->
- crypto:sha_mac(ServerKey, AuthMessage).
+ sha_mac(ServerKey, AuthMessage).
hi(Password, Salt, IterationCount) ->
- U1 = crypto:sha_mac(Password, <<Salt/binary, 0, 0, 0, 1>>),
+ U1 = sha_mac(Password, <<Salt/binary, 0, 0, 0, 1>>),
list_to_binary(lists:zipwith(fun (X, Y) -> X bxor Y end,
binary_to_list(U1),
binary_to_list(hi_round(Password, U1,
IterationCount - 1)))).
hi_round(Password, UPrev, 1) ->
- crypto:sha_mac(Password, UPrev);
+ sha_mac(Password, UPrev);
hi_round(Password, UPrev, IterationCount) ->
- U = crypto:sha_mac(Password, UPrev),
+ U = sha_mac(Password, UPrev),
list_to_binary(lists:zipwith(fun (X, Y) -> X bxor Y end,
binary_to_list(U),
binary_to_list(hi_round(Password, U,
IterationCount - 1)))).
+
+sha_mac(Key, Data) ->
+ crypto:hmac(sha, Key, Data).