Skip to content

Commit 204ac33

Browse files
authored
Merge pull request #111 from jpds/scram-client-proof-constant-time
Use constant-time comparison in SCRAM client proof verification
2 parents 35fc161 + 30173d9 commit 204ac33

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/xmpp_sasl_scram.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ mech_step(#state{step = 4, algo = Algo} = State, ClientIn) ->
235235
ClientKey =
236236
scram:client_key_xor(ClientProof, ClientSignature),
237237
CompareStoredKey = scram:stored_key(Algo, ClientKey),
238-
if
239-
CompareStoredKey == State#state.stored_key ->
238+
case crypto:hash_equals(CompareStoredKey, State#state.stored_key) of
239+
true ->
240240
ServerSignature =
241241
scram:server_signature(Algo,
242242
State#state.server_key,
@@ -245,7 +245,7 @@ mech_step(#state{step = 4, algo = Algo} = State, ClientIn) ->
245245
{auth_module, State#state.auth_module},
246246
{authzid, State#state.username}],
247247
<<"v=", (base64:encode(ServerSignature))/binary>>};
248-
true ->
248+
false ->
249249
{error, not_authorized, State#state.username}
250250
end
251251
end;

0 commit comments

Comments
 (0)