]> granicus.if.org Git - transmission/commitdiff
Abort handshake if establishing DH shared secret fails
authorMike Gelfand <mikedld@mikedld.com>
Sun, 18 Sep 2016 10:58:15 +0000 (13:58 +0300)
committerMike Gelfand <mikedld@mikedld.com>
Mon, 15 Jan 2018 20:51:44 +0000 (23:51 +0300)
Fixes #27

libtransmission/handshake.c

index 4367fbbcaf5b5509cee49902548bf630c54be3c6..8dc08d39e4c251cd7f9cfa56f3e1ced1ef82e91c 100644 (file)
@@ -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) */
@@ -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 */