]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Merge branch 'maint-0.2.8'
authorNick Mathewson <nickm@torproject.org>
Tue, 14 Jun 2016 16:17:24 +0000 (12:17 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 14 Jun 2016 16:17:24 +0000 (12:17 -0400)
1  2 
src/common/crypto.c
src/common/tortls.c
src/test/test_tortls.c
src/tools/tor-gencert.c

index 76e262e2575c7c344a60c8a45f8e1046eedadb0b,614f9b5de911ecdc6ca9ae9b7981d6697b848bdd..4df674bee65c4002d13c0e429ea03d77276994d8
@@@ -2311,17 -2387,27 +2396,32 @@@ crypto_dh_get_bytes(crypto_dh_t *dh
  int
  crypto_dh_generate_public(crypto_dh_t *dh)
  {
+ #ifndef OPENSSL_1_1_API
   again:
+ #endif
    if (!DH_generate_key(dh->dh)) {
 +    /* LCOV_EXCL_START
 +     * To test this we would need some way to tell openssl to break DH. */
      crypto_log_errors(LOG_WARN, "generating DH key");
      return -1;
 +    /* LCOV_EXCL_STOP */
    }
+ #ifdef OPENSSL_1_1_API
+   /* OpenSSL 1.1.x doesn't appear to let you regenerate a DH key, without
+    * recreating the DH object.  I have no idea what sort of aliasing madness
+    * can occur here, so do the check, and just bail on failure.
+    */
+   BIGNUM *pub_key, *priv_key;
+   DH_get0_key(dh->dh, &pub_key, &priv_key);
+   if (tor_check_dh_key(LOG_WARN, pub_key)<0) {
+     log_warn(LD_CRYPTO, "Weird! Our own DH key was invalid.  I guess once-in-"
+              "the-universe chances really do happen.  Treating as a failure.");
+     return -1;
+   }
+ #else
    if (tor_check_dh_key(LOG_WARN, dh->dh->pub_key)<0) {
 +    /* LCOV_EXCL_START
 +     * If this happens, then openssl's DH implementation is busted. */
      log_warn(LD_CRYPTO, "Weird! Our own DH key was invalid.  I guess once-in-"
               "the-universe chances really do happen.  Trying again.");
      /* Free and clear the keys, so OpenSSL will actually try again. */
      BN_clear_free(dh->dh->priv_key);
      dh->dh->pub_key = dh->dh->priv_key = NULL;
      goto again;
 +    /* LCOV_EXCL_STOP */
    }
+ #endif
    return 0;
  }
  
Simple merge
Simple merge
Simple merge