summaryrefslogtreecommitdiff
path: root/src/scram.erl
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-01-17 22:37:44 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-01-17 22:37:44 +0300
commit9021ba01ac5fa2dda762cdf187f77ae9727bf10a (patch)
tree9fd4fa855d029c068ca2aa46e1e6675e76e4f1b7 /src/scram.erl
parentReset XML stream before sending SASL <success/> (diff)
Use crypto:exor/2 instead of hand-crafted bxor
Diffstat (limited to 'src/scram.erl')
-rw-r--r--src/scram.erl14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/scram.erl b/src/scram.erl
index 2c4d265b..1c1c28ec 100644
--- a/src/scram.erl
+++ b/src/scram.erl
@@ -60,9 +60,7 @@ client_signature(StoredKey, AuthMessage) ->
-spec client_key(binary(), binary()) -> binary().
client_key(ClientProof, ClientSignature) ->
- list_to_binary(lists:zipwith(fun (X, Y) -> X bxor Y end,
- binary_to_list(ClientProof),
- binary_to_list(ClientSignature))).
+ crypto:exor(ClientProof, ClientSignature).
-spec server_signature(binary(), binary()) -> binary().
@@ -71,19 +69,13 @@ server_signature(ServerKey, AuthMessage) ->
hi(Password, Salt, IterationCount) ->
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)))).
+ crypto:exor(U1, hi_round(Password, U1, IterationCount - 1)).
hi_round(Password, UPrev, 1) ->
sha_mac(Password, UPrev);
hi_round(Password, UPrev, IterationCount) ->
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)))).
+ crypto:exor(U, hi_round(Password, U, IterationCount - 1)).
sha_mac(Key, Data) ->
crypto:hmac(sha, Key, Data).