Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Version xxx

* Increase the iteration count for SCRAM-SHA-512
[see spec](https://datatracker.ietf.org/doc/html/draft-melnikov-scram-sha-512#name-security-considerations-3)

# Version 1.8.1

* Updating fast_tls to version 1.1.19.
Expand Down
2 changes: 2 additions & 0 deletions include/scram.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@
-type scram() :: #scram{}.

-define(SCRAM_DEFAULT_ITERATION_COUNT, 4096).
% see https://datatracker.ietf.org/doc/html/draft-melnikov-scram-sha-512#name-security-considerations-3
-define(SCRAM_SHA512_ITERATION_COUNT, 10000).
7 changes: 5 additions & 2 deletions src/xmpp_sasl_scram.erl
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,19 @@ mech_step(#state{step = 2, algo = Algo, ssdp = Ssdp} = State, ClientIn) ->
base64:decode(SEK),
base64:decode(Slt), IC};
_ ->
Iterations = if Algo =:= sha512 -> ?SCRAM_SHA512_ITERATION_COUNT;
true -> ?SCRAM_DEFAULT_ITERATION_COUNT
end,
TempSalt =
p1_rand:bytes(?SALT_LENGTH),
SaltedPassword =
scram:salted_password(Algo, Pass,
TempSalt,
?SCRAM_DEFAULT_ITERATION_COUNT),
Iterations),
{scram:stored_key(Algo, scram:client_key(Algo, SaltedPassword)),
scram:server_key(Algo, SaltedPassword),
TempSalt,
?SCRAM_DEFAULT_ITERATION_COUNT}
Iterations}
end,
ClientFirstMessageBare =
substr(ClientIn,
Expand Down