diff options
author | Hans Nilsson <[email protected]> | 2015-08-03 16:50:53 +0200 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2015-08-03 16:53:17 +0200 |
commit | ec0da994d1c223cc7b1fde18061464a6c44cdf0b (patch) | |
tree | f631c39666605fbab441be7e3f5d6a899fac941b /lib/ssh/src/ssh_transport.erl | |
parent | d964a7bfb9b87bf69f8a131aea517f4f0bfdfdd1 (diff) | |
download | otp-ec0da994d1c223cc7b1fde18061464a6c44cdf0b.tar.gz otp-ec0da994d1c223cc7b1fde18061464a6c44cdf0b.tar.bz2 otp-ec0da994d1c223cc7b1fde18061464a6c44cdf0b.zip |
ssh: rm ssh_math and use crypto:compute_key instead
Diffstat (limited to 'lib/ssh/src/ssh_transport.erl')
-rw-r--r-- | lib/ssh/src/ssh_transport.erl | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/ssh/src/ssh_transport.erl b/lib/ssh/src/ssh_transport.erl index a0a0217fe2..74e25e1641 100644 --- a/lib/ssh/src/ssh_transport.erl +++ b/lib/ssh/src/ssh_transport.erl @@ -336,7 +336,7 @@ handle_kexdh_init(#ssh_msg_kexdh_init{e = E}, Ssh0) -> if 1=<E, E=<(P-1) -> {Private, Public} = dh_gen_key(G, P, 1024), - K = ssh_math:ipow(E, Private, P), + K = dh_compute_key(G, P, E, Private), Key = get_host_key(Ssh0), H = kex_h(Ssh0, Key, E, Public, K), H_SIG = sign_host_key(Ssh0, Key, H), @@ -361,11 +361,11 @@ handle_kexdh_init(#ssh_msg_kexdh_init{e = E}, Ssh0) -> handle_kexdh_reply(#ssh_msg_kexdh_reply{public_host_key = HostKey, f = F, h_sig = H_SIG}, - #ssh{keyex_key = {{Private, Public}, {_G, P}}} = Ssh0) -> + #ssh{keyex_key = {{Private, Public}, {G, P}}} = Ssh0) -> %% client if 1=<F, F=<(P-1)-> - K = ssh_math:ipow(F, Private, P), + K = dh_compute_key(G, P, F, Private), H = kex_h(Ssh0, HostKey, Public, F, K), case verify_host_key(Ssh0, HostKey, H, H_SIG) of @@ -426,7 +426,7 @@ handle_kex_dh_gex_init(#ssh_msg_kex_dh_gex_init{e = E}, %% server if 1=<E, E=<(P-1) -> - K = ssh_math:ipow(E, Private, P), + K = dh_compute_key(G, P, E, Private), if 1<K, K<(P-1) -> HostKey = get_host_key(Ssh0), @@ -466,7 +466,7 @@ handle_kex_dh_gex_reply(#ssh_msg_kex_dh_gex_reply{public_host_key = HostKey, %% client if 1=<F, F=<(P-1)-> - K = ssh_math:ipow(F, Private, P), + K = dh_compute_key(G, P, F, Private), if 1<K, K<(P-1) -> H = kex_h(Ssh0, HostKey, Min, NBits, Max, P, G, Public, F, K), @@ -1212,6 +1212,11 @@ dh_gen_key(G, P, _) -> {Public, Private} = crypto:generate_key(dh, [P, G]), {crypto:bytes_to_integer(Private), crypto:bytes_to_integer(Public)}. +dh_compute_key(G, P, OthersPublic, MyPrivate) -> + crypto:bytes_to_integer( + crypto:compute_key(dh, OthersPublic, MyPrivate, [P,G]) + ). + trim_tail(Str) -> lists:reverse(trim_head(lists:reverse(Str))). |