summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Nilsson <hans@erlang.org>2020-01-08 12:57:50 +0100
committerHans Nilsson <hans@erlang.org>2020-01-08 15:40:24 +0100
commitd4bab14d06503a133aec2afc9d829c6562206d6a (patch)
treed635782405038f10aedd39cabe4f022464dff0db
parent850d016a2de739bf58dc588c13fe378debf758e1 (diff)
downloaderlang-d4bab14d06503a133aec2afc9d829c6562206d6a.tar.gz
ssh: Use constant time comparision in some places
-rw-r--r--lib/ssh/src/ssh_auth.erl2
-rw-r--r--lib/ssh/src/ssh_transport.erl2
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/ssh/src/ssh_auth.erl b/lib/ssh/src/ssh_auth.erl
index 03d264745b..6d9373e9db 100644
--- a/lib/ssh/src/ssh_auth.erl
+++ b/lib/ssh/src/ssh_auth.erl
@@ -473,7 +473,7 @@ check_password(User, Password, Opts, Ssh) ->
case ?GET_OPT(pwdfun, Opts) of
undefined ->
Static = get_password_option(Opts, User),
- {Password == Static, Ssh};
+ {crypto:equal_const_time(Password,Static), Ssh};
Checker when is_function(Checker,2) ->
{Checker(User, Password), Ssh};
diff --git a/lib/ssh/src/ssh_transport.erl b/lib/ssh/src/ssh_transport.erl
index 6820f534cb..313593c680 100644
--- a/lib/ssh/src/ssh_transport.erl
+++ b/lib/ssh/src/ssh_transport.erl
@@ -222,7 +222,7 @@ is_valid_mac(_, _ , #ssh{recv_mac_size = 0}) ->
true;
is_valid_mac(Mac, Data, #ssh{recv_mac = Algorithm,
recv_mac_key = Key, recv_sequence = SeqNum}) ->
- Mac == mac(Algorithm, Key, SeqNum, Data).
+ crypto:equal_const_time(Mac, mac(Algorithm, Key, SeqNum, Data)).
format_version({Major,Minor}, SoftwareVersion) ->
"SSH-" ++ integer_to_list(Major) ++ "." ++