Skip to content

Commit

Permalink
Abort handshake if establishing DH shared secret fails
Browse files Browse the repository at this point in the history
Fixes #27
  • Loading branch information
mikedld committed Jan 15, 2018
1 parent 67ef7b8 commit 7cc4cfb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libtransmission/handshake.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ readYb (tr_handshake * handshake, struct evbuffer * inbuf)

/* compute the secret */
evbuffer_remove (inbuf, yb, KEY_LEN);
tr_cryptoComputeSecret (handshake->crypto, yb);
if (!tr_cryptoComputeSecret (handshake->crypto, yb))
return tr_handshakeDone (handshake, false);

/* now send these: HASH ('req1', S), HASH ('req2', SKEY) xor HASH ('req3', S),
* ENCRYPT (VC, crypto_provide, len (PadC), PadC, len (IA)), ENCRYPT (IA) */
Expand Down Expand Up @@ -742,7 +743,9 @@ readYa (tr_handshake * handshake,

/* read the incoming peer's public key */
evbuffer_remove (inbuf, ya, KEY_LEN);
tr_cryptoComputeSecret (handshake->crypto, ya);
if (!tr_cryptoComputeSecret (handshake->crypto, ya))
return tr_handshakeDone (handshake, false);

computeRequestHash (handshake, "req1", handshake->myReq1);

/* send our public key to the peer */
Expand Down

0 comments on commit 7cc4cfb

Please sign in to comment.