diff options
author | Alex Auvolat <alex@adnab.me> | 2018-10-10 17:24:00 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2018-10-10 17:24:00 +0200 |
commit | 062faf49cbd98fc7ef68f8387a18c5a0a131025e (patch) | |
tree | 3cd55898ab518ac1f0188df2bebae477439ed47a /shard/lib/net | |
parent | 7bdd60c7f99df417b2589f0e99ff16abc8e925c5 (diff) | |
download | shard-062faf49cbd98fc7ef68f8387a18c5a0a131025e.tar.gz shard-062faf49cbd98fc7ef68f8387a18c5a0a131025e.zip |
Fixes, and I think it works not too bad at the moment.
Diffstat (limited to 'shard/lib/net')
-rw-r--r-- | shard/lib/net/tcpconn.ex | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/shard/lib/net/tcpconn.ex b/shard/lib/net/tcpconn.ex index aaab9e1..5dbf42b 100644 --- a/shard/lib/net/tcpconn.ex +++ b/shard/lib/net/tcpconn.ex @@ -118,7 +118,7 @@ defmodule SNet.TCPConn do {:ok, srv_accept} = :gen_tcp.recv(socket, 0) key4 = :crypto.hash(:sha256, net_key <> sh_sec_ab <> sh_sec_aB <> sh_sec_Ab) {:ok, det_sign_B} = :enacl.secretbox_open(srv_accept, <<0 :: 24*8>>, key4) - true = :enacl.sign_verify_detached(det_sign_B, net_key <> det_sign_A <> cli_longterm_pk <> :crypto.hash(:sha256, sh_sec_ab), srv_longterm_pk) + {:ok, _} = :enacl.sign_verify_detached(det_sign_B, net_key <> det_sign_A <> cli_longterm_pk <> :crypto.hash(:sha256, sh_sec_ab), srv_longterm_pk) # Derive secrets and initial nonces for stream communication secret_common = :crypto.hash(:sha256, :crypto.hash(:sha256, net_key <> sh_sec_ab <> sh_sec_aB <> sh_sec_Ab)) @@ -219,7 +219,7 @@ defmodule SNet.TCPConn do 96 = byte_size cli_auth_plain det_sign_A = :binary.part(cli_auth_plain, 0, 64) cli_longterm_pk = :binary.part(cli_auth_plain, 64, 32) - true = :enacl.sign_verify_detached(det_sign_A, net_key <> srv_longterm_pk <> :crypto.hash(:sha256, sh_sec_ab), cli_longterm_pk) + {:ok, _} = :enacl.sign_verify_detached(det_sign_A, net_key <> srv_longterm_pk <> :crypto.hash(:sha256, sh_sec_ab), cli_longterm_pk) # Shared secret derivation sh_sec_Ab = :enacl.curve25519_scalarmult(srv_eph_sk, :enacl.crypto_sign_ed25519_public_to_curve25519(cli_longterm_pk)) |